Skip to contentSkip to conversation

drm: document better that drivers shouldn't use drm_minor directly

PATCH In review Daniel Vetter 7 participants 7 messages Jan 4, 2023 – Jan 5, 2023

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

PATCH 1/1 drm: document better that drivers shouldn't use drm_minor directly

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Motvated by some discussion with Rodrigo on irc about how drm/xe should lay out its sysfs interfaces.

Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>
---
 include/drm/drm_device.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
include/drm/drm_device.h +15 -2
index 9923c7a6885e..b40e07e004ee 100644
@@ -87,10 +87,23 @@ struct drm_device {
 	 */
 	void *dev_private;
 
-	/** @primary: Primary node */
+	/**
+	 * @primary:
+	 *
+	 * Primary node. Drivers should not interact with this
+	 * directly. debugfs interface can be registered with
+	 * drm_debugfs_add_file(), and sysfs should be directly added on the
+	 * hardwire struct device @dev.
+	 */
 	struct drm_minor *primary;
 
-	/** @render: Render node */
+	/**
+	 * @render:
+	 *
+	 * Render node. Drivers should not interact with this directly ever.
+	 * Drivers should not expose any additional interfaces in debugfs or
+	 * sysfs on thise node.
+	 */
 	struct drm_minor *render;
 
 	/**
Signature · 1 line
2.37.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Daniel Vetter

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Motvated by some discussion with Rodrigo on irc about how drm/xe

^ Motivated

Quoted 8 lines

should lay out its sysfs interfaces.

Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>

Maxime

Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel Vetter
Quoted 37 lines · Daniel Vetter

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Motvated by some discussion with Rodrigo on irc about how drm/xe should lay out its sysfs interfaces.

Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>
---
  include/drm/drm_device.h | 17 +++++++++++++++--
  1 file changed, 15 insertions(+), 2 deletions(-)
include/drm/drm_device.h +7 -1
index 9923c7a6885e..b40e07e004ee 100644
@@ -87,10 +87,23 @@ struct drm_device {
  	 */
  	void *dev_private;
 
-	/** @primary: Primary node */
+	/**
+	 * @primary:
+	 *
+	 * Primary node. Drivers should not interact with this
+	 * directly. debugfs interface can be registered with
+	 * drm_debugfs_add_file(), and sysfs should be directly added on the
+	 * hardwire struct device @dev.

include/drm/drm_device.h struct drm_device { · line 105

Quoted 10 lines
include/drm/drm_device.h +7 -1
+	 */
  	struct drm_minor *primary;
 
-	/** @render: Render node */
+	/**
+	 * @render:
+	 *
+	 * Render node. Drivers should not interact with this directly ever.
+	 * Drivers should not expose any additional interfaces in debugfs or
+	 * sysfs on thise node.

I believe you meant s/thise/this.

Apart from this small nit,

Best Regards,
- Maíra Canal

Quoted 4 lines
include/drm/drm_device.h +1 -0
+	 */
  	struct drm_minor *render;
 
  	/**
Reviewed-by on v1 1/1
#3 lore raw
In reply to Daniel Vetter
Quoted 41 lines · Daniel Vetter

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Motvated by some discussion with Rodrigo on irc about how drm/xe should lay out its sysfs interfaces.

Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>
---
 include/drm/drm_device.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
include/drm/drm_device.h +8 -2
index 9923c7a6885e..b40e07e004ee 100644
@@ -87,10 +87,23 @@ struct drm_device {
 	 */
 	void *dev_private;
 
-	/** @primary: Primary node */
+	/**
+	 * @primary:
+	 *
+	 * Primary node. Drivers should not interact with this
+	 * directly. debugfs interface can be registered with
+	 * drm_debugfs_add_file(), and sysfs should be directly added on the
+	 * hardwire struct device @dev.
+	 */
 	struct drm_minor *primary;
 
-	/** @render: Render node */

include/drm/drm_device.h struct drm_device { · line 109

Quoted 10 lines
include/drm/drm_device.h +7 -0
+	/**
+	 * @render:
+	 *
+	 * Render node. Drivers should not interact with this directly ever.
+	 * Drivers should not expose any additional interfaces in debugfs or
+	 * sysfs on thise node.
+	 */
 	struct drm_minor *render;
 
 	/**

yeah, with those typos fixed, LGTM.

Thanks!

Quoted 3 lines
Signature · 1 line
2.37.2
Acked-by on v1 1/1
#4 lore raw
In reply to Daniel Vetter
Quoted 10 lines · Daniel Vetter

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Motvated by some discussion with Rodrigo on irc about how drm/xe should lay out its sysfs interfaces.

Thank you!

Quoted 44 lines
Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>
---
 include/drm/drm_device.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
include/drm/drm_device.h +15 -2
index 9923c7a6885e..b40e07e004ee 100644
@@ -87,10 +87,23 @@ struct drm_device {
 	 */
 	void *dev_private;
 
-	/** @primary: Primary node */
+	/**
+	 * @primary:
+	 *
+	 * Primary node. Drivers should not interact with this
+	 * directly. debugfs interface can be registered with
+	 * drm_debugfs_add_file(), and sysfs should be directly added on the
+	 * hardwire struct device @dev.
+	 */
 	struct drm_minor *primary;
 
-	/** @render: Render node */
+	/**
+	 * @render:
+	 *
+	 * Render node. Drivers should not interact with this directly ever.
+	 * Drivers should not expose any additional interfaces in debugfs or
+	 * sysfs on thise node.
+	 */
 	struct drm_minor *render;
 
 	/**
Signature · 1 line
2.37.2
#5 lore raw
In reply to Daniel Vetter
Quoted 7 lines · Daniel Vetter

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Care to expand on the vague "this is now getting fixed" part a bit?

I've seen the "Introduce debugfs device-centered functions" series from Maíra, but that doesn't solve everything. Not everything can use drm_debugfs_add_file().

BR,
Jani.

Quoted 44 lines

Motvated by some discussion with Rodrigo on irc about how drm/xe should lay out its sysfs interfaces.

Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>
---
 include/drm/drm_device.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
include/drm/drm_device.h +15 -2
index 9923c7a6885e..b40e07e004ee 100644
@@ -87,10 +87,23 @@ struct drm_device {
 	 */
 	void *dev_private;
 
-	/** @primary: Primary node */
+	/**
+	 * @primary:
+	 *
+	 * Primary node. Drivers should not interact with this
+	 * directly. debugfs interface can be registered with
+	 * drm_debugfs_add_file(), and sysfs should be directly added on the
+	 * hardwire struct device @dev.
+	 */
 	struct drm_minor *primary;
 
-	/** @render: Render node */
+	/**
+	 * @render:
+	 *
+	 * Render node. Drivers should not interact with this directly ever.
+	 * Drivers should not expose any additional interfaces in debugfs or
+	 * sysfs on thise node.
+	 */
 	struct drm_minor *render;
 
 	/**
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#6 lore raw
Quoted 9 lines · Jani Nikula
Quoted 7 lines · Daniel Vetter

The documentation for struct drm_minor already states this, but that's not always that easy to find.

Also due to historical reasons we still have the minor-centric (like drm_debugfs_create_files), but since this is now getting fixed we can put a few more pointers in place as to how this should be done ideally.

Quoted 5 lines

Care to expand on the vague "this is now getting fixed" part a bit?

I've seen the "Introduce debugfs device-centered functions" series from Maíra, but that doesn't solve everything. Not everything can use drm_debugfs_add_file().

Yeah this is only step 1 of the entire project, there's still more in the todo entry:

https://dri.freedesktop.org/docs/drm/gpu/todo.html#clean-up-the-debugfs-support

We need the same trick on the connector and crtc too. I think with those we should have most things covered?
-Daniel

Quoted 51 lines

BR,
Jani.

Quoted 44 lines

Motvated by some discussion with Rodrigo on irc about how drm/xe should lay out its sysfs interfaces.

Cc Rodrigo Vivi <[email protected]>
Cc Wambui Karuga <[email protected]>
Cc Maíra Canal <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Melissa Wen <[email protected]>
---
 include/drm/drm_device.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
include/drm/drm_device.h +15 -2
index 9923c7a6885e..b40e07e004ee 100644
@@ -87,10 +87,23 @@ struct drm_device {
 	 */
 	void *dev_private;
 
-	/** @primary: Primary node */
+	/**
+	 * @primary:
+	 *
+	 * Primary node. Drivers should not interact with this
+	 * directly. debugfs interface can be registered with
+	 * drm_debugfs_add_file(), and sysfs should be directly added on the
+	 * hardwire struct device @dev.
+	 */
 	struct drm_minor *primary;
 
-	/** @render: Render node */
+	/**
+	 * @render:
+	 *
+	 * Render node. Drivers should not interact with this directly ever.
+	 * Drivers should not expose any additional interfaces in debugfs or
+	 * sysfs on thise node.
+	 */
 	struct drm_minor *render;
 
 	/**
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch