Skip to contentSkip to conversation

drm/drv: use enum drm_minor_type when appropriate

PATCH In review Simon Ser 3 participants 7 messages Jul 14, 2023

Subsystems (2)
lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/3 drm/drv: use enum drm_minor_type when appropriate

This makes it easier to figure out what the "type" variable can be set to when reading the implementation of these functions.

Cc Christian König <[email protected]>
Cc James Zhu <[email protected]>
Cc Marek Olšák <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_drv.c +4 -4
index 12687dd9e1ac..3eda026ffac6 100644
@@ -84,7 +84,7 @@ DEFINE_STATIC_SRCU(drm_unplug_srcu);
  */
 
 static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
-					     unsigned int type)
+					     enum drm_minor_type type)
 {
 	switch (type) {
 	case DRM_MINOR_PRIMARY:
@@ -116,7 +116,7 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 	}
 }
 
-static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
+static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
 	unsigned long flags;
@@ -160,7 +160,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
 	return 0;
 }
 
-static int drm_minor_register(struct drm_device *dev, unsigned int type)
+static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
 	unsigned long flags;
@@ -203,7 +203,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
 	return ret;
 }
 
-static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
+static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
 	unsigned long flags;
Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 2/3 drm/file: use explicit values for enum drm_minor_type

This makes it clearer that the values cannot be changed because they are ABI.

Cc Christian König <[email protected]>
Cc James Zhu <[email protected]>
Cc Marek Olšák <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 include/drm/drm_file.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/drm/drm_file.h +4 -4
index 966912053cb0..010239392adf 100644
@@ -50,16 +50,16 @@ struct file;
  * header include loops we need it here for now.
  */
 
-/* Note that the order of this enum is ABI (it determines
+/* Note that the values of this enum are ABI (it determines
  * /dev/dri/renderD* numbers).
  *
  * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
  * be implemented before we hit any future
  */
 enum drm_minor_type {
-	DRM_MINOR_PRIMARY,
-	DRM_MINOR_CONTROL,
-	DRM_MINOR_RENDER,
+	DRM_MINOR_PRIMARY = 0,
+	DRM_MINOR_CONTROL = 1,
+	DRM_MINOR_RENDER = 2,
 	DRM_MINOR_ACCEL = 32,
 };
 
Signature · 1 line
2.41.0
author
#2 lore raw

RFC PATCH 3/3 drm/file: drop DRM_MINOR_CONTROL

In reply to Simon Ser

This entry should never be used by the kernel. Record the historical context in a comment.

Cc Christian König <[email protected]>
Cc James Zhu <[email protected]>
Cc Marek Olšák <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 include/drm/drm_file.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/drm/drm_file.h +3 -1
index 010239392adf..a23cc2f6163f 100644
@@ -53,12 +53,14 @@ struct file;
 /* Note that the values of this enum are ABI (it determines
  * /dev/dri/renderD* numbers).
  *
+ * There used to be a DRM_MINOR_CONTROL = 1 entry, but such nodes were never
+ * exposed. Still, some user-space has logic to handle them.
+ *
  * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
  * be implemented before we hit any future
  */
 enum drm_minor_type {
 	DRM_MINOR_PRIMARY = 0,
-	DRM_MINOR_CONTROL = 1,
 	DRM_MINOR_RENDER = 2,
 	DRM_MINOR_ACCEL = 32,
 };
Signature · 1 line
2.41.0
maintainer Reviewed-by on v1 3/3
#3 lore raw

Re: [RFC PATCH 3/3] drm/file: drop DRM_MINOR_CONTROL

Hi Simon

Am 14.07.23 um 12:46 schrieb Simon Ser:

Quoted 19 lines

This entry should never be used by the kernel. Record the historical context in a comment.

Cc Christian König <[email protected]>
Cc James Zhu <[email protected]>
Cc Marek Olšák <[email protected]>
Cc Daniel Vetter <[email protected]>
---
  include/drm/drm_file.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
include/drm/drm_file.h +0 -0
index 010239392adf..a23cc2f6163f 100644
@@ -53,12 +53,14 @@ struct file;
  /* Note that the values of this enum are ABI (it determines
   * /dev/dri/renderD* numbers).

include/drm/drm_file.h struct file; · line 61

Quoted 10 lines
include/drm/drm_file.h +3 -1
   *
+ * There used to be a DRM_MINOR_CONTROL = 1 entry, but such nodes were never
+ * exposed. Still, some user-space has logic to handle them.
+ *
   * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
   * be implemented before we hit any future
   */
  enum drm_minor_type {
  	DRM_MINOR_PRIMARY = 0,
-	DRM_MINOR_CONTROL = 1,

Maybe rather leave this line in and comment it with "// obsolete". Otherwise someone might accidentally use 1 for something.

In any case

for the whole series.

Best regards
Thomas

Quoted 3 lines
include/drm/drm_file.h +0 -0
  	DRM_MINOR_RENDER = 2,
  	DRM_MINOR_ACCEL = 32,
  };
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
author
#4 lore raw

Re: [RFC PATCH 3/3] drm/file: drop DRM_MINOR_CONTROL

Quoted 27 lines · Thomas Zimmermann

Hi Simon

Am 14.07.23 um 12:46 schrieb Simon Ser:

Quoted 24 lines

This entry should never be used by the kernel. Record the historical context in a comment.

Cc Christian König <[email protected]>
Cc James Zhu <[email protected]>
Cc Marek Olšák <[email protected]>
Cc Daniel Vetter <[email protected]>
---
  include/drm/drm_file.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
include/drm/drm_file.h +3 -0
index 010239392adf..a23cc2f6163f 100644
@@ -53,12 +53,14 @@ struct file;
  /* Note that the values of this enum are ABI (it determines
   * /dev/dri/renderD* numbers).
   *
+ * There used to be a DRM_MINOR_CONTROL = 1 entry, but such nodes were never
+ * exposed. Still, some user-space has logic to handle them.
+ *
   * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
Quoted 8 lines

include/drm/drm_file.h struct file; · line 61

Quoted 5 lines
include/drm/drm_file.h +0 -1
   * be implemented before we hit any future
   */
  enum drm_minor_type {
  	DRM_MINOR_PRIMARY = 0,
-	DRM_MINOR_CONTROL = 1,

Maybe rather leave this line in and comment it with "// obsolete". Otherwise someone might accidentally use 1 for something.

Yeah... That's why I added the comment. But maybe better to leave the entry indeed, even if we risk someone accidentally using it.

Quoted 5 lines

In any case

for the whole series.

Thanks for the review!

#5 lore raw

Re: [RFC PATCH 3/3] drm/file: drop DRM_MINOR_CONTROL

Hi

Am 14.07.23 um 16:37 schrieb Simon Ser:

Quoted 38 lines · Thomas Zimmermann
Quoted 28 lines

Hi Simon

Am 14.07.23 um 12:46 schrieb Simon Ser:

Quoted 24 lines

This entry should never be used by the kernel. Record the historical context in a comment.

Cc Christian König <[email protected]>
Cc James Zhu <[email protected]>
Cc Marek Olšák <[email protected]>
Cc Daniel Vetter <[email protected]>
---
   include/drm/drm_file.h | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
include/drm/drm_file.h +3 -0
index 010239392adf..a23cc2f6163f 100644
@@ -53,12 +53,14 @@ struct file;
   /* Note that the values of this enum are ABI (it determines
    * /dev/dri/renderD* numbers).
    *
+ * There used to be a DRM_MINOR_CONTROL = 1 entry, but such nodes were never
+ * exposed. Still, some user-space has logic to handle them.
+ *
    * Setting DRM_MINOR_ACCEL to 32 gives enough space for more drm minors to
Quoted 8 lines

include/drm/drm_file.h struct file; · line 61

Quoted 5 lines
include/drm/drm_file.h +0 -1
    * be implemented before we hit any future
    */
   enum drm_minor_type {
   	DRM_MINOR_PRIMARY = 0,
-	DRM_MINOR_CONTROL = 1,

Maybe rather leave this line in and comment it with "// obsolete". Otherwise someone might accidentally use 1 for something.

Quoted 2 lines

Yeah... That's why I added the comment. But maybe better to leave the entry indeed, even if we risk someone accidentally using it.

You could still out-comment the line as a whole. Simply having it there will warn potential users.

Best regards
Thomas

Quoted 8 lines
Quoted 6 lines

In any case

for the whole series.

Thanks for the review!

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Reviewed-by JamesZhu on v1 1/3
#6 lore raw
In reply to Simon Ser

Hi Simon

Thanks!

Quoted 52 lines · Simon Ser

This makes it easier to figure out what the "type" variable can be set to when reading the implementation of these functions.

Cc Christian König<[email protected]>
Cc James Zhu<[email protected]>
Cc Marek Olšák<[email protected]>
Cc Daniel Vetter<[email protected]>
---
  drivers/gpu/drm/drm_drv.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_drv.c +4 -4
index 12687dd9e1ac..3eda026ffac6 100644
@@ -84,7 +84,7 @@ DEFINE_STATIC_SRCU(drm_unplug_srcu);
   */
 
  static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
-					     unsigned int type)
+					     enum drm_minor_type type)
  {
  	switch (type) {
  	case DRM_MINOR_PRIMARY:
@@ -116,7 +116,7 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
  	}
  }
 
-static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
+static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
  {
  	struct drm_minor *minor;
  	unsigned long flags;
@@ -160,7 +160,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
  	return 0;
  }
 
-static int drm_minor_register(struct drm_device *dev, unsigned int type)
+static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
  {
  	struct drm_minor *minor;
  	unsigned long flags;
@@ -203,7 +203,7 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
  	return ret;
  }
 
-static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
+static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
  {
  	struct drm_minor *minor;
  	unsigned long flags;