diff mbox

[17/20] drm: add driver->set_busid() callback

Message ID 1409307166-12396-18-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann Aug. 29, 2014, 10:12 a.m. UTC
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>
---
 drivers/gpu/drm/armada/armada_drv.c      |  1 +
 drivers/gpu/drm/ast/ast_drv.c            |  1 +
 drivers/gpu/drm/bochs/bochs_drv.c        |  1 +
 drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 +
 drivers/gpu/drm/drm_ioctl.c              |  8 +++++++-
 drivers/gpu/drm/drm_pci.c                |  3 ++-
 drivers/gpu/drm/drm_platform.c           |  3 ++-
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  1 +
 drivers/gpu/drm/gma500/psb_drv.c         |  1 +
 drivers/gpu/drm/i810/i810_drv.c          |  1 +
 drivers/gpu/drm/i915/i915_drv.c          |  1 +
 drivers/gpu/drm/mga/mga_drv.c            |  1 +
 drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 +
 drivers/gpu/drm/msm/msm_drv.c            |  1 +
 drivers/gpu/drm/nouveau/nouveau_drm.c    | 19 +++++++++++++------
 drivers/gpu/drm/omapdrm/omap_drv.c       |  1 +
 drivers/gpu/drm/qxl/qxl_drv.c            |  1 +
 drivers/gpu/drm/r128/r128_drv.c          |  1 +
 drivers/gpu/drm/radeon/radeon_drv.c      |  2 ++
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |  1 +
 drivers/gpu/drm/savage/savage_drv.c      |  1 +
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 +
 drivers/gpu/drm/sis/sis_drv.c            |  1 +
 drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 +
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 +
 drivers/gpu/drm/udl/udl_drv.c            |  6 ++++++
 drivers/gpu/drm/via/via_drv.c            |  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 +
 drivers/staging/imx-drm/imx-drm-core.c   |  1 +
 include/drm/drmP.h                       |  3 +++
 30 files changed, 58 insertions(+), 9 deletions(-)

Comments

Thierry Reding Aug. 29, 2014, 12:54 p.m. UTC | #1
On Fri, Aug 29, 2014 at 12:12:43PM +0200, David Herrmann wrote:
> 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).

It's not at all unlikely. There are quite a few people using nouveau to
drive an discrete GPU over PCIe on Tegra K1.

I've also been noticing lately (and I'm not sure why I didn't see it
earlier, possibly because the relevant patches weren't in nouveau yet)
that the nouveau kernel driver crashes when running X on Tegra K1 with
nouveau (and the gk20a GPU) enabled. The reason being that the device is
wrongfully marked as drm_pci_bus.

> Therefore, we create two
> different drivers for each platform during module_init() and set the
> set_busid() callback respectively.

From what I can tell this patch should fix the above-mentioned issue, so
thanks for that. =) I do have local changes that do mostly the same
thing, but slightly less elegantly.

> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
[...]
> @@ -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;

I think at some point we may also want to remove the DRIVER_MODESET flag
here. It probably won't be that easy because DRIVER_MODESET still
implies !legacy. I thought I had submitted a patch series at some point
to fix that (and got rid of the useless /dev/dri/cardX for render-only
devices), but I don't quite remember what became of it. I seem to
remember that Daniel didn't like it, but I can't recall the reason.

> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
[...]
> @@ -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);

One step closer to getting rid of this altogether.

Reviewed-by: Thierry Reding <treding@nvidia.com>
Daniel Vetter Aug. 29, 2014, 1:01 p.m. UTC | #2
On Fri, Aug 29, 2014 at 12:12:43PM +0200, David Herrmann wrote:
> 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>

This has a bit a midlayer smell to it tbh, we don't really need a
set_busid callback I think. Instead there's just two cases:
- The crazy implementation for pci devices. But we already have dev->pdev,
  so the core can figure this out itself.
- Everyone else just sets a static name. For those I think we should just
  add a drm_dev_set_busid function which they can call in their
  driver-load function. Well maybe different versions for platform drivers
  and stuff.

Thanks, Daniel

