FreeBSD Bugzilla – Attachment 186436 Details for
Bug 222375
[linux][linsysfs] Support for libdrm/Mesa
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
linsysfs_drm.patch
linsysfs_drm.patch (text/plain), 8.18 KB, created by
Val Packett
on 2017-09-16 19:56:45 UTC
(
hide
)
Description:
linsysfs_drm.patch
Filename:
MIME Type:
Creator:
Val Packett
Created:
2017-09-16 19:56:45 UTC
Size:
8.18 KB
patch
obsolete
>diff --git i/sys/compat/linsysfs/linsysfs.c w/sys/compat/linsysfs/linsysfs.c >index d771b46d965..4622ab6973b 100644 >--- i/sys/compat/linsysfs/linsysfs.c >+++ w/sys/compat/linsysfs/linsysfs.c >@@ -133,19 +133,133 @@ linsysfs_link_scsi_host(PFS_FILL_ARGS) > return (0); > } > >-#define PCI_DEV "pci" >+/* >+ * Filler function for custom strings >+ */ > static int >-linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, char *path, >- char *prefix) >+linsysfs_fill_data(PFS_FILL_ARGS) >+{ >+ sbuf_printf(sb, "%s", pn->pn_data); >+ return (0); >+} >+ >+/* >+ * Filler function for PCI vendor >+ */ >+static int >+linsysfs_fill_vendor(PFS_FILL_ARGS) >+{ >+ sbuf_printf(sb, "0x%04x\n", pci_get_vendor((device_t)pn->pn_data)); >+ return (0); >+} >+ >+/* >+ * Filler function for PCI device >+ */ >+static int >+linsysfs_fill_device(PFS_FILL_ARGS) >+{ >+ sbuf_printf(sb, "0x%04x\n", pci_get_device((device_t)pn->pn_data)); >+ return (0); >+} >+ >+/* >+ * Filler function for PCI subvendor >+ */ >+static int >+linsysfs_fill_subvendor(PFS_FILL_ARGS) >+{ >+ sbuf_printf(sb, "0x%04x\n", pci_get_subvendor((device_t)pn->pn_data)); >+ return (0); >+} >+ >+/* >+ * Filler function for PCI subdevice >+ */ >+static int >+linsysfs_fill_subdevice(PFS_FILL_ARGS) >+{ >+ sbuf_printf(sb, "0x%04x\n", pci_get_subdevice((device_t)pn->pn_data)); >+ return (0); >+} >+ >+/* >+ * Filler function for PCI revid >+ */ >+static int >+linsysfs_fill_revid(PFS_FILL_ARGS) >+{ >+ sbuf_printf(sb, "0x%x\n", pci_get_revid((device_t)pn->pn_data)); >+ return (0); >+} >+ >+/* >+ * Filler function for PCI uevent >+ */ >+static int >+linsysfs_fill_uevent_pci(PFS_FILL_ARGS) >+{ >+ device_t dev = (device_t)pn->pn_data; >+ sbuf_printf(sb, "DRIVER=%s\nPCI_CLASS=%X\nPCI_ID=%04X:%04X\n" >+ "PCI_SUBSYS_ID=%04X:%04X\nPCI_SLOT_NAME=%04d:%02x:%02x.%x\n", >+ linux_driver_get_name_dev(dev), >+ pci_get_class(dev), >+ pci_get_vendor(dev), pci_get_device(dev), >+ pci_get_subvendor(dev), pci_get_subdevice(dev), >+ pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev)); >+ return (0); >+} >+ >+/* >+ * Filler function for drm uevent >+ */ >+static int >+linsysfs_fill_uevent_drm(PFS_FILL_ARGS) >+{ >+ device_t dev = (device_t)pn->pn_data; >+ int unit = device_get_unit(dev); >+ sbuf_printf(sb, "MAJOR=226\nMINOR=%d\nDEVNAME=drm/%d\nDEVTYPE=dri_minor\n", >+ unit, unit); >+ return (0); >+} >+ >+ >+/* >+ * Filler function for symlink from drm char device to PCI device >+ */ >+static int >+linsysfs_fill_vgapci(PFS_FILL_ARGS) >+{ >+ struct pfs_node *cur = (struct pfs_node*)pn->pn_data; >+ char *temp = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); >+ char *path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); >+ path[0] = '\0'; >+ do { >+ snprintf(temp, MAXPATHLEN, "%s/%s", cur->pn_name, path); >+ strncpy(path, temp, MAXPATHLEN); >+ cur = cur->pn_parent; >+ } while (cur->pn_parent); >+ path[strnlen(path, MAXPATHLEN) - 1] = '\0'; /* remove extra slash */ >+ sbuf_printf(sb, "../../../%s", path); >+ free(path, M_TEMP); >+ free(temp, M_TEMP); >+ return (0); >+} >+ >+#define PCI_DEV "pci" >+#define DRMN_DEV "drmn" >+static int >+linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, struct pfs_node *chardev, >+ char *path, char *prefix) > { > struct scsi_host_queue *scsi_host; >- struct pfs_node *sub_dir; >+ struct pfs_node *sub_dir, *cur_file, *cur_chardev; > int i, nchildren; > device_t *children, parent; > devclass_t devclass; > const char *name = NULL; >- struct pci_devinfo *dinfo; >- char *device, *host, *new_path = path; >+ struct pci_devinfo *dinfo = NULL; >+ char *device, *host, *new_path = path, *chardevname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); > > parent = device_get_parent(dev); > if (parent) { >@@ -171,6 +285,28 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, char > strcat(new_path, device); > dir = pfs_create_dir(dir, device, > NULL, NULL, NULL, 0); >+ cur_file = pfs_create_file(dir, "vendor", >+ &linsysfs_fill_vendor, NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ cur_file = pfs_create_file(dir, "device", >+ &linsysfs_fill_device, NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ cur_file = pfs_create_file(dir, "subsystem_vendor", >+ &linsysfs_fill_subvendor, NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ cur_file = pfs_create_file(dir, "subsystem_device", >+ &linsysfs_fill_subdevice, NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ cur_file = pfs_create_file(dir, "revision", >+ &linsysfs_fill_revid, NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ cur_file = pfs_create_file(dir, "uevent", >+ &linsysfs_fill_uevent_pci, NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ cur_file = pfs_create_link(dir, "subsystem", >+ &linsysfs_fill_data, NULL, NULL, NULL, 0); >+ /* libdrm just checks that the link ends in "/pci" */ >+ cur_file->pn_data = "/sys/bus/pci"; > > if (dinfo->cfg.baseclass == PCIC_STORAGE) { > /* DJA only make this if needed */ >@@ -207,15 +343,33 @@ linsysfs_run_bus(device_t dev, struct pfs_node *dir, struct pfs_node *scsi, char > free(host, M_TEMP); > } > } >+ >+ dinfo = device_get_ivars(parent); >+ if (dinfo && dinfo->cfg.baseclass == PCIC_DISPLAY) { >+ devclass = device_get_devclass(dev); >+ if (devclass != NULL) >+ name = devclass_get_name(devclass); >+ if (name && strcmp(name, DRMN_DEV) == 0 && device_get_unit(dev) >= 0) { >+ sprintf(chardevname, "226:%d", device_get_unit(dev)); >+ cur_chardev = pfs_create_dir(chardev, chardevname, NULL, NULL, NULL, 0); >+ cur_file = pfs_create_link(cur_chardev, "device", &linsysfs_fill_vgapci, >+ NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dir; >+ cur_file = pfs_create_file(cur_chardev, "uevent", &linsysfs_fill_uevent_drm, >+ NULL, NULL, NULL, PFS_RD); >+ cur_file->pn_data = (void*)dev; >+ } >+ } > } > > device_get_children(dev, &children, &nchildren); > for (i = 0; i < nchildren; i++) { > if (children[i]) >- linsysfs_run_bus(children[i], dir, scsi, new_path, prefix); >+ linsysfs_run_bus(children[i], dir, scsi, chardev, new_path, prefix); > } > if (new_path != path) > free(new_path, M_TEMP); >+ free(chardevname, M_TEMP); > > return (1); > } >@@ -279,6 +433,7 @@ linsysfs_init(PFS_INIT_ARGS) > struct pfs_node *dir, *sys, *cpu; > struct pfs_node *pci; > struct pfs_node *scsi; >+ struct pfs_node *devdir, *chardev; > devclass_t devclass; > device_t dev; > >@@ -296,13 +451,17 @@ linsysfs_init(PFS_INIT_ARGS) > /* /sys/devices/pci0000:00 */ > pci = pfs_create_dir(dir, "pci0000:00", NULL, NULL, NULL, 0); > >+ /* /sys/dev/char */ >+ devdir = pfs_create_dir(root, "dev", NULL, NULL, NULL, 0); >+ chardev = pfs_create_dir(devdir, "char", NULL, NULL, NULL, 0); >+ > devclass = devclass_find("root"); > if (devclass == NULL) { > return (0); > } > > dev = devclass_get_device(devclass, 0); >- linsysfs_run_bus(dev, pci, scsi, "/pci0000:00", "0000"); >+ linsysfs_run_bus(dev, pci, scsi, chardev, "/pci0000:00", "0000"); > > /* /sys/devices/system */ > sys = pfs_create_dir(dir, "system", NULL, NULL, NULL, 0); >diff --git i/sys/compat/linux/linux_util.c w/sys/compat/linux/linux_util.c >index 466c588157c..f0ac309b669 100644 >--- i/sys/compat/linux/linux_util.c >+++ w/sys/compat/linux/linux_util.c >@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); > > #include "opt_compat.h" > >+#include <sys/ctype.h> > #include <sys/param.h> > #include <sys/bus.h> > #include <sys/fcntl.h> >@@ -127,14 +128,13 @@ int > linux_driver_get_major_minor(const char *node, int *major, int *minor) > { > struct device_element *de; >+ unsigned long devno; > > if (node == NULL || major == NULL || minor == NULL) > return 1; > > if (strlen(node) > strlen("pts/") && > strncmp(node, "pts/", strlen("pts/")) == 0) { >- unsigned long devno; >- > /* > * Linux checks major and minors of the slave device > * to make sure it's a pty device, so let's make him >@@ -147,6 +147,16 @@ linux_driver_get_major_minor(const char *node, int *major, int *minor) > return (0); > } > >+ if ((strlen(node) > strlen("drm/") && >+ strncmp(node, "drm/", strlen("drm/")) == 0) ) { >+ devno = strtoul(node + strlen("drm/"), NULL, 10); >+ *major = 226 + (devno / 256); >+ *minor = devno % 256; >+ >+ return (0); >+ } >+ >+ > TAILQ_FOREACH(de, &devices, list) { > if (strcmp(node, de->entry.bsd_device_name) == 0) { > *major = de->entry.linux_major;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 222375
:
186436
|
186477
|
186478
|
186483