mbox series

[v2,0/2] drm/panel: Add device link in drm_panel_attach()

Message ID cover.1519815150.git.jsarha@ti.com
Headers show
Series drm/panel: Add device link in drm_panel_attach() | expand

Message

Jyri Sarha Feb. 28, 2018, 11:09 a.m. UTC
The first version of the series can be found here:
https://lists.freedesktop.org/archives/dri-devel/2018-February/166909.html

The only change is the dev_err print in drm_panel_attach() if
device_link_add() fails.

The device_link_del() is still there in drm_panel_detach(), despite
Lukas Wunner's comment[1]. In the usual (currently all) cases things
would work perfectly without the call too, because
device_links_driver_cleanup() will eventually remove all orphaned
links. However, this would cause an error in the situation where a drm
device would like to detach a panel but remain operational, since the
drm device would be unbound for no good reason if the detached panel
is later unbound.

Anyway, if somebody still comes up with an argument for dropping the
device_link_del() from drm_panel_detach(), I'll do it as things will
normally work fine either case (drm devices don't normally detach
panels and remain operational).

These older comment still apply:

The first patch could be squashed to second, but kept is separate
since I think it is correct even without the second patch.

With these patches unbinding a panel driver in use does not cause
nasty backtraces and corrupted drm core structures, but instead it
cleanly unbind the drm master device at the same time.

The only down side (currently[2]) is that the drm device does not reprobe
if the panel driver is bound again, but everything should work if the
drm master driver is bound manually.

Best regards,
Jyri

[1] https://lists.freedesktop.org/archives/dri-devel/2018-February/167047.html
[2] https://lists.freedesktop.org/archives/dri-devel/2018-February/166907.html

Jyri Sarha (2):
  drm/panel: Remove drm_panel_detach() calls from all panel drives
  drm/panel: Add device_link from panel device to drm device

 drivers/gpu/drm/drm_panel.c                          | 12 ++++++++++++
 drivers/gpu/drm/panel/panel-innolux-p079zca.c        |  1 -
 drivers/gpu/drm/panel/panel-jdi-lt070me05000.c       |  1 -
 drivers/gpu/drm/panel/panel-lvds.c                   |  1 -
 drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c |  1 -
 drivers/gpu/drm/panel/panel-seiko-43wvf1g.c          |  1 -
 drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c      |  1 -
 drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c      |  1 -
 drivers/gpu/drm/panel/panel-simple.c                 |  1 -
 drivers/gpu/drm/panel/panel-sitronix-st7789v.c       |  1 -
 include/drm/drm_panel.h                              |  1 +
 11 files changed, 13 insertions(+), 9 deletions(-)

Comments

Lukas Wunner Feb. 28, 2018, 7:47 p.m. UTC | #1
On Wed, Feb 28, 2018 at 01:09:28PM +0200, Jyri Sarha wrote:
> The device_link_del() is still there in drm_panel_detach(), despite
> Lukas Wunner's comment[1]. In the usual (currently all) cases things
> would work perfectly without the call too, because
> device_links_driver_cleanup() will eventually remove all orphaned
> links. However, this would cause an error in the situation where a drm
> device would like to detach a panel but remain operational, since the
> drm device would be unbound for no good reason if the detached panel
> is later unbound.

Okay, in that case I'd suggest dropping the DL_FLAG_AUTOREMOVE flag
and keep the device_link_del().  That gives you the flexibility to
detach a panel at runtime and drop the device link, but also have
the DRM driver unbound once the panel driver is unbound.

If you have things like optional panels that can be detached without
the necessity to unbind the DRM driver, you need something else instead
of or on top of device links.  Perhaps some kind of notifier block.
And perhaps two drm_panel_attach/detach() helpers in the DRM library,
one with device link and one with notifier.

As stated in the device links documentation, optional dependencies
are "beyond the scope of device links."

Thanks,

Lukas
Jyri Sarha March 1, 2018, 5:42 p.m. UTC | #2
On 28/02/18 21:47, Lukas Wunner wrote:
> On Wed, Feb 28, 2018 at 01:09:28PM +0200, Jyri Sarha wrote:
>> The device_link_del() is still there in drm_panel_detach(), despite
>> Lukas Wunner's comment[1]. In the usual (currently all) cases things
>> would work perfectly without the call too, because
>> device_links_driver_cleanup() will eventually remove all orphaned
>> links. However, this would cause an error in the situation where a drm
>> device would like to detach a panel but remain operational, since the
>> drm device would be unbound for no good reason if the detached panel
>> is later unbound.
> 
> Okay, in that case I'd suggest dropping the DL_FLAG_AUTOREMOVE flag
> and keep the device_link_del().  That gives you the flexibility to
> detach a panel at runtime and drop the device link, but also have
> the DRM driver unbound once the panel driver is unbound.
> 
> If you have things like optional panels that can be detached without
> the necessity to unbind the DRM driver, you need something else instead
> of or on top of device links.  Perhaps some kind of notifier block.
> And perhaps two drm_panel_attach/detach() helpers in the DRM library,
> one with device link and one with notifier.
> 
> As stated in the device links documentation, optional dependencies
> are "beyond the scope of device links."
> 

I think the "optional panel" usage pattern is quite unlikely to ever
exist, but still it sound wrong to me to leave the links behind when
there is an apparent symmetry of detach and attach functions.

The situation would be different if we would get rid of the detach call
all together. After all the function in its current form is pretty
useless. The only purpose for its existence is marking the panel
available for other drm devices to use, which would suggest that the
"optional panel"-pattern is supported.

I think my current approach is fine (after removing the
DL_FLAG_AUTOREMOVE, I had not really understood its purpose before) if
we accept that the device link is there only as a precaution. But I am
also fine with removing the drm_panel_detach() function and laeving the
DL_FLAG_AUTOREMOVE flag there.

Best regards,
Jyri