> ---
>  drivers/gpu/drm/armada/armada_drv.c      |  1 +
>  drivers/gpu/drm/ast/ast_drv.c            |  1 +
>  drivers/gpu/drm/bochs/bochs_drv.c        |  1 +
>  drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 +
>  drivers/gpu/drm/drm_ioctl.c              |  8 +++++++-
>  drivers/gpu/drm/drm_pci.c                |  3 ++-
>  drivers/gpu/drm/drm_platform.c           |  3 ++-
>  drivers/gpu/drm/exynos/exynos_drm_drv.c  |  1 +
>  drivers/gpu/drm/gma500/psb_drv.c         |  1 +
>  drivers/gpu/drm/i810/i810_drv.c          |  1 +
>  drivers/gpu/drm/i915/i915_drv.c          |  1 +
>  drivers/gpu/drm/mga/mga_drv.c            |  1 +
>  drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 +
>  drivers/gpu/drm/msm/msm_drv.c            |  1 +
>  drivers/gpu/drm/nouveau/nouveau_drm.c    | 19 +++++++++++++------
>  drivers/gpu/drm/omapdrm/omap_drv.c       |  1 +
>  drivers/gpu/drm/qxl/qxl_drv.c            |  1 +
>  drivers/gpu/drm/r128/r128_drv.c          |  1 +
>  drivers/gpu/drm/radeon/radeon_drv.c      |  2 ++
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c    |  1 +
>  drivers/gpu/drm/savage/savage_drv.c      |  1 +
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 +
>  drivers/gpu/drm/sis/sis_drv.c            |  1 +
>  drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 +
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 +
>  drivers/gpu/drm/udl/udl_drv.c            |  6 ++++++
>  drivers/gpu/drm/via/via_drv.c            |  1 +
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 +
>  drivers/staging/imx-drm/imx-drm-core.c   |  1 +
>  include/drm/drmP.h                       |  3 +++
>  30 files changed, 58 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index e2d5792..f672e6a 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index f19682a..9a32d9d 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
> index 9738e9b..98837bd 100644
> --- a/drivers/gpu/drm/bochs/bochs_drv.c
> +++ b/drivers/gpu/drm/bochs/bochs_drv.c
> @@ -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)",
> diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
> index 919c73b..e705335 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_drv.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index cb6b54a..4770bd7 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -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);
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index e266927..0400c37 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -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,
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
> index f197a2b..939cd22 100644
> --- a/drivers/gpu/drm/drm_platform.c
> +++ b/drivers/gpu/drm/drm_platform.c
> @@ -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,
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index 0d74e9b..5aae95c 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
> index eec993f..6ec3a90 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
> index 441ccf8..6cb08a1 100644
> --- a/drivers/gpu/drm/i810/i810_drv.c
> +++ b/drivers/gpu/drm/i810/i810_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index e27cdbe..fa188b4 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1572,6 +1572,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,
> diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
> index 6b1a87c..cb5c71f 100644
> --- a/drivers/gpu/drm/mga/mga_drv.c
> +++ b/drivers/gpu/drm/mga/mga_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
> index 2d75d6d..9774599 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index b447c01..47ccdbf 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 250a5e8..cee1eaf 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -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();
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 002b972..862ba03 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index a3fd920..ab9a1e3 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -216,6 +216,7 @@ static struct drm_driver qxl_driver = {
>  			   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
>  	.load = qxl_driver_load,
>  	.unload = qxl_driver_unload,
> +	.set_busid = drm_pci_set_busid,
>  
>  	.dumb_create = qxl_mode_dumb_create,
>  	.dumb_map_offset = qxl_mode_dumb_mmap,
> diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
> index 5bd307c..4a59370 100644
> --- a/drivers/gpu/drm/r128/r128_drv.c
> +++ b/drivers/gpu/drm/r128/r128_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index f1e96e0..ec7e963 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index fda64b7..672d2fc 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
> index 3c03021..1b09d21 100644
> --- a/drivers/gpu/drm/savage/savage_drv.c
> +++ b/drivers/gpu/drm/savage/savage_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> index ff4ba48..873d12f 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
> index 756f787..54858e6 100644
> --- a/drivers/gpu/drm/sis/sis_drv.c
> +++ b/drivers/gpu/drm/sis/sis_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
> index 3492ca5..df533ff 100644
> --- a/drivers/gpu/drm/tdfx/tdfx_drv.c
> +++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 6be623b..aea4b766 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 3ddd6cd..06675e5 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
> index 50abc2a..c16ffa6 100644
> --- a/drivers/gpu/drm/via/via_drv.c
> +++ b/drivers/gpu/drm/via/via_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 18b54ac..7197af1 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -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,
> diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
> index 6b22106..16392b6 100644
> --- a/drivers/staging/imx-drm/imx-drm-core.c
> +++ b/drivers/staging/imx-drm/imx-drm-core.c
> @@ -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,
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 98b1eaf..c82f292 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -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)
> -- 
> 2.1.0
>
Thierry Reding Aug. 29, 2014, 1:30 p.m. UTC | #3
On Fri, Aug 29, 2014 at 03:01:00PM +0200, Daniel Vetter wrote:
> On Fri, Aug 29, 2014 at 12:12:43PM +0200, David Herrmann wrote:
> > 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>
> 
> This has a bit a midlayer smell to it tbh, we don't really need a
> set_busid callback I think. Instead there's just two cases:
> - The crazy implementation for pci devices. But we already have dev->pdev,
>   so the core can figure this out itself.
> - Everyone else just sets a static name. For those I think we should just
>   add a drm_dev_set_busid function which they can call in their
>   driver-load function. Well maybe different versions for platform drivers
>   and stuff.

We already have drm_dev_set_unique() for exactly this purpose. I think
drivers can just be converted to use that one at a time and when no
users are left we can drop drm_*_set_busid().

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index e2d5792..f672e6a 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index f19682a..9a32d9d 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
index 9738e9b..98837bd 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -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)",
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 919c73b..e705335 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index cb6b54a..4770bd7 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -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);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index e266927..0400c37 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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,
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index f197a2b..939cd22 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -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,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 0d74e9b..5aae95c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index eec993f..6ec3a90 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 441ccf8..6cb08a1 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index e27cdbe..fa188b4 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1572,6 +1572,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,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 6b1a87c..cb5c71f 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 2d75d6d..9774599 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index b447c01..47ccdbf 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 250a5e8..cee1eaf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -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();
 }
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 002b972..862ba03 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index a3fd920..ab9a1e3 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -216,6 +216,7 @@  static struct drm_driver qxl_driver = {
 			   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
 	.load = qxl_driver_load,
 	.unload = qxl_driver_unload,
+	.set_busid = drm_pci_set_busid,
 
 	.dumb_create = qxl_mode_dumb_create,
 	.dumb_map_offset = qxl_mode_dumb_mmap,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 5bd307c..4a59370 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index f1e96e0..ec7e963 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index fda64b7..672d2fc 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 3c03021..1b09d21 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index ff4ba48..873d12f 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 756f787..54858e6 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 3492ca5..df533ff 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 6be623b..aea4b766 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 3ddd6cd..06675e5 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 50abc2a..c16ffa6 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 18b54ac..7197af1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -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,
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 6b22106..16392b6 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -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,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 98b1eaf..c82f292 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -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)