drm: cleanup device registration
Subsystems (5)
PATCH 1/1 drm: cleanup device registration
The non modesetting drm drivers currently use a handcrafted pci probe function. This requires the drm core to keep a list of registered devices for each driver. This series adds a probe function for the non modesetting drivers and removes the legacy probe code. The USB and platform drivers use the devices_list aswell which is unnecessary. This is also cleaned up in this series.
I am confident that the standard pci probe mechanism will work for the non modesetting drivers, but unfortunately I have non of them handy for testing, so it would be great if someone with access to one of those devices could give this series a test.
Sascha
Sascha Hauer (12):
drm: remove kdriver union from struct drm_driver
drm: remove platformdev and usbdev from struct drm_device
drm: remove unused field bus_type from struct drm_bus
drm: provide a pci probe function for non modesetting devices
drm: use drm_get_platform_dev and drop drm_platform_init/exit drm usb: drop drm_usb_init/exit
drm: remove now unused device_list
drm vmwgfx: remove unused field vmw_chipset from struct vmw_private
drm: Add drm_register_device function
drm pci: use drm_register_device
drm platform: use drm_register_device
drm usb: use drm_register_device
drivers/gpu/drm/drm_pci.c | 98 ++------------------------ drivers/gpu/drm/drm_platform.c | 108 +++++------------------------ drivers/gpu/drm/drm_stub.c | 56 +++++++++++++++ drivers/gpu/drm/drm_usb.c | 72 ++------------------ drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +- drivers/gpu/drm/i810/i810_drv.c | 16 ++++ drivers/gpu/drm/mga/mga_drv.c | 16 ++++ drivers/gpu/drm/r128/r128_drv.c | 16 ++++ drivers/gpu/drm/savage/savage_drv.c | 16 ++++ drivers/gpu/drm/sis/sis_drv.c | 16 ++++ drivers/gpu/drm/tdfx/tdfx_drv.c | 16 ++++ drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 - drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 - include/drm/drmP.h | 21 +----- include/drm/drm_usb.h | 3 - 16 files changed, 190 insertions(+), 275 deletions(-)
PATCH 1/12 drm: remove kdriver union from struct drm_driver
struct drm_driver has a union containing the different drivers. This field is unused in case of a usb or platform device. For pci devices it is only used in drm_pci_get_name() which uses the pci_driver to return the pci driver name. For all existing drm drivers this driver name matches the struct drm_device->name, so return this name instead and remove the now unnecessary code.
--- drivers/gpu/drm/drm_pci.c | 10 +++------- drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_usb.c | 1 - include/drm/drmP.h | 5 ----- 4 files changed, 3 insertions(+), 14 deletions(-)
drivers/gpu/drm/drm_pci.c +3 -7
@@ -148,14 +148,12 @@ static int drm_pci_get_irq(struct drm_device *dev)static const char *drm_pci_get_name (struct drm_device *dev) { -struct pci_driver *pdriver = dev->driver->kdriver.pci; -return pdriver->name; +return dev->driver->name; }int drm_pci_set_busid (struct drm_device *dev,struct drm_master *master) {int len, ret; -struct pci_driver *pdriver = dev->driver->kdriver.pci; master->unique_len =40 ; master->unique_size = master->unique_len; master->unique =kmalloc (master->unique_size,GFP_KERNEL );
@@ -178,7 +176,7 @@ int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) master->unique_len = len; dev->devname = -kmalloc (strlen (pdriver->name) + +kmalloc (strlen (dev->driver->name) + master->unique_len +2 ,GFP_KERNEL );if (dev->devname ==NULL ) {
@@ -186,8 +184,7 @@ int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) goto err; } -sprintf (dev->devname,"%s@%s" , pdriver->name, - master->unique); +sprintf (dev->devname,"%s@%s" , dev->driver->name, master->unique);return 0 ; err:
@@ -410,7 +407,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)DRM_DEBUG ("\n" );INIT_LIST_HEAD (&driver->device_list); - driver->kdriver.pci = pdriver; driver->bus = &drm_pci_bus;if (driver->driver_features &DRIVER_MODESET )
drivers/gpu/drm/drm_platform.c +0 -1
@@ -179,7 +179,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor {DRM_DEBUG ("\n" ); - driver->kdriver.platform_device = platform_device; driver->bus = &drm_platform_bus;INIT_LIST_HEAD (&driver->device_list);return drm_get_platform_dev (platform_device, driver);
drivers/gpu/drm/drm_usb.c +0 -1
@@ -101,7 +101,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)DRM_DEBUG ("\n" );INIT_LIST_HEAD (&driver->device_list); - driver->kdriver.usb = udriver; driver->bus = &drm_usb_bus; res =usb_register (udriver);
include/drm/drmP.h +0 -5
@@ -919,11 +919,6 @@ struct drm_driver {struct drm_ioctl_desc *ioctls;int num_ioctls;const struct file_operations *fops; -union { -struct pci_driver *pci; -struct platform_device *platform_device; -struct usb_driver *usb; - } kdriver;struct drm_bus *bus;/* List of devices hanging off this driver */
Signature · 1 line
1.7.8.3
PATCH 2/12 drm: remove platformdev and usbdev from struct drm_device
In reply to Sascha Hauerstruct drm_device has a struct usbdevice * and a struct platform_device *. This is unused, so remove it. If the platform_device or usbdevice is needed, we can always get it using to_usb_device or to to_platform_device.
--- drivers/gpu/drm/drm_platform.c | 18 +++++++++++------- drivers/gpu/drm/drm_usb.c | 1 - drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +-- include/drm/drmP.h | 3 --- 4 files changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_platform.c +11 -7
@@ -51,7 +51,6 @@ int drm_get_platform_dev(struct platform_device *platdev,if (!dev)return -ENOMEM ; - dev->platformdev = platdev; dev->dev = &platdev->dev;mutex_lock (&drm_global_mutex);
@@ -112,19 +111,24 @@ EXPORT_SYMBOL(drm_get_platform_dev);static int drm_platform_get_irq (struct drm_device *dev) { -return platform_get_irq (dev->platformdev,0 ); +struct platform_device *pdev =to_platform_device (dev->dev); + +return platform_get_irq (pdev,0 ); }static const char *drm_platform_get_name (struct drm_device *dev) { -return dev->platformdev->name; +struct platform_device *pdev =to_platform_device (dev->dev); + +return pdev->name; }static int drm_platform_set_busid (struct drm_device *dev,struct drm_master *master) { +struct platform_device *pdev =to_platform_device (dev->dev);int len, ret; - master->unique_len =13 +strlen (dev->platformdev->name); + master->unique_len =13 +strlen (pdev->name); master->unique_size = master->unique_len; master->unique =kmalloc (master->unique_len +1 ,GFP_KERNEL );
@@ -132,7 +136,7 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *masreturn -ENOMEM ; len =snprintf (master->unique, master->unique_len, -"platform:%s:%02d" , dev->platformdev->name, dev->platformdev->id); +"platform:%s:%02d" , pdev->name, pdev->id);if (len > master->unique_len) {DRM_ERROR ("Unique buffer overflowed\n" );
@@ -141,7 +145,7 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas } dev->devname = -kmalloc (strlen (dev->platformdev->name) + +kmalloc (strlen (pdev->name) + master->unique_len +2 ,GFP_KERNEL );if (dev->devname ==NULL ) {
@@ -149,7 +153,7 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas goto err; } -sprintf (dev->devname,"%s@%s" , dev->platformdev->name, +sprintf (dev->devname,"%s@%s" , pdev->name, master->unique);return 0 ; err:
drivers/gpu/drm/drm_usb.c +0 -1
@@ -18,7 +18,6 @@ int drm_get_usb_dev(struct usb_interface *interface,return -ENOMEM ; usbdev =interface_to_usbdev (interface); - dev->usbdev = usbdev; dev->dev = &usbdev->dev;mutex_lock (&drm_global_mutex);
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -2
@@ -125,7 +125,6 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,struct drm_device *dev = helper->dev;struct fb_info *fbi;struct drm_mode_fb_cmd2 mode_cmd = {0 }; -struct platform_device *pdev = dev->platformdev;unsigned long size;int ret;
@@ -143,7 +142,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,mutex_lock (&dev->struct_mutex); - fbi =framebuffer_alloc (0 , &pdev->dev); + fbi =framebuffer_alloc (0 , dev->dev);if (!fbi) {DRM_ERROR ("failed to allocate fb info.\n" ); ret = -ENOMEM ;
include/drm/drmP.h +0 -3
@@ -1140,9 +1140,6 @@ struct drm_device {struct pci_controller *hose;#endif -struct platform_device *platformdev;/**< Platform device struture */ -struct usb_device *usbdev; -struct drm_sg_mem *sg;/**< Scatter gather memory */ unsigned int num_crtcs;/**< Number of CRTCs on this device */ void *dev_private;/**< device private data */
Signature · 1 line
1.7.8.3
PATCH 3/12 drm: remove unused field bus_type from struct drm_bus
In reply to Sascha Hauer--- drivers/gpu/drm/drm_pci.c | 1 - drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_usb.c | 1 - include/drm/drmP.h | 5 ----- 4 files changed, 0 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -1
@@ -285,7 +285,6 @@ int drm_pci_agp_init(struct drm_device *dev) }static struct drm_bus drm_pci_bus = { - .bus_type =DRIVER_BUS_PCI , .get_irq = drm_pci_get_irq, .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid,
drivers/gpu/drm/drm_platform.c +0 -1
@@ -161,7 +161,6 @@ err: }static struct drm_bus drm_platform_bus = { - .bus_type =DRIVER_BUS_PLATFORM , .get_irq = drm_platform_get_irq, .get_name = drm_platform_get_name, .set_busid = drm_platform_set_busid,
drivers/gpu/drm/drm_usb.c +0 -1
@@ -88,7 +88,6 @@ static int drm_usb_set_busid(struct drm_device *dev, }static struct drm_bus drm_usb_bus = { - .bus_type =DRIVER_BUS_USB , .get_irq = drm_usb_get_irq, .get_name = drm_usb_get_name, .set_busid = drm_usb_set_busid,
include/drm/drmP.h +0 -5
@@ -151,10 +151,6 @@ int drm_err(const char *func, const char *format, ...);#define DRIVER_GEM 0x1000#define DRIVER_MODESET 0x2000 -#define DRIVER_BUS_PCI 0x1 -#define DRIVER_BUS_PLATFORM 0x2 -#define DRIVER_BUS_USB 0x3 -/***********************************************************************/ /** \name Begin the DRM... */ /*@{*/
@@ -697,7 +693,6 @@ struct drm_master {#define DRM_SCANOUTPOS_ACCURATE (1 << 2)struct drm_bus { -int bus_type;int (*get_irq)(struct drm_device *dev);const char *(*get_name)(struct drm_device *dev);int (*set_busid)(struct drm_device *dev,struct drm_master *master);
Signature · 1 line
1.7.8.3
PATCH 4/12 drm: provide a pci probe function for non modesetting devices
In reply to Sascha HauerThis way we do not need the legacy handcrafted probe mechanism anymore and can remove it.
--- drivers/gpu/drm/drm_pci.c | 41 +--------------------------------- drivers/gpu/drm/i810/i810_drv.c | 16 +++++++++++++ drivers/gpu/drm/mga/mga_drv.c | 16 +++++++++++++ drivers/gpu/drm/r128/r128_drv.c | 16 +++++++++++++ drivers/gpu/drm/savage/savage_drv.c | 16 +++++++++++++ drivers/gpu/drm/sis/sis_drv.c | 16 +++++++++++++ drivers/gpu/drm/tdfx/tdfx_drv.c | 16 +++++++++++++ 7 files changed, 98 insertions(+), 39 deletions(-)
drivers/gpu/drm/drm_pci.c +2 -39
@@ -363,8 +363,6 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, goto err_g4; } -list_add_tail (&dev->driver_item, &driver->device_list); -DRM_INFO ("Initialized %s %d.%d.%d %s for %s on minor %d\n" , driver->name, driver->major, driver->minor, driver->patchlevel, driver->date,pci_name (pdev), dev->primary->index);
@@ -399,41 +397,12 @@ EXPORT_SYMBOL(drm_get_pci_dev);*/ int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver) { -struct pci_dev *pdev =NULL ; -const struct pci_device_id *pid; -int i; -DRM_DEBUG ("\n" );INIT_LIST_HEAD (&driver->device_list); driver->bus = &drm_pci_bus; -if (driver->driver_features &DRIVER_MODESET ) -return pci_register_driver (pdriver); - -/* If not using KMS, fall back to stealth mode manual scanning. */ -for (i =0 ; pdriver->id_table[i].vendor !=0 ; i++) { - pid = &pdriver->id_table[i]; - -/* Loop around setting up a DRM device for each PCI device -* matching our ID and device class. If we had the internal -* function that pci_get_subsys and pci_get_class used, we'd -* be able to just pass pid in instead of doing a two-stage -* thing. -*/ - pdev =NULL ; -while ((pdev = -pci_get_subsys (pid->vendor, pid->device, pid->subvendor, - pid->subdevice, pdev)) !=NULL ) { -if ((pdev->class & pid->class_mask) != pid->class) -continue ; - -/* stealth mode requires a manual probe */ -pci_dev_get (pdev); -drm_get_pci_dev (pdev, pid, driver); - } - } -return 0 ; +return pci_register_driver (pdriver); }#else
@@ -450,15 +419,9 @@ EXPORT_SYMBOL(drm_pci_init);/*@}*/ void drm_pci_exit (struct drm_driver *driver,struct pci_driver *pdriver) { -struct drm_device *dev, *tmp;DRM_DEBUG ("\n" ); -if (driver->driver_features &DRIVER_MODESET ) { -pci_unregister_driver (pdriver); - }else { -list_for_each_entry_safe (dev, tmp, &driver->device_list, driver_item) -drm_put_dev (dev); - } +pci_unregister_driver (pdriver);DRM_INFO ("Module unloaded\n" ); }EXPORT_SYMBOL (drm_pci_exit);
drivers/gpu/drm/i810/i810_drv.c +16 -0
@@ -75,7 +75,23 @@ static struct drm_driver driver = { .patchlevel = DRIVER_PATCHLEVEL, }; +static int __devinit +i810_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +return drm_get_pci_dev (pdev, ent, &driver); +} + +static void +i810_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_put_dev (dev); +} +static struct pci_driver i810_pci_driver = { + .probe = i810_pci_probe, + .remove = i810_pci_remove, .name =DRIVER_NAME , .id_table = pciidlist, };
drivers/gpu/drm/mga/mga_drv.c +16 -0
@@ -87,7 +87,23 @@ static struct drm_driver driver = { .patchlevel = DRIVER_PATCHLEVEL, }; +static int __devinit +mga_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +return drm_get_pci_dev (pdev, ent, &driver); +} + +static void +mga_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_put_dev (dev); +} +static struct pci_driver mga_pci_driver = { + .probe = mga_pci_probe, + .remove = mga_pci_remove, .name =DRIVER_NAME , .id_table = pciidlist, };
drivers/gpu/drm/r128/r128_drv.c +16 -0
@@ -88,7 +88,23 @@ int r128_driver_load(struct drm_device *dev, unsigned long flags)return drm_vblank_init (dev,1 ); } +static int __devinit +r128_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +return drm_get_pci_dev (pdev, ent, &driver); +} + +static void +r128_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_put_dev (dev); +} +static struct pci_driver r128_pci_driver = { + .probe = r128_pci_probe, + .remove = r128_pci_remove, .name =DRIVER_NAME , .id_table = pciidlist, };
drivers/gpu/drm/savage/savage_drv.c +16 -0
@@ -66,7 +66,23 @@ static struct drm_driver driver = { .patchlevel = DRIVER_PATCHLEVEL, }; +static int __devinit +savage_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +return drm_get_pci_dev (pdev, ent, &driver); +} + +static void +savage_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_put_dev (dev); +} +static struct pci_driver savage_pci_driver = { + .probe = savage_pci_probe, + .remove = savage_pci_remove, .name =DRIVER_NAME , .id_table = pciidlist, };
drivers/gpu/drm/sis/sis_drv.c +16 -0
@@ -118,7 +118,23 @@ static struct drm_driver driver = { .patchlevel = DRIVER_PATCHLEVEL, }; +static int __devinit +sis_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +return drm_get_pci_dev (pdev, ent, &driver); +} + +static void +sis_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_put_dev (dev); +} +static struct pci_driver sis_pci_driver = { + .probe = sis_pci_probe, + .remove = sis_pci_remove, .name =DRIVER_NAME , .id_table = pciidlist, };
drivers/gpu/drm/tdfx/tdfx_drv.c +16 -0
@@ -64,7 +64,23 @@ static struct drm_driver driver = { .patchlevel = DRIVER_PATCHLEVEL, }; +static int __devinit +tdfx_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +return drm_get_pci_dev (pdev, ent, &driver); +} + +static void +tdfx_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_put_dev (dev); +} +static struct pci_driver tdfx_pci_driver = { + .probe = tdfx_pci_probe, + .remove = tdfx_pci_remove, .name =DRIVER_NAME , .id_table = pciidlist, };
Signature · 1 line
1.7.8.3
PATCH 5/12 drm: use drm_get_platform_dev and drop drm_platform_init/exit
In reply to Sascha Hauerdrm_platform_init is modelled after the legacy pci probe support. It initializes a device_list, but this list will only ever have a single entry as it is specific to a single platform device instance. Simplify this by calling drm_get_platform_dev directly from the driver.
--- drivers/gpu/drm/drm_platform.c | 39 +++--------------------------- drivers/gpu/drm/exynos/exynos_drm_drv.c | 6 +++- include/drm/drmP.h | 3 -- 3 files changed, 8 insertions(+), 40 deletions(-)
drivers/gpu/drm/drm_platform.c +4 -35
@@ -28,6 +28,8 @@#include <linux/export.h> #include "drmP.h" +static struct drm_bus drm_platform_bus; +/** * Register. *
@@ -53,6 +55,8 @@ int drm_get_platform_dev(struct platform_device *platdev, dev->dev = &platdev->dev; + driver->bus = &drm_platform_bus; +mutex_lock (&drm_global_mutex); ret =drm_fill_in_dev (dev,NULL , driver);
@@ -87,8 +91,6 @@ int drm_get_platform_dev(struct platform_device *platdev, goto err_g3; } -list_add_tail (&dev->driver_item, &driver->device_list); -mutex_unlock (&drm_global_mutex); DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
@@ -165,36 +167,3 @@ static struct drm_bus drm_platform_bus = { .get_name = drm_platform_get_name, .set_busid = drm_platform_set_busid, }; - -/** -* Platform device initialization. Called direct from modules. -* -* \return zero on success or a negative number on failure. -* -* Initializes a drm_device structures,registering the -* stubs -* -* Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and -* after the initialization for driver customization. -*/ - -int drm_platform_init (struct drm_driver *driver,struct platform_device *platform_device) -{ -DRM_DEBUG ("\n" ); - - driver->bus = &drm_platform_bus; -INIT_LIST_HEAD (&driver->device_list); -return drm_get_platform_dev (platform_device, driver); -} -EXPORT_SYMBOL (drm_platform_init); - -void drm_platform_exit (struct drm_driver *driver,struct platform_device *platform_device) -{ -struct drm_device *dev, *tmp; -DRM_DEBUG ("\n" ); - -list_for_each_entry_safe (dev, tmp, &driver->device_list, driver_item) -drm_put_dev (dev); -DRM_INFO ("Module unloaded\n" ); -} -EXPORT_SYMBOL (drm_platform_exit);
drivers/gpu/drm/exynos/exynos_drm_drv.c +4 -2
@@ -219,14 +219,16 @@ static int exynos_drm_platform_probe(struct platform_device *pdev) exynos_drm_driver.num_ioctls =DRM_ARRAY_SIZE (exynos_ioctls); -return drm_platform_init (&exynos_drm_driver, pdev); +return drm_get_platform_dev (pdev, &exynos_drm_driver); }static int exynos_drm_platform_remove (struct platform_device *pdev) { +struct drm_device *dev =platform_get_drvdata (pdev); +DRM_DEBUG_DRIVER ("%s\n" , __FILE__); -drm_platform_exit (&exynos_drm_driver, pdev); +drm_put_dev (dev);return 0 ; }
include/drm/drmP.h +0 -3
@@ -1678,9 +1678,6 @@ extern int drm_get_pci_dev(struct pci_dev *pdev,/* platform section */ -extern int drm_platform_init (struct drm_driver *driver,struct platform_device *platform_device); -extern void drm_platform_exit (struct drm_driver *driver,struct platform_device *platform_device); -extern int drm_get_platform_dev (struct platform_device *pdev,struct drm_driver *driver);
Signature · 1 line
1.7.8.3
PATCH 6/12 drm usb: drop drm_usb_init/exit
In reply to Sascha HauerUsb drivers can register themselves and call drm_get_usb_dev in their probe function. We don't need a drm specific wrapper function for this. As there are currently no users, none a touched here.
--- drivers/gpu/drm/drm_usb.c | 26 ++++---------------------- include/drm/drm_usb.h | 3 --- 2 files changed, 4 insertions(+), 25 deletions(-)
drivers/gpu/drm/drm_usb.c +4 -22
@@ -2,6 +2,8 @@#include <linux/usb.h> #include <linux/export.h> +static struct drm_bus drm_usb_bus; +#ifdef CONFIG_USB int drm_get_usb_dev(struct usb_interface *interface, const struct usb_device_id *id,
@@ -17,6 +19,8 @@ int drm_get_usb_dev(struct usb_interface *interface,if (!dev)return -ENOMEM ; + driver->bus = &drm_usb_bus; + usbdev =interface_to_usbdev (interface); dev->dev = &usbdev->dev;
@@ -49,8 +53,6 @@ int drm_get_usb_dev(struct usb_interface *interface,if (ret) goto err_g3; -list_add_tail (&dev->driver_item, &driver->device_list); -mutex_unlock (&drm_global_mutex); DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
@@ -92,24 +94,4 @@ static struct drm_bus drm_usb_bus = { .get_name = drm_usb_get_name, .set_busid = drm_usb_set_busid, }; - -int drm_usb_init (struct drm_driver *driver,struct usb_driver *udriver) -{ -int res; -DRM_DEBUG ("\n" ); - -INIT_LIST_HEAD (&driver->device_list); - driver->bus = &drm_usb_bus; - - res =usb_register (udriver); -return res; -} -EXPORT_SYMBOL (drm_usb_init); - -void drm_usb_exit (struct drm_driver *driver, -struct usb_driver *udriver) -{ -usb_deregister (udriver); -} -EXPORT_SYMBOL (drm_usb_exit);#endif
include/drm/drm_usb.h +0 -3
@@ -5,9 +5,6 @@#include <linux/usb.h> -extern int drm_usb_init (struct drm_driver *driver,struct usb_driver *udriver); -extern void drm_usb_exit (struct drm_driver *driver,struct usb_driver *udriver); -int drm_get_usb_dev (struct usb_interface *interface,const struct usb_device_id *id,struct drm_driver *driver);
Signature · 1 line
1.7.8.3
PATCH 7/12 drm: remove now unused device_list
In reply to Sascha HauerThe driver core is better at tracking the devices associated to a device, no need to do this ourselves.
--- drivers/gpu/drm/drm_pci.c | 1 - include/drm/drmP.h | 3 --- 2 files changed, 0 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -1
@@ -399,7 +399,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) {DRM_DEBUG ("\n" ); -INIT_LIST_HEAD (&driver->device_list); driver->bus = &drm_pci_bus;return pci_register_driver (pdriver);
include/drm/drmP.h +0 -3
@@ -915,9 +915,6 @@ struct drm_driver {int num_ioctls;const struct file_operations *fops;struct drm_bus *bus; - -/* List of devices hanging off this driver */ -struct list_head device_list; };#define DRM_MINOR_UNASSIGNED 0
Signature · 1 line
1.7.8.3
PATCH 8/12 drm vmwgfx: remove unused field vmw_chipset from struct vmw_private
In reply to Sascha Hauer--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 - drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -1
@@ -401,7 +401,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)memset (dev_priv,0 ,sizeof (*dev_priv)); dev_priv->dev = dev; - dev_priv->vmw_chipset = chipset; dev_priv->last_read_seqno = (uint32_t )-100 ;mutex_init (&dev_priv->hw_mutex);mutex_init (&dev_priv->cmdbuf_mutex);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0 -1
@@ -194,7 +194,6 @@ struct vmw_private {struct vmw_fifo_state fifo;struct drm_device *dev; -unsigned long vmw_chipset;unsigned int io_start;uint32_t vram_start;uint32_t vram_size;
Signature · 1 line
1.7.8.3
PATCH 9/12 drm: Add drm_register_device function
In reply to Sascha Hauerpci, usb and platform support all duplicate the same code. Provide a common function for this.
--- drivers/gpu/drm/drm_stub.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drmP.h | 2 + 2 files changed, 58 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_stub.c +56 -0
@@ -320,6 +320,62 @@ int drm_fill_in_dev(struct drm_device *dev,return retcode; } +int drm_register_device (struct drm_device *dev,struct drm_driver *driver, +unsigned long flags) +{ +int ret; + +mutex_lock (&drm_global_mutex); + + ret =drm_fill_in_dev (dev,NULL , driver); +if (ret) { +printk (KERN_ERR "DRM: Fill_in_dev failed.\n" ); + goto err_g1; + } + +if (drm_core_check_feature (dev,DRIVER_MODESET )) { + ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL ); +if (ret) + goto err_g1; + } + + ret =drm_get_minor (dev, &dev->primary,DRM_MINOR_LEGACY ); +if (ret) + goto err_g2; + +if (dev->driver->load) { + ret = dev->driver->load (dev, flags); +if (ret) + goto err_g3; + } + +/* setup the grouping for the legacy output */ +if (drm_core_check_feature (dev,DRIVER_MODESET )) { + ret =drm_mode_group_init_legacy_group (dev, + &dev->primary->mode_group); +if (ret) + goto err_g3; + } + +mutex_unlock (&drm_global_mutex); + +DRM_INFO ("Initialized %s %d.%d.%d %s on minor %d\n" , + driver->name, driver->major, driver->minor, driver->patchlevel, + driver->date, dev->primary->index); + +return 0 ; + +err_g3: +drm_put_minor (&dev->primary); +err_g2: +if (drm_core_check_feature (dev,DRIVER_MODESET )) +drm_put_minor (&dev->control); +err_g1: +mutex_unlock (&drm_global_mutex); + +return ret; +} +EXPORT_SYMBOL (drm_register_device);/** * Get a secondary minor number.
include/drm/drmP.h +2 -0
@@ -1651,6 +1651,8 @@ extern int drm_fill_in_dev(struct drm_device *dev,const struct pci_device_id *ent, struct drm_driver *driver);int drm_get_minor (struct drm_device *dev,struct drm_minor **minor,int type); +int drm_register_device (struct drm_device *dev,struct drm_driver *driver, +unsigned long flags);/*@}*/ /* PCI section */
Signature · 1 line
1.7.8.3
PATCH 10/12 drm pci: use drm_register_device
In reply to Sascha Hauer--- drivers/gpu/drm/drm_pci.c | 45 +++------------------------------------------ 1 files changed, 3 insertions(+), 42 deletions(-)
drivers/gpu/drm/drm_pci.c +3 -42
@@ -332,54 +332,15 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, dev->hose = pdev->sysdata;#endif -mutex_lock (&drm_global_mutex); - -if ((ret =drm_fill_in_dev (dev, ent, driver))) { -printk (KERN_ERR "DRM: Fill_in_dev failed.\n" ); + ret =drm_register_device (dev, driver, ent->driver_data); +if (ret) goto err_g2; - } - -if (drm_core_check_feature (dev,DRIVER_MODESET )) { -pci_set_drvdata (pdev, dev); - ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL ); -if (ret) - goto err_g2; - } - -if ((ret =drm_get_minor (dev, &dev->primary,DRM_MINOR_LEGACY ))) - goto err_g3; - -if (dev->driver->load) { - ret = dev->driver->load (dev, ent->driver_data); -if (ret) - goto err_g4; - } - -/* setup the grouping for the legacy output */ -if (drm_core_check_feature (dev,DRIVER_MODESET )) { - ret =drm_mode_group_init_legacy_group (dev, - &dev->primary->mode_group); -if (ret) - goto err_g4; - } - -DRM_INFO ("Initialized %s %d.%d.%d %s for %s on minor %d\n" , - driver->name, driver->major, driver->minor, driver->patchlevel, - driver->date,pci_name (pdev), dev->primary->index); -mutex_unlock (&drm_global_mutex); -return 0 ; - -err_g4: -drm_put_minor (&dev->primary); -err_g3: -if (drm_core_check_feature (dev,DRIVER_MODESET )) -drm_put_minor (&dev->control); +return ret; err_g2:pci_disable_device (pdev); err_g1:kfree (dev); -mutex_unlock (&drm_global_mutex);return ret; }EXPORT_SYMBOL (drm_get_pci_dev);
Signature · 1 line
1.7.8.3
PATCH 11/12 drm platform: use drm_register_device
In reply to Sascha Hauer--- drivers/gpu/drm/drm_platform.c | 51 ++------------------------------------- 1 files changed, 3 insertions(+), 48 deletions(-)
drivers/gpu/drm/drm_platform.c +3 -48
@@ -56,57 +56,12 @@ int drm_get_platform_dev(struct platform_device *platdev, dev->dev = &platdev->dev; driver->bus = &drm_platform_bus; +dev_set_drvdata (&platdev->dev, dev); -mutex_lock (&drm_global_mutex); - - ret =drm_fill_in_dev (dev,NULL , driver); - -if (ret) { -printk (KERN_ERR "DRM: Fill_in_dev failed.\n" ); - goto err_g1; - } - -if (drm_core_check_feature (dev,DRIVER_MODESET )) { -dev_set_drvdata (&platdev->dev, dev); - ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL ); -if (ret) - goto err_g1; - } - - ret =drm_get_minor (dev, &dev->primary,DRM_MINOR_LEGACY ); + ret =drm_register_device (dev, driver,0 );if (ret) - goto err_g2; - -if (dev->driver->load) { - ret = dev->driver->load (dev,0 ); -if (ret) - goto err_g3; - } - -/* setup the grouping for the legacy output */ -if (drm_core_check_feature (dev,DRIVER_MODESET )) { - ret =drm_mode_group_init_legacy_group (dev, - &dev->primary->mode_group); -if (ret) - goto err_g3; - } - -mutex_unlock (&drm_global_mutex); - -DRM_INFO ("Initialized %s %d.%d.%d %s on minor %d\n" , - driver->name, driver->major, driver->minor, driver->patchlevel, - driver->date, dev->primary->index); - -return 0 ; +kfree (dev); -err_g3: -drm_put_minor (&dev->primary); -err_g2: -if (drm_core_check_feature (dev,DRIVER_MODESET )) -drm_put_minor (&dev->control); -err_g1: -kfree (dev); -mutex_unlock (&drm_global_mutex);return ret; }EXPORT_SYMBOL (drm_get_platform_dev);
Signature · 1 line
1.7.8.3
PATCH 12/12 drm usb: use drm_register_device
In reply to Sascha Hauer--- drivers/gpu/drm/drm_usb.c | 43 ++----------------------------------------- 1 files changed, 2 insertions(+), 41 deletions(-)
drivers/gpu/drm/drm_usb.c +2 -41
@@ -24,52 +24,13 @@ int drm_get_usb_dev(struct usb_interface *interface, usbdev =interface_to_usbdev (interface); dev->dev = &usbdev->dev; -mutex_lock (&drm_global_mutex); - - ret =drm_fill_in_dev (dev,NULL , driver); -if (ret) { -printk (KERN_ERR "DRM: Fill_in_dev failed.\n" ); - goto err_g1; - } -usb_set_intfdata (interface, dev); - ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL ); -if (ret) - goto err_g1; - - ret =drm_get_minor (dev, &dev->primary,DRM_MINOR_LEGACY ); -if (ret) - goto err_g2; - -if (dev->driver->load) { - ret = dev->driver->load (dev,0 ); -if (ret) - goto err_g3; - } -/* setup the grouping for the legacy output */ - ret =drm_mode_group_init_legacy_group (dev, - &dev->primary->mode_group); + ret =drm_register_device (dev, driver,0 );if (ret) - goto err_g3; +kfree (dev); -mutex_unlock (&drm_global_mutex); - -DRM_INFO ("Initialized %s %d.%d.%d %s on minor %d\n" , - driver->name, driver->major, driver->minor, driver->patchlevel, - driver->date, dev->primary->index); - -return 0 ; - -err_g3: -drm_put_minor (&dev->primary); -err_g2: -drm_put_minor (&dev->control); -err_g1: -kfree (dev); -mutex_unlock (&drm_global_mutex);return ret; - }EXPORT_SYMBOL (drm_get_usb_dev);
Signature · 1 line
1.7.8.3
----- Original Message -----
Quoted 6 lines
From: "Sascha Hauer" <[email protected]>
To: [email protected]
Cc: "Inki Dae" <[email protected]>, [email protected]
Sent: Thursday, 2 February, 2012 11:57:52 AM
Subject: [PATCH] drm: cleanup device registration
Quoted 10 lines
The non modesetting drm drivers currently use a handcrafted pci probe function. This requires the drm core to keep a list of registered devices
for each driver. This series adds a probe function for the non modesetting
drivers and removes the legacy probe code. The USB and platform drivers
use thedevices_listaswell which is unnecessary. This is also cleaned
up in this series.
No it can't work like this because we have conflicts between fb and drm drivers, so the DRM is required to do its own probe if an fb driver for a device is already loaded.
it can't use the PCI probe out of the box.
Dave.
Quoted 18 lines · David Airlie
----- Original Message -----
Quoted 6 lines
From: "Sascha Hauer" <[email protected]>
To: [email protected]
Cc: "Inki Dae" <[email protected]>, [email protected]
Sent: Thursday, 2 February, 2012 11:57:52 AM
Subject: [PATCH] drm: cleanup device registrationQuoted 10 lines
The non modesetting drm drivers currently use a handcrafted pci probe function. This requires the drm core to keep a list of registered devices
for each driver. This series adds a probe function for the non modesetting
drivers and removes the legacy probe code. The USB and platform drivers
use thedevices_listaswell which is unnecessary. This is also cleaned
up in this series.
Quoted 4 lines
No it can't work like this because we have conflicts between fb and drm drivers, so the DRM is required to do its own probe if an fb driver for a device is already loaded.
it can't use the PCI probe out of the box.
I see. For example the i810 also has a framebuffer driver. Do you see a way to fix this except writing a kms driver for all legacy devices? Otherwise I would leave the pci part untouched and only keep the platform/USB pieces which I'm admittedly more interested in.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
----- Original Message -----
Quoted 30 lines
From: "Sascha Hauer" <[email protected]>
To: "David Airlie" <[email protected]>
Cc: "Inki Dae" <[email protected]>, [email protected], [email protected]
Sent: Thursday, 2 February, 2012 12:34:02 PM
Subject: Re: [PATCH] drm: cleanup device registrationQuoted 23 lines · David Airlie
----- Original Message -----
Quoted 6 lines
From: "Sascha Hauer" <[email protected]>
To: [email protected]
Cc: "Inki Dae" <[email protected]>, [email protected]
Sent: Thursday, 2 February, 2012 11:57:52 AM
Subject: [PATCH] drm: cleanup device registrationQuoted 11 lines
The non modesetting drm drivers currently use a handcrafted pci probe
function. This requires the drm core to keep a list of registered devices
for each driver. This series adds a probe function for the non modesetting
drivers and removes the legacy probe code. The USB and platform drivers
use thedevices_listaswell which is unnecessary. This is also cleaned
up in this series.No it can't work like this because we have conflicts between fb and drm drivers, so the DRM is required to do its own
probe if an fb driver for a device is already loaded.
Quoted 7 lines
Quoted 1 line
it can't use the PCI probe out of the box.
I see. For example the i810 also has a framebuffer driver. Do you see a way to fix this except writing a kms driver for all legacy devices? Otherwise I would leave the pci part untouched and only keep the platform/USB pieces which I'm admittedly more interested in.
Its one of those things that would be a real pain to fix, since we can't remove drm drivers since their interfaces are ABI. So its why its been left like it is.
It might be possible to split the PCI path up a bit so the non-kms drivers use it, and we port kms ones to a newer interfaces, but I think nouveau is the only PCI KMS only driver we have (maybe vmwgfx as well).
Dave.
Quoted 4 lines
I see. For example the i810 also has a framebuffer driver. Do you see a way to fix this except writing a kms driver for all legacy devices? Otherwise I would leave the pci part untouched and only keep the platform/USB pieces which I'm admittedly more interested in.
Which is obsolete and unmaintained. More of a problem would be the various ati framebuffer drivers.
I would like to see Linux move to the situation where if there is a driver for a given device its either one or the other not one and some legacy code which is just extra work.
Doesn't need to be "all KMS" - but for any given card either/or seems perfectly reasonable.
The big thing that is needed is someone crazy enough to write a KMS driver to replace vesa/uvesafb and the like.
Alan
Quoted 12 lines · Alan Cox
Quoted 4 lines
I see. For example the i810 also has a framebuffer driver. Do you see a way to fix this except writing a kms driver for all legacy devices? Otherwise I would leave the pci part untouched and only keep the platform/USB pieces which I'm admittedly more interested in.
Which is obsolete and unmaintained. More of a problem would be the various ati framebuffer drivers.
I would like to see Linux move to the situation where if there is a driver for a given device its either one or the other not one and some legacy code which is just extra work.
Quoted 5 lines
Doesn't need to be "all KMS" - but for any given card either/or seems perfectly reasonable.
The big thing that is needed is someone crazy enough to write a KMS driver to replace vesa/uvesafb and the like.
I am currently working on a layer which provides all the necessary drm glue code for simple framebuffer devices. My test driver is a Freescale i.MX framebuffer driver. This currently has < 500 loc which is less than the corresponding driver under drivers/video. I am not crazy enough to implement a vesa KMS driver, but my hope is that these tasks can become quite easy with such a layer.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |