FreeBSDDesktop / kms-drm

the DRM part of the linuxkpi-based KMS
63 stars 26 forks source link

FIXME: lkpi dev_is_pci() function missing #63

Open johalun opened 6 years ago

johalun commented 6 years ago

Currently assuming PCI. Need to impl dev_is_pci() or workaround.

https://github.com/FreeBSDDesktop/kms-drm/blob/drm-v4.15/drivers/gpu/drm/drm_ioctl.c#L150

juikim commented 5 years ago

The following patch is not generic but it should do for drm.

--- drivers/gpu/drm/drm_ioctl.c.orig    2019-05-20 01:24:26 UTC
+++ drivers/gpu/drm/drm_ioctl.c
@@ -137,6 +137,15 @@ drm_unset_busid(struct drm_device *dev,
    master->unique_len = 0;
 }

+#ifdef __FreeBSD__
+static bool dev_is_pci(struct device *dev)
+{
+   device_t bus = device_get_parent(device_get_parent(dev->bsddev));
+
+   return (device_get_devclass(bus) == devclass_find("pci"));
+}
+#endif
+
 static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
 {
    struct drm_master *master = file_priv->master;
@@ -145,12 +154,7 @@ static int drm_set_busid(struct drm_device *dev, struc
    if (master->unique != NULL)
        drm_unset_busid(dev, master);

-#ifdef __linux__
    if (dev->dev && dev_is_pci(dev->dev)) {
-#else
-   // BSDFIXME: Assume it's PCI for now
-   if (dev->dev) {
-#endif
        ret = drm_pci_set_busid(dev, master);
        if (ret) {
            drm_unset_busid(dev, master);