drm de-midlayer, part 1: device list and agp bus stuff
Subsystems (14)
cover drm de-midlayer, part 1: device list and agp bus stuff
Hi all,
So at ks there was a lot of talk about fixing up the drm device model to stop insanity like imx. And I kinda promised Dave to resurrect my latest branch at drm demidlayering - motivation kinda dissipated when I've started this a few moons back.
So this is the first part. Patches 1-11 rework the device list. The ugly part is that drm_platform_exit survived from the horrible days of shadow attache despite that no platform drm driver with shadow attach was ever merged. And everyone dutifully copypasted the crap out of this. Compiletested for all drm drivers that work with arm multiplatforms. Luckily that now includes exynons (yay), but the new kid msm on the block fails this (shame on Rob).
The remaining stuff flattens some of the agp indirection madness away. Plus a tiny patch in between as a follow-up cleanup for David's vma offset manager work. Also includes one patch from David, rebased into my series.
Next up on my plan is to get rid of drm_bus completely. I already have a plan for the irq stuff and a few patches, which leaves the setversion/busid/... bonghits madness. But that's luckily constraint to the drm core.
Once that's settled I think we can start to untangle the driver load/setup vs. interface registration mess. David&Dave already have patches to play around with that. Then we need to untangle all the drm lifetime rules around open files, mmaps, sysfs and debugfs files so that finally we can try to fix the driver unload madness. Or at least that's my overtly optimistic plan.
Flames, comments and more good&dry wood for the pyre highly welcome.
Cheers, Daniel
Daniel Vetter (18):
drm/rcar: call drm_put_dev directly in the ->remove hook drm/exynos: call drm_put_dev directly from ->remove drm/imx: directly call drm_put_dev in ->remove drm/tilcdc: call drm_put_dev directly from ->remove drm/omap: call drm_put_dev directly in ->remove drm/shmob: call drm_put_dev directly from ->remove hook drm/host1x: Call drm_put_dev directly instead of drm_platform_exit drm/armada: directly call drm_put_dev in ->remove drm/msm: call drm_put_dev directly in ->remove
drm: rip out drm_platform_exit
drm: restrict the device list for shadow attached drivers drm/bufs: remove handling of _DRM_GEM mappings
drm: kill DRIVER_REQUIRE_AGP
drm: ->agp_init can't fail
drm: rip out drm_core_has_AGP
drm: inline drm_agp_destroy
drm: kill the ->agp_destroy callback
drm: remove global_mutex locking around agp_init
David Herrmann (1):
drm: remove agp_init() bus callback
drivers/gpu/drm/armada/armada_drv.c | 3 ++- drivers/gpu/drm/drm_agpsupport.c | 17 +------------- drivers/gpu/drm/drm_bufs.c | 10 ++------- drivers/gpu/drm/drm_memory.c | 9 +++----- drivers/gpu/drm/drm_pci.c | 38 +++++++++++++++++--------------- drivers/gpu/drm/drm_platform.c | 12 ---------- drivers/gpu/drm/drm_stub.c | 19 +++------------- drivers/gpu/drm/drm_usb.c | 1 - drivers/gpu/drm/drm_vm.c | 7 ++---- drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 +++- drivers/gpu/drm/i810/i810_dma.c | 4 ++++ drivers/gpu/drm/i810/i810_drv.c | 2 +- drivers/gpu/drm/i915/i915_dma.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.c | 5 ++--- drivers/gpu/drm/msm/msm_drv.c | 2 +- drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++-- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 4 +++- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 4 +++- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- drivers/gpu/host1x/drm/drm.c | 3 +-- drivers/staging/imx-drm/imx-drm-core.c | 4 +++- include/drm/drmP.h | 13 ++++------- include/drm/drm_agpsupport.h | 17 -------------- include/uapi/drm/drm.h | 1 - 25 files changed, 67 insertions(+), 125 deletions(-)
Signature · 1 line
1.8.4.rc3
PATCH 1/19 drm/rcar: call drm_put_dev directly in the ->remove hook
The magic dance drm_platform_exit does is actually a remnant of the old legacy shadow attach support for platform devices. Modern modesetting drm drivers shouldn't do this any more (and usb/pci devices actually don't do this).
--- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/rcar-du/rcar_du_drv.c +3 -1
@@ -224,7 +224,9 @@ static int rcar_du_probe(struct platform_device *pdev)static int rcar_du_remove (struct platform_device *pdev) { -drm_platform_exit (&rcar_du_driver, pdev); +struct rcar_du_device *rcdu =platform_get_drvdata (pdev); + +drm_put_dev (rcdu->ddev);return 0 ; }
Signature · 1 line
1.8.4.rc3
Re: [PATCH 01/19] drm/rcar: call drm_put_dev directly in the ->remove hook
Hi Daniel,
Thank you for the patch.
Quoted 7 lines · On Sunday 03 November 2013 14:31:07 Daniel Vetter wrote:
The magic dance
drm_platform_exitdoes is actually a remnant of the old legacy shadow attach support for platform devices. Modern modesetting drm drivers shouldn't do this any more (and usb/pci devices actually don't do this).Cc Laurent Pinchart <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
For 01/19 and 06/19,
Quoted 20 lines
--- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/rcar-du/rcar_du_drv.cindex0023f9719cf1..4ec6272a1c11100644drivers/gpu/drm/rcar-du/rcar_du_drv.c +3
-1@@ -224,7 +224,9 @@ static int rcar_du_probe(struct platform_device *pdev)static int rcar_du_remove (struct platform_device *pdev) { -drm_platform_exit (&rcar_du_driver, pdev); +struct rcar_du_device *rcdu =platform_get_drvdata (pdev); + +drm_put_dev (rcdu->ddev);return 0 ; }
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 2/19 drm/exynos: call drm_put_dev directly from ->remove
In reply to Daniel VetterI didn't find any user of the driver data yet, so store the drm_device pointer in there.
--- drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +3 -1
@@ -119,6 +119,8 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags) drm_vblank_offdelay =VBLANK_OFF_DELAY ; +platform_set_drvdata (dev->platformdev, dev); +return 0 ; err_drm_device:
@@ -292,7 +294,7 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)static int exynos_drm_platform_remove (struct platform_device *pdev) { -drm_platform_exit (&exynos_drm_driver, pdev); +drm_put_dev (platform_get_drvdata (pdev));return 0 ; }
Signature · 1 line
1.8.4.rc3
PATCH 3/19 drm/imx: directly call drm_put_dev in ->remove
In reply to Daniel VetterAgain no apparent user of the driver data field.
--- drivers/staging/imx-drm/imx-drm-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/imx-drm/imx-drm-core.c +3 -1
@@ -432,6 +432,8 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)if (!imx_drm_device_get ()) ret = -EINVAL ; +platform_set_drvdata (drm->platformdev, drm); + ret =0 ; err_init:
@@ -807,7 +809,7 @@ static int imx_drm_platform_probe(struct platform_device *pdev)static int imx_drm_platform_remove (struct platform_device *pdev) { -drm_platform_exit (&imx_drm_driver, pdev); +drm_put_dev (platform_get_drvdata (pdev));return 0 ; }
Signature · 1 line
1.8.4.rc3
Re: [PATCH 03/19] drm/imx: directly call drm_put_dev in ->remove
Quoted 5 lines · Daniel Vetter
Again no apparent user of the driver data field.
Cc Sascha Hauer <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Sascha
Quoted 30 lines
--- drivers/staging/imx-drm/imx-drm-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/staging/imx-drm/imx-drm-core.c +3
-1@@ -432,6 +432,8 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)if (!imx_drm_device_get ()) ret = -EINVAL ; +platform_set_drvdata (drm->platformdev, drm); + ret =0 ; err_init:@@ -807,7 +809,7 @@ static int imx_drm_platform_probe(struct platform_device *pdev)static int imx_drm_platform_remove (struct platform_device *pdev) { -drm_platform_exit (&imx_drm_driver, pdev); +drm_put_dev (platform_get_drvdata (pdev));return 0 ; }Signature · 1 line
1.8.4.rc3
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 |
PATCH 4/19 drm/tilcdc: call drm_put_dev directly from ->remove
In reply to Daniel Vettertilcdc already stores the drm_device in the driver data pointer. So use that.
--- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
@@ -594,7 +594,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)static int tilcdc_pdev_remove (struct platform_device *pdev) { -drm_platform_exit (&tilcdc_driver, pdev); +drm_put_dev (platform_get_drvdata (pdev));return 0 ; }
Signature · 1 line
1.8.4.rc3
PATCH 5/19 drm/omap: call drm_put_dev directly in ->remove
In reply to Daniel VetterAgain omap already sets the driver data pointer to the drm_device.
Also drop the driver unregister call, that should be (and already is) done in the module unload hook.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +2 -2
@@ -665,9 +665,9 @@ static int pdev_probe(struct platform_device *device)static int pdev_remove (struct platform_device *device) {DBG ("" ); -drm_platform_exit (&omap_drm_driver, device); -platform_driver_unregister (&omap_dmm_driver); +drm_put_dev (platform_get_drvdata (device)); +return 0 ; }
Signature · 1 line
1.8.4.rc3
PATCH 6/19 drm/shmob: call drm_put_dev directly from ->remove hook
In reply to Daniel VetterWe need to chase one pointer here.
--- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/shmobile/shmob_drm_drv.c +3 -1
@@ -336,7 +336,9 @@ static int shmob_drm_probe(struct platform_device *pdev)static int shmob_drm_remove (struct platform_device *pdev) { -drm_platform_exit (&shmob_drm_driver, pdev); +struct shmob_drm_device *sdev =platform_get_drvdata (pdev); + +drm_put_dev (sdev->ddev);return 0 ; }
Signature · 1 line
1.8.4.rc3
PATCH 7/19 drm/host1x: Call drm_put_dev directly instead of drm_platform_exit
In reply to Daniel VetterI'm a bit confused about how this all works wrt host1x clients, but this patch looks like the right thing to me.
--- drivers/gpu/host1x/drm/drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/host1x/drm/drm.c +1 -2
@@ -161,7 +161,6 @@ int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm)int host1x_drm_exit (struct host1x_drm *host1x) { -struct platform_device *pdev =to_platform_device (host1x->dev);struct host1x_client *client;if (!host1x->drm)
@@ -184,7 +183,7 @@ int host1x_drm_exit(struct host1x_drm *host1x)mutex_unlock (&host1x->clients_lock); -drm_platform_exit (&tegra_drm_driver, pdev); +drm_put_dev (host1x->drm); host1x->drm =NULL ;return 0 ;
Signature · 1 line
1.8.4.rc3
Re: [PATCH 07/19] drm/host1x: Call drm_put_dev directly instead of drm_platform_exit
Quoted 8 lines · Daniel Vetter
I'm a bit confused about how this all works wrt host1x clients, but this patch looks like the right thing to me.
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/host1x/drm/drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
This has been largely rewritten in the code that I submitted in my 3.13 pull request. In fact Tegra DRM no longer uses drm_platform, but a custom bus type to deal with the quirkiness of the multi-driver architecture.
So if you really want to get rid of drm_bus altogether I'd appreciate a heads-up so I know what's coming and can prepare.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/19] drm/host1x: Call drm_put_dev directly instead of drm_platform_exit
Quoted 10 lines · Thierry Reding
Quoted 8 lines · Daniel Vetter
I'm a bit confused about how this all works wrt host1x clients, but this patch looks like the right thing to me.
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/host1x/drm/drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 4 lines
This has been largely rewritten in the code that I submitted in my 3.13 pull request. In fact Tegra DRM no longer uses
drm_platform, but a custom bus type to deal with the quirkiness of the multi-driver architecture.
And for what it's worth, there's a drm_host1x_exit() that actually does only drm_put_dev(), which I guess could be simplified in the way that you've done here, but I sort of liked the symmetry between an *_init()/ *_exit() pair of functions.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/19] drm/host1x: Call drm_put_dev directly instead of drm_platform_exit
In reply to Thierry RedingQuoted 10 lines · Thierry Reding
Quoted 8 lines · Daniel Vetter
I'm a bit confused about how this all works wrt host1x clients, but this patch looks like the right thing to me.
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/host1x/drm/drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 7 lines
This has been largely rewritten in the code that I submitted in my 3.13 pull request. In fact Tegra DRM no longer uses
drm_platform, but a custom bus type to deal with the quirkiness of the multi-driver architecture.So if you really want to get rid of
drm_busaltogether I'd appreciate a heads-up so I know what's coming and can prepare.
It's almost completely gone now, the one thing left to do is rip out bus->set_busid. But I have that planned already.
http://cgit.freedesktop.org/~danvet/drm/log/?h=drm-init-cleanup
I guess I get to rebase the entire thing again, meh.
<rant>
It'd be awesome of other drm drivers would submit their stuff a bit earlier, atm there's absolutely nothing in drm-next beside all of intel and a few things for armada... Maybe we need to have a drm integration tree to make this a bit less frustrating. </rant>
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 07/19] drm/host1x: Call drm_put_dev directly instead of drm_platform_exit
Quoted 25 lines · Daniel Vetter
Quoted 10 lines · Thierry Reding
Quoted 8 lines · Daniel Vetter
I'm a bit confused about how this all works wrt host1x clients, but this patch looks like the right thing to me.
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/host1x/drm/drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Quoted 7 lines
This has been largely rewritten in the code that I submitted in my 3.13 pull request. In fact Tegra DRM no longer uses
drm_platform, but a custom bus type to deal with the quirkiness of the multi-driver architecture.So if you really want to get rid of
drm_busaltogether I'd appreciate a heads-up so I know what's coming and can prepare.It's almost completely gone now, the one thing left to do is rip out
bus->set_busid. But I have that planned already.http://cgit.freedesktop.org/~danvet/drm/log/?h=drm-init-cleanup
Quoted 8 lines
I guess I get to rebase the entire thing again, meh.
<rant>
It'd be awesome of other drm drivers would submit their stuff a bit earlier, atm there's absolutely nothing in drm-next beside all of intel and a few things for armada... Maybe we need to have a drm integration tree to make this a bit less frustrating. </rant>
Yeah, I know. I had actually planned on sending out this pull request much earlier, but then all the discussion around DRM panel and device tree bindings started again...
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/19 drm/armada: directly call drm_put_dev in ->remove
In reply to Daniel VetterAgain no apparent user of the driver data field.
--- drivers/gpu/drm/armada/armada_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/armada/armada_drv.c +2 -1
@@ -128,6 +128,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)return -ENOMEM ; } +platform_set_drvdata (dev->platformdev, dev); dev->dev_private = priv;/* Get the implementation specific driver data. */
@@ -376,7 +377,7 @@ static int armada_drm_probe(struct platform_device *pdev)static int armada_drm_remove (struct platform_device *pdev) { -drm_platform_exit (&armada_drm_driver, pdev); +drm_put_dev (platform_get_drvdata (pdev));return 0 ; }
Signature · 1 line
1.8.4.rc3
PATCH 9/19 drm/msm: call drm_put_dev directly in ->remove
In reply to Daniel VetterThe drvdata pointer is already assigned to something useful.
--- drivers/gpu/drm/msm/msm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -747,7 +747,7 @@ static int msm_pdev_probe(struct platform_device *pdev)static int msm_pdev_remove (struct platform_device *pdev) { -drm_platform_exit (&msm_driver, pdev); +drm_put_dev (platform_get_drvdata (pdev));return 0 ; }
Signature · 1 line
1.8.4.rc3
PATCH 10/19 drm: rip out drm_platform_exit
In reply to Daniel VetterThis very much looks like a remnant of the old legady ums shadow attach days. Now with the last users gone we can rip it out since we won't ever support an ums drm driver again.
--- drivers/gpu/drm/drm_platform.c | 11 ----------- include/drm/drmP.h | 1 - 2 files changed, 12 deletions(-)
drivers/gpu/drm/drm_platform.c +0 -11
@@ -151,14 +151,3 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platforreturn 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);
include/drm/drmP.h +0 -1
@@ -1675,7 +1675,6 @@ 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 void drm_platform_exit (struct drm_driver *driver,struct platform_device *platform_device);/* returns true if currently okay to sleep */ static __inline__bool drm_can_sleep (void )
Signature · 1 line
1.8.4.rc3
PATCH 11/19 drm: restrict the device list for shadow attached drivers
In reply to Daniel VetterThere's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us.
The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else.
v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus dev_set_drvdata for platform drivers that somehow crept into the original version - drivers really should be in full control of that field.
--- drivers/gpu/drm/drm_pci.c | 12 ++++++++++-- drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_stub.c | 4 ---- drivers/gpu/drm/drm_usb.c | 1 - include/drm/drmP.h | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_pci.c +10 -2
@@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, driver->name, driver->major, driver->minor, driver->patchlevel, driver->date, pci_name(pdev), dev->primary->index); +/* No locking needed since shadow-attach is single-threaded since it may +* only be called from the per-driver module init hook. */ +if (!drm_core_check_feature (dev,DRIVER_MODESET )) +list_add_tail (&dev->legacy_dev_list, &driver->legacy_dev_list); +return 0 ; err_pci:
@@ -375,7 +380,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;
@@ -384,6 +388,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)/* If not using KMS, fall back to stealth mode manual scanning. */ for (i =0 ; pdriver->id_table[i].vendor !=0 ; i++) { +INIT_LIST_HEAD (&driver->legacy_dev_list); pid = &pdriver->id_table[i];/* Loop around setting up a DRM device for each PCI device
@@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)if (driver->driver_features &DRIVER_MODESET ) {pci_unregister_driver (pdriver); }else { -list_for_each_entry_safe (dev, tmp, &driver->device_list, driver_item) +list_for_each_entry_safe (dev, tmp, &driver->legacy_dev_list, + legacy_dev_list) {drm_put_dev (dev); +list_del (&dev->legacy_dev_list); + } }DRM_INFO ("Module unloaded\n" ); }
drivers/gpu/drm/drm_platform.c +0 -1
@@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor 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); }EXPORT_SYMBOL (drm_platform_init);
drivers/gpu/drm/drm_stub.c +0 -4
@@ -538,8 +538,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) goto err_unload; } -list_add_tail (&dev->driver_item, &dev->driver->device_list); - ret =0 ; goto out_unlock;
@@ -593,7 +591,5 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->render)drm_put_minor (&dev->render);drm_put_minor (&dev->primary); - -list_del (&dev->driver_item); }EXPORT_SYMBOL (drm_dev_unregister);
drivers/gpu/drm/drm_usb.c +0 -1
@@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)int res;DRM_DEBUG ("\n" ); -INIT_LIST_HEAD (&driver->device_list); driver->kdriver.usb = udriver; driver->bus = &drm_usb_bus;
include/drm/drmP.h +3 -3
@@ -988,8 +988,8 @@ struct drm_driver { } kdriver;struct drm_bus *bus; -/* List of devices hanging off this driver */ -struct list_head device_list; +/* List of devices hanging off this driver with stealth attach. */ +struct list_head legacy_dev_list; };#define DRM_MINOR_UNASSIGNED 0
@@ -1099,7 +1099,7 @@ struct drm_vblank_crtc {* may contain multiple heads. */ struct drm_device { -struct list_head driver_item;/**< list of devices per driver */ +struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ char *devname;/**< For /proc/interrupts */ int if_version;/**< Highest interface version set */
Signature · 1 line
1.8.4.rc3
Re: [PATCH 11/19] drm: restrict the device list for shadow attached drivers
Hi Daniel
Quoted 4 lines · Daniel Vetter
There's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us.
Quoted 8 lines
The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else.
v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus
dev_set_drvdatafor platform drivers that somehow crept into the original version - drivers really should be in full control of that field.
You didn't really change any dev_set_drvdata, did you? And I guess you mean pci_set_drvdata()? I had to keep it in place in drm_pci.c as it has been there before my device-registration changes. However, with your series you added the pci_set_drvdata() everywhere yourself, so yes, please remove it.
Quoted 35 lines
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 12 ++++++++++-- drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_stub.c | 4 ---- drivers/gpu/drm/drm_usb.c | 1 - include/drm/drmP.h | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_pci.c +5
-1@@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, driver->name, driver->major, driver->minor, driver->patchlevel, driver->date, pci_name(pdev), dev->primary->index); +/* No locking needed since shadow-attach is single-threaded since it may +* only be called from the per-driver module init hook. */ +if (!drm_core_check_feature (dev,DRIVER_MODESET )) +list_add_tail (&dev->legacy_dev_list, &driver->legacy_dev_list); +return 0 ; err_pci:@@ -375,7 +380,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;
drivers/gpu/drm/drm_pci.c int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) · line 391
Quoted 4 lines
drivers/gpu/drm/drm_pci.c +1
-0@@ -384,6 +388,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)/* If not using KMS, fall back to stealth mode manual scanning. */ for (i =0 ; pdriver->id_table[i].vendor !=0 ; i++) { +INIT_LIST_HEAD (&driver->legacy_dev_list);
Why doing this inside of the loop? If the pci_get_dev() below succeeds, you clear the list again?
Thanks
David
Quoted 92 lines
drivers/gpu/drm/drm_pci.c +4
-1pid = &pdriver->id_table[i];/* Loop around setting up a DRM device for each PCI device @@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)if (driver->driver_features &DRIVER_MODESET ) {pci_unregister_driver (pdriver); }else { -list_for_each_entry_safe (dev, tmp, &driver->device_list, driver_item) +list_for_each_entry_safe (dev, tmp, &driver->legacy_dev_list, + legacy_dev_list) {drm_put_dev (dev); +list_del (&dev->legacy_dev_list); + } }DRM_INFO ("Module unloaded\n" ); }drivers/gpu/drm/drm_platform.c +0
-1@@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor 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); }EXPORT_SYMBOL (drm_platform_init);drivers/gpu/drm/drm_stub.c +0
-4@@ -538,8 +538,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) goto err_unload; } -list_add_tail (&dev->driver_item, &dev->driver->device_list); - ret =0 ; goto out_unlock;@@ -593,7 +591,5 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->render)drm_put_minor (&dev->render);drm_put_minor (&dev->primary); - -list_del (&dev->driver_item); }EXPORT_SYMBOL (drm_dev_unregister);drivers/gpu/drm/drm_usb.c +0
-1@@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)int res;DRM_DEBUG ("\n" ); -INIT_LIST_HEAD (&driver->device_list); driver->kdriver.usb = udriver; driver->bus = &drm_usb_bus;include/drm/drmP.h +3
-4@@ -988,8 +988,8 @@ struct drm_driver { } kdriver;struct drm_bus *bus; -/* List of devices hanging off this driver */ -struct list_head device_list; +/* List of devices hanging off this driver with stealth attach. */ +struct list_head legacy_dev_list; };#define DRM_MINOR_UNASSIGNED 0@@ -1099,7 +1099,7 @@ struct drm_vblank_crtc {* may contain multiple heads. */ struct drm_device { -struct list_head driver_item;/**< list of devices per driver */ +struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ char *devname;/**< For /proc/interrupts */ int if_version;/**< Highest interface version set */ --1.8.4.rc3
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 11/19] drm: restrict the device list for shadow attached drivers
Quoted 14 lines · David Herrmann
Quoted 4 lines · Daniel Vetter
There's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us.
Quoted 8 lines
The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else.
v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus
dev_set_drvdatafor platform drivers that somehow crept into the original version - drivers really should be in full control of that field.
Quoted 5 lines
You didn't really change any
dev_set_drvdata, did you? And I guess you meanpci_set_drvdata()? I had to keep it in place indrm_pci.cas it has been there before my device-registration changes. However, with your series you added thepci_set_drvdata()everywhere yourself, so yes, please remove it.
That was a bogus hunk in v1 of this patch, which iirc I've never posted onto the list anywhere. I added a platfrom_set_drvdata call, but with the previous series to make sure that each driver has that it's a bit redundant.
Long term, when we split up the drm init code I think the drvdata assignment should be the driver's job.
I'll fix the fumble with the list_head init, thanks for spotting that. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm: restrict the device list for shadow attached drivers
There's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us.
The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else.
v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus dev_set_drvdata for platform drivers that somehow crept into the original version - drivers really should be in full control of that field.
v3: Initialize driver->legacy_dev_list outside of the loop, spotted by David Herrmann.
--- drivers/gpu/drm/drm_pci.c | 12 ++++++++++-- drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_stub.c | 4 ---- drivers/gpu/drm/drm_usb.c | 1 - include/drm/drmP.h | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_pci.c +10 -2
@@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, driver->name, driver->major, driver->minor, driver->patchlevel, driver->date, pci_name(pdev), dev->primary->index); +/* No locking needed since shadow-attach is single-threaded since it may +* only be called from the per-driver module init hook. */ +if (!drm_core_check_feature (dev,DRIVER_MODESET )) +list_add_tail (&dev->legacy_dev_list, &driver->legacy_dev_list); +return 0 ; err_pci:
@@ -375,7 +380,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;
@@ -383,6 +387,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)return pci_register_driver (pdriver);/* If not using KMS, fall back to stealth mode manual scanning. */ +INIT_LIST_HEAD (&driver->legacy_dev_list);for (i =0 ; pdriver->id_table[i].vendor !=0 ; i++) { pid = &pdriver->id_table[i];
@@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)if (driver->driver_features &DRIVER_MODESET ) {pci_unregister_driver (pdriver); }else { -list_for_each_entry_safe (dev, tmp, &driver->device_list, driver_item) +list_for_each_entry_safe (dev, tmp, &driver->legacy_dev_list, + legacy_dev_list) {drm_put_dev (dev); +list_del (&dev->legacy_dev_list); + } }DRM_INFO ("Module unloaded\n" ); }
drivers/gpu/drm/drm_platform.c +0 -1
@@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor 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); }EXPORT_SYMBOL (drm_platform_init);
drivers/gpu/drm/drm_stub.c +0 -4
@@ -538,8 +538,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) goto err_unload; } -list_add_tail (&dev->driver_item, &dev->driver->device_list); - ret =0 ; goto out_unlock;
@@ -593,7 +591,5 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->render)drm_put_minor (&dev->render);drm_put_minor (&dev->primary); - -list_del (&dev->driver_item); }EXPORT_SYMBOL (drm_dev_unregister);
drivers/gpu/drm/drm_usb.c +0 -1
@@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)int res;DRM_DEBUG ("\n" ); -INIT_LIST_HEAD (&driver->device_list); driver->kdriver.usb = udriver; driver->bus = &drm_usb_bus;
include/drm/drmP.h +3 -3
@@ -988,8 +988,8 @@ struct drm_driver { } kdriver;struct drm_bus *bus; -/* List of devices hanging off this driver */ -struct list_head device_list; +/* List of devices hanging off this driver with stealth attach. */ +struct list_head legacy_dev_list; };#define DRM_MINOR_UNASSIGNED 0
@@ -1099,7 +1099,7 @@ struct drm_vblank_crtc {* may contain multiple heads. */ struct drm_device { -struct list_head driver_item;/**< list of devices per driver */ +struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ char *devname;/**< For /proc/interrupts */ int if_version;/**< Highest interface version set */
Signature · 1 line
1.8.4.rc3
Re: [PATCH 11/19] drm: restrict the device list for shadow attached drivers
In reply to Daniel VetterQuoted 21 lines · Daniel Vetter
Quoted 14 lines · David Herrmann
Quoted 4 lines · Daniel Vetter
There's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us.
Quoted 8 lines
The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else.
v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus
dev_set_drvdatafor platform drivers that somehow crept into the original version - drivers really should be in full control of that field.Quoted 5 lines
You didn't really change any
dev_set_drvdata, did you? And I guess you meanpci_set_drvdata()? I had to keep it in place indrm_pci.cas it has been there before my device-registration changes. However, with your series you added thepci_set_drvdata()everywhere yourself, so yes, please remove it.
Quoted 7 lines
That was a bogus hunk in v1 of this patch, which iirc I've never posted onto the list anywhere. I added a
platfrom_set_drvdatacall, but with the previous series to make sure that each driver has that it's a bit redundant.Long term, when we split up the drm init code I think the drvdata assignment should be the driver's job.
I remember submitting a patch for that a while ago. It was applied about a year ago, see commit a16d4f86019a ('drm: platform: Don't initialize driver-private data'). The issue at the time was that I needed the drvdata for other purposes and drm_platform_init() kept overwriting it, which had me confused for days.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/19 drm/bufs: remove handling of _DRM_GEM mappings
In reply to Daniel VetterGone with the new gem vma offset manager from David.
We can also ditch the uapi header definition from the enum since userspace never used this. It ended up in there purely for historical reasons (for reusing the old drm mmap code essentially), not because userspace ever needed it.
--- drivers/gpu/drm/drm_bufs.c | 6 ------ drivers/gpu/drm/drm_vm.c | 3 --- include/uapi/drm/drm.h | 1 - 3 files changed, 10 deletions(-)
drivers/gpu/drm/drm_bufs.c +0 -6
@@ -303,9 +303,6 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,break ; } -case _DRM_GEM: -DRM_ERROR ("tried to addmap GEM object\n" ); -break ;case _DRM_SCATTER_GATHER:if (!dev->sg) {kfree (map);
@@ -483,9 +480,6 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) dmah.size = map->size;__drm_pci_free (dev, &dmah);break ; -case _DRM_GEM: -DRM_ERROR ("tried to rmmap GEM object\n" ); -break ; }kfree (map);
drivers/gpu/drm/drm_vm.c +0 -3
@@ -266,9 +266,6 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) dmah.size = map->size;__drm_pci_free (dev, &dmah);break ; -case _DRM_GEM: -DRM_ERROR ("tried to rmmap GEM object\n" ); -break ; }kfree (map); }
include/uapi/drm/drm.h +0 -1
@@ -181,7 +181,6 @@ enum drm_map_type { _DRM_AGP =3 ,/**< AGP/GART */ _DRM_SCATTER_GATHER =4 ,/**< Scatter/gather memory for PCI DMA */ _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ - _DRM_GEM = 6, /**< GEM object (obsolete) */ };/**
Signature · 1 line
1.8.4.rc3
Re: [PATCH 12/19] drm/bufs: remove handling of _DRM_GEM mappings
Hi Daniel
Quoted 9 lines · Daniel Vetter
Gone with the new gem vma offset manager from David.
We can also ditch the uapi header definition from the enum since userspace never used this. It ended up in there purely for historical reasons (for reusing the old drm mmap code essentially), not because userspace ever needed it.
Cc David Herrmann <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Thanks for removing it. I haven't found any code using _DRM_GEM when changing the vma-manager either, so:
Thanks
David
Quoted 59 lines
--- drivers/gpu/drm/drm_bufs.c | 6 ------ drivers/gpu/drm/drm_vm.c | 3 --- include/uapi/drm/drm.h | 1 - 3 files changed, 10 deletions(-)drivers/gpu/drm/drm_bufs.c +0
-6@@ -303,9 +303,6 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,break ; } -case _DRM_GEM: -DRM_ERROR ("tried to addmap GEM object\n" ); -break ;case _DRM_SCATTER_GATHER:if (!dev->sg) {kfree (map);@@ -483,9 +480,6 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) dmah.size = map->size;__drm_pci_free (dev, &dmah);break ; -case _DRM_GEM: -DRM_ERROR ("tried to rmmap GEM object\n" ); -break ; }kfree (map);drivers/gpu/drm/drm_vm.c +0
-3@@ -266,9 +266,6 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) dmah.size = map->size;__drm_pci_free (dev, &dmah);break ; -case _DRM_GEM: -DRM_ERROR ("tried to rmmap GEM object\n" ); -break ; }kfree (map); }include/uapi/drm/drm.h +0
-2@@ -181,7 +181,6 @@ enum drm_map_type { _DRM_AGP =3 ,/**< AGP/GART */ _DRM_SCATTER_GATHER =4 ,/**< Scatter/gather memory for PCI DMA */ _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ - _DRM_GEM = 6, /**< GEM object (obsolete) */ };/** -- 1.8.4.rc3
PATCH 13/19 drm: kill DRIVER_REQUIRE_AGP
In reply to Daniel VetterOnly the two intel drivers need this and they can easily check for working agp support in their driver ->load callbacks.
This is the only reason why agp initialization could fail, so allows us to rip out a bit of error handling code in the next patch.
--- drivers/gpu/drm/drm_pci.c | 5 ----- drivers/gpu/drm/i810/i810_dma.c | 4 ++++ drivers/gpu/drm/i810/i810_drv.c | 2 +- drivers/gpu/drm/i915/i915_dma.c | 5 +++++ drivers/gpu/drm/i915/i915_drv.c | 5 ++--- include/drm/drmP.h | 1 - 6 files changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -5
@@ -267,11 +267,6 @@ static int drm_pci_agp_init(struct drm_device *dev)if (drm_core_has_AGP (dev)) {if (drm_pci_device_is_agp (dev)) dev->agp =drm_agp_init (dev); -if (drm_core_check_feature (dev,DRIVER_REQUIRE_AGP ) - && (dev->agp ==NULL )) { -DRM_ERROR ("Cannot initialize the agpgart module.\n" ); -return -EINVAL ; - }if (dev->agp) { dev->agp->agp_mtrr = arch_phys_wc_add( dev->agp->agp_info.aper_base,
drivers/gpu/drm/i810/i810_dma.c +4 -0
@@ -1193,6 +1193,10 @@ static int i810_flip_bufs(struct drm_device *dev, void *data,int i810_driver_load (struct drm_device *dev,unsigned long flags) { +/* Our userspace depends upon the agp mapping support. */ +if (!dev->agp) +return -EINVAL ; +pci_set_master (dev->pdev);return 0 ;
drivers/gpu/drm/i810/i810_drv.c +1 -1
@@ -57,7 +57,7 @@ static const struct file_operations i810_driver_fops = {static struct drm_driver driver = { .driver_features = -DRIVER_USE_AGP |DRIVER_REQUIRE_AGP | +DRIVER_USE_AGP |DRIVER_HAVE_DMA , .dev_priv_size =sizeof (drm_i810_buf_priv_t), .load = i810_driver_load,
drivers/gpu/drm/i915/i915_dma.c +5 -0
@@ -1476,7 +1476,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)return -ENODEV ; } +/* UMS needs agp support. */ +if (!drm_core_check_feature (dev,DRIVER_MODESET ) && !dev->agp) +return -EINVAL ; + dev_priv =kzalloc (sizeof (*dev_priv),GFP_KERNEL ); +if (dev_priv ==NULL )return -ENOMEM ;
drivers/gpu/drm/i915/i915_drv.c +2 -3
@@ -801,8 +801,7 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)* (gasp!) to share buffers between X and the client. Hence we need to * keep around the fake agp stuff for gen3, even when kms is enabled. */ if (intel_info->gen !=3 ) { - driver.driver_features &= - ~(DRIVER_USE_AGP |DRIVER_REQUIRE_AGP ); + driver.driver_features &= ~DRIVER_USE_AGP ; }else if (!intel_agp_enabled) {DRM_ERROR ("drm/i915 can't work without intel_agp module!\n" );return -ENODEV ;
@@ -914,7 +913,7 @@ static struct drm_driver driver = {* deal with them for Intel hardware. */ .driver_features = -DRIVER_USE_AGP |DRIVER_REQUIRE_AGP | +DRIVER_USE_AGP |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED |DRIVER_GEM |DRIVER_PRIME | DRIVER_RENDER, .load = i915_driver_load,
include/drm/drmP.h +0 -1
@@ -136,7 +136,6 @@ int drm_err(const char *func, const char *format, ...);/* driver capabilities and requirements mask */ #define DRIVER_USE_AGP 0x1 -#define DRIVER_REQUIRE_AGP 0x2#define DRIVER_PCI_DMA 0x8#define DRIVER_SG 0x10#define DRIVER_HAVE_DMA 0x20
Signature · 1 line
1.8.4.rc3
PATCH 14/19 drm: ->agp_init can't fail
In reply to Daniel VetterThanks to the removal of REQUIRE_AGP we can use a void return value and shed a bit of complexity.
--- drivers/gpu/drm/drm_pci.c | 3 +-- drivers/gpu/drm/drm_stub.c | 7 ++----- include/drm/drmP.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_pci.c +1 -2
@@ -262,7 +262,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)return 0 ; } -static int drm_pci_agp_init (struct drm_device *dev) +static void drm_pci_agp_init (struct drm_device *dev) {if (drm_core_has_AGP (dev)) {if (drm_pci_device_is_agp (dev))
@@ -274,7 +274,6 @@ static int drm_pci_agp_init(struct drm_device *dev) 1024 * 1024); } } -return 0 ; }static void drm_pci_agp_destroy (struct drm_device *dev)
drivers/gpu/drm/drm_stub.c +2 -5
@@ -502,11 +502,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)mutex_lock (&drm_global_mutex); -if (dev->driver->bus->agp_init) { - ret = dev->driver->bus->agp_init (dev); -if (ret) - goto out_unlock; - } +if (dev->driver->bus->agp_init) + dev->driver->bus->agp_init (dev);if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL );
include/drm/drmP.h +1 -1
@@ -749,7 +749,7 @@ struct drm_bus { struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p);/* hooks that are for PCI */ -int (*agp_init)(struct drm_device *dev); +void (*agp_init)(struct drm_device *dev);void (*agp_destroy)(struct drm_device *dev); };
Signature · 1 line
1.8.4.rc3
Re: [PATCH 14/19] drm: ->agp_init can't fail
Hi Daniel
Quoted 36 lines · Daniel Vetter
Thanks to the removal of
REQUIRE_AGPwe can use a void return value and shed a bit of complexity.Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 3 +-- drivers/gpu/drm/drm_stub.c | 7 ++----- include/drm/drmP.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_pci.c +1
-2@@ -262,7 +262,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)return 0 ; } -static int drm_pci_agp_init (struct drm_device *dev) +static void drm_pci_agp_init (struct drm_device *dev) {if (drm_core_has_AGP (dev)) {if (drm_pci_device_is_agp (dev))@@ -274,7 +274,6 @@ static int drm_pci_agp_init(struct drm_device *dev) 1024 * 1024); } } -return 0 ; }static void drm_pci_agp_destroy (struct drm_device *dev)drivers/gpu/drm/drm_stub.c +0
-0
drivers/gpu/drm/drm_stub.c int drm_dev_register(struct drm_device *dev, unsigned long flags) · line 506
Quoted 10 lines
drivers/gpu/drm/drm_stub.c +2
-5@@ -502,11 +502,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)mutex_lock (&drm_global_mutex); -if (dev->driver->bus->agp_init) { - ret = dev->driver->bus->agp_init (dev); -if (ret) - goto out_unlock; - } +if (dev->driver->bus->agp_init) + dev->driver->bus->agp_init (dev);
Ok, technically, you need to remove "out_unlock" here. But patch #16 removes err_agp and reused out_unlock, so I think this is fine.
Thanks
David
Quoted 23 lines
drivers/gpu/drm/drm_stub.c +0
-0if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL );include/drm/drmP.h +1
-2@@ -749,7 +749,7 @@ struct drm_bus { struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p);/* hooks that are for PCI */ -int (*agp_init)(struct drm_device *dev); +void (*agp_init)(struct drm_device *dev);void (*agp_destroy)(struct drm_device *dev); }; --1.8.4.rc3
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 15/19 drm: rip out drm_core_has_AGP
In reply to Daniel VetterMost place actually want to just check for dev->agp (most do, but a few don't so this fixes a few potential NULL derefs). The only exception is the agp init code which should check for the AGP driver feature flag.
--- drivers/gpu/drm/drm_agpsupport.c | 2 +- drivers/gpu/drm/drm_bufs.c | 4 ++-- drivers/gpu/drm/drm_memory.c | 9 +++------ drivers/gpu/drm/drm_pci.c | 4 ++-- drivers/gpu/drm/drm_vm.c | 4 ++-- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- include/drm/drm_agpsupport.h | 12 ------------ 7 files changed, 11 insertions(+), 26 deletions(-)
drivers/gpu/drm/drm_agpsupport.c +1 -1
@@ -439,7 +439,7 @@ void drm_agp_clear(struct drm_device *dev) {struct drm_agp_mem *entry, *tempe; -if (!drm_core_has_AGP (dev) || !dev->agp) +if (!dev->agp)return ;if (drm_core_check_feature (dev,DRIVER_MODESET ))return ;
drivers/gpu/drm/drm_bufs.c +2 -2
@@ -261,7 +261,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,struct drm_agp_mem *entry;int valid =0 ; -if (!drm_core_has_AGP (dev)) { +if (!dev->agp) {kfree (map);return -EINVAL ; }
@@ -1390,7 +1390,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,spin_unlock (&dev->count_lock);if (request->count >= dma->buf_count) { -if ((drm_core_has_AGP (dev) && (dma->flags & _DRM_DMA_USE_AGP)) +if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP)) || (drm_core_check_feature (dev,DRIVER_SG ) && (dma->flags & _DRM_DMA_USE_SG))) {struct drm_local_map *map = dev->agp_buffer_map;
drivers/gpu/drm/drm_memory.c +3 -6
@@ -110,8 +110,7 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,void drm_core_ioremap (struct drm_local_map *map,struct drm_device *dev) { -if (drm_core_has_AGP (dev) && - dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) +if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) map->handle =agp_remap (map->offset, map->size, dev);else map->handle =ioremap (map->offset, map->size);
@@ -120,8 +119,7 @@ EXPORT_SYMBOL(drm_core_ioremap);void drm_core_ioremap_wc (struct drm_local_map *map,struct drm_device *dev) { -if (drm_core_has_AGP (dev) && - dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) +if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) map->handle =agp_remap (map->offset, map->size, dev);else map->handle =ioremap_wc (map->offset, map->size);
@@ -133,8 +131,7 @@ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)if (!map->handle || !map->size)return ; -if (drm_core_has_AGP (dev) && - dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP) +if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)vunmap (map->handle);else iounmap (map->handle);
drivers/gpu/drm/drm_pci.c +2 -2
@@ -264,7 +264,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)static void drm_pci_agp_init (struct drm_device *dev) { -if (drm_core_has_AGP (dev)) { +if (drm_core_check_feature (dev,DRIVER_USE_AGP )) {if (drm_pci_device_is_agp (dev)) dev->agp =drm_agp_init (dev);if (dev->agp) {
@@ -278,7 +278,7 @@ static void drm_pci_agp_init(struct drm_device *dev)static void drm_pci_agp_destroy (struct drm_device *dev) { -if (drm_core_has_AGP (dev) && dev->agp) { +if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);drm_agp_clear (dev);drm_agp_destroy (dev->agp);
drivers/gpu/drm/drm_vm.c +2 -2
@@ -101,7 +101,7 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)/* * Find the right map */ -if (!drm_core_has_AGP (dev)) +if (!dev->agp) goto vm_fault_error;if (!dev->agp || !dev->agp->cant_use_aperture)
@@ -592,7 +592,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)switch (map->type) {#if !defined(__arm__)case _DRM_AGP: -if (drm_core_has_AGP (dev) && dev->agp->cant_use_aperture) { +if (dev->agp && dev->agp->cant_use_aperture) {/* * On some platforms we can't talk to bus dma address from the CPU, so for * memory of type DRM_AGP, we'll deal with sorting out the real physical
drivers/gpu/drm/radeon/radeon_ttm.c +1 -1
@@ -142,7 +142,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, man->flags =TTM_MEMTYPE_FLAG_MAPPABLE |TTM_MEMTYPE_FLAG_CMA ;#if __OS_HAS_AGPif (rdev->flags &RADEON_IS_AGP ) { -if (!(drm_core_has_AGP (rdev->ddev) && rdev->ddev->agp)) { +if (!rdev->ddev->agp) {DRM_ERROR ("AGP is not enabled for memory type %u\n" , (unsigned )type);return -EINVAL ;
include/drm/drm_agpsupport.h +0 -12
@@ -46,12 +46,6 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,int drm_agp_bind (struct drm_device *dev,struct drm_agp_binding *request);int drm_agp_bind_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); - -static inline int drm_core_has_AGP (struct drm_device *dev) -{ -return drm_core_check_feature (dev,DRIVER_USE_AGP ); -} -#else /* __OS_HAS_AGP */ static inline void drm_free_agp (DRM_AGP_MEM * handle,int pages)
@@ -183,12 +177,6 @@ static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data, {return -ENODEV ; } - -static inline int drm_core_has_AGP (struct drm_device *dev) -{ -return 0 ; -} -#endif /* __OS_HAS_AGP */ #endif /* _DRM_AGPSUPPORT_H_ */
Signature · 1 line
1.8.4.rc3
PATCH 16/19 drm: remove agp_init() bus callback
In reply to Daniel VetterFrom: David Herrmann <[email protected]>
The PCI bus helper is the only user of it. Call it directly before device-registration to get rid of the callback.
Note that all drm_agp_*() calls are locked with the drm-global-mutex so we need to explicitly lock it during initialization. It's not really clear why it's needed, but lets be safe.
v2: Rebase on top of the agp_init interface change.
--- drivers/gpu/drm/drm_pci.c | 13 +++++++++---- drivers/gpu/drm/drm_stub.c | 8 +------- include/drm/drmP.h | 1 - 3 files changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/drm_pci.c +9 -4
@@ -292,8 +292,6 @@ static struct drm_bus drm_pci_bus = { .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, - .irq_by_busid = drm_pci_irq_by_busid, - .agp_init = drm_pci_agp_init, .agp_destroy = drm_pci_agp_destroy, };
@@ -332,9 +330,13 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,if (drm_core_check_feature (dev,DRIVER_MODESET ))pci_set_drvdata (pdev, dev); +mutex_lock (&drm_global_mutex); +drm_pci_agp_init (dev); +mutex_unlock (&drm_global_mutex); + ret =drm_dev_register (dev, ent->driver_data);if (ret) - goto err_pci; + goto err_agp; DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", driver->name, driver->major, driver->minor, driver->patchlevel,
@@ -347,7 +349,10 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,return 0 ; -err_pci: +err_agp: +mutex_lock (&drm_global_mutex); +drm_pci_agp_destroy (dev); +mutex_unlock (&drm_global_mutex);pci_disable_device (pdev); err_free:drm_dev_free (dev);
drivers/gpu/drm/drm_stub.c +1 -7
@@ -502,13 +502,10 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)mutex_lock (&drm_global_mutex); -if (dev->driver->bus->agp_init) - dev->driver->bus->agp_init (dev); -if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL );if (ret) - goto err_agp; + goto out_unlock; }if (drm_core_check_feature (dev,DRIVER_RENDER ) && drm_rnodes) {
@@ -549,9 +546,6 @@ err_render_node: err_control_node:if (dev->control)drm_put_minor (&dev->control); -err_agp: -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); out_unlock:mutex_unlock (&drm_global_mutex);return ret;
include/drm/drmP.h +0 -1
@@ -749,7 +749,6 @@ struct drm_bus { struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p);/* hooks that are for PCI */ -void (*agp_init)(struct drm_device *dev);void (*agp_destroy)(struct drm_device *dev); };
Signature · 1 line
1.8.4.rc3
Re: [PATCH 16/19] drm: remove agp_init() bus callback
Hi Daniel
Quoted 24 lines · Daniel Vetter
From: David Herrmann <[email protected]>
The PCI bus helper is the only user of it. Call it directly before device-registration to get rid of the callback.
Note that all drm_agp_*() calls are locked with the drm-global-mutex so we need to explicitly lock it during initialization. It's not really clear why it's needed, but lets be safe.
v2: Rebase on top of the
agp_initinterface change.Signed-off-by David Herrmann <[email protected]> (v1)Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 13 +++++++++---- drivers/gpu/drm/drm_stub.c | 8 +------- include/drm/drmP.h | 1 - 3 files changed, 10 insertions(+), 12 deletions(-)drivers/gpu/drm/drm_pci.c +0
-0
drivers/gpu/drm/drm_pci.c static struct drm_bus drm_pci_bus = { · line 295
Quoted 4 lines
drivers/gpu/drm/drm_pci.c +0
-1@@ -292,8 +292,6 @@ static struct drm_bus drm_pci_bus = { .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, - .irq_by_busid = drm_pci_irq_by_busid,
Err, where does that come from?
Cheers
David
Quoted 75 lines
drivers/gpu/drm/drm_pci.c +9
-3- .agp_init = drm_pci_agp_init, .agp_destroy = drm_pci_agp_destroy, };@@ -332,9 +330,13 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,if (drm_core_check_feature (dev,DRIVER_MODESET ))pci_set_drvdata (pdev, dev); +mutex_lock (&drm_global_mutex); +drm_pci_agp_init (dev); +mutex_unlock (&drm_global_mutex); + ret =drm_dev_register (dev, ent->driver_data);if (ret) - goto err_pci; + goto err_agp; DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", driver->name, driver->major, driver->minor, driver->patchlevel,@@ -347,7 +349,10 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,return 0 ; -err_pci: +err_agp: +mutex_lock (&drm_global_mutex); +drm_pci_agp_destroy (dev); +mutex_unlock (&drm_global_mutex);pci_disable_device (pdev); err_free:drm_dev_free (dev);drivers/gpu/drm/drm_stub.c +1
-7@@ -502,13 +502,10 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)mutex_lock (&drm_global_mutex); -if (dev->driver->bus->agp_init) - dev->driver->bus->agp_init (dev); -if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL );if (ret) - goto err_agp; + goto out_unlock; }if (drm_core_check_feature (dev,DRIVER_RENDER ) && drm_rnodes) {@@ -549,9 +546,6 @@ err_render_node: err_control_node:if (dev->control)drm_put_minor (&dev->control); -err_agp: -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); out_unlock:mutex_unlock (&drm_global_mutex);return ret;include/drm/drmP.h +0
-2@@ -749,7 +749,6 @@ struct drm_bus { struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p);/* hooks that are for PCI */ -void (*agp_init)(struct drm_device *dev);void (*agp_destroy)(struct drm_device *dev); }; --1.8.4.rc3
Re: [PATCH 16/19] drm: remove agp_init() bus callback
Quoted 11 lines · David Herrmann
drivers/gpu/drm/drm_pci.c static struct drm_bus drm_pci_bus = { · line 295
Quoted 9 lines
drivers/gpu/drm/drm_pci.c +0
-1@@ -292,8 +292,6 @@ static struct drm_bus drm_pci_bus = { .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, - .irq_by_busid = drm_pci_irq_by_busid,Err, where does that come from?
Pretty bad case of rebase fail - it's all ripped out in the in-flux irq rework I have here on top of these patches. Thanks for spotting this.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 drm: remove agp_init() bus callback
The PCI bus helper is the only user of it. Call it directly before device-registration to get rid of the callback.
Note that all drm_agp_*() calls are locked with the drm-global-mutex so we need to explicitly lock it during initialization. It's not really clear why it's needed, but lets be safe.
v2: Rebase on top of the agp_init interface change.
v3: Remove the rebase-fail where I've accidentally killed the ->irq_by_busid callback a bit too early.
--- drivers/gpu/drm/drm_pci.c | 12 +++++++++--- drivers/gpu/drm/drm_stub.c | 8 +------- include/drm/drmP.h | 1 - 3 files changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_pci.c +9 -3
@@ -293,7 +293,6 @@ static struct drm_bus drm_pci_bus = { .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, .irq_by_busid = drm_pci_irq_by_busid, - .agp_init = drm_pci_agp_init, .agp_destroy = drm_pci_agp_destroy, };
@@ -332,9 +331,13 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,if (drm_core_check_feature (dev,DRIVER_MODESET ))pci_set_drvdata (pdev, dev); +mutex_lock (&drm_global_mutex); +drm_pci_agp_init (dev); +mutex_unlock (&drm_global_mutex); + ret =drm_dev_register (dev, ent->driver_data);if (ret) - goto err_pci; + goto err_agp; DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", driver->name, driver->major, driver->minor, driver->patchlevel,
@@ -347,7 +350,10 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,return 0 ; -err_pci: +err_agp: +mutex_lock (&drm_global_mutex); +drm_pci_agp_destroy (dev); +mutex_unlock (&drm_global_mutex);pci_disable_device (pdev); err_free:drm_dev_free (dev);
drivers/gpu/drm/drm_stub.c +1 -7
@@ -502,13 +502,10 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)mutex_lock (&drm_global_mutex); -if (dev->driver->bus->agp_init) - dev->driver->bus->agp_init (dev); -if (drm_core_check_feature (dev,DRIVER_MODESET )) { ret =drm_get_minor (dev, &dev->control,DRM_MINOR_CONTROL );if (ret) - goto err_agp; + goto out_unlock; }if (drm_core_check_feature (dev,DRIVER_RENDER ) && drm_rnodes) {
@@ -549,9 +546,6 @@ err_render_node: err_control_node:if (dev->control)drm_put_minor (&dev->control); -err_agp: -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); out_unlock:mutex_unlock (&drm_global_mutex);return ret;
include/drm/drmP.h +0 -1
@@ -749,7 +749,6 @@ struct drm_bus { struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p);/* hooks that are for PCI */ -void (*agp_init)(struct drm_device *dev);void (*agp_destroy)(struct drm_device *dev); };
Signature · 1 line
1.8.4.rc3
PATCH 17/19 drm: inline drm_agp_destroy
In reply to Daniel VetterWrapping a kfree is pointless.
--- drivers/gpu/drm/drm_agpsupport.c | 15 --------------- drivers/gpu/drm/drm_pci.c | 2 +- include/drm/drm_agpsupport.h | 5 ----- 3 files changed, 1 insertion(+), 21 deletions(-)
drivers/gpu/drm/drm_agpsupport.c +0 -15
@@ -460,21 +460,6 @@ void drm_agp_clear(struct drm_device *dev) }/** -* drm_agp_destroy - Destroy AGP head -* @dev: DRM device -* -* Destroy resources that were previously allocated via drm_agp_initp. Caller -* must ensure to clean up all AGP resources before calling this. See -* drm_agp_clear(). -* -* Call this to destroy AGP heads allocated via drm_agp_init(). -*/ -void drm_agp_destroy (struct drm_agp_head *agp) -{ -kfree (agp); -} - -/** * Binds a collection of pages into AGP memory at the given offset, returning * the AGP memory structure containing them. *
drivers/gpu/drm/drm_pci.c +1 -1
@@ -281,7 +281,7 @@ static void drm_pci_agp_destroy(struct drm_device *dev)if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);drm_agp_clear (dev); -drm_agp_destroy (dev->agp); +kfree (dev->agp); dev->agp =NULL ; } }
include/drm/drm_agpsupport.h +0 -5
@@ -20,7 +20,6 @@ DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, uint32_t type);struct drm_agp_head *drm_agp_init (struct drm_device *dev); -void drm_agp_destroy (struct drm_agp_head *agp);void drm_agp_clear (struct drm_device *dev);int drm_agp_acquire (struct drm_device *dev); int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
@@ -76,10 +75,6 @@ static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)return NULL ; } -static inline void drm_agp_destroy (struct drm_agp_head *agp) -{ -} -static inline void drm_agp_clear (struct drm_device *dev) { }
Signature · 1 line
1.8.4.rc3
Re: [PATCH 17/19] drm: inline drm_agp_destroy
Hi
Quoted 4 lines · Daniel Vetter
Wrapping a kfree is pointless.
Signed-off-by Daniel Vetter <[email protected]>---
I added that one dutifully to document the API in:
commit 28ec711cd427f8b61f73712a43b8100ba8ca933b
Author: David Herrmann <[email protected]> Date: Sat Jul 27 16:37:00 2013 +0200
drm/agp: move AGP cleanup paths to drm_agpsupport.c
By removing it, we loose the comment on how to clean it up. Maybe we can copy the comment to drm_agp_init()? Other than that, I'm fine with it:
Thanks
David
Quoted 74 lines
drivers/gpu/drm/drm_agpsupport.c | 15 --------------- drivers/gpu/drm/drm_pci.c | 2 +- include/drm/drm_agpsupport.h | 5 ----- 3 files changed, 1 insertion(+), 21 deletions(-)drivers/gpu/drm/drm_agpsupport.c +0
-15@@ -460,21 +460,6 @@ void drm_agp_clear(struct drm_device *dev) }/** -* drm_agp_destroy - Destroy AGP head -* @dev: DRM device -* -* Destroy resources that were previously allocated via drm_agp_initp. Caller -* must ensure to clean up all AGP resources before calling this. See -* drm_agp_clear(). -* -* Call this to destroy AGP heads allocated via drm_agp_init(). -*/ -void drm_agp_destroy (struct drm_agp_head *agp) -{ -kfree (agp); -} - -/** * Binds a collection of pages into AGP memory at the given offset, returning * the AGP memory structure containing them. * drivers/gpu/drm/drm_pci.c +1
-1@@ -281,7 +281,7 @@ static void drm_pci_agp_destroy(struct drm_device *dev)if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);drm_agp_clear (dev); -drm_agp_destroy (dev->agp); +kfree (dev->agp); dev->agp =NULL ; } }include/drm/drm_agpsupport.h +0
-6@@ -20,7 +20,6 @@ DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, uint32_t type);struct drm_agp_head *drm_agp_init (struct drm_device *dev); -void drm_agp_destroy (struct drm_agp_head *agp);void drm_agp_clear (struct drm_device *dev);int drm_agp_acquire (struct drm_device *dev); int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,@@ -76,10 +75,6 @@ static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)return NULL ; } -static inline void drm_agp_destroy (struct drm_agp_head *agp) -{ -} -static inline void drm_agp_clear (struct drm_device *dev) { } --1.8.4.rc3
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 17/19] drm: inline drm_agp_destroy
Quoted 11 lines · David Herrmann
Hi
Quoted 4 lines · Daniel Vetter
Wrapping a kfree is pointless.
Signed-off-by Daniel Vetter <[email protected]>---
I added that one dutifully to document the API in:
commit
28ec711cd427f8b61f73712a43b8100ba8ca933b
Quoted 8 lines
Author: David Herrmann <[email protected]> Date: Sat Jul 27 16:37:00 2013 +0200drm/agp: move AGP cleanup paths to
drm_agpsupport.cBy removing it, we loose the comment on how to clean it up. Maybe we can copy the comment to
drm_agp_init()? Other than that, I'm fine with it:
Hm, I haven't really noticed your original patch fly by. But I think agp setup/teardown is neatly fubar anyway, e.g. for modesetting drivers we seem to leak refcount on the agp backend driver.
Long term (if anyone actually cares) I think we should shovel all the legacy agp stuff somewhere far away and switch the modesetting drivers to using the agp system directly and making sure that stuff gets cleaned up with devres.c.
-Daniel
Quoted 80 lines
Reviewed-by David Herrmann <[email protected]>Thanks
DavidQuoted 74 lines
drivers/gpu/drm/drm_agpsupport.c | 15 --------------- drivers/gpu/drm/drm_pci.c | 2 +- include/drm/drm_agpsupport.h | 5 ----- 3 files changed, 1 insertion(+), 21 deletions(-)drivers/gpu/drm/drm_agpsupport.c +0
-15@@ -460,21 +460,6 @@ void drm_agp_clear(struct drm_device *dev) }/** -* drm_agp_destroy - Destroy AGP head -* @dev: DRM device -* -* Destroy resources that were previously allocated via drm_agp_initp. Caller -* must ensure to clean up all AGP resources before calling this. See -* drm_agp_clear(). -* -* Call this to destroy AGP heads allocated via drm_agp_init(). -*/ -void drm_agp_destroy (struct drm_agp_head *agp) -{ -kfree (agp); -} - -/** * Binds a collection of pages into AGP memory at the given offset, returning * the AGP memory structure containing them. * drivers/gpu/drm/drm_pci.c +1
-1@@ -281,7 +281,7 @@ static void drm_pci_agp_destroy(struct drm_device *dev)if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);drm_agp_clear (dev); -drm_agp_destroy (dev->agp); +kfree (dev->agp); dev->agp =NULL ; } }include/drm/drm_agpsupport.h +0
-6@@ -20,7 +20,6 @@ DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev, uint32_t type);struct drm_agp_head *drm_agp_init (struct drm_device *dev); -void drm_agp_destroy (struct drm_agp_head *agp);void drm_agp_clear (struct drm_device *dev);int drm_agp_acquire (struct drm_device *dev); int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,@@ -76,10 +75,6 @@ static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)return NULL ; } -static inline void drm_agp_destroy (struct drm_agp_head *agp) -{ -} -static inline void drm_agp_clear (struct drm_device *dev) { } --1.8.4.rc3
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 18/19 drm: kill the ->agp_destroy callback
In reply to Daniel VetterCall drm_pci_agp_destroy directly, there's no point in the indirection. Long term we want to shuffle this into each driver's unload logic, but that needs cleared-up drm lifetime rules first.
--- drivers/gpu/drm/drm_pci.c | 3 +-- drivers/gpu/drm/drm_stub.c | 4 ++-- include/drm/drmP.h | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_pci.c +1 -2
@@ -276,7 +276,7 @@ static void drm_pci_agp_init(struct drm_device *dev) } } -static void drm_pci_agp_destroy (struct drm_device *dev) +void drm_pci_agp_destroy (struct drm_device *dev) {if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);
@@ -292,7 +292,6 @@ static struct drm_bus drm_pci_bus = { .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, - .agp_destroy = drm_pci_agp_destroy, };/**
drivers/gpu/drm/drm_stub.c +2 -2
@@ -569,8 +569,8 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->driver->unload) dev->driver->unload (dev); -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); +if (dev->agp) +drm_pci_agp_destroy (dev);drm_vblank_cleanup (dev);
include/drm/drmP.h +1 -3
@@ -748,9 +748,6 @@ struct drm_bus {int (*set_unique)(struct drm_device *dev,struct drm_master *master,struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p); -/* hooks that are for PCI */ -void (*agp_destroy)(struct drm_device *dev); - };/**
@@ -1658,6 +1655,7 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)return pci_find_capability (dev->pdev,PCI_CAP_ID_AGP ); } +void drm_pci_agp_destroy (struct drm_device *dev);extern int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver);extern void drm_pci_exit (struct drm_driver *driver,struct pci_driver *pdriver);
Signature · 1 line
1.8.4.rc3
Re: [PATCH 18/19] drm: kill the ->agp_destroy callback
Hi Daniel
Quoted 16 lines · Daniel Vetter
Call
drm_pci_agp_destroydirectly, there's no point in the indirection. Long term we want to shuffle this into each driver's unload logic, but that needs cleared-up drm lifetime rules first.Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 3 +-- drivers/gpu/drm/drm_stub.c | 4 ++-- include/drm/drmP.h | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_pci.c +0
-0
drivers/gpu/drm/drm_pci.c static void drm_pci_agp_init(struct drm_device *dev) · line 279
Quoted 5 lines
drivers/gpu/drm/drm_pci.c +1
-1@@ -276,7 +276,7 @@ static void drm_pci_agp_init(struct drm_device *dev) } } -static void drm_pci_agp_destroy (struct drm_device *dev) +void drm_pci_agp_destroy (struct drm_device *dev)
That one is #ifdef CONFIG_PCI
So please provide a dummy below, same as for drm_pci_init().
If that's fixed:
Thanks
David
Quoted 55 lines
drivers/gpu/drm/drm_pci.c +0
-1{if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);@@ -292,7 +292,6 @@ static struct drm_bus drm_pci_bus = { .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, - .agp_destroy = drm_pci_agp_destroy, };/** drivers/gpu/drm/drm_stub.c +2
-2@@ -569,8 +569,8 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->driver->unload) dev->driver->unload (dev); -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); +if (dev->agp) +drm_pci_agp_destroy (dev);drm_vblank_cleanup (dev);include/drm/drmP.h +1
-4@@ -748,9 +748,6 @@ struct drm_bus {int (*set_unique)(struct drm_device *dev,struct drm_master *master,struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p); -/* hooks that are for PCI */ -void (*agp_destroy)(struct drm_device *dev); - };/** @@ -1658,6 +1655,7 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)return pci_find_capability (dev->pdev,PCI_CAP_ID_AGP ); } +void drm_pci_agp_destroy (struct drm_device *dev);extern int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver);extern void drm_pci_exit (struct drm_driver *driver,struct pci_driver *pdriver); --1.8.4.rc3
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm: kill the ->agp_destroy callback
Call drm_pci_agp_destroy directly, there's no point in the indirection. Long term we want to shuffle this into each driver's unload logic, but that needs cleared-up drm lifetime rules first.
v2: Add a dummy function for !CONFIG_PCI, spotted my David Herrmann.
--- drivers/gpu/drm/drm_pci.c | 4 ++-- drivers/gpu/drm/drm_stub.c | 4 ++-- include/drm/drmP.h | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_pci.c +2 -2
@@ -276,7 +276,7 @@ static void drm_pci_agp_init(struct drm_device *dev) } } -static void drm_pci_agp_destroy (struct drm_device *dev) +void drm_pci_agp_destroy (struct drm_device *dev) {if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);
@@ -293,7 +293,6 @@ static struct drm_bus drm_pci_bus = { .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, .irq_by_busid = drm_pci_irq_by_busid, - .agp_destroy = drm_pci_agp_destroy, };/**
@@ -457,6 +456,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) return -1; } +void drm_pci_agp_destroy (struct drm_device *dev) { };#endif EXPORT_SYMBOL (drm_pci_init);
drivers/gpu/drm/drm_stub.c +2 -2
@@ -569,8 +569,8 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->driver->unload) dev->driver->unload (dev); -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); +if (dev->agp) +drm_pci_agp_destroy (dev);drm_vblank_cleanup (dev);
include/drm/drmP.h +1 -3
@@ -748,9 +748,6 @@ struct drm_bus {int (*set_unique)(struct drm_device *dev,struct drm_master *master,struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p); -/* hooks that are for PCI */ -void (*agp_destroy)(struct drm_device *dev); - };/**
@@ -1658,6 +1655,7 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)return pci_find_capability (dev->pdev,PCI_CAP_ID_AGP ); } +void drm_pci_agp_destroy (struct drm_device *dev);extern int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver);extern void drm_pci_exit (struct drm_driver *driver,struct pci_driver *pdriver);
Signature · 1 line
1.8.4.rc3
Re: [PATCH] drm: kill the ->agp_destroy callback
Hey Daniel
Quoted 37 lines · Daniel Vetter
Call
drm_pci_agp_destroydirectly, there's no point in the indirection. Long term we want to shuffle this into each driver's unload logic, but that needs cleared-up drm lifetime rules first.v2: Add a dummy function for !CONFIG_PCI, spotted my David Herrmann.
Reviewed-by David Herrmann <[email protected]>Cc David Herrmann <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 4 ++-- drivers/gpu/drm/drm_stub.c | 4 ++-- include/drm/drmP.h | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_pci.c +1
-2@@ -276,7 +276,7 @@ static void drm_pci_agp_init(struct drm_device *dev) } } -static void drm_pci_agp_destroy (struct drm_device *dev) +void drm_pci_agp_destroy (struct drm_device *dev) {if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);@@ -293,7 +293,6 @@ static struct drm_bus drm_pci_bus = { .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, .irq_by_busid = drm_pci_irq_by_busid, - .agp_destroy = drm_pci_agp_destroy, };/**
drivers/gpu/drm/drm_pci.c int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) · line 459
Quoted 4 lines
drivers/gpu/drm/drm_pci.c +1
-0@@ -457,6 +456,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)return -1 ; } +void drm_pci_agp_destroy (struct drm_device *dev) { };
Looks good, but if you want to avoid getting a coding-style fixup patch in the next week from an eager linux-next tester, I'd recommend removing that unnecessary semicolon.
Thanks
David
Quoted 43 lines
drivers/gpu/drm/drm_pci.c +0
-0#endif EXPORT_SYMBOL (drm_pci_init);drivers/gpu/drm/drm_stub.c +2
-2@@ -569,8 +569,8 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->driver->unload) dev->driver->unload (dev); -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); +if (dev->agp) +drm_pci_agp_destroy (dev);drm_vblank_cleanup (dev);include/drm/drmP.h +1
-4@@ -748,9 +748,6 @@ struct drm_bus {int (*set_unique)(struct drm_device *dev,struct drm_master *master,struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p); -/* hooks that are for PCI */ -void (*agp_destroy)(struct drm_device *dev); - };/** @@ -1658,6 +1655,7 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)return pci_find_capability (dev->pdev,PCI_CAP_ID_AGP ); } +void drm_pci_agp_destroy (struct drm_device *dev);extern int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver);extern void drm_pci_exit (struct drm_driver *driver,struct pci_driver *pdriver); --1.8.4.rc3
PATCH 1/1 drm: kill the ->agp_destroy callback
Call drm_pci_agp_destroy directly, there's no point in the indirection. Long term we want to shuffle this into each driver's unload logic, but that needs cleared-up drm lifetime rules first.
v2: Add a dummy function for !CONFIG_PCI, spotted my David Herrmann.
v3: Fixup for the coding style police.
--- drivers/gpu/drm/drm_pci.c | 4 ++-- drivers/gpu/drm/drm_stub.c | 4 ++-- include/drm/drmP.h | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_pci.c +2 -2
@@ -276,7 +276,7 @@ static void drm_pci_agp_init(struct drm_device *dev) } } -static void drm_pci_agp_destroy (struct drm_device *dev) +void drm_pci_agp_destroy (struct drm_device *dev) {if (dev->agp) {arch_phys_wc_del (dev->agp->agp_mtrr);
@@ -293,7 +293,6 @@ static struct drm_bus drm_pci_bus = { .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique, .irq_by_busid = drm_pci_irq_by_busid, - .agp_destroy = drm_pci_agp_destroy, };/**
@@ -457,6 +456,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) return -1; } +void drm_pci_agp_destroy (struct drm_device *dev) {}#endif EXPORT_SYMBOL (drm_pci_init);
drivers/gpu/drm/drm_stub.c +2 -2
@@ -569,8 +569,8 @@ void drm_dev_unregister(struct drm_device *dev)if (dev->driver->unload) dev->driver->unload (dev); -if (dev->driver->bus->agp_destroy) - dev->driver->bus->agp_destroy (dev); +if (dev->agp) +drm_pci_agp_destroy (dev);drm_vblank_cleanup (dev);
include/drm/drmP.h +1 -3
@@ -748,9 +748,6 @@ struct drm_bus {int (*set_unique)(struct drm_device *dev,struct drm_master *master,struct drm_unique *unique);int (*irq_by_busid)(struct drm_device *dev,struct drm_irq_busid *p); -/* hooks that are for PCI */ -void (*agp_destroy)(struct drm_device *dev); - };/**
@@ -1658,6 +1655,7 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)return pci_find_capability (dev->pdev,PCI_CAP_ID_AGP ); } +void drm_pci_agp_destroy (struct drm_device *dev);extern int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver);extern void drm_pci_exit (struct drm_driver *driver,struct pci_driver *pdriver);
Signature · 1 line
1.8.4.rc3
PATCH 19/19 drm: remove global_mutex locking around agp_init
In reply to Daniel VetterDavid Herrmann dutifully moved this locking along when moving the agp_init call out of the generic drm_dev_register into the pci specific load helpers.
But afaict there's no need and the reason for that locking has been purely a historical accident - we need the lock around the driver dev node registration to paper over the midlayer init races, and the agp init simply ended up in there. The real fix for all this is of course to delay the dev (and sysfs/debugfs) interface registration until everything is fully set up.
Until then stop the cargo-cult locking from spreading and remove the locking.
--- drivers/gpu/drm/drm_pci.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -4
@@ -329,9 +329,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,if (drm_core_check_feature (dev,DRIVER_MODESET ))pci_set_drvdata (pdev, dev); -mutex_lock (&drm_global_mutex);drm_pci_agp_init (dev); -mutex_unlock (&drm_global_mutex); ret =drm_dev_register (dev, ent->driver_data);if (ret)
@@ -349,9 +347,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,return 0 ; err_agp: -mutex_lock (&drm_global_mutex);drm_pci_agp_destroy (dev); -mutex_unlock (&drm_global_mutex);pci_disable_device (pdev); err_free:drm_dev_free (dev);
Signature · 1 line
1.8.4.rc3