summaryrefslogtreecommitdiffstats
path: root/drm-dp-mst-error-handling-improvements.patch
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2020-03-09 17:26:45 +0100
committerHans de Goede <hdegoede@redhat.com>2020-03-09 17:26:45 +0100
commit3256dcb620f0b7e4e1c231c093ca3ca5b35f3433 (patch)
treee9d9d49f362fdee4064eebacde31e885cb58666f /drm-dp-mst-error-handling-improvements.patch
parentb128fdd3ea05ed50981620db8d1bbdad66786d68 (diff)
downloadkernel-3256dcb620f0b7e4e1c231c093ca3ca5b35f3433.tar.gz
kernel-3256dcb620f0b7e4e1c231c093ca3ca5b35f3433.tar.xz
kernel-3256dcb620f0b7e4e1c231c093ca3ca5b35f3433.zip
Fix only 1 monitor working on DP-MST docking stations (rhbz 1809681)
Fix backtraces on various buggy BIOS-es (rhbz 1564895, 1808874) Add /etc/modprobe.d/floppy-blacklist.conf to fix auto-loading of the legacy floppy driver (rhbz 1789155)
Diffstat (limited to 'drm-dp-mst-error-handling-improvements.patch')
-rw-r--r--drm-dp-mst-error-handling-improvements.patch471
1 files changed, 471 insertions, 0 deletions
diff --git a/drm-dp-mst-error-handling-improvements.patch b/drm-dp-mst-error-handling-improvements.patch
new file mode 100644
index 000000000..91e396940
--- /dev/null
+++ b/drm-dp-mst-error-handling-improvements.patch
@@ -0,0 +1,471 @@
+From 52bd42038880354565bd5ca0bcc1d24b15136b0d Mon Sep 17 00:00:00 2001
+From: Benjamin Gaignard <benjamin.gaignard@st.com>
+Date: Wed, 5 Feb 2020 09:48:42 +0100
+Subject: [PATCH 1/3] drm/dp_mst: Fix W=1 warnings
+
+Fix the warnings that show up with W=1.
+They are all about unused but set variables.
+If functions returns are not used anymore make them void.
+
+Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
+Reviewed-by: Lyude Paul <lyude@redhat.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20200205084842.5642-1-benjamin.gaignard@st.com
+---
+ drivers/gpu/drm/drm_dp_mst_topology.c | 114 +++++++++++++++-----------
+ 1 file changed, 65 insertions(+), 49 deletions(-)
+
+diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
+index 415bd0770eab..95e08d908dd2 100644
+--- a/drivers/gpu/drm/drm_dp_mst_topology.c
++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
+@@ -1035,7 +1035,8 @@ static bool drm_dp_sideband_parse_req(struct drm_dp_sideband_msg_rx *raw,
+ }
+ }
+
+-static int build_dpcd_write(struct drm_dp_sideband_msg_tx *msg, u8 port_num, u32 offset, u8 num_bytes, u8 *bytes)
++static void build_dpcd_write(struct drm_dp_sideband_msg_tx *msg,
++ u8 port_num, u32 offset, u8 num_bytes, u8 *bytes)
+ {
+ struct drm_dp_sideband_msg_req_body req;
+
+@@ -1045,17 +1046,14 @@ static int build_dpcd_write(struct drm_dp_sideband_msg_tx *msg, u8 port_num, u32
+ req.u.dpcd_write.num_bytes = num_bytes;
+ req.u.dpcd_write.bytes = bytes;
+ drm_dp_encode_sideband_req(&req, msg);
+-
+- return 0;
+ }
+
+-static int build_link_address(struct drm_dp_sideband_msg_tx *msg)
++static void build_link_address(struct drm_dp_sideband_msg_tx *msg)
+ {
+ struct drm_dp_sideband_msg_req_body req;
+
+ req.req_type = DP_LINK_ADDRESS;
+ drm_dp_encode_sideband_req(&req, msg);
+- return 0;
+ }
+
+ static int build_clear_payload_id_table(struct drm_dp_sideband_msg_tx *msg)
+@@ -1067,7 +1065,8 @@ static int build_clear_payload_id_table(struct drm_dp_sideband_msg_tx *msg)
+ return 0;
+ }
+
+-static int build_enum_path_resources(struct drm_dp_sideband_msg_tx *msg, int port_num)
++static int build_enum_path_resources(struct drm_dp_sideband_msg_tx *msg,
++ int port_num)
+ {
+ struct drm_dp_sideband_msg_req_body req;
+
+@@ -1078,10 +1077,11 @@ static int build_enum_path_resources(struct drm_dp_sideband_msg_tx *msg, int por
+ return 0;
+ }
+
+-static int build_allocate_payload(struct drm_dp_sideband_msg_tx *msg, int port_num,
+- u8 vcpi, uint16_t pbn,
+- u8 number_sdp_streams,
+- u8 *sdp_stream_sink)
++static void build_allocate_payload(struct drm_dp_sideband_msg_tx *msg,
++ int port_num,
++ u8 vcpi, uint16_t pbn,
++ u8 number_sdp_streams,
++ u8 *sdp_stream_sink)
+ {
+ struct drm_dp_sideband_msg_req_body req;
+ memset(&req, 0, sizeof(req));
+@@ -1094,11 +1094,10 @@ static int build_allocate_payload(struct drm_dp_sideband_msg_tx *msg, int port_n
+ number_sdp_streams);
+ drm_dp_encode_sideband_req(&req, msg);
+ msg->path_msg = true;
+- return 0;
+ }
+
+-static int build_power_updown_phy(struct drm_dp_sideband_msg_tx *msg,
+- int port_num, bool power_up)
++static void build_power_updown_phy(struct drm_dp_sideband_msg_tx *msg,
++ int port_num, bool power_up)
+ {
+ struct drm_dp_sideband_msg_req_body req;
+
+@@ -1110,7 +1109,6 @@ static int build_power_updown_phy(struct drm_dp_sideband_msg_tx *msg,
+ req.u.port_num.port_number = port_num;
+ drm_dp_encode_sideband_req(&req, msg);
+ msg->path_msg = true;
+- return 0;
+ }
+
+ static int drm_dp_mst_assign_payload_id(struct drm_dp_mst_topology_mgr *mgr,
+@@ -2073,29 +2071,24 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
+ offset, size, buffer);
+ }
+
+-static void drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid)
++static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid)
+ {
+- int ret;
++ int ret = 0;
+
+ memcpy(mstb->guid, guid, 16);
+
+ if (!drm_dp_validate_guid(mstb->mgr, mstb->guid)) {
+ if (mstb->port_parent) {
+- ret = drm_dp_send_dpcd_write(
+- mstb->mgr,
+- mstb->port_parent,
+- DP_GUID,
+- 16,
+- mstb->guid);
++ ret = drm_dp_send_dpcd_write(mstb->mgr,
++ mstb->port_parent,
++ DP_GUID, 16, mstb->guid);
+ } else {
+-
+- ret = drm_dp_dpcd_write(
+- mstb->mgr->aux,
+- DP_GUID,
+- mstb->guid,
+- 16);
++ ret = drm_dp_dpcd_write(mstb->mgr->aux,
++ DP_GUID, mstb->guid, 16);
+ }
+ }
++
++ return ret;
+ }
+
+ static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb,
+@@ -2641,7 +2634,8 @@ static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
+ return false;
+ }
+
+-static int build_dpcd_read(struct drm_dp_sideband_msg_tx *msg, u8 port_num, u32 offset, u8 num_bytes)
++static void build_dpcd_read(struct drm_dp_sideband_msg_tx *msg,
++ u8 port_num, u32 offset, u8 num_bytes)
+ {
+ struct drm_dp_sideband_msg_req_body req;
+
+@@ -2650,8 +2644,6 @@ static int build_dpcd_read(struct drm_dp_sideband_msg_tx *msg, u8 port_num, u32
+ req.u.dpcd_read.dpcd_address = offset;
+ req.u.dpcd_read.num_bytes = num_bytes;
+ drm_dp_encode_sideband_req(&req, msg);
+-
+- return 0;
+ }
+
+ static int drm_dp_send_sideband_msg(struct drm_dp_mst_topology_mgr *mgr,
+@@ -2877,7 +2869,7 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_sideband_msg_tx *txmsg;
+ struct drm_dp_link_address_ack_reply *reply;
+ struct drm_dp_mst_port *port, *tmp;
+- int i, len, ret, port_mask = 0;
++ int i, ret, port_mask = 0;
+ bool changed = false;
+
+ txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+@@ -2885,7 +2877,7 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
+ return -ENOMEM;
+
+ txmsg->dst = mstb;
+- len = build_link_address(txmsg);
++ build_link_address(txmsg);
+
+ mstb->link_address_sent = true;
+ drm_dp_queue_down_tx(mgr, txmsg);
+@@ -2906,7 +2898,9 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
+ DRM_DEBUG_KMS("link address reply: %d\n", reply->nports);
+ drm_dp_dump_link_address(reply);
+
+- drm_dp_check_mstb_guid(mstb, reply->guid);
++ ret = drm_dp_check_mstb_guid(mstb, reply->guid);
++ if (ret)
++ goto out;
+
+ for (i = 0; i < reply->nports; i++) {
+ port_mask |= BIT(reply->ports[i].port_number);
+@@ -2947,14 +2941,14 @@ void drm_dp_send_clear_payload_id_table(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_mst_branch *mstb)
+ {
+ struct drm_dp_sideband_msg_tx *txmsg;
+- int len, ret;
++ int ret;
+
+ txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+ if (!txmsg)
+ return;
+
+ txmsg->dst = mstb;
+- len = build_clear_payload_id_table(txmsg);
++ build_clear_payload_id_table(txmsg);
+
+ drm_dp_queue_down_tx(mgr, txmsg);
+
+@@ -2972,7 +2966,6 @@ drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
+ {
+ struct drm_dp_enum_path_resources_ack_reply *path_res;
+ struct drm_dp_sideband_msg_tx *txmsg;
+- int len;
+ int ret;
+
+ txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
+@@ -2980,7 +2973,7 @@ drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
+ return -ENOMEM;
+
+ txmsg->dst = mstb;
+- len = build_enum_path_resources(txmsg, port->port_num);
++ build_enum_path_resources(txmsg, port->port_num);
+
+ drm_dp_queue_down_tx(mgr, txmsg);
+
+@@ -3073,7 +3066,7 @@ static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr,
+ {
+ struct drm_dp_sideband_msg_tx *txmsg;
+ struct drm_dp_mst_branch *mstb;
+- int len, ret, port_num;
++ int ret, port_num;
+ u8 sinks[DRM_DP_MAX_SDP_STREAMS];
+ int i;
+
+@@ -3098,9 +3091,9 @@ static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr,
+ sinks[i] = i;
+
+ txmsg->dst = mstb;
+- len = build_allocate_payload(txmsg, port_num,
+- id,
+- pbn, port->num_sdp_streams, sinks);
++ build_allocate_payload(txmsg, port_num,
++ id,
++ pbn, port->num_sdp_streams, sinks);
+
+ drm_dp_queue_down_tx(mgr, txmsg);
+
+@@ -3129,7 +3122,7 @@ int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_mst_port *port, bool power_up)
+ {
+ struct drm_dp_sideband_msg_tx *txmsg;
+- int len, ret;
++ int ret;
+
+ port = drm_dp_mst_topology_get_port_validated(mgr, port);
+ if (!port)
+@@ -3142,7 +3135,7 @@ int drm_dp_send_power_updown_phy(struct drm_dp_mst_topology_mgr *mgr,
+ }
+
+ txmsg->dst = port->parent;
+- len = build_power_updown_phy(txmsg, port->port_num, power_up);
++ build_power_updown_phy(txmsg, port->port_num, power_up);
+ drm_dp_queue_down_tx(mgr, txmsg);
+
+ ret = drm_dp_mst_wait_tx_reply(port->parent, txmsg);
+@@ -3364,7 +3357,6 @@ static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_mst_port *port,
+ int offset, int size, u8 *bytes)
+ {
+- int len;
+ int ret = 0;
+ struct drm_dp_sideband_msg_tx *txmsg;
+ struct drm_dp_mst_branch *mstb;
+@@ -3379,7 +3371,7 @@ static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr,
+ goto fail_put;
+ }
+
+- len = build_dpcd_read(txmsg, port->port_num, offset, size);
++ build_dpcd_read(txmsg, port->port_num, offset, size);
+ txmsg->dst = port->parent;
+
+ drm_dp_queue_down_tx(mgr, txmsg);
+@@ -3417,7 +3409,6 @@ static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr,
+ struct drm_dp_mst_port *port,
+ int offset, int size, u8 *bytes)
+ {
+- int len;
+ int ret;
+ struct drm_dp_sideband_msg_tx *txmsg;
+ struct drm_dp_mst_branch *mstb;
+@@ -3432,7 +3423,7 @@ static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr,
+ goto fail_put;
+ }
+
+- len = build_dpcd_write(txmsg, port->port_num, offset, size, bytes);
++ build_dpcd_write(txmsg, port->port_num, offset, size, bytes);
+ txmsg->dst = mstb;
+
+ drm_dp_queue_down_tx(mgr, txmsg);
+@@ -3682,7 +3673,12 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
+ DRM_DEBUG_KMS("dpcd read failed - undocked during suspend?\n");
+ goto out_fail;
+ }
+- drm_dp_check_mstb_guid(mgr->mst_primary, guid);
++
++ ret = drm_dp_check_mstb_guid(mgr->mst_primary, guid);
++ if (ret) {
++ DRM_DEBUG_KMS("check mstb failed - undocked during suspend?\n");
++ goto out_fail;
++ }
+
+ /*
+ * For the final step of resuming the topology, we need to bring the
+@@ -4625,15 +4621,34 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
+ int ret;
+
+ ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, buf, DP_RECEIVER_CAP_SIZE);
++ if (ret) {
++ seq_printf(m, "dpcd read failed\n");
++ goto out;
++ }
+ seq_printf(m, "dpcd: %*ph\n", DP_RECEIVER_CAP_SIZE, buf);
++
+ ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2);
++ if (ret) {
++ seq_printf(m, "faux/mst read failed\n");
++ goto out;
++ }
+ seq_printf(m, "faux/mst: %*ph\n", 2, buf);
++
+ ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1);
++ if (ret) {
++ seq_printf(m, "mst ctrl read failed\n");
++ goto out;
++ }
+ seq_printf(m, "mst ctrl: %*ph\n", 1, buf);
+
+ /* dump the standard OUI branch header */
+ ret = drm_dp_dpcd_read(mgr->aux, DP_BRANCH_OUI, buf, DP_BRANCH_OUI_HEADER_SIZE);
++ if (ret) {
++ seq_printf(m, "branch oui read failed\n");
++ goto out;
++ }
+ seq_printf(m, "branch oui: %*phN devid: ", 3, buf);
++
+ for (i = 0x3; i < 0x8 && buf[i]; i++)
+ seq_printf(m, "%c", buf[i]);
+ seq_printf(m, " revision: hw: %x.%x sw: %x.%x\n",
+@@ -4642,6 +4657,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
+ seq_printf(m, "payload table: %*ph\n", DP_PAYLOAD_TABLE_SIZE, buf);
+ }
+
++out:
+ mutex_unlock(&mgr->lock);
+
+ }
+--
+2.25.1
+
+From 9004e704af8486da3dcbde0fb35a2a309152a5c3 Mon Sep 17 00:00:00 2001
+From: Lyude Paul <lyude@redhat.com>
+Date: Fri, 6 Mar 2020 18:49:21 -0500
+Subject: [PATCH 2/3] drm/dp_mst: Make drm_dp_mst_dpcd_write() consistent with
+ drm_dp_dpcd_write()
+
+Noticed this while having some problems with hubs sometimes not being
+detected on the first plug. Every single dpcd read or write function
+returns the number of bytes transferred on success or a negative error
+code, except apparently for drm_dp_mst_dpcd_write() - which returns 0 on
+success.
+
+There's not really any good reason for this difference that I can tell,
+and having the two functions give differing behavior means that
+drm_dp_dpcd_write() will end up returning 0 on success for MST devices,
+but the number of bytes transferred for everything else.
+
+So, fix that and update the kernel doc.
+
+Signed-off-by: Lyude Paul <lyude@redhat.com>
+Fixes: 2f221a5efed4 ("drm/dp_mst: Add MST support to DP DPCD R/W functions")
+Cc: Hans de Goede <hdegoede@redhat.com>
+Cc: Mikita Lipski <mikita.lipski@amd.com>
+Cc: Sean Paul <sean@poorly.run>
+---
+ drivers/gpu/drm/drm_dp_mst_topology.c | 11 ++++-------
+ 1 file changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
+index 95e08d908dd2..2dc1c0ba456b 100644
+--- a/drivers/gpu/drm/drm_dp_mst_topology.c
++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
+@@ -2059,7 +2059,7 @@ ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux,
+ * sideband messaging as drm_dp_dpcd_write() does for local
+ * devices via actual AUX CH.
+ *
+- * Return: 0 on success, negative error code on failure.
++ * Return: number of bytes written on success, negative error code on failure.
+ */
+ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
+ unsigned int offset, void *buffer, size_t size)
+@@ -3429,12 +3429,9 @@ static int drm_dp_send_dpcd_write(struct drm_dp_mst_topology_mgr *mgr,
+ drm_dp_queue_down_tx(mgr, txmsg);
+
+ ret = drm_dp_mst_wait_tx_reply(mstb, txmsg);
+- if (ret > 0) {
+- if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK)
+- ret = -EIO;
+- else
+- ret = 0;
+- }
++ if (ret > 0 && txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK)
++ ret = -EIO;
++
+ kfree(txmsg);
+ fail_put:
+ drm_dp_mst_topology_put_mstb(mstb);
+--
+2.25.1
+
+From ff18e1a7ef709cdd3dcbf7b4ae2b37e1c6695289 Mon Sep 17 00:00:00 2001
+From: Lyude Paul <lyude@redhat.com>
+Date: Fri, 6 Mar 2020 18:49:22 -0500
+Subject: [PATCH 3/3] drm/dp_mst: Fix drm_dp_check_mstb_guid() return code
+
+We actually expect this to return a 0 on success, or negative error code
+on failure. In order to do that, we check whether or not we managed to
+write the whole GUID and then return 0 if so, otherwise return a
+negative error code. Also, let's add an error message here so it's a
+little more obvious when this fails in the middle of a link address
+probe.
+
+This should fix issues with certain MST hubs seemingly stopping for no
+reason in the middle of the link address probe process.
+
+Fixes: cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")
+Cc: Benjamin Gaignard <benjamin.gaignard@st.com>
+Cc: Sean Paul <sean@poorly.run>
+Cc: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Lyude Paul <lyude@redhat.com>
+---
+ drivers/gpu/drm/drm_dp_mst_topology.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
+index 2dc1c0ba456b..d0e5993b0622 100644
+--- a/drivers/gpu/drm/drm_dp_mst_topology.c
++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
+@@ -2088,7 +2088,10 @@ static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid)
+ }
+ }
+
+- return ret;
++ if (ret < 16 && ret > 0)
++ return -EPROTO;
++
++ return ret == 16 ? 0 : ret;
+ }
+
+ static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb,
+@@ -2899,8 +2902,14 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
+ drm_dp_dump_link_address(reply);
+
+ ret = drm_dp_check_mstb_guid(mstb, reply->guid);
+- if (ret)
++ if (ret) {
++ char buf[64];
++
++ drm_dp_mst_rad_to_str(mstb->rad, mstb->lct, buf, sizeof(buf));
++ DRM_ERROR("GUID check on %s failed: %d\n",
++ buf, ret);
+ goto out;
++ }
+
+ for (i = 0; i < reply->nports; i++) {
+ port_mask |= BIT(reply->ports[i].port_number);
+--
+2.25.1
+