* [RESEND PATCH v2 0/2] Check MST topology change on resume @ 2018-10-24 2:19 Juston Li 2018-10-24 2:19 ` [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports " Juston Li ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Juston Li @ 2018-10-24 2:19 UTC (permalink / raw) To: intel-gfx, dri-devel Cc: lyude, clinton.a.taylor, nathan.d.ciobanu, mario.limonciello, jared_dominguez, linux-kernel, Juston Li Updated and resending these patches from Lyude: https://lkml.org/lkml/2016/5/19/361 https://lkml.org/lkml/2016/5/19/360 As Lyude explains in patch 1/2, we can't rely on MST hubs to handle hotplugs during suspend. This patchset will check if any EDID's changed upon resume and reset the MST connections if they did. This resolves issues with monitors not being detected when hotplugging them during suspend. Signed-off-by: Juston Li <juston.li@intel.com> Changes since v1: - update functions that have been renamed since the original patch - add a null check for the cached EDID in case a new device was added - checkpatch fixes Lyude (2): drm/dp/mst: Reprobe EDID for MST ports on resume drm/i915/mst: Reset MST after resume when necessary drivers/gpu/drm/drm_dp_mst_topology.c | 94 ++++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_dp.c | 7 +- 2 files changed, 99 insertions(+), 2 deletions(-) -- 2.17.2 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-10-24 2:19 [RESEND PATCH v2 0/2] Check MST topology change on resume Juston Li @ 2018-10-24 2:19 ` Juston Li 2018-10-24 22:09 ` Lyude Paul 2018-10-24 2:19 ` [RESEND PATCH v2 2/2] drm/i915/mst: Reset MST after resume when necessary Juston Li 2018-10-24 8:57 ` [Intel-gfx] [RESEND PATCH v2 0/2] Check MST topology change on resume Daniel Vetter 2 siblings, 1 reply; 11+ messages in thread From: Juston Li @ 2018-10-24 2:19 UTC (permalink / raw) To: intel-gfx, dri-devel Cc: lyude, clinton.a.taylor, nathan.d.ciobanu, mario.limonciello, jared_dominguez, linux-kernel, Lyude, stable, Juston Li From: Lyude <cpaul@redhat.com> As observed with the latest ThinkPad docks, we unfortunately can't rely on docks keeping us updated with hotplug events that happened while we were suspended. On top of that, even if the number of connectors remains the same between suspend and resume it's still not safe to assume that there were no hotplugs, since a different monitor might have been plugged into a port another monitor previously occupied. As such, we need to go through all of the MST ports and check whether or not their EDIDs have changed. In addition to that, we also now return -EINVAL from drm_dp_mst_topology_mgr_resume to indicate to callers that they need to reset the MST connection, and that they can't rely on any other method of reprobing. Cc: stable@vger.kernel.org Signed-off-by: Lyude <cpaul@redhat.com> Signed-off-by: Juston Li <juston.li@intel.com> --- drivers/gpu/drm/drm_dp_mst_topology.c | 94 ++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 5ff1d79b86c4..88abebe52021 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -29,6 +29,7 @@ #include <linux/i2c.h> #include <drm/drm_dp_mst_helper.h> #include <drm/drmP.h> +#include <drm/drm_edid.h> #include <drm/drm_fixed.h> #include <drm/drm_atomic.h> @@ -2201,6 +2202,64 @@ void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr) } EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); +static bool drm_dp_mst_edids_changed(struct drm_dp_mst_topology_mgr *mgr, + struct drm_dp_mst_port *port) +{ + struct drm_device *dev; + struct drm_connector *connector; + struct drm_dp_mst_port *dport; + struct drm_dp_mst_branch *mstb; + struct edid *current_edid, *cached_edid; + bool ret = false; + + port = drm_dp_get_validated_port_ref(mgr, port); + if (!port) + return false; + + mstb = drm_dp_get_validated_mstb_ref(mgr, port->mstb); + if (mstb) { + list_for_each_entry(dport, &port->mstb->ports, next) { + ret = drm_dp_mst_edids_changed(mgr, dport); + if (ret) + break; + } + + drm_dp_put_mst_branch_device(mstb); + if (ret) + goto out; + } + + connector = port->connector; + if (!connector || !port->aux.ddc.algo) + goto out; + + dev = connector->dev; + mutex_lock(&dev->mode_config.mutex); + + current_edid = drm_get_edid(connector, &port->aux.ddc); + if (connector->edid_blob_ptr) + cached_edid = (void *)connector->edid_blob_ptr->data; + else + return false; + + if ((current_edid && cached_edid && memcmp(current_edid, cached_edid, + sizeof(struct edid)) != 0) || + (!current_edid && cached_edid) || (current_edid && !cached_edid)) { + ret = true; + DRM_DEBUG_KMS("EDID on %s changed, reprobing connectors\n", + connector->name); + } + + mutex_unlock(&dev->mode_config.mutex); + + kfree(current_edid); + +out: + drm_dp_put_port(port); + + return ret; +} + /** * drm_dp_mst_topology_mgr_resume() - resume the MST manager * @mgr: manager to resume @@ -2210,9 +2269,15 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); * * if the device fails this returns -1, and the driver should do * a full MST reprobe, in case we were undocked. + * + * if the device can no longer be trusted, this returns -EINVAL + * and the driver should unconditionally disconnect and reconnect + * the dock. */ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr) { + struct drm_dp_mst_branch *mstb; + struct drm_dp_mst_port *port; int ret = 0; mutex_lock(&mgr->lock); @@ -2246,8 +2311,35 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr) drm_dp_check_mstb_guid(mgr->mst_primary, guid); ret = 0; - } else + + /* + * Some hubs also forget to notify us of hotplugs that happened + * while we were in suspend, so we need to verify that the edid + * hasn't changed for any of the connectors. If it has been, + * we unfortunately can't rely on the dock updating us with + * hotplug events, so indicate we need a full reconnect. + */ + + /* MST's I2C helpers can't be used while holding this lock */ + mutex_unlock(&mgr->lock); + + mstb = drm_dp_get_validated_mstb_ref(mgr, mgr->mst_primary); + if (mstb) { + list_for_each_entry(port, &mstb->ports, next) { + if (drm_dp_mst_edids_changed(mgr, port)) { + ret = -EINVAL; + break; + } + } + + drm_dp_put_mst_branch_device(mstb); + } + } else { ret = -1; + mutex_unlock(&mgr->lock); + } + + return ret; out_unlock: mutex_unlock(&mgr->lock); -- 2.17.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-10-24 2:19 ` [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports " Juston Li @ 2018-10-24 22:09 ` Lyude Paul 2018-10-24 22:45 ` Li, Juston 2018-10-24 23:02 ` Lyude Paul 0 siblings, 2 replies; 11+ messages in thread From: Lyude Paul @ 2018-10-24 22:09 UTC (permalink / raw) To: Juston Li, intel-gfx, dri-devel Cc: clinton.a.taylor, nathan.d.ciobanu, mario.limonciello, jared_dominguez, linux-kernel, Lyude, stable Thought this was going to be an easy review until I realized that there's multiple problems in nouveau this would cause issues with, even if we didn't pay attention to the -EINVAL that gets returned. The suspend/resume order in nouveau needs some fixing up to prevent this patch from causing timeouts, and then also there's a hidden surprise [ 972.294437] ============================================ [ 972.295225] WARNING: possible recursive locking detected [ 972.296042] 4.19.0-rc8mst-reprobe+ #2 Not tainted [ 972.296842] -------------------------------------------- [ 972.297614] zsh/6840 is trying to acquire lock: [ 972.298441] 0000000072e521f7 (&dev->mode_config.mutex){+.+.}, at: drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] [ 972.299299] but task is already holding lock: [ 972.300991] 0000000072e521f7 (&dev->mode_config.mutex){+.+.}, at: status_store+0x34/0x180 [drm] [ 972.301875] other info that might help us debug this: [ 972.303563] Possible unsafe locking scenario: [ 972.305315] CPU0 [ 972.306182] ---- [ 972.307061] lock(&dev->mode_config.mutex); [ 972.307943] lock(&dev->mode_config.mutex); [ 972.308819] *** DEADLOCK *** [ 972.311446] May be due to missing lock nesting notation [ 972.313234] 6 locks held by zsh/6840: [ 972.314135] #0: 0000000092b5ba9d (sb_writers#4){.+.+}, at: vfs_write+0x13e/0x1a0 [ 972.315049] #1: 00000000e628e6e9 (&of->mutex){+.+.}, at: kernfs_fop_write+0xbd/0x1a0 [ 972.315980] #2: 000000000fb65e6c (kn->count#240){.+.+}, at: kernfs_fop_write+0xc5/0x1a0 [ 972.316928] #3: 0000000072e521f7 (&dev->mode_config.mutex){+.+.}, at: status_store+0x34/0x180 [drm] [ 972.317892] #4: 00000000344224c2 (crtc_ww_class_acquire){+.+.}, at: drm_helper_probe_single_connector_modes+0x66/0x6c0 [drm_kms_helper] [ 972.318863] #5: 00000000d65352e2 (crtc_ww_class_mutex){+.+.}, at: drm_modeset_lock+0x44/0x110 [drm] [ 972.319860] stack backtrace: [ 972.321800] CPU: 5 PID: 6840 Comm: zsh Kdump: loaded Not tainted 4.19.0- rc8mst-reprobe+ #2 [ 972.322772] Hardware name: LENOVO 20EQZ1J7US/20EQZ1J7US, BIOS N1EET80W (1.53 ) 09/14/2018 [ 972.323792] Call Trace: [ 972.324821] dump_stack+0x85/0xc0 [ 972.325832] __lock_acquire.cold.59+0x158/0x227 [ 972.326887] ? retint_kernel+0x10/0x10 [ 972.327918] lock_acquire+0x9e/0x170 [ 972.328948] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] [ 972.329986] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] [ 972.331066] __mutex_lock+0x68/0x900 [ 972.332094] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] [ 972.333146] ? __mutex_unlock_slowpath+0x4b/0x2b0 [ 972.334221] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] [ 972.335255] drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] [ 972.336318] drm_dp_mst_topology_mgr_resume+0x104/0x190 [drm_kms_helper] [ 972.337397] nv50_display_init+0x73/0xd0 [nouveau] [ 972.338483] nouveau_display_init+0x8e/0xe0 [nouveau] [ 972.339547] nouveau_display_resume+0x39/0x250 [nouveau] [ 972.340634] ? pci_restore_standard_config+0x40/0x40 [ 972.341762] nouveau_do_resume+0x79/0x150 [nouveau] [ 972.342850] nouveau_pmops_runtime_resume+0x88/0x150 [nouveau] [ 972.343915] pci_pm_runtime_resume+0x78/0xb0 [ 972.345004] __rpm_callback+0x75/0x1b0 [ 972.346084] ? pci_restore_standard_config+0x40/0x40 [ 972.347148] rpm_callback+0x1f/0x70 [ 972.348256] ? pci_restore_standard_config+0x40/0x40 [ 972.349351] rpm_resume+0x5d4/0x810 [ 972.350446] ? drm_modeset_lock+0x44/0x110 [drm] [ 972.351573] __pm_runtime_resume+0x47/0x70 [ 972.352737] nouveau_connector_detect+0x373/0x470 [nouveau] [ 972.353841] ? _cond_resched+0x15/0x30 [ 972.354945] ? ww_mutex_lock+0x30/0x60 [ 972.356044] ? drm_modeset_lock+0x44/0x110 [drm] [ 972.357146] drm_helper_probe_single_connector_modes+0xd9/0x6c0 [drm_kms_helper] [ 972.358274] ? printk+0x58/0x6f [ 972.359400] status_store+0xb2/0x180 [drm] [ 972.360519] kernfs_fop_write+0xf0/0x1a0 [ 972.361711] __vfs_write+0x36/0x180 [ 972.362842] ? rcu_read_lock_sched_held+0x55/0x60 [ 972.363974] ? rcu_sync_lockdep_assert+0x2e/0x60 [ 972.365103] ? __sb_start_write+0x115/0x170 [ 972.366241] ? vfs_write+0x13e/0x1a0 [ 972.367365] vfs_write+0xa5/0x1a0 [ 972.368486] ksys_write+0x52/0xc0 [ 972.369596] do_syscall_64+0x60/0x1a0 [ 972.370782] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 972.371890] RIP: 0033:0x7fc93e169ef4 [ 972.373012] Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 8d 05 f1 3a 2d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 [ 972.374214] RSP: 002b:00007ffcd7ad1918 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 972.375421] RAX: ffffffffffffffda RBX: 0000000000000007 RCX: 00007fc93e169ef4 [ 972.376628] RDX: 0000000000000007 RSI: 000055aefe5c30c0 RDI: 0000000000000001 [ 972.377872] RBP: 000055aefe5c30c0 R08: 00007fc93e43a8c0 R09: 00007fc93f6cdb80 [ 972.379082] R10: 000000000000000a R11: 0000000000000246 R12: 00007fc93e439760 [ 972.380311] R13: 0000000000000007 R14: 00007fc93e434760 R15: 0000000000000007 I must not have noticed that back when I wrote these patches! Whoops. Since there's going to be quite a number of changes I need to make to this I'm just going to make the changes myself! I'll make sure to Cc you with the respin On Tue, 2018-10-23 at 19:19 -0700, Juston Li wrote: > From: Lyude <cpaul@redhat.com> > > As observed with the latest ThinkPad docks, we unfortunately can't rely > on docks keeping us updated with hotplug events that happened while we > were suspended. On top of that, even if the number of connectors remains > the same between suspend and resume it's still not safe to assume that > there were no hotplugs, since a different monitor might have been > plugged into a port another monitor previously occupied. As such, we > need to go through all of the MST ports and check whether or not their > EDIDs have changed. > > In addition to that, we also now return -EINVAL from > drm_dp_mst_topology_mgr_resume to indicate to callers that they need to > reset the MST connection, and that they can't rely on any other method > of reprobing. > > Cc: stable@vger.kernel.org > Signed-off-by: Lyude <cpaul@redhat.com> > Signed-off-by: Juston Li <juston.li@intel.com> > --- > drivers/gpu/drm/drm_dp_mst_topology.c | 94 ++++++++++++++++++++++++++- > 1 file changed, 93 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c > b/drivers/gpu/drm/drm_dp_mst_topology.c > index 5ff1d79b86c4..88abebe52021 100644 > --- a/drivers/gpu/drm/drm_dp_mst_topology.c > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c > @@ -29,6 +29,7 @@ > #include <linux/i2c.h> > #include <drm/drm_dp_mst_helper.h> > #include <drm/drmP.h> > +#include <drm/drm_edid.h> > > #include <drm/drm_fixed.h> > #include <drm/drm_atomic.h> > @@ -2201,6 +2202,64 @@ void drm_dp_mst_topology_mgr_suspend(struct > drm_dp_mst_topology_mgr *mgr) > } > EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); > > +static bool drm_dp_mst_edids_changed(struct drm_dp_mst_topology_mgr *mgr, > + struct drm_dp_mst_port *port) > +{ > + struct drm_device *dev; > + struct drm_connector *connector; > + struct drm_dp_mst_port *dport; > + struct drm_dp_mst_branch *mstb; > + struct edid *current_edid, *cached_edid; > + bool ret = false; > + > + port = drm_dp_get_validated_port_ref(mgr, port); > + if (!port) > + return false; > + > + mstb = drm_dp_get_validated_mstb_ref(mgr, port->mstb); > + if (mstb) { > + list_for_each_entry(dport, &port->mstb->ports, next) { > + ret = drm_dp_mst_edids_changed(mgr, dport); > + if (ret) > + break; > + } > + > + drm_dp_put_mst_branch_device(mstb); > + if (ret) > + goto out; > + } > + > + connector = port->connector; > + if (!connector || !port->aux.ddc.algo) > + goto out; > + > + dev = connector->dev; > + mutex_lock(&dev->mode_config.mutex); > + > + current_edid = drm_get_edid(connector, &port->aux.ddc); > + if (connector->edid_blob_ptr) > + cached_edid = (void *)connector->edid_blob_ptr->data; > + else > + return false; > + > + if ((current_edid && cached_edid && memcmp(current_edid, cached_edid, > + sizeof(struct edid)) != 0) > || > + (!current_edid && cached_edid) || (current_edid && !cached_edid)) > { > + ret = true; > + DRM_DEBUG_KMS("EDID on %s changed, reprobing connectors\n", > + connector->name); > + } > + > + mutex_unlock(&dev->mode_config.mutex); > + > + kfree(current_edid); > + > +out: > + drm_dp_put_port(port); > + > + return ret; > +} > + > /** > * drm_dp_mst_topology_mgr_resume() - resume the MST manager > * @mgr: manager to resume > @@ -2210,9 +2269,15 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); > * > * if the device fails this returns -1, and the driver should do > * a full MST reprobe, in case we were undocked. > + * > + * if the device can no longer be trusted, this returns -EINVAL > + * and the driver should unconditionally disconnect and reconnect > + * the dock. > */ > int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr) > { > + struct drm_dp_mst_branch *mstb; > + struct drm_dp_mst_port *port; > int ret = 0; > > mutex_lock(&mgr->lock); > @@ -2246,8 +2311,35 @@ int drm_dp_mst_topology_mgr_resume(struct > drm_dp_mst_topology_mgr *mgr) > drm_dp_check_mstb_guid(mgr->mst_primary, guid); > > ret = 0; > - } else > + > + /* > + * Some hubs also forget to notify us of hotplugs that > happened > + * while we were in suspend, so we need to verify that the > edid > + * hasn't changed for any of the connectors. If it has been, > + * we unfortunately can't rely on the dock updating us with > + * hotplug events, so indicate we need a full reconnect. > + */ > + > + /* MST's I2C helpers can't be used while holding this lock */ > + mutex_unlock(&mgr->lock); > + > + mstb = drm_dp_get_validated_mstb_ref(mgr, mgr->mst_primary); > + if (mstb) { > + list_for_each_entry(port, &mstb->ports, next) { > + if (drm_dp_mst_edids_changed(mgr, port)) { > + ret = -EINVAL; > + break; > + } > + } > + > + drm_dp_put_mst_branch_device(mstb); > + } > + } else { > ret = -1; > + mutex_unlock(&mgr->lock); > + } > + > + return ret; > > out_unlock: > mutex_unlock(&mgr->lock); -- Cheers, Lyude Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-10-24 22:09 ` Lyude Paul @ 2018-10-24 22:45 ` Li, Juston 2018-11-09 0:43 ` Lyude Paul 2018-10-24 23:02 ` Lyude Paul 1 sibling, 1 reply; 11+ messages in thread From: Li, Juston @ 2018-10-24 22:45 UTC (permalink / raw) To: dri-devel, intel-gfx, lyude Cc: Ciobanu, Nathan D, linux-kernel, Taylor, Clinton A, jared_dominguez, stable, mario.limonciello, cpaul On Wed, 2018-10-24 at 18:09 -0400, Lyude Paul wrote: > Since there's going to be quite a number of changes I need to make to > this I'm > just going to make the changes myself! I'll make sure to Cc you with > the > respin Sounds good, thanks for picking it up! Juston ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-10-24 22:45 ` Li, Juston @ 2018-11-09 0:43 ` Lyude Paul 2018-11-26 21:53 ` Li, Juston 0 siblings, 1 reply; 11+ messages in thread From: Lyude Paul @ 2018-11-09 0:43 UTC (permalink / raw) To: Li, Juston, dri-devel, intel-gfx Cc: Ciobanu, Nathan D, linux-kernel, Taylor, Clinton A, jared_dominguez, stable, mario.limonciello, cpaul Are you still looking into this at all? Even if it's not the right approach I'm still interested in seeing this get fixed as well/discussing what I said before On Wed, 2018-10-24 at 22:45 +0000, Li, Juston wrote: > On Wed, 2018-10-24 at 18:09 -0400, Lyude Paul wrote: > > Since there's going to be quite a number of changes I need to make to > > this I'm > > just going to make the changes myself! I'll make sure to Cc you with > > the > > respin > > Sounds good, thanks for picking it up! > > Juston > -- Cheers, Lyude Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-11-09 0:43 ` Lyude Paul @ 2018-11-26 21:53 ` Li, Juston 2018-11-26 22:35 ` Lyude Paul 0 siblings, 1 reply; 11+ messages in thread From: Li, Juston @ 2018-11-26 21:53 UTC (permalink / raw) To: dri-devel, intel-gfx, lyude Cc: Ciobanu, Nathan D, linux-kernel, Taylor, Clinton A, jared_dominguez, stable, mario.limonciello, cpaul Sorry for the late reply, email got caught in a bad filter =/ I haven't been looking into it lately but we are still interested in getting this fixed so I can start looking into this again. In your last email you mentioned a sysfs hotplug could be the way to go? Thanks Juston On Thu, 2018-11-08 at 19:43 -0500, Lyude Paul wrote: > Are you still looking into this at all? Even if it's not the right > approach > I'm still interested in seeing this get fixed as well/discussing what > I said > before > > On Wed, 2018-10-24 at 22:45 +0000, Li, Juston wrote: > > On Wed, 2018-10-24 at 18:09 -0400, Lyude Paul wrote: > > > Since there's going to be quite a number of changes I need to > > > make to > > > this I'm > > > just going to make the changes myself! I'll make sure to Cc you > > > with > > > the > > > respin > > > > Sounds good, thanks for picking it up! > > > > Juston > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-11-26 21:53 ` Li, Juston @ 2018-11-26 22:35 ` Lyude Paul 0 siblings, 0 replies; 11+ messages in thread From: Lyude Paul @ 2018-11-26 22:35 UTC (permalink / raw) To: Li, Juston, dri-devel, intel-gfx Cc: Ciobanu, Nathan D, linux-kernel, Taylor, Clinton A, jared_dominguez, stable, mario.limonciello, cpaul On Mon, 2018-11-26 at 21:53 +0000, Li, Juston wrote: > Sorry for the late reply, email got caught in a bad filter =/ > > I haven't been looking into it lately but we are still interested in > getting this fixed so I can start looking into this again. > > In your last email you mentioned a sysfs hotplug could be the way to > go? I had thought so; but I did a little more investigation and it looks like I wasn't totally wrong when I first wrote this patch; we actually do need to destroy the previous topology when it's not actually there and prevent the driver from trying to set it up again. Something that apparently a simple sysfs hotplug won't do. I think what we might be able to do is instead of comparing against the connector's EDID, we should try repurposing drm_dp_mst_port->cached_edid so that it holds a copy of each mst connector's EDID instead of just logical MSTBs, then compare against those EDIDs instead of the ones we assigned to the drm_connector to avoid the lockdep issues that would occur from trying to grab dev->mode_config.mutex from the suspend/resume codepaths, and decide from where whether or not to tell the driver to cut off the topology. Feel free to poke me about this on irc btw, might be quicker to discuss it there > > Thanks > Juston > > On Thu, 2018-11-08 at 19:43 -0500, Lyude Paul wrote: > > Are you still looking into this at all? Even if it's not the right > > approach > > I'm still interested in seeing this get fixed as well/discussing what > > I said > > before > > > > On Wed, 2018-10-24 at 22:45 +0000, Li, Juston wrote: > > > On Wed, 2018-10-24 at 18:09 -0400, Lyude Paul wrote: > > > > Since there's going to be quite a number of changes I need to > > > > make to > > > > this I'm > > > > just going to make the changes myself! I'll make sure to Cc you > > > > with > > > > the > > > > respin > > > > > > Sounds good, thanks for picking it up! > > > > > > Juston > > > -- Cheers, Lyude Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports on resume 2018-10-24 22:09 ` Lyude Paul 2018-10-24 22:45 ` Li, Juston @ 2018-10-24 23:02 ` Lyude Paul 1 sibling, 0 replies; 11+ messages in thread From: Lyude Paul @ 2018-10-24 23:02 UTC (permalink / raw) To: Juston Li, intel-gfx, dri-devel Cc: clinton.a.taylor, nathan.d.ciobanu, mario.limonciello, jared_dominguez, linux-kernel, Lyude, stable Gah, the more I think about this the more I realize this was never the correct approach to begin with. I wrote this patch a long time ago when I wasn't nearly as experienced, so that's not terribly surprising. So: the thing is this isn't actually a problem that's specific to MST. Pretty much all of the different connector types have this issue, since any GPU is going to miss hotplugs if the entire system is in S3. So it doesn't make much sense to have this be in MST helpers; we should just reprobe all of the connectors on the system. Honestly: I think it might just be a better idea to just send a sysfs hotplug when we wake up from suspend/resume, so that userspace just rechecks all of the connectors anyway. Nouveau already does this, jfyi. On Wed, 2018-10-24 at 18:09 -0400, Lyude Paul wrote: > Thought this was going to be an easy review until I realized that there's > multiple problems in nouveau this would cause issues with, even if we didn't > pay attention to the -EINVAL that gets returned. The suspend/resume order in > nouveau needs some fixing up to prevent this patch from causing timeouts, > and > then also there's a hidden surprise > > [ 972.294437] ============================================ > [ 972.295225] WARNING: possible recursive locking detected > [ 972.296042] 4.19.0-rc8mst-reprobe+ #2 Not tainted > [ 972.296842] -------------------------------------------- > [ 972.297614] zsh/6840 is trying to acquire lock: > [ 972.298441] 0000000072e521f7 (&dev->mode_config.mutex){+.+.}, at: > drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] > [ 972.299299] > but task is already holding lock: > [ 972.300991] 0000000072e521f7 (&dev->mode_config.mutex){+.+.}, at: > status_store+0x34/0x180 [drm] > [ 972.301875] > other info that might help us debug this: > [ 972.303563] Possible unsafe locking scenario: > > [ 972.305315] CPU0 > [ 972.306182] ---- > [ 972.307061] lock(&dev->mode_config.mutex); > [ 972.307943] lock(&dev->mode_config.mutex); > [ 972.308819] > *** DEADLOCK *** > > [ 972.311446] May be due to missing lock nesting notation > > [ 972.313234] 6 locks held by zsh/6840: > [ 972.314135] #0: 0000000092b5ba9d (sb_writers#4){.+.+}, at: > vfs_write+0x13e/0x1a0 > [ 972.315049] #1: 00000000e628e6e9 (&of->mutex){+.+.}, at: > kernfs_fop_write+0xbd/0x1a0 > [ 972.315980] #2: 000000000fb65e6c (kn->count#240){.+.+}, at: > kernfs_fop_write+0xc5/0x1a0 > [ 972.316928] #3: 0000000072e521f7 (&dev->mode_config.mutex){+.+.}, at: > status_store+0x34/0x180 [drm] > [ 972.317892] #4: 00000000344224c2 (crtc_ww_class_acquire){+.+.}, at: > drm_helper_probe_single_connector_modes+0x66/0x6c0 [drm_kms_helper] > [ 972.318863] #5: 00000000d65352e2 (crtc_ww_class_mutex){+.+.}, at: > drm_modeset_lock+0x44/0x110 [drm] > [ 972.319860] > stack backtrace: > [ 972.321800] CPU: 5 PID: 6840 Comm: zsh Kdump: loaded Not tainted 4.19.0- > rc8mst-reprobe+ #2 > [ 972.322772] Hardware name: LENOVO 20EQZ1J7US/20EQZ1J7US, BIOS N1EET80W > (1.53 ) 09/14/2018 > [ 972.323792] Call Trace: > [ 972.324821] dump_stack+0x85/0xc0 > [ 972.325832] __lock_acquire.cold.59+0x158/0x227 > [ 972.326887] ? retint_kernel+0x10/0x10 > [ 972.327918] lock_acquire+0x9e/0x170 > [ 972.328948] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] > [ 972.329986] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] > [ 972.331066] __mutex_lock+0x68/0x900 > [ 972.332094] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] > [ 972.333146] ? __mutex_unlock_slowpath+0x4b/0x2b0 > [ 972.334221] ? drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] > [ 972.335255] drm_dp_mst_edids_changed+0xc0/0x180 [drm_kms_helper] > [ 972.336318] drm_dp_mst_topology_mgr_resume+0x104/0x190 [drm_kms_helper] > [ 972.337397] nv50_display_init+0x73/0xd0 [nouveau] > [ 972.338483] nouveau_display_init+0x8e/0xe0 [nouveau] > [ 972.339547] nouveau_display_resume+0x39/0x250 [nouveau] > [ 972.340634] ? pci_restore_standard_config+0x40/0x40 > [ 972.341762] nouveau_do_resume+0x79/0x150 [nouveau] > [ 972.342850] nouveau_pmops_runtime_resume+0x88/0x150 [nouveau] > [ 972.343915] pci_pm_runtime_resume+0x78/0xb0 > [ 972.345004] __rpm_callback+0x75/0x1b0 > [ 972.346084] ? pci_restore_standard_config+0x40/0x40 > [ 972.347148] rpm_callback+0x1f/0x70 > [ 972.348256] ? pci_restore_standard_config+0x40/0x40 > [ 972.349351] rpm_resume+0x5d4/0x810 > [ 972.350446] ? drm_modeset_lock+0x44/0x110 [drm] > [ 972.351573] __pm_runtime_resume+0x47/0x70 > [ 972.352737] nouveau_connector_detect+0x373/0x470 [nouveau] > [ 972.353841] ? _cond_resched+0x15/0x30 > [ 972.354945] ? ww_mutex_lock+0x30/0x60 > [ 972.356044] ? drm_modeset_lock+0x44/0x110 [drm] > [ 972.357146] drm_helper_probe_single_connector_modes+0xd9/0x6c0 > [drm_kms_helper] > [ 972.358274] ? printk+0x58/0x6f > [ 972.359400] status_store+0xb2/0x180 [drm] > [ 972.360519] kernfs_fop_write+0xf0/0x1a0 > [ 972.361711] __vfs_write+0x36/0x180 > [ 972.362842] ? rcu_read_lock_sched_held+0x55/0x60 > [ 972.363974] ? rcu_sync_lockdep_assert+0x2e/0x60 > [ 972.365103] ? __sb_start_write+0x115/0x170 > [ 972.366241] ? vfs_write+0x13e/0x1a0 > [ 972.367365] vfs_write+0xa5/0x1a0 > [ 972.368486] ksys_write+0x52/0xc0 > [ 972.369596] do_syscall_64+0x60/0x1a0 > [ 972.370782] entry_SYSCALL_64_after_hwframe+0x49/0xbe > [ 972.371890] RIP: 0033:0x7fc93e169ef4 > [ 972.373012] Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 > 00 > 00 66 90 48 8d 05 f1 3a 2d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d > 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53 > [ 972.374214] RSP: 002b:00007ffcd7ad1918 EFLAGS: 00000246 ORIG_RAX: > 0000000000000001 > [ 972.375421] RAX: ffffffffffffffda RBX: 0000000000000007 RCX: > 00007fc93e169ef4 > [ 972.376628] RDX: 0000000000000007 RSI: 000055aefe5c30c0 RDI: > 0000000000000001 > [ 972.377872] RBP: 000055aefe5c30c0 R08: 00007fc93e43a8c0 R09: > 00007fc93f6cdb80 > [ 972.379082] R10: 000000000000000a R11: 0000000000000246 R12: > 00007fc93e439760 > [ 972.380311] R13: 0000000000000007 R14: 00007fc93e434760 R15: > 0000000000000007 > > I must not have noticed that back when I wrote these patches! Whoops. > > Since there's going to be quite a number of changes I need to make to this > I'm > just going to make the changes myself! I'll make sure to Cc you with the > respin > > On Tue, 2018-10-23 at 19:19 -0700, Juston Li wrote: > > From: Lyude <cpaul@redhat.com> > > > > As observed with the latest ThinkPad docks, we unfortunately can't rely > > on docks keeping us updated with hotplug events that happened while we > > were suspended. On top of that, even if the number of connectors remains > > the same between suspend and resume it's still not safe to assume that > > there were no hotplugs, since a different monitor might have been > > plugged into a port another monitor previously occupied. As such, we > > need to go through all of the MST ports and check whether or not their > > EDIDs have changed. > > > > In addition to that, we also now return -EINVAL from > > drm_dp_mst_topology_mgr_resume to indicate to callers that they need to > > reset the MST connection, and that they can't rely on any other method > > of reprobing. > > > > Cc: stable@vger.kernel.org > > Signed-off-by: Lyude <cpaul@redhat.com> > > Signed-off-by: Juston Li <juston.li@intel.com> > > --- > > drivers/gpu/drm/drm_dp_mst_topology.c | 94 ++++++++++++++++++++++++++- > > 1 file changed, 93 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c > > b/drivers/gpu/drm/drm_dp_mst_topology.c > > index 5ff1d79b86c4..88abebe52021 100644 > > --- a/drivers/gpu/drm/drm_dp_mst_topology.c > > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c > > @@ -29,6 +29,7 @@ > > #include <linux/i2c.h> > > #include <drm/drm_dp_mst_helper.h> > > #include <drm/drmP.h> > > +#include <drm/drm_edid.h> > > > > #include <drm/drm_fixed.h> > > #include <drm/drm_atomic.h> > > @@ -2201,6 +2202,64 @@ void drm_dp_mst_topology_mgr_suspend(struct > > drm_dp_mst_topology_mgr *mgr) > > } > > EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); > > > > +static bool drm_dp_mst_edids_changed(struct drm_dp_mst_topology_mgr *mgr, > > + struct drm_dp_mst_port *port) > > +{ > > + struct drm_device *dev; > > + struct drm_connector *connector; > > + struct drm_dp_mst_port *dport; > > + struct drm_dp_mst_branch *mstb; > > + struct edid *current_edid, *cached_edid; > > + bool ret = false; > > + > > + port = drm_dp_get_validated_port_ref(mgr, port); > > + if (!port) > > + return false; > > + > > + mstb = drm_dp_get_validated_mstb_ref(mgr, port->mstb); > > + if (mstb) { > > + list_for_each_entry(dport, &port->mstb->ports, next) { > > + ret = drm_dp_mst_edids_changed(mgr, dport); > > + if (ret) > > + break; > > + } > > + > > + drm_dp_put_mst_branch_device(mstb); > > + if (ret) > > + goto out; > > + } > > + > > + connector = port->connector; > > + if (!connector || !port->aux.ddc.algo) > > + goto out; > > + > > + dev = connector->dev; > > + mutex_lock(&dev->mode_config.mutex); > > + > > + current_edid = drm_get_edid(connector, &port->aux.ddc); > > + if (connector->edid_blob_ptr) > > + cached_edid = (void *)connector->edid_blob_ptr->data; > > + else > > + return false; > > + > > + if ((current_edid && cached_edid && memcmp(current_edid, cached_edid, > > + sizeof(struct edid)) != 0) > > > > > > > > + (!current_edid && cached_edid) || (current_edid && !cached_edid)) > > { > > + ret = true; > > + DRM_DEBUG_KMS("EDID on %s changed, reprobing connectors\n", > > + connector->name); > > + } > > + > > + mutex_unlock(&dev->mode_config.mutex); > > + > > + kfree(current_edid); > > + > > +out: > > + drm_dp_put_port(port); > > + > > + return ret; > > +} > > + > > /** > > * drm_dp_mst_topology_mgr_resume() - resume the MST manager > > * @mgr: manager to resume > > @@ -2210,9 +2269,15 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); > > * > > * if the device fails this returns -1, and the driver should do > > * a full MST reprobe, in case we were undocked. > > + * > > + * if the device can no longer be trusted, this returns -EINVAL > > + * and the driver should unconditionally disconnect and reconnect > > + * the dock. > > */ > > int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr) > > { > > + struct drm_dp_mst_branch *mstb; > > + struct drm_dp_mst_port *port; > > int ret = 0; > > > > mutex_lock(&mgr->lock); > > @@ -2246,8 +2311,35 @@ int drm_dp_mst_topology_mgr_resume(struct > > drm_dp_mst_topology_mgr *mgr) > > drm_dp_check_mstb_guid(mgr->mst_primary, guid); > > > > ret = 0; > > - } else > > + > > + /* > > + * Some hubs also forget to notify us of hotplugs that > > happened > > + * while we were in suspend, so we need to verify that the > > edid > > + * hasn't changed for any of the connectors. If it has been, > > + * we unfortunately can't rely on the dock updating us with > > + * hotplug events, so indicate we need a full reconnect. > > + */ > > + > > + /* MST's I2C helpers can't be used while holding this lock */ > > + mutex_unlock(&mgr->lock); > > + > > + mstb = drm_dp_get_validated_mstb_ref(mgr, mgr->mst_primary); > > + if (mstb) { > > + list_for_each_entry(port, &mstb->ports, next) { > > + if (drm_dp_mst_edids_changed(mgr, port)) { > > + ret = -EINVAL; > > + break; > > + } > > + } > > + > > + drm_dp_put_mst_branch_device(mstb); > > + } > > + } else { > > ret = -1; > > + mutex_unlock(&mgr->lock); > > + } > > + > > + return ret; > > > > out_unlock: > > mutex_unlock(&mgr->lock); -- Cheers, Lyude Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* [RESEND PATCH v2 2/2] drm/i915/mst: Reset MST after resume when necessary 2018-10-24 2:19 [RESEND PATCH v2 0/2] Check MST topology change on resume Juston Li 2018-10-24 2:19 ` [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports " Juston Li @ 2018-10-24 2:19 ` Juston Li 2018-10-24 8:57 ` [Intel-gfx] [RESEND PATCH v2 0/2] Check MST topology change on resume Daniel Vetter 2 siblings, 0 replies; 11+ messages in thread From: Juston Li @ 2018-10-24 2:19 UTC (permalink / raw) To: intel-gfx, dri-devel Cc: lyude, clinton.a.taylor, nathan.d.ciobanu, mario.limonciello, jared_dominguez, linux-kernel, Lyude, stable, Juston Li From: Lyude <cpaul@redhat.com> A follow-up to the previous commit, we skip checking the status of the MST device and completely reprobe it if drm_dp_mst_topology_mgr_resume() returns -EINVAL. Cc: stable@vger.kernel.org Signed-off-by: Lyude <cpaul@redhat.com> Signed-off-by: Juston Li <juston.li@intel.com> --- drivers/gpu/drm/i915/intel_dp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 8c38efef77a1..cb5ffec73094 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -6793,7 +6793,12 @@ void intel_dp_mst_resume(struct drm_i915_private *dev_priv) continue; ret = drm_dp_mst_topology_mgr_resume(&intel_dp->mst_mgr); - if (ret) + /* A full reset is required */ + if (ret == -EINVAL) { + drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, false); + intel_dp_configure_mst(intel_dp); + } else if (ret != 0) { intel_dp_check_mst_status(intel_dp); + } } } -- 2.17.2 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Intel-gfx] [RESEND PATCH v2 0/2] Check MST topology change on resume 2018-10-24 2:19 [RESEND PATCH v2 0/2] Check MST topology change on resume Juston Li 2018-10-24 2:19 ` [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports " Juston Li 2018-10-24 2:19 ` [RESEND PATCH v2 2/2] drm/i915/mst: Reset MST after resume when necessary Juston Li @ 2018-10-24 8:57 ` Daniel Vetter 2018-10-24 16:37 ` Li, Juston 2 siblings, 1 reply; 11+ messages in thread From: Daniel Vetter @ 2018-10-24 8:57 UTC (permalink / raw) To: Juston Li Cc: intel-gfx, dri-devel, mario.limonciello, linux-kernel, nathan.d.ciobanu, jared_dominguez On Tue, Oct 23, 2018 at 07:19:23PM -0700, Juston Li wrote: > Updated and resending these patches from Lyude: > https://lkml.org/lkml/2016/5/19/361 > https://lkml.org/lkml/2016/5/19/360 > > As Lyude explains in patch 1/2, we can't rely on MST hubs to handle > hotplugs during suspend. This patchset will check if any EDID's changed > upon resume and reset the MST connections if they did. > > This resolves issues with monitors not being detected when hotplugging them > during suspend. > > Signed-off-by: Juston Li <juston.li@intel.com> For formality, does this also imply a reviewed-by tag? For merging propably best we wait for the backmerge and the push these in through drm-misc-next-fixes. Well for drm-misc-next-fixes drm-misc maintainers need to roll the tree forward. Either way needs synchronization. Plus an ack from drm-intel maintainers. -Daniel > > Changes since v1: > - update functions that have been renamed since the original patch > - add a null check for the cached EDID in case a new device was added > - checkpatch fixes > > Lyude (2): > drm/dp/mst: Reprobe EDID for MST ports on resume > drm/i915/mst: Reset MST after resume when necessary > > drivers/gpu/drm/drm_dp_mst_topology.c | 94 ++++++++++++++++++++++++++- > drivers/gpu/drm/i915/intel_dp.c | 7 +- > 2 files changed, 99 insertions(+), 2 deletions(-) > > -- > 2.17.2 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Intel-gfx] [RESEND PATCH v2 0/2] Check MST topology change on resume 2018-10-24 8:57 ` [Intel-gfx] [RESEND PATCH v2 0/2] Check MST topology change on resume Daniel Vetter @ 2018-10-24 16:37 ` Li, Juston 0 siblings, 0 replies; 11+ messages in thread From: Li, Juston @ 2018-10-24 16:37 UTC (permalink / raw) To: daniel Cc: dri-devel, intel-gfx, linux-kernel, Ciobanu, Nathan D, jared_dominguez, mario.limonciello On Wed, 2018-10-24 at 10:57 +0200, Daniel Vetter wrote: > On Tue, Oct 23, 2018 at 07:19:23PM -0700, Juston Li wrote: > > > > Signed-off-by: Juston Li <juston.li@intel.com> > > For formality, does this also imply a reviewed-by tag? I'm quite new to drm so I'll withhold a reviewed-by tag and ask that someone else take a look at it too. Lyude, the original author, mentioned he should probably take a look again also since the patchset is a bit old. > For merging propably best we wait for the backmerge and the push > these in > through drm-misc-next-fixes. > > Well for drm-misc-next-fixes drm-misc maintainers need to roll the > tree > forward. Either way needs synchronization. Plus an ack from drm-intel > maintainers. > -Daniel > Will do Thanks Juston ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-11-26 22:35 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-10-24 2:19 [RESEND PATCH v2 0/2] Check MST topology change on resume Juston Li 2018-10-24 2:19 ` [RESEND PATCH v2 1/2] drm/dp/mst: Reprobe EDID for MST ports " Juston Li 2018-10-24 22:09 ` Lyude Paul 2018-10-24 22:45 ` Li, Juston 2018-11-09 0:43 ` Lyude Paul 2018-11-26 21:53 ` Li, Juston 2018-11-26 22:35 ` Lyude Paul 2018-10-24 23:02 ` Lyude Paul 2018-10-24 2:19 ` [RESEND PATCH v2 2/2] drm/i915/mst: Reset MST after resume when necessary Juston Li 2018-10-24 8:57 ` [Intel-gfx] [RESEND PATCH v2 0/2] Check MST topology change on resume Daniel Vetter 2018-10-24 16:37 ` Li, Juston
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).