From: Eric Engestrom <eric.engestrom@intel.com>
To: Thomas Hellstrom <thellstrom@vmware.com>
Cc: linux-graphics-maintainer@vmware.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH libdrm] libdrm: Allow dynamic drm majors on linux
Date: Fri, 31 Aug 2018 13:15:56 +0100 [thread overview]
Message-ID: <20180831121556.tsmfcm7ewd2n73ze@intel.com> (raw)
In-Reply-To: <20180831115419.4922-1-thellstrom@vmware.com>
On Friday, 2018-08-31 13:54:19 +0200, Thomas Hellstrom wrote:
> To determine whether a device node is a drm device node or not, the code
> currently compares the node's major number to the static drm major device
> number.
>
> This breaks the standalone vmwgfx driver on XWayland dri clients,
> https://cgit.freedesktop.org/mesa/vmwgfx
> and any future attempt to introduce dynamic device numbers for drm.
>
> So instead of checking for the device major, instead check for the presence
> of the /sys/dev/char/<major>:<minor>/device/drm directory.
Just FYI, this means it now matches /dev/fb0 too.
I don't think this will be an issue, but just pointing it out so people notice.
>
> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
> ---
> xf86drm.c | 31 +++++++++++++++++++++++--------
> 1 file changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 7807dce9..4cfc5d3e 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -2761,6 +2761,21 @@ char *drmGetDeviceNameFromFd(int fd)
> return strdup(name);
> }
>
> +static bool
> +drmNodeIsDRM(int maj, int min)
> +{
> +#ifdef __linux__
> + char path[64];
> + struct stat sbuf;
> +
> + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/drm",
> + maj, min);
Nit: mixing tabs and space on this line.
With that fixed:
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
> + return stat(path, &sbuf) == 0;
> +#else
> + return maj == DRM_MAJOR;
> +#endif
> +}
> +
> int drmGetNodeTypeFromFd(int fd)
> {
> struct stat sbuf;
> @@ -2772,7 +2787,7 @@ int drmGetNodeTypeFromFd(int fd)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) {
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode)) {
> errno = EINVAL;
> return -1;
> }
> @@ -2837,7 +2852,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return NULL;
>
> snprintf(buf, sizeof(buf), "/sys/dev/char/%d:%d/device/drm", maj, min);
> @@ -2871,7 +2886,7 @@ static char *drmGetMinorNameForFD(int fd, int type)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return NULL;
>
> switch (type) {
> @@ -3731,7 +3746,7 @@ process_device(drmDevicePtr *device, const char *d_name,
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return -1;
>
> subsystem_type = drmParseSubsystemType(maj, min);
> @@ -3845,7 +3860,7 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return -EINVAL;
>
> node_type = drmGetMinorType(min);
> @@ -3911,7 +3926,7 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return -EINVAL;
>
> subsystem_type = drmParseSubsystemType(maj, min);
> @@ -4071,7 +4086,7 @@ char *drmGetDeviceNameFromFd2(int fd)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return NULL;
>
> snprintf(path, sizeof(path), "/sys/dev/char/%d:%d", maj, min);
> @@ -4097,7 +4112,7 @@ char *drmGetDeviceNameFromFd2(int fd)
> maj = major(sbuf.st_rdev);
> min = minor(sbuf.st_rdev);
>
> - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
> + if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
> return NULL;
>
> node_type = drmGetMinorType(min);
> --
> 2.18.0.rc1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-08-31 12:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 11:54 [PATCH libdrm] libdrm: Allow dynamic drm majors on linux Thomas Hellstrom
2018-08-31 12:15 ` Eric Engestrom [this message]
2018-08-31 12:30 ` Emil Velikov
2018-08-31 13:05 ` Thomas Hellstrom
[not found] ` <bbb94b6f-c9d5-27ab-9e6d-4b4c1d85db8e-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2018-08-31 14:38 ` Michel Dänzer
[not found] ` <33fb1ba6-cc44-f747-545b-9f877917933e-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-08-31 14:46 ` Thomas Hellstrom
[not found] ` <e656d26a-be98-cc9c-7962-fd74ad226c60-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2018-08-31 14:49 ` Michel Dänzer
[not found] ` <6d78b948-55bc-3adf-f8c0-691aa80a8bb2-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-08-31 14:59 ` Thomas Hellstrom
2018-08-31 15:27 ` Emil Velikov
[not found] ` <CACvgo53Wd1fq8=V_v7jjuFGimUfh7xD+ccCg-jOTjLSJdWUKeA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-08-31 15:30 ` Thomas Hellstrom
[not found] ` <c1dc7253-d505-dd16-480c-ee9a862d57ef-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2018-09-03 9:16 ` Thomas Hellstrom
2018-09-03 16:33 ` Daniel Vetter
[not found] ` <20180903163310.GJ21634-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-09-03 17:00 ` Thomas Hellstrom
[not found] ` <91ad6140-4e56-afc1-2515-9ca973d0ea05-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2018-09-04 22:33 ` Dave Airlie
[not found] ` <CAPM=9tzScEQ-RWK55zKeT_yXiN6iAyx34DVX1eCgA3ZqC_SpuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-05 9:33 ` Emil Velikov
[not found] ` <CACvgo50cfLHWDUEjeNet4H3F4i3okdhSsXfjNiPvH-YZbQsyEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-05 10:10 ` Thomas Hellstrom
2018-09-05 13:07 ` Emil Velikov
[not found] ` <CACvgo53t4OSsdmxdHSqrfSWKZGYg4s+uXrSV3gWcignwNxfE8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-09-05 13:20 ` Thomas Hellstrom
2018-09-05 13:53 ` Emil Velikov
2018-09-30 17:31 ` Thomas Hellstrom
2018-10-02 19:55 ` Thomas Hellstrom
[not found] ` <a3af864a-8914-3bef-ff26-02c7672a9e50-4+hqylr40dJg9hUCZPvPmw@public.gmane.org>
2018-10-04 14:12 ` Emil Velikov
[not found] ` <CACvgo5289XdFe9S4r3uSUA20QP37Zy0iiYEW_nHMho4yc0Pi8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-10-04 16:43 ` Thomas Hellstrom
2018-08-31 15:31 ` Christian König
[not found] ` <02acda47-d071-1c97-e151-fcb75d10c656-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-02 14:54 ` Alex Deucher
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=20180831121556.tsmfcm7ewd2n73ze@intel.com \
--to=eric.engestrom@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-graphics-maintainer@vmware.com \
--cc=thellstrom@vmware.com \
/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