Skip to content

Commit 0dd059a

Browse files
mwiniarsgregkh
authored andcommitted
drm: Expand max DRM device number to full MINORBITS
[ Upstream commit 071d583 ] 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> Link: https://patchwork.freedesktop.org/patch/msgid/20240823163048.2676257-4-michal.winiarski@intel.com Acked-by: James Zhu <James.Zhu@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5f5b32b commit 0dd059a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/gpu/drm/drm_drv.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,19 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
121121
xa_erase(drm_minor_get_xa(minor->type), minor->index);
122122
}
123123

124+
/*
125+
* DRM used to support 64 devices, for backwards compatibility we need to maintain the
126+
* minor allocation scheme where minors 0-63 are primary nodes, 64-127 are control nodes,
127+
* and 128-191 are render nodes.
128+
* After reaching the limit, we're allocating minors dynamically - first-come, first-serve.
129+
* Accel nodes are using a distinct major, so the minors are allocated in continuous 0-MAX
130+
* range.
131+
*/
124132
#define DRM_MINOR_LIMIT(t) ({ \
125133
typeof(t) _t = (t); \
126134
_t == DRM_MINOR_ACCEL ? XA_LIMIT(0, ACCEL_MAX_MINORS) : XA_LIMIT(64 * _t, 64 * _t + 63); \
127135
})
136+
#define DRM_EXTENDED_MINOR_LIMIT XA_LIMIT(192, (1 << MINORBITS) - 1)
128137

129138
static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
130139
{
@@ -140,6 +149,9 @@ static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
140149

141150
r = xa_alloc(drm_minor_get_xa(type), &minor->index,
142151
NULL, DRM_MINOR_LIMIT(type), GFP_KERNEL);
152+
if (r == -EBUSY && (type == DRM_MINOR_PRIMARY || type == DRM_MINOR_RENDER))
153+
r = xa_alloc(&drm_minors_xa, &minor->index,
154+
NULL, DRM_EXTENDED_MINOR_LIMIT, GFP_KERNEL);
143155
if (r < 0)
144156
return r;
145157

0 commit comments

Comments
 (0)