drm: add driver->set_busid() callback
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 29 Aug 2014 10:12:43 +0000 (12:12 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 10 Sep 2014 07:43:04 +0000 (17:43 +1000)
One step closer to dropping all the drm_bus_* code:
Add a driver->set_busid() callback and make all drivers use the generic
helpers. Nouveau is the only driver that uses two different bus-types with
the same drm_driver. This is totally broken if both buses are available on
the same machine (unlikely, but lets be safe). Therefore, we create two
different drivers for each platform during module_init() and set the
set_busid() callback respectively.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
30 files changed:
drivers/gpu/drm/armada/armada_drv.c
drivers/gpu/drm/ast/ast_drv.c
drivers/gpu/drm/bochs/bochs_drv.c
drivers/gpu/drm/cirrus/cirrus_drv.c
drivers/gpu/drm/drm_ioctl.c
drivers/gpu/drm/drm_pci.c
drivers/gpu/drm/drm_platform.c
drivers/gpu/drm/exynos/exynos_drm_drv.c
drivers/gpu/drm/gma500/psb_drv.c
drivers/gpu/drm/i810/i810_drv.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/mga/mga_drv.c
drivers/gpu/drm/mgag200/mgag200_drv.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/gpu/drm/qxl/qxl_drv.c
drivers/gpu/drm/r128/r128_drv.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/rcar-du/rcar_du_drv.c
drivers/gpu/drm/savage/savage_drv.c
drivers/gpu/drm/shmobile/shmob_drm_drv.c
drivers/gpu/drm/sis/sis_drv.c
drivers/gpu/drm/tdfx/tdfx_drv.c
drivers/gpu/drm/tilcdc/tilcdc_drv.c
drivers/gpu/drm/udl/udl_drv.c
drivers/gpu/drm/via/via_drv.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
drivers/staging/imx-drm/imx-drm-core.c
include/drm/drmP.h

index e2d5792b140fb41069713661612e0853da0e5854..f672e6ad8afae05d42ebeb31b31bc9c3eb60c117 100644 (file)
@@ -308,6 +308,7 @@ static struct drm_driver armada_drm_driver = {
        .postclose              = NULL,
        .lastclose              = armada_drm_lastclose,
        .unload                 = armada_drm_unload,
+       .set_busid              = drm_platform_set_busid,
        .get_vblank_counter     = drm_vblank_count,
        .enable_vblank          = armada_drm_enable_vblank,
        .disable_vblank         = armada_drm_disable_vblank,
index f19682a93c243e3775fa96b6b0750334b97dd95f..9a32d9dfdd269aaa1918e4340b660b5b9567ef4d 100644 (file)
@@ -199,6 +199,7 @@ static struct drm_driver driver = {
 
        .load = ast_driver_load,
        .unload = ast_driver_unload,
+       .set_busid = drm_pci_set_busid,
 
        .fops = &ast_fops,
        .name = DRIVER_NAME,
index 9738e9b14708d7a59b549dc1717c6f8716fefeff..98837bde2d2528356c2764b27fe5ac3721c51817 100644 (file)
@@ -82,6 +82,7 @@ static struct drm_driver bochs_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET,
        .load                   = bochs_load,
        .unload                 = bochs_unload,
+       .set_busid              = drm_pci_set_busid,
        .fops                   = &bochs_fops,
        .name                   = "bochs-drm",
        .desc                   = "bochs dispi vga interface (qemu stdvga)",
index 919c73b9444723eee3bfcfa71408c55e9cb9f631..e705335101a59ea0a703d9b699d8ea7af9eafcb5 100644 (file)
@@ -128,6 +128,7 @@ static struct drm_driver driver = {
        .driver_features = DRIVER_MODESET | DRIVER_GEM,
        .load = cirrus_driver_load,
        .unload = cirrus_driver_unload,
+       .set_busid = drm_pci_set_busid,
        .fops = &cirrus_driver_fops,
        .name = DRIVER_NAME,
        .desc = DRIVER_DESC,
index cb6b54aebd6fcc0239568cfc5e479f75ce96b324..4770bd78b30780e1656249549e8b70e9162084fa 100644 (file)
@@ -244,7 +244,13 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
        if (master->unique != NULL)
                drm_unset_busid(dev, master);
 
-       if (dev->driver->bus && dev->driver->bus->set_busid) {
+       if (dev->driver->set_busid) {
+               ret = dev->driver->set_busid(dev, master);
+               if (ret) {
+                       drm_unset_busid(dev, master);
+                       return ret;
+               }
+       } else if (dev->driver->bus && dev->driver->bus->set_busid) {
                ret = dev->driver->bus->set_busid(dev, master);
                if (ret) {
                        drm_unset_busid(dev, master);
index e266927bb9f1daa35f000edb9ddf4e20b43ade9b..0400c371cbdea6b64252033f654e3ef05c0442d0 100644 (file)
@@ -127,7 +127,7 @@ static int drm_get_pci_domain(struct drm_device *dev)
        return pci_domain_nr(dev->pdev->bus);
 }
 
-static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
+int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 {
        master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
                                        drm_get_pci_domain(dev),
@@ -140,6 +140,7 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
        master->unique_len = strlen(master->unique);
        return 0;
 }
+EXPORT_SYMBOL(drm_pci_set_busid);
 
 int drm_pci_set_unique(struct drm_device *dev,
                       struct drm_master *master,
index f197a2b6911a1bec359044e0171772c530161ecc..939cd2272b91725db847f198aaba1e67b05d9044 100644 (file)
@@ -68,7 +68,7 @@ err_free:
        return ret;
 }
 
-static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
+int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
 {
        int id;
 
@@ -84,6 +84,7 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas
        master->unique_len = strlen(master->unique);
        return 0;
 }
+EXPORT_SYMBOL(drm_platform_set_busid);
 
 static struct drm_bus drm_platform_bus = {
        .set_busid = drm_platform_set_busid,
index 0d74e9b99c4ec672aa413bf6489cbb3a17898832..5aae95cf5b231b38d5b7181c52c3debca0ef70f7 100644 (file)
@@ -330,6 +330,7 @@ static struct drm_driver exynos_drm_driver = {
        .preclose               = exynos_drm_preclose,
        .lastclose              = exynos_drm_lastclose,
        .postclose              = exynos_drm_postclose,
+       .set_busid              = drm_platform_set_busid,
        .get_vblank_counter     = drm_vblank_count,
        .enable_vblank          = exynos_drm_crtc_enable_vblank,
        .disable_vblank         = exynos_drm_crtc_disable_vblank,
index eec993f93b1aaea8cd7309918b2c51a08bf08725..6ec3a905fdd274bbcd1ec169efc802e8cf1663be 100644 (file)
@@ -476,6 +476,7 @@ static struct drm_driver driver = {
        .unload = psb_driver_unload,
        .lastclose = psb_driver_lastclose,
        .preclose = psb_driver_preclose,
+       .set_busid = drm_pci_set_busid,
 
        .num_ioctls = ARRAY_SIZE(psb_ioctls),
        .device_is_agp = psb_driver_device_is_agp,
index 441ccf8f5bdc3a7d2ebad9b4724eff2044d2c34b..6cb08a1c6b62607c1a3676faa6360308cf3ec669 100644 (file)
@@ -63,6 +63,7 @@ static struct drm_driver driver = {
        .load = i810_driver_load,
        .lastclose = i810_driver_lastclose,
        .preclose = i810_driver_preclose,
+       .set_busid = drm_pci_set_busid,
        .device_is_agp = i810_driver_device_is_agp,
        .dma_quiescent = i810_driver_dma_quiescent,
        .ioctls = i810_ioctls,
index ff4db249cc7210f16169cc9d6a4c4413e9f70104..cdd95956811d4f5431b005cab9f73fe68fb7bdc1 100644 (file)
@@ -1593,6 +1593,7 @@ static struct drm_driver driver = {
        .lastclose = i915_driver_lastclose,
        .preclose = i915_driver_preclose,
        .postclose = i915_driver_postclose,
+       .set_busid = drm_pci_set_busid,
 
        /* Used in place of i915_pm_ops for non-DRIVER_MODESET */
        .suspend = i915_suspend,
index 6b1a87c8aac52f6f103385a7302713e719a3a1b3..cb5c71f4b28e8dd9e0019946986b235c23e4880a 100644 (file)
@@ -64,6 +64,7 @@ static struct drm_driver driver = {
        .load = mga_driver_load,
        .unload = mga_driver_unload,
        .lastclose = mga_driver_lastclose,
+       .set_busid = drm_pci_set_busid,
        .dma_quiescent = mga_driver_dma_quiescent,
        .device_is_agp = mga_driver_device_is_agp,
        .get_vblank_counter = mga_get_vblank_counter,
index 2d75d6df0789d5fd7d0515995ae1f80a35e982ca..97745991544ddd4a02000ed506a0a9cce5ccf8b1 100644 (file)
@@ -91,6 +91,7 @@ static struct drm_driver driver = {
        .driver_features = DRIVER_GEM | DRIVER_MODESET,
        .load = mgag200_driver_load,
        .unload = mgag200_driver_unload,
+       .set_busid = drm_pci_set_busid,
        .fops = &mgag200_driver_fops,
        .name = DRIVER_NAME,
        .desc = DRIVER_DESC,
index b447c01ad89c86c909b92679444843989df22c9e..47ccdbf49fa151b84949f5ce8c9938efa39369f0 100644 (file)
@@ -836,6 +836,7 @@ static struct drm_driver msm_driver = {
        .open               = msm_open,
        .preclose           = msm_preclose,
        .lastclose          = msm_lastclose,
+       .set_busid          = drm_platform_set_busid,
        .irq_handler        = msm_irq,
        .irq_preinstall     = msm_irq_preinstall,
        .irq_postinstall    = msm_irq_postinstall,
index 250a5e88c7516f78aba08cf39b6a0b7696072fb4..cee1eaf64117003526539c910fa7d875b25c0c64 100644 (file)
@@ -73,7 +73,9 @@ MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1
 int nouveau_runtime_pm = -1;
 module_param_named(runpm, nouveau_runtime_pm, int, 0400);
 
-static struct drm_driver driver;
+static struct drm_driver driver_stub;
+static struct drm_driver driver_pci;
+static struct drm_driver driver_platform;
 
 static u64
 nouveau_pci_name(struct pci_dev *pdev)
@@ -322,7 +324,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 
        pci_set_master(pdev);
 
-       ret = drm_get_pci_dev(pdev, pent, &driver);
+       ret = drm_get_pci_dev(pdev, pent, &driver_pci);
        if (ret) {
                nouveau_object_ref(NULL, (struct nouveau_object **)&device);
                return ret;
@@ -855,7 +857,7 @@ nouveau_driver_fops = {
 };
 
 static struct drm_driver
-driver = {
+driver_stub = {
        .driver_features =
                DRIVER_USE_AGP |
                DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
@@ -1061,7 +1063,7 @@ nouveau_platform_device_create_(struct platform_device *pdev, int size,
        if (err)
                return ERR_PTR(err);
 
-       drm = drm_dev_alloc(&driver, &pdev->dev);
+       drm = drm_dev_alloc(&driver_platform, &pdev->dev);
        if (!drm) {
                err = -ENOMEM;
                goto err_free;
@@ -1086,6 +1088,11 @@ EXPORT_SYMBOL(nouveau_platform_device_create_);
 static int __init
 nouveau_drm_init(void)
 {
+       driver_pci = driver_stub;
+       driver_pci.set_busid = drm_pci_set_busid;
+       driver_platform = driver_stub;
+       driver_platform.set_busid = drm_platform_set_busid;
+
        if (nouveau_modeset == -1) {
 #ifdef CONFIG_VGA_CONSOLE
                if (vgacon_text_force())
@@ -1097,7 +1104,7 @@ nouveau_drm_init(void)
                return 0;
 
        nouveau_register_dsm_handler();
-       return drm_pci_init(&driver, &nouveau_drm_pci_driver);
+       return drm_pci_init(&driver_pci, &nouveau_drm_pci_driver);
 }
 
 static void __exit
@@ -1106,7 +1113,7 @@ nouveau_drm_exit(void)
        if (!nouveau_modeset)
                return;
 
-       drm_pci_exit(&driver, &nouveau_drm_pci_driver);
+       drm_pci_exit(&driver_pci, &nouveau_drm_pci_driver);
        nouveau_unregister_dsm_handler();
 }
 
index 002b9721e85a348077f09285c99bbb7600ecce32..862ba03c236ca1c42766cd8f94d4f4b93ceb5cdc 100644 (file)
@@ -629,6 +629,7 @@ static struct drm_driver omap_drm_driver = {
                .lastclose = dev_lastclose,
                .preclose = dev_preclose,
                .postclose = dev_postclose,
+               .set_busid = drm_platform_set_busid,
                .get_vblank_counter = drm_vblank_count,
                .enable_vblank = omap_irq_enable_vblank,
                .disable_vblank = omap_irq_disable_vblank,
index 4da0105e481a0c98795ef27d43fb9559a8665fb1..1d9b80c91a152585ba8c4380825e5964fe5e4cf0 100644 (file)
@@ -235,6 +235,8 @@ static struct drm_driver qxl_driver = {
        .enable_vblank = qxl_noop_enable_vblank,
        .disable_vblank = qxl_noop_disable_vblank,
 
+       .set_busid = drm_pci_set_busid,
+
        .dumb_create = qxl_mode_dumb_create,
        .dumb_map_offset = qxl_mode_dumb_mmap,
        .dumb_destroy = drm_gem_dumb_destroy,
index 5bd307cd8da129316db121ad0e41736a10338322..4a59370eb580ea92032264b166b69e573921c657 100644 (file)
@@ -62,6 +62,7 @@ static struct drm_driver driver = {
        .load = r128_driver_load,
        .preclose = r128_driver_preclose,
        .lastclose = r128_driver_lastclose,
+       .set_busid = drm_pci_set_busid,
        .get_vblank_counter = r128_get_vblank_counter,
        .enable_vblank = r128_enable_vblank,
        .disable_vblank = r128_disable_vblank,
index f1e96e094b00d52808e3c58da5a641909b4ba126..ec7e963d9bf76acb7b62c647c4281702e80ec44d 100644 (file)
@@ -328,6 +328,7 @@ static struct drm_driver driver_old = {
        .preclose = radeon_driver_preclose,
        .postclose = radeon_driver_postclose,
        .lastclose = radeon_driver_lastclose,
+       .set_busid = drm_pci_set_busid,
        .unload = radeon_driver_unload,
        .suspend = radeon_suspend,
        .resume = radeon_resume,
@@ -551,6 +552,7 @@ static struct drm_driver kms_driver = {
        .preclose = radeon_driver_preclose_kms,
        .postclose = radeon_driver_postclose_kms,
        .lastclose = radeon_driver_lastclose_kms,
+       .set_busid = drm_pci_set_busid,
        .unload = radeon_driver_unload_kms,
        .get_vblank_counter = radeon_get_vblank_counter_kms,
        .enable_vblank = radeon_enable_vblank_kms,
index fda64b7b73e816f80716f0a33b2764a7b4711af1..672d2fcba00947eac83a8d050e86eacb4d27b568 100644 (file)
@@ -158,6 +158,7 @@ static struct drm_driver rcar_du_driver = {
        .unload                 = rcar_du_unload,
        .preclose               = rcar_du_preclose,
        .lastclose              = rcar_du_lastclose,
+       .set_busid              = drm_platform_set_busid,
        .get_vblank_counter     = drm_vblank_count,
        .enable_vblank          = rcar_du_enable_vblank,
        .disable_vblank         = rcar_du_disable_vblank,
index 3c030216e8888a14078af5d67b26399f7dfbf585..1b09d2182037e135db5b2941f3acaf079a0ad90a 100644 (file)
@@ -57,6 +57,7 @@ static struct drm_driver driver = {
        .preclose = savage_reclaim_buffers,
        .lastclose = savage_driver_lastclose,
        .unload = savage_driver_unload,
+       .set_busid = drm_pci_set_busid,
        .ioctls = savage_ioctls,
        .dma_ioctl = savage_bci_buffers,
        .fops = &savage_driver_fops,
index ff4ba483b6020798aac9dfb31254dd3067e50a22..873d12f851bf2d57fc134524551afcbfba3acf1c 100644 (file)
@@ -267,6 +267,7 @@ static struct drm_driver shmob_drm_driver = {
        .load                   = shmob_drm_load,
        .unload                 = shmob_drm_unload,
        .preclose               = shmob_drm_preclose,
+       .set_busid              = drm_platform_set_busid,
        .irq_handler            = shmob_drm_irq,
        .get_vblank_counter     = drm_vblank_count,
        .enable_vblank          = shmob_drm_enable_vblank,
index 756f787b71439ac42af2b6a723916207165b2382..54858e6fedaf6a5e6cf5f612bc12662f09a0cdda 100644 (file)
@@ -108,6 +108,7 @@ static struct drm_driver driver = {
        .open = sis_driver_open,
        .preclose = sis_reclaim_buffers_locked,
        .postclose = sis_driver_postclose,
+       .set_busid = drm_pci_set_busid,
        .dma_quiescent = sis_idle,
        .lastclose = sis_lastclose,
        .ioctls = sis_ioctls,
index 3492ca5c46d323b6932ee8d917a00af3544bebf2..df533ff999a4273877bc12cb9f1267400db50c09 100644 (file)
@@ -55,6 +55,7 @@ static const struct file_operations tdfx_driver_fops = {
 };
 
 static struct drm_driver driver = {
+       .set_busid = drm_pci_set_busid,
        .fops = &tdfx_driver_fops,
        .name = DRIVER_NAME,
        .desc = DRIVER_DESC,
index 6be623b4a86fda98867ee08f1c68428b2cb35687..aea4b76639345cd80eee23fce80a602ce5e39795 100644 (file)
@@ -502,6 +502,7 @@ static struct drm_driver tilcdc_driver = {
        .unload             = tilcdc_unload,
        .preclose           = tilcdc_preclose,
        .lastclose          = tilcdc_lastclose,
+       .set_busid          = drm_platform_set_busid,
        .irq_handler        = tilcdc_irq,
        .irq_preinstall     = tilcdc_irq_preinstall,
        .irq_postinstall    = tilcdc_irq_postinstall,
index 3ddd6cd98ac12d0d8cbf9124556f6688b677c9f8..06675e5d4342c9988b101fc9996587ac01a02bcc 100644 (file)
@@ -34,6 +34,11 @@ MODULE_DEVICE_TABLE(usb, id_table);
 
 MODULE_LICENSE("GPL");
 
+static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m)
+{
+       return 0;
+}
+
 static int udl_usb_probe(struct usb_interface *interface,
                         const struct usb_device_id *id)
 {
@@ -75,6 +80,7 @@ static struct drm_driver driver = {
        .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
        .load = udl_driver_load,
        .unload = udl_driver_unload,
+       .set_busid = udl_driver_set_busid,
 
        /* gem hooks */
        .gem_free_object = udl_gem_free_object,
index 50abc2adfaee495730337a94b4fc931bcdd40f37..c16ffa63ded62ac8547e291bdc10e5505d714f52 100644 (file)
@@ -79,6 +79,7 @@ static struct drm_driver driver = {
        .open = via_driver_open,
        .preclose = via_reclaim_buffers_locked,
        .postclose = via_driver_postclose,
+       .set_busid = drm_pci_set_busid,
        .context_dtor = via_final_context,
        .get_vblank_counter = via_get_vblank_counter,
        .enable_vblank = via_enable_vblank,
index 18b54acacfbb813335c00964117613a232840c94..7197af15731383c817728e155c09621c4c954fb0 100644 (file)
@@ -1418,6 +1418,7 @@ static struct drm_driver driver = {
        .open = vmw_driver_open,
        .preclose = vmw_preclose,
        .postclose = vmw_postclose,
+       .set_busid = drm_pci_set_busid,
 
        .dumb_create = vmw_dumb_create,
        .dumb_map_offset = vmw_dumb_map_offset,
index 6b22106534d8d62451e18f5fe453bd3c2bc2078f..16392b674d7950a1b631888ddf25c71a35670a90 100644 (file)
@@ -528,6 +528,7 @@ static struct drm_driver imx_drm_driver = {
        .unload                 = imx_drm_driver_unload,
        .lastclose              = imx_drm_driver_lastclose,
        .preclose               = imx_drm_driver_preclose,
+       .set_busid              = drm_platform_set_busid,
        .gem_free_object        = drm_gem_cma_free_object,
        .gem_vm_ops             = &drm_gem_cma_vm_ops,
        .dumb_create            = drm_gem_cma_dumb_create,
index 98b1eafebc1c6b258c8c02376dd01175e86d4597..c82f292efcd4087fe27b35fa64ebb4aaba62d023 100644 (file)
@@ -627,6 +627,7 @@ struct drm_driver {
        int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
        int (*dma_quiescent) (struct drm_device *);
        int (*context_dtor) (struct drm_device *dev, int context);
+       int (*set_busid)(struct drm_device *dev, struct drm_master *master);
 
        /**
         * get_vblank_counter - get raw hardware vblank counter
@@ -1498,6 +1499,7 @@ extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
 extern int drm_get_pci_dev(struct pci_dev *pdev,
                           const struct pci_device_id *ent,
                           struct drm_driver *driver);
+extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
 
 #define DRM_PCIE_SPEED_25 1
 #define DRM_PCIE_SPEED_50 2
@@ -1507,6 +1509,7 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
 
 /* platform section */
 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
+extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
 
 /* returns true if currently okay to sleep */
 static __inline__ bool drm_can_sleep(void)