drm: introduce drm_connector_plug_all() helper
Subsystems (5)
cover drm: introduce drm_connector_plug_all() helper
As a pair to already existing drm_connector_unplug_all() we're adding generic implementation of what is already done in some drivers.
After implementation of that new helper we're updating 2 drivers that used to use it's own implementation:
[1] atmel_hlcdc
[2] rcar_du
Other drivers still use load() callback and so should be first modified so their load() gets called from their probe() explicitly.
Build- and run-tested on yet to be upstreamed ARC PGU (part of AXS10x board).
Alexey Brodkin (3):
drm: introduce drm_connector_plug_all() helper
drm: atmel_hldc - use generic drm_connector_plug_all() helper
drm: rcar-du - use generic drm_connector_plug_all() helper
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 39 ++---------------------- drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c | 3 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +----- include/drm/drm_crtc.h | 3 +- 5 files changed, 50 insertions(+), 48 deletions(-)
Signature · 1 line
2.5.0
PATCH 1/3 drm: introduce drm_connector_plug_all() helper
As a pair to already existing drm_connector_unplug_all() we're adding generic implementation of what is already done in some drivers.
Once this helper is implemented we'll be ready to switch existing driver-specific implementations with generic one.
--- drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c | 3 ++- include/drm/drm_crtc.h | 3 ++- 3 files changed, 47 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +43 -1
@@ -1080,6 +1080,46 @@ void drm_connector_unregister(struct drm_connector *connector) }EXPORT_SYMBOL (drm_connector_unregister); +/** +* drm_connector_plug_all - register connector userspace interfaces +* @dev: drm device +* +* This function registers all connector userspace interfaces in sysfs. Should +* be call when the device is disconnected, e.g. from an usb driver's +* ->connect callback. +*/ +int drm_connector_plug_all (struct drm_device *dev) +{ +struct drm_connector *connector, *failed; +int ret; + +mutex_lock (&dev->mode_config.mutex); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { + ret =drm_connector_register (connector); +if (ret) { + failed = connector; + goto err; + } + } + +mutex_unlock (&dev->mode_config.mutex); + +return 0 ; + +err: +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (failed == connector) +break ; + +drm_connector_unregister (connector); + } + +mutex_unlock (&dev->mode_config.mutex); + +return ret; +} +EXPORT_SYMBOL (drm_connector_plug_all);/** * drm_connector_unplug_all - unregister connector userspace interfaces
@@ -1093,10 +1133,12 @@ void drm_connector_unplug_all(struct drm_device *dev) {struct drm_connector *connector; -/* FIXME: taking the mode config mutex ends up in a clash with sysfs */ +mutex_lock (&dev->mode_config.mutex); +list_for_each_entry (connector, &dev->mode_config.connector_list, head)drm_connector_unregister (connector); +mutex_unlock (&dev->mode_config.mutex); }EXPORT_SYMBOL (drm_connector_unplug_all);
drivers/gpu/drm/drm_drv.c +2 -1
@@ -715,7 +715,8 @@ EXPORT_SYMBOL(drm_dev_unref);* * Register the DRM device @dev with the system, advertise device to user-space * and start normal device operation. @dev must be allocated via drm_dev_alloc() -* previously. +* previously and right after drm_dev_register() driver should call +* drm_connector_plug_all() to register all connectors in sysfs. * * Never call this twice on any device! *
include/drm/drm_crtc.h +2 -1
@@ -2214,7 +2214,8 @@ void drm_connector_unregister(struct drm_connector *connector);extern void drm_connector_cleanup (struct drm_connector *connector);extern unsigned int drm_connector_index (struct drm_connector *connector); -/* helper to unplug all connectors from sysfs for device */ +/* helpers to plug/unplug all connectors to/from sysfs for device */ +extern int drm_connector_plug_all (struct drm_device *dev);extern void drm_connector_unplug_all (struct drm_device *dev);extern int drm_bridge_add (struct drm_bridge *bridge);
Signature · 1 line
2.5.0
Quoted 20 lines · Alexey Brodkin
As a pair to already existing
drm_connector_unplug_all()we're adding generic implementation of what is already done in some drivers.Once this helper is implemented we'll be ready to switch existing driver-specific implementations with generic one.
Signed-off-by Alexey Brodkin <[email protected]>Cc Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c | 3 ++- include/drm/drm_crtc.h | 3 ++- 3 files changed, 47 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c void drm_connector_unregister(struct drm_connector *connector) · line 1088
Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +6
-0@@ -1080,6 +1080,46 @@ void drm_connector_unregister(struct drm_connector *connector) }EXPORT_SYMBOL (drm_connector_unregister); +/** +* drm_connector_plug_all - register connector userspace interfaces +* @dev: drm device +* +* This function registers all connector userspace interfaces in sysfs. Should +* be call when the device is disconnected, e.g. from an usb driver's
Still talks about disconnect ;-) Please also mention that this just calls drm_connector_register() exactly like this including () to generate a kerneldoc hyperlink.
drivers/gpu/drm/drm_crtc.c void drm_connector_unregister(struct drm_connector *connector) · line 1089
Quoted 1 line
drivers/gpu/drm/drm_crtc.c +1
-0+* ->connect callback.
Returns: section is missing, specifying how this can fail. Just copy the one from connector_register().
drivers/gpu/drm/drm_crtc.c void drm_connector_unregister(struct drm_connector *connector) · line 1098
Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +9
-0+*/ +int drm_connector_plug_all (struct drm_device *dev) +{ +struct drm_connector *connector, *failed; +int ret; + +mutex_lock (&dev->mode_config.mutex); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) {
for_each_connector here please. And the s/plug/register/ naming discussion we've had.
Quoted 28 lines
drivers/gpu/drm/drm_crtc.c +24
-0+ ret =drm_connector_register (connector); +if (ret) { + failed = connector; + goto err; + } + } + +mutex_unlock (&dev->mode_config.mutex); + +return 0 ; + +err: +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (failed == connector) +break ; + +drm_connector_unregister (connector); + } + +mutex_unlock (&dev->mode_config.mutex); + +return ret; +} +EXPORT_SYMBOL (drm_connector_plug_all);/** * drm_connector_unplug_all - unregister connector userspace interfaces
drivers/gpu/drm/drm_crtc.c void drm_connector_unplug_all(struct drm_device *dev) · line 1136
Quoted 5 lines
drivers/gpu/drm/drm_crtc.c +1
-1@@ -1093,10 +1133,12 @@ void drm_connector_unplug_all(struct drm_device *dev) {struct drm_connector *connector; -/* FIXME: taking the mode config mutex ends up in a clash with sysfs */ +mutex_lock (&dev->mode_config.mutex);
You can't drop that FIXME, the bug is still there.
Quoted 13 lines
drivers/gpu/drm/drm_crtc.c +2
-0+list_for_each_entry (connector, &dev->mode_config.connector_list, head)drm_connector_unregister (connector); +mutex_unlock (&dev->mode_config.mutex); }EXPORT_SYMBOL (drm_connector_unplug_all);drivers/gpu/drm/drm_drv.c +0
-0
drivers/gpu/drm/drm_drv.c EXPORT_SYMBOL(drm_dev_unref); · line 718
Quoted 5 lines
drivers/gpu/drm/drm_drv.c +1
-1@@ -715,7 +715,8 @@ EXPORT_SYMBOL(drm_dev_unref);* * Register the DRM device @dev with the system, advertise device to user-space * and start normal device operation. @dev must be allocated via drm_dev_alloc() -* previously. +* previously and right after drm_dev_register() driver should call
It'd do 2 sentences here for simplicity, not connect them with and. Also "... _the_ driver should ..."
drivers/gpu/drm/drm_drv.c EXPORT_SYMBOL(drm_dev_unref); · line 719
Quoted 1 line
drivers/gpu/drm/drm_drv.c +1
-0+* drm_connector_plug_all() to register all connectors in sysfs.
Maybe mention why this is separate: "This is a separate call for backwards compatibility with drivers still using the deprecated ->load() callback, where connectors are registered from within the ->load() callback."
Besides these details looks good.
-Daniel
Quoted 20 lines
drivers/gpu/drm/drm_drv.c +0
-0* * Never call this twice on any device! * include/drm/drm_crtc.h +2
-1@@ -2214,7 +2214,8 @@ void drm_connector_unregister(struct drm_connector *connector);extern void drm_connector_cleanup (struct drm_connector *connector);extern unsigned int drm_connector_index (struct drm_connector *connector); -/* helper to unplug all connectors from sysfs for device */ +/* helpers to plug/unplug all connectors to/from sysfs for device */ +extern int drm_connector_plug_all (struct drm_device *dev);extern void drm_connector_unplug_all (struct drm_device *dev);extern int drm_bridge_add (struct drm_bridge *bridge);Signature · 1 line
2.5.0
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
Hi Daniel,
Quoted 26 lines · Daniel Vetter
Quoted 25 lines · Alexey Brodkin
As a pair to already existing
drm_connector_unplug_all()we're adding generic implementation of what is already done in some drivers.Once this helper is implemented we'll be ready to switch existing driver-specific implementations with generic one.
Signed-off-by Alexey Brodkin <[email protected]>Cc Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>---
drivers/gpu/drm/drm_crtc.c | 44 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-- drivers/gpu/drm/drm_drv.c | 3 +-+--
include/drm/drm_crtc.h | 3 +-+--3 files changed, 47 insertions(+-), 3 deletions(-)drivers/gpu/drm/drm_crtc.c +1
-1--- a/drivers/gpu/drm/drm_crtc.c +-+-+- b/drivers/gpu/drm/drm_crtc.c@@ -1080,6 +-1080,46 @@ void
drm_connector_unregister(struct drm_connector *connector)}
EXPORT_SYMBOL(drm_connector_unregister);
+-/**
Quoted 8 lines
Quoted 5 lines
+- * drm_connector_plug_all - register connector userspace interfaces +- * @dev: drm device +- * +- * This function registers all connector userspace interfaces in sysfs. Should +- * be call when the device is disconnected, e.g. from an usb driver'sStill talks about disconnect ;-) Please also mention that this just calls
drm_connector_register()exactly like this including () to generate a kerneldoc hyperlink.
Well I intentionally left in description of drm_connector_register_all():
"Should be call when the device is disconnected, e.g. from an usb driver's ->connect callback."
I did mean it. Or is this statement is incorrect and example of invocation of drm_connector_register_all() should be different? Which one works better then?
Quoted 4 lines
Quoted 2 lines
+- * ->connect callback.
Returns: section is missing, specifying how this can fail. Just copy the one from
connector_register().
Yeah, correct. Blind copy-paste doesn't work equally good always :(
Quoted 10 lines
Quoted 10 lines
+- */ +-int drm_connector_plug_all(struct drm_device *dev) +-{ +- struct drm_connector *connector, *failed; +- int ret; +- +- mutex_lock(&dev->mode_config.mutex); +- +- list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
Quoted 2 lines
for_each_connectorhere please. And the s/plug/register/ naming discussion we've had.
Ok.
Quoted 27 lines
Quoted 27 lines
+- ret = drm_connector_register(connector); +- if (ret) { +- failed = connector; +- goto err; +- } +- } +- +- mutex_unlock(&dev->mode_config.mutex); +- +- return 0; +- +-err: +- list_for_each_entry(connector, &dev->mode_config.connector_list, head) { +- if (failed == connector) +- break; +- +- drm_connector_unregister(connector); +- } +- +- mutex_unlock(&dev->mode_config.mutex); +- +- return ret; +-} +-EXPORT_SYMBOL(drm_connector_plug_all);
/**
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c
Quoted 7 lines
*
drm_connector_unplug_all- unregister connector userspace interfaces @@ -1093,10 +-1133,12 @@ voiddrm_connector_unplug_all(struct drm_device *dev){
structdrm_connector*connector;drivers/gpu/drm/drm_crtc.c +1
-1-/* FIXME: taking the mode config mutex ends up in a clash with sysfs */ +-mutex_lock (&dev->mode_config.mutex);You can't drop that FIXME, the bug is still there.
That's clear given your explanation in the previous email.
Quoted 13 lines
Quoted 13 lines
+-
list_for_each_entry(connector, &dev->mode_config.connector_list, head)drm_connector_unregister(connector);
+-mutex_unlock(&dev->mode_config.mutex);
}
EXPORT_SYMBOL(drm_connector_unplug_all);drivers/gpu/drm/drm_drv.c +1
-1--- a/drivers/gpu/drm/drm_drv.c +-+-+- b/drivers/gpu/drm/drm_drv.c
Quoted 8 lines
Quoted 6 lines
@@ -715,7 +-715,8 @@
EXPORT_SYMBOL(drm_dev_unref);
*
* Register the DRM device @dev with the system, advertise device to user-space
* and start normal device operation. @dev must be allocated viadrm_dev_alloc()
- * previously.
+- * previously and right afterdrm_dev_register()driver should callIt'd do 2 sentences here for simplicity, not connect them with and. Also "... _the_ driver should ..."
Ok.
Quoted 5 lines
Quoted 2 lines
+- *
drm_connector_plug_all()to register all connectors in sysfs.Maybe mention why this is separate: "This is a separate call for backwards compatibility with drivers still using the deprecated ->load() callback, where connectors are registered from within the ->load() callback."
Ok.
-Alexey
Quoted 38 lines · Alexey Brodkin
Hi Daniel,
Quoted 26 lines · Daniel Vetter
Quoted 25 lines · Alexey Brodkin
As a pair to already existing
drm_connector_unplug_all()we're adding generic implementation of what is already done in some drivers.Once this helper is implemented we'll be ready to switch existing driver-specific implementations with generic one.
Signed-off-by Alexey Brodkin <[email protected]>Cc Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>---
drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c | 3 ++-
include/drm/drm_crtc.h | 3 ++-3 files changed, 47 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0@@ -1080,6 +1080,46 @@ void drm_connector_unregister(struct drm_connector *connector) } EXPORT_SYMBOL(drm_connector_unregister);
+/**Quoted 8 lines
Quoted 5 lines
+ *
drm_connector_plug_all- register connector userspace interfaces
+ * @dev: drm device
+ *
+ * This function registers all connector userspace interfaces in sysfs. Should
+ * be call when the device is disconnected, e.g. from an usb driver'sStill talks about disconnect ;-) Please also mention that this just calls
drm_connector_register()exactly like this including () to generate a kerneldoc hyperlink.
Quoted 3 lines
Well I intentionally left in description of
drm_connector_register_all():
"Should be call when the device is disconnected, e.g. from an usb driver's ->connect callback."
You use "disconnected" for connecting stuff. That doesn't make sense to me at all - register_all is for when you want to publish something, not for unpublishing when the device disappears. Or maybe this is a case of lost in translation, and you mean something else?
-Daniel
Quoted 96 lines
I did mean it. Or is this statement is incorrect and example of invocation of
drm_connector_register_all()should be different? Which one works better then?Quoted 4 lines
Quoted 2 lines
+ * ->connect callback.
Returns: section is missing, specifying how this can fail. Just copy the one from
connector_register().Yeah, correct. Blind copy-paste doesn't work equally good always :(
Quoted 12 lines
drivers/gpu/drm/drm_crtc.c void drm_connector_unregister(struct drm_connector *connector) · line 1098
Quoted 10 lines
+ */
drivers/gpu/drm/drm_crtc.c +8
-0+int drm_connector_plug_all (struct drm_device *dev) +{ +struct drm_connector *connector, *failed; +int ret; + +mutex_lock (&dev->mode_config.mutex); + +list_for_each_entry (connector, &dev->mode_config.connector_list, head) {
for_each_connectorhere please. And the s/plug/register/ naming discussion we've had.Ok.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/drm_crtc.c +24
-0+ ret =drm_connector_register (connector); +if (ret) { + failed = connector; + goto err; + } + } + +mutex_unlock (&dev->mode_config.mutex); + +return 0 ; + +err: +list_for_each_entry (connector, &dev->mode_config.connector_list, head) { +if (failed == connector) +break ; + +drm_connector_unregister (connector); + } + +mutex_unlock (&dev->mode_config.mutex); + +return ret; +} +EXPORT_SYMBOL (drm_connector_plug_all);
/**Quoted 8 lines
drivers/gpu/drm/drm_crtc.c void drm_connector_unplug_all(struct drm_device *dev) · line 1136
Quoted 7 lines
*
drm_connector_unplug_all- unregister connector userspace interfacesdrivers/gpu/drm/drm_crtc.c +0
-0@@ -1093,10 +1133,12 @@ void drm_connector_unplug_all(struct drm_device *dev) { struct drm_connector *connector;drivers/gpu/drm/drm_crtc.c +1
-1-/* FIXME: taking the mode config mutex ends up in a clash with sysfs */ +mutex_lock (&dev->mode_config.mutex);You can't drop that FIXME, the bug is still there.
That's clear given your explanation in the previous email.
Quoted 13 lines
Quoted 13 lines
+
list_for_each_entry(connector, &dev->mode_config.connector_list, head)drm_connector_unregister(connector);drivers/gpu/drm/drm_crtc.c +1
-0+mutex_unlock (&dev->mode_config.mutex);}
EXPORT_SYMBOL(drm_connector_unplug_all);drivers/gpu/drm/drm_drv.c +0
-0Quoted 8 lines
drivers/gpu/drm/drm_drv.c EXPORT_SYMBOL(drm_dev_unref); · line 718
Quoted 6 lines
drivers/gpu/drm/drm_drv.c +1
-1@@ -715,7 +715,8 @@ EXPORT_SYMBOL(drm_dev_unref); * * Register the DRM device @dev with the system, advertise device to user-space * and start normal device operation. @dev must be allocated via drm_dev_alloc() - * previously. + * previously and right after drm_dev_register() driver should callIt'd do 2 sentences here for simplicity, not connect them with and. Also "... _the_ driver should ..."
Ok.
Quoted 5 lines
drivers/gpu/drm/drm_drv.c EXPORT_SYMBOL(drm_dev_unref); · line 719
Quoted 2 lines
drivers/gpu/drm/drm_drv.c +1
-0+* drm_connector_plug_all() to register all connectors in sysfs. Maybe mention why this is separate: "This is a separate call for backwards compatibility with drivers still using the deprecated ->load() callback, where connectors are registered from within the ->load() callback."
Ok.
-Alexey
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
Hi Daniel,
Quoted 41 lines · Daniel Vetter
Quoted 40 lines · Alexey Brodkin
Hi Daniel,
Quoted 36 lines · Daniel Vetter
Quoted 25 lines · Alexey Brodkin
As a pair to already existing
drm_connector_unplug_all()we're adding generic implementation of what is already done in some drivers.Once this helper is implemented we'll be ready to switch existing driver-specific implementations with generic one.
Signed-off-by Alexey Brodkin <[email protected]>Cc Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>---
drivers/gpu/drm/drm_crtc.c | 44 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-- drivers/gpu/drm/drm_drv.c | 3 +-+--
include/drm/drm_crtc.h | 3 +-+--3 files changed, 47 insertions(+-), 3 deletions(-)drivers/gpu/drm/drm_crtc.c +1
-1--- a/drivers/gpu/drm/drm_crtc.c +-+-+- b/drivers/gpu/drm/drm_crtc.c@@ -1080,6 +-1080,46 @@ void
drm_connector_unregister(struct drm_connector *connector)}
EXPORT_SYMBOL(drm_connector_unregister);Quoted 6 lines
+-/** +- * drm_connector_plug_all - register connector userspace interfaces +- * @dev: drm device +- * +- * This function registers all connector userspace interfaces in sysfs. Should +- * be call when the device is disconnected, e.g. from an usb driver'sStill talks about disconnect ;-) Please also mention that this just calls
drm_connector_register()exactly like this including () to generate a kerneldoc hyperlink.
Quoted 7 lines
Quoted 3 lines
Well I intentionally left in description of
drm_connector_register_all():
"Should be call when the device is disconnected, e.g. from an usb driver's ->connect callback."You use "disconnected" for connecting stuff. That doesn't make sense to me at all -
register_allis for when you want to publish something, not for unpublishing when the device disappears. Or maybe this is a case of lost in translation, and you mean something else?
Let me try to explain what I meant.
We execute ->connect() callback of USB device when USB device is still in "disconnected" state (well at least that was my thought). And only when that ->connect() callback succeeds we're entering "connected" state.
Probably above sentence is not correct. Then could you please help me with correct wording of comment to drm_connector_register_all()?
-Alexey
Quoted 52 lines · Alexey Brodkin
Hi Daniel,
Quoted 41 lines · Daniel Vetter
Quoted 40 lines · Alexey Brodkin
Hi Daniel,
Quoted 36 lines · Daniel Vetter
Quoted 24 lines · Alexey Brodkin
As a pair to already existing
drm_connector_unplug_all()we're adding generic implementation of what is already done in some drivers.Once this helper is implemented we'll be ready to switch existing driver-specific implementations with generic one.
Signed-off-by Alexey Brodkin <[email protected]>Cc Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>---
drivers/gpu/drm/drm_crtc.c | 44 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c | 3 ++-
include/drm/drm_crtc.h | 3 ++-3 files changed, 47 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0@@ -1080,6 +1080,46 @@ void drm_connector_unregister(struct drm_connector *connector) } EXPORT_SYMBOL(drm_connector_unregister);Quoted 7 lines
+/**
+ *drm_connector_plug_all- register connector userspace interfaces
+ * @dev: drm device
+ *
+ * This function registers all connector userspace interfaces in sysfs. Should
+ * be call when the device is disconnected, e.g. from an usb driver'sStill talks about disconnect ;-) Please also mention that this just calls
drm_connector_register()exactly like this including () to generate a kerneldoc hyperlink.Quoted 7 lines
Quoted 3 lines
Well I intentionally left in description of
drm_connector_register_all():
"Should be call when the device is disconnected, e.g. from an usb driver's ->connect callback."You use "disconnected" for connecting stuff. That doesn't make sense to me at all -
register_allis for when you want to publish something, not for unpublishing when the device disappears. Or maybe this is a case of lost in translation, and you mean something else?
Quoted 8 lines
Let me try to explain what I meant.
We execute ->connect() callback of USB device when USB device is still in "disconnected" state (well at least that was my thought). And only when that ->connect() callback succeeds we're entering "connected" state.
Probably above sentence is not correct. Then could you please help me with correct wording of comment to drm_connector_register_all()?
Yeah, your sentence suggests more that register_all should be called when someone unplugs udl. What about:
"This function registers all connectors in sysfs and other places so that userspace can start to access them. Drivers can call it after calling drm_dev_register() to complete the device registration, if they don't call drm_connector_register() on each connector individually.
When a device is unplugged and should be removed from userspace access, call drm_connector_unregister_all(), which is the inverse of this function."
And for drm_connector_unregister_all:
"This functions unregisters all connectors from sysfs and other places so that userspace can no longer access them. Drivers should call this as the first step tearing down the device instace, or when the underlying physical device disappeared (e.g. USB unplug), right before calling drm_dev_unregister()."
Thinking about this we might want to merge drm_dev_register and drm_connector_register_all, but that's a long-term goal which will need some trickery to no break drivers.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 2/3 drm: atmel_hldc - use generic drm_connector_plug_all() helper
In reply to Alexey BrodkinThis driver used to have its own implementation of connector_plug_all() which actually was taken as a prototype of drm_connector_plug_all().
Now when drm_connector_plug_all() exists reusing it here.
And while at it getting rid of mutex in both plug() and unplug() because they were moved to generic helper as well.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 39 ++-------------------------- 1 file changed, 2 insertions(+), 37 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +2 -37
@@ -584,41 +584,6 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)destroy_workqueue (dc->wq); } -static int atmel_hlcdc_dc_connector_plug_all (struct drm_device *dev) -{ -struct drm_connector *connector, *failed; -int ret; - -mutex_lock (&dev->mode_config.mutex); -list_for_each_entry (connector, &dev->mode_config.connector_list, head) { - ret =drm_connector_register (connector); -if (ret) { - failed = connector; - goto err; - } - } -mutex_unlock (&dev->mode_config.mutex); -return 0 ; - -err: -list_for_each_entry (connector, &dev->mode_config.connector_list, head) { -if (failed == connector) -break ; - -drm_connector_unregister (connector); - } -mutex_unlock (&dev->mode_config.mutex); - -return ret; -} - -static void atmel_hlcdc_dc_connector_unplug_all (struct drm_device *dev) -{ -mutex_lock (&dev->mode_config.mutex); -drm_connector_unplug_all (dev); -mutex_unlock (&dev->mode_config.mutex); -} -static void atmel_hlcdc_dc_lastclose (struct drm_device *dev) {struct atmel_hlcdc_dc *dc = dev->dev_private;
@@ -736,7 +701,7 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)if (ret) goto err_unload; - ret =atmel_hlcdc_dc_connector_plug_all (ddev); + ret =drm_connector_plug_all (ddev);if (ret) goto err_unregister;
@@ -758,7 +723,7 @@ static int atmel_hlcdc_dc_drm_remove(struct platform_device *pdev) {struct drm_device *ddev =platform_get_drvdata (pdev); -atmel_hlcdc_dc_connector_unplug_all (ddev); +drm_connector_unplug_all (ddev);drm_dev_unregister (ddev);atmel_hlcdc_dc_unload (ddev);drm_dev_unref (ddev);
Signature · 1 line
2.5.0
PATCH 3/3 drm: rcar-du - use generic drm_connector_plug_all() helper
In reply to Alexey BrodkinNow when generic drm_connector_plug_all() helper exists we may safely substiture with it driver-specific implementation of connectors plugging in sysfs.
--- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/rcar-du/rcar_du_drv.c +1 -8
@@ -364,14 +364,7 @@ static int rcar_du_probe(struct platform_device *pdev)if (ret) goto error; -mutex_lock (&ddev->mode_config.mutex); -drm_for_each_connector (connector, ddev) { - ret =drm_connector_register (connector); -if (ret <0 ) -break ; - } -mutex_unlock (&ddev->mode_config.mutex); - + ret =drm_connector_plug_all (ddev);if (ret <0 ) goto error;
Signature · 1 line
2.5.0