xf86drm: implement drmGetMinorNameForFD for non-sysfs
PATCH 1/5 xf86drm: implement drmGetMinorNameForFD for non-sysfs
Implement drmGetMinorNameForFD for systems without sysfs by adapting drm_get_device_name_for_fd() from the Mesa loader.
--- xf86drm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
xf86drm.c +19 -1
@@ -2818,7 +2818,25 @@ static char *drmGetMinorNameForFD(int fd, int type) out_close_dir:closedir (sysdir);#else -#warning "Missing implementation of drmGetMinorNameForFD" +struct stat sbuf; +unsigned int maj, min; +char buf[PATH_MAX +1 ]; +int n; + +if (fstat (fd, &sbuf)) +return NULL ; + + maj =major (sbuf.st_rdev); + min =minor (sbuf.st_rdev); + +if (maj !=DRM_MAJOR || !S_ISCHR (sbuf.st_mode)) +return NULL ; + + n =snprintf (buf,sizeof (buf),DRM_DEV_NAME ,DRM_DIR_NAME , min); +if (n ==-1 || n >=sizeof (buf)) +return NULL ; + +return strdup (buf);#endif return NULL ; }
Signature · 6 lines
2.10.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/5 xf86drm: implement drmParseSubsystemType for OpenBSD
Implement drmParseSubsystemType for OpenBSD by always returning DRM_BUS_PCI. No non-pci drm drivers are in the kernel and this is unlikely to change anytime soon as the existing ones aren't permissively licensed.
--- xf86drm.c | 2 ++ 1 file changed, 2 insertions(+)
xf86drm.c +2 -0
@@ -2872,6 +2872,8 @@ static int drmParseSubsystemType(int maj, int min)return DRM_BUS_PCI ;return -EINVAL ; +#elif defined(__OpenBSD__) +return DRM_BUS_PCI ;#else #warning "Missing implementation of drmParseSubsystemType"return -EINVAL ;
Signature · 6 lines
2.10.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 2/5] xf86drm: implement drmParseSubsystemType for OpenBSD
Quoted 5 lines · Jonathan Gray
Implement drmParseSubsystemType for OpenBSD by always returning
DRM_BUS_PCI. No non-pci drm drivers are in the kernel and this is unlikely to change anytime soon as the existing ones aren't permissively licensed.
A few noticeable X11 MIT style licensed drivers include qxl, vgem and virtio. Two of which PCI ones and vgem in it's own unique category ;-)
There was a question about re-licensing [some] drivers a few years ago at XDC in France. IIRC devs were fine with it, yet it doesn't seem like things changed much.
Have you/fellow BSD developers considered reaching out [as a group] to interested drivers/developers ? Pardon if I've already mentioned/already asked about this.
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 2/5] xf86drm: implement drmParseSubsystemType for OpenBSD
Quoted 16 lines · Emil Velikov
Quoted 5 lines · Jonathan Gray
Implement drmParseSubsystemType for OpenBSD by always returning
DRM_BUS_PCI. No non-pci drm drivers are in the kernel and this is unlikely to change anytime soon as the existing ones aren't permissively licensed.A few noticeable X11 MIT style licensed drivers include qxl, vgem and virtio. Two of which PCI ones and vgem in it's own unique category ;-)
There was a question about re-licensing [some] drivers a few years ago at XDC in France. IIRC devs were fine with it, yet it doesn't seem like things changed much.
Have you/fellow BSD developers considered reaching out [as a group] to interesteddrivers/developers? Pardon if I've already mentioned/already asked about this.
Quoted 2 lines
Thanks
Emil
There is no particular driver, cirrus, gma500 etc might be nice but really what limited spare time we have that involves drm is dealt dealing with the constant churn of i915.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 2/5] xf86drm: implement drmParseSubsystemType for OpenBSD
Quoted 17 lines · Jonathan Gray
Quoted 16 lines · Emil Velikov
Quoted 5 lines · Jonathan Gray
Implement drmParseSubsystemType for OpenBSD by always returning
DRM_BUS_PCI. No non-pci drm drivers are in the kernel and this is unlikely to change anytime soon as the existing ones aren't permissively licensed.A few noticeable X11 MIT style licensed drivers include qxl, vgem and virtio. Two of which PCI ones and vgem in it's own unique category ;-)
There was a question about re-licensing [some] drivers a few years ago at XDC in France. IIRC devs were fine with it, yet it doesn't seem like things changed much.
Have you/fellow BSD developers considered reaching out [as a group] to interesteddrivers/developers? Pardon if I've already mentioned/already asked about this.
Quoted 6 lines
Quoted 2 lines
Thanks
EmilThere is no particular driver, cirrus, gma500 etc might be nice but really what limited spare time we have that involves drm is dealt dealing with the constant churn of i915.
Ack. AFAICT keeping track is a slightly different ball-game, which does eat a lot of time.
<offtopic>
Consider reusing/sharing of the kernel compat layer that FreeBSD and others did. If you haven't already.
As one starts incrementally picking each [git] commit it should be easier to track regressions and pick fixes.
</offtopic>
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 xf86drm: implement drmParsePciDeviceInfo for OpenBSD
In reply to Jonathan GrayImplement drmParsePciDeviceInfo for OpenBSD by using the new DRM_IOCTL_GET_PCIINFO ioctl.
--- xf86drm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
xf86drm.c +51 -0
@@ -102,6 +102,26 @@#define DRM_MAJOR 226/* Linux */ #endif +#ifdef __OpenBSD__ + +#define X_PRIVSEP + +struct drm_pciinfo { +uint16_t domain; +uint8_t bus; +uint8_t dev; +uint8_t func; +uint16_t vendor_id; +uint16_t device_id; +uint16_t subvendor_id; +uint16_t subdevice_id; +uint8_t revision_id; +}; + +#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo) + +#endif +#define DRM_MSG_VERBOSITY 3#define memclear (s) memset(&s, 0, sizeof(s))
@@ -2991,6 +3011,37 @@ static int drmParsePciDeviceInfo(const char *d_name, device->subdevice_id = config[46 ] | (config[47 ] <<8 );return 0 ; +#elif defined(__OpenBSD__) +struct drm_pciinfo pinfo; +char buf[PATH_MAX +1 ]; +int fd, n; + + n =snprintf (buf,sizeof (buf),"%s/%s" ,DRM_DIR_NAME , d_name); +if (n ==-1 || n >=sizeof (buf)) +return -errno; + +#ifndef X_PRIVSEP + fd =open (buf,O_RDWR ,0 ); +#else + fd =priv_open_device (buf); +#endif + +if (fd <0 ) +return -errno; + +if (drmIoctl (fd,DRM_IOCTL_GET_PCIINFO , &pinfo)) { +close (fd); +return -errno; + } +close (fd); + + device->vendor_id = pinfo.vendor_id; + device->device_id = pinfo.device_id; + device->revision_id = pinfo.revision_id; + device->subvendor_id = pinfo.subvendor_id; + device->subdevice_id = pinfo.subdevice_id; + +return 0 ;#else #warning "Missing implementation of drmParsePciDeviceInfo"return -EINVAL ;
Signature · 6 lines
2.10.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 3/5] xf86drm: implement drmParsePciDeviceInfo for OpenBSD
Quoted 48 lines · Jonathan Gray
Implement drmParsePciDeviceInfo for OpenBSD by using the new
DRM_IOCTL_GET_PCIINFOioctl.Signed-off-by Jonathan Gray <[email protected]>--- xf86drm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)xf86drm.c +25
-0@@ -102,6 +102,26 @@#define DRM_MAJOR 226/* Linux */ #endif +#ifdef __OpenBSD__ + +#define X_PRIVSEP + +struct drm_pciinfo { +uint16_t domain; +uint8_t bus; +uint8_t dev; +uint8_t func; +uint16_t vendor_id; +uint16_t device_id; +uint16_t subvendor_id; +uint16_t subdevice_id; +uint8_t revision_id; +}; + +#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo) + +#endif +#define DRM_MSG_VERBOSITY 3#define memclear (s) memset(&s, 0, sizeof(s))@@ -2991,6 +3011,37 @@ static int drmParsePciDeviceInfo(const char *d_name, device->subdevice_id = config[46 ] | (config[47 ] <<8 );return 0 ; +#elif defined(__OpenBSD__) +struct drm_pciinfo pinfo; +char buf[PATH_MAX +1 ]; +int fd, n; +
xf86drm.c static int drmParsePciDeviceInfo(const char *d_name, · line 3028
Quoted 10 lines
xf86drm.c +10
-0+ n =snprintf (buf,sizeof (buf),"%s/%s" ,DRM_DIR_NAME , d_name); +if (n ==-1 || n >=sizeof (buf)) +return -errno; + +#ifndef X_PRIVSEP + fd =open (buf,O_RDWR ,0 ); +#else + fd =priv_open_device (buf); +#endif +
Since X_PRIVSEP is always set one can drop the ifndef case alongside the define X_PRIVSEP all together. At the same time, priv_open_device isn't defined thus one might well use drmOpenMinor() like in 4/5 ?
Sidenote: In the future we might fold drmParsePciBusInfo and drmParsePciDeviceInfo, but for the moment we have to keep them separate :-(
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 3/5] xf86drm: implement drmParsePciDeviceInfo for OpenBSD
Quoted 54 lines · Emil Velikov
Quoted 53 lines · Jonathan Gray
Implement drmParsePciDeviceInfo for OpenBSD by using the new
DRM_IOCTL_GET_PCIINFOioctl.Signed-off-by Jonathan Gray <[email protected]>--- xf86drm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)xf86drm.c +30
-0@@ -102,6 +102,26 @@#define DRM_MAJOR 226/* Linux */ #endif +#ifdef __OpenBSD__ + +#define X_PRIVSEP + +struct drm_pciinfo { +uint16_t domain; +uint8_t bus; +uint8_t dev; +uint8_t func; +uint16_t vendor_id; +uint16_t device_id; +uint16_t subvendor_id; +uint16_t subdevice_id; +uint8_t revision_id; +}; + +#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo) + +#endif +#define DRM_MSG_VERBOSITY 3#define memclear (s) memset(&s, 0, sizeof(s))@@ -2991,6 +3011,37 @@ static int drmParsePciDeviceInfo(const char *d_name, device->subdevice_id = config[46 ] | (config[47 ] <<8 );return 0 ; +#elif defined(__OpenBSD__) +struct drm_pciinfo pinfo; +char buf[PATH_MAX +1 ]; +int fd, n; + + n =snprintf (buf,sizeof (buf),"%s/%s" ,DRM_DIR_NAME , d_name); +if (n ==-1 || n >=sizeof (buf)) +return -errno; + +#ifndef X_PRIVSEP
Quoted 8 lines
xf86drm.c static int drmParsePciDeviceInfo(const char *d_name, · line 3028
Quoted 5 lines
xf86drm.c +5
-0+ fd =open (buf,O_RDWR ,0 ); +#else + fd =priv_open_device (buf); +#endif +Since
X_PRIVSEPis always set one can drop the ifndef case alongside the defineX_PRIVSEPall together. At the same time,priv_open_deviceisn't defined thus one might well usedrmOpenMinor()like in 4/5 ?
Then we'd have to find a minor number and type based on the d_name string argument to drmParsePciDeviceInfo. The priv_open_device part is really a different patch.
Quoted 4 lines
Sidenote: In the future we might fold drmParsePciBusInfo and drmParsePciDeviceInfo, but for the moment we have to keep them separate :-(
Annoying that one takes a minor and one takes a string...
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 3/5] xf86drm: implement drmParsePciDeviceInfo for OpenBSD
Quoted 69 lines · Jonathan Gray
Quoted 54 lines · Emil Velikov
Quoted 53 lines · Jonathan Gray
Implement drmParsePciDeviceInfo for OpenBSD by using the new
DRM_IOCTL_GET_PCIINFOioctl.Signed-off-by Jonathan Gray <[email protected]>--- xf86drm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)xf86drm.c +30
-0@@ -102,6 +102,26 @@#define DRM_MAJOR 226/* Linux */ #endif +#ifdef __OpenBSD__ + +#define X_PRIVSEP + +struct drm_pciinfo { +uint16_t domain; +uint8_t bus; +uint8_t dev; +uint8_t func; +uint16_t vendor_id; +uint16_t device_id; +uint16_t subvendor_id; +uint16_t subdevice_id; +uint8_t revision_id; +}; + +#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo) + +#endif +#define DRM_MSG_VERBOSITY 3#define memclear (s) memset(&s, 0, sizeof(s))@@ -2991,6 +3011,37 @@ static int drmParsePciDeviceInfo(const char *d_name, device->subdevice_id = config[46 ] | (config[47 ] <<8 );return 0 ; +#elif defined(__OpenBSD__) +struct drm_pciinfo pinfo; +char buf[PATH_MAX +1 ]; +int fd, n; + + n =snprintf (buf,sizeof (buf),"%s/%s" ,DRM_DIR_NAME , d_name); +if (n ==-1 || n >=sizeof (buf)) +return -errno; + +#ifndef X_PRIVSEP Quoted 8 lines
xf86drm.c static int drmParsePciDeviceInfo(const char *d_name, · line 3028
Quoted 5 lines
xf86drm.c +5
-0+ fd =open (buf,O_RDWR ,0 ); +#else + fd =priv_open_device (buf); +#endif +Since
X_PRIVSEPis always set one can drop the ifndef case alongside the defineX_PRIVSEPall together. At the same time,priv_open_deviceisn't defined thus one might well usedrmOpenMinor()like in 4/5 ?Then we'd have to find a minor number and type based on the
d_namestring argument to drmParsePciDeviceInfo. Thepriv_open_devicepart is really a different patch.Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Sidenote: In the future we might fold drmParsePciBusInfo and drmParsePciDeviceInfo, but for the moment we have to keep them separate :-(
Annoying that one takes a minor and one takes a string...
It's a po-tay-to po-tah-to case on our end :-) A maj/min pair seems better, patch coming in a bit.
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/5 xf86drm: implement drmParsePciBusInfo for OpenBSD
In reply to Jonathan GrayImplement drmParsePciBusInfo for OpenBSD by using the new DRM_IOCTL_GET_PCIINFO ioctl.
--- xf86drm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
xf86drm.c +20 -0
@@ -2936,6 +2936,26 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) info->func = func;return 0 ; +#elif defined(__OpenBSD__) +struct drm_pciinfo pinfo; +int fd; + + fd =drmOpenMinor (min,0 ,DRM_NODE_PRIMARY ); +if (fd <0 ) +return -errno; + +if (drmIoctl (fd,DRM_IOCTL_GET_PCIINFO , &pinfo)) { +close (fd); +return -errno; + } +close (fd); + + info->domain = pinfo.domain; + info->bus = pinfo.bus; + info->dev = pinfo.dev; + info->func = pinfo.func; + +return 0 ;#else #warning "Missing implementation of drmParsePciBusInfo"return -EINVAL ;
Signature · 6 lines
2.10.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/5 xf86drm: implement an OpenBSD specific drmGetDevice
In reply to Jonathan GrayThis avoids walking all of /dev and directly maps the fd to a path to a primary node.
--- xf86drm.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
xf86drm.c +41 -0
@@ -3175,6 +3175,46 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count)*/ int drmGetDevice (int fd,drmDevicePtr *device) { +#ifdef __OpenBSD__ +drmDevicePtr d; +struct stat sbuf; +char node[PATH_MAX +1 ]; +char d_name[PATH_MAX +1 ]; +int maj, min, n; +int ret; +int max_count =1 ; + +if (fd ==-1 || device ==NULL ) +return -EINVAL ; + +if (fstat (fd, &sbuf)) +return -errno; + + maj =major (sbuf.st_rdev); + min =minor (sbuf.st_rdev); + +if (maj !=DRM_MAJOR || !S_ISCHR (sbuf.st_mode)) +return -EINVAL ; + + n =snprintf (d_name,PATH_MAX ,"drm%d" , min); +if (n ==-1 || n >=PATH_MAX ) +return -errno; + + n =snprintf (node,PATH_MAX ,DRM_DEV_NAME ,DRM_DIR_NAME , min); +if (n ==-1 || n >=PATH_MAX ) +return -errno; +if (stat (node, &sbuf)) +return -EINVAL ; + + ret =drmProcessPciDevice (&d, d_name, node,DRM_NODE_PRIMARY , + maj, min, true); +if (ret) +return ret; + + *device = d; + +return 0 ; +#else drmDevicePtr *local_devices;drmDevicePtr d;DIR *sysdir;
@@ -3282,6 +3322,7 @@ free_devices: free_locals:free (local_devices);return ret; +#endif }/**
Signature · 6 lines
2.10.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 5/5] xf86drm: implement an OpenBSD specific drmGetDevice
Quoted 3 lines · Jonathan Gray
This avoids walking all of /dev and directly maps the fd to a path to a primary node.
I realise that the code is pretty ugly/bad/etc, but I would stay way from similar optimisations. As-is it will just work as you guys get support for render nodes/other.
That is unless things are noticeably slow [or bad in general].
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 5/5] xf86drm: implement an OpenBSD specific drmGetDevice
Quoted 11 lines · Emil Velikov
Quoted 3 lines · Jonathan Gray
This avoids walking all of /dev and directly maps the fd to a path to a primary node.
I realise that the code is pretty ugly/bad/etc, but I would stay way from similar optimisations. As-is it will just work as you guys get support for render nodes/other.
That is unless things are noticeably slow [or bad in general].Thanks
Emil
/dev/ has 1200 files on a machine here, drm nodes aren't in a drm specific directory as on linux.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH libdrm 5/5] xf86drm: implement an OpenBSD specific drmGetDevice
Quoted 10 lines · Jonathan Gray
Quoted 9 lines · Emil Velikov
Quoted 3 lines · Jonathan Gray
This avoids walking all of /dev and directly maps the fd to a path to a primary node.
I realise that the code is pretty ugly/bad/etc, but I would stay way from similar optimisations. As-is it will just work as you guys get support for render nodes/other.
That is unless things are noticeably slow [or bad in general].
Quoted 5 lines
Quoted 2 lines
Thanks
Emil
/dev/has 1200 files on a machine here, drm nodes aren't in a drm specific directory as on linux.
Eeek ...1200, there's only ~160 over here.
Is it against OpenBSD policy/philosophy to nest things (using sub-folders), a matter of carefully updating this to avoid breakage (shortage to time/manpower), or it's mostly a matter of personal taste ?
Regardless of the reason, please include your comment in the code. Also please mention that this works only for card nodes. And don't forget the (dummy) drmParseSubsystemType call.
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 26 lines · Jonathan Gray
Implement drmGetMinorNameForFD for systems without sysfs by adapting
drm_get_device_name_for_fd()from the Mesa loader.Signed-off-by Jonathan Gray <[email protected]>--- xf86drm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)xf86drm.c +9
-1@@ -2818,7 +2818,25 @@ static char *drmGetMinorNameForFD(int fd, int type) out_close_dir:closedir (sysdir);#else -#warning "Missing implementation of drmGetMinorNameForFD" +struct stat sbuf; +unsigned int maj, min; +char buf[PATH_MAX +1 ]; +int n; + +if (fstat (fd, &sbuf)) +return NULL ; + + maj =major (sbuf.st_rdev);
xf86drm.c static char *drmGetMinorNameForFD(int fd, int type) · line 2839
Quoted 10 lines
xf86drm.c +10
-0+ min =minor (sbuf.st_rdev); + +if (maj !=DRM_MAJOR || !S_ISCHR (sbuf.st_mode)) +return NULL ; + + n =snprintf (buf,sizeof (buf),DRM_DEV_NAME ,DRM_DIR_NAME , min); +if (n ==-1 || n >=sizeof (buf)) +return NULL ; + +return strdup (buf);
Doesn't look too good I'm afraid:
- you ignore the node type, making the whole helper and API that
depends on it useless.
Note: mesa wants to know the render node name for the given fd. We can replace with drmGetDevice but I'd like to check the double-auth [and related fun] trimming things down before changing things.
- implementation seems identical to drmGetDeviceNameFromFd(). Barring
a few trivial bits of course.
Speaking of which there is drmGetDeviceNameFromFd2 which attributes for any node type(s) - the present primary, control and render plus any future ones.
I'm leaning towards using it in the next (or one after) version in mesa.
Have you and fellow OpenBSD developers considered render nodes. Do you have any preliminary ideas how it will be exposed, such that you can build a comprehensive interface here ?
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 35 lines · Emil Velikov
Quoted 34 lines · Jonathan Gray
Implement drmGetMinorNameForFD for systems without sysfs by adapting
drm_get_device_name_for_fd()from the Mesa loader.Signed-off-by Jonathan Gray <[email protected]>--- xf86drm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)xf86drm.c +17
-1@@ -2818,7 +2818,25 @@ static char *drmGetMinorNameForFD(int fd, int type) out_close_dir:closedir (sysdir);#else -#warning "Missing implementation of drmGetMinorNameForFD" +struct stat sbuf; +unsigned int maj, min; +char buf[PATH_MAX +1 ]; +int n; + +if (fstat (fd, &sbuf)) +return NULL ; + + maj =major (sbuf.st_rdev); + min =minor (sbuf.st_rdev); + +if (maj !=DRM_MAJOR || !S_ISCHR (sbuf.st_mode)) +return NULL ; + + n =snprintf (buf,sizeof (buf),DRM_DEV_NAME ,DRM_DIR_NAME , min); +if (n ==-1 || n >=sizeof (buf)) +return NULL ;
Quoted 8 lines
xf86drm.c static char *drmGetMinorNameForFD(int fd, int type) · line 2839
Quoted 2 lines
xf86drm.c +2
-0+ +return strdup (buf);Doesn't look too good I'm afraid:
- you ignore the node type, making the whole helper and API that
depends on it useless.
Note: mesa wants to know the render node name for the given fd. We can replace with drmGetDevice but I'd like to check the double-auth [and related fun] trimming things down before changing things.
It could be changed to handle the type along the lines of
base = drmGetMinorBase(type);
if (min < base)
return -EINVAL;
switch (type) {
case DRM_NODE_PRIMARY:
dev_name = DRM_DEV_NAME;
break;
case DRM_NODE_CONTROL:
dev_name = DRM_CONTROL_DEV_NAME;
break;
case DRM_NODE_RENDER:
dev_name = DRM_RENDER_DEV_NAME;
break;
default:
return -EINVAL;
};
n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);Quoted 8 lines
- implementation seems identical to
drmGetDeviceNameFromFd(). Barring
a few trivial bits of course.
Speaking of which there is drmGetDeviceNameFromFd2 which attributes for any node type(s) - the present primary, control and render plus any future ones.
I'm leaning towards using it in the next (or one after) version in mesa.
Quoted 6 lines
Have you and fellow OpenBSD developers considered render nodes. Do you have any preliminary ideas how it will be exposed, such that you can build a comprehensive interface here ?
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 59 lines · Jonathan Gray
Quoted 35 lines · Emil Velikov
Quoted 34 lines · Jonathan Gray
Implement drmGetMinorNameForFD for systems without sysfs by adapting
drm_get_device_name_for_fd()from the Mesa loader.Signed-off-by Jonathan Gray <[email protected]>--- xf86drm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)xf86drm.c +17
-1@@ -2818,7 +2818,25 @@ static char *drmGetMinorNameForFD(int fd, int type) out_close_dir:closedir (sysdir);#else -#warning "Missing implementation of drmGetMinorNameForFD" +struct stat sbuf; +unsigned int maj, min; +char buf[PATH_MAX +1 ]; +int n; + +if (fstat (fd, &sbuf)) +return NULL ; + + maj =major (sbuf.st_rdev); + min =minor (sbuf.st_rdev); + +if (maj !=DRM_MAJOR || !S_ISCHR (sbuf.st_mode)) +return NULL ; + + n =snprintf (buf,sizeof (buf),DRM_DEV_NAME ,DRM_DIR_NAME , min); +if (n ==-1 || n >=sizeof (buf)) +return NULL ;Quoted 8 lines
xf86drm.c static char *drmGetMinorNameForFD(int fd, int type) · line 2839
Quoted 2 lines
xf86drm.c +2
-0+ +return strdup (buf);Doesn't look too good I'm afraid:
- you ignore the node type, making the whole helper and API that
depends on it useless.
Note: mesa wants to know the render node name for the given fd. We can replace with drmGetDevice but I'd like to check the double-auth [and related fun] trimming things down before changing things.It could be changed to handle the type along the lines of
base = drmGetMinorBase(type); if (min < base) return -EINVAL; switch (type) { case DRM_NODE_PRIMARY: dev_name = DRM_DEV_NAME; break; case DRM_NODE_CONTROL: dev_name = DRM_CONTROL_DEV_NAME; break;
Quoted 9 lines
case DRM_NODE_RENDER:
dev_name = DRM_RENDER_DEV_NAME;
break;
default:
return -EINVAL;
};
n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);Far better, thanks !
Quoted 8 lines
Quoted 8 lines
- implementation seems identical to
drmGetDeviceNameFromFd(). Barring
a few trivial bits of course.
Speaking of which there is drmGetDeviceNameFromFd2 which attributes for any node type(s) - the present primary, control and render plus any future ones.
I'm leaning towards using it in the next (or one after) version in mesa.
Quoted 4 lines
Quoted 4 lines
Have you and fellow OpenBSD developers considered render nodes. Do you have any preliminary ideas how it will be exposed, such that you can build a comprehensive interface here ?
... and to answer my question - the control/render node names are already set/defined for OpenBSD.
Memory is failing :-\
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel