All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/4] drm: Use full allocated minor range for DRM
@ 2023-07-24 21:14 ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Matthew Wilcox, Oded Gabbay,
	Christian König, James Zhu, Pekka Paalanen, Emil Velikov,
	Michał Winiarski

64 DRM device nodes is not enough for everyone.
Upgrade it to ~512K (which definitely is more than enough).

To allow testing userspace support for >64 devices, add additional DRM
modparam (force_extended_minors) which causes DRM to skip allocating minors
in 0-192 range.
Additionally - convert minors to use XArray instead of IDR to simplify the
locking.

v1 -> v2:
Don't touch DRM_MINOR_CONTROL and its range (Simon Ser)

v2 -> v3:
Don't use legacy scheme for >=192 minor range (Dave Airlie)
Add modparam for testing (Dave Airlie)
Add lockdep annotation for IDR (Daniel Vetter)

v3 -> v4:
Convert from IDR to XArray (Matthew Wilcox)

v4 -> v5:
Fixup IDR to XArray conversion (Matthew Wilcox)

v5 -> v6:
Also convert Accel to XArray
Rename skip_legacy_minors to force_extended_minors

Michał Winiarski (4):
  drm: Use XArray instead of IDR for minors
  accel: Use XArray instead of IDR for minors
  drm: Expand max DRM device number to full MINORBITS
  drm: Introduce force_extended_minors modparam

 drivers/accel/drm_accel.c      | 110 +++------------------------------
 drivers/gpu/drm/drm_drv.c      | 105 ++++++++++++++++---------------
 drivers/gpu/drm/drm_file.c     |   2 +-
 drivers/gpu/drm/drm_internal.h |   4 --
 include/drm/drm_accel.h        |  18 +-----
 include/drm/drm_file.h         |   5 ++
 6 files changed, 69 insertions(+), 175 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v6 0/4] drm: Use full allocated minor range for DRM
@ 2023-07-24 21:14 ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

64 DRM device nodes is not enough for everyone.
Upgrade it to ~512K (which definitely is more than enough).

To allow testing userspace support for >64 devices, add additional DRM
modparam (force_extended_minors) which causes DRM to skip allocating minors
in 0-192 range.
Additionally - convert minors to use XArray instead of IDR to simplify the
locking.

v1 -> v2:
Don't touch DRM_MINOR_CONTROL and its range (Simon Ser)

v2 -> v3:
Don't use legacy scheme for >=192 minor range (Dave Airlie)
Add modparam for testing (Dave Airlie)
Add lockdep annotation for IDR (Daniel Vetter)

v3 -> v4:
Convert from IDR to XArray (Matthew Wilcox)

v4 -> v5:
Fixup IDR to XArray conversion (Matthew Wilcox)

v5 -> v6:
Also convert Accel to XArray
Rename skip_legacy_minors to force_extended_minors

Michał Winiarski (4):
  drm: Use XArray instead of IDR for minors
  accel: Use XArray instead of IDR for minors
  drm: Expand max DRM device number to full MINORBITS
  drm: Introduce force_extended_minors modparam

 drivers/accel/drm_accel.c      | 110 +++------------------------------
 drivers/gpu/drm/drm_drv.c      | 105 ++++++++++++++++---------------
 drivers/gpu/drm/drm_file.c     |   2 +-
 drivers/gpu/drm/drm_internal.h |   4 --
 include/drm/drm_accel.h        |  18 +-----
 include/drm/drm_file.h         |   5 ++
 6 files changed, 69 insertions(+), 175 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 64+ messages in thread

* [Intel-gfx] [PATCH v6 0/4] drm: Use full allocated minor range for DRM
@ 2023-07-24 21:14 ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

64 DRM device nodes is not enough for everyone.
Upgrade it to ~512K (which definitely is more than enough).

To allow testing userspace support for >64 devices, add additional DRM
modparam (force_extended_minors) which causes DRM to skip allocating minors
in 0-192 range.
Additionally - convert minors to use XArray instead of IDR to simplify the
locking.

v1 -> v2:
Don't touch DRM_MINOR_CONTROL and its range (Simon Ser)

v2 -> v3:
Don't use legacy scheme for >=192 minor range (Dave Airlie)
Add modparam for testing (Dave Airlie)
Add lockdep annotation for IDR (Daniel Vetter)

v3 -> v4:
Convert from IDR to XArray (Matthew Wilcox)

v4 -> v5:
Fixup IDR to XArray conversion (Matthew Wilcox)

v5 -> v6:
Also convert Accel to XArray
Rename skip_legacy_minors to force_extended_minors

Michał Winiarski (4):
  drm: Use XArray instead of IDR for minors
  accel: Use XArray instead of IDR for minors
  drm: Expand max DRM device number to full MINORBITS
  drm: Introduce force_extended_minors modparam

 drivers/accel/drm_accel.c      | 110 +++------------------------------
 drivers/gpu/drm/drm_drv.c      | 105 ++++++++++++++++---------------
 drivers/gpu/drm/drm_file.c     |   2 +-
 drivers/gpu/drm/drm_internal.h |   4 --
 include/drm/drm_accel.h        |  18 +-----
 include/drm/drm_file.h         |   5 ++
 6 files changed, 69 insertions(+), 175 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-07-24 21:14 ` Michał Winiarski
  (?)
@ 2023-07-24 21:14   ` Michał Winiarski
  -1 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Matthew Wilcox, Oded Gabbay,
	Christian König, James Zhu, Pekka Paalanen, Emil Velikov,
	Michał Winiarski

IDR is deprecated, and since XArray manages its own state with internal
locking, it simplifies the locking on DRM side.
Additionally, don't use the IRQ-safe variant, since operating on drm
minor is not done in IRQ context.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Suggested-by: Matthew Wilcox <willy@infradead.org>
---
 drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3eda026ffac6..3faecb01186f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -34,6 +34,7 @@
 #include <linux/pseudo_fs.h>
 #include <linux/slab.h>
 #include <linux/srcu.h>
+#include <linux/xarray.h>
 
 #include <drm/drm_accel.h>
 #include <drm/drm_cache.h>
@@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
 MODULE_DESCRIPTION("DRM shared core routines");
 MODULE_LICENSE("GPL and additional rights");
 
-static DEFINE_SPINLOCK(drm_minor_lock);
-static struct idr drm_minors_idr;
+static DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
 /*
  * If the drm core fails to init for whatever reason,
@@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 {
 	struct drm_minor *minor = data;
-	unsigned long flags;
 
 	WARN_ON(dev != minor->dev);
 
 	put_device(minor->kdev);
 
-	if (minor->type == DRM_MINOR_ACCEL) {
+	if (minor->type == DRM_MINOR_ACCEL)
 		accel_minor_remove(minor->index);
-	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_remove(&drm_minors_idr, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
-	}
+	else
+		xa_erase(&drm_minors_xa, minor->index);
 }
 
+#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
+
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
-	int r;
+	int index, r;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	idr_preload(GFP_KERNEL);
 	if (type == DRM_MINOR_ACCEL) {
 		r = accel_minor_alloc();
+		index = r;
 	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		r = idr_alloc(&drm_minors_idr,
-			NULL,
-			64 * type,
-			64 * (type + 1),
-			GFP_NOWAIT);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
+		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	}
-	idr_preload_end();
 
 	if (r < 0)
 		return r;
 
-	minor->index = r;
+	minor->index = index;
 
 	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
 	if (r)
@@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
+	void *entry;
 	int ret;
 
 	DRM_DEBUG("\n");
@@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 	if (minor->type == DRM_MINOR_ACCEL) {
 		accel_minor_replace(minor, minor->index);
 	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_replace(&drm_minors_idr, minor, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
+		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
+		if (xa_is_err(entry)) {
+			ret = xa_err(entry);
+			goto err_debugfs;
+		}
+		WARN_ON(entry);
 	}
 
 	DRM_DEBUG("new minor registered %d\n", minor->index);
@@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
 
 	minor = *drm_minor_get_slot(dev, type);
 	if (!minor || !device_is_registered(minor->kdev))
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
-	if (minor->type == DRM_MINOR_ACCEL) {
+	if (minor->type == DRM_MINOR_ACCEL)
 		accel_minor_replace(NULL, minor->index);
-	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_replace(&drm_minors_idr, NULL, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
-	}
+	else
+		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
 
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
@@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
 struct drm_minor *drm_minor_acquire(unsigned int minor_id)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
 
-	spin_lock_irqsave(&drm_minor_lock, flags);
-	minor = idr_find(&drm_minors_idr, minor_id);
+	xa_lock(&drm_minors_xa);
+	minor = xa_load(&drm_minors_xa, minor_id);
 	if (minor)
 		drm_dev_get(minor->dev);
-	spin_unlock_irqrestore(&drm_minor_lock, flags);
+	xa_unlock(&drm_minors_xa);
 
 	if (!minor) {
 		return ERR_PTR(-ENODEV);
@@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
 	unregister_chrdev(DRM_MAJOR, "drm");
 	debugfs_remove(drm_debugfs_root);
 	drm_sysfs_destroy();
-	idr_destroy(&drm_minors_idr);
+	WARN_ON(!xa_empty(&drm_minors_xa));
 	drm_connector_ida_destroy();
 }
 
@@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
 	int ret;
 
 	drm_connector_ida_init();
-	idr_init(&drm_minors_idr);
 	drm_memcpy_init_early();
 
 	ret = drm_sysfs_init();
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

IDR is deprecated, and since XArray manages its own state with internal
locking, it simplifies the locking on DRM side.
Additionally, don't use the IRQ-safe variant, since operating on drm
minor is not done in IRQ context.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Suggested-by: Matthew Wilcox <willy@infradead.org>
---
 drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3eda026ffac6..3faecb01186f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -34,6 +34,7 @@
 #include <linux/pseudo_fs.h>
 #include <linux/slab.h>
 #include <linux/srcu.h>
+#include <linux/xarray.h>
 
 #include <drm/drm_accel.h>
 #include <drm/drm_cache.h>
@@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
 MODULE_DESCRIPTION("DRM shared core routines");
 MODULE_LICENSE("GPL and additional rights");
 
-static DEFINE_SPINLOCK(drm_minor_lock);
-static struct idr drm_minors_idr;
+static DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
 /*
  * If the drm core fails to init for whatever reason,
@@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 {
 	struct drm_minor *minor = data;
-	unsigned long flags;
 
 	WARN_ON(dev != minor->dev);
 
 	put_device(minor->kdev);
 
-	if (minor->type == DRM_MINOR_ACCEL) {
+	if (minor->type == DRM_MINOR_ACCEL)
 		accel_minor_remove(minor->index);
-	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_remove(&drm_minors_idr, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
-	}
+	else
+		xa_erase(&drm_minors_xa, minor->index);
 }
 
+#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
+
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
-	int r;
+	int index, r;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	idr_preload(GFP_KERNEL);
 	if (type == DRM_MINOR_ACCEL) {
 		r = accel_minor_alloc();
+		index = r;
 	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		r = idr_alloc(&drm_minors_idr,
-			NULL,
-			64 * type,
-			64 * (type + 1),
-			GFP_NOWAIT);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
+		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	}
-	idr_preload_end();
 
 	if (r < 0)
 		return r;
 
-	minor->index = r;
+	minor->index = index;
 
 	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
 	if (r)
@@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
+	void *entry;
 	int ret;
 
 	DRM_DEBUG("\n");
@@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 	if (minor->type == DRM_MINOR_ACCEL) {
 		accel_minor_replace(minor, minor->index);
 	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_replace(&drm_minors_idr, minor, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
+		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
+		if (xa_is_err(entry)) {
+			ret = xa_err(entry);
+			goto err_debugfs;
+		}
+		WARN_ON(entry);
 	}
 
 	DRM_DEBUG("new minor registered %d\n", minor->index);
@@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
 
 	minor = *drm_minor_get_slot(dev, type);
 	if (!minor || !device_is_registered(minor->kdev))
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
-	if (minor->type == DRM_MINOR_ACCEL) {
+	if (minor->type == DRM_MINOR_ACCEL)
 		accel_minor_replace(NULL, minor->index);
-	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_replace(&drm_minors_idr, NULL, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
-	}
+	else
+		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
 
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
@@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
 struct drm_minor *drm_minor_acquire(unsigned int minor_id)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
 
-	spin_lock_irqsave(&drm_minor_lock, flags);
-	minor = idr_find(&drm_minors_idr, minor_id);
+	xa_lock(&drm_minors_xa);
+	minor = xa_load(&drm_minors_xa, minor_id);
 	if (minor)
 		drm_dev_get(minor->dev);
-	spin_unlock_irqrestore(&drm_minor_lock, flags);
+	xa_unlock(&drm_minors_xa);
 
 	if (!minor) {
 		return ERR_PTR(-ENODEV);
@@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
 	unregister_chrdev(DRM_MAJOR, "drm");
 	debugfs_remove(drm_debugfs_root);
 	drm_sysfs_destroy();
-	idr_destroy(&drm_minors_idr);
+	WARN_ON(!xa_empty(&drm_minors_xa));
 	drm_connector_ida_destroy();
 }
 
@@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
 	int ret;
 
 	drm_connector_ida_init();
-	idr_init(&drm_minors_idr);
 	drm_memcpy_init_early();
 
 	ret = drm_sysfs_init();
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

IDR is deprecated, and since XArray manages its own state with internal
locking, it simplifies the locking on DRM side.
Additionally, don't use the IRQ-safe variant, since operating on drm
minor is not done in IRQ context.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Suggested-by: Matthew Wilcox <willy@infradead.org>
---
 drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3eda026ffac6..3faecb01186f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -34,6 +34,7 @@
 #include <linux/pseudo_fs.h>
 #include <linux/slab.h>
 #include <linux/srcu.h>
+#include <linux/xarray.h>
 
 #include <drm/drm_accel.h>
 #include <drm/drm_cache.h>
@@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
 MODULE_DESCRIPTION("DRM shared core routines");
 MODULE_LICENSE("GPL and additional rights");
 
-static DEFINE_SPINLOCK(drm_minor_lock);
-static struct idr drm_minors_idr;
+static DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
 /*
  * If the drm core fails to init for whatever reason,
@@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 {
 	struct drm_minor *minor = data;
-	unsigned long flags;
 
 	WARN_ON(dev != minor->dev);
 
 	put_device(minor->kdev);
 
-	if (minor->type == DRM_MINOR_ACCEL) {
+	if (minor->type == DRM_MINOR_ACCEL)
 		accel_minor_remove(minor->index);
-	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_remove(&drm_minors_idr, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
-	}
+	else
+		xa_erase(&drm_minors_xa, minor->index);
 }
 
+#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
+
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
-	int r;
+	int index, r;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	idr_preload(GFP_KERNEL);
 	if (type == DRM_MINOR_ACCEL) {
 		r = accel_minor_alloc();
+		index = r;
 	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		r = idr_alloc(&drm_minors_idr,
-			NULL,
-			64 * type,
-			64 * (type + 1),
-			GFP_NOWAIT);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
+		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	}
-	idr_preload_end();
 
 	if (r < 0)
 		return r;
 
-	minor->index = r;
+	minor->index = index;
 
 	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
 	if (r)
@@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
+	void *entry;
 	int ret;
 
 	DRM_DEBUG("\n");
@@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 	if (minor->type == DRM_MINOR_ACCEL) {
 		accel_minor_replace(minor, minor->index);
 	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_replace(&drm_minors_idr, minor, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
+		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
+		if (xa_is_err(entry)) {
+			ret = xa_err(entry);
+			goto err_debugfs;
+		}
+		WARN_ON(entry);
 	}
 
 	DRM_DEBUG("new minor registered %d\n", minor->index);
@@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
 
 	minor = *drm_minor_get_slot(dev, type);
 	if (!minor || !device_is_registered(minor->kdev))
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
-	if (minor->type == DRM_MINOR_ACCEL) {
+	if (minor->type == DRM_MINOR_ACCEL)
 		accel_minor_replace(NULL, minor->index);
-	} else {
-		spin_lock_irqsave(&drm_minor_lock, flags);
-		idr_replace(&drm_minors_idr, NULL, minor->index);
-		spin_unlock_irqrestore(&drm_minor_lock, flags);
-	}
+	else
+		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
 
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
@@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
 struct drm_minor *drm_minor_acquire(unsigned int minor_id)
 {
 	struct drm_minor *minor;
-	unsigned long flags;
 
-	spin_lock_irqsave(&drm_minor_lock, flags);
-	minor = idr_find(&drm_minors_idr, minor_id);
+	xa_lock(&drm_minors_xa);
+	minor = xa_load(&drm_minors_xa, minor_id);
 	if (minor)
 		drm_dev_get(minor->dev);
-	spin_unlock_irqrestore(&drm_minor_lock, flags);
+	xa_unlock(&drm_minors_xa);
 
 	if (!minor) {
 		return ERR_PTR(-ENODEV);
@@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
 	unregister_chrdev(DRM_MAJOR, "drm");
 	debugfs_remove(drm_debugfs_root);
 	drm_sysfs_destroy();
-	idr_destroy(&drm_minors_idr);
+	WARN_ON(!xa_empty(&drm_minors_xa));
 	drm_connector_ida_destroy();
 }
 
@@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
 	int ret;
 
 	drm_connector_ida_init();
-	idr_init(&drm_minors_idr);
 	drm_memcpy_init_early();
 
 	ret = drm_sysfs_init();
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 2/4] accel: Use XArray instead of IDR for minors
  2023-07-24 21:14 ` Michał Winiarski
  (?)
@ 2023-07-24 21:14   ` Michał Winiarski
  -1 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Matthew Wilcox, Oded Gabbay,
	Christian König, James Zhu, Pekka Paalanen, Emil Velikov,
	Michał Winiarski

Accel minor management is based on DRM (and is also using struct
drm_minor internally), since DRM is using XArray for minors, it makes
sense to also convert accel.
As the two implementations are identical (only difference being the
underlying xarray), move the accel_minor_* functionality to DRM.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/accel/drm_accel.c      | 110 +++------------------------------
 drivers/gpu/drm/drm_drv.c      |  66 ++++++++++----------
 drivers/gpu/drm/drm_file.c     |   2 +-
 drivers/gpu/drm/drm_internal.h |   4 --
 include/drm/drm_accel.h        |  18 +-----
 include/drm/drm_file.h         |   5 ++
 6 files changed, 47 insertions(+), 158 deletions(-)

diff --git a/drivers/accel/drm_accel.c b/drivers/accel/drm_accel.c
index 4a9baf02439e..8827cb78ca9d 100644
--- a/drivers/accel/drm_accel.c
+++ b/drivers/accel/drm_accel.c
@@ -8,7 +8,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/device.h>
-#include <linux/idr.h>
+#include <linux/xarray.h>
 
 #include <drm/drm_accel.h>
 #include <drm/drm_debugfs.h>
@@ -17,8 +17,7 @@
 #include <drm/drm_ioctl.h>
 #include <drm/drm_print.h>
 
-static DEFINE_SPINLOCK(accel_minor_lock);
-static struct idr accel_minors_idr;
+DEFINE_XARRAY_ALLOC(accel_minors_xa);
 
 static struct dentry *accel_debugfs_root;
 static struct class *accel_class;
@@ -120,99 +119,6 @@ void accel_set_device_instance_params(struct device *kdev, int index)
 	kdev->type = &accel_sysfs_device_minor;
 }
 
-/**
- * accel_minor_alloc() - Allocates a new accel minor
- *
- * This function access the accel minors idr and allocates from it
- * a new id to represent a new accel minor
- *
- * Return: A new id on success or error code in case idr_alloc failed
- */
-int accel_minor_alloc(void)
-{
-	unsigned long flags;
-	int r;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	r = idr_alloc(&accel_minors_idr, NULL, 0, ACCEL_MAX_MINORS, GFP_NOWAIT);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-
-	return r;
-}
-
-/**
- * accel_minor_remove() - Remove an accel minor
- * @index: The minor id to remove.
- *
- * This function access the accel minors idr and removes from
- * it the member with the id that is passed to this function.
- */
-void accel_minor_remove(int index)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	idr_remove(&accel_minors_idr, index);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-}
-
-/**
- * accel_minor_replace() - Replace minor pointer in accel minors idr.
- * @minor: Pointer to the new minor.
- * @index: The minor id to replace.
- *
- * This function access the accel minors idr structure and replaces the pointer
- * that is associated with an existing id. Because the minor pointer can be
- * NULL, we need to explicitly pass the index.
- *
- * Return: 0 for success, negative value for error
- */
-void accel_minor_replace(struct drm_minor *minor, int index)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	idr_replace(&accel_minors_idr, minor, index);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-}
-
-/*
- * Looks up the given minor-ID and returns the respective DRM-minor object. The
- * refence-count of the underlying device is increased so you must release this
- * object with accel_minor_release().
- *
- * The object can be only a drm_minor that represents an accel device.
- *
- * As long as you hold this minor, it is guaranteed that the object and the
- * minor->dev pointer will stay valid! However, the device may get unplugged and
- * unregistered while you hold the minor.
- */
-static struct drm_minor *accel_minor_acquire(unsigned int minor_id)
-{
-	struct drm_minor *minor;
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	minor = idr_find(&accel_minors_idr, minor_id);
-	if (minor)
-		drm_dev_get(minor->dev);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-
-	if (!minor) {
-		return ERR_PTR(-ENODEV);
-	} else if (drm_dev_is_unplugged(minor->dev)) {
-		drm_dev_put(minor->dev);
-		return ERR_PTR(-ENODEV);
-	}
-
-	return minor;
-}
-
-static void accel_minor_release(struct drm_minor *minor)
-{
-	drm_dev_put(minor->dev);
-}
-
 /**
  * accel_open - open method for ACCEL file
  * @inode: device inode
@@ -230,7 +136,7 @@ int accel_open(struct inode *inode, struct file *filp)
 	struct drm_minor *minor;
 	int retcode;
 
-	minor = accel_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&accel_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
@@ -249,7 +155,7 @@ int accel_open(struct inode *inode, struct file *filp)
 
 err_undo:
 	atomic_dec(&dev->open_count);
-	accel_minor_release(minor);
+	drm_minor_release(minor);
 	return retcode;
 }
 EXPORT_SYMBOL_GPL(accel_open);
@@ -260,7 +166,7 @@ static int accel_stub_open(struct inode *inode, struct file *filp)
 	struct drm_minor *minor;
 	int err;
 
-	minor = accel_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&accel_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
@@ -277,7 +183,7 @@ static int accel_stub_open(struct inode *inode, struct file *filp)
 		err = 0;
 
 out:
-	accel_minor_release(minor);
+	drm_minor_release(minor);
 
 	return err;
 }
@@ -293,15 +199,13 @@ void accel_core_exit(void)
 	unregister_chrdev(ACCEL_MAJOR, "accel");
 	debugfs_remove(accel_debugfs_root);
 	accel_sysfs_destroy();
-	idr_destroy(&accel_minors_idr);
+	WARN_ON(!xa_empty(&accel_minors_xa));
 }
 
 int __init accel_core_init(void)
 {
 	int ret;
 
-	idr_init(&accel_minors_idr);
-
 	ret = accel_sysfs_init();
 	if (ret < 0) {
 		DRM_ERROR("Cannot create ACCEL class: %d\n", ret);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3faecb01186f..34b60196c443 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -55,7 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
 MODULE_DESCRIPTION("DRM shared core routines");
 MODULE_LICENSE("GPL and additional rights");
 
-static DEFINE_XARRAY_ALLOC(drm_minors_xa);
+DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
 /*
  * If the drm core fails to init for whatever reason,
@@ -83,6 +83,18 @@ DEFINE_STATIC_SRCU(drm_unplug_srcu);
  * registered and unregistered dynamically according to device-state.
  */
 
+static struct xarray *drm_minor_get_xa(enum drm_minor_type type)
+{
+	if (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER)
+		return &drm_minors_xa;
+#if IS_ENABLED(CONFIG_DRM_ACCEL)
+	else if (type == DRM_MINOR_ACCEL)
+		return &accel_minors_xa;
+#endif
+	else
+		return ERR_PTR(-EOPNOTSUPP);
+}
+
 static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 					     enum drm_minor_type type)
 {
@@ -106,18 +118,18 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 
 	put_device(minor->kdev);
 
-	if (minor->type == DRM_MINOR_ACCEL)
-		accel_minor_remove(minor->index);
-	else
-		xa_erase(&drm_minors_xa, minor->index);
+	xa_erase(drm_minor_get_xa(minor->type), minor->index);
 }
 
-#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
+#define DRM_MINOR_LIMIT(t) ({ \
+	typeof(t) _t = (t); \
+	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
+})
 
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	int index, r;
+	int r;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -126,18 +138,11 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	if (type == DRM_MINOR_ACCEL) {
-		r = accel_minor_alloc();
-		index = r;
-	} else {
-		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
-	}
-
+	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
+		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	if (r < 0)
 		return r;
 
-	minor->index = index;
-
 	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
 	if (r)
 		return r;
@@ -177,16 +182,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 		goto err_debugfs;
 
 	/* replace NULL with @minor so lookups will succeed from now on */
-	if (minor->type == DRM_MINOR_ACCEL) {
-		accel_minor_replace(minor, minor->index);
-	} else {
-		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
-		if (xa_is_err(entry)) {
-			ret = xa_err(entry);
-			goto err_debugfs;
-		}
-		WARN_ON(entry);
+	entry = xa_store(drm_minor_get_xa(type), minor->index, minor, GFP_KERNEL);
+	if (xa_is_err(entry)) {
+		ret = xa_err(entry);
+		goto err_debugfs;
 	}
+	WARN_ON(entry);
 
 	DRM_DEBUG("new minor registered %d\n", minor->index);
 	return 0;
@@ -205,10 +206,7 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
-	if (minor->type == DRM_MINOR_ACCEL)
-		accel_minor_replace(NULL, minor->index);
-	else
-		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
+	xa_store(drm_minor_get_xa(type), minor->index, NULL, GFP_KERNEL);
 
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
@@ -224,15 +222,15 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
  * minor->dev pointer will stay valid! However, the device may get unplugged and
  * unregistered while you hold the minor.
  */
-struct drm_minor *drm_minor_acquire(unsigned int minor_id)
+struct drm_minor *drm_minor_acquire(struct xarray *minor_xa, unsigned int minor_id)
 {
 	struct drm_minor *minor;
 
-	xa_lock(&drm_minors_xa);
-	minor = xa_load(&drm_minors_xa, minor_id);
+	xa_lock(minor_xa);
+	minor = xa_load(minor_xa, minor_id);
 	if (minor)
 		drm_dev_get(minor->dev);
-	xa_unlock(&drm_minors_xa);
+	xa_unlock(minor_xa);
 
 	if (!minor) {
 		return ERR_PTR(-ENODEV);
@@ -1020,7 +1018,7 @@ static int drm_stub_open(struct inode *inode, struct file *filp)
 
 	DRM_DEBUG("\n");
 
-	minor = drm_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 883d83bc0e3d..20c9afe0f5a5 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -413,7 +413,7 @@ int drm_open(struct inode *inode, struct file *filp)
 	int retcode;
 	int need_setup = 0;
 
-	minor = drm_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index d7e023bbb0d5..cb46f4c61991 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -77,10 +77,6 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
 void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
 				 uint32_t handle);
 
-/* drm_drv.c */
-struct drm_minor *drm_minor_acquire(unsigned int minor_id);
-void drm_minor_release(struct drm_minor *minor);
-
 /* drm_managed.c */
 void drm_managed_release(struct drm_device *dev);
 void drmm_add_final_kfree(struct drm_device *dev, void *container);
diff --git a/include/drm/drm_accel.h b/include/drm/drm_accel.h
index d4955062c77e..f93e23985f4e 100644
--- a/include/drm/drm_accel.h
+++ b/include/drm/drm_accel.h
@@ -51,11 +51,10 @@
 
 #if IS_ENABLED(CONFIG_DRM_ACCEL)
 
+extern struct xarray accel_minors_xa;
+
 void accel_core_exit(void);
 int accel_core_init(void);
-void accel_minor_remove(int index);
-int accel_minor_alloc(void);
-void accel_minor_replace(struct drm_minor *minor, int index);
 void accel_set_device_instance_params(struct device *kdev, int index);
 int accel_open(struct inode *inode, struct file *filp);
 void accel_debugfs_init(struct drm_minor *minor, int minor_id);
@@ -72,19 +71,6 @@ static inline int __init accel_core_init(void)
 	return 0;
 }
 
-static inline void accel_minor_remove(int index)
-{
-}
-
-static inline int accel_minor_alloc(void)
-{
-	return -EOPNOTSUPP;
-}
-
-static inline void accel_minor_replace(struct drm_minor *minor, int index)
-{
-}
-
 static inline void accel_set_device_instance_params(struct device *kdev, int index)
 {
 }
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 010239392adf..7fc09460051f 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -45,6 +45,8 @@ struct drm_printer;
 struct device;
 struct file;
 
+extern struct xarray drm_minors_xa;
+
 /*
  * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
  * header include loops we need it here for now.
@@ -420,6 +422,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
 	return file_priv->minor->type == DRM_MINOR_ACCEL;
 }
 
+struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
+void drm_minor_release(struct drm_minor *minor);
+
 int drm_open(struct inode *inode, struct file *filp);
 int drm_open_helper(struct file *filp, struct drm_minor *minor);
 ssize_t drm_read(struct file *filp, char __user *buffer,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 2/4] accel: Use XArray instead of IDR for minors
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

Accel minor management is based on DRM (and is also using struct
drm_minor internally), since DRM is using XArray for minors, it makes
sense to also convert accel.
As the two implementations are identical (only difference being the
underlying xarray), move the accel_minor_* functionality to DRM.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/accel/drm_accel.c      | 110 +++------------------------------
 drivers/gpu/drm/drm_drv.c      |  66 ++++++++++----------
 drivers/gpu/drm/drm_file.c     |   2 +-
 drivers/gpu/drm/drm_internal.h |   4 --
 include/drm/drm_accel.h        |  18 +-----
 include/drm/drm_file.h         |   5 ++
 6 files changed, 47 insertions(+), 158 deletions(-)

diff --git a/drivers/accel/drm_accel.c b/drivers/accel/drm_accel.c
index 4a9baf02439e..8827cb78ca9d 100644
--- a/drivers/accel/drm_accel.c
+++ b/drivers/accel/drm_accel.c
@@ -8,7 +8,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/device.h>
-#include <linux/idr.h>
+#include <linux/xarray.h>
 
 #include <drm/drm_accel.h>
 #include <drm/drm_debugfs.h>
@@ -17,8 +17,7 @@
 #include <drm/drm_ioctl.h>
 #include <drm/drm_print.h>
 
-static DEFINE_SPINLOCK(accel_minor_lock);
-static struct idr accel_minors_idr;
+DEFINE_XARRAY_ALLOC(accel_minors_xa);
 
 static struct dentry *accel_debugfs_root;
 static struct class *accel_class;
@@ -120,99 +119,6 @@ void accel_set_device_instance_params(struct device *kdev, int index)
 	kdev->type = &accel_sysfs_device_minor;
 }
 
-/**
- * accel_minor_alloc() - Allocates a new accel minor
- *
- * This function access the accel minors idr and allocates from it
- * a new id to represent a new accel minor
- *
- * Return: A new id on success or error code in case idr_alloc failed
- */
-int accel_minor_alloc(void)
-{
-	unsigned long flags;
-	int r;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	r = idr_alloc(&accel_minors_idr, NULL, 0, ACCEL_MAX_MINORS, GFP_NOWAIT);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-
-	return r;
-}
-
-/**
- * accel_minor_remove() - Remove an accel minor
- * @index: The minor id to remove.
- *
- * This function access the accel minors idr and removes from
- * it the member with the id that is passed to this function.
- */
-void accel_minor_remove(int index)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	idr_remove(&accel_minors_idr, index);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-}
-
-/**
- * accel_minor_replace() - Replace minor pointer in accel minors idr.
- * @minor: Pointer to the new minor.
- * @index: The minor id to replace.
- *
- * This function access the accel minors idr structure and replaces the pointer
- * that is associated with an existing id. Because the minor pointer can be
- * NULL, we need to explicitly pass the index.
- *
- * Return: 0 for success, negative value for error
- */
-void accel_minor_replace(struct drm_minor *minor, int index)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	idr_replace(&accel_minors_idr, minor, index);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-}
-
-/*
- * Looks up the given minor-ID and returns the respective DRM-minor object. The
- * refence-count of the underlying device is increased so you must release this
- * object with accel_minor_release().
- *
- * The object can be only a drm_minor that represents an accel device.
- *
- * As long as you hold this minor, it is guaranteed that the object and the
- * minor->dev pointer will stay valid! However, the device may get unplugged and
- * unregistered while you hold the minor.
- */
-static struct drm_minor *accel_minor_acquire(unsigned int minor_id)
-{
-	struct drm_minor *minor;
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	minor = idr_find(&accel_minors_idr, minor_id);
-	if (minor)
-		drm_dev_get(minor->dev);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-
-	if (!minor) {
-		return ERR_PTR(-ENODEV);
-	} else if (drm_dev_is_unplugged(minor->dev)) {
-		drm_dev_put(minor->dev);
-		return ERR_PTR(-ENODEV);
-	}
-
-	return minor;
-}
-
-static void accel_minor_release(struct drm_minor *minor)
-{
-	drm_dev_put(minor->dev);
-}
-
 /**
  * accel_open - open method for ACCEL file
  * @inode: device inode
@@ -230,7 +136,7 @@ int accel_open(struct inode *inode, struct file *filp)
 	struct drm_minor *minor;
 	int retcode;
 
-	minor = accel_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&accel_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
@@ -249,7 +155,7 @@ int accel_open(struct inode *inode, struct file *filp)
 
 err_undo:
 	atomic_dec(&dev->open_count);
-	accel_minor_release(minor);
+	drm_minor_release(minor);
 	return retcode;
 }
 EXPORT_SYMBOL_GPL(accel_open);
@@ -260,7 +166,7 @@ static int accel_stub_open(struct inode *inode, struct file *filp)
 	struct drm_minor *minor;
 	int err;
 
-	minor = accel_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&accel_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
@@ -277,7 +183,7 @@ static int accel_stub_open(struct inode *inode, struct file *filp)
 		err = 0;
 
 out:
-	accel_minor_release(minor);
+	drm_minor_release(minor);
 
 	return err;
 }
@@ -293,15 +199,13 @@ void accel_core_exit(void)
 	unregister_chrdev(ACCEL_MAJOR, "accel");
 	debugfs_remove(accel_debugfs_root);
 	accel_sysfs_destroy();
-	idr_destroy(&accel_minors_idr);
+	WARN_ON(!xa_empty(&accel_minors_xa));
 }
 
 int __init accel_core_init(void)
 {
 	int ret;
 
-	idr_init(&accel_minors_idr);
-
 	ret = accel_sysfs_init();
 	if (ret < 0) {
 		DRM_ERROR("Cannot create ACCEL class: %d\n", ret);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3faecb01186f..34b60196c443 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -55,7 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
 MODULE_DESCRIPTION("DRM shared core routines");
 MODULE_LICENSE("GPL and additional rights");
 
-static DEFINE_XARRAY_ALLOC(drm_minors_xa);
+DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
 /*
  * If the drm core fails to init for whatever reason,
@@ -83,6 +83,18 @@ DEFINE_STATIC_SRCU(drm_unplug_srcu);
  * registered and unregistered dynamically according to device-state.
  */
 
+static struct xarray *drm_minor_get_xa(enum drm_minor_type type)
+{
+	if (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER)
+		return &drm_minors_xa;
+#if IS_ENABLED(CONFIG_DRM_ACCEL)
+	else if (type == DRM_MINOR_ACCEL)
+		return &accel_minors_xa;
+#endif
+	else
+		return ERR_PTR(-EOPNOTSUPP);
+}
+
 static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 					     enum drm_minor_type type)
 {
@@ -106,18 +118,18 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 
 	put_device(minor->kdev);
 
-	if (minor->type == DRM_MINOR_ACCEL)
-		accel_minor_remove(minor->index);
-	else
-		xa_erase(&drm_minors_xa, minor->index);
+	xa_erase(drm_minor_get_xa(minor->type), minor->index);
 }
 
-#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
+#define DRM_MINOR_LIMIT(t) ({ \
+	typeof(t) _t = (t); \
+	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
+})
 
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	int index, r;
+	int r;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -126,18 +138,11 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	if (type == DRM_MINOR_ACCEL) {
-		r = accel_minor_alloc();
-		index = r;
-	} else {
-		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
-	}
-
+	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
+		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	if (r < 0)
 		return r;
 
-	minor->index = index;
-
 	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
 	if (r)
 		return r;
@@ -177,16 +182,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 		goto err_debugfs;
 
 	/* replace NULL with @minor so lookups will succeed from now on */
-	if (minor->type == DRM_MINOR_ACCEL) {
-		accel_minor_replace(minor, minor->index);
-	} else {
-		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
-		if (xa_is_err(entry)) {
-			ret = xa_err(entry);
-			goto err_debugfs;
-		}
-		WARN_ON(entry);
+	entry = xa_store(drm_minor_get_xa(type), minor->index, minor, GFP_KERNEL);
+	if (xa_is_err(entry)) {
+		ret = xa_err(entry);
+		goto err_debugfs;
 	}
+	WARN_ON(entry);
 
 	DRM_DEBUG("new minor registered %d\n", minor->index);
 	return 0;
@@ -205,10 +206,7 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
-	if (minor->type == DRM_MINOR_ACCEL)
-		accel_minor_replace(NULL, minor->index);
-	else
-		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
+	xa_store(drm_minor_get_xa(type), minor->index, NULL, GFP_KERNEL);
 
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
@@ -224,15 +222,15 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
  * minor->dev pointer will stay valid! However, the device may get unplugged and
  * unregistered while you hold the minor.
  */
-struct drm_minor *drm_minor_acquire(unsigned int minor_id)
+struct drm_minor *drm_minor_acquire(struct xarray *minor_xa, unsigned int minor_id)
 {
 	struct drm_minor *minor;
 
-	xa_lock(&drm_minors_xa);
-	minor = xa_load(&drm_minors_xa, minor_id);
+	xa_lock(minor_xa);
+	minor = xa_load(minor_xa, minor_id);
 	if (minor)
 		drm_dev_get(minor->dev);
-	xa_unlock(&drm_minors_xa);
+	xa_unlock(minor_xa);
 
 	if (!minor) {
 		return ERR_PTR(-ENODEV);
@@ -1020,7 +1018,7 @@ static int drm_stub_open(struct inode *inode, struct file *filp)
 
 	DRM_DEBUG("\n");
 
-	minor = drm_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 883d83bc0e3d..20c9afe0f5a5 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -413,7 +413,7 @@ int drm_open(struct inode *inode, struct file *filp)
 	int retcode;
 	int need_setup = 0;
 
-	minor = drm_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index d7e023bbb0d5..cb46f4c61991 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -77,10 +77,6 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
 void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
 				 uint32_t handle);
 
-/* drm_drv.c */
-struct drm_minor *drm_minor_acquire(unsigned int minor_id);
-void drm_minor_release(struct drm_minor *minor);
-
 /* drm_managed.c */
 void drm_managed_release(struct drm_device *dev);
 void drmm_add_final_kfree(struct drm_device *dev, void *container);
diff --git a/include/drm/drm_accel.h b/include/drm/drm_accel.h
index d4955062c77e..f93e23985f4e 100644
--- a/include/drm/drm_accel.h
+++ b/include/drm/drm_accel.h
@@ -51,11 +51,10 @@
 
 #if IS_ENABLED(CONFIG_DRM_ACCEL)
 
+extern struct xarray accel_minors_xa;
+
 void accel_core_exit(void);
 int accel_core_init(void);
-void accel_minor_remove(int index);
-int accel_minor_alloc(void);
-void accel_minor_replace(struct drm_minor *minor, int index);
 void accel_set_device_instance_params(struct device *kdev, int index);
 int accel_open(struct inode *inode, struct file *filp);
 void accel_debugfs_init(struct drm_minor *minor, int minor_id);
@@ -72,19 +71,6 @@ static inline int __init accel_core_init(void)
 	return 0;
 }
 
-static inline void accel_minor_remove(int index)
-{
-}
-
-static inline int accel_minor_alloc(void)
-{
-	return -EOPNOTSUPP;
-}
-
-static inline void accel_minor_replace(struct drm_minor *minor, int index)
-{
-}
-
 static inline void accel_set_device_instance_params(struct device *kdev, int index)
 {
 }
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 010239392adf..7fc09460051f 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -45,6 +45,8 @@ struct drm_printer;
 struct device;
 struct file;
 
+extern struct xarray drm_minors_xa;
+
 /*
  * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
  * header include loops we need it here for now.
@@ -420,6 +422,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
 	return file_priv->minor->type == DRM_MINOR_ACCEL;
 }
 
+struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
+void drm_minor_release(struct drm_minor *minor);
+
 int drm_open(struct inode *inode, struct file *filp);
 int drm_open_helper(struct file *filp, struct drm_minor *minor);
 ssize_t drm_read(struct file *filp, char __user *buffer,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [Intel-gfx] [PATCH v6 2/4] accel: Use XArray instead of IDR for minors
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

Accel minor management is based on DRM (and is also using struct
drm_minor internally), since DRM is using XArray for minors, it makes
sense to also convert accel.
As the two implementations are identical (only difference being the
underlying xarray), move the accel_minor_* functionality to DRM.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/accel/drm_accel.c      | 110 +++------------------------------
 drivers/gpu/drm/drm_drv.c      |  66 ++++++++++----------
 drivers/gpu/drm/drm_file.c     |   2 +-
 drivers/gpu/drm/drm_internal.h |   4 --
 include/drm/drm_accel.h        |  18 +-----
 include/drm/drm_file.h         |   5 ++
 6 files changed, 47 insertions(+), 158 deletions(-)

diff --git a/drivers/accel/drm_accel.c b/drivers/accel/drm_accel.c
index 4a9baf02439e..8827cb78ca9d 100644
--- a/drivers/accel/drm_accel.c
+++ b/drivers/accel/drm_accel.c
@@ -8,7 +8,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/device.h>
-#include <linux/idr.h>
+#include <linux/xarray.h>
 
 #include <drm/drm_accel.h>
 #include <drm/drm_debugfs.h>
@@ -17,8 +17,7 @@
 #include <drm/drm_ioctl.h>
 #include <drm/drm_print.h>
 
-static DEFINE_SPINLOCK(accel_minor_lock);
-static struct idr accel_minors_idr;
+DEFINE_XARRAY_ALLOC(accel_minors_xa);
 
 static struct dentry *accel_debugfs_root;
 static struct class *accel_class;
@@ -120,99 +119,6 @@ void accel_set_device_instance_params(struct device *kdev, int index)
 	kdev->type = &accel_sysfs_device_minor;
 }
 
-/**
- * accel_minor_alloc() - Allocates a new accel minor
- *
- * This function access the accel minors idr and allocates from it
- * a new id to represent a new accel minor
- *
- * Return: A new id on success or error code in case idr_alloc failed
- */
-int accel_minor_alloc(void)
-{
-	unsigned long flags;
-	int r;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	r = idr_alloc(&accel_minors_idr, NULL, 0, ACCEL_MAX_MINORS, GFP_NOWAIT);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-
-	return r;
-}
-
-/**
- * accel_minor_remove() - Remove an accel minor
- * @index: The minor id to remove.
- *
- * This function access the accel minors idr and removes from
- * it the member with the id that is passed to this function.
- */
-void accel_minor_remove(int index)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	idr_remove(&accel_minors_idr, index);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-}
-
-/**
- * accel_minor_replace() - Replace minor pointer in accel minors idr.
- * @minor: Pointer to the new minor.
- * @index: The minor id to replace.
- *
- * This function access the accel minors idr structure and replaces the pointer
- * that is associated with an existing id. Because the minor pointer can be
- * NULL, we need to explicitly pass the index.
- *
- * Return: 0 for success, negative value for error
- */
-void accel_minor_replace(struct drm_minor *minor, int index)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	idr_replace(&accel_minors_idr, minor, index);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-}
-
-/*
- * Looks up the given minor-ID and returns the respective DRM-minor object. The
- * refence-count of the underlying device is increased so you must release this
- * object with accel_minor_release().
- *
- * The object can be only a drm_minor that represents an accel device.
- *
- * As long as you hold this minor, it is guaranteed that the object and the
- * minor->dev pointer will stay valid! However, the device may get unplugged and
- * unregistered while you hold the minor.
- */
-static struct drm_minor *accel_minor_acquire(unsigned int minor_id)
-{
-	struct drm_minor *minor;
-	unsigned long flags;
-
-	spin_lock_irqsave(&accel_minor_lock, flags);
-	minor = idr_find(&accel_minors_idr, minor_id);
-	if (minor)
-		drm_dev_get(minor->dev);
-	spin_unlock_irqrestore(&accel_minor_lock, flags);
-
-	if (!minor) {
-		return ERR_PTR(-ENODEV);
-	} else if (drm_dev_is_unplugged(minor->dev)) {
-		drm_dev_put(minor->dev);
-		return ERR_PTR(-ENODEV);
-	}
-
-	return minor;
-}
-
-static void accel_minor_release(struct drm_minor *minor)
-{
-	drm_dev_put(minor->dev);
-}
-
 /**
  * accel_open - open method for ACCEL file
  * @inode: device inode
@@ -230,7 +136,7 @@ int accel_open(struct inode *inode, struct file *filp)
 	struct drm_minor *minor;
 	int retcode;
 
-	minor = accel_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&accel_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
@@ -249,7 +155,7 @@ int accel_open(struct inode *inode, struct file *filp)
 
 err_undo:
 	atomic_dec(&dev->open_count);
-	accel_minor_release(minor);
+	drm_minor_release(minor);
 	return retcode;
 }
 EXPORT_SYMBOL_GPL(accel_open);
@@ -260,7 +166,7 @@ static int accel_stub_open(struct inode *inode, struct file *filp)
 	struct drm_minor *minor;
 	int err;
 
-	minor = accel_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&accel_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
@@ -277,7 +183,7 @@ static int accel_stub_open(struct inode *inode, struct file *filp)
 		err = 0;
 
 out:
-	accel_minor_release(minor);
+	drm_minor_release(minor);
 
 	return err;
 }
@@ -293,15 +199,13 @@ void accel_core_exit(void)
 	unregister_chrdev(ACCEL_MAJOR, "accel");
 	debugfs_remove(accel_debugfs_root);
 	accel_sysfs_destroy();
-	idr_destroy(&accel_minors_idr);
+	WARN_ON(!xa_empty(&accel_minors_xa));
 }
 
 int __init accel_core_init(void)
 {
 	int ret;
 
-	idr_init(&accel_minors_idr);
-
 	ret = accel_sysfs_init();
 	if (ret < 0) {
 		DRM_ERROR("Cannot create ACCEL class: %d\n", ret);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3faecb01186f..34b60196c443 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -55,7 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
 MODULE_DESCRIPTION("DRM shared core routines");
 MODULE_LICENSE("GPL and additional rights");
 
-static DEFINE_XARRAY_ALLOC(drm_minors_xa);
+DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
 /*
  * If the drm core fails to init for whatever reason,
@@ -83,6 +83,18 @@ DEFINE_STATIC_SRCU(drm_unplug_srcu);
  * registered and unregistered dynamically according to device-state.
  */
 
+static struct xarray *drm_minor_get_xa(enum drm_minor_type type)
+{
+	if (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER)
+		return &drm_minors_xa;
+#if IS_ENABLED(CONFIG_DRM_ACCEL)
+	else if (type == DRM_MINOR_ACCEL)
+		return &accel_minors_xa;
+#endif
+	else
+		return ERR_PTR(-EOPNOTSUPP);
+}
+
 static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
 					     enum drm_minor_type type)
 {
@@ -106,18 +118,18 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 
 	put_device(minor->kdev);
 
-	if (minor->type == DRM_MINOR_ACCEL)
-		accel_minor_remove(minor->index);
-	else
-		xa_erase(&drm_minors_xa, minor->index);
+	xa_erase(drm_minor_get_xa(minor->type), minor->index);
 }
 
-#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
+#define DRM_MINOR_LIMIT(t) ({ \
+	typeof(t) _t = (t); \
+	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
+})
 
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	int index, r;
+	int r;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -126,18 +138,11 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	if (type == DRM_MINOR_ACCEL) {
-		r = accel_minor_alloc();
-		index = r;
-	} else {
-		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
-	}
-
+	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
+		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	if (r < 0)
 		return r;
 
-	minor->index = index;
-
 	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
 	if (r)
 		return r;
@@ -177,16 +182,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
 		goto err_debugfs;
 
 	/* replace NULL with @minor so lookups will succeed from now on */
-	if (minor->type == DRM_MINOR_ACCEL) {
-		accel_minor_replace(minor, minor->index);
-	} else {
-		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
-		if (xa_is_err(entry)) {
-			ret = xa_err(entry);
-			goto err_debugfs;
-		}
-		WARN_ON(entry);
+	entry = xa_store(drm_minor_get_xa(type), minor->index, minor, GFP_KERNEL);
+	if (xa_is_err(entry)) {
+		ret = xa_err(entry);
+		goto err_debugfs;
 	}
+	WARN_ON(entry);
 
 	DRM_DEBUG("new minor registered %d\n", minor->index);
 	return 0;
@@ -205,10 +206,7 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
 		return;
 
 	/* replace @minor with NULL so lookups will fail from now on */
-	if (minor->type == DRM_MINOR_ACCEL)
-		accel_minor_replace(NULL, minor->index);
-	else
-		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
+	xa_store(drm_minor_get_xa(type), minor->index, NULL, GFP_KERNEL);
 
 	device_del(minor->kdev);
 	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
@@ -224,15 +222,15 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
  * minor->dev pointer will stay valid! However, the device may get unplugged and
  * unregistered while you hold the minor.
  */
-struct drm_minor *drm_minor_acquire(unsigned int minor_id)
+struct drm_minor *drm_minor_acquire(struct xarray *minor_xa, unsigned int minor_id)
 {
 	struct drm_minor *minor;
 
-	xa_lock(&drm_minors_xa);
-	minor = xa_load(&drm_minors_xa, minor_id);
+	xa_lock(minor_xa);
+	minor = xa_load(minor_xa, minor_id);
 	if (minor)
 		drm_dev_get(minor->dev);
-	xa_unlock(&drm_minors_xa);
+	xa_unlock(minor_xa);
 
 	if (!minor) {
 		return ERR_PTR(-ENODEV);
@@ -1020,7 +1018,7 @@ static int drm_stub_open(struct inode *inode, struct file *filp)
 
 	DRM_DEBUG("\n");
 
-	minor = drm_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 883d83bc0e3d..20c9afe0f5a5 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -413,7 +413,7 @@ int drm_open(struct inode *inode, struct file *filp)
 	int retcode;
 	int need_setup = 0;
 
-	minor = drm_minor_acquire(iminor(inode));
+	minor = drm_minor_acquire(&drm_minors_xa, iminor(inode));
 	if (IS_ERR(minor))
 		return PTR_ERR(minor);
 
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index d7e023bbb0d5..cb46f4c61991 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -77,10 +77,6 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
 void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
 				 uint32_t handle);
 
-/* drm_drv.c */
-struct drm_minor *drm_minor_acquire(unsigned int minor_id);
-void drm_minor_release(struct drm_minor *minor);
-
 /* drm_managed.c */
 void drm_managed_release(struct drm_device *dev);
 void drmm_add_final_kfree(struct drm_device *dev, void *container);
diff --git a/include/drm/drm_accel.h b/include/drm/drm_accel.h
index d4955062c77e..f93e23985f4e 100644
--- a/include/drm/drm_accel.h
+++ b/include/drm/drm_accel.h
@@ -51,11 +51,10 @@
 
 #if IS_ENABLED(CONFIG_DRM_ACCEL)
 
+extern struct xarray accel_minors_xa;
+
 void accel_core_exit(void);
 int accel_core_init(void);
-void accel_minor_remove(int index);
-int accel_minor_alloc(void);
-void accel_minor_replace(struct drm_minor *minor, int index);
 void accel_set_device_instance_params(struct device *kdev, int index);
 int accel_open(struct inode *inode, struct file *filp);
 void accel_debugfs_init(struct drm_minor *minor, int minor_id);
@@ -72,19 +71,6 @@ static inline int __init accel_core_init(void)
 	return 0;
 }
 
-static inline void accel_minor_remove(int index)
-{
-}
-
-static inline int accel_minor_alloc(void)
-{
-	return -EOPNOTSUPP;
-}
-
-static inline void accel_minor_replace(struct drm_minor *minor, int index)
-{
-}
-
 static inline void accel_set_device_instance_params(struct device *kdev, int index)
 {
 }
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 010239392adf..7fc09460051f 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -45,6 +45,8 @@ struct drm_printer;
 struct device;
 struct file;
 
+extern struct xarray drm_minors_xa;
+
 /*
  * FIXME: Not sure we want to have drm_minor here in the end, but to avoid
  * header include loops we need it here for now.
@@ -420,6 +422,9 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
 	return file_priv->minor->type == DRM_MINOR_ACCEL;
 }
 
+struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
+void drm_minor_release(struct drm_minor *minor);
+
 int drm_open(struct inode *inode, struct file *filp);
 int drm_open_helper(struct file *filp, struct drm_minor *minor);
 ssize_t drm_read(struct file *filp, char __user *buffer,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-07-24 21:14 ` Michał Winiarski
  (?)
@ 2023-07-24 21:14   ` Michał Winiarski
  -1 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Matthew Wilcox, Oded Gabbay,
	Christian König, James Zhu, Pekka Paalanen, Emil Velikov,
	Michał Winiarski

Having a limit of 64 DRM devices is not good enough for modern world
where we have multi-GPU servers, SR-IOV virtual functions and virtual
devices used for testing.
Let's utilize full minor range for DRM devices.
To avoid regressing the existing userspace, we're still maintaining the
numbering scheme where 0-63 is used for primary, 64-127 is reserved
(formerly for control) and 128-191 is used for render.
For minors >= 192, we're allocating minors dynamically on a first-come,
first-served basis.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 34b60196c443..c2c6e80e6b31 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 	xa_erase(drm_minor_get_xa(minor->type), minor->index);
 }
 
+/*
+ * DRM used to support 64 devices, for backwards compatibility we need to maintain the
+ * minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes,
+ * and 128-191 are render nodes.
+ * After reaching the limit, we're allocating minors dynamically - first-come, first-serve.
+ * Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX
+ * range.
+ */
 #define DRM_MINOR_LIMIT(t) ({ \
 	typeof(t) _t = (t); \
 	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
 })
+#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1)
 
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
@@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 
 	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
 		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
+	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
+		r = xa_alloc(&drm_minors_xa, &minor->index,
+			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
 	if (r < 0)
 		return r;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

Having a limit of 64 DRM devices is not good enough for modern world
where we have multi-GPU servers, SR-IOV virtual functions and virtual
devices used for testing.
Let's utilize full minor range for DRM devices.
To avoid regressing the existing userspace, we're still maintaining the
numbering scheme where 0-63 is used for primary, 64-127 is reserved
(formerly for control) and 128-191 is used for render.
For minors >= 192, we're allocating minors dynamically on a first-come,
first-served basis.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 34b60196c443..c2c6e80e6b31 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 	xa_erase(drm_minor_get_xa(minor->type), minor->index);
 }
 
+/*
+ * DRM used to support 64 devices, for backwards compatibility we need to maintain the
+ * minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes,
+ * and 128-191 are render nodes.
+ * After reaching the limit, we're allocating minors dynamically - first-come, first-serve.
+ * Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX
+ * range.
+ */
 #define DRM_MINOR_LIMIT(t) ({ \
 	typeof(t) _t = (t); \
 	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
 })
+#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1)
 
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
@@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 
 	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
 		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
+	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
+		r = xa_alloc(&drm_minors_xa, &minor->index,
+			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
 	if (r < 0)
 		return r;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

Having a limit of 64 DRM devices is not good enough for modern world
where we have multi-GPU servers, SR-IOV virtual functions and virtual
devices used for testing.
Let's utilize full minor range for DRM devices.
To avoid regressing the existing userspace, we're still maintaining the
numbering scheme where 0-63 is used for primary, 64-127 is reserved
(formerly for control) and 128-191 is used for render.
For minors >= 192, we're allocating minors dynamically on a first-come,
first-served basis.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 34b60196c443..c2c6e80e6b31 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 	xa_erase(drm_minor_get_xa(minor->type), minor->index);
 }
 
+/*
+ * DRM used to support 64 devices, for backwards compatibility we need to maintain the
+ * minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes,
+ * and 128-191 are render nodes.
+ * After reaching the limit, we're allocating minors dynamically - first-come, first-serve.
+ * Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX
+ * range.
+ */
 #define DRM_MINOR_LIMIT(t) ({ \
 	typeof(t) _t = (t); \
 	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
 })
+#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1)
 
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
@@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 
 	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
 		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
+	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
+		r = xa_alloc(&drm_minors_xa, &minor->index,
+			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
 	if (r < 0)
 		return r;
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 4/4] drm: Introduce force_extended_minors modparam
  2023-07-24 21:14 ` Michał Winiarski
  (?)
@ 2023-07-24 21:14   ` Michał Winiarski
  -1 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Matthew Wilcox, Oded Gabbay,
	Christian König, James Zhu, Pekka Paalanen, Emil Velikov,
	Michał Winiarski

While there is support for >64 DRM devices on kernel side, existing
userspace may still have some hardcoded assumptions and it's possible
that it will require changes to be able to use more than 64 devices.
Add a modparam to simplify testing and development of >64 devices
support on userspace side by allocating minors from the >=192 range
(without the need of having >64 physical devices connected).

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index c2c6e80e6b31..ef6d7b498784 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -57,6 +57,11 @@ MODULE_LICENSE("GPL and additional rights");
 
 DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
+static bool force_extended_minors;
+module_param_unsafe(force_extended_minors, bool, 0400);
+MODULE_PARM_DESC(force_extended_minors,
+		 "Don't allocate minors in 0-192 range. This can be used for testing userspace support for >64 drm devices (default: false)");
+
 /*
  * If the drm core fails to init for whatever reason,
  * we should prevent any drivers from registering with it.
@@ -138,7 +143,7 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	int r;
+	int r = -EBUSY;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -147,8 +152,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
-		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
+	if (type == DRM_MINOR_ACCEL || !force_extended_minors)
+		r = xa_alloc(drm_minor_get_xa(type), &minor->index,
+			     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
 		r = xa_alloc(&drm_minors_xa, &minor->index,
 			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH v6 4/4] drm: Introduce force_extended_minors modparam
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

While there is support for >64 DRM devices on kernel side, existing
userspace may still have some hardcoded assumptions and it's possible
that it will require changes to be able to use more than 64 devices.
Add a modparam to simplify testing and development of >64 devices
support on userspace side by allocating minors from the >=192 range
(without the need of having >64 physical devices connected).

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index c2c6e80e6b31..ef6d7b498784 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -57,6 +57,11 @@ MODULE_LICENSE("GPL and additional rights");
 
 DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
+static bool force_extended_minors;
+module_param_unsafe(force_extended_minors, bool, 0400);
+MODULE_PARM_DESC(force_extended_minors,
+		 "Don't allocate minors in 0-192 range. This can be used for testing userspace support for >64 drm devices (default: false)");
+
 /*
  * If the drm core fails to init for whatever reason,
  * we should prevent any drivers from registering with it.
@@ -138,7 +143,7 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	int r;
+	int r = -EBUSY;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -147,8 +152,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
-		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
+	if (type == DRM_MINOR_ACCEL || !force_extended_minors)
+		r = xa_alloc(drm_minor_get_xa(type), &minor->index,
+			     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
 		r = xa_alloc(&drm_minors_xa, &minor->index,
 			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [Intel-gfx] [PATCH v6 4/4] drm: Introduce force_extended_minors modparam
@ 2023-07-24 21:14   ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-07-24 21:14 UTC (permalink / raw)
  To: dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	Michał Winiarski, James Zhu, Christian König

While there is support for >64 DRM devices on kernel side, existing
userspace may still have some hardcoded assumptions and it's possible
that it will require changes to be able to use more than 64 devices.
Add a modparam to simplify testing and development of >64 devices
support on userspace side by allocating minors from the >=192 range
(without the need of having >64 physical devices connected).

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index c2c6e80e6b31..ef6d7b498784 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -57,6 +57,11 @@ MODULE_LICENSE("GPL and additional rights");
 
 DEFINE_XARRAY_ALLOC(drm_minors_xa);
 
+static bool force_extended_minors;
+module_param_unsafe(force_extended_minors, bool, 0400);
+MODULE_PARM_DESC(force_extended_minors,
+		 "Don't allocate minors in 0-192 range. This can be used for testing userspace support for >64 drm devices (default: false)");
+
 /*
  * If the drm core fails to init for whatever reason,
  * we should prevent any drivers from registering with it.
@@ -138,7 +143,7 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
 static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 {
 	struct drm_minor *minor;
-	int r;
+	int r = -EBUSY;
 
 	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
 	if (!minor)
@@ -147,8 +152,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
 	minor->type = type;
 	minor->dev = dev;
 
-	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
-		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
+	if (type == DRM_MINOR_ACCEL || !force_extended_minors)
+		r = xa_alloc(drm_minor_get_xa(type), &minor->index,
+			     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
 	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
 		r = xa_alloc(&drm_minors_xa, &minor->index,
 			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Use full allocated minor range for DRM (rev3)
  2023-07-24 21:14 ` Michał Winiarski
                   ` (5 preceding siblings ...)
  (?)
@ 2023-07-24 21:46 ` Patchwork
  -1 siblings, 0 replies; 64+ messages in thread
From: Patchwork @ 2023-07-24 21:46 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

== Series Details ==

Series: drm: Use full allocated minor range for DRM (rev3)
URL   : https://patchwork.freedesktop.org/series/108206/
State : warning

== Summary ==

Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.



^ permalink raw reply	[flat|nested] 64+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Use full allocated minor range for DRM (rev3)
  2023-07-24 21:14 ` Michał Winiarski
                   ` (6 preceding siblings ...)
  (?)
@ 2023-07-24 22:00 ` Patchwork
  -1 siblings, 0 replies; 64+ messages in thread
From: Patchwork @ 2023-07-24 22:00 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 6475 bytes --]

== Series Details ==

Series: drm: Use full allocated minor range for DRM (rev3)
URL   : https://patchwork.freedesktop.org/series/108206/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_13417 -> Patchwork_108206v3
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/index.html

Participating hosts (42 -> 41)
------------------------------

  Missing    (1): bat-rpls-2 

Known issues
------------

  Here are the changes found in Patchwork_108206v3 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_pm_rpm@basic-rte:
    - fi-cfl-8109u:       [PASS][1] -> [FAIL][2] ([i915#7940]) +1 similar issue
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/fi-cfl-8109u/igt@i915_pm_rpm@basic-rte.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/fi-cfl-8109u/igt@i915_pm_rpm@basic-rte.html

  * igt@i915_selftest@live@slpc:
    - bat-mtlp-6:         [PASS][3] -> [DMESG-WARN][4] ([i915#6367])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/bat-mtlp-6/igt@i915_selftest@live@slpc.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-mtlp-6/igt@i915_selftest@live@slpc.html
    - bat-mtlp-8:         NOTRUN -> [DMESG-WARN][5] ([i915#6367])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-mtlp-8/igt@i915_selftest@live@slpc.html
    - bat-rpls-1:         [PASS][6] -> [DMESG-WARN][7] ([i915#6367])
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/bat-rpls-1/igt@i915_selftest@live@slpc.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-rpls-1/igt@i915_selftest@live@slpc.html

  * igt@i915_suspend@basic-s3-without-i915:
    - bat-mtlp-8:         NOTRUN -> [SKIP][8] ([i915#6645])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-mtlp-8/igt@i915_suspend@basic-s3-without-i915.html

  * igt@kms_chamelium_hpd@common-hpd-after-suspend:
    - bat-mtlp-8:         NOTRUN -> [SKIP][9] ([i915#7828])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-mtlp-8/igt@kms_chamelium_hpd@common-hpd-after-suspend.html

  * igt@kms_psr@primary_mmap_gtt:
    - bat-rplp-1:         NOTRUN -> [ABORT][10] ([i915#8434] / [i915#8442] / [i915#8668])
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-rplp-1/igt@kms_psr@primary_mmap_gtt.html

  * igt@kms_psr@sprite_plane_onoff:
    - bat-rplp-1:         NOTRUN -> [SKIP][11] ([i915#1072])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-rplp-1/igt@kms_psr@sprite_plane_onoff.html

  
#### Possible fixes ####

  * igt@i915_pm_rpm@module-reload:
    - fi-cfl-guc:         [FAIL][12] ([i915#7940]) -> [PASS][13]
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/fi-cfl-guc/igt@i915_pm_rpm@module-reload.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/fi-cfl-guc/igt@i915_pm_rpm@module-reload.html

  * igt@i915_selftest@live@gt_heartbeat:
    - fi-kbl-soraka:      [DMESG-FAIL][14] ([i915#5334] / [i915#7872]) -> [PASS][15]
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html

  * igt@i915_selftest@live@requests:
    - bat-mtlp-8:         [ABORT][16] ([i915#7982]) -> [PASS][17]
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/bat-mtlp-8/igt@i915_selftest@live@requests.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-mtlp-8/igt@i915_selftest@live@requests.html
    - bat-mtlp-6:         [DMESG-FAIL][18] ([i915#8497]) -> [PASS][19]
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/bat-mtlp-6/igt@i915_selftest@live@requests.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-mtlp-6/igt@i915_selftest@live@requests.html

  
#### Warnings ####

  * igt@i915_pm_rpm@basic-pci-d3-state:
    - fi-cfl-8700k:       [FAIL][20] ([i915#7940]) -> [FAIL][21] ([i915#7691])
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/fi-cfl-8700k/igt@i915_pm_rpm@basic-pci-d3-state.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/fi-cfl-8700k/igt@i915_pm_rpm@basic-pci-d3-state.html

  * igt@kms_psr@cursor_plane_move:
    - bat-rplp-1:         [ABORT][22] ([i915#8434] / [i915#8668]) -> [SKIP][23] ([i915#1072])
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/bat-rplp-1/igt@kms_psr@cursor_plane_move.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/bat-rplp-1/igt@kms_psr@cursor_plane_move.html

  
  [i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
  [i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
  [i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
  [i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
  [i915#7691]: https://gitlab.freedesktop.org/drm/intel/issues/7691
  [i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
  [i915#7872]: https://gitlab.freedesktop.org/drm/intel/issues/7872
  [i915#7940]: https://gitlab.freedesktop.org/drm/intel/issues/7940
  [i915#7982]: https://gitlab.freedesktop.org/drm/intel/issues/7982
  [i915#8434]: https://gitlab.freedesktop.org/drm/intel/issues/8434
  [i915#8442]: https://gitlab.freedesktop.org/drm/intel/issues/8442
  [i915#8497]: https://gitlab.freedesktop.org/drm/intel/issues/8497
  [i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668


Build changes
-------------

  * Linux: CI_DRM_13417 -> Patchwork_108206v3

  CI-20190529: 20190529
  CI_DRM_13417: 58ea4f6d151dc9e4f9822e5073d926a11d5af80c @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7400: 86fa0e885f8d020eeb046f27fae5729d5962ebd7 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_108206v3: 58ea4f6d151dc9e4f9822e5073d926a11d5af80c @ git://anongit.freedesktop.org/gfx-ci/linux


### Linux commits

5f3e6d03e6b0 drm: Introduce force_extended_minors modparam
c42e18c639da drm: Expand max DRM device number to full MINORBITS
323b8ba06c91 accel: Use XArray instead of IDR for minors
040f50015eb6 drm: Use XArray instead of IDR for minors

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/index.html

[-- Attachment #2: Type: text/html, Size: 7884 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-07-24 21:14   ` Michał Winiarski
@ 2023-07-24 22:29     ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-07-24 22:29 UTC (permalink / raw)
  To: Michał Winiarski, dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann, James Zhu,
	Christian König

[-- Attachment #1: Type: text/plain, Size: 2465 bytes --]


On 2023-07-24 17:14, Michał Winiarski wrote:
> Having a limit of 64 DRM devices is not good enough for modern world
> where we have multi-GPU servers, SR-IOV virtual functions and virtual
> devices used for testing.
> Let's utilize full minor range for DRM devices.
> To avoid regressing the existing userspace, we're still maintaining the
> numbering scheme where 0-63 is used for primary, 64-127 is reserved
> (formerly for control) and 128-191 is used for render.
> For minors >= 192, we're allocating minors dynamically on a first-come,
> first-served basis.

[JZ] Hello Michal,

Do you have libdrm patches for review together with this change?

Especially to support static int drmGetMinorType(int major, int minor).

Thanks and Best Regards!

James Zhu

>
> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> ---
>   drivers/gpu/drm/drm_drv.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 34b60196c443..c2c6e80e6b31 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>   	xa_erase(drm_minor_get_xa(minor->type), minor->index);
>   }
>   
> +/*
> + * DRM used to support 64 devices, for backwards compatibility we need to maintain the
> + * minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes,
> + * and 128-191 are render nodes.
> + * After reaching the limit, we're allocating minors dynamically - first-come, first-serve.
> + * Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX
> + * range.
> + */
>   #define DRM_MINOR_LIMIT(t) ({ \
>   	typeof(t) _t = (t); \
>   	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
>   })
> +#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1)
>   
>   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   {
> @@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   
>   	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
>   		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
> +	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
> +		r = xa_alloc(&drm_minors_xa, &minor->index,
> +			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
>   	if (r < 0)
>   		return r;
>   

[-- Attachment #2: Type: text/html, Size: 4737 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-24 22:29     ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-07-24 22:29 UTC (permalink / raw)
  To: Michał Winiarski, dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	James Zhu, Christian König

[-- Attachment #1: Type: text/plain, Size: 2465 bytes --]


On 2023-07-24 17:14, Michał Winiarski wrote:
> Having a limit of 64 DRM devices is not good enough for modern world
> where we have multi-GPU servers, SR-IOV virtual functions and virtual
> devices used for testing.
> Let's utilize full minor range for DRM devices.
> To avoid regressing the existing userspace, we're still maintaining the
> numbering scheme where 0-63 is used for primary, 64-127 is reserved
> (formerly for control) and 128-191 is used for render.
> For minors >= 192, we're allocating minors dynamically on a first-come,
> first-served basis.

[JZ] Hello Michal,

Do you have libdrm patches for review together with this change?

Especially to support static int drmGetMinorType(int major, int minor).

Thanks and Best Regards!

James Zhu

>
> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> ---
>   drivers/gpu/drm/drm_drv.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 34b60196c443..c2c6e80e6b31 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>   	xa_erase(drm_minor_get_xa(minor->type), minor->index);
>   }
>   
> +/*
> + * DRM used to support 64 devices, for backwards compatibility we need to maintain the
> + * minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes,
> + * and 128-191 are render nodes.
> + * After reaching the limit, we're allocating minors dynamically - first-come, first-serve.
> + * Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX
> + * range.
> + */
>   #define DRM_MINOR_LIMIT(t) ({ \
>   	typeof(t) _t = (t); \
>   	_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
>   })
> +#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1)
>   
>   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   {
> @@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   
>   	r = xa_alloc(drm_minor_get_xa(type), &minor->index,
>   		     NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
> +	if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
> +		r = xa_alloc(&drm_minors_xa, &minor->index,
> +			     NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
>   	if (r < 0)
>   		return r;
>   

[-- Attachment #2: Type: text/html, Size: 4737 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [Intel-gfx] ✗ Fi.CI.IGT: failure for drm: Use full allocated minor range for DRM (rev3)
  2023-07-24 21:14 ` Michał Winiarski
                   ` (7 preceding siblings ...)
  (?)
@ 2023-07-25  6:39 ` Patchwork
  -1 siblings, 0 replies; 64+ messages in thread
From: Patchwork @ 2023-07-25  6:39 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 48585 bytes --]

== Series Details ==

Series: drm: Use full allocated minor range for DRM (rev3)
URL   : https://patchwork.freedesktop.org/series/108206/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13417_full -> Patchwork_108206v3_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_108206v3_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_108206v3_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

Participating hosts (11 -> 11)
------------------------------

  No changes in participating hosts

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_108206v3_full:

### IGT changes ###

#### Possible regressions ####

  * igt@gem_linear_blits@normal:
    - shard-snb:          NOTRUN -> [ABORT][1]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb6/igt@gem_linear_blits@normal.html

  
Known issues
------------

  Here are the changes found in Patchwork_108206v3_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@api_intel_bb@blit-reloc-purge-cache:
    - shard-dg2:          NOTRUN -> [SKIP][2] ([i915#8411])
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@api_intel_bb@blit-reloc-purge-cache.html
    - shard-rkl:          NOTRUN -> [SKIP][3] ([i915#8411])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@api_intel_bb@blit-reloc-purge-cache.html

  * igt@drm_fdinfo@busy-idle@bcs0:
    - shard-dg2:          NOTRUN -> [SKIP][4] ([i915#8414]) +10 similar issues
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@drm_fdinfo@busy-idle@bcs0.html

  * igt@gem_basic@multigpu-create-close:
    - shard-dg2:          NOTRUN -> [SKIP][5] ([i915#7697])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gem_basic@multigpu-create-close.html

  * igt@gem_ctx_persistence@legacy-engines-mixed:
    - shard-snb:          NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#1099]) +2 similar issues
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb5/igt@gem_ctx_persistence@legacy-engines-mixed.html

  * igt@gem_eio@hibernate:
    - shard-tglu:         [PASS][7] -> [ABORT][8] ([i915#7975] / [i915#8213] / [i915#8398])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-tglu-9/igt@gem_eio@hibernate.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-tglu-10/igt@gem_eio@hibernate.html
    - shard-dg2:          NOTRUN -> [ABORT][9] ([i915#7975] / [i915#8213])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gem_eio@hibernate.html

  * igt@gem_exec_balancer@full-pulse:
    - shard-dg2:          [PASS][10] -> [FAIL][11] ([i915#6032])
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-11/igt@gem_exec_balancer@full-pulse.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-1/igt@gem_exec_balancer@full-pulse.html

  * igt@gem_exec_balancer@hog:
    - shard-dg2:          NOTRUN -> [SKIP][12] ([i915#4812])
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_exec_balancer@hog.html

  * igt@gem_exec_capture@pi@vcs0:
    - shard-mtlp:         [PASS][13] -> [FAIL][14] ([i915#4475])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-3/igt@gem_exec_capture@pi@vcs0.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-7/igt@gem_exec_capture@pi@vcs0.html

  * igt@gem_exec_capture@pi@vcs1:
    - shard-mtlp:         [PASS][15] -> [DMESG-WARN][16] ([i915#8504])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-3/igt@gem_exec_capture@pi@vcs1.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-7/igt@gem_exec_capture@pi@vcs1.html

  * igt@gem_exec_fair@basic-none-solo@rcs0:
    - shard-apl:          [PASS][17] -> [FAIL][18] ([i915#2842])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-apl2/igt@gem_exec_fair@basic-none-solo@rcs0.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-apl4/igt@gem_exec_fair@basic-none-solo@rcs0.html

  * igt@gem_exec_fair@basic-pace:
    - shard-dg2:          NOTRUN -> [SKIP][19] ([i915#3539])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_exec_fair@basic-pace.html

  * igt@gem_exec_fair@basic-pace-solo@rcs0:
    - shard-rkl:          [PASS][20] -> [FAIL][21] ([i915#2842]) +1 similar issue
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-6/igt@gem_exec_fair@basic-pace-solo@rcs0.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-1/igt@gem_exec_fair@basic-pace-solo@rcs0.html

  * igt@gem_exec_fair@basic-pace@bcs0:
    - shard-rkl:          NOTRUN -> [FAIL][22] ([i915#2842]) +2 similar issues
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_exec_fair@basic-pace@bcs0.html

  * igt@gem_exec_reloc@basic-range:
    - shard-rkl:          NOTRUN -> [SKIP][23] ([i915#3281]) +1 similar issue
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_exec_reloc@basic-range.html

  * igt@gem_exec_reloc@basic-wc-read:
    - shard-dg2:          NOTRUN -> [SKIP][24] ([i915#3281]) +3 similar issues
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_exec_reloc@basic-wc-read.html

  * igt@gem_exec_suspend@basic-s4-devices@smem:
    - shard-rkl:          NOTRUN -> [ABORT][25] ([i915#7975] / [i915#8213])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_exec_suspend@basic-s4-devices@smem.html

  * igt@gem_exec_whisper@basic-contexts-forked-all:
    - shard-mtlp:         [PASS][26] -> [ABORT][27] ([i915#8131]) +1 similar issue
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-6/igt@gem_exec_whisper@basic-contexts-forked-all.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-6/igt@gem_exec_whisper@basic-contexts-forked-all.html

  * igt@gem_fenced_exec_thrash@no-spare-fences-busy-interruptible:
    - shard-dg2:          NOTRUN -> [SKIP][28] ([i915#4860]) +1 similar issue
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_fenced_exec_thrash@no-spare-fences-busy-interruptible.html

  * igt@gem_lmem_swapping@basic:
    - shard-rkl:          NOTRUN -> [SKIP][29] ([i915#4613])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_lmem_swapping@basic.html

  * igt@gem_mmap_gtt@cpuset-big-copy:
    - shard-dg2:          NOTRUN -> [SKIP][30] ([i915#4077]) +5 similar issues
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gem_mmap_gtt@cpuset-big-copy.html

  * igt@gem_mmap_wc@write-prefaulted:
    - shard-dg2:          NOTRUN -> [SKIP][31] ([i915#4083]) +3 similar issues
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gem_mmap_wc@write-prefaulted.html

  * igt@gem_pwrite@basic-exhaustion:
    - shard-dg2:          NOTRUN -> [SKIP][32] ([i915#3282]) +1 similar issue
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_pwrite@basic-exhaustion.html
    - shard-rkl:          NOTRUN -> [SKIP][33] ([i915#3282]) +1 similar issue
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_pwrite@basic-exhaustion.html

  * igt@gem_pxp@verify-pxp-key-change-after-suspend-resume:
    - shard-dg2:          NOTRUN -> [SKIP][34] ([i915#4270])
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gem_pxp@verify-pxp-key-change-after-suspend-resume.html

  * igt@gem_set_tiling_vs_blt@untiled-to-tiled:
    - shard-dg2:          NOTRUN -> [SKIP][35] ([i915#4079])
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gem_set_tiling_vs_blt@untiled-to-tiled.html

  * igt@gem_userptr_blits@coherency-sync:
    - shard-dg2:          NOTRUN -> [SKIP][36] ([i915#3297]) +2 similar issues
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_userptr_blits@coherency-sync.html
    - shard-rkl:          NOTRUN -> [SKIP][37] ([fdo#110542])
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_userptr_blits@coherency-sync.html

  * igt@gem_userptr_blits@unsync-overlap:
    - shard-rkl:          NOTRUN -> [SKIP][38] ([i915#3297])
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gem_userptr_blits@unsync-overlap.html

  * igt@gem_userptr_blits@vma-merge:
    - shard-snb:          NOTRUN -> [FAIL][39] ([i915#2724])
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb5/igt@gem_userptr_blits@vma-merge.html

  * igt@gen7_exec_parse@basic-rejected:
    - shard-dg2:          NOTRUN -> [SKIP][40] ([fdo#109289]) +2 similar issues
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@gen7_exec_parse@basic-rejected.html

  * igt@gen7_exec_parse@chained-batch:
    - shard-rkl:          NOTRUN -> [SKIP][41] ([fdo#109289])
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@gen7_exec_parse@chained-batch.html

  * igt@gen9_exec_parse@basic-rejected-ctx-param:
    - shard-snb:          NOTRUN -> [SKIP][42] ([fdo#109271]) +268 similar issues
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb5/igt@gen9_exec_parse@basic-rejected-ctx-param.html

  * igt@gen9_exec_parse@batch-zero-length:
    - shard-dg2:          NOTRUN -> [SKIP][43] ([i915#2856])
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gen9_exec_parse@batch-zero-length.html

  * igt@i915_hwmon@hwmon-read:
    - shard-rkl:          NOTRUN -> [SKIP][44] ([i915#7707])
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@i915_hwmon@hwmon-read.html

  * igt@i915_module_load@reload-with-fault-injection:
    - shard-dg2:          NOTRUN -> [DMESG-WARN][45] ([i915#7061])
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@i915_module_load@reload-with-fault-injection.html

  * igt@i915_pm_rpm@drm-resources-equal:
    - shard-rkl:          [PASS][46] -> [FAIL][47] ([i915#7940])
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-1/igt@i915_pm_rpm@drm-resources-equal.html
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-4/igt@i915_pm_rpm@drm-resources-equal.html

  * igt@i915_pm_rpm@modeset-lpsp:
    - shard-dg2:          NOTRUN -> [SKIP][48] ([i915#1397])
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@i915_pm_rpm@modeset-lpsp.html

  * igt@i915_pm_rpm@modeset-non-lpsp-stress:
    - shard-rkl:          [PASS][49] -> [SKIP][50] ([i915#1397]) +1 similar issue
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-4/igt@i915_pm_rpm@modeset-non-lpsp-stress.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-7/igt@i915_pm_rpm@modeset-non-lpsp-stress.html

  * igt@i915_pm_rps@min-max-config-idle:
    - shard-dg2:          NOTRUN -> [SKIP][51] ([i915#6621])
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@i915_pm_rps@min-max-config-idle.html

  * igt@i915_query@query-topology-coherent-slice-mask:
    - shard-dg2:          NOTRUN -> [SKIP][52] ([i915#6188])
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@i915_query@query-topology-coherent-slice-mask.html

  * igt@i915_suspend@forcewake:
    - shard-snb:          NOTRUN -> [DMESG-WARN][53] ([i915#8841]) +1 similar issue
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb6/igt@i915_suspend@forcewake.html

  * igt@kms_addfb_basic@invalid-smem-bo-on-discrete:
    - shard-rkl:          NOTRUN -> [SKIP][54] ([i915#3826])
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_addfb_basic@invalid-smem-bo-on-discrete.html

  * igt@kms_atomic_transition@plane-all-modeset-transition-internal-panels:
    - shard-glk:          NOTRUN -> [SKIP][55] ([fdo#109271] / [i915#1769])
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk2/igt@kms_atomic_transition@plane-all-modeset-transition-internal-panels.html

  * igt@kms_big_fb@4-tiled-64bpp-rotate-180:
    - shard-mtlp:         [PASS][56] -> [FAIL][57] ([i915#5138])
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-7/igt@kms_big_fb@4-tiled-64bpp-rotate-180.html
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-5/igt@kms_big_fb@4-tiled-64bpp-rotate-180.html

  * igt@kms_big_fb@4-tiled-64bpp-rotate-270:
    - shard-dg2:          NOTRUN -> [SKIP][58] ([fdo#111614]) +1 similar issue
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_big_fb@4-tiled-64bpp-rotate-270.html

  * igt@kms_big_fb@4-tiled-8bpp-rotate-180:
    - shard-rkl:          NOTRUN -> [SKIP][59] ([i915#5286])
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_big_fb@4-tiled-8bpp-rotate-180.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-async-flip:
    - shard-mtlp:         [PASS][60] -> [FAIL][61] ([i915#3743])
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-7/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-async-flip.html
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-8/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-async-flip.html

  * igt@kms_big_fb@yf-tiled-addfb-size-overflow:
    - shard-dg2:          NOTRUN -> [SKIP][62] ([i915#5190]) +5 similar issues
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_big_fb@yf-tiled-addfb-size-overflow.html

  * igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0-hflip-async-flip:
    - shard-dg2:          NOTRUN -> [SKIP][63] ([i915#4538] / [i915#5190])
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0-hflip-async-flip.html
    - shard-rkl:          NOTRUN -> [SKIP][64] ([fdo#110723])
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0-hflip-async-flip.html

  * igt@kms_ccs@pipe-a-bad-pixel-format-4_tiled_mtl_mc_ccs:
    - shard-dg2:          NOTRUN -> [SKIP][65] ([i915#5354]) +17 similar issues
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_ccs@pipe-a-bad-pixel-format-4_tiled_mtl_mc_ccs.html
    - shard-rkl:          NOTRUN -> [SKIP][66] ([i915#5354] / [i915#6095]) +2 similar issues
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_ccs@pipe-a-bad-pixel-format-4_tiled_mtl_mc_ccs.html

  * igt@kms_ccs@pipe-b-crc-primary-basic-y_tiled_gen12_mc_ccs:
    - shard-glk:          NOTRUN -> [SKIP][67] ([fdo#109271] / [i915#3886])
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk2/igt@kms_ccs@pipe-b-crc-primary-basic-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-b-crc-primary-rotation-180-yf_tiled_ccs:
    - shard-rkl:          NOTRUN -> [SKIP][68] ([i915#3734] / [i915#5354] / [i915#6095]) +1 similar issue
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_ccs@pipe-b-crc-primary-rotation-180-yf_tiled_ccs.html

  * igt@kms_ccs@pipe-c-crc-primary-rotation-180-y_tiled_gen12_mc_ccs:
    - shard-dg2:          NOTRUN -> [SKIP][69] ([i915#3689] / [i915#3886] / [i915#5354]) +4 similar issues
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_ccs@pipe-c-crc-primary-rotation-180-y_tiled_gen12_mc_ccs.html

  * igt@kms_ccs@pipe-c-random-ccs-data-4_tiled_mtl_rc_ccs:
    - shard-rkl:          NOTRUN -> [SKIP][70] ([i915#5354]) +4 similar issues
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_ccs@pipe-c-random-ccs-data-4_tiled_mtl_rc_ccs.html

  * igt@kms_ccs@pipe-d-missing-ccs-buffer-y_tiled_gen12_mc_ccs:
    - shard-dg2:          NOTRUN -> [SKIP][71] ([i915#3689] / [i915#5354]) +9 similar issues
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_ccs@pipe-d-missing-ccs-buffer-y_tiled_gen12_mc_ccs.html

  * igt@kms_cdclk@plane-scaling@pipe-c-hdmi-a-3:
    - shard-dg2:          NOTRUN -> [SKIP][72] ([i915#4087]) +3 similar issues
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_cdclk@plane-scaling@pipe-c-hdmi-a-3.html

  * igt@kms_chamelium_frames@hdmi-crc-multiple:
    - shard-dg2:          NOTRUN -> [SKIP][73] ([i915#7828]) +3 similar issues
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_chamelium_frames@hdmi-crc-multiple.html
    - shard-rkl:          NOTRUN -> [SKIP][74] ([i915#7828]) +1 similar issue
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_chamelium_frames@hdmi-crc-multiple.html

  * igt@kms_content_protection@atomic-dpms:
    - shard-dg2:          NOTRUN -> [SKIP][75] ([i915#7118]) +2 similar issues
   [75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-3/igt@kms_content_protection@atomic-dpms.html

  * igt@kms_cursor_crc@cursor-rapid-movement-512x512:
    - shard-dg2:          NOTRUN -> [SKIP][76] ([i915#3359])
   [76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_cursor_crc@cursor-rapid-movement-512x512.html

  * igt@kms_cursor_crc@cursor-suspend@pipe-a-hdmi-a-3:
    - shard-dg2:          [PASS][77] -> [FAIL][78] ([fdo#103375]) +2 similar issues
   [77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-6/igt@kms_cursor_crc@cursor-suspend@pipe-a-hdmi-a-3.html
   [78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-5/igt@kms_cursor_crc@cursor-suspend@pipe-a-hdmi-a-3.html

  * igt@kms_cursor_legacy@cursora-vs-flipb-atomic:
    - shard-dg2:          NOTRUN -> [SKIP][79] ([fdo#109274] / [i915#5354]) +1 similar issue
   [79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_cursor_legacy@cursora-vs-flipb-atomic.html

  * igt@kms_cursor_legacy@cursora-vs-flipb-atomic-transitions:
    - shard-rkl:          NOTRUN -> [SKIP][80] ([fdo#111825])
   [80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_cursor_legacy@cursora-vs-flipb-atomic-transitions.html

  * igt@kms_cursor_legacy@cursorb-vs-flipb-toggle:
    - shard-snb:          NOTRUN -> [SKIP][81] ([fdo#109271] / [fdo#111767]) +2 similar issues
   [81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb5/igt@kms_cursor_legacy@cursorb-vs-flipb-toggle.html

  * igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
    - shard-apl:          [PASS][82] -> [FAIL][83] ([i915#2346])
   [82]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-apl3/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
   [83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-apl4/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
    - shard-glk:          NOTRUN -> [FAIL][84] ([i915#2346])
   [84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk2/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

  * igt@kms_dither@fb-8bpc-vs-panel-8bpc:
    - shard-dg2:          NOTRUN -> [SKIP][85] ([i915#3555]) +1 similar issue
   [85]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-1/igt@kms_dither@fb-8bpc-vs-panel-8bpc.html

  * igt@kms_dsc@dsc-with-bpc-formats:
    - shard-dg2:          NOTRUN -> [SKIP][86] ([i915#3555] / [i915#3840])
   [86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_dsc@dsc-with-bpc-formats.html

  * igt@kms_flip@2x-flip-vs-wf_vblank:
    - shard-dg2:          NOTRUN -> [SKIP][87] ([fdo#109274])
   [87]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_flip@2x-flip-vs-wf_vblank.html

  * igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a1:
    - shard-glk:          [PASS][88] -> [FAIL][89] ([i915#79])
   [88]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-glk5/igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a1.html
   [89]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk1/igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a1.html

  * igt@kms_flip_scaled_crc@flip-64bpp-yftile-to-32bpp-yftile-upscaling@pipe-a-valid-mode:
    - shard-rkl:          NOTRUN -> [SKIP][90] ([i915#2672])
   [90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_flip_scaled_crc@flip-64bpp-yftile-to-32bpp-yftile-upscaling@pipe-a-valid-mode.html
    - shard-dg2:          NOTRUN -> [SKIP][91] ([i915#2672])
   [91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_flip_scaled_crc@flip-64bpp-yftile-to-32bpp-yftile-upscaling@pipe-a-valid-mode.html

  * igt@kms_force_connector_basic@prune-stale-modes:
    - shard-dg2:          NOTRUN -> [SKIP][92] ([i915#5274])
   [92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_force_connector_basic@prune-stale-modes.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt:
    - shard-dg2:          NOTRUN -> [SKIP][93] ([i915#8708]) +7 similar issues
   [93]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-indfb-draw-render:
    - shard-snb:          [PASS][94] -> [SKIP][95] ([fdo#109271])
   [94]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-snb5/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-indfb-draw-render.html
   [95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-indfb-draw-render.html

  * igt@kms_frontbuffer_tracking@fbc-indfb-scaledprimary:
    - shard-dg2:          NOTRUN -> [FAIL][96] ([i915#6880])
   [96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_frontbuffer_tracking@fbc-indfb-scaledprimary.html

  * igt@kms_frontbuffer_tracking@fbc-suspend:
    - shard-dg2:          NOTRUN -> [FAIL][97] ([fdo#103375]) +1 similar issue
   [97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_frontbuffer_tracking@fbc-suspend.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-move:
    - shard-glk:          NOTRUN -> [SKIP][98] ([fdo#109271]) +56 similar issues
   [98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-move.html

  * igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-cpu:
    - shard-dg2:          NOTRUN -> [SKIP][99] ([i915#3458]) +7 similar issues
   [99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_frontbuffer_tracking@fbcpsr-rgb101010-draw-mmap-cpu.html

  * igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-pwrite:
    - shard-rkl:          NOTRUN -> [SKIP][100] ([i915#3023]) +5 similar issues
   [100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-pwrite.html

  * igt@kms_frontbuffer_tracking@psr-2p-primscrn-spr-indfb-move:
    - shard-rkl:          NOTRUN -> [SKIP][101] ([fdo#111825] / [i915#1825]) +6 similar issues
   [101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_frontbuffer_tracking@psr-2p-primscrn-spr-indfb-move.html

  * igt@kms_hdr@static-swap:
    - shard-dg2:          NOTRUN -> [SKIP][102] ([i915#3555] / [i915#8228])
   [102]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-2/igt@kms_hdr@static-swap.html

  * igt@kms_plane_scaling@plane-downscale-with-modifiers-factor-0-25@pipe-b-dp-2:
    - shard-dg2:          NOTRUN -> [SKIP][103] ([i915#5176]) +3 similar issues
   [103]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-12/igt@kms_plane_scaling@plane-downscale-with-modifiers-factor-0-25@pipe-b-dp-2.html

  * igt@kms_plane_scaling@plane-downscale-with-rotation-factor-0-5@pipe-a-hdmi-a-1:
    - shard-rkl:          NOTRUN -> [SKIP][104] ([i915#5176]) +3 similar issues
   [104]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-7/igt@kms_plane_scaling@plane-downscale-with-rotation-factor-0-5@pipe-a-hdmi-a-1.html

  * igt@kms_plane_scaling@planes-downscale-factor-0-25@pipe-d-hdmi-a-3:
    - shard-dg2:          NOTRUN -> [SKIP][105] ([i915#5235]) +7 similar issues
   [105]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-8/igt@kms_plane_scaling@planes-downscale-factor-0-25@pipe-d-hdmi-a-3.html

  * igt@kms_plane_scaling@planes-upscale-20x20-downscale-factor-0-25@pipe-b-hdmi-a-1:
    - shard-rkl:          NOTRUN -> [SKIP][106] ([i915#5235]) +3 similar issues
   [106]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-7/igt@kms_plane_scaling@planes-upscale-20x20-downscale-factor-0-25@pipe-b-hdmi-a-1.html

  * igt@kms_psr2_sf@primary-plane-update-sf-dmg-area-big-fb:
    - shard-dg2:          NOTRUN -> [SKIP][107] ([i915#658])
   [107]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_psr2_sf@primary-plane-update-sf-dmg-area-big-fb.html
    - shard-rkl:          NOTRUN -> [SKIP][108] ([i915#658])
   [108]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_psr2_sf@primary-plane-update-sf-dmg-area-big-fb.html

  * igt@kms_psr@psr2_sprite_mmap_gtt:
    - shard-dg2:          NOTRUN -> [SKIP][109] ([i915#1072]) +2 similar issues
   [109]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_psr@psr2_sprite_mmap_gtt.html
    - shard-rkl:          NOTRUN -> [SKIP][110] ([i915#1072])
   [110]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_psr@psr2_sprite_mmap_gtt.html

  * igt@kms_rotation_crc@primary-rotation-90:
    - shard-dg2:          NOTRUN -> [SKIP][111] ([i915#4235])
   [111]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@kms_rotation_crc@primary-rotation-90.html

  * igt@kms_vblank@pipe-c-ts-continuation-idle-hang:
    - shard-rkl:          NOTRUN -> [SKIP][112] ([i915#4070] / [i915#6768])
   [112]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_vblank@pipe-c-ts-continuation-idle-hang.html

  * igt@kms_vblank@pipe-d-query-forked-busy-hang:
    - shard-rkl:          NOTRUN -> [SKIP][113] ([i915#4070] / [i915#533] / [i915#6768]) +1 similar issue
   [113]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_vblank@pipe-d-query-forked-busy-hang.html

  * igt@prime_mmap@test_aperture_limit@test_aperture_limit-smem:
    - shard-dg2:          NOTRUN -> [INCOMPLETE][114] ([i915#5493])
   [114]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@prime_mmap@test_aperture_limit@test_aperture_limit-smem.html

  * igt@prime_vgem@fence-flip-hang:
    - shard-dg2:          NOTRUN -> [SKIP][115] ([i915#3708])
   [115]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-6/igt@prime_vgem@fence-flip-hang.html

  * igt@v3d/v3d_job_submission@array-job-submission:
    - shard-dg2:          NOTRUN -> [SKIP][116] ([i915#2575]) +4 similar issues
   [116]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@v3d/v3d_job_submission@array-job-submission.html
    - shard-rkl:          NOTRUN -> [SKIP][117] ([fdo#109315]) +1 similar issue
   [117]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@v3d/v3d_job_submission@array-job-submission.html

  * igt@vc4/vc4_tiling@get-bad-modifier:
    - shard-dg2:          NOTRUN -> [SKIP][118] ([i915#7711]) +3 similar issues
   [118]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@vc4/vc4_tiling@get-bad-modifier.html
    - shard-rkl:          NOTRUN -> [SKIP][119] ([i915#7711]) +2 similar issues
   [119]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@vc4/vc4_tiling@get-bad-modifier.html

  
#### Possible fixes ####

  * igt@gem_eio@kms:
    - shard-dg2:          [INCOMPLETE][120] ([i915#7892]) -> [PASS][121]
   [120]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-8/igt@gem_eio@kms.html
   [121]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@gem_eio@kms.html

  * igt@gem_exec_fair@basic-none-share@rcs0:
    - shard-tglu:         [FAIL][122] ([i915#2842]) -> [PASS][123]
   [122]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-tglu-8/igt@gem_exec_fair@basic-none-share@rcs0.html
   [123]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-tglu-2/igt@gem_exec_fair@basic-none-share@rcs0.html

  * igt@gem_exec_fair@basic-none@vcs0:
    - shard-rkl:          [FAIL][124] ([i915#2842]) -> [PASS][125]
   [124]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-7/igt@gem_exec_fair@basic-none@vcs0.html
   [125]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-4/igt@gem_exec_fair@basic-none@vcs0.html

  * igt@gem_exec_suspend@basic-s3@smem:
    - shard-dg2:          [FAIL][126] ([fdo#103375]) -> [PASS][127]
   [126]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-5/igt@gem_exec_suspend@basic-s3@smem.html
   [127]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-2/igt@gem_exec_suspend@basic-s3@smem.html

  * igt@gem_lmem_swapping@smem-oom@lmem0:
    - shard-dg2:          [TIMEOUT][128] ([i915#5493]) -> [PASS][129]
   [128]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-1/igt@gem_lmem_swapping@smem-oom@lmem0.html
   [129]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-1/igt@gem_lmem_swapping@smem-oom@lmem0.html
    - {shard-dg1}:        [TIMEOUT][130] ([i915#5493]) -> [PASS][131]
   [130]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg1-18/igt@gem_lmem_swapping@smem-oom@lmem0.html
   [131]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg1-16/igt@gem_lmem_swapping@smem-oom@lmem0.html

  * igt@i915_module_load@reload-with-fault-injection:
    - shard-snb:          [INCOMPLETE][132] ([i915#8294]) -> [PASS][133]
   [132]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-snb6/igt@i915_module_load@reload-with-fault-injection.html
   [133]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb1/igt@i915_module_load@reload-with-fault-injection.html

  * igt@i915_pm_rc6_residency@rc6-idle@vecs0:
    - {shard-dg1}:        [FAIL][134] ([i915#3591]) -> [PASS][135]
   [134]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg1-18/igt@i915_pm_rc6_residency@rc6-idle@vecs0.html
   [135]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg1-17/igt@i915_pm_rc6_residency@rc6-idle@vecs0.html

  * igt@i915_pm_rpm@cursor-dpms:
    - shard-tglu:         [FAIL][136] ([i915#7940]) -> [PASS][137]
   [136]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-tglu-2/igt@i915_pm_rpm@cursor-dpms.html
   [137]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-tglu-4/igt@i915_pm_rpm@cursor-dpms.html

  * igt@i915_pm_rpm@dpms-mode-unset-non-lpsp:
    - shard-rkl:          [SKIP][138] ([i915#1397]) -> [PASS][139] +1 similar issue
   [138]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-7/igt@i915_pm_rpm@dpms-mode-unset-non-lpsp.html
   [139]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-4/igt@i915_pm_rpm@dpms-mode-unset-non-lpsp.html

  * igt@i915_pm_rpm@gem-execbuf-stress@lmem0:
    - {shard-dg1}:        [FAIL][140] ([i915#7940]) -> [PASS][141] +1 similar issue
   [140]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg1-18/igt@i915_pm_rpm@gem-execbuf-stress@lmem0.html
   [141]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg1-18/igt@i915_pm_rpm@gem-execbuf-stress@lmem0.html

  * igt@i915_pm_rpm@modeset-non-lpsp:
    - shard-dg2:          [SKIP][142] ([i915#1397]) -> [PASS][143] +1 similar issue
   [142]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-12/igt@i915_pm_rpm@modeset-non-lpsp.html
   [143]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-2/igt@i915_pm_rpm@modeset-non-lpsp.html
    - {shard-dg1}:        [SKIP][144] ([i915#1397]) -> [PASS][145]
   [144]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg1-19/igt@i915_pm_rpm@modeset-non-lpsp.html
   [145]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg1-16/igt@i915_pm_rpm@modeset-non-lpsp.html

  * igt@i915_pm_rpm@system-suspend-devices:
    - shard-mtlp:         [FAIL][146] ([i915#6121] / [i915#7052]) -> [PASS][147]
   [146]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-3/igt@i915_pm_rpm@system-suspend-devices.html
   [147]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-8/igt@i915_pm_rpm@system-suspend-devices.html

  * igt@i915_selftest@live@gt_heartbeat:
    - shard-glk:          [DMESG-FAIL][148] ([i915#5334]) -> [PASS][149]
   [148]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-glk5/igt@i915_selftest@live@gt_heartbeat.html
   [149]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk1/igt@i915_selftest@live@gt_heartbeat.html

  * igt@i915_selftest@live@requests:
    - shard-mtlp:         [DMESG-FAIL][150] ([i915#8497]) -> [PASS][151]
   [150]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-2/igt@i915_selftest@live@requests.html
   [151]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-7/igt@i915_selftest@live@requests.html

  * igt@i915_selftest@live@slpc:
    - shard-mtlp:         [DMESG-WARN][152] ([i915#6367]) -> [PASS][153]
   [152]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-2/igt@i915_selftest@live@slpc.html
   [153]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-7/igt@i915_selftest@live@slpc.html

  * igt@i915_suspend@basic-s3-without-i915:
    - shard-rkl:          [FAIL][154] ([fdo#103375]) -> [PASS][155]
   [154]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-6/igt@i915_suspend@basic-s3-without-i915.html
   [155]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-2/igt@i915_suspend@basic-s3-without-i915.html

  * igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions:
    - shard-glk:          [FAIL][156] ([i915#2346]) -> [PASS][157]
   [156]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-glk1/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions.html
   [157]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk8/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions.html

  * igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2:
    - shard-glk:          [FAIL][158] ([i915#79]) -> [PASS][159]
   [158]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-glk4/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2.html
   [159]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-glk6/igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2.html

  * igt@kms_flip@flip-vs-suspend@b-edp1:
    - shard-mtlp:         [FAIL][160] ([fdo#103375]) -> [PASS][161] +4 similar issues
   [160]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-3/igt@kms_flip@flip-vs-suspend@b-edp1.html
   [161]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-8/igt@kms_flip@flip-vs-suspend@b-edp1.html

  * igt@perf@enable-disable@0-rcs0:
    - shard-dg2:          [FAIL][162] ([i915#8724]) -> [PASS][163]
   [162]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-11/igt@perf@enable-disable@0-rcs0.html
   [163]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-1/igt@perf@enable-disable@0-rcs0.html

  * igt@perf@gen12-group-concurrent-oa-buffer-read:
    - shard-mtlp:         [FAIL][164] ([i915#1542]) -> [PASS][165]
   [164]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-4/igt@perf@gen12-group-concurrent-oa-buffer-read.html
   [165]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-2/igt@perf@gen12-group-concurrent-oa-buffer-read.html

  * igt@perf_pmu@most-busy-idle-check-all@bcs0:
    - shard-mtlp:         [FAIL][166] ([i915#5234]) -> [PASS][167] +1 similar issue
   [166]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-5/igt@perf_pmu@most-busy-idle-check-all@bcs0.html
   [167]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-4/igt@perf_pmu@most-busy-idle-check-all@bcs0.html

  
#### Warnings ####

  * igt@kms_content_protection@type1:
    - shard-dg2:          [SKIP][168] ([i915#7118]) -> [SKIP][169] ([i915#7118] / [i915#7162]) +1 similar issue
   [168]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-dg2-5/igt@kms_content_protection@type1.html
   [169]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-dg2-11/igt@kms_content_protection@type1.html

  * igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
    - shard-mtlp:         [FAIL][170] ([i915#2346]) -> [DMESG-FAIL][171] ([i915#2017] / [i915#5954])
   [170]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-8/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
   [171]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-3/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

  * igt@kms_force_connector_basic@force-load-detect:
    - shard-rkl:          [SKIP][172] ([fdo#109285] / [i915#4098]) -> [SKIP][173] ([fdo#109285])
   [172]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-rkl-2/igt@kms_force_connector_basic@force-load-detect.html
   [173]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-rkl-6/igt@kms_force_connector_basic@force-load-detect.html

  * igt@kms_vblank@pipe-b-ts-continuation-dpms-suspend:
    - shard-snb:          [DMESG-WARN][174] ([i915#8841]) -> [DMESG-FAIL][175] ([fdo#103375])
   [174]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-snb1/igt@kms_vblank@pipe-b-ts-continuation-dpms-suspend.html
   [175]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-snb7/igt@kms_vblank@pipe-b-ts-continuation-dpms-suspend.html

  * igt@sysfs_timeslice_duration@timeout@vecs0:
    - shard-mtlp:         [TIMEOUT][176] ([i915#6950]) -> [ABORT][177] ([i915#8521])
   [176]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13417/shard-mtlp-4/igt@sysfs_timeslice_duration@timeout@vecs0.html
   [177]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/shard-mtlp-8/igt@sysfs_timeslice_duration@timeout@vecs0.html

  

### Piglit changes ###

#### Issues hit ####

  * igt@i915_pm_rpm@basic-rte:
    - pig-kbl-iris:       NOTRUN -> [FAIL][178] ([i915#5603])
   [178]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/pig-kbl-iris/igt@i915_pm_rpm@basic-rte.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
  [fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
  [fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
  [fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
  [fdo#110542]: https://bugs.freedesktop.org/show_bug.cgi?id=110542
  [fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
  [fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
  [fdo#111767]: https://bugs.freedesktop.org/show_bug.cgi?id=111767
  [fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
  [fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
  [i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
  [i915#1099]: https://gitlab.freedesktop.org/drm/intel/issues/1099
  [i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
  [i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
  [i915#1769]: https://gitlab.freedesktop.org/drm/intel/issues/1769
  [i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
  [i915#2017]: https://gitlab.freedesktop.org/drm/intel/issues/2017
  [i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
  [i915#2434]: https://gitlab.freedesktop.org/drm/intel/issues/2434
  [i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
  [i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
  [i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
  [i915#2724]: https://gitlab.freedesktop.org/drm/intel/issues/2724
  [i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
  [i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
  [i915#3023]: https://gitlab.freedesktop.org/drm/intel/issues/3023
  [i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
  [i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
  [i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
  [i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
  [i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
  [i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
  [i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
  [i915#3591]: https://gitlab.freedesktop.org/drm/intel/issues/3591
  [i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
  [i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
  [i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
  [i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
  [i915#3743]: https://gitlab.freedesktop.org/drm/intel/issues/3743
  [i915#3826]: https://gitlab.freedesktop.org/drm/intel/issues/3826
  [i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
  [i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
  [i915#404]: https://gitlab.freedesktop.org/drm/intel/issues/404
  [i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
  [i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
  [i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
  [i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
  [i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
  [i915#4087]: https://gitlab.freedesktop.org/drm/intel/issues/4087
  [i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
  [i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
  [i915#4235]: https://gitlab.freedesktop.org/drm/intel/issues/4235
  [i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
  [i915#4475]: https://gitlab.freedesktop.org/drm/intel/issues/4475
  [i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
  [i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
  [i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
  [i915#5138]: https://gitlab.freedesktop.org/drm/intel/issues/5138
  [i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
  [i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
  [i915#5234]: https://gitlab.freedesktop.org/drm/intel/issues/5234
  [i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
  [i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
  [i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
  [i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
  [i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
  [i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
  [i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
  [i915#5493]: https://gitlab.freedesktop.org/drm/intel/issues/5493
  [i915#5603]: https://gitlab.freedesktop.org/drm/intel/issues/5603
  [i915#5954]: https://gitlab.freedesktop.org/drm/intel/issues/5954
  [i915#6032]: https://gitlab.freedesktop.org/drm/intel/issues/6032
  [i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
  [i915#6121]: https://gitlab.freedesktop.org/drm/intel/issues/6121
  [i915#6188]: https://gitlab.freedesktop.org/drm/intel/issues/6188
  [i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
  [i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
  [i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
  [i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
  [i915#6880]: https://gitlab.freedesktop.org/drm/intel/issues/6880
  [i915#6950]: https://gitlab.freedesktop.org/drm/intel/issues/6950
  [i915#7052]: https://gitlab.freedesktop.org/drm/intel/issues/7052
  [i915#7061]: https://gitlab.freedesktop.org/drm/intel/issues/7061
  [i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
  [i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
  [i915#7162]: https://gitlab.freedesktop.org/drm/intel/issues/7162
  [i915#7697]: https://gitlab.freedesktop.org/drm/intel/issues/7697
  [i915#7707]: https://gitlab.freedesktop.org/drm/intel/issues/7707
  [i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
  [i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
  [i915#7892]: https://gitlab.freedesktop.org/drm/intel/issues/7892
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#7940]: https://gitlab.freedesktop.org/drm/intel/issues/7940
  [i915#7975]: https://gitlab.freedesktop.org/drm/intel/issues/7975
  [i915#8131]: https://gitlab.freedesktop.org/drm/intel/issues/8131
  [i915#8213]: https://gitlab.freedesktop.org/drm/intel/issues/8213
  [i915#8228]: https://gitlab.freedesktop.org/drm/intel/issues/8228
  [i915#8247]: https://gitlab.freedesktop.org/drm/intel/issues/8247
  [i915#8294]: https://gitlab.freedesktop.org/drm/intel/issues/8294
  [i915#8398]: https://gitlab.freedesktop.org/drm/intel/issues/8398
  [i915#8411]: https://gitlab.freedesktop.org/drm/intel/issues/8411
  [i915#8414]: https://gitlab.freedesktop.org/drm/intel/issues/8414
  [i915#8497]: https://gitlab.freedesktop.org/drm/intel/issues/8497
  [i915#8502]: https://gitlab.freedesktop.org/drm/intel/issues/8502
  [i915#8504]: https://gitlab.freedesktop.org/drm/intel/issues/8504
  [i915#8521]: https://gitlab.freedesktop.org/drm/intel/issues/8521
  [i915#8708]: https://gitlab.freedesktop.org/drm/intel/issues/8708
  [i915#8709]: https://gitlab.freedesktop.org/drm/intel/issues/8709
  [i915#8724]: https://gitlab.freedesktop.org/drm/intel/issues/8724
  [i915#8841]: https://gitlab.freedesktop.org/drm/intel/issues/8841


Build changes
-------------

  * Linux: CI_DRM_13417 -> Patchwork_108206v3

  CI-20190529: 20190529
  CI_DRM_13417: 58ea4f6d151dc9e4f9822e5073d926a11d5af80c @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7400: 86fa0e885f8d020eeb046f27fae5729d5962ebd7 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_108206v3: 58ea4f6d151dc9e4f9822e5073d926a11d5af80c @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_108206v3/index.html

[-- Attachment #2: Type: text/html, Size: 55673 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-07-24 21:14   ` Michał Winiarski
  (?)
@ 2023-07-26 18:15     ` Simon Ser
  -1 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-07-26 18:15 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: dri-devel, linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Matthew Wilcox, Oded Gabbay, Christian König, James Zhu,
	Pekka Paalanen, Emil Velikov

On Monday, July 24th, 2023 at 23:14, Michał Winiarski <michal.winiarski@intel.com> wrote:

> Having a limit of 64 DRM devices is not good enough for modern world
> where we have multi-GPU servers, SR-IOV virtual functions and virtual
> devices used for testing.
> Let's utilize full minor range for DRM devices.
> To avoid regressing the existing userspace, we're still maintaining the
> numbering scheme where 0-63 is used for primary, 64-127 is reserved
> (formerly for control) and 128-191 is used for render.
> For minors >= 192, we're allocating minors dynamically on a first-come,
> first-served basis.

In general the approach looks good to me. Old libdrm will see the new
nodes as nodes with an unknown type when it tries to infer the nod type
from the minor, which is as good as it gets.

We do need patches to stop trying to infer the node type from the minor
in libdrm, though. Emil has suggested using sysfs, which we already do
in a few places in libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-26 18:15     ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-07-26 18:15 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Christian König, Maxime Ripard, James Zhu, Oded Gabbay

On Monday, July 24th, 2023 at 23:14, Michał Winiarski <michal.winiarski@intel.com> wrote:

> Having a limit of 64 DRM devices is not good enough for modern world
> where we have multi-GPU servers, SR-IOV virtual functions and virtual
> devices used for testing.
> Let's utilize full minor range for DRM devices.
> To avoid regressing the existing userspace, we're still maintaining the
> numbering scheme where 0-63 is used for primary, 64-127 is reserved
> (formerly for control) and 128-191 is used for render.
> For minors >= 192, we're allocating minors dynamically on a first-come,
> first-served basis.

In general the approach looks good to me. Old libdrm will see the new
nodes as nodes with an unknown type when it tries to infer the nod type
from the minor, which is as good as it gets.

We do need patches to stop trying to infer the node type from the minor
in libdrm, though. Emil has suggested using sysfs, which we already do
in a few places in libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-26 18:15     ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-07-26 18:15 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Christian König,
	Maxime Ripard, Daniel Vetter, James Zhu, Oded Gabbay

On Monday, July 24th, 2023 at 23:14, Michał Winiarski <michal.winiarski@intel.com> wrote:

> Having a limit of 64 DRM devices is not good enough for modern world
> where we have multi-GPU servers, SR-IOV virtual functions and virtual
> devices used for testing.
> Let's utilize full minor range for DRM devices.
> To avoid regressing the existing userspace, we're still maintaining the
> numbering scheme where 0-63 is used for primary, 64-127 is reserved
> (formerly for control) and 128-191 is used for render.
> For minors >= 192, we're allocating minors dynamically on a first-come,
> first-served basis.

In general the approach looks good to me. Old libdrm will see the new
nodes as nodes with an unknown type when it tries to infer the nod type
from the minor, which is as good as it gets.

We do need patches to stop trying to infer the node type from the minor
in libdrm, though. Emil has suggested using sysfs, which we already do
in a few places in libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-07-26 18:15     ` Simon Ser
  (?)
@ 2023-07-27 12:01       ` Christian König
  -1 siblings, 0 replies; 64+ messages in thread
From: Christian König @ 2023-07-27 12:01 UTC (permalink / raw)
  To: Simon Ser, Michał Winiarski
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Maxime Ripard, Daniel Vetter,
	James Zhu, Oded Gabbay

Am 26.07.23 um 20:15 schrieb Simon Ser:
> On Monday, July 24th, 2023 at 23:14, Michał Winiarski <michal.winiarski@intel.com> wrote:
>
>> Having a limit of 64 DRM devices is not good enough for modern world
>> where we have multi-GPU servers, SR-IOV virtual functions and virtual
>> devices used for testing.
>> Let's utilize full minor range for DRM devices.
>> To avoid regressing the existing userspace, we're still maintaining the
>> numbering scheme where 0-63 is used for primary, 64-127 is reserved
>> (formerly for control) and 128-191 is used for render.
>> For minors >= 192, we're allocating minors dynamically on a first-come,
>> first-served basis.
> In general the approach looks good to me. Old libdrm will see the new
> nodes as nodes with an unknown type when it tries to infer the nod type
> from the minor, which is as good as it gets.

Yeah, agree. I wouldn't upstream patch #4, but apart from that it looks 
like it shouldn't break anything which wasn't broken before.

> We do need patches to stop trying to infer the node type from the minor
> in libdrm, though. Emil has suggested using sysfs, which we already do
> in a few places in libdrm.

That sounds like a really good idea to me as well.

But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps 
should use drmGetDevices2() like Emil suggested?

Regards,
Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-27 12:01       ` Christian König
  0 siblings, 0 replies; 64+ messages in thread
From: Christian König @ 2023-07-27 12:01 UTC (permalink / raw)
  To: Simon Ser, Michał Winiarski
  Cc: dri-devel, linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Matthew Wilcox, Oded Gabbay, James Zhu, Pekka Paalanen,
	Emil Velikov

Am 26.07.23 um 20:15 schrieb Simon Ser:
> On Monday, July 24th, 2023 at 23:14, Michał Winiarski <michal.winiarski@intel.com> wrote:
>
>> Having a limit of 64 DRM devices is not good enough for modern world
>> where we have multi-GPU servers, SR-IOV virtual functions and virtual
>> devices used for testing.
>> Let's utilize full minor range for DRM devices.
>> To avoid regressing the existing userspace, we're still maintaining the
>> numbering scheme where 0-63 is used for primary, 64-127 is reserved
>> (formerly for control) and 128-191 is used for render.
>> For minors >= 192, we're allocating minors dynamically on a first-come,
>> first-served basis.
> In general the approach looks good to me. Old libdrm will see the new
> nodes as nodes with an unknown type when it tries to infer the nod type
> from the minor, which is as good as it gets.

Yeah, agree. I wouldn't upstream patch #4, but apart from that it looks 
like it shouldn't break anything which wasn't broken before.

> We do need patches to stop trying to infer the node type from the minor
> in libdrm, though. Emil has suggested using sysfs, which we already do
> in a few places in libdrm.

That sounds like a really good idea to me as well.

But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps 
should use drmGetDevices2() like Emil suggested?

Regards,
Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-27 12:01       ` Christian König
  0 siblings, 0 replies; 64+ messages in thread
From: Christian König @ 2023-07-27 12:01 UTC (permalink / raw)
  To: Simon Ser, Michał Winiarski
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	Emil Velikov, intel-gfx, linux-kernel, dri-devel, Maxime Ripard,
	James Zhu, Oded Gabbay

Am 26.07.23 um 20:15 schrieb Simon Ser:
> On Monday, July 24th, 2023 at 23:14, Michał Winiarski <michal.winiarski@intel.com> wrote:
>
>> Having a limit of 64 DRM devices is not good enough for modern world
>> where we have multi-GPU servers, SR-IOV virtual functions and virtual
>> devices used for testing.
>> Let's utilize full minor range for DRM devices.
>> To avoid regressing the existing userspace, we're still maintaining the
>> numbering scheme where 0-63 is used for primary, 64-127 is reserved
>> (formerly for control) and 128-191 is used for render.
>> For minors >= 192, we're allocating minors dynamically on a first-come,
>> first-served basis.
> In general the approach looks good to me. Old libdrm will see the new
> nodes as nodes with an unknown type when it tries to infer the nod type
> from the minor, which is as good as it gets.

Yeah, agree. I wouldn't upstream patch #4, but apart from that it looks 
like it shouldn't break anything which wasn't broken before.

> We do need patches to stop trying to infer the node type from the minor
> in libdrm, though. Emil has suggested using sysfs, which we already do
> in a few places in libdrm.

That sounds like a really good idea to me as well.

But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps 
should use drmGetDevices2() like Emil suggested?

Regards,
Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-07-27 12:01       ` Christian König
  (?)
@ 2023-07-28 14:22         ` Simon Ser
  -1 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-07-28 14:22 UTC (permalink / raw)
  To: Christian König
  Cc: Michał Winiarski, dri-devel, linux-kernel, intel-gfx,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Matthew Wilcox, Oded Gabbay, James Zhu,
	Pekka Paalanen, Emil Velikov

On Thursday, July 27th, 2023 at 14:01, Christian König <christian.koenig@amd.com> wrote:

> > We do need patches to stop trying to infer the node type from the minor
> > in libdrm, though. Emil has suggested using sysfs, which we already do
> > in a few places in libdrm.
> 
> That sounds like a really good idea to me as well.
> 
> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
> should use drmGetDevices2() like Emil suggested?

DRM_MAX_MINOR has been bumped to 64 now.

With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
because there is no "max minor per type" concept anymore: the minor no
longer contains the type.

So I'd suggest leaving it as-is (so that old apps still continue to
work on systems with < 64 devices like they do today) and mark it as
deprecated.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-28 14:22         ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-07-28 14:22 UTC (permalink / raw)
  To: Christian König
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Maxime Ripard, Pekka Paalanen, James Zhu, Oded Gabbay

On Thursday, July 27th, 2023 at 14:01, Christian König <christian.koenig@amd.com> wrote:

> > We do need patches to stop trying to infer the node type from the minor
> > in libdrm, though. Emil has suggested using sysfs, which we already do
> > in a few places in libdrm.
> 
> That sounds like a really good idea to me as well.
> 
> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
> should use drmGetDevices2() like Emil suggested?

DRM_MAX_MINOR has been bumped to 64 now.

With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
because there is no "max minor per type" concept anymore: the minor no
longer contains the type.

So I'd suggest leaving it as-is (so that old apps still continue to
work on systems with < 64 devices like they do today) and mark it as
deprecated.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-07-28 14:22         ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-07-28 14:22 UTC (permalink / raw)
  To: Christian König
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, intel-gfx, linux-kernel, dri-devel, Maxime Ripard,
	Daniel Vetter, Pekka Paalanen, James Zhu, Oded Gabbay

On Thursday, July 27th, 2023 at 14:01, Christian König <christian.koenig@amd.com> wrote:

> > We do need patches to stop trying to infer the node type from the minor
> > in libdrm, though. Emil has suggested using sysfs, which we already do
> > in a few places in libdrm.
> 
> That sounds like a really good idea to me as well.
> 
> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
> should use drmGetDevices2() like Emil suggested?

DRM_MAX_MINOR has been bumped to 64 now.

With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
because there is no "max minor per type" concept anymore: the minor no
longer contains the type.

So I'd suggest leaving it as-is (so that old apps still continue to
work on systems with < 64 devices like they do today) and mark it as
deprecated.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-07-28 14:22         ` Simon Ser
  (?)
@ 2023-08-08 13:55           ` Christian König
  -1 siblings, 0 replies; 64+ messages in thread
From: Christian König @ 2023-08-08 13:55 UTC (permalink / raw)
  To: Simon Ser
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Maxime Ripard, Pekka Paalanen, James Zhu, Oded Gabbay

Am 28.07.23 um 16:22 schrieb Simon Ser:
> On Thursday, July 27th, 2023 at 14:01, Christian König <christian.koenig@amd.com> wrote:
>
>>> We do need patches to stop trying to infer the node type from the minor
>>> in libdrm, though. Emil has suggested using sysfs, which we already do
>>> in a few places in libdrm.
>> That sounds like a really good idea to me as well.
>>
>> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
>> should use drmGetDevices2() like Emil suggested?
> DRM_MAX_MINOR has been bumped to 64 now.
>
> With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
> because there is no "max minor per type" concept anymore: the minor no
> longer contains the type.
>
> So I'd suggest leaving it as-is (so that old apps still continue to
> work on systems with < 64 devices like they do today) and mark it as
> deprecated.

Sounds like a plan to me.

Regards,
Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-08 13:55           ` Christian König
  0 siblings, 0 replies; 64+ messages in thread
From: Christian König @ 2023-08-08 13:55 UTC (permalink / raw)
  To: Simon Ser
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, intel-gfx, linux-kernel, dri-devel, Maxime Ripard,
	Daniel Vetter, Pekka Paalanen, James Zhu, Oded Gabbay

Am 28.07.23 um 16:22 schrieb Simon Ser:
> On Thursday, July 27th, 2023 at 14:01, Christian König <christian.koenig@amd.com> wrote:
>
>>> We do need patches to stop trying to infer the node type from the minor
>>> in libdrm, though. Emil has suggested using sysfs, which we already do
>>> in a few places in libdrm.
>> That sounds like a really good idea to me as well.
>>
>> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
>> should use drmGetDevices2() like Emil suggested?
> DRM_MAX_MINOR has been bumped to 64 now.
>
> With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
> because there is no "max minor per type" concept anymore: the minor no
> longer contains the type.
>
> So I'd suggest leaving it as-is (so that old apps still continue to
> work on systems with < 64 devices like they do today) and mark it as
> deprecated.

Sounds like a plan to me.

Regards,
Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-08 13:55           ` Christian König
  0 siblings, 0 replies; 64+ messages in thread
From: Christian König @ 2023-08-08 13:55 UTC (permalink / raw)
  To: Simon Ser
  Cc: Michał Winiarski, dri-devel, linux-kernel, intel-gfx,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Matthew Wilcox, Oded Gabbay, James Zhu,
	Pekka Paalanen, Emil Velikov

Am 28.07.23 um 16:22 schrieb Simon Ser:
> On Thursday, July 27th, 2023 at 14:01, Christian König <christian.koenig@amd.com> wrote:
>
>>> We do need patches to stop trying to infer the node type from the minor
>>> in libdrm, though. Emil has suggested using sysfs, which we already do
>>> in a few places in libdrm.
>> That sounds like a really good idea to me as well.
>>
>> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
>> should use drmGetDevices2() like Emil suggested?
> DRM_MAX_MINOR has been bumped to 64 now.
>
> With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
> because there is no "max minor per type" concept anymore: the minor no
> longer contains the type.
>
> So I'd suggest leaving it as-is (so that old apps still continue to
> work on systems with < 64 devices like they do today) and mark it as
> deprecated.

Sounds like a plan to me.

Regards,
Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-08-08 13:55           ` [Intel-gfx] " Christian König
  (?)
@ 2023-08-08 15:04             ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-08 15:04 UTC (permalink / raw)
  To: Christian König, Simon Ser
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Maxime Ripard, Pekka Paalanen, James Zhu, Oded Gabbay

I would like if these kernel patches are accepted by everyone, If yes, 
when they can be upstream.

I have a MR for libdrm to support drm nodes type up to 2^MINORBITS  
nodes which can work with these patches,

https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305

Thanks!

James

On 2023-08-08 09:55, Christian König wrote:
> Am 28.07.23 um 16:22 schrieb Simon Ser:
>> On Thursday, July 27th, 2023 at 14:01, Christian König 
>> <christian.koenig@amd.com> wrote:
>>
>>>> We do need patches to stop trying to infer the node type from the 
>>>> minor
>>>> in libdrm, though. Emil has suggested using sysfs, which we already do
>>>> in a few places in libdrm.
>>> That sounds like a really good idea to me as well.
>>>
>>> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
>>> should use drmGetDevices2() like Emil suggested?
>> DRM_MAX_MINOR has been bumped to 64 now.
>>
>> With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
>> because there is no "max minor per type" concept anymore: the minor no
>> longer contains the type.
>>
>> So I'd suggest leaving it as-is (so that old apps still continue to
>> work on systems with < 64 devices like they do today) and mark it as
>> deprecated.
>
> Sounds like a plan to me.
>
> Regards,
> Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-08 15:04             ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-08 15:04 UTC (permalink / raw)
  To: Christian König, Simon Ser
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, intel-gfx, linux-kernel, dri-devel, Maxime Ripard,
	Daniel Vetter, Pekka Paalanen, James Zhu, Oded Gabbay

I would like if these kernel patches are accepted by everyone, If yes, 
when they can be upstream.

I have a MR for libdrm to support drm nodes type up to 2^MINORBITS  
nodes which can work with these patches,

https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305

Thanks!

James

On 2023-08-08 09:55, Christian König wrote:
> Am 28.07.23 um 16:22 schrieb Simon Ser:
>> On Thursday, July 27th, 2023 at 14:01, Christian König 
>> <christian.koenig@amd.com> wrote:
>>
>>>> We do need patches to stop trying to infer the node type from the 
>>>> minor
>>>> in libdrm, though. Emil has suggested using sysfs, which we already do
>>>> in a few places in libdrm.
>>> That sounds like a really good idea to me as well.
>>>
>>> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
>>> should use drmGetDevices2() like Emil suggested?
>> DRM_MAX_MINOR has been bumped to 64 now.
>>
>> With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
>> because there is no "max minor per type" concept anymore: the minor no
>> longer contains the type.
>>
>> So I'd suggest leaving it as-is (so that old apps still continue to
>> work on systems with < 64 devices like they do today) and mark it as
>> deprecated.
>
> Sounds like a plan to me.
>
> Regards,
> Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-08 15:04             ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-08 15:04 UTC (permalink / raw)
  To: Christian König, Simon Ser
  Cc: Michał Winiarski, dri-devel, linux-kernel, intel-gfx,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Matthew Wilcox, Oded Gabbay, James Zhu,
	Pekka Paalanen, Emil Velikov

I would like if these kernel patches are accepted by everyone, If yes, 
when they can be upstream.

I have a MR for libdrm to support drm nodes type up to 2^MINORBITS  
nodes which can work with these patches,

https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305

Thanks!

James

On 2023-08-08 09:55, Christian König wrote:
> Am 28.07.23 um 16:22 schrieb Simon Ser:
>> On Thursday, July 27th, 2023 at 14:01, Christian König 
>> <christian.koenig@amd.com> wrote:
>>
>>>> We do need patches to stop trying to infer the node type from the 
>>>> minor
>>>> in libdrm, though. Emil has suggested using sysfs, which we already do
>>>> in a few places in libdrm.
>>> That sounds like a really good idea to me as well.
>>>
>>> But what do we do with DRM_MAX_MINOR? Change it or keep it and say apps
>>> should use drmGetDevices2() like Emil suggested?
>> DRM_MAX_MINOR has been bumped to 64 now.
>>
>> With the new minor allocation scheme, DRM_MAX_MINOR is meaningless
>> because there is no "max minor per type" concept anymore: the minor no
>> longer contains the type.
>>
>> So I'd suggest leaving it as-is (so that old apps still continue to
>> work on systems with < 64 devices like they do today) and mark it as
>> deprecated.
>
> Sounds like a plan to me.
>
> Regards,
> Christian.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-08-08 15:04             ` [Intel-gfx] " James Zhu
  (?)
@ 2023-08-23 10:53               ` Simon Ser
  -1 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-08-23 10:53 UTC (permalink / raw)
  To: James Zhu
  Cc: Christian König, Michał Winiarski, dri-devel,
	linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Matthew Wilcox, Oded Gabbay, James Zhu, Pekka Paalanen,
	Emil Velikov

On Tuesday, August 8th, 2023 at 17:04, James Zhu <jamesz@amd.com> wrote:

> I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
> nodes which can work with these patches,
> 
> https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305

FWIW, this MR has been merged, so in theory this kernel patch should
work fine with latest libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-23 10:53               ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-08-23 10:53 UTC (permalink / raw)
  To: James Zhu
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Oded Gabbay, Maxime Ripard, Pekka Paalanen, James Zhu,
	Christian König

On Tuesday, August 8th, 2023 at 17:04, James Zhu <jamesz@amd.com> wrote:

> I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
> nodes which can work with these patches,
> 
> https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305

FWIW, this MR has been merged, so in theory this kernel patch should
work fine with latest libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-23 10:53               ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-08-23 10:53 UTC (permalink / raw)
  To: James Zhu
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, intel-gfx, linux-kernel, dri-devel, Oded Gabbay,
	Maxime Ripard, Daniel Vetter, Pekka Paalanen, James Zhu,
	Christian König

On Tuesday, August 8th, 2023 at 17:04, James Zhu <jamesz@amd.com> wrote:

> I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
> nodes which can work with these patches,
> 
> https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305

FWIW, this MR has been merged, so in theory this kernel patch should
work fine with latest libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-08-23 10:53               ` Simon Ser
  (?)
@ 2023-08-23 10:58                 ` Simon Ser
  -1 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-08-23 10:58 UTC (permalink / raw)
  To: James Zhu
  Cc: Christian König, Michał Winiarski, dri-devel,
	linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Matthew Wilcox, Oded Gabbay, James Zhu, Pekka Paalanen,
	Emil Velikov

On Wednesday, August 23rd, 2023 at 12:53, Simon Ser <contact@emersion.fr> wrote:

> On Tuesday, August 8th, 2023 at 17:04, James Zhu jamesz@amd.com wrote:
> 
> > I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
> > nodes which can work with these patches,
> > 
> > https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305
> 
> FWIW, this MR has been merged, so in theory this kernel patch should
> work fine with latest libdrm.

Hm, we might want to adjust MAX_DRM_NODES still. It's set to 256
currently, which should be enough for 128 DRM devices, but not more.
Not bumping this value will make drmGetDevices2() print a warning and
not return all devices on systems with more than 128 DRM devices.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-23 10:58                 ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-08-23 10:58 UTC (permalink / raw)
  To: James Zhu
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Oded Gabbay, Maxime Ripard, Pekka Paalanen, James Zhu,
	Christian König

On Wednesday, August 23rd, 2023 at 12:53, Simon Ser <contact@emersion.fr> wrote:

> On Tuesday, August 8th, 2023 at 17:04, James Zhu jamesz@amd.com wrote:
> 
> > I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
> > nodes which can work with these patches,
> > 
> > https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305
> 
> FWIW, this MR has been merged, so in theory this kernel patch should
> work fine with latest libdrm.

Hm, we might want to adjust MAX_DRM_NODES still. It's set to 256
currently, which should be enough for 128 DRM devices, but not more.
Not bumping this value will make drmGetDevices2() print a warning and
not return all devices on systems with more than 128 DRM devices.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-23 10:58                 ` Simon Ser
  0 siblings, 0 replies; 64+ messages in thread
From: Simon Ser @ 2023-08-23 10:58 UTC (permalink / raw)
  To: James Zhu
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, intel-gfx, linux-kernel, dri-devel, Oded Gabbay,
	Maxime Ripard, Daniel Vetter, Pekka Paalanen, James Zhu,
	Christian König

On Wednesday, August 23rd, 2023 at 12:53, Simon Ser <contact@emersion.fr> wrote:

> On Tuesday, August 8th, 2023 at 17:04, James Zhu jamesz@amd.com wrote:
> 
> > I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
> > nodes which can work with these patches,
> > 
> > https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305
> 
> FWIW, this MR has been merged, so in theory this kernel patch should
> work fine with latest libdrm.

Hm, we might want to adjust MAX_DRM_NODES still. It's set to 256
currently, which should be enough for 128 DRM devices, but not more.
Not bumping this value will make drmGetDevices2() print a warning and
not return all devices on systems with more than 128 DRM devices.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
  2023-08-23 10:53               ` Simon Ser
  (?)
@ 2023-08-23 14:06                 ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-23 14:06 UTC (permalink / raw)
  To: Simon Ser
  Cc: Christian König, Michał Winiarski, dri-devel,
	linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Matthew Wilcox, Oded Gabbay, James Zhu, Pekka Paalanen,
	Emil Velikov

Hi Simon,

Thanks! Yes, this kernel patch should work with latest libdrm.

Best regards!

James Zhu

On 2023-08-23 06:53, Simon Ser wrote:
> On Tuesday, August 8th, 2023 at 17:04, James Zhu <jamesz@amd.com> wrote:
>
>> I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
>> nodes which can work with these patches,
>>
>> https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305
> FWIW, this MR has been merged, so in theory this kernel patch should
> work fine with latest libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-23 14:06                 ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-23 14:06 UTC (permalink / raw)
  To: Simon Ser
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, Emil Velikov, intel-gfx, linux-kernel, dri-devel,
	Oded Gabbay, Maxime Ripard, Pekka Paalanen, James Zhu,
	Christian König

Hi Simon,

Thanks! Yes, this kernel patch should work with latest libdrm.

Best regards!

James Zhu

On 2023-08-23 06:53, Simon Ser wrote:
> On Tuesday, August 8th, 2023 at 17:04, James Zhu <jamesz@amd.com> wrote:
>
>> I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
>> nodes which can work with these patches,
>>
>> https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305
> FWIW, this MR has been merged, so in theory this kernel patch should
> work fine with latest libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS
@ 2023-08-23 14:06                 ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-23 14:06 UTC (permalink / raw)
  To: Simon Ser
  Cc: Matthew Wilcox, Michał Winiarski, Thomas Zimmermann,
	David Airlie, intel-gfx, linux-kernel, dri-devel, Oded Gabbay,
	Maxime Ripard, Daniel Vetter, Pekka Paalanen, James Zhu,
	Christian König

Hi Simon,

Thanks! Yes, this kernel patch should work with latest libdrm.

Best regards!

James Zhu

On 2023-08-23 06:53, Simon Ser wrote:
> On Tuesday, August 8th, 2023 at 17:04, James Zhu <jamesz@amd.com> wrote:
>
>> I have a MR for libdrm to support drm nodes type up to 2^MINORBITS
>> nodes which can work with these patches,
>>
>> https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/305
> FWIW, this MR has been merged, so in theory this kernel patch should
> work fine with latest libdrm.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-07-24 21:14   ` Michał Winiarski
@ 2023-08-25 16:59     ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-25 16:59 UTC (permalink / raw)
  To: Michał Winiarski, dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann, James Zhu,
	Christian König

[-- Attachment #1: Type: text/plain, Size: 6148 bytes --]


On 2023-07-24 17:14, Michał Winiarski wrote:
> IDR is deprecated, and since XArray manages its own state with internal
> locking, it simplifies the locking on DRM side.
> Additionally, don't use the IRQ-safe variant, since operating on drm
> minor is not done in IRQ context.
>
> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> Suggested-by: Matthew Wilcox<willy@infradead.org>
> ---
>   drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
>   1 file changed, 25 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 3eda026ffac6..3faecb01186f 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -34,6 +34,7 @@
>   #include <linux/pseudo_fs.h>
>   #include <linux/slab.h>
>   #include <linux/srcu.h>
> +#include <linux/xarray.h>
>   
>   #include <drm/drm_accel.h>
>   #include <drm/drm_cache.h>
> @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
>   MODULE_DESCRIPTION("DRM shared core routines");
>   MODULE_LICENSE("GPL and additional rights");
>   
> -static DEFINE_SPINLOCK(drm_minor_lock);
> -static struct idr drm_minors_idr;
> +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
>   
>   /*
>    * If the drm core fails to init for whatever reason,
> @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
>   static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>   {
>   	struct drm_minor *minor = data;
> -	unsigned long flags;
>   
>   	WARN_ON(dev != minor->dev);
>   
>   	put_device(minor->kdev);
>   
> -	if (minor->type == DRM_MINOR_ACCEL) {
> +	if (minor->type == DRM_MINOR_ACCEL)
>   		accel_minor_remove(minor->index);
> -	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		idr_remove(&drm_minors_idr, minor->index);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> -	}
> +	else
> +		xa_erase(&drm_minors_xa, minor->index);
>   }
>   
> +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
> +
>   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
> -	int r;
> +	int index, r;
>   
>   	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
>   	if (!minor)
> @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   	minor->type = type;
>   	minor->dev = dev;
>   
> -	idr_preload(GFP_KERNEL);
>   	if (type == DRM_MINOR_ACCEL) {
>   		r = accel_minor_alloc();
> +		index = r;
>   	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		r = idr_alloc(&drm_minors_idr,
> -			NULL,
> -			64 * type,
> -			64 * (type + 1),
> -			GFP_NOWAIT);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
>   	}
> -	idr_preload_end();
>   
>   	if (r < 0)
>   		return r;
>   
> -	minor->index = r;
> +	minor->index = index;
>   
>   	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
>   	if (r)
> @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
> +	void *entry;
>   	int ret;
>   
>   	DRM_DEBUG("\n");
> @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>   	if (minor->type == DRM_MINOR_ACCEL) {
>   		accel_minor_replace(minor, minor->index);
>   	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		idr_replace(&drm_minors_idr, minor, minor->index);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
> +		if (xa_is_err(entry)) {
> +			ret = xa_err(entry);
> +			goto err_debugfs;
> +		}
> +		WARN_ON(entry);
[JZ] would WARN_ON(entry != minor)be better?
>   	}
>   
>   	DRM_DEBUG("new minor registered %d\n", minor->index);
> @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>   static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
>   
>   	minor = *drm_minor_get_slot(dev, type);
>   	if (!minor || !device_is_registered(minor->kdev))
>   		return;
>   
>   	/* replace @minor with NULL so lookups will fail from now on */
> -	if (minor->type == DRM_MINOR_ACCEL) {
> +	if (minor->type == DRM_MINOR_ACCEL)
>   		accel_minor_replace(NULL, minor->index);
> -	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		idr_replace(&drm_minors_idr, NULL, minor->index);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> -	}
> +	else
> +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
>   
>   	device_del(minor->kdev);
>   	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
> @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
>   struct drm_minor *drm_minor_acquire(unsigned int minor_id)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
>   
> -	spin_lock_irqsave(&drm_minor_lock, flags);
> -	minor = idr_find(&drm_minors_idr, minor_id);
> +	xa_lock(&drm_minors_xa);
> +	minor = xa_load(&drm_minors_xa, minor_id);
>   	if (minor)
>   		drm_dev_get(minor->dev);
[JZ] why minor->dev need ca_lock here?
> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> +	xa_unlock(&drm_minors_xa);
>   
>   	if (!minor) {
>   		return ERR_PTR(-ENODEV);
> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>   	unregister_chrdev(DRM_MAJOR, "drm");
>   	debugfs_remove(drm_debugfs_root);
>   	drm_sysfs_destroy();
> -	idr_destroy(&drm_minors_idr);
[JZ] Should we call xa_destroy instead here?
> +	WARN_ON(!xa_empty(&drm_minors_xa));
>   	drm_connector_ida_destroy();
>   }
>   
> @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
>   	int ret;
>   
>   	drm_connector_ida_init();
> -	idr_init(&drm_minors_idr);
>   	drm_memcpy_init_early();
>   
>   	ret = drm_sysfs_init();

[-- Attachment #2: Type: text/html, Size: 7562 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-25 16:59     ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-25 16:59 UTC (permalink / raw)
  To: Michał Winiarski, dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	James Zhu, Christian König

[-- Attachment #1: Type: text/plain, Size: 6148 bytes --]


On 2023-07-24 17:14, Michał Winiarski wrote:
> IDR is deprecated, and since XArray manages its own state with internal
> locking, it simplifies the locking on DRM side.
> Additionally, don't use the IRQ-safe variant, since operating on drm
> minor is not done in IRQ context.
>
> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> Suggested-by: Matthew Wilcox<willy@infradead.org>
> ---
>   drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
>   1 file changed, 25 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 3eda026ffac6..3faecb01186f 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -34,6 +34,7 @@
>   #include <linux/pseudo_fs.h>
>   #include <linux/slab.h>
>   #include <linux/srcu.h>
> +#include <linux/xarray.h>
>   
>   #include <drm/drm_accel.h>
>   #include <drm/drm_cache.h>
> @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
>   MODULE_DESCRIPTION("DRM shared core routines");
>   MODULE_LICENSE("GPL and additional rights");
>   
> -static DEFINE_SPINLOCK(drm_minor_lock);
> -static struct idr drm_minors_idr;
> +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
>   
>   /*
>    * If the drm core fails to init for whatever reason,
> @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
>   static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>   {
>   	struct drm_minor *minor = data;
> -	unsigned long flags;
>   
>   	WARN_ON(dev != minor->dev);
>   
>   	put_device(minor->kdev);
>   
> -	if (minor->type == DRM_MINOR_ACCEL) {
> +	if (minor->type == DRM_MINOR_ACCEL)
>   		accel_minor_remove(minor->index);
> -	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		idr_remove(&drm_minors_idr, minor->index);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> -	}
> +	else
> +		xa_erase(&drm_minors_xa, minor->index);
>   }
>   
> +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
> +
>   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
> -	int r;
> +	int index, r;
>   
>   	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
>   	if (!minor)
> @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   	minor->type = type;
>   	minor->dev = dev;
>   
> -	idr_preload(GFP_KERNEL);
>   	if (type == DRM_MINOR_ACCEL) {
>   		r = accel_minor_alloc();
> +		index = r;
>   	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		r = idr_alloc(&drm_minors_idr,
> -			NULL,
> -			64 * type,
> -			64 * (type + 1),
> -			GFP_NOWAIT);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
>   	}
> -	idr_preload_end();
>   
>   	if (r < 0)
>   		return r;
>   
> -	minor->index = r;
> +	minor->index = index;
>   
>   	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
>   	if (r)
> @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>   static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
> +	void *entry;
>   	int ret;
>   
>   	DRM_DEBUG("\n");
> @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>   	if (minor->type == DRM_MINOR_ACCEL) {
>   		accel_minor_replace(minor, minor->index);
>   	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		idr_replace(&drm_minors_idr, minor, minor->index);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
> +		if (xa_is_err(entry)) {
> +			ret = xa_err(entry);
> +			goto err_debugfs;
> +		}
> +		WARN_ON(entry);
[JZ] would WARN_ON(entry != minor)be better?
>   	}
>   
>   	DRM_DEBUG("new minor registered %d\n", minor->index);
> @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>   static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
>   
>   	minor = *drm_minor_get_slot(dev, type);
>   	if (!minor || !device_is_registered(minor->kdev))
>   		return;
>   
>   	/* replace @minor with NULL so lookups will fail from now on */
> -	if (minor->type == DRM_MINOR_ACCEL) {
> +	if (minor->type == DRM_MINOR_ACCEL)
>   		accel_minor_replace(NULL, minor->index);
> -	} else {
> -		spin_lock_irqsave(&drm_minor_lock, flags);
> -		idr_replace(&drm_minors_idr, NULL, minor->index);
> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> -	}
> +	else
> +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
>   
>   	device_del(minor->kdev);
>   	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
> @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
>   struct drm_minor *drm_minor_acquire(unsigned int minor_id)
>   {
>   	struct drm_minor *minor;
> -	unsigned long flags;
>   
> -	spin_lock_irqsave(&drm_minor_lock, flags);
> -	minor = idr_find(&drm_minors_idr, minor_id);
> +	xa_lock(&drm_minors_xa);
> +	minor = xa_load(&drm_minors_xa, minor_id);
>   	if (minor)
>   		drm_dev_get(minor->dev);
[JZ] why minor->dev need ca_lock here?
> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> +	xa_unlock(&drm_minors_xa);
>   
>   	if (!minor) {
>   		return ERR_PTR(-ENODEV);
> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>   	unregister_chrdev(DRM_MAJOR, "drm");
>   	debugfs_remove(drm_debugfs_root);
>   	drm_sysfs_destroy();
> -	idr_destroy(&drm_minors_idr);
[JZ] Should we call xa_destroy instead here?
> +	WARN_ON(!xa_empty(&drm_minors_xa));
>   	drm_connector_ida_destroy();
>   }
>   
> @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
>   	int ret;
>   
>   	drm_connector_ida_init();
> -	idr_init(&drm_minors_idr);
>   	drm_memcpy_init_early();
>   
>   	ret = drm_sysfs_init();

[-- Attachment #2: Type: text/html, Size: 7562 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-08-25 16:59     ` [Intel-gfx] " James Zhu
  (?)
@ 2023-08-28 21:08       ` Michał Winiarski
  -1 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-08-28 21:08 UTC (permalink / raw)
  To: James Zhu
  Cc: dri-devel, linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Simon Ser,
	Matthew Wilcox, Oded Gabbay, Christian König, James Zhu,
	Pekka Paalanen, Emil Velikov

On Fri, Aug 25, 2023 at 12:59:26PM -0400, James Zhu wrote:
> 
> On 2023-07-24 17:14, Michał Winiarski wrote:
> > IDR is deprecated, and since XArray manages its own state with internal
> > locking, it simplifies the locking on DRM side.
> > Additionally, don't use the IRQ-safe variant, since operating on drm
> > minor is not done in IRQ context.
> > 
> > Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> > Suggested-by: Matthew Wilcox<willy@infradead.org>
> > ---
> >   drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
> >   1 file changed, 25 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 3eda026ffac6..3faecb01186f 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -34,6 +34,7 @@
> >   #include <linux/pseudo_fs.h>
> >   #include <linux/slab.h>
> >   #include <linux/srcu.h>
> > +#include <linux/xarray.h>
> >   #include <drm/drm_accel.h>
> >   #include <drm/drm_cache.h>
> > @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
> >   MODULE_DESCRIPTION("DRM shared core routines");
> >   MODULE_LICENSE("GPL and additional rights");
> > -static DEFINE_SPINLOCK(drm_minor_lock);
> > -static struct idr drm_minors_idr;
> > +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
> >   /*
> >    * If the drm core fails to init for whatever reason,
> > @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
> >   static void drm_minor_alloc_release(struct drm_device *dev, void *data)
> >   {
> >   	struct drm_minor *minor = data;
> > -	unsigned long flags;
> >   	WARN_ON(dev != minor->dev);
> >   	put_device(minor->kdev);
> > -	if (minor->type == DRM_MINOR_ACCEL) {
> > +	if (minor->type == DRM_MINOR_ACCEL)
> >   		accel_minor_remove(minor->index);
> > -	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_remove(&drm_minors_idr, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > -	}
> > +	else
> > +		xa_erase(&drm_minors_xa, minor->index);
> >   }
> > +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
> > +
> >   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > -	int r;
> > +	int index, r;
> >   	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
> >   	if (!minor)
> > @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   	minor->type = type;
> >   	minor->dev = dev;
> > -	idr_preload(GFP_KERNEL);
> >   	if (type == DRM_MINOR_ACCEL) {
> >   		r = accel_minor_alloc();
> > +		index = r;
> >   	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		r = idr_alloc(&drm_minors_idr,
> > -			NULL,
> > -			64 * type,
> > -			64 * (type + 1),
> > -			GFP_NOWAIT);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
> >   	}
> > -	idr_preload_end();
> >   	if (r < 0)
> >   		return r;
> > -	minor->index = r;
> > +	minor->index = index;
> >   	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
> >   	if (r)
> > @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > +	void *entry;
> >   	int ret;
> >   	DRM_DEBUG("\n");
> > @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   	if (minor->type == DRM_MINOR_ACCEL) {
> >   		accel_minor_replace(minor, minor->index);
> >   	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_replace(&drm_minors_idr, minor, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
> > +		if (xa_is_err(entry)) {
> > +			ret = xa_err(entry);
> > +			goto err_debugfs;
> > +		}
> > +		WARN_ON(entry);
> [JZ] would WARN_ON(entry != minor)be better?

We expect NULL here.
The same one that was previously stored here ⌄⌄⌄
r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
in drm_minor_alloc.

> >   	}
> >   	DRM_DEBUG("new minor registered %d\n", minor->index);
> > @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> >   	minor = *drm_minor_get_slot(dev, type);
> >   	if (!minor || !device_is_registered(minor->kdev))
> >   		return;
> >   	/* replace @minor with NULL so lookups will fail from now on */
> > -	if (minor->type == DRM_MINOR_ACCEL) {
> > +	if (minor->type == DRM_MINOR_ACCEL)
> >   		accel_minor_replace(NULL, minor->index);
> > -	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_replace(&drm_minors_idr, NULL, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > -	}
> > +	else
> > +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
> >   	device_del(minor->kdev);
> >   	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
> > @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
> >   struct drm_minor *drm_minor_acquire(unsigned int minor_id)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > -	spin_lock_irqsave(&drm_minor_lock, flags);
> > -	minor = idr_find(&drm_minors_idr, minor_id);
> > +	xa_lock(&drm_minors_xa);
> > +	minor = xa_load(&drm_minors_xa, minor_id);
> >   	if (minor)
> >   		drm_dev_get(minor->dev);
> [JZ] why minor->dev need ca_lock here?

We're relying on the ordering for acquire/release (previously
guaranteed by the drm_minor_lock, now by internal XArray locking).
xa_load doesn't take xa_lock internally:
https://docs.kernel.org/core-api/xarray.html#locking

> > -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +	xa_unlock(&drm_minors_xa);
> >   	if (!minor) {
> >   		return ERR_PTR(-ENODEV);
> > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> >   	unregister_chrdev(DRM_MAJOR, "drm");
> >   	debugfs_remove(drm_debugfs_root);
> >   	drm_sysfs_destroy();
> > -	idr_destroy(&drm_minors_idr);
> [JZ] Should we call xa_destroy instead here?

We could, if we expect the xarray to potentially not be empty.
From what I understand - all minors should be released at this point.

Thanks,
-Michał

> > +	WARN_ON(!xa_empty(&drm_minors_xa));
> >   	drm_connector_ida_destroy();
> >   }
> > @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
> >   	int ret;
> >   	drm_connector_ida_init();
> > -	idr_init(&drm_minors_idr);
> >   	drm_memcpy_init_early();
> >   	ret = drm_sysfs_init();

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-28 21:08       ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-08-28 21:08 UTC (permalink / raw)
  To: James Zhu
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Christian König,
	Emil Velikov, Maxime Ripard, James Zhu, Oded Gabbay

On Fri, Aug 25, 2023 at 12:59:26PM -0400, James Zhu wrote:
> 
> On 2023-07-24 17:14, Michał Winiarski wrote:
> > IDR is deprecated, and since XArray manages its own state with internal
> > locking, it simplifies the locking on DRM side.
> > Additionally, don't use the IRQ-safe variant, since operating on drm
> > minor is not done in IRQ context.
> > 
> > Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> > Suggested-by: Matthew Wilcox<willy@infradead.org>
> > ---
> >   drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
> >   1 file changed, 25 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 3eda026ffac6..3faecb01186f 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -34,6 +34,7 @@
> >   #include <linux/pseudo_fs.h>
> >   #include <linux/slab.h>
> >   #include <linux/srcu.h>
> > +#include <linux/xarray.h>
> >   #include <drm/drm_accel.h>
> >   #include <drm/drm_cache.h>
> > @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
> >   MODULE_DESCRIPTION("DRM shared core routines");
> >   MODULE_LICENSE("GPL and additional rights");
> > -static DEFINE_SPINLOCK(drm_minor_lock);
> > -static struct idr drm_minors_idr;
> > +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
> >   /*
> >    * If the drm core fails to init for whatever reason,
> > @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
> >   static void drm_minor_alloc_release(struct drm_device *dev, void *data)
> >   {
> >   	struct drm_minor *minor = data;
> > -	unsigned long flags;
> >   	WARN_ON(dev != minor->dev);
> >   	put_device(minor->kdev);
> > -	if (minor->type == DRM_MINOR_ACCEL) {
> > +	if (minor->type == DRM_MINOR_ACCEL)
> >   		accel_minor_remove(minor->index);
> > -	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_remove(&drm_minors_idr, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > -	}
> > +	else
> > +		xa_erase(&drm_minors_xa, minor->index);
> >   }
> > +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
> > +
> >   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > -	int r;
> > +	int index, r;
> >   	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
> >   	if (!minor)
> > @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   	minor->type = type;
> >   	minor->dev = dev;
> > -	idr_preload(GFP_KERNEL);
> >   	if (type == DRM_MINOR_ACCEL) {
> >   		r = accel_minor_alloc();
> > +		index = r;
> >   	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		r = idr_alloc(&drm_minors_idr,
> > -			NULL,
> > -			64 * type,
> > -			64 * (type + 1),
> > -			GFP_NOWAIT);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
> >   	}
> > -	idr_preload_end();
> >   	if (r < 0)
> >   		return r;
> > -	minor->index = r;
> > +	minor->index = index;
> >   	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
> >   	if (r)
> > @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > +	void *entry;
> >   	int ret;
> >   	DRM_DEBUG("\n");
> > @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   	if (minor->type == DRM_MINOR_ACCEL) {
> >   		accel_minor_replace(minor, minor->index);
> >   	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_replace(&drm_minors_idr, minor, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
> > +		if (xa_is_err(entry)) {
> > +			ret = xa_err(entry);
> > +			goto err_debugfs;
> > +		}
> > +		WARN_ON(entry);
> [JZ] would WARN_ON(entry != minor)be better?

We expect NULL here.
The same one that was previously stored here ⌄⌄⌄
r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
in drm_minor_alloc.

> >   	}
> >   	DRM_DEBUG("new minor registered %d\n", minor->index);
> > @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> >   	minor = *drm_minor_get_slot(dev, type);
> >   	if (!minor || !device_is_registered(minor->kdev))
> >   		return;
> >   	/* replace @minor with NULL so lookups will fail from now on */
> > -	if (minor->type == DRM_MINOR_ACCEL) {
> > +	if (minor->type == DRM_MINOR_ACCEL)
> >   		accel_minor_replace(NULL, minor->index);
> > -	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_replace(&drm_minors_idr, NULL, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > -	}
> > +	else
> > +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
> >   	device_del(minor->kdev);
> >   	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
> > @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
> >   struct drm_minor *drm_minor_acquire(unsigned int minor_id)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > -	spin_lock_irqsave(&drm_minor_lock, flags);
> > -	minor = idr_find(&drm_minors_idr, minor_id);
> > +	xa_lock(&drm_minors_xa);
> > +	minor = xa_load(&drm_minors_xa, minor_id);
> >   	if (minor)
> >   		drm_dev_get(minor->dev);
> [JZ] why minor->dev need ca_lock here?

We're relying on the ordering for acquire/release (previously
guaranteed by the drm_minor_lock, now by internal XArray locking).
xa_load doesn't take xa_lock internally:
https://docs.kernel.org/core-api/xarray.html#locking

> > -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +	xa_unlock(&drm_minors_xa);
> >   	if (!minor) {
> >   		return ERR_PTR(-ENODEV);
> > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> >   	unregister_chrdev(DRM_MAJOR, "drm");
> >   	debugfs_remove(drm_debugfs_root);
> >   	drm_sysfs_destroy();
> > -	idr_destroy(&drm_minors_idr);
> [JZ] Should we call xa_destroy instead here?

We could, if we expect the xarray to potentially not be empty.
From what I understand - all minors should be released at this point.

Thanks,
-Michał

> > +	WARN_ON(!xa_empty(&drm_minors_xa));
> >   	drm_connector_ida_destroy();
> >   }
> > @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
> >   	int ret;
> >   	drm_connector_ida_init();
> > -	idr_init(&drm_minors_idr);
> >   	drm_memcpy_init_early();
> >   	ret = drm_sysfs_init();

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-28 21:08       ` Michał Winiarski
  0 siblings, 0 replies; 64+ messages in thread
From: Michał Winiarski @ 2023-08-28 21:08 UTC (permalink / raw)
  To: James Zhu
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	Simon Ser, intel-gfx, linux-kernel, dri-devel,
	Christian König, Maxime Ripard, Daniel Vetter, James Zhu,
	Oded Gabbay

On Fri, Aug 25, 2023 at 12:59:26PM -0400, James Zhu wrote:
> 
> On 2023-07-24 17:14, Michał Winiarski wrote:
> > IDR is deprecated, and since XArray manages its own state with internal
> > locking, it simplifies the locking on DRM side.
> > Additionally, don't use the IRQ-safe variant, since operating on drm
> > minor is not done in IRQ context.
> > 
> > Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
> > Suggested-by: Matthew Wilcox<willy@infradead.org>
> > ---
> >   drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
> >   1 file changed, 25 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> > index 3eda026ffac6..3faecb01186f 100644
> > --- a/drivers/gpu/drm/drm_drv.c
> > +++ b/drivers/gpu/drm/drm_drv.c
> > @@ -34,6 +34,7 @@
> >   #include <linux/pseudo_fs.h>
> >   #include <linux/slab.h>
> >   #include <linux/srcu.h>
> > +#include <linux/xarray.h>
> >   #include <drm/drm_accel.h>
> >   #include <drm/drm_cache.h>
> > @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
> >   MODULE_DESCRIPTION("DRM shared core routines");
> >   MODULE_LICENSE("GPL and additional rights");
> > -static DEFINE_SPINLOCK(drm_minor_lock);
> > -static struct idr drm_minors_idr;
> > +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
> >   /*
> >    * If the drm core fails to init for whatever reason,
> > @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
> >   static void drm_minor_alloc_release(struct drm_device *dev, void *data)
> >   {
> >   	struct drm_minor *minor = data;
> > -	unsigned long flags;
> >   	WARN_ON(dev != minor->dev);
> >   	put_device(minor->kdev);
> > -	if (minor->type == DRM_MINOR_ACCEL) {
> > +	if (minor->type == DRM_MINOR_ACCEL)
> >   		accel_minor_remove(minor->index);
> > -	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_remove(&drm_minors_idr, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > -	}
> > +	else
> > +		xa_erase(&drm_minors_xa, minor->index);
> >   }
> > +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
> > +
> >   static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > -	int r;
> > +	int index, r;
> >   	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
> >   	if (!minor)
> > @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   	minor->type = type;
> >   	minor->dev = dev;
> > -	idr_preload(GFP_KERNEL);
> >   	if (type == DRM_MINOR_ACCEL) {
> >   		r = accel_minor_alloc();
> > +		index = r;
> >   	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		r = idr_alloc(&drm_minors_idr,
> > -			NULL,
> > -			64 * type,
> > -			64 * (type + 1),
> > -			GFP_NOWAIT);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
> >   	}
> > -	idr_preload_end();
> >   	if (r < 0)
> >   		return r;
> > -	minor->index = r;
> > +	minor->index = index;
> >   	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
> >   	if (r)
> > @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
> >   static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > +	void *entry;
> >   	int ret;
> >   	DRM_DEBUG("\n");
> > @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   	if (minor->type == DRM_MINOR_ACCEL) {
> >   		accel_minor_replace(minor, minor->index);
> >   	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_replace(&drm_minors_idr, minor, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
> > +		if (xa_is_err(entry)) {
> > +			ret = xa_err(entry);
> > +			goto err_debugfs;
> > +		}
> > +		WARN_ON(entry);
> [JZ] would WARN_ON(entry != minor)be better?

We expect NULL here.
The same one that was previously stored here ⌄⌄⌄
r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
in drm_minor_alloc.

> >   	}
> >   	DRM_DEBUG("new minor registered %d\n", minor->index);
> > @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
> >   static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> >   	minor = *drm_minor_get_slot(dev, type);
> >   	if (!minor || !device_is_registered(minor->kdev))
> >   		return;
> >   	/* replace @minor with NULL so lookups will fail from now on */
> > -	if (minor->type == DRM_MINOR_ACCEL) {
> > +	if (minor->type == DRM_MINOR_ACCEL)
> >   		accel_minor_replace(NULL, minor->index);
> > -	} else {
> > -		spin_lock_irqsave(&drm_minor_lock, flags);
> > -		idr_replace(&drm_minors_idr, NULL, minor->index);
> > -		spin_unlock_irqrestore(&drm_minor_lock, flags);
> > -	}
> > +	else
> > +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
> >   	device_del(minor->kdev);
> >   	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
> > @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
> >   struct drm_minor *drm_minor_acquire(unsigned int minor_id)
> >   {
> >   	struct drm_minor *minor;
> > -	unsigned long flags;
> > -	spin_lock_irqsave(&drm_minor_lock, flags);
> > -	minor = idr_find(&drm_minors_idr, minor_id);
> > +	xa_lock(&drm_minors_xa);
> > +	minor = xa_load(&drm_minors_xa, minor_id);
> >   	if (minor)
> >   		drm_dev_get(minor->dev);
> [JZ] why minor->dev need ca_lock here?

We're relying on the ordering for acquire/release (previously
guaranteed by the drm_minor_lock, now by internal XArray locking).
xa_load doesn't take xa_lock internally:
https://docs.kernel.org/core-api/xarray.html#locking

> > -	spin_unlock_irqrestore(&drm_minor_lock, flags);
> > +	xa_unlock(&drm_minors_xa);
> >   	if (!minor) {
> >   		return ERR_PTR(-ENODEV);
> > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> >   	unregister_chrdev(DRM_MAJOR, "drm");
> >   	debugfs_remove(drm_debugfs_root);
> >   	drm_sysfs_destroy();
> > -	idr_destroy(&drm_minors_idr);
> [JZ] Should we call xa_destroy instead here?

We could, if we expect the xarray to potentially not be empty.
From what I understand - all minors should be released at this point.

Thanks,
-Michał

> > +	WARN_ON(!xa_empty(&drm_minors_xa));
> >   	drm_connector_ida_destroy();
> >   }
> > @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
> >   	int ret;
> >   	drm_connector_ida_init();
> > -	idr_init(&drm_minors_idr);
> >   	drm_memcpy_init_early();
> >   	ret = drm_sysfs_init();

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-08-28 21:08       ` Michał Winiarski
  (?)
@ 2023-08-29 17:34         ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-29 17:34 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: dri-devel, linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Simon Ser,
	Matthew Wilcox, Oded Gabbay, Christian König, James Zhu,
	Pekka Paalanen, Emil Velikov


On 2023-08-28 17:08, Michał Winiarski wrote:
> On Fri, Aug 25, 2023 at 12:59:26PM -0400, James Zhu wrote:
>> On 2023-07-24 17:14, Michał Winiarski wrote:
>>> IDR is deprecated, and since XArray manages its own state with internal
>>> locking, it simplifies the locking on DRM side.
>>> Additionally, don't use the IRQ-safe variant, since operating on drm
>>> minor is not done in IRQ context.
>>>
>>> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
>>> Suggested-by: Matthew Wilcox<willy@infradead.org>
>>> ---
>>>    drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
>>>    1 file changed, 25 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>>> index 3eda026ffac6..3faecb01186f 100644
>>> --- a/drivers/gpu/drm/drm_drv.c
>>> +++ b/drivers/gpu/drm/drm_drv.c
>>> @@ -34,6 +34,7 @@
>>>    #include <linux/pseudo_fs.h>
>>>    #include <linux/slab.h>
>>>    #include <linux/srcu.h>
>>> +#include <linux/xarray.h>
>>>    #include <drm/drm_accel.h>
>>>    #include <drm/drm_cache.h>
>>> @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
>>>    MODULE_DESCRIPTION("DRM shared core routines");
>>>    MODULE_LICENSE("GPL and additional rights");
>>> -static DEFINE_SPINLOCK(drm_minor_lock);
>>> -static struct idr drm_minors_idr;
>>> +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
>>>    /*
>>>     * If the drm core fails to init for whatever reason,
>>> @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
>>>    static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>>>    {
>>>    	struct drm_minor *minor = data;
>>> -	unsigned long flags;
>>>    	WARN_ON(dev != minor->dev);
>>>    	put_device(minor->kdev);
>>> -	if (minor->type == DRM_MINOR_ACCEL) {
>>> +	if (minor->type == DRM_MINOR_ACCEL)
>>>    		accel_minor_remove(minor->index);
>>> -	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_remove(&drm_minors_idr, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> -	}
>>> +	else
>>> +		xa_erase(&drm_minors_xa, minor->index);
>>>    }
>>> +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
>>> +
>>>    static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> -	int r;
>>> +	int index, r;
>>>    	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
>>>    	if (!minor)
>>> @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    	minor->type = type;
>>>    	minor->dev = dev;
>>> -	idr_preload(GFP_KERNEL);
>>>    	if (type == DRM_MINOR_ACCEL) {
>>>    		r = accel_minor_alloc();
>>> +		index = r;
>>>    	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		r = idr_alloc(&drm_minors_idr,
>>> -			NULL,
>>> -			64 * type,
>>> -			64 * (type + 1),
>>> -			GFP_NOWAIT);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
>>>    	}
>>> -	idr_preload_end();
>>>    	if (r < 0)
>>>    		return r;
>>> -	minor->index = r;
>>> +	minor->index = index;
>>>    	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
>>>    	if (r)
>>> @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> +	void *entry;
>>>    	int ret;
>>>    	DRM_DEBUG("\n");
>>> @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    	if (minor->type == DRM_MINOR_ACCEL) {
>>>    		accel_minor_replace(minor, minor->index);
>>>    	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_replace(&drm_minors_idr, minor, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
>>> +		if (xa_is_err(entry)) {
>>> +			ret = xa_err(entry);
>>> +			goto err_debugfs;
>>> +		}
>>> +		WARN_ON(entry);
>> [JZ] would WARN_ON(entry != minor)be better?
> We expect NULL here.
> The same one that was previously stored here ⌄⌄⌄
> r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
> in drm_minor_alloc.
[JZ] My mistake.
>
>>>    	}
>>>    	DRM_DEBUG("new minor registered %d\n", minor->index);
>>> @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>>    	minor = *drm_minor_get_slot(dev, type);
>>>    	if (!minor || !device_is_registered(minor->kdev))
>>>    		return;
>>>    	/* replace @minor with NULL so lookups will fail from now on */
>>> -	if (minor->type == DRM_MINOR_ACCEL) {
>>> +	if (minor->type == DRM_MINOR_ACCEL)
>>>    		accel_minor_replace(NULL, minor->index);
>>> -	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_replace(&drm_minors_idr, NULL, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> -	}
>>> +	else
>>> +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
>>>    	device_del(minor->kdev);
>>>    	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
>>> @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
>>>    struct drm_minor *drm_minor_acquire(unsigned int minor_id)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> -	spin_lock_irqsave(&drm_minor_lock, flags);
>>> -	minor = idr_find(&drm_minors_idr, minor_id);
>>> +	xa_lock(&drm_minors_xa);
>>> +	minor = xa_load(&drm_minors_xa, minor_id);
>>>    	if (minor)
>>>    		drm_dev_get(minor->dev);
>> [JZ] why minor->dev need ca_lock here?
> We're relying on the ordering for acquire/release (previously
> guaranteed by the drm_minor_lock, now by internal XArray locking).
> xa_load doesn't take xa_lock internally:
> https://docs.kernel.org/core-api/xarray.html#locking
[JZ] I means that drm_dev_get(minor->dev); can move out of xa_lock.
>>> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +	xa_unlock(&drm_minors_xa);
>>>    	if (!minor) {
>>>    		return ERR_PTR(-ENODEV);
>>> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>>>    	unregister_chrdev(DRM_MAJOR, "drm");
>>>    	debugfs_remove(drm_debugfs_root);
>>>    	drm_sysfs_destroy();
>>> -	idr_destroy(&drm_minors_idr);
>> [JZ] Should we call xa_destroy instead here?
> We could, if we expect the xarray to potentially not be empty.
>  From what I understand - all minors should be released at this point.
[JZ] In practice,  adding destroy here will be better.
>
> Thanks,
> -Michał
>
>>> +	WARN_ON(!xa_empty(&drm_minors_xa));
>>>    	drm_connector_ida_destroy();
>>>    }
>>> @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
>>>    	int ret;
>>>    	drm_connector_ida_init();
>>> -	idr_init(&drm_minors_idr);
>>>    	drm_memcpy_init_early();
>>>    	ret = drm_sysfs_init();

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 17:34         ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-29 17:34 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Christian König,
	Emil Velikov, Maxime Ripard, James Zhu, Oded Gabbay


On 2023-08-28 17:08, Michał Winiarski wrote:
> On Fri, Aug 25, 2023 at 12:59:26PM -0400, James Zhu wrote:
>> On 2023-07-24 17:14, Michał Winiarski wrote:
>>> IDR is deprecated, and since XArray manages its own state with internal
>>> locking, it simplifies the locking on DRM side.
>>> Additionally, don't use the IRQ-safe variant, since operating on drm
>>> minor is not done in IRQ context.
>>>
>>> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
>>> Suggested-by: Matthew Wilcox<willy@infradead.org>
>>> ---
>>>    drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
>>>    1 file changed, 25 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>>> index 3eda026ffac6..3faecb01186f 100644
>>> --- a/drivers/gpu/drm/drm_drv.c
>>> +++ b/drivers/gpu/drm/drm_drv.c
>>> @@ -34,6 +34,7 @@
>>>    #include <linux/pseudo_fs.h>
>>>    #include <linux/slab.h>
>>>    #include <linux/srcu.h>
>>> +#include <linux/xarray.h>
>>>    #include <drm/drm_accel.h>
>>>    #include <drm/drm_cache.h>
>>> @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
>>>    MODULE_DESCRIPTION("DRM shared core routines");
>>>    MODULE_LICENSE("GPL and additional rights");
>>> -static DEFINE_SPINLOCK(drm_minor_lock);
>>> -static struct idr drm_minors_idr;
>>> +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
>>>    /*
>>>     * If the drm core fails to init for whatever reason,
>>> @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
>>>    static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>>>    {
>>>    	struct drm_minor *minor = data;
>>> -	unsigned long flags;
>>>    	WARN_ON(dev != minor->dev);
>>>    	put_device(minor->kdev);
>>> -	if (minor->type == DRM_MINOR_ACCEL) {
>>> +	if (minor->type == DRM_MINOR_ACCEL)
>>>    		accel_minor_remove(minor->index);
>>> -	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_remove(&drm_minors_idr, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> -	}
>>> +	else
>>> +		xa_erase(&drm_minors_xa, minor->index);
>>>    }
>>> +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
>>> +
>>>    static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> -	int r;
>>> +	int index, r;
>>>    	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
>>>    	if (!minor)
>>> @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    	minor->type = type;
>>>    	minor->dev = dev;
>>> -	idr_preload(GFP_KERNEL);
>>>    	if (type == DRM_MINOR_ACCEL) {
>>>    		r = accel_minor_alloc();
>>> +		index = r;
>>>    	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		r = idr_alloc(&drm_minors_idr,
>>> -			NULL,
>>> -			64 * type,
>>> -			64 * (type + 1),
>>> -			GFP_NOWAIT);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
>>>    	}
>>> -	idr_preload_end();
>>>    	if (r < 0)
>>>    		return r;
>>> -	minor->index = r;
>>> +	minor->index = index;
>>>    	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
>>>    	if (r)
>>> @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> +	void *entry;
>>>    	int ret;
>>>    	DRM_DEBUG("\n");
>>> @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    	if (minor->type == DRM_MINOR_ACCEL) {
>>>    		accel_minor_replace(minor, minor->index);
>>>    	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_replace(&drm_minors_idr, minor, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
>>> +		if (xa_is_err(entry)) {
>>> +			ret = xa_err(entry);
>>> +			goto err_debugfs;
>>> +		}
>>> +		WARN_ON(entry);
>> [JZ] would WARN_ON(entry != minor)be better?
> We expect NULL here.
> The same one that was previously stored here ⌄⌄⌄
> r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
> in drm_minor_alloc.
[JZ] My mistake.
>
>>>    	}
>>>    	DRM_DEBUG("new minor registered %d\n", minor->index);
>>> @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>>    	minor = *drm_minor_get_slot(dev, type);
>>>    	if (!minor || !device_is_registered(minor->kdev))
>>>    		return;
>>>    	/* replace @minor with NULL so lookups will fail from now on */
>>> -	if (minor->type == DRM_MINOR_ACCEL) {
>>> +	if (minor->type == DRM_MINOR_ACCEL)
>>>    		accel_minor_replace(NULL, minor->index);
>>> -	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_replace(&drm_minors_idr, NULL, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> -	}
>>> +	else
>>> +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
>>>    	device_del(minor->kdev);
>>>    	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
>>> @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
>>>    struct drm_minor *drm_minor_acquire(unsigned int minor_id)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> -	spin_lock_irqsave(&drm_minor_lock, flags);
>>> -	minor = idr_find(&drm_minors_idr, minor_id);
>>> +	xa_lock(&drm_minors_xa);
>>> +	minor = xa_load(&drm_minors_xa, minor_id);
>>>    	if (minor)
>>>    		drm_dev_get(minor->dev);
>> [JZ] why minor->dev need ca_lock here?
> We're relying on the ordering for acquire/release (previously
> guaranteed by the drm_minor_lock, now by internal XArray locking).
> xa_load doesn't take xa_lock internally:
> https://docs.kernel.org/core-api/xarray.html#locking
[JZ] I means that drm_dev_get(minor->dev); can move out of xa_lock.
>>> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +	xa_unlock(&drm_minors_xa);
>>>    	if (!minor) {
>>>    		return ERR_PTR(-ENODEV);
>>> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>>>    	unregister_chrdev(DRM_MAJOR, "drm");
>>>    	debugfs_remove(drm_debugfs_root);
>>>    	drm_sysfs_destroy();
>>> -	idr_destroy(&drm_minors_idr);
>> [JZ] Should we call xa_destroy instead here?
> We could, if we expect the xarray to potentially not be empty.
>  From what I understand - all minors should be released at this point.
[JZ] In practice,  adding destroy here will be better.
>
> Thanks,
> -Michał
>
>>> +	WARN_ON(!xa_empty(&drm_minors_xa));
>>>    	drm_connector_ida_destroy();
>>>    }
>>> @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
>>>    	int ret;
>>>    	drm_connector_ida_init();
>>> -	idr_init(&drm_minors_idr);
>>>    	drm_memcpy_init_early();
>>>    	ret = drm_sysfs_init();

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 17:34         ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-29 17:34 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: Matthew Wilcox, Pekka Paalanen, Thomas Zimmermann, David Airlie,
	Simon Ser, intel-gfx, linux-kernel, dri-devel,
	Christian König, Maxime Ripard, Daniel Vetter, James Zhu,
	Oded Gabbay


On 2023-08-28 17:08, Michał Winiarski wrote:
> On Fri, Aug 25, 2023 at 12:59:26PM -0400, James Zhu wrote:
>> On 2023-07-24 17:14, Michał Winiarski wrote:
>>> IDR is deprecated, and since XArray manages its own state with internal
>>> locking, it simplifies the locking on DRM side.
>>> Additionally, don't use the IRQ-safe variant, since operating on drm
>>> minor is not done in IRQ context.
>>>
>>> Signed-off-by: Michał Winiarski<michal.winiarski@intel.com>
>>> Suggested-by: Matthew Wilcox<willy@infradead.org>
>>> ---
>>>    drivers/gpu/drm/drm_drv.c | 63 ++++++++++++++++-----------------------
>>>    1 file changed, 25 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
>>> index 3eda026ffac6..3faecb01186f 100644
>>> --- a/drivers/gpu/drm/drm_drv.c
>>> +++ b/drivers/gpu/drm/drm_drv.c
>>> @@ -34,6 +34,7 @@
>>>    #include <linux/pseudo_fs.h>
>>>    #include <linux/slab.h>
>>>    #include <linux/srcu.h>
>>> +#include <linux/xarray.h>
>>>    #include <drm/drm_accel.h>
>>>    #include <drm/drm_cache.h>
>>> @@ -54,8 +55,7 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
>>>    MODULE_DESCRIPTION("DRM shared core routines");
>>>    MODULE_LICENSE("GPL and additional rights");
>>> -static DEFINE_SPINLOCK(drm_minor_lock);
>>> -static struct idr drm_minors_idr;
>>> +static DEFINE_XARRAY_ALLOC(drm_minors_xa);
>>>    /*
>>>     * If the drm core fails to init for whatever reason,
>>> @@ -101,26 +101,23 @@ static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
>>>    static void drm_minor_alloc_release(struct drm_device *dev, void *data)
>>>    {
>>>    	struct drm_minor *minor = data;
>>> -	unsigned long flags;
>>>    	WARN_ON(dev != minor->dev);
>>>    	put_device(minor->kdev);
>>> -	if (minor->type == DRM_MINOR_ACCEL) {
>>> +	if (minor->type == DRM_MINOR_ACCEL)
>>>    		accel_minor_remove(minor->index);
>>> -	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_remove(&drm_minors_idr, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> -	}
>>> +	else
>>> +		xa_erase(&drm_minors_xa, minor->index);
>>>    }
>>> +#define DRM_MINOR_LIMIT(t) ({ typeof(t) _t = (t); XA_LIMIT(64 * _t, 64 * _t + 63); })
>>> +
>>>    static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> -	int r;
>>> +	int index, r;
>>>    	minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
>>>    	if (!minor)
>>> @@ -129,24 +126,17 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    	minor->type = type;
>>>    	minor->dev = dev;
>>> -	idr_preload(GFP_KERNEL);
>>>    	if (type == DRM_MINOR_ACCEL) {
>>>    		r = accel_minor_alloc();
>>> +		index = r;
>>>    	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		r = idr_alloc(&drm_minors_idr,
>>> -			NULL,
>>> -			64 * type,
>>> -			64 * (type + 1),
>>> -			GFP_NOWAIT);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +		r = xa_alloc(&drm_minors_xa, &index, NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
>>>    	}
>>> -	idr_preload_end();
>>>    	if (r < 0)
>>>    		return r;
>>> -	minor->index = r;
>>> +	minor->index = index;
>>>    	r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor);
>>>    	if (r)
>>> @@ -163,7 +153,7 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
>>>    static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> +	void *entry;
>>>    	int ret;
>>>    	DRM_DEBUG("\n");
>>> @@ -190,9 +180,12 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    	if (minor->type == DRM_MINOR_ACCEL) {
>>>    		accel_minor_replace(minor, minor->index);
>>>    	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_replace(&drm_minors_idr, minor, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +		entry = xa_store(&drm_minors_xa, minor->index, minor, GFP_KERNEL);
>>> +		if (xa_is_err(entry)) {
>>> +			ret = xa_err(entry);
>>> +			goto err_debugfs;
>>> +		}
>>> +		WARN_ON(entry);
>> [JZ] would WARN_ON(entry != minor)be better?
> We expect NULL here.
> The same one that was previously stored here ⌄⌄⌄
> r = xa_alloc(&drm_minors_xa, &minor->index, NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
> in drm_minor_alloc.
[JZ] My mistake.
>
>>>    	}
>>>    	DRM_DEBUG("new minor registered %d\n", minor->index);
>>> @@ -206,20 +199,16 @@ static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
>>>    static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>>    	minor = *drm_minor_get_slot(dev, type);
>>>    	if (!minor || !device_is_registered(minor->kdev))
>>>    		return;
>>>    	/* replace @minor with NULL so lookups will fail from now on */
>>> -	if (minor->type == DRM_MINOR_ACCEL) {
>>> +	if (minor->type == DRM_MINOR_ACCEL)
>>>    		accel_minor_replace(NULL, minor->index);
>>> -	} else {
>>> -		spin_lock_irqsave(&drm_minor_lock, flags);
>>> -		idr_replace(&drm_minors_idr, NULL, minor->index);
>>> -		spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> -	}
>>> +	else
>>> +		xa_store(&drm_minors_xa, minor->index, NULL, GFP_KERNEL);
>>>    	device_del(minor->kdev);
>>>    	dev_set_drvdata(minor->kdev, NULL); /* safety belt */
>>> @@ -238,13 +227,12 @@ static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type typ
>>>    struct drm_minor *drm_minor_acquire(unsigned int minor_id)
>>>    {
>>>    	struct drm_minor *minor;
>>> -	unsigned long flags;
>>> -	spin_lock_irqsave(&drm_minor_lock, flags);
>>> -	minor = idr_find(&drm_minors_idr, minor_id);
>>> +	xa_lock(&drm_minors_xa);
>>> +	minor = xa_load(&drm_minors_xa, minor_id);
>>>    	if (minor)
>>>    		drm_dev_get(minor->dev);
>> [JZ] why minor->dev need ca_lock here?
> We're relying on the ordering for acquire/release (previously
> guaranteed by the drm_minor_lock, now by internal XArray locking).
> xa_load doesn't take xa_lock internally:
> https://docs.kernel.org/core-api/xarray.html#locking
[JZ] I means that drm_dev_get(minor->dev); can move out of xa_lock.
>>> -	spin_unlock_irqrestore(&drm_minor_lock, flags);
>>> +	xa_unlock(&drm_minors_xa);
>>>    	if (!minor) {
>>>    		return ERR_PTR(-ENODEV);
>>> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>>>    	unregister_chrdev(DRM_MAJOR, "drm");
>>>    	debugfs_remove(drm_debugfs_root);
>>>    	drm_sysfs_destroy();
>>> -	idr_destroy(&drm_minors_idr);
>> [JZ] Should we call xa_destroy instead here?
> We could, if we expect the xarray to potentially not be empty.
>  From what I understand - all minors should be released at this point.
[JZ] In practice,  adding destroy here will be better.
>
> Thanks,
> -Michał
>
>>> +	WARN_ON(!xa_empty(&drm_minors_xa));
>>>    	drm_connector_ida_destroy();
>>>    }
>>> @@ -1076,7 +1064,6 @@ static int __init drm_core_init(void)
>>>    	int ret;
>>>    	drm_connector_ida_init();
>>> -	idr_init(&drm_minors_idr);
>>>    	drm_memcpy_init_early();
>>>    	ret = drm_sysfs_init();

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-08-29 17:34         ` James Zhu
  (?)
@ 2023-08-29 18:33           ` Matthew Wilcox
  -1 siblings, 0 replies; 64+ messages in thread
From: Matthew Wilcox @ 2023-08-29 18:33 UTC (permalink / raw)
  To: James Zhu
  Cc: Michał Winiarski, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Christian König,
	Emil Velikov, Maxime Ripard, Pekka Paalanen, James Zhu,
	Oded Gabbay

On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
> > > > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> > > >    	unregister_chrdev(DRM_MAJOR, "drm");
> > > >    	debugfs_remove(drm_debugfs_root);
> > > >    	drm_sysfs_destroy();
> > > > -	idr_destroy(&drm_minors_idr);
> > > [JZ] Should we call xa_destroy instead here?
> > We could, if we expect the xarray to potentially not be empty.
> >  From what I understand - all minors should be released at this point.
> [JZ] In practice,  adding destroy here will be better.

Why do you say that?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 18:33           ` Matthew Wilcox
  0 siblings, 0 replies; 64+ messages in thread
From: Matthew Wilcox @ 2023-08-29 18:33 UTC (permalink / raw)
  To: James Zhu
  Cc: Michał Winiarski, Thomas Zimmermann, David Airlie,
	Simon Ser, intel-gfx, linux-kernel, dri-devel,
	Christian König, Maxime Ripard, Daniel Vetter,
	Pekka Paalanen, James Zhu, Oded Gabbay

On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
> > > > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> > > >    	unregister_chrdev(DRM_MAJOR, "drm");
> > > >    	debugfs_remove(drm_debugfs_root);
> > > >    	drm_sysfs_destroy();
> > > > -	idr_destroy(&drm_minors_idr);
> > > [JZ] Should we call xa_destroy instead here?
> > We could, if we expect the xarray to potentially not be empty.
> >  From what I understand - all minors should be released at this point.
> [JZ] In practice,  adding destroy here will be better.

Why do you say that?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 18:33           ` Matthew Wilcox
  0 siblings, 0 replies; 64+ messages in thread
From: Matthew Wilcox @ 2023-08-29 18:33 UTC (permalink / raw)
  To: James Zhu
  Cc: Michał Winiarski, dri-devel, linux-kernel, intel-gfx,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Oded Gabbay, Christian König,
	James Zhu, Pekka Paalanen, Emil Velikov

On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
> > > > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> > > >    	unregister_chrdev(DRM_MAJOR, "drm");
> > > >    	debugfs_remove(drm_debugfs_root);
> > > >    	drm_sysfs_destroy();
> > > > -	idr_destroy(&drm_minors_idr);
> > > [JZ] Should we call xa_destroy instead here?
> > We could, if we expect the xarray to potentially not be empty.
> >  From what I understand - all minors should be released at this point.
> [JZ] In practice,  adding destroy here will be better.

Why do you say that?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-08-29 18:33           ` [Intel-gfx] " Matthew Wilcox
  (?)
@ 2023-08-29 18:35             ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-29 18:35 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Michał Winiarski, dri-devel, linux-kernel, intel-gfx,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Oded Gabbay, Christian König,
	James Zhu, Pekka Paalanen, Emil Velikov


On 2023-08-29 14:33, Matthew Wilcox wrote:
> On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
>>>>> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>>>>>     	unregister_chrdev(DRM_MAJOR, "drm");
>>>>>     	debugfs_remove(drm_debugfs_root);
>>>>>     	drm_sysfs_destroy();
>>>>> -	idr_destroy(&drm_minors_idr);
>>>> [JZ] Should we call xa_destroy instead here?
>>> We could, if we expect the xarray to potentially not be empty.
>>>   From what I understand - all minors should be released at this point.
>> [JZ] In practice,  adding destroy here will be better.
> Why do you say that?
[JZ] In case, the future, INIT adds something, need DESTROY to free 
completely.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 18:35             ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-29 18:35 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Michał Winiarski, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Christian König,
	Emil Velikov, Maxime Ripard, Pekka Paalanen, James Zhu,
	Oded Gabbay


On 2023-08-29 14:33, Matthew Wilcox wrote:
> On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
>>>>> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>>>>>     	unregister_chrdev(DRM_MAJOR, "drm");
>>>>>     	debugfs_remove(drm_debugfs_root);
>>>>>     	drm_sysfs_destroy();
>>>>> -	idr_destroy(&drm_minors_idr);
>>>> [JZ] Should we call xa_destroy instead here?
>>> We could, if we expect the xarray to potentially not be empty.
>>>   From what I understand - all minors should be released at this point.
>> [JZ] In practice,  adding destroy here will be better.
> Why do you say that?
[JZ] In case, the future, INIT adds something, need DESTROY to free 
completely.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 18:35             ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-29 18:35 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Michał Winiarski, Thomas Zimmermann, David Airlie,
	Simon Ser, intel-gfx, linux-kernel, dri-devel,
	Christian König, Maxime Ripard, Daniel Vetter,
	Pekka Paalanen, James Zhu, Oded Gabbay


On 2023-08-29 14:33, Matthew Wilcox wrote:
> On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
>>>>> @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
>>>>>     	unregister_chrdev(DRM_MAJOR, "drm");
>>>>>     	debugfs_remove(drm_debugfs_root);
>>>>>     	drm_sysfs_destroy();
>>>>> -	idr_destroy(&drm_minors_idr);
>>>> [JZ] Should we call xa_destroy instead here?
>>> We could, if we expect the xarray to potentially not be empty.
>>>   From what I understand - all minors should be released at this point.
>> [JZ] In practice,  adding destroy here will be better.
> Why do you say that?
[JZ] In case, the future, INIT adds something, need DESTROY to free 
completely.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
  2023-08-29 18:35             ` James Zhu
  (?)
@ 2023-08-29 18:37               ` Matthew Wilcox
  -1 siblings, 0 replies; 64+ messages in thread
From: Matthew Wilcox @ 2023-08-29 18:37 UTC (permalink / raw)
  To: James Zhu
  Cc: Michał Winiarski, dri-devel, linux-kernel, intel-gfx,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Simon Ser, Oded Gabbay, Christian König,
	James Zhu, Pekka Paalanen, Emil Velikov

On Tue, Aug 29, 2023 at 02:35:34PM -0400, James Zhu wrote:
> 
> On 2023-08-29 14:33, Matthew Wilcox wrote:
> > On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
> > > > > > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> > > > > >     	unregister_chrdev(DRM_MAJOR, "drm");
> > > > > >     	debugfs_remove(drm_debugfs_root);
> > > > > >     	drm_sysfs_destroy();
> > > > > > -	idr_destroy(&drm_minors_idr);
> > > > > [JZ] Should we call xa_destroy instead here?
> > > > We could, if we expect the xarray to potentially not be empty.
> > > >   From what I understand - all minors should be released at this point.
> > > [JZ] In practice,  adding destroy here will be better.
> > Why do you say that?
> [JZ] In case, the future, INIT adds something, need DESTROY to free
> completely.

That isn't going to happen.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 18:37               ` Matthew Wilcox
  0 siblings, 0 replies; 64+ messages in thread
From: Matthew Wilcox @ 2023-08-29 18:37 UTC (permalink / raw)
  To: James Zhu
  Cc: Michał Winiarski, Thomas Zimmermann, David Airlie,
	intel-gfx, linux-kernel, dri-devel, Christian König,
	Emil Velikov, Maxime Ripard, Pekka Paalanen, James Zhu,
	Oded Gabbay

On Tue, Aug 29, 2023 at 02:35:34PM -0400, James Zhu wrote:
> 
> On 2023-08-29 14:33, Matthew Wilcox wrote:
> > On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
> > > > > > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> > > > > >     	unregister_chrdev(DRM_MAJOR, "drm");
> > > > > >     	debugfs_remove(drm_debugfs_root);
> > > > > >     	drm_sysfs_destroy();
> > > > > > -	idr_destroy(&drm_minors_idr);
> > > > > [JZ] Should we call xa_destroy instead here?
> > > > We could, if we expect the xarray to potentially not be empty.
> > > >   From what I understand - all minors should be released at this point.
> > > [JZ] In practice,  adding destroy here will be better.
> > Why do you say that?
> [JZ] In case, the future, INIT adds something, need DESTROY to free
> completely.

That isn't going to happen.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 1/4] drm: Use XArray instead of IDR for minors
@ 2023-08-29 18:37               ` Matthew Wilcox
  0 siblings, 0 replies; 64+ messages in thread
From: Matthew Wilcox @ 2023-08-29 18:37 UTC (permalink / raw)
  To: James Zhu
  Cc: Michał Winiarski, Thomas Zimmermann, David Airlie,
	Simon Ser, intel-gfx, linux-kernel, dri-devel,
	Christian König, Maxime Ripard, Daniel Vetter,
	Pekka Paalanen, James Zhu, Oded Gabbay

On Tue, Aug 29, 2023 at 02:35:34PM -0400, James Zhu wrote:
> 
> On 2023-08-29 14:33, Matthew Wilcox wrote:
> > On Tue, Aug 29, 2023 at 01:34:22PM -0400, James Zhu wrote:
> > > > > > @@ -1067,7 +1055,7 @@ static void drm_core_exit(void)
> > > > > >     	unregister_chrdev(DRM_MAJOR, "drm");
> > > > > >     	debugfs_remove(drm_debugfs_root);
> > > > > >     	drm_sysfs_destroy();
> > > > > > -	idr_destroy(&drm_minors_idr);
> > > > > [JZ] Should we call xa_destroy instead here?
> > > > We could, if we expect the xarray to potentially not be empty.
> > > >   From what I understand - all minors should be released at this point.
> > > [JZ] In practice,  adding destroy here will be better.
> > Why do you say that?
> [JZ] In case, the future, INIT adds something, need DESTROY to free
> completely.

That isn't going to happen.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 0/4] drm: Use full allocated minor range for DRM
  2023-07-24 21:14 ` Michał Winiarski
@ 2023-08-30 16:31   ` James Zhu
  -1 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-30 16:31 UTC (permalink / raw)
  To: Michał Winiarski, dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, David Airlie, Oded Gabbay, Maxime Ripard,
	Emil Velikov, Matthew Wilcox, Thomas Zimmermann, James Zhu,
	Christian König

[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]

PATCH 1 and 3 are

Tested-by:JamesZhu<James.Zhu@amd.com>

Best Regards!

James Zhu

On 2023-07-24 17:14, Michał Winiarski wrote:
> 64 DRM device nodes is not enough for everyone.
> Upgrade it to ~512K (which definitely is more than enough).
>
> To allow testing userspace support for >64 devices, add additional DRM
> modparam (force_extended_minors) which causes DRM to skip allocating minors
> in 0-192 range.
> Additionally - convert minors to use XArray instead of IDR to simplify the
> locking.
>
> v1 -> v2:
> Don't touch DRM_MINOR_CONTROL and its range (Simon Ser)
>
> v2 -> v3:
> Don't use legacy scheme for >=192 minor range (Dave Airlie)
> Add modparam for testing (Dave Airlie)
> Add lockdep annotation for IDR (Daniel Vetter)
>
> v3 -> v4:
> Convert from IDR to XArray (Matthew Wilcox)
>
> v4 -> v5:
> Fixup IDR to XArray conversion (Matthew Wilcox)
>
> v5 -> v6:
> Also convert Accel to XArray
> Rename skip_legacy_minors to force_extended_minors
>
> Michał Winiarski (4):
>    drm: Use XArray instead of IDR for minors
>    accel: Use XArray instead of IDR for minors
>    drm: Expand max DRM device number to full MINORBITS
>    drm: Introduce force_extended_minors modparam
>
>   drivers/accel/drm_accel.c      | 110 +++------------------------------
>   drivers/gpu/drm/drm_drv.c      | 105 ++++++++++++++++---------------
>   drivers/gpu/drm/drm_file.c     |   2 +-
>   drivers/gpu/drm/drm_internal.h |   4 --
>   include/drm/drm_accel.h        |  18 +-----
>   include/drm/drm_file.h         |   5 ++
>   6 files changed, 69 insertions(+), 175 deletions(-)
>

[-- Attachment #2: Type: text/html, Size: 2287 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [Intel-gfx] [PATCH v6 0/4] drm: Use full allocated minor range for DRM
@ 2023-08-30 16:31   ` James Zhu
  0 siblings, 0 replies; 64+ messages in thread
From: James Zhu @ 2023-08-30 16:31 UTC (permalink / raw)
  To: Michał Winiarski, dri-devel, linux-kernel, intel-gfx
  Cc: Pekka Paalanen, Daniel Vetter, David Airlie, Simon Ser,
	Oded Gabbay, Maxime Ripard, Matthew Wilcox, Thomas Zimmermann,
	James Zhu, Christian König

[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]

PATCH 1 and 3 are

Tested-by:JamesZhu<James.Zhu@amd.com>

Best Regards!

James Zhu

On 2023-07-24 17:14, Michał Winiarski wrote:
> 64 DRM device nodes is not enough for everyone.
> Upgrade it to ~512K (which definitely is more than enough).
>
> To allow testing userspace support for >64 devices, add additional DRM
> modparam (force_extended_minors) which causes DRM to skip allocating minors
> in 0-192 range.
> Additionally - convert minors to use XArray instead of IDR to simplify the
> locking.
>
> v1 -> v2:
> Don't touch DRM_MINOR_CONTROL and its range (Simon Ser)
>
> v2 -> v3:
> Don't use legacy scheme for >=192 minor range (Dave Airlie)
> Add modparam for testing (Dave Airlie)
> Add lockdep annotation for IDR (Daniel Vetter)
>
> v3 -> v4:
> Convert from IDR to XArray (Matthew Wilcox)
>
> v4 -> v5:
> Fixup IDR to XArray conversion (Matthew Wilcox)
>
> v5 -> v6:
> Also convert Accel to XArray
> Rename skip_legacy_minors to force_extended_minors
>
> Michał Winiarski (4):
>    drm: Use XArray instead of IDR for minors
>    accel: Use XArray instead of IDR for minors
>    drm: Expand max DRM device number to full MINORBITS
>    drm: Introduce force_extended_minors modparam
>
>   drivers/accel/drm_accel.c      | 110 +++------------------------------
>   drivers/gpu/drm/drm_drv.c      | 105 ++++++++++++++++---------------
>   drivers/gpu/drm/drm_file.c     |   2 +-
>   drivers/gpu/drm/drm_internal.h |   4 --
>   include/drm/drm_accel.h        |  18 +-----
>   include/drm/drm_file.h         |   5 ++
>   6 files changed, 69 insertions(+), 175 deletions(-)
>

[-- Attachment #2: Type: text/html, Size: 2287 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v6 0/4] drm: Use full allocated minor range for DRM
  2023-07-24 21:14 ` Michał Winiarski
                   ` (9 preceding siblings ...)
  (?)
@ 2024-05-03  1:22 ` Eric Pilmore
  -1 siblings, 0 replies; 64+ messages in thread
From: Eric Pilmore @ 2024-05-03  1:22 UTC (permalink / raw)
  To: Michał Winiarski
  Cc: dri-devel, linux-kernel, intel-gfx, David Airlie, Daniel Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Simon Ser,
	Matthew Wilcox, Oded Gabbay, Christian König, James Zhu,
	Pekka Paalanen, Emil Velikov



> On Jul 24, 2023, at 2:14 PM, Michał Winiarski <michal.winiarski@intel.com> wrote:
> 
> 64 DRM device nodes is not enough for everyone.
> Upgrade it to ~512K (which definitely is more than enough).
> 
> To allow testing userspace support for >64 devices, add additional DRM
> modparam (force_extended_minors) which causes DRM to skip allocating minors
> in 0-192 range.
> Additionally - convert minors to use XArray instead of IDR to simplify the
> locking.
> 
> v1 -> v2:
> Don't touch DRM_MINOR_CONTROL and its range (Simon Ser)
> 
> v2 -> v3:
> Don't use legacy scheme for >=192 minor range (Dave Airlie)
> Add modparam for testing (Dave Airlie)
> Add lockdep annotation for IDR (Daniel Vetter)
> 
> v3 -> v4:
> Convert from IDR to XArray (Matthew Wilcox)
> 
> v4 -> v5:
> Fixup IDR to XArray conversion (Matthew Wilcox)
> 
> v5 -> v6:
> Also convert Accel to XArray
> Rename skip_legacy_minors to force_extended_minors
> 
> Michał Winiarski (4):
>  drm: Use XArray instead of IDR for minors
>  accel: Use XArray instead of IDR for minors
>  drm: Expand max DRM device number to full MINORBITS
>  drm: Introduce force_extended_minors modparam
> 
> drivers/accel/drm_accel.c      | 110 +++------------------------------
> drivers/gpu/drm/drm_drv.c      | 105 ++++++++++++++++---------------
> drivers/gpu/drm/drm_file.c     |   2 +-
> drivers/gpu/drm/drm_internal.h |   4 --
> include/drm/drm_accel.h        |  18 +-----
> include/drm/drm_file.h         |   5 ++
> 6 files changed, 69 insertions(+), 175 deletions(-)
> 
> -- 
> 2.41.0
> 


Hi Michal,

What is the status on this patch? Did it ever get accepted upstream?
If so, what release? I don’t see the changes in the latest Linux kernel.
I am working on a system that involves a large number of GPUs, where
each GPU consumes a number of DRM devices. As such, I’m easily
exceeding the current limit of 64 in the (6.6) kernel. To workaround this issue,
I have temporarily picked up this patch which is doing the trick, but now
I’m wondering if this patch has seen the light of day in the Linux kernel.

Thanks for any info!

Regards,
Eric


^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2024-05-03  1:22 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 21:14 [PATCH v6 0/4] drm: Use full allocated minor range for DRM Michał Winiarski
2023-07-24 21:14 ` [Intel-gfx] " Michał Winiarski
2023-07-24 21:14 ` Michał Winiarski
2023-07-24 21:14 ` [PATCH v6 1/4] drm: Use XArray instead of IDR for minors Michał Winiarski
2023-07-24 21:14   ` [Intel-gfx] " Michał Winiarski
2023-07-24 21:14   ` Michał Winiarski
2023-08-25 16:59   ` James Zhu
2023-08-25 16:59     ` [Intel-gfx] " James Zhu
2023-08-28 21:08     ` Michał Winiarski
2023-08-28 21:08       ` [Intel-gfx] " Michał Winiarski
2023-08-28 21:08       ` Michał Winiarski
2023-08-29 17:34       ` James Zhu
2023-08-29 17:34         ` [Intel-gfx] " James Zhu
2023-08-29 17:34         ` James Zhu
2023-08-29 18:33         ` Matthew Wilcox
2023-08-29 18:33           ` Matthew Wilcox
2023-08-29 18:33           ` [Intel-gfx] " Matthew Wilcox
2023-08-29 18:35           ` James Zhu
2023-08-29 18:35             ` [Intel-gfx] " James Zhu
2023-08-29 18:35             ` James Zhu
2023-08-29 18:37             ` Matthew Wilcox
2023-08-29 18:37               ` [Intel-gfx] " Matthew Wilcox
2023-08-29 18:37               ` Matthew Wilcox
2023-07-24 21:14 ` [PATCH v6 2/4] accel: " Michał Winiarski
2023-07-24 21:14   ` [Intel-gfx] " Michał Winiarski
2023-07-24 21:14   ` Michał Winiarski
2023-07-24 21:14 ` [PATCH v6 3/4] drm: Expand max DRM device number to full MINORBITS Michał Winiarski
2023-07-24 21:14   ` [Intel-gfx] " Michał Winiarski
2023-07-24 21:14   ` Michał Winiarski
2023-07-24 22:29   ` James Zhu
2023-07-24 22:29     ` [Intel-gfx] " James Zhu
2023-07-26 18:15   ` Simon Ser
2023-07-26 18:15     ` [Intel-gfx] " Simon Ser
2023-07-26 18:15     ` Simon Ser
2023-07-27 12:01     ` [Intel-gfx] " Christian König
2023-07-27 12:01       ` Christian König
2023-07-27 12:01       ` Christian König
2023-07-28 14:22       ` Simon Ser
2023-07-28 14:22         ` [Intel-gfx] " Simon Ser
2023-07-28 14:22         ` Simon Ser
2023-08-08 13:55         ` Christian König
2023-08-08 13:55           ` Christian König
2023-08-08 13:55           ` [Intel-gfx] " Christian König
2023-08-08 15:04           ` James Zhu
2023-08-08 15:04             ` James Zhu
2023-08-08 15:04             ` [Intel-gfx] " James Zhu
2023-08-23 10:53             ` Simon Ser
2023-08-23 10:53               ` [Intel-gfx] " Simon Ser
2023-08-23 10:53               ` Simon Ser
2023-08-23 10:58               ` Simon Ser
2023-08-23 10:58                 ` [Intel-gfx] " Simon Ser
2023-08-23 10:58                 ` Simon Ser
2023-08-23 14:06               ` James Zhu
2023-08-23 14:06                 ` [Intel-gfx] " James Zhu
2023-08-23 14:06                 ` James Zhu
2023-07-24 21:14 ` [PATCH v6 4/4] drm: Introduce force_extended_minors modparam Michał Winiarski
2023-07-24 21:14   ` [Intel-gfx] " Michał Winiarski
2023-07-24 21:14   ` Michał Winiarski
2023-07-24 21:46 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Use full allocated minor range for DRM (rev3) Patchwork
2023-07-24 22:00 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-07-25  6:39 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-08-30 16:31 ` [PATCH v6 0/4] drm: Use full allocated minor range for DRM James Zhu
2023-08-30 16:31   ` [Intel-gfx] " James Zhu
2024-05-03  1:22 ` Eric Pilmore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.