From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, Rob Herring <robh+dt@kernel.org>,
devicetree@vger.kernel.org,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH] drm: support gpu aliases defined in DT data
Date: Thu, 17 Jan 2019 13:19:18 +0200 [thread overview]
Message-ID: <20190117111918.31759-1-tomi.valkeinen@ti.com> (raw)
The DRM device minor numbers are allocated according to the registration
order. This causes confusion in cases where the registration order can
change, or when, say, a modesetting capable device is preferred to be
card0, and a rendering device is preferred to be card1.
This patch adds similar functionality that is used in some other
subsystems, where device minor numbers can be defined in DT bindings'
aliases node.
For example, this sets the DRM device minor number to 1 for the 'dss'
device.
aliases {
gpu1 = &dss;
};
The logic on how to pick the minor number is:
- if there's a DT gpu alias for the device, use that
- else, if there are any gpu aliases, pick a minor number that is higher
than any of the aliases.
- else, use the full range of possible numbers
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
drivers/gpu/drm/drm_drv.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a5fe91b8c3c9..f536a2760293 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -110,6 +110,8 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
struct drm_minor *minor;
unsigned long flags;
int r;
+ int min_id, max_id;
+ bool of_id_found = false;
minor = kzalloc(sizeof(*minor), GFP_KERNEL);
if (!minor)
@@ -118,12 +120,37 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
minor->type = type;
minor->dev = dev;
+ min_id = 64 * type;
+ max_id = 64 * (type + 1);
+
+ if (dev->dev && dev->dev->of_node) {
+ int id;
+
+ id = of_alias_get_id(dev->dev->of_node, "gpu");
+
+ if (id >= 0) {
+ min_id = 64 * type + id;
+ max_id = 64 * type + id + 1;
+
+ of_id_found = true;
+ }
+ }
+
+ if (!of_id_found) {
+ int id;
+
+ id = of_alias_get_highest_id("gpu");
+
+ if (id >= 0)
+ min_id = id + 1;
+ }
+
idr_preload(GFP_KERNEL);
spin_lock_irqsave(&drm_minor_lock, flags);
r = idr_alloc(&drm_minors_idr,
NULL,
- 64 * type,
- 64 * (type + 1),
+ min_id,
+ max_id,
GFP_NOWAIT);
spin_unlock_irqrestore(&drm_minor_lock, flags);
idr_preload_end();
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2019-01-17 11:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 11:19 Tomi Valkeinen [this message]
2019-01-17 11:35 ` [PATCH] drm: support gpu aliases defined in DT data Maxime Ripard
2019-01-17 12:33 ` Daniel Vetter
2019-01-17 13:04 ` Tomi Valkeinen
2019-01-17 13:26 ` Daniel Vetter
2019-01-17 13:56 ` Tomi Valkeinen
2019-01-17 22:04 ` Rob Herring
2019-01-18 8:29 ` Tomi Valkeinen
2019-03-06 1:41 ` Laurent Pinchart
2019-03-06 7:49 ` Tomi Valkeinen
2019-04-17 17:42 ` Emil Velikov
2019-04-26 11:23 ` Tomi Valkeinen
2019-01-17 21:38 ` Eric Anholt
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=20190117111918.31759-1-tomi.valkeinen@ti.com \
--to=tomi.valkeinen@ti.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maxime.ripard@bootlin.com \
--cc=robh+dt@kernel.org \
--cc=sean@poorly.run \
/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).