From: "Michał Winiarski" <michal.winiarski@intel.com>
To: <dri-devel@lists.freedesktop.org>
Cc: "Michał Winiarski" <michal.winiarski@intel.com>,
"David Airlie" <airlied@linux.ie>,
"Thomas Zimmermann" <tzimmermann@suse.de>
Subject: [PATCH v2 1/2] drm: Expand max DRM device number to full MINORBITS
Date: Tue, 23 Aug 2022 23:06:11 +0200 [thread overview]
Message-ID: <20220823210612.296922-2-michal.winiarski@intel.com> (raw)
In-Reply-To: <20220823210612.296922-1-michal.winiarski@intel.com>
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.
This is continued for minors >= 192 (192-255 for primary, 256-319
reserved, 320-383 for render, and so on).
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
drivers/gpu/drm/drm_drv.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 8214a0b1ab7f..b64b5c45cd80 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -113,7 +113,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
{
struct drm_minor *minor;
unsigned long flags;
- int r;
+ int r, start, end;
minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL);
if (!minor)
@@ -122,15 +122,19 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
minor->type = type;
minor->dev = dev;
- idr_preload(GFP_KERNEL);
- 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);
- idr_preload_end();
+ start = 64 * type;
+ end = 64 * (type + 1);
+
+ do {
+ idr_preload(GFP_KERNEL);
+ spin_lock_irqsave(&drm_minor_lock, flags);
+ r = idr_alloc(&drm_minors_idr, NULL, start, end, GFP_NOWAIT);
+ spin_unlock_irqrestore(&drm_minor_lock, flags);
+ idr_preload_end();
+
+ start += 192;
+ end += 192;
+ } while ((r == -ENOSPC) && end <= (1 << MINORBITS));
if (r < 0)
return r;
--
2.37.2
next prev parent reply other threads:[~2022-08-23 21:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 21:06 [PATCH v2 0/2] drm: Use full allocated minor range for DRM Michał Winiarski
2022-08-23 21:06 ` Michał Winiarski [this message]
2022-08-24 8:02 ` [PATCH v2 1/2] drm: Expand max DRM device number to full MINORBITS Simon Ser
2022-08-23 21:06 ` [PATCH v2 2/2] drm: Use mutex for minors Michał Winiarski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220823210612.296922-2-michal.winiarski@intel.com \
--to=michal.winiarski@intel.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).