Skip to contentSkip to conversation

libdrm: Fix drmNodeIsDRM() on DragonFly

PATCH In review François Tigeot 3 participants 4 messages Dec 11, 2018 – Dec 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libdrm: Fix drmNodeIsDRM() on DragonFly

* There is no way to check if a device name is really a drm device by looking it up in a virtual filesystem like on Linux

* The major device number is also dynamically allocated from a pool, comparing it to a constant makes no sense

* In the absence of better ideas, just assume the device name really points to a drm device and always return true

---
 xf86drm.c | 2 ++
 1 file changed, 2 insertions(+)
xf86drm.c +2 -0
index 71ad54ba..0085bf17 100644
@@ -2778,6 +2778,8 @@ static bool drmNodeIsDRM(int maj, int min)
     snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/drm",
              maj, min);
     return stat(path, &sbuf) == 0;
+#elif __DragonFly__
+    return true;	/* DragonFly BSD has no fixed major device numbers */
 #else
     return maj == DRM_MAJOR;
 #endif
Signature · 6 lines
2.19.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 10 lines · François Tigeot

* There is no way to check if a device name is really a drm device by looking it up in a virtual filesystem like on Linux

* The major device number is also dynamically allocated from a pool, comparing it to a constant makes no sense

* In the absence of better ideas, just assume the device name really points to a drm device and always return true

I guess one could use the sysfs path, although that may require a few extra lines to the linux emulation layer.

What's the reason behind the dynamic allocation of the major? FWIW some userspace requires a fixed DRM_MAJOR - they will need patching to run :-(

Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 5 lines · Emil Velikov
Quoted 4 lines · François Tigeot

* There is no way to check if a device name is really a drm device by looking it up in a virtual filesystem like on Linux

Quoted 8 lines
Quoted 6 lines

* The major device number is also dynamically allocated from a pool, comparing it to a constant makes no sense

* In the absence of better ideas, just assume the device name really points to a drm device and always return true

I guess one could use the sysfs path, although that may require a few extra lines to the linux emulation layer.

We currently have such a thing living in local patches and it's a source of pain; it regularly breaks for one reason or another.
It's not using sysfs but a hw.dri sysctl mechanism originating from FreeBSD. Some of the patches are visible here:
https://github.com/DragonFlyBSD/DPorts/blob/master/graphics/libdrm/files/patch-xf86drm.c

Quoted 3 lines

What's the reason behind the dynamic allocation of the major? FWIW some userspace requires a fixed DRM_MAJOR - they will need patching to run :-(

Major/minor numbers were required when device files had to be created on regular filesystem like UFS but when a devfs filesystem was implemented for DragonFly almost a decade ago, nobody thought it was important anymore.

There have been no fixed major numbers on DragonFly since 2009 or so.

Signature · 5 lines
Francois Tigeot
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 12 lines · Francois Tigeot
Quoted 11 lines · Emil Velikov
Quoted 10 lines · François Tigeot

* There is no way to check if a device name is really a drm device by looking it up in a virtual filesystem like on Linux

* The major device number is also dynamically allocated from a pool, comparing it to a constant makes no sense

* In the absence of better ideas, just assume the device name really points to a drm device and always return true

Quoted 8 lines
Quoted 2 lines

I guess one could use the sysfs path, although that may require a few extra lines to the linux emulation layer.

We currently have such a thing living in local patches and it's a source of pain; it regularly breaks for one reason or another.
It's not using sysfs but a hw.dri sysctl mechanism originating from FreeBSD. Some of the patches are visible here:
https://github.com/DragonFlyBSD/DPorts/blob/master/graphics/libdrm/files/patch-xf86drm.c

I'm going through those right now, and I'll send patches for those that make sense upstream. Apologies in advance for the rebase pains :]

Quoted 10 lines
Quoted 4 lines

What's the reason behind the dynamic allocation of the major? FWIW some userspace requires a fixed DRM_MAJOR - they will need patching to run :-(

Major/minor numbers were required when device files had to be created on regular filesystem like UFS but when a devfs filesystem was implemented for DragonFly almost a decade ago, nobody thought it was important anymore.

There have been no fixed major numbers on DragonFly since 2009 or so.

Fwiw, this if dragonfly return true patch is:

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel