Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-02-01 Thread Dave Hansen
On 02/01/2017 12:52 AM, Daniel Vetter wrote:
> On Tue, Jan 31, 2017 at 04:27:14PM -0800, Dave Hansen wrote:
>> 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:
> 
> 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

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.1485980540.start.log 2017-02-01 12:22:20.328242293 -0800
+++ xdebug.1485980621.dvi-replugged.log 2017-02-01 12:23:41.964241982 -0800
@@ -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
-   800x60060.3
-   640x48059.9
-   720x40070.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.

> 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  
   960x54060.0  
   800x60060.3 56.2  
   864x48660.0  
   640x48059.9  
   720x40560.0  
   640x36060.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  
   800x60060.3  
   640x48059.9  
   720x40070.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 inverte

Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-02-01 Thread Daniel Vetter
On Tue, Jan 31, 2017 at 04:27:14PM -0800, Dave Hansen wrote:
> 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:

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
> 
> Push DVI switch button to switch to other system:
> 
> > [ 6824.562838] drm_dp_destroy_port() kfree(8801ade46800)
> > [ 6824.563164] drm_dp_destroy_connector_work() port: 8801ade42000 
> > connector: 8801ade46000
> > [ 6824.563178] intel_dp_destroy_mst_connector() connector: 8801ade46000 
> > name: DP-3 &name: 8801ade46048 intel_connector: 8801ade46000
> > [ 6824.563186] drm_sysfs_connector_remove() connector: 8801ade46000 
> > kdev: 8801a941b400
> > [ 6824.571556] drm_connector_cleanup(8801ade46000)::329 
> > connector->registered: 0 cpu: 3
> > [ 6824.571570] drm_connector_cleanup() kfree() connector->name: 'DP-3' 
> > &name: 8801ade46048
> > [ 6824.571581] drm_dp_free_mst_port() kfree port: 8801ade42000
> > [ 6824.571587] drm_dp_destroy_connector_work() port: 8801ade42800 
> > connector: 8801ade47000
> > [ 6824.571594] intel_dp_destroy_mst_connector() connector: 8801ade47000 
> > name: DP-4 &name: 8801ade47048 intel_connector: 8801ade47000
> > [ 6824.571601] drm_sysfs_connector_remove() connector: 8801ade47000 
> > kdev: 8801a941a000
> > [ 6824.571915] drm_dp_free_mst_port() kfree port: 8801ade42800
> > [ 6824.571925] drm_dp_destroy_connector_work() port: 8801ade40800 
> > connector: 8801ade43000
> > [ 6824.571934] intel_dp_destroy_mst_connector() connector: 8801ade43000 
> > name: DP-6 &name: 8801ade43048 intel_connector: 8801ade43000
> > [ 6824.571943] drm_sysfs_connector_remove() connector: 8801ade43000 
> > kdev: 8801a9419800
> > [ 6824.572091] drm_connector_cleanup(8801ade43000)::329 
> > connector->registered: 0 cpu: 3
> > [ 6824.572101] drm_connector_cleanup() kfree() connector->name: 'DP-6' 
> > &name: 8801ade43048
> > [ 6824.572110] drm_dp_free_mst_branch_device() kfree mstb: 88030ac22600
> > [ 6824.572117] drm_dp_free_mst_port() kfree port: 8801ade40800
> 
> Push button to switch back:
> 
> > [ 6837.349693] drm_connector_init() connector->name: 'DP-3' &name: 
> > 88040231d848
> > [ 6837.349894] drm_sysfs_connector_add() connector: 88040231d800 kdev: 
> > 8801ae99f400
> > [ 6837.352786] drm_connector_init() connector->name: 'DP-5' &name: 
> > 880402318048
> > [ 6837.352951] drm_sysfs_connector_add() connector: 880402318000 kdev: 
> > 8801ae99c000
> > [ 6837.353036] drm_connector_init() connector->name: 'DP-6' &name: 
> > 88040d37f048
> > [ 6837.353154] drm_sysfs_connector_add() connector: 88040d37f000 kdev: 
> > 8801ae99ec00
> 
> I can type into the X session, but both screens are blank.  When I press
> Ctrl-Alt-F2, I get:
> 
> > [ 6850.494310] drm_connector_cleanup(8801ade47000)::329 
> > connector->registered: 0 cpu: 1
> > [ 6850.494314] drm_connector_cleanup() kfree() connector->name: 'DP-4' 
> > &name: 8801ade47048
> 
> Now I can switch back to X and everything is OK again.

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-31 Thread 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.

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

Push DVI switch button to switch to other system:

> [ 6824.562838] drm_dp_destroy_port() kfree(8801ade46800)
> [ 6824.563164] drm_dp_destroy_connector_work() port: 8801ade42000 
> connector: 8801ade46000
> [ 6824.563178] intel_dp_destroy_mst_connector() connector: 8801ade46000 
> name: DP-3 &name: 8801ade46048 intel_connector: 8801ade46000
> [ 6824.563186] drm_sysfs_connector_remove() connector: 8801ade46000 kdev: 
> 8801a941b400
> [ 6824.571556] drm_connector_cleanup(8801ade46000)::329 
> connector->registered: 0 cpu: 3
> [ 6824.571570] drm_connector_cleanup() kfree() connector->name: 'DP-3' &name: 
> 8801ade46048
> [ 6824.571581] drm_dp_free_mst_port() kfree port: 8801ade42000
> [ 6824.571587] drm_dp_destroy_connector_work() port: 8801ade42800 
> connector: 8801ade47000
> [ 6824.571594] intel_dp_destroy_mst_connector() connector: 8801ade47000 
> name: DP-4 &name: 8801ade47048 intel_connector: 8801ade47000
> [ 6824.571601] drm_sysfs_connector_remove() connector: 8801ade47000 kdev: 
> 8801a941a000
> [ 6824.571915] drm_dp_free_mst_port() kfree port: 8801ade42800
> [ 6824.571925] drm_dp_destroy_connector_work() port: 8801ade40800 
> connector: 8801ade43000
> [ 6824.571934] intel_dp_destroy_mst_connector() connector: 8801ade43000 
> name: DP-6 &name: 8801ade43048 intel_connector: 8801ade43000
> [ 6824.571943] drm_sysfs_connector_remove() connector: 8801ade43000 kdev: 
> 8801a9419800
> [ 6824.572091] drm_connector_cleanup(8801ade43000)::329 
> connector->registered: 0 cpu: 3
> [ 6824.572101] drm_connector_cleanup() kfree() connector->name: 'DP-6' &name: 
> 8801ade43048
> [ 6824.572110] drm_dp_free_mst_branch_device() kfree mstb: 88030ac22600
> [ 6824.572117] drm_dp_free_mst_port() kfree port: 8801ade40800

Push button to switch back:

> [ 6837.349693] drm_connector_init() connector->name: 'DP-3' &name: 
> 88040231d848
> [ 6837.349894] drm_sysfs_connector_add() connector: 88040231d800 kdev: 
> 8801ae99f400
> [ 6837.352786] drm_connector_init() connector->name: 'DP-5' &name: 
> 880402318048
> [ 6837.352951] drm_sysfs_connector_add() connector: 880402318000 kdev: 
> 8801ae99c000
> [ 6837.353036] drm_connector_init() connector->name: 'DP-6' &name: 
> 88040d37f048
> [ 6837.353154] drm_sysfs_connector_add() connector: 88040d37f000 kdev: 
> 8801ae99ec00

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

> [ 6850.494310] drm_connector_cleanup(8801ade47000)::329 
> connector->registered: 0 cpu: 1
> [ 6850.494314] drm_connector_cleanup() kfree() connector->name: 'DP-4' &name: 
> 8801ade47048

Now I can switch back to X and everything is OK again.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-30 Thread Daniel Vetter
On Mon, Jan 30, 2017 at 08:43:17AM -0800, Dave Hansen wrote:
> On 01/30/2017 01:12 AM, Daniel Vetter wrote:
> > On Thu, Jan 26, 2017 at 12:34:29PM -0800, Dave Hansen wrote:
> ...
> >> 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.

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.

> 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.
> 
> > - 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
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-30 Thread Dave Hansen
On 01/30/2017 01:12 AM, Daniel Vetter wrote:
> On Thu, Jan 26, 2017 at 12:34:29PM -0800, Dave Hansen wrote:
...
>> 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.

> - 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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-30 Thread Daniel Vetter
On Thu, Jan 26, 2017 at 12:34:29PM -0800, Dave Hansen wrote:
> On 01/25/2017 07:38 AM, Daniel Vetter wrote:
> > On Wed, Jan 25, 2017 at 07:20:45AM -0800, Dave Hansen wrote:
> >> On 01/24/2017 10:21 PM, Daniel Vetter wrote:
> >>> 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?
> 
> 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.

> 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:


diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c 
b/drivers/gpu/drm/i915/intel_dp_mst.c
index 38e3ca2f6f18..24ac2d1ce3ad 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -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
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-26 Thread Dave Hansen
On 01/25/2017 07:38 AM, Daniel Vetter wrote:
> On Wed, Jan 25, 2017 at 07:20:45AM -0800, Dave Hansen wrote:
>> On 01/24/2017 10:21 PM, Daniel Vetter wrote:
>>> 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?

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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-25 Thread Daniel Vetter
On Wed, Jan 25, 2017 at 07:20:45AM -0800, Dave Hansen wrote:
> On 01/24/2017 10:21 PM, Daniel Vetter wrote:
> > 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
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-25 Thread Dave Hansen
On 01/24/2017 10:21 PM, Daniel Vetter wrote:
> 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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-24 Thread Daniel Vetter
Hi Dave,

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

On Thu, Jan 12, 2017 at 05:17:21PM +0100, Daniel Vetter wrote:
> On Thu, Jan 12, 2017 at 05:15:56PM +0100, Daniel Vetter wrote:
> > 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.
> > 
> > Reported-by: Dave Hansen 
> > Cc: Dave Hansen 
> > Cc: Chris Wilson 
> > Signed-off-by: Daniel Vetter 
> 
> Cc: sta...@vger.kernel.org
> 
> > ---
> >  drivers/gpu/drm/drm_connector.c | 3 +++
> >  drivers/gpu/drm/drm_drv.c   | 4 
> >  include/drm/drmP.h  | 1 +
> >  3 files changed, 8 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_connector.c 
> > b/drivers/gpu/drm/drm_connector.c
> > index c75ab242f907..5999cb83d05b 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -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;
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 7e24103c47f1..cad6df626678 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -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);
> >  
> > diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> > index c537c278a4be..ec105c339347 100644
> > --- a/include/drm/drmP.h
> > +++ b/include/drm/drmP.h
> > @@ -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;
> > -- 
> > 2.5.5
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-12 Thread Chris Wilson
On Thu, Jan 12, 2017 at 05:15:56PM +0100, Daniel Vetter wrote:
> 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.

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?)

Acked-by: Chris Wilson 
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-12 Thread Daniel Vetter
On Thu, Jan 12, 2017 at 05:15:56PM +0100, Daniel Vetter wrote:
> 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.
> 
> Reported-by: Dave Hansen 
> Cc: Dave Hansen 
> Cc: Chris Wilson 
> Signed-off-by: Daniel Vetter 

Cc: sta...@vger.kernel.org

> ---
>  drivers/gpu/drm/drm_connector.c | 3 +++
>  drivers/gpu/drm/drm_drv.c   | 4 
>  include/drm/drmP.h  | 1 +
>  3 files changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index c75ab242f907..5999cb83d05b 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -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;
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 7e24103c47f1..cad6df626678 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -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);
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index c537c278a4be..ec105c339347 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -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;
> -- 
> 2.5.5
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm: Don't race connector registration

2017-01-12 Thread 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.

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

Reported-by: Dave Hansen 
Cc: Dave Hansen 
Cc: Chris Wilson 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_connector.c | 3 +++
 drivers/gpu/drm/drm_drv.c   | 4 
 include/drm/drmP.h  | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index c75ab242f907..5999cb83d05b 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 7e24103c47f1..cad6df626678 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -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);
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c537c278a4be..ec105c339347 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -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;
-- 
2.5.5

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx