Skip to contentSkip to conversation

drm: Don't race connector registration

PATCH In review Daniel Vetter 5 participants 14 messages Jan 12, 2017 – Feb 1, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Don't race connector registration

I was under the misconception that the sysfs dev stuff can be fully set up, and then registered all in one step with device_add. That's true for properties and property groups, but not for parents and child devices. Those must be fully registered before you can register a child.

Add a bit of tracking to make sure that asynchronous mst connector hotplugging gets this right. For consistency we rely upon the implicit barriers of the connector->mutex, which is taken anyway, to ensure that at least either the connector or device registration call will work out.

Mildly tested since I can't reliably reproduce this on my mst box here.

---
 drivers/gpu/drm/drm_connector.c | 3 +++
 drivers/gpu/drm/drm_drv.c       | 4 ++++
 include/drm/drmP.h              | 1 +
 3 files changed, 8 insertions(+)
drivers/gpu/drm/drm_connector.c +3 -0
index c75ab242f907..5999cb83d05b 100644
@@ -378,6 +378,9 @@ int drm_connector_register(struct drm_connector *connector)
 {
 	int ret = 0;
 
+	if (!connector->dev->registered)
+		return 0;
+
 	mutex_lock(&connector->mutex);
 	if (connector->registered)
 		goto unlock;
drivers/gpu/drm/drm_drv.c +4 -0
index 7e24103c47f1..cad6df626678 100644
@@ -749,6 +749,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto err_minors;
 
+	dev->registered = true;
+
 	if (dev->driver->load) {
 		ret = dev->driver->load(dev, flags);
 		if (ret)
@@ -796,6 +798,8 @@ void drm_dev_unregister(struct drm_device *dev)
 
 	drm_lastclose(dev);
 
+	dev->registered = false;
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_modeset_unregister_all(dev);
 
include/drm/drmP.h +1 -0
index c537c278a4be..ec105c339347 100644
@@ -518,6 +518,7 @@ struct drm_device {
 	struct drm_minor *control;		/**< Control node */
 	struct drm_minor *primary;		/**< Primary node */
 	struct drm_minor *render;		/**< Render node */
+	bool registered;
 
 	/* currently active master for this device. Protected by master_mutex */
 	struct drm_master *master;
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 12 lines · Daniel Vetter

I was under the misconception that the sysfs dev stuff can be fully set up, and then registered all in one step with device_add. That's true for properties and property groups, but not for parents and child devices. Those must be fully registered before you can register a child.

Add a bit of tracking to make sure that asynchronous mst connector hotplugging gets this right. For consistency we rely upon the implicit barriers of the connector->mutex, which is taken anyway, to ensure that at least either the connector or device registration call will work out.

Quoted 7 lines

Mildly tested since I can't reliably reproduce this on my mst box here.

Quoted 57 lines
---
 drivers/gpu/drm/drm_connector.c | 3 +++
 drivers/gpu/drm/drm_drv.c       | 4 ++++
 include/drm/drmP.h              | 1 +
 3 files changed, 8 insertions(+)
drivers/gpu/drm/drm_connector.c +3 -0
index c75ab242f907..5999cb83d05b 100644
@@ -378,6 +378,9 @@ int drm_connector_register(struct drm_connector *connector)
 {
 	int ret = 0;
 
+	if (!connector->dev->registered)
+		return 0;
+
 	mutex_lock(&connector->mutex);
 	if (connector->registered)
 		goto unlock;
drivers/gpu/drm/drm_drv.c +4 -0
index 7e24103c47f1..cad6df626678 100644
@@ -749,6 +749,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto err_minors;
 
+	dev->registered = true;
+
 	if (dev->driver->load) {
 		ret = dev->driver->load(dev, flags);
 		if (ret)
@@ -796,6 +798,8 @@ void drm_dev_unregister(struct drm_device *dev)
 
 	drm_lastclose(dev);
 
+	dev->registered = false;
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_modeset_unregister_all(dev);
 
include/drm/drmP.h +1 -0
index c537c278a4be..ec105c339347 100644
@@ -518,6 +518,7 @@ struct drm_device {
 	struct drm_minor *control;		/**< Control node */
 	struct drm_minor *primary;		/**< Primary node */
 	struct drm_minor *render;		/**< Render node */
+	bool registered;
 
 	/* currently active master for this device. Protected by master_mutex */
 	struct drm_master *master;
Signature · 1 line
2.5.5
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Hi Dave,

Still waiting for your testing results on this one here ... -Daniel

Quoted 85 lines · Daniel Vetter
Quoted 12 lines · Daniel Vetter

I was under the misconception that the sysfs dev stuff can be fully set up, and then registered all in one step with device_add. That's true for properties and property groups, but not for parents and child devices. Those must be fully registered before you can register a child.

Add a bit of tracking to make sure that asynchronous mst connector hotplugging gets this right. For consistency we rely upon the implicit barriers of the connector->mutex, which is taken anyway, to ensure that at least either the connector or device registration call will work out.

Quoted 7 lines

Mildly tested since I can't reliably reproduce this on my mst box here.

Quoted 57 lines
---
 drivers/gpu/drm/drm_connector.c | 3 +++
 drivers/gpu/drm/drm_drv.c       | 4 ++++
 include/drm/drmP.h              | 1 +
 3 files changed, 8 insertions(+)
drivers/gpu/drm/drm_connector.c +3 -0
index c75ab242f907..5999cb83d05b 100644
@@ -378,6 +378,9 @@ int drm_connector_register(struct drm_connector *connector)
 {
 	int ret = 0;
 
+	if (!connector->dev->registered)
+		return 0;
+
 	mutex_lock(&connector->mutex);
 	if (connector->registered)
 		goto unlock;
drivers/gpu/drm/drm_drv.c +4 -0
index 7e24103c47f1..cad6df626678 100644
@@ -749,6 +749,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (ret)
 		goto err_minors;
 
+	dev->registered = true;
+
 	if (dev->driver->load) {
 		ret = dev->driver->load(dev, flags);
 		if (ret)
@@ -796,6 +798,8 @@ void drm_dev_unregister(struct drm_device *dev)
 
 	drm_lastclose(dev);
 
+	dev->registered = false;
+
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_modeset_unregister_all(dev);
 
include/drm/drmP.h +1 -0
index c537c278a4be..ec105c339347 100644
@@ -518,6 +518,7 @@ struct drm_device {
 	struct drm_minor *control;		/**< Control node */
 	struct drm_minor *primary;		/**< Primary node */
 	struct drm_minor *render;		/**< Render node */
+	bool registered;
 
 	/* currently active master for this device. Protected by master_mutex */
 	struct drm_master *master;
Signature · 1 line
2.5.5
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 3 lines · Daniel Vetter

Hi Dave,

Still waiting for your testing results on this one here ...

It's definitely stable with that patch applied. No more crashes.

But, it's also definitely having difficulty re-probing to find the monitor that's attached to the dock in some cases. Whatever is going on isn't fixed by poking it with xrandr.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 10 lines · Dave Hansen
Quoted 3 lines · Daniel Vetter

Hi Dave,

Still waiting for your testing results on this one here ...

It's definitely stable with that patch applied. No more crashes.

But, it's also definitely having difficulty re-probing to find the monitor that's attached to the dock in some cases. Whatever is going on isn't fixed by poking it with xrandr.

Is this new? When exactly does this happen? Does the mst sink connector no longer show up, or is the connected/disconnected status all wrong? -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
Quoted 6 lines · Daniel Vetter
Quoted 5 lines · Dave Hansen
Quoted 3 lines · Daniel Vetter

Hi Dave,

Still waiting for your testing results on this one here ...

Quoted 8 lines
Quoted 5 lines

It's definitely stable with that patch applied. No more crashes.

But, it's also definitely having difficulty re-probing to find the monitor that's attached to the dock in some cases. Whatever is going on isn't fixed by poking it with xrandr.

Is this new? When exactly does this happen? Does the mst sink connector no longer show up, or is the connected/disconnected status all wrong?

It's hard to say whether it's new or not. I *think* it worked better before, but it also crashed pretty often, so it's hard to say.

And, yeah, I think it just gets the connected status wrong. The connector is still there.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
Quoted 13 lines · Dave Hansen
Quoted 12 lines · Daniel Vetter
Quoted 10 lines · Dave Hansen
Quoted 3 lines · Daniel Vetter

Hi Dave,

Still waiting for your testing results on this one here ...

It's definitely stable with that patch applied. No more crashes.

But, it's also definitely having difficulty re-probing to find the monitor that's attached to the dock in some cases. Whatever is going on isn't fixed by poking it with xrandr.

Quoted 5 lines
Quoted 2 lines

Is this new? When exactly does this happen? Does the mst sink connector no longer show up, or is the connected/disconnected status all wrong?

It's hard to say whether it's new or not. I *think* it worked better before, but it also crashed pretty often, so it's hard to say.

Ok, I guess that's good enough to push at least the crash fix forward.

Quoted 2 lines

And, yeah, I think it just gets the connected status wrong. The connector is still there.

Hm, I thought I replied here but I didn't:
- Is this just after boot (and then the connector is stuck forever), or starts to happen after suspend/resume, or some other system change like that? Or do they just crop up eventually?

- Does this only happen once the connector is destroyed? Please trace intel_dp_destroy_mst_connector with something like:

drivers/gpu/drm/i915/intel_dp_mst.c +2 -0
index 38e3ca2f6f18..24ac2d1ce3ad 100644
@@ -502,6 +502,8 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 
 	drm_connector_unregister(connector);
 
+	printk("mst connector getting destroyed: %s\n", connector->name);
+
 	/* need to nuke the connector */
 	drm_modeset_lock_all(dev);
 	intel_connector_remove_from_fbdev(intel_connector);

- If it's not that then something in intel_dp_mst_detect (well, it's helper implementation drm_dp_mst_detect_port) is probably going wrong.

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
Quoted 1 line · Daniel Vetter

On Thu, Jan 26, 2017 at 12:34:29PM -0800, Dave Hansen wrote:

...

Quoted 7 lines
Quoted 2 lines

And, yeah, I think it just gets the connected status wrong. The connector is still there.

Hm, I thought I replied here but I didn't:
- Is this just after boot (and then the connector is stuck forever), or starts to happen after suspend/resume, or some other system change like that? Or do they just crop up eventually?

The most consistent thing I do to screw it up is switch systems on my DVI KVM switch. When I switch back to the system in question, it doesn't seem to notice the condition. The connectors eventually show up with random combinations of switching to the console (ctrl-alt-f1) and back, running xrandr, or running gnome-control-panel and opening the Displays applet.

I haven't been able to discern any pattern to it. Sometimes just running xrandr fixes it. Sometimes just opening the control panel. Others, I have to do it several times.

I don't think it shows up if I just leave it for a while.

Quoted 2 lines

- Does this only happen once the connector is destroyed? Please trace intel_dp_destroy_mst_connector with something like:

I'll see if I can gather that.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
Quoted 11 lines · Dave Hansen
Quoted 1 line · Daniel Vetter

On Thu, Jan 26, 2017 at 12:34:29PM -0800, Dave Hansen wrote:

...

Quoted 7 lines
Quoted 2 lines

And, yeah, I think it just gets the connected status wrong. The connector is still there.

Hm, I thought I replied here but I didn't:
- Is this just after boot (and then the connector is stuck forever), or starts to happen after suspend/resume, or some other system change like that? Or do they just crop up eventually?

Quoted 6 lines

The most consistent thing I do to screw it up is switch systems on my DVI KVM switch. When I switch back to the system in question, it doesn't seem to notice the condition. The connectors eventually show up with random combinations of switching to the console (ctrl-alt-f1) and back, running xrandr, or running gnome-control-panel and opening the Displays applet.

Hm, so is this a dp mst kvm switch (i.e. do the connectors get hot-added/removed when you plug/unplug that thing)? Or just some other non-mst switch? I was working under the assumption that this is mst still, but I've never seen an mst kvm switch.

Quoted 10 lines

I haven't been able to discern any pattern to it. Sometimes just running xrandr fixes it. Sometimes just opening the control panel. Others, I have to do it several times.

I don't think it shows up if I just leave it for a while.

Quoted 2 lines

- Does this only happen once the connector is destroyed? Please trace intel_dp_destroy_mst_connector with something like:

I'll see if I can gather that.

If it's not mst, then don't bother with this for obvious reasons :-) -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

I added some printk()s all over and gathered a bit more information about what's going on. It looks like the display doesn't work until the drm connector code cleans up the *old* connector. For some reason, it isn't motivated to do that until I go to the console and back.

In this case, the display was connected to DP-4. intel_dp_destroy_mst_connector() got called on it when I switched away, but drm_connector_cleanup() did not get called. Upon switching back DP-3/5/6 get created. One of these *eventually* ends up being "enabled", but is not now. When I switch over to the console, drm_connector_cleanup() finally gets called on the old connector: DP-4 and I can switch back to X and I see one of DP-3/5/6 enabled and working.

Here are some snippets of dmesg interspersed with what I was doing:

Push DVI switch button to switch to other system:

Quoted 10 lines
[ 6824.562838] drm_dp_destroy_port() kfree(ffff8801ade46800)
[ 6824.563164] drm_dp_destroy_connector_work() port: ffff8801ade42000 connector: ffff8801ade46000
[ 6824.563178] intel_dp_destroy_mst_connector() connector: ffff8801ade46000 name: DP-3 &name: ffff8801ade46048 intel_connector: ffff8801ade46000
[ 6824.563186] drm_sysfs_connector_remove() connector: ffff8801ade46000 kdev: ffff8801a941b400
[ 6824.571556] drm_connector_cleanup(ffff8801ade46000)::329 connector->registered: 0 cpu: 3
[ 6824.571570] drm_connector_cleanup() kfree() connector->name: 'DP-3' &name: ffff8801ade46048
[ 6824.571581] drm_dp_free_mst_port() kfree port: ffff8801ade42000
[ 6824.571587] drm_dp_destroy_connector_work() port: ffff8801ade42800 connector: ffff8801ade47000
[ 6824.571594] intel_dp_destroy_mst_connector() connector: ffff8801ade47000 name: DP-4 &name: ffff8801ade47048 intel_connector: ffff8801ade47000
[ 6824.571601] drm_sysfs_connector_remove() connector: ffff8801ade47000 kdev: ffff8801a941a000
Quoted 8 lines
[ 6824.571915] drm_dp_free_mst_port() kfree port: ffff8801ade42800
[ 6824.571925] drm_dp_destroy_connector_work() port: ffff8801ade40800 connector: ffff8801ade43000
[ 6824.571934] intel_dp_destroy_mst_connector() connector: ffff8801ade43000 name: DP-6 &name: ffff8801ade43048 intel_connector: ffff8801ade43000
[ 6824.571943] drm_sysfs_connector_remove() connector: ffff8801ade43000 kdev: ffff8801a9419800
[ 6824.572091] drm_connector_cleanup(ffff8801ade43000)::329 connector->registered: 0 cpu: 3
[ 6824.572101] drm_connector_cleanup() kfree() connector->name: 'DP-6' &name: ffff8801ade43048
[ 6824.572110] drm_dp_free_mst_branch_device() kfree mstb: ffff88030ac22600
[ 6824.572117] drm_dp_free_mst_port() kfree port: ffff8801ade40800

Push button to switch back:

Quoted 6 lines
[ 6837.349693] drm_connector_init() connector->name: 'DP-3' &name: ffff88040231d848
[ 6837.349894] drm_sysfs_connector_add() connector: ffff88040231d800 kdev: ffff8801ae99f400
[ 6837.352786] drm_connector_init() connector->name: 'DP-5' &name: ffff880402318048
[ 6837.352951] drm_sysfs_connector_add() connector: ffff880402318000 kdev: ffff8801ae99c000
[ 6837.353036] drm_connector_init() connector->name: 'DP-6' &name: ffff88040d37f048
[ 6837.353154] drm_sysfs_connector_add() connector: ffff88040d37f000 kdev: ffff8801ae99ec00

I can type into the X session, but both screens are blank. When I press Ctrl-Alt-F2, I get:

Quoted 2 lines
[ 6850.494310] drm_connector_cleanup(ffff8801ade47000)::329 connector->registered: 0 cpu: 1
[ 6850.494314] drm_connector_cleanup() kfree() connector->name: 'DP-4' &name: ffff8801ade47048

Now I can switch back to X and everything is OK again.
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw
Quoted 13 lines · Dave Hansen

I added some printk()s all over and gathered a bit more information about what's going on. It looks like the display doesn't work until the drm connector code cleans up the *old* connector. For some reason, it isn't motivated to do that until I go to the console and back.

In this case, the display was connected to DP-4. intel_dp_destroy_mst_connector() got called on it when I switched away, but drm_connector_cleanup() did not get called. Upon switching back DP-3/5/6 get created. One of these *eventually* ends up being "enabled", but is not now. When I switch over to the console, drm_connector_cleanup() finally gets called on the old connector: DP-4 and I can switch back to X and I see one of DP-3/5/6 enabled and working.

Quoted 1 line

Here are some snippets of dmesg interspersed with what I was doing:

Ok, so the delayed deleting seems to be involved in the bug (and we only do that since we recently introduced refcounting for hotplugged connectors). The question is who's getting confused, either kernel or X. To figure this out, next time things are out of sync, please compare the output of

$ xrandr

with what's reported in /sys/class/drm/*/status:

$ grep . /sys/class/drm/card0-DP-*/status

Another question: What desktop are you using, and if you unplug a screen, does that general reconfigure the desktop size to disable that output? The zombie connector only sticks around as long as someone is still using it in the screen configuration. As soon as the reconfiguration has happened, it should go away. You can test this by manually disabling the output when it's stuck as on:

$ xrandr --output DP-4 --off

That should result in the delayed cleanup happening when you look at dmesg afterwards.

Thanks, Daniel

Quoted 38 lines

Push DVI switch button to switch to other system:

Quoted 10 lines
[ 6824.562838] drm_dp_destroy_port() kfree(ffff8801ade46800)
[ 6824.563164] drm_dp_destroy_connector_work() port: ffff8801ade42000 connector: ffff8801ade46000
[ 6824.563178] intel_dp_destroy_mst_connector() connector: ffff8801ade46000 name: DP-3 &name: ffff8801ade46048 intel_connector: ffff8801ade46000
[ 6824.563186] drm_sysfs_connector_remove() connector: ffff8801ade46000 kdev: ffff8801a941b400
[ 6824.571556] drm_connector_cleanup(ffff8801ade46000)::329 connector->registered: 0 cpu: 3
[ 6824.571570] drm_connector_cleanup() kfree() connector->name: 'DP-3' &name: ffff8801ade46048
[ 6824.571581] drm_dp_free_mst_port() kfree port: ffff8801ade42000
[ 6824.571587] drm_dp_destroy_connector_work() port: ffff8801ade42800 connector: ffff8801ade47000
[ 6824.571594] intel_dp_destroy_mst_connector() connector: ffff8801ade47000 name: DP-4 &name: ffff8801ade47048 intel_connector: ffff8801ade47000
[ 6824.571601] drm_sysfs_connector_remove() connector: ffff8801ade47000 kdev: ffff8801a941a000
Quoted 8 lines
[ 6824.571915] drm_dp_free_mst_port() kfree port: ffff8801ade42800
[ 6824.571925] drm_dp_destroy_connector_work() port: ffff8801ade40800 connector: ffff8801ade43000
[ 6824.571934] intel_dp_destroy_mst_connector() connector: ffff8801ade43000 name: DP-6 &name: ffff8801ade43048 intel_connector: ffff8801ade43000
[ 6824.571943] drm_sysfs_connector_remove() connector: ffff8801ade43000 kdev: ffff8801a9419800
[ 6824.572091] drm_connector_cleanup(ffff8801ade43000)::329 connector->registered: 0 cpu: 3
[ 6824.572101] drm_connector_cleanup() kfree() connector->name: 'DP-6' &name: ffff8801ade43048
[ 6824.572110] drm_dp_free_mst_branch_device() kfree mstb: ffff88030ac22600
[ 6824.572117] drm_dp_free_mst_port() kfree port: ffff8801ade40800

Push button to switch back:

Quoted 6 lines
[ 6837.349693] drm_connector_init() connector->name: 'DP-3' &name: ffff88040231d848
[ 6837.349894] drm_sysfs_connector_add() connector: ffff88040231d800 kdev: ffff8801ae99f400
[ 6837.352786] drm_connector_init() connector->name: 'DP-5' &name: ffff880402318048
[ 6837.352951] drm_sysfs_connector_add() connector: ffff880402318000 kdev: ffff8801ae99c000
[ 6837.353036] drm_connector_init() connector->name: 'DP-6' &name: ffff88040d37f048
[ 6837.353154] drm_sysfs_connector_add() connector: ffff88040d37f000 kdev: ffff8801ae99ec00

I can type into the X session, but both screens are blank. When I press Ctrl-Alt-F2, I get:

Quoted 2 lines
[ 6850.494310] drm_connector_cleanup(ffff8801ade47000)::329 connector->registered: 0 cpu: 1
[ 6850.494314] drm_connector_cleanup() kfree() connector->name: 'DP-4' &name: ffff8801ade47048

Now I can switch back to X and everything is OK again.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw
Quoted 22 lines · Daniel Vetter
Quoted 13 lines · Dave Hansen

I added some printk()s all over and gathered a bit more information about what's going on. It looks like the display doesn't work until the drm connector code cleans up the *old* connector. For some reason, it isn't motivated to do that until I go to the console and back.

In this case, the display was connected to DP-4. intel_dp_destroy_mst_connector() got called on it when I switched away, but drm_connector_cleanup() did not get called. Upon switching back DP-3/5/6 get created. One of these *eventually* ends up being "enabled", but is not now. When I switch over to the console, drm_connector_cleanup() finally gets called on the old connector: DP-4 and I can switch back to X and I see one of DP-3/5/6 enabled and working.

Quoted 1 line

Here are some snippets of dmesg interspersed with what I was doing:

Ok, so the delayed deleting seems to be involved in the bug (and we only do that since we recently introduced refcounting for hotplugged connectors). The question is who's getting confused, either kernel or X. To figure this out, next time things are out of sync, please compare the output of

Quoted 5 lines
$ xrandr

with what's reported in /sys/class/drm/*/status:

$ grep . /sys/class/drm/card0-DP-*/status

OK, I collected that 4 times:
1. When everything is OK
2. When the DVI is unplugged
3. When the DVI is re-plugged (no output)
4. After I press Ctrl-Alt-F2 (back to OK)

The good vs. bad diff looks like this:

xdebug.1485980621.dvi-replugged.log renamed from xdebug.1485980540.start.log +0 -0
@@ -25,15 +25,6 @@
 DP2-1 disconnected (normal left inverted right x axis y axis)
 DP2-2 connected primary 1920x1200+0+0 (normal left inverted right x

axis y axis) 518mm x 324mm

    1920x1200      60.0*+
-   1920x1080      60.0
-   1600x1200      60.0
-   1680x1050      59.9
-   1280x1024      60.0
-   1280x960       60.0
-   1024x768       60.0
-   800x600        60.3
-   640x480        59.9
-   720x400        70.1

DP2-3 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) HDMI2 disconnected (normal left inverted right x axis y axis)
@@ -41,5 +32,5 @@
/sys/class/drm/card0-DP-1/status:disconnected /sys/class/drm/card0-DP-2/status:disconnected /sys/class/drm/card0-DP-3/status:disconnected
-/sys/class/drm/card0-DP-5/status:connected +/sys/class/drm/card0-DP-4/status:connected
/sys/class/drm/card0-DP-6/status:disconnected

But it's very interesting that when I unplug the DVI, the xrandr output does not change. Only the /sys/class/drm/.../status does.

Quoted 8 lines

Another question: What desktop are you using, and if you unplug a screen, does that general reconfigure the desktop size to disable that output? The zombie connector only sticks around as long as someone is still using it in the screen configuration. As soon as the reconfiguration has happened, it should go away. You can test this by manually disabling the output when it's stuck as on:

$ xrandr --output DP-4 --off

Yep, it does the delayed cleanup. The output still shows up in xrandr (as an 8x8 display) at this point, but it can at least be turned back on.

xrandr snippet:

	Screen 0: minimum 8 x 8, current 8 x 8, maximum 32767 x 32767

So, if I do a pair of these:

	xrandr --output DP-4 --off
	xrandr --output DP-4 --auto

it does bring the display back consistently.

Screen 0: minimum 8 x 8, current 1920 x 1200, maximum 32767 x 32767 eDP1 connected (normal left inverted right x axis y axis)

   1920x1080      60.0 +   59.9  
   1680x1050      60.0     59.9  
   1600x1024      60.2  
   1400x1050      60.0  
   1600x900       60.0  
   1280x1024      60.0  
   1440x900       59.9  
   1280x960       60.0  
   1368x768       60.0  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1280x720       60.0  
   1024x768       60.0  
   1024x576       60.0  
   960x540        60.0  
   800x600        60.3     56.2  
   864x486        60.0  
   640x480        59.9  
   720x405        60.0  
   640x360        60.0  

DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP2-1 disconnected (normal left inverted right x axis y axis)
DP2-2 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm

   1920x1200      60.0*+
   1920x1080      60.0  
   1600x1200      60.0  
   1680x1050      59.9  
   1280x1024      60.0  
   1280x960       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        59.9  
   720x400        70.1  

DP2-3 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) HDMI2 disconnected (normal left inverted right x axis y axis) VIRTUAL1 disconnected (normal left inverted right x axis y axis) /sys/class/drm/card0-DP-1/status:disconnected /sys/class/drm/card0-DP-2/status:disconnected /sys/class/drm/card0-DP-3/status:disconnected /sys/class/drm/card0-DP-5/status:connected /sys/class/drm/card0-DP-6/status:disconnected

Screen 0: minimum 8 x 8, current 1920 x 1200, maximum 32767 x 32767 eDP1 connected (normal left inverted right x axis y axis)

   1920x1080      60.0 +   59.9  
   1680x1050      60.0     59.9  
   1600x1024      60.2  
   1400x1050      60.0  
   1600x900       60.0  
   1280x1024      60.0  
   1440x900       59.9  
   1280x960       60.0  
   1368x768       60.0  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1280x720       60.0  
   1024x768       60.0  
   1024x576       60.0  
   960x540        60.0  
   800x600        60.3     56.2  
   864x486        60.0  
   640x480        59.9  
   720x405        60.0  
   640x360        60.0  

DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP2-1 disconnected (normal left inverted right x axis y axis)
DP2-2 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm

   1920x1200      60.0*+
   1920x1080      60.0  
   1600x1200      60.0  
   1680x1050      59.9  
   1280x1024      60.0  
   1280x960       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        59.9  
   720x400        70.1  

DP2-3 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) HDMI2 disconnected (normal left inverted right x axis y axis) VIRTUAL1 disconnected (normal left inverted right x axis y axis) /sys/class/drm/card0-DP-1/status:disconnected /sys/class/drm/card0-DP-2/status:disconnected

Screen 0: minimum 8 x 8, current 1920 x 1200, maximum 32767 x 32767 eDP1 connected (normal left inverted right x axis y axis)

   1920x1080      60.0 +   59.9  
   1680x1050      60.0     59.9  
   1600x1024      60.2  
   1400x1050      60.0  
   1600x900       60.0  
   1280x1024      60.0  
   1440x900       59.9  
   1280x960       60.0  
   1368x768       60.0  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1280x720       60.0  
   1024x768       60.0  
   1024x576       60.0  
   960x540        60.0  
   800x600        60.3     56.2  
   864x486        60.0  
   640x480        59.9  
   720x405        60.0  
   640x360        60.0  

DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP2-1 disconnected (normal left inverted right x axis y axis)
DP2-2 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm
1920x1200 60.0*+
DP2-3 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis) /sys/class/drm/card0-DP-1/status:disconnected /sys/class/drm/card0-DP-2/status:disconnected /sys/class/drm/card0-DP-3/status:disconnected /sys/class/drm/card0-DP-4/status:connected /sys/class/drm/card0-DP-6/status:disconnected

Screen 0: minimum 8 x 8, current 1920 x 1200, maximum 32767 x 32767 eDP1 connected (normal left inverted right x axis y axis)

   1920x1080      60.0 +   59.9  
   1680x1050      60.0     59.9  
   1600x1024      60.2  
   1400x1050      60.0  
   1600x900       60.0  
   1280x1024      60.0  
   1440x900       59.9  
   1280x960       60.0  
   1368x768       60.0  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1280x720       60.0  
   1024x768       60.0  
   1024x576       60.0  
   960x540        60.0  
   800x600        60.3     56.2  
   864x486        60.0  
   640x480        59.9  
   720x405        60.0  
   640x360        60.0  

DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP2-1 disconnected (normal left inverted right x axis y axis)
DP2-2 connected primary 1920x1200+0+0 (normal left inverted right x axis y axis) 518mm x 324mm

   1920x1200      60.0*+
   1920x1080      60.0  
   1600x1200      60.0  
   1680x1050      59.9  
   1280x1024      60.0  
   1280x960       60.0  
   1024x768       60.0  
   800x600        60.3  
   640x480        59.9  
   720x400        70.1  

DP2-3 disconnected (normal left inverted right x axis y axis) HDMI1 disconnected (normal left inverted right x axis y axis) HDMI2 disconnected (normal left inverted right x axis y axis) VIRTUAL1 disconnected (normal left inverted right x axis y axis) /sys/class/drm/card0-DP-1/status:disconnected /sys/class/drm/card0-DP-2/status:disconnected /sys/class/drm/card0-DP-3/status:disconnected /sys/class/drm/card0-DP-4/status:connected /sys/class/drm/card0-DP-6/status:disconnected

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Acked-by on v1 1/1
#13 lore raw
In reply to Daniel Vetter
Quoted 6 lines · Daniel Vetter

I was under the misconception that the sysfs dev stuff can be fully set up, and then registered all in one step with device_add. That's true for properties and property groups, but not for parents and child devices. Those must be fully registered before you can register a child.

Quoted 8 lines

Add a bit of tracking to make sure that asynchronous mst connector hotplugging gets this right. For consistency we rely upon the implicit barriers of the connector->mutex, which is taken anyway, to ensure that at least either the connector or device registration call will work out.

Mildly tested since I can't reliably reproduce this on my mst box here.

Hmm, right it should prevent the oops on load. I think we need to control the async dp-mst better and stop it running until we have the device registered, and so if we use in the interim, plonk a WARN_ON on top for -next and try and fix it for realz. (Probably a drm_dp_mst_mgr_register() hook?)

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw

✓ Fi.CI.BAT: success for drm: Don't race connector registration

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: drm: Don't race connector registration
URL : https://patchwork.freedesktop.org/series/17910/
State : success

== Summary ==

Series 17910v1 drm: Don't race connector registration
https://patchwork.freedesktop.org/api/1.0/series/17910/revisions/1/mbox/

fi-bdw-5557u     total:246  pass:232  dwarn:0   dfail:0   fail:0   skip:14 
fi-bsw-n3050     total:246  pass:207  dwarn:0   dfail:0   fail:0   skip:39 
fi-bxt-j4205     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22 
fi-bxt-t5700     total:82   pass:69   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-j1900     total:246  pass:219  dwarn:0   dfail:0   fail:0   skip:27 
fi-byt-n2820     total:246  pass:215  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:246  pass:227  dwarn:0   dfail:0   fail:0   skip:19 
fi-hsw-4770r     total:246  pass:227  dwarn:0   dfail:0   fail:0   skip:19 
fi-ivb-3520m     total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-ivb-3770      total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-kbl-7500u     total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6260u     total:246  pass:233  dwarn:0   dfail:0   fail:0   skip:13 
fi-skl-6700hq    total:246  pass:226  dwarn:0   dfail:0   fail:0   skip:20 
fi-skl-6700k     total:246  pass:222  dwarn:3   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:246  pass:233  dwarn:0   dfail:0   fail:0   skip:13 
fi-snb-2520m     total:246  pass:215  dwarn:0   dfail:0   fail:0   skip:31 
fi-snb-2600      total:246  pass:214  dwarn:0   dfail:0   fail:0   skip:32 

8f7458237916d6c1e5e1e9ebfc5923a6d1658385 drm-tip: 2017y-01m-12d-15h-39m-40s UTC integration manifest f9e487c drm: Don't race connector registration

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3503/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx