Created attachment 186436 [details] linsysfs_drm.patch This patch exposes more information about PCI devices (and GPUs in particular) via linsysfs (and linux_common). This allows unmodified modern 64-bit Linux libdrm to work, which allows modern Linux Mesa to work. Tested with an Ubuntu 16.04 chroot + amdgpu from graphics/drm-next-kmod. libdrm code that reads these files: https://cgit.freedesktop.org/mesa/drm/tree/xf86drm.c?id=libdrm-2.4.83
Patch mostly looks good to me. I'd remove the useless comments above fillers for the simple data/device/vendor/etc ones (but keep for uevent_foo and vgapci). I'd replace strncpy() in linsysfs_fill_vgapci with strlcpy(). I don't think this routine behaves correctly at the limit due to strncpy() and the "%s" format string use. (Also, strncpy() unnecessarily zero-fills the remainder of the buffer, which isn't needed on every loop iteration.) This module should use its own malloc type, rather than M_TEMP, but that matches the existing pattern so it doesn't need to be changed. Indentation seems funky on line 351 in the new file, but that might just be bugzilla. MAXPATHLEN is hugely excessive for chardevname.
Created attachment 186477 [details] linsysfs_drm.patch (v2) (In reply to Conrad Meyer from comment #1) Nice, didn't know strlcpy was available in the kernel, I just assumed it wasn't. Uploaded new version.
Created attachment 186478 [details] linsysfs_drm.patch (v3) Oops, forgot to remove the sys/ctype.h include from linux_util — it was for handling differently named symlinks in /dev/dri (finding the first digit), but that wasn't necessary (and didn't even work).
Indentation here is still wrong: + if (devclass != NULL) + name = devclass_get_name(devclass); Otherwise, LGTM. And, thanks! :-)
Created attachment 186483 [details] linsysfs_drm.patch (v4) Oh, there. Fixed.
A commit references this bug: Author: cem Date: Sun Sep 17 23:40:16 UTC 2017 New revision: 323692 URL: https://svnweb.freebsd.org/changeset/base/323692 Log: linsysfs(5): Add support for recent libdrm Expose more information about PCI devices (and GPUs in particular) via linsysfs to libdrm. This allows unmodified modern 64-bit Linux libdrm to work, which allows modern Linux Mesa to work. The submitter reports that he tested the change with an Ubuntu 16.04 chroot + amdgpu from graphics/drm-next-kmod. PR: 222375 Submitted by: Greg V <greg AT unrelenting.technology> Changes: head/sys/compat/linsysfs/linsysfs.c head/sys/compat/linux/linux_util.c
BTW, forgot to say — for anyone actually trying to run Linux games and stuff: you'll probably need to set LIBGL_DRI3_DISABLE=1 in your Linux environment. For some reason only DRI2 works with Linux apps for me (even though DRI3 works fine for native apps).