Skip to contentSkip to conversation

drm/doc: Add a warning to drm_dev_is_unplugged

PATCH In review Daniel Vetter 3 participants 5 messages Jan 29, 2019

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

PATCH 1/1 drm/doc: Add a warning to drm_dev_is_unplugged

It's probably not what you want, definitely not after Noralf's work to add drm_dev_enter/exit.

Cc Noralf Trønnes <[email protected]>
---
 include/drm/drm_drv.h | 4 ++++
 1 file changed, 4 insertions(+)
include/drm/drm_drv.h +4 -0
index 9a688cf12881..ca46a45a9cce 100644
@@ -740,6 +740,10 @@ void drm_dev_unplug(struct drm_device *dev);
  * Unplugging itself is singalled through drm_dev_unplug(). If a device is
  * unplugged, these two functions guarantee that any store before calling
  * drm_dev_unplug() is visible to callers of this function after it completes
+ *
+ * WARNING: This function fundamentally races against drm_dev_unplug(). It is
+ * recommended that drivers instead use the underlying drm_dev_enter() and
+ * drm_dev_exit() function pairs.
  */
 static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 {
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

Den 29.01.2019 09.56, skrev Daniel Vetter:

Quoted 6 lines

It's probably not what you want, definitely not after Noralf's work to add drm_dev_enter/exit.

Cc Noralf Trønnes <[email protected]>

---

Quoted 9 lines
 include/drm/drm_drv.h | 4 ++++
 1 file changed, 4 insertions(+)
include/drm/drm_drv.h +0 -0
index 9a688cf12881..ca46a45a9cce 100644

include/drm/drm_drv.h void drm_dev_unplug(struct drm_device *dev); · line 749

Quoted 10 lines
include/drm/drm_drv.h +4 -0
@@ -740,6 +740,10 @@ void drm_dev_unplug(struct drm_device *dev);
  * Unplugging itself is singalled through drm_dev_unplug(). If a device is
  * unplugged, these two functions guarantee that any store before calling
  * drm_dev_unplug() is visible to callers of this function after it completes
+ *
+ * WARNING: This function fundamentally races against drm_dev_unplug(). It is
+ * recommended that drivers instead use the underlying drm_dev_enter() and
+ * drm_dev_exit() function pairs.
  */
 static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 11 lines · Noralf Trønnes

Den 29.01.2019 09.56, skrev Daniel Vetter:

Quoted 6 lines

It's probably not what you want, definitely not after Noralf's work to add drm_dev_enter/exit.

Cc Noralf Trønnes <[email protected]>

---

Thanks for your review, applied. btw I noticed that we also have plenty of drm_dev_is_unplugged in the core, not sure what to do about those. -Daniel

Quoted 20 lines
Quoted 20 lines
 include/drm/drm_drv.h | 4 ++++
 1 file changed, 4 insertions(+)
include/drm/drm_drv.h +4 -0
index 9a688cf12881..ca46a45a9cce 100644
@@ -740,6 +740,10 @@ void drm_dev_unplug(struct drm_device *dev);
  * Unplugging itself is singalled through drm_dev_unplug(). If a device is
  * unplugged, these two functions guarantee that any store before calling
  * drm_dev_unplug() is visible to callers of this function after it completes
+ *
+ * WARNING: This function fundamentally races against drm_dev_unplug(). It is
+ * recommended that drivers instead use the underlying drm_dev_enter() and
+ * drm_dev_exit() function pairs.
  */
 static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 {
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
#3 lore raw

Den 29.01.2019 10.51, skrev Daniel Vetter:

Quoted 7 lines · Noralf Trønnes
Quoted 6 lines

Den 29.01.2019 09.56, skrev Daniel Vetter:

Quoted 3 lines

It's probably not what you want, definitely not after Noralf's work to add drm_dev_enter/exit.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Cc Noralf Trønnes <[email protected]>

---

Thanks for your review, applied. btw I noticed that we also have plenty of drm_dev_is_unplugged in the core, not sure what to do about those.

I think they're fine. They're kind of a shortcut for some code paths, but in order to be safe I believe that it's the driver that needs to have the responsibility to protect its resources. This way we don't run into any suprises, since DRM and it's codepaths are quite complex.

Noralf.

Quoted 6 lines

-Daniel

Quoted 4 lines
Quoted 4 lines
 include/drm/drm_drv.h | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
include/drm/drm_drv.h +0 -0
index 9a688cf12881..ca46a45a9cce 100644
@@ -740,6 +740,10 @@ void drm_dev_unplug(struct drm_device *dev);
  * Unplugging itself is singalled through drm_dev_unplug(). If a device is
  * unplugged, these two functions guarantee that any store before calling
  * drm_dev_unplug() is visible to callers of this function after it completes
Quoted 8 lines

include/drm/drm_drv.h void drm_dev_unplug(struct drm_device *dev); · line 749

Quoted 8 lines
include/drm/drm_drv.h +4 -0
+ *
+ * WARNING: This function fundamentally races against drm_dev_unplug(). It is
+ * recommended that drivers instead use the underlying drm_dev_enter() and
+ * drm_dev_exit() function pairs.
  */
 static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Den 29.01.2019 11.20, skrev Noralf Trønnes:

Quoted 16 lines

Den 29.01.2019 10.51, skrev Daniel Vetter:

Quoted 13 lines · Noralf Trønnes
Quoted 11 lines

Den 29.01.2019 09.56, skrev Daniel Vetter:

Quoted 6 lines

It's probably not what you want, definitely not after Noralf's work to add drm_dev_enter/exit.

Cc Noralf Trønnes <[email protected]>

---

Quoted 8 lines
Quoted 2 lines

Thanks for your review, applied. btw I noticed that we also have plenty of drm_dev_is_unplugged in the core, not sure what to do about those.

I think they're fine. They're kind of a shortcut for some code paths, but in order to be safe I believe that it's the driver that needs to have the responsibility to protect its resources. This way we don't run into any suprises, since DRM and it's codepaths are quite complex.

To be a bit more precise, it also reports back to userspace for some code paths that might not reach the driver that the device is gone.

Quoted 25 lines

Noralf.

Quoted 6 lines

-Daniel

Quoted 4 lines
Quoted 4 lines
 include/drm/drm_drv.h | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
include/drm/drm_drv.h +0 -0
index 9a688cf12881..ca46a45a9cce 100644
@@ -740,6 +740,10 @@ void drm_dev_unplug(struct drm_device *dev);
  * Unplugging itself is singalled through drm_dev_unplug(). If a device is
  * unplugged, these two functions guarantee that any store before calling
  * drm_dev_unplug() is visible to callers of this function after it completes
Quoted 8 lines

include/drm/drm_drv.h void drm_dev_unplug(struct drm_device *dev); · line 749

Quoted 8 lines
include/drm/drm_drv.h +4 -0
+ *
+ * WARNING: This function fundamentally races against drm_dev_unplug(). It is
+ * recommended that drivers instead use the underlying drm_dev_enter() and
+ * drm_dev_exit() function pairs.
  */
 static inline bool drm_dev_is_unplugged(struct drm_device *dev)
 {
Quoted 5 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel