drm_bus cleanups and other cruft removal
Subsystems (16)
cover drm_bus cleanups and other cruft removal
Hi all,
I've chatted a bit with Thierry about how we could allow drivers to not even required a drm_bus any more. Which is relevant when e.g. due to the new master/component no platform device is conveniently around.
So I've brushed off my old series to remove some drm_bus functions and other cruft and rebased it onto latest drm-next.
It gets rid of everything but drm_bus->set_busid, but Thierry has a good plan to make that one optional too - it's only really needed for backwards compat with some old libdrm versions on pci drm drivers.
Comments and review highly welcome.
Presuming no one screams I plan to send a pull request with these patches to Dave fairly early for 3.16 so that Thierry can base his tegra rework on top of it.
Cheers, Daniel
Daniel Vetter (18):
drm/omap: fix up pdev_remove
drm/irq: simplify irq checks in drm_wait_vblank drm/pci: fold in irq_by_busid support
drm/irq: drm_control is a legacy ioctl, so pci devices only drm/irq: remove cargo-culted locking from irq_install/unistall
drm: remove drm_dev_to_irq from drivers
drm: kill drm_bus->bus_type
drm: Rip out totally bogus vga_switcheroo->can_switch locking
drm: rename dev->count_lock to dev->buf_lock
drm/irq: track the irq installed in drm_irq_install in dev->irq drm/irq: Look up the pci irq directly in the drm_control ioctl
drm: pass the irq explicitly to drm_irq_install
drm: remove bus->get_irq implementations
drm: inline drm_pci_set_unique
drm: rip out dev->devname
drm: remove drm_bus->get_name
drm: Remove dev->kdriver
drm/<drivers>: don't set driver->dev_priv_size to 0
Documentation/DocBook/drm.tmpl | 10 +-- drivers/gpu/drm/armada/armada_drv.c | 2 +- drivers/gpu/drm/ast/ast_drv.c | 1 - drivers/gpu/drm/drm_bufs.c | 32 +++++----- drivers/gpu/drm/drm_info.c | 6 +- drivers/gpu/drm/drm_ioctl.c | 13 ++-- drivers/gpu/drm/drm_irq.c | 106 +++++++++++-------------------- drivers/gpu/drm/drm_pci.c | 94 +++++++++++++-------------- drivers/gpu/drm/drm_platform.c | 25 -------- drivers/gpu/drm/drm_stub.c | 7 +- drivers/gpu/drm/drm_usb.c | 14 ---- drivers/gpu/drm/gma500/psb_drv.c | 2 +- drivers/gpu/drm/i915/i915_dma.c | 9 ++- drivers/gpu/drm/i915/i915_drv.c | 9 ++- drivers/gpu/drm/i915/i915_gem.c | 7 +- drivers/gpu/drm/mga/mga_state.c | 2 +- drivers/gpu/drm/msm/msm_drv.c | 2 +- drivers/gpu/drm/nouveau/nouveau_vga.c | 7 +- drivers/gpu/drm/omapdrm/omap_drv.c | 2 + drivers/gpu/drm/qxl/qxl_drv.c | 1 - drivers/gpu/drm/qxl/qxl_irq.c | 2 +- drivers/gpu/drm/r128/r128_state.c | 2 +- drivers/gpu/drm/radeon/radeon_device.c | 7 +- drivers/gpu/drm/radeon/radeon_drv.c | 1 - drivers/gpu/drm/radeon/radeon_irq_kms.c | 2 +- drivers/gpu/drm/radeon/radeon_state.c | 2 +- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +- drivers/gpu/drm/tegra/bus.c | 11 ---- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- include/drm/drmP.h | 33 +++------- 31 files changed, 159 insertions(+), 258 deletions(-)
Signature · 1 line
1.8.5.2
PATCH 1/18 drm/omap: fix up pdev_remove
Dave accidentally merged the wrong version of the patch in
commit fd3c02531461924853db65f2664db361b53a70d3
Author: Daniel Vetter <[email protected]> Date: Wed Dec 11 11:34:26 2013 +0100
drm/omap: call drm_put_dev directly in ->remove
which did not include the fix from Rob's review: omapdrm is split into the drm driver and the dmm driver (yeah, I've complained about that almost-impossible-to-spot difference, too). We need to unregister the dmm driver in the pdev_remove hook.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/omapdrm/omap_drv.c +2 -0
@@ -699,6 +699,8 @@ static int pdev_remove(struct platform_device *device)omap_disconnect_dssdevs ();omap_crtc_pre_uninit (); +platform_driver_unregister (&omap_dmm_driver); +drm_put_dev (platform_get_drvdata (device));return 0 ; }
Signature · 1 line
1.8.5.2
Re: [PATCH 01/18] drm/omap: fix up pdev_remove
Quoted 8 lines · Daniel Vetter
Dave accidentally merged the wrong version of the patch in
commit
fd3c02531461924853db65f2664db361b53a70d3Author: Daniel Vetter <[email protected]> Date: Wed Dec 11 11:34:26 2013 +0100drm/omap: call drm_put_dev directly in ->remove
Quoted 8 lines
which did not include the fix from Rob's review: omapdrm is split into the drm driver and the dmm driver (yeah, I've complained about that almost-impossible-to-spot difference, too). We need to unregister the dmm driver in the
pdev_removehook.Cc Dave Airlie <[email protected]>Cc Rob Clark <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Thanks
Quoted 20 lines
--- drivers/gpu/drm/omapdrm/omap_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/omapdrm/omap_drv.c +2
-1@@ -699,6 +699,8 @@ static int pdev_remove(struct platform_device *device)omap_disconnect_dssdevs ();omap_crtc_pre_uninit (); +platform_driver_unregister (&omap_dmm_driver); +drm_put_dev (platform_get_drvdata (device));return 0 ; } --1.8.5.2
Re: [PATCH 01/18] drm/omap: fix up pdev_remove
In reply to Daniel VetterHi,
Quoted 25 lines · Daniel Vetter
Dave accidentally merged the wrong version of the patch in
commit
fd3c02531461924853db65f2664db361b53a70d3Author: Daniel Vetter <[email protected]> Date: Wed Dec 11 11:34:26 2013 +0100drm/omap: call drm_put_dev directly in ->removewhich did not include the fix from Rob's review: omapdrm is split into the drm driver and the dmm driver (yeah, I've complained about that almost-impossible-to-spot difference, too). We need to unregister the dmm driver in the
pdev_removehook.Cc Dave Airlie <[email protected]>Cc Rob Clark <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/omapdrm/omap_drv.c +0
-0
drivers/gpu/drm/omapdrm/omap_drv.c static int pdev_remove(struct platform_device *device) · line 706
Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_drv.c +2
-0@@ -699,6 +699,8 @@ static int pdev_remove(struct platform_device *device)omap_disconnect_dssdevs ();omap_crtc_pre_uninit (); +platform_driver_unregister (&omap_dmm_driver); +drm_put_dev (platform_get_drvdata (device));return 0 ; }
Your patch does fix the "drm/omap: call drm_put_dev directly in ->remove" patch, but I think the unregistering is not right if done in pdev_remove.
I sent this patch a few weeks ago:
http://www.spinics.net/lists/dri-devel/msg56464.html
It unregisters the dmm driver at the module exit function, which is the proper place for it as the dmm driver is registered in the module init function.
Tomi
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/18] drm/omap: fix up pdev_remove
Quoted 41 lines · Tomi Valkeinen
Hi,
Quoted 25 lines · Daniel Vetter
Dave accidentally merged the wrong version of the patch in
commit
fd3c02531461924853db65f2664db361b53a70d3Author: Daniel Vetter <[email protected]> Date: Wed Dec 11 11:34:26 2013 +0100drm/omap: call drm_put_dev directly in ->removewhich did not include the fix from Rob's review: omapdrm is split into the drm driver and the dmm driver (yeah, I've complained about that almost-impossible-to-spot difference, too). We need to unregister the dmm driver in the
pdev_removehook.Cc Dave Airlie <[email protected]>Cc Rob Clark <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/omapdrm/omap_drv.c +0
-0drivers/gpu/drm/omapdrm/omap_drv.c static int pdev_remove(struct platform_device *device) · line 706
Quoted 8 lines
drivers/gpu/drm/omapdrm/omap_drv.c +2
-0@@ -699,6 +699,8 @@ static int pdev_remove(struct platform_device *device)omap_disconnect_dssdevs ();omap_crtc_pre_uninit (); +platform_driver_unregister (&omap_dmm_driver); +drm_put_dev (platform_get_drvdata (device));return 0 ; }Your patch does fix the "drm/omap: call
drm_put_devdirectly in ->remove" patch, but I think the unregistering is not right if done inpdev_remove.
Quoted 7 lines
I sent this patch a few weeks ago:
http://www.spinics.net/lists/dri-devel/msg56464.html
It unregisters the dmm driver at the module exit function, which is the proper place for it as the dmm driver is registered in the module init function.
I don't mind how this is getting fixed, I just don't like when regression caused by my patches are left lingering too long ;-)
Have you merged your patch for 3.14-rc already so that I can drop this one here?
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 01/18] drm/omap: fix up pdev_remove
Quoted 5 lines · Daniel Vetter
I don't mind how this is getting fixed, I just don't like when regression caused by my patches are left lingering too long ;-)
Have you merged your patch for 3.14-rc already so that I can drop this one here?
Did you mean 3.15-rc? It's on my branch for 3.15 omapdrm fixes, which I'm about to send today.
Tomi
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/18] drm/omap: fix up pdev_remove
Quoted 10 lines · Tomi Valkeinen
Quoted 5 lines · Daniel Vetter
I don't mind how this is getting fixed, I just don't like when regression caused by my patches are left lingering too long ;-)
Have you merged your patch for 3.14-rc already so that I can drop this one here?
Did you mean 3.15-rc? It's on my branch for 3.15 omapdrm fixes, which I'm about to send today.
Yeah, 3.15-fixes, typoe'ed that ;-)
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 2/18 drm/irq: simplify irq checks in drm_wait_vblank
In reply to Daniel VetterChecking for both an irq number _and_ whether it's enabled is redundant. Originally I've thought the drm_dev_to_irq call would break drivers which do their own irq checking, but those shouldn't have DRIVER_HAVE_IRQ set as Thierry Reding pointed out. But such drivers already need to set dev->irq_enabled for other reasons, so we might as well ditch that check, too.
v2: Also drop the HAVE_IRQ check.
--- drivers/gpu/drm/drm_irq.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_irq.c +2 -3
@@ -1160,9 +1160,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data,int ret;unsigned int flags, seq, crtc, high_crtc; -if (drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) -if ((!drm_dev_to_irq (dev)) || (!dev->irq_enabled)) -return -EINVAL ; +if (!dev->irq_enabled) +return -EINVAL ;if (vblwait->request.type & _DRM_VBLANK_SIGNAL)return -EINVAL ;
Signature · 1 line
1.8.5.2
Re: [PATCH 02/18] drm/irq: simplify irq checks in drm_wait_vblank
Quoted 7 lines · Daniel Vetter
Checking for both an irq number _and_ whether it's enabled is redundant. Originally I've thought the
drm_dev_to_irqcall would break drivers which do their own irq checking, but those shouldn't haveDRIVER_HAVE_IRQset as Thierry Reding pointed out. But such drivers already need to setdev->irq_enabledfor other reasons, so we might as well ditch that check, too.
Quoted 7 lines
v2: Also drop the
HAVE_IRQcheck.Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/18 drm/pci: fold in irq_by_busid support
In reply to Daniel VetterThis is a ums-only ioctl, and we've only ever supported ums (at least in upstream) on pci devices. So no point in keeping that piece of legacy logic abstracted within the drm bus driver.
To keep things work without CONFIG_PCI also add a dummy ioctl.
v2: Block the irq_by_busid ioctl for modeset drivers.
--- drivers/gpu/drm/drm_irq.c | 27 --------------------------- drivers/gpu/drm/drm_pci.c | 40 ++++++++++++++++++++++++++++++++++++++-- include/drm/drmP.h | 1 - 3 files changed, 38 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_irq.c +0 -27
@@ -56,33 +56,6 @@*/ #define DRM_REDUNDANT_VBLIRQ_THRESH_NS 1000000 -/** -* Get interrupt from bus id. -* -* \param inode device inode. -* \param file_priv DRM file private. -* \param cmd command. -* \param arg user argument, pointing to a drm_irq_busid structure. -* \return zero on success or a negative number on failure. -* -* Finds the PCI device with the specified bus id and gets its IRQ number. -* This IOCTL is deprecated, and will now return EINVAL for any busid not equal -* to that of the device that this DRM instance attached to. -*/ -int drm_irq_by_busid (struct drm_device *dev,void *data, -struct drm_file *file_priv) -{ -struct drm_irq_busid *p = data; - -if (!dev->driver->bus->irq_by_busid) -return -EINVAL ; - -if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) -return -EINVAL ; - -return dev->driver->bus->irq_by_busid (dev, p); -} -/* * Clear vblank timestamp buffer for a crtc. */
drivers/gpu/drm/drm_pci.c +38 -2
@@ -247,7 +247,6 @@ err:return ret; } -static int drm_pci_irq_by_busid (struct drm_device *dev,struct drm_irq_busid *p) { if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
@@ -262,6 +261,38 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)return 0 ; } +/** +* Get interrupt from bus id. +* +* \param inode device inode. +* \param file_priv DRM file private. +* \param cmd command. +* \param arg user argument, pointing to a drm_irq_busid structure. +* \return zero on success or a negative number on failure. +* +* Finds the PCI device with the specified bus id and gets its IRQ number. +* This IOCTL is deprecated, and will now return EINVAL for any busid not equal +* to that of the device that this DRM instance attached to. +*/ +int drm_irq_by_busid (struct drm_device *dev,void *data, +struct drm_file *file_priv) +{ +struct drm_irq_busid *p = data; + +if (drm_core_check_feature (dev,DRIVER_MODESET )) +return -EINVAL ; + +/* UMS was only ever support on pci devices. */ +if (WARN_ON (!dev->pdev)) +return -EINVAL ; + +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) +return -EINVAL ; + +return drm_pci_irq_by_busid (dev, p); +} + +static void drm_pci_agp_init (struct drm_device *dev) {if (drm_core_check_feature (dev,DRIVER_USE_AGP )) {
@@ -292,7 +323,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, };/**
@@ -453,6 +483,12 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver) }void drm_pci_agp_destroy (struct drm_device *dev) {} + +int drm_irq_by_busid (struct drm_device *dev,void *data, +struct drm_file *file_priv) +{ +return -EINVAL ; +}#endif EXPORT_SYMBOL (drm_pci_init);
include/drm/drmP.h +0 -1
@@ -737,7 +737,6 @@ struct drm_bus {int (*set_busid)(struct drm_device *dev,struct drm_master *master);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); };/**
Signature · 1 line
1.8.5.2
Re: [PATCH 03/18] drm/pci: fold in irq_by_busid support
On Fri, Apr 11, 2014 at 11:36:00PM +0200, Daniel Vetter wrote:
[...]
drivers/gpu/drm/drm_pci.c static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p) · line 285
Quoted 9 lines
drivers/gpu/drm/drm_pci.c +9
-0+int drm_irq_by_busid (struct drm_device *dev,void *data, +struct drm_file *file_priv) +{ +struct drm_irq_busid *p = data; + +if (drm_core_check_feature (dev,DRIVER_MODESET )) +return -EINVAL ; + +/* UMS was only ever support on pci devices. */
Nit: s/pci/PCI?
drivers/gpu/drm/drm_pci.c static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p) · line 295
Quoted 10 lines
drivers/gpu/drm/drm_pci.c +10
-0+if (WARN_ON (!dev->pdev)) +return -EINVAL ; + +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) +return -EINVAL ; + +return drm_pci_irq_by_busid (dev, p); +} + +
Nit: there's a gratuitous blank line introduced here.
Other than that:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/18 drm/irq: drm_control is a legacy ioctl, so pci devices only
In reply to Daniel VetterThis just adds a correspdonding check, follow-up patches will exploit this.
--- drivers/gpu/drm/drm_irq.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_irq.c +8 -8
@@ -386,22 +386,22 @@ int drm_control(struct drm_device *dev, void *data,* this used to be a separate function in drm_dma.h */ +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) +return 0 ; +if (drm_core_check_feature (dev,DRIVER_MODESET )) +return 0 ; +/* UMS was only ever support on pci devices. */ +if (WARN_ON (!dev->pdev)) +return -EINVAL ;switch (ctl->func) {case DRM_INST_HANDLER : -if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) -return 0 ; -if (drm_core_check_feature (dev,DRIVER_MODESET )) -return 0 ;if (dev->if_version <DRM_IF_VERSION (1 ,2 ) && ctl->irq !=drm_dev_to_irq (dev))return -EINVAL ; +return drm_irq_install (dev);case DRM_UNINST_HANDLER : -if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) -return 0 ; -if (drm_core_check_feature (dev,DRIVER_MODESET )) -return 0 ;return drm_irq_uninstall (dev);default :return -EINVAL ;
Signature · 1 line
1.8.5.2
Re: [PATCH 04/18] drm/irq: drm_control is a legacy ioctl, so pci devices only
On Fri, Apr 11, 2014 at 11:36:01PM +0200, Daniel Vetter wrote:
[...]
Quoted 16 lines
drivers/gpu/drm/drm_irq.c +7
-0@@ -386,22 +386,22 @@ int drm_control(struct drm_device *dev, void *data,* this used to be a separate function in drm_dma.h */ +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) +return 0 ; +if (drm_core_check_feature (dev,DRIVER_MODESET )) +return 0 ; +/* UMS was only ever support on pci devices. */ +if (WARN_ON (!dev->pdev)) +return -EINVAL ;
drivers/gpu/drm/drm_irq.c int drm_control(struct drm_device *dev, void *data, · line 402
Quoted 10 lines
drivers/gpu/drm/drm_irq.c +1
-4switch (ctl->func) {case DRM_INST_HANDLER : -if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ )) -return 0 ; -if (drm_core_check_feature (dev,DRIVER_MODESET )) -return 0 ;if (dev->if_version <DRM_IF_VERSION (1 ,2 ) && ctl->irq !=drm_dev_to_irq (dev))return -EINVAL ; +
Nit: This blank line seems unnecessary, but either way:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/18 drm/irq: remove cargo-culted locking from irq_install/unistall
In reply to Daniel VetterThe dev->struct_mutex locking in drm_irq.c only protects dev->irq_enabled. Which isn't really much at all and only prevents especially nasty ums userspace from concurrently installing the interrupt handling a few times. Or at least trying.
There are tons of unlocked readers of dev->irqs_enabled in the vblank wait code (and by extension also in the pageflip code since that uses the same vblank timestamp engine).
Real modesetting drivers should ensure that nothing can go haywire with a sane setup teardown sequence. So we only really need this for the drm_control ioctl, everywhere else this will just paper over nastiness.
Note that drm/i915 is a bit specially due to the gem+ums combination. So there we also need to properly protect the entervt and leavevt ioctls. But it's definitely saner to do everything in one go than to drop the lock in-between.
Finally there's the gpu reset code in drm/i915. That one's just race (concurrent userspace calls to for vblank waits of pageflips could spuriously fail). So wrap it up in with a nice comment since fixing this is more involved.
--- drivers/gpu/drm/drm_irq.c | 30 +++++++++++++----------------- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_gem.c | 5 +++-- 3 files changed, 21 insertions(+), 19 deletions(-)
drivers/gpu/drm/drm_irq.c +13 -17
@@ -254,20 +254,13 @@ int drm_irq_install(struct drm_device *dev)if (drm_dev_to_irq (dev) ==0 )return -EINVAL ; -mutex_lock (&dev->struct_mutex); -/* Driver must have been initialized */ -if (!dev->dev_private) { -mutex_unlock (&dev->struct_mutex); +if (!dev->dev_private)return -EINVAL ; - } -if (dev->irq_enabled) { -mutex_unlock (&dev->struct_mutex); +if (dev->irq_enabled)return -EBUSY ; - } dev->irq_enabled = true; -mutex_unlock (&dev->struct_mutex);DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev));
@@ -288,9 +281,7 @@ int drm_irq_install(struct drm_device *dev) sh_flags, irqname, dev);if (ret <0 ) { -mutex_lock (&dev->struct_mutex); dev->irq_enabled = false; -mutex_unlock (&dev->struct_mutex);return ret; }
@@ -302,9 +293,7 @@ int drm_irq_install(struct drm_device *dev) ret = dev->driver->irq_postinstall (dev);if (ret <0 ) { -mutex_lock (&dev->struct_mutex); dev->irq_enabled = false; -mutex_unlock (&dev->struct_mutex);if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL );free_irq (drm_dev_to_irq (dev), dev);
@@ -330,10 +319,8 @@ int drm_irq_uninstall(struct drm_device *dev)if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -mutex_lock (&dev->struct_mutex); irq_enabled = dev->irq_enabled; dev->irq_enabled = false; -mutex_unlock (&dev->struct_mutex);/* * Wake up any waiters so they don't hang.
@@ -381,6 +368,7 @@ int drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv) {struct drm_control *ctl = data; +int ret =0 ;/* if we haven't irq we fallback for compatibility reasons - * this used to be a separate function in drm_dma.h
@@ -400,9 +388,17 @@ int drm_control(struct drm_device *dev, void *data, ctl->irq != drm_dev_to_irq(dev))return -EINVAL ; -return drm_irq_install (dev); +mutex_lock (&dev->struct_mutex); + ret =drm_irq_install (dev); +mutex_unlock (&dev->struct_mutex); + +return ret;case DRM_UNINST_HANDLER : -return drm_irq_uninstall (dev); +mutex_lock (&dev->struct_mutex); + ret =drm_irq_uninstall (dev); +mutex_unlock (&dev->struct_mutex); + +return ret;default :return -EINVAL ; }
drivers/gpu/drm/i915/i915_drv.c +5 -0
@@ -746,6 +746,11 @@ int i915_reset(struct drm_device *dev)return ret; } +/* +* FIXME: This is horribly race against concurrent pageflip and +* vblank wait ioctls since they can observe dev->irqs_disabled +* being false when they shouldn't be able to. +*/ drm_irq_uninstall (dev);drm_irq_install (dev);
drivers/gpu/drm/i915/i915_gem.c +3 -2
@@ -4522,16 +4522,15 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data, }BUG_ON (!list_empty (&dev_priv->gtt.base.active_list)); -mutex_unlock (&dev->struct_mutex); ret =drm_irq_install (dev);if (ret) goto cleanup_ringbuffer; +mutex_unlock (&dev->struct_mutex);return 0 ; cleanup_ringbuffer: -mutex_lock (&dev->struct_mutex);i915_gem_cleanup_ringbuffer (dev); dev_priv->ums.mm_suspended =1 ;mutex_unlock (&dev->struct_mutex);
@@ -4546,7 +4545,9 @@ i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,if (drm_core_check_feature (dev,DRIVER_MODESET ))return 0 ; +mutex_lock (&dev->struct_mutex);drm_irq_uninstall (dev); +mutex_unlock (&dev->struct_mutex);return i915_gem_suspend (dev); }
Signature · 1 line
1.8.5.2
Re: [PATCH 05/18] drm/irq: remove cargo-culted locking from irq_install/unistall
Quoted 24 lines · Daniel Vetter
The
dev->struct_mutexlocking indrm_irq.conly protectsdev->irq_enabled. Which isn't really much at all and only prevents especially nasty ums userspace from concurrently installing the interrupt handling a few times. Or at least trying.There are tons of unlocked readers of
dev->irqs_enabledin the vblank wait code (and by extension also in the pageflip code since that uses the same vblank timestamp engine).Real modesetting drivers should ensure that nothing can go haywire with a sane setup teardown sequence. So we only really need this for the
drm_controlioctl, everywhere else this will just paper over nastiness.Note that drm/i915 is a bit specially due to the gem+ums combination. So there we also need to properly protect the entervt and leavevt ioctls. But it's definitely saner to do everything in one go than to drop the lock in-between.
Finally there's the gpu reset code in drm/i915. That one's just race (concurrent userspace calls to for vblank waits of pageflips could spuriously fail). So wrap it up in with a nice comment since fixing this is more involved.
Quoted 6 lines
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 30 +++++++++++++----------------- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_gem.c | 5 +++-- 3 files changed, 21 insertions(+), 19 deletions(-)
Looks good to me:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/18] drm/irq: remove cargo-culted locking from irq_install/unistall
Quoted 32 lines · Thierry Reding
Quoted 24 lines · Daniel Vetter
The
dev->struct_mutexlocking indrm_irq.conly protectsdev->irq_enabled. Which isn't really much at all and only prevents especially nasty ums userspace from concurrently installing the interrupt handling a few times. Or at least trying.There are tons of unlocked readers of
dev->irqs_enabledin the vblank wait code (and by extension also in the pageflip code since that uses the same vblank timestamp engine).Real modesetting drivers should ensure that nothing can go haywire with a sane setup teardown sequence. So we only really need this for the
drm_controlioctl, everywhere else this will just paper over nastiness.Note that drm/i915 is a bit specially due to the gem+ums combination. So there we also need to properly protect the entervt and leavevt ioctls. But it's definitely saner to do everything in one go than to drop the lock in-between.
Finally there's the gpu reset code in drm/i915. That one's just race (concurrent userspace calls to for vblank waits of pageflips could spuriously fail). So wrap it up in with a nice comment since fixing this is more involved.
Quoted 6 lines
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 30 +++++++++++++----------------- drivers/gpu/drm/i915/i915_drv.c | 5 +++++ drivers/gpu/drm/i915/i915_gem.c | 5 +++-- 3 files changed, 21 insertions(+), 19 deletions(-)
Quoted 3 lines
Looks good to me:
Reviewed-by Thierry Reding <[email protected]>
Oh, perhaps s/unistall/uninstall/ in the commit subject.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/18 drm: remove drm_dev_to_irq from drivers
In reply to Daniel VetterOnly used in some legacy pci drivers, and dereferncing the pci irq is actually shorter ...
Since this removes all users for drm_dev_to_irq from the tree except in drm_irq.c, move the inline helper in there. It'll disappear soon, too.
--- drivers/gpu/drm/drm_irq.c | 5 +++++ drivers/gpu/drm/mga/mga_state.c | 2 +- drivers/gpu/drm/r128/r128_state.c | 2 +- drivers/gpu/drm/radeon/radeon_state.c | 2 +- include/drm/drmP.h | 5 ----- 5 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_irq.c +5 -0
@@ -233,6 +233,11 @@ static void drm_irq_vgaarb_nokms(void *cookie, bool state) } } +static inline int drm_dev_to_irq (struct drm_device *dev) +{ +return dev->driver->bus->get_irq (dev); +} +/** * Install IRQ handler. *
drivers/gpu/drm/mga/mga_state.c +1 -1
@@ -1020,7 +1020,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *filswitch (param->param) {case MGA_PARAM_IRQ_NR : - value =drm_dev_to_irq (dev); + value = dev->pdev->irq;break ;case MGA_PARAM_CARD_TYPE : value = dev_priv->chipset;
drivers/gpu/drm/r128/r128_state.c +1 -1
@@ -1594,7 +1594,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fiswitch (param->param) {case R128_PARAM_IRQ_NR : - value =drm_dev_to_irq (dev); + value = dev->pdev->irq;break ;default :return -EINVAL ;
drivers/gpu/drm/radeon/radeon_state.c +1 -1
@@ -3054,7 +3054,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_filif ((dev_priv->flags &RADEON_FAMILY_MASK ) >=CHIP_R600 ) value =0 ;else - value =drm_dev_to_irq (dev); + value = dev->pdev->irq;break ;case RADEON_PARAM_GART_BASE : value = dev_priv->gart_vm_start;
include/drm/drmP.h +0 -5
@@ -1185,11 +1185,6 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,return ((dev->driver->driver_features & feature) ?1 :0 ); } -static inline int drm_dev_to_irq (struct drm_device *dev) -{ -return dev->driver->bus->get_irq (dev); -} -static inline void drm_device_set_unplugged (struct drm_device *dev) {smp_wmb ();
Signature · 1 line
1.8.5.2
Re: [PATCH 06/18] drm: remove drm_dev_to_irq from drivers
Quoted 6 lines · Daniel Vetter
Only used in some legacy pci drivers, and dereferncing the pci irq is actually shorter ...
Since this removes all users for
drm_dev_to_irqfrom the tree except indrm_irq.c, move the inline helper in there. It'll disappear soon, too.
Nit: s/dereferncing/dereferencing/ and s/pci/PCI/? Other than that, glad to see it go away.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/18 drm: kill drm_bus->bus_type
In reply to Daniel VetterCompletely unused. Hooray, midlayer mistakes that didn't cause work to undo!
v2: Rebase on top of the recent tegra changes which added a host1x drm bus.
--- drivers/gpu/drm/drm_pci.c | 1 - drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_usb.c | 1 - drivers/gpu/drm/tegra/bus.c | 1 - include/drm/drmP.h | 6 ------ 5 files changed, 10 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -1
@@ -318,7 +318,6 @@ void drm_pci_agp_destroy(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
@@ -123,7 +123,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
@@ -53,7 +53,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,
drivers/gpu/drm/tegra/bus.c +0 -1
@@ -37,7 +37,6 @@ static int drm_host1x_set_busid(struct drm_device *dev, }static struct drm_bus drm_host1x_bus = { - .bus_type =DRIVER_BUS_HOST1X , .set_busid = drm_host1x_set_busid, };
include/drm/drmP.h +0 -6
@@ -143,11 +143,6 @@ int drm_err(const char *func, const char *format, ...);#define DRIVER_PRIME 0x4000#define DRIVER_RENDER 0x8000 -#define DRIVER_BUS_PCI 0x1 -#define DRIVER_BUS_PLATFORM 0x2 -#define DRIVER_BUS_USB 0x3 -#define DRIVER_BUS_HOST1X 0x4 -/***********************************************************************/ /** \name Begin the DRM... */ /*@{*/
@@ -731,7 +726,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.8.5.2
Re: [PATCH 07/18] drm: kill drm_bus->bus_type
Quoted 2 lines · Daniel Vetter
Completely unused. Hooray, midlayer mistakes that didn't cause work to undo!
\o/
Quoted 2 lines
v2: Rebase on top of the recent tegra changes which added a host1x drm bus.
FWIW, I'm hoping to get rid of the host1x DRM bus soon. With this series applied it takes only a small additional patch to get rid of the requirement for .set_busid() and then I can simply to drm_dev_alloc() followed by drm_dev_register() directly in the driver.
Quoted 8 lines
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 1 - drivers/gpu/drm/drm_platform.c | 1 - drivers/gpu/drm/drm_usb.c | 1 - drivers/gpu/drm/tegra/bus.c | 1 - include/drm/drmP.h | 6 ------ 5 files changed, 10 deletions(-)
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/18 drm: Rip out totally bogus vga_switcheroo->can_switch locking
In reply to Daniel VetterSo I just wanted to add a new field to struct drm_device and accidentally stumbled over something. According to comments dev->open_count is protected by dev->count_lock, but that's totally not the case. It's protected by drm_global_mutex.
Unfortunately the vga switcheroo callbacks took this comment at face value. The problem is that we can't just take the drm_global_mutex because:
- It would lead to a locking inversion with the driver load/unload paths.
- It wouldn't actually protect anything, for that we'd need to wrap the entire vga switcheroo code in the drm_global_mutex. And I'm not sure whether that would actually solve anything.
What we probably want is a try_to_grab_switcheroo reference kind of thing which is used in the driver's ->open callback. Then we could move all that ->can_switch madness into the vga switcheroo core where it really belongs.
But since that would amount to real work take the easy way out and just add a comment. It's definitely not going to make anything worse since doing switcheroo state changes while restarting X just isn't recommended. Even though the delayed switching code does exactly that.
--- drivers/gpu/drm/i915/i915_dma.c | 7 +++++-- drivers/gpu/drm/nouveau/nouveau_vga.c | 7 +++++-- drivers/gpu/drm/radeon/radeon_device.c | 7 +++++-- include/drm/drmP.h | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +5 -2
@@ -1286,9 +1286,12 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);bool can_switch; -spin_lock (&dev->count_lock); +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock);return can_switch; }
drivers/gpu/drm/nouveau/nouveau_vga.c +5 -2
@@ -66,9 +66,12 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);bool can_switch; -spin_lock (&dev->count_lock); +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock);return can_switch; }
drivers/gpu/drm/radeon/radeon_device.c +5 -2
@@ -1124,9 +1124,12 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);bool can_switch; -spin_lock (&dev->count_lock); +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock);return can_switch; }
include/drm/drmP.h +1 -1
@@ -1076,7 +1076,7 @@ struct drm_device {/** \name Usage Counters */ /*@{ */ -int open_count;/**< Outstanding files open */ +int open_count;/**< Outstanding files open, protected by drm_global_lock. */ int buf_use;/**< Buffers in use -- cannot alloc */ atomic_t buf_alloc;/**< Buffer allocation in progress */ /*@} */
Signature · 1 line
1.8.5.2
Re: [PATCH 08/18] drm: Rip out totally bogus vga_switcheroo->can_switch locking
On Fri, Apr 11, 2014 at 11:36:05PM +0200, Daniel Vetter wrote:
[...]
Quoted 8 lines
drivers/gpu/drm/i915/i915_dma.c +0
-0@@ -1286,9 +1286,12 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)struct drm_device *dev =pci_get_drvdata (pdev);bool can_switch;
drivers/gpu/drm/i915/i915_dma.c static bool i915_switcheroo_can_switch(struct pci_dev *pdev) · line 1296
Quoted 10 lines
drivers/gpu/drm/i915/i915_dma.c +5
-2-spin_lock (&dev->count_lock); +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock);return can_switch; }
Couldn't this now be shortened to:
return (dev->open_count == 0);
? Similarily for the other drivers.
include/drm/drmP.h struct drm_device { · line 1079
Quoted 10 lines
include/drm/drmP.h +1
-1@@ -1076,7 +1076,7 @@ struct drm_device {/** \name Usage Counters */ /*@{ */ -int open_count;/**< Outstanding files open */ +int open_count;/**< Outstanding files open, protected by drm_global_lock. */
s/drm_global_lock/drm_global_mutex/?
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm: Rip out totally bogus vga_switcheroo->can_switch locking
So I just wanted to add a new field to struct drm_device and accidentally stumbled over something. According to comments dev->open_count is protected by dev->count_lock, but that's totally not the case. It's protected by drm_global_mutex.
Unfortunately the vga switcheroo callbacks took this comment at face value. The problem is that we can't just take the drm_global_mutex because:
- It would lead to a locking inversion with the driver load/unload paths.
- It wouldn't actually protect anything, for that we'd need to wrap the entire vga switcheroo code in the drm_global_mutex. And I'm not sure whether that would actually solve anything.
What we probably want is a try_to_grab_switcheroo reference kind of thing which is used in the driver's ->open callback. Then we could move all that ->can_switch madness into the vga switcheroo core where it really belongs.
But since that would amount to real work take the easy way out and just add a comment. It's definitely not going to make anything worse since doing switcheroo state changes while restarting X just isn't recommended. Even though the delayed switching code does exactly that.
v2:
- Simplify the ->can_switch implementations more (Thierry)
- Fix comment about the dev->open_count locking (Thierry)
--- drivers/gpu/drm/i915/i915_dma.c | 11 ++++++----- drivers/gpu/drm/nouveau/nouveau_vga.c | 11 ++++++----- drivers/gpu/drm/radeon/radeon_device.c | 11 ++++++----- include/drm/drmP.h | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +6 -5
@@ -1277,12 +1277,13 @@ static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_static bool i915_switcheroo_can_switch (struct pci_dev *pdev) {struct drm_device *dev =pci_get_drvdata (pdev); -bool can_switch; -spin_lock (&dev->count_lock); - can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock); -return can_switch; +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ +return dev->open_count ==0 ; }static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
drivers/gpu/drm/nouveau/nouveau_vga.c +6 -5
@@ -64,12 +64,13 @@ static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev) {struct drm_device *dev =pci_get_drvdata (pdev); -bool can_switch; -spin_lock (&dev->count_lock); - can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock); -return can_switch; +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ +return dev->open_count ==0 ; } static const struct vga_switcheroo_client_ops
drivers/gpu/drm/radeon/radeon_device.c +6 -5
@@ -1125,12 +1125,13 @@ static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcherostatic bool radeon_switcheroo_can_switch (struct pci_dev *pdev) {struct drm_device *dev =pci_get_drvdata (pdev); -bool can_switch; -spin_lock (&dev->count_lock); - can_switch = (dev->open_count ==0 ); -spin_unlock (&dev->count_lock); -return can_switch; +/* +* FIXME: open_count is protected by drm_global_mutex but that would lead to +* locking inversion with the driver load path. And the access here is +* completely racy anyway. So don't bother with locking for now. +*/ +return dev->open_count ==0 ; }static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
include/drm/drmP.h +1 -1
@@ -1076,7 +1076,7 @@ struct drm_device {/** \name Usage Counters */ /*@{ */ -int open_count;/**< Outstanding files open */ +int open_count;/**< Outstanding files open, protected by drm_global_mutex. */ int buf_use;/**< Buffers in use -- cannot alloc */ atomic_t buf_alloc;/**< Buffer allocation in progress */ /*@} */
Signature · 1 line
1.9.2
Re: [PATCH] drm: Rip out totally bogus vga_switcheroo->can_switch locking
Quoted 31 lines · Daniel Vetter
So I just wanted to add a new field to struct
drm_deviceand accidentally stumbled over something. According to commentsdev->open_countis protected bydev->count_lock, but that's totally not the case. It's protected bydrm_global_mutex.Unfortunately the vga switcheroo callbacks took this comment at face value. The problem is that we can't just take the
drm_global_mutexbecause:
- It would lead to a locking inversion with the driver load/unload paths.
- It wouldn't actually protect anything, for that we'd need to wrap the entire vga switcheroo code in thedrm_global_mutex. And I'm not sure whether that would actually solve anything.What we probably want is a
try_to_grab_switcherooreference kind of thing which is used in the driver's ->open callback. Then we could move all that ->can_switch madness into the vga switcheroo core where it really belongs.But since that would amount to real work take the easy way out and just add a comment. It's definitely not going to make anything worse since doing switcheroo state changes while restarting X just isn't recommended. Even though the delayed switching code does exactly that.
v2:
- Simplify the ->can_switch implementations more (Thierry)
- Fix comment about thedev->open_countlocking (Thierry)Cc Thierry Reding <[email protected]>Reviewed-by Laurent Pinchart <[email protected]> (v1)Signed-off-by Daniel Vetter <[email protected]>
Quoted 6 lines
--- drivers/gpu/drm/i915/i915_dma.c | 11 ++++++----- drivers/gpu/drm/nouveau/nouveau_vga.c | 11 ++++++----- drivers/gpu/drm/radeon/radeon_device.c | 11 ++++++----- include/drm/drmP.h | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-)
Looks good:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/18 drm: rename dev->count_lock to dev->buf_lock
In reply to Daniel VetterSince really that's all it protects - legacy horror stories in drm_bufs.c. Since I don't want to waste any more time on this I didn't bother to actually look at what it protects in there, but it's at least contained now.
v2: Move the spurious hunk to the right patch (Thierry).
--- drivers/gpu/drm/drm_bufs.c | 32 ++++++++++++++++---------------- drivers/gpu/drm/drm_stub.c | 2 +- include/drm/drmP.h | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_bufs.c +16 -16
@@ -656,13 +656,13 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)DRM_DEBUG ("zone invalid\n" );return -EINVAL ; } -spin_lock (&dev->count_lock); +spin_lock (&dev->buf_lock);if (dev->buf_use) { -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);return -EBUSY ; }atomic_inc (&dev->buf_alloc); -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);mutex_lock (&dev->struct_mutex); entry = &dma->bufs[order];
@@ -805,13 +805,13 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) page_order = order -PAGE_SHIFT >0 ? order -PAGE_SHIFT :0 ; total =PAGE_SIZE << page_order; -spin_lock (&dev->count_lock); +spin_lock (&dev->buf_lock);if (dev->buf_use) { -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);return -EBUSY ; }atomic_inc (&dev->buf_alloc); -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);mutex_lock (&dev->struct_mutex); entry = &dma->bufs[order];
@@ -1015,13 +1015,13 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * requestif (order <DRM_MIN_ORDER || order >DRM_MAX_ORDER )return -EINVAL ; -spin_lock (&dev->count_lock); +spin_lock (&dev->buf_lock);if (dev->buf_use) { -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);return -EBUSY ; }atomic_inc (&dev->buf_alloc); -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);mutex_lock (&dev->struct_mutex); entry = &dma->bufs[order];
@@ -1175,7 +1175,7 @@ int drm_addbufs(struct drm_device *dev, void *data,* \param arg pointer to a drm_buf_info structure. * \return zero on success or a negative number on failure. * -* Increments drm_device::buf_use while holding the drm_device::count_lock +* Increments drm_device::buf_use while holding the drm_device::buf_lock * lock, preventing of allocating more buffers after this call. Information * about each requested buffer is then copied into user space. */
@@ -1196,13 +1196,13 @@ int drm_infobufs(struct drm_device *dev, void *data,if (!dma)return -EINVAL ; -spin_lock (&dev->count_lock); +spin_lock (&dev->buf_lock);if (atomic_read (&dev->buf_alloc)) { -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);return -EBUSY ; } ++dev->buf_use;/* Can't allocate more after this call */ -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);for (i =0 , count =0 ; i <DRM_MAX_ORDER +1 ; i++) {if (dma->bufs[i].buf_count)
@@ -1381,13 +1381,13 @@ int drm_mapbufs(struct drm_device *dev, void *data,if (!dma)return -EINVAL ; -spin_lock (&dev->count_lock); +spin_lock (&dev->buf_lock);if (atomic_read (&dev->buf_alloc)) { -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);return -EBUSY ; } dev->buf_use++;/* Can't allocate more after this call */ -spin_unlock (&dev->count_lock); +spin_unlock (&dev->buf_lock);if (request->count >= dma->buf_count) { if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP))
drivers/gpu/drm/drm_stub.c +1 -1
@@ -569,7 +569,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,INIT_LIST_HEAD (&dev->maplist);INIT_LIST_HEAD (&dev->vblank_event_list); -spin_lock_init (&dev->count_lock); +spin_lock_init (&dev->buf_lock);spin_lock_init (&dev->event_lock);mutex_init (&dev->struct_mutex);mutex_init (&dev->ctxlist_mutex);
include/drm/drmP.h +1 -1
@@ -1069,7 +1069,6 @@ struct drm_device {/** \name Locks */ /*@{ */ -spinlock_t count_lock;/**< For inuse, drm_device::open_count, drm_device::buf_use */ struct mutex struct_mutex;/**< For others */ struct mutex master_mutex;/**< For drm_minor::master and drm_file::is_master */ /*@} */
@@ -1077,6 +1076,7 @@ struct drm_device {/** \name Usage Counters */ /*@{ */ int open_count;/**< Outstanding files open, protected by drm_global_lock. */ +spinlock_t buf_lock;/**< For drm_device::buf_use and a few other things. */ int buf_use;/**< Buffers in use -- cannot alloc */ atomic_t buf_alloc;/**< Buffer allocation in progress */ /*@} */
Signature · 1 line
1.8.5.2
Re: [PATCH 09/18] drm: rename dev->count_lock to dev->buf_lock
Quoted 7 lines · Daniel Vetter
Since really that's all it protects - legacy horror stories in
drm_bufs.c. Since I don't want to waste any more time on this I didn't bother to actually look at what it protects in there, but it's at least contained now.v2: Move the spurious hunk to the right patch (Thierry).
Quoted 7 lines
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_bufs.c | 32 ++++++++++++++++---------------- drivers/gpu/drm/drm_stub.c | 2 +- include/drm/drmP.h | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-)
Looks good:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/18 drm/irq: track the irq installed in drm_irq_install in dev->irq
In reply to Daniel VetterTo get rid of the dev->bus->get_irq callback we need to pass in the desired irq explicitly into drm_irq_install. To avoid having to do the same for drm_irq_unistall just track it internally. That leaves drivers with less room to botch things up.
v2: Add the hunk lost in an earlier patch to this one (Thierry).
--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_irq.c +11 -7
@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device *dev)*/ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )return -EINVAL ;/* Driver must have been initialized */
@@ -267,7 +269,7 @@ int drm_irq_install(struct drm_device *dev)return -EBUSY ; dev->irq_enabled = true; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);/* Before installing handler */ if (dev->driver->irq_preinstall)
@@ -282,7 +284,7 @@ int drm_irq_install(struct drm_device *dev)else irqname = dev->driver->name; - ret =request_irq (drm_dev_to_irq (dev), dev->driver->irq_handler, + ret =request_irq (dev->irq, dev->driver->irq_handler, sh_flags, irqname, dev);if (ret <0 ) {
@@ -301,7 +303,9 @@ int drm_irq_install(struct drm_device *dev) dev->irq_enabled = false;if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL ); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev); + }else { + dev->irq = irq; }return ret;
@@ -344,7 +348,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (!irq_enabled)return -EINVAL ; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL );
@@ -352,7 +356,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (dev->driver->irq_uninstall) dev->driver->irq_uninstall (dev); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev);return 0 ; }
include/drm/drmP.h +2 -0
@@ -1107,6 +1107,8 @@ struct drm_device {/** \name Context support */ /*@{ */ bool irq_enabled;/**< True if irq handler is enabled */ +int irq; +__volatile__ long context_flag;/**< Context swapping flag */ int last_context;/**< Last current context */ /*@} */
Signature · 1 line
1.8.5.2
Re: [PATCH 10/18] drm/irq: track the irq installed in drm_irq_install in dev->irq
Hi Daniel,
Thank you for the patch.
Quoted 38 lines · On Friday 11 April 2014 23:36:07 Daniel Vetter wrote:
To get rid of the
dev->bus->get_irqcallback we need to pass in the desired irq explicitly intodrm_irq_install. To avoid having to do the same fordrm_irq_unistalljust track it internally. That leaves drivers with less room to botch things up.v2: Add the hunk lost in an earlier patch to this one (Thierry).
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_irq.c +4
-2@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device*dev) */ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )return -EINVAL ;/* Driver must have been initialized */
drivers/gpu/drm/drm_irq.c int drm_irq_install(struct drm_device *dev) · line 272
Quoted 5 lines
drivers/gpu/drm/drm_irq.c +1
-1@@ -267,7 +269,7 @@ int drm_irq_install(struct drm_device *dev)return -EBUSY ; dev->irq_enabled = true; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);
I might be missing something obvious, but you use dev->irq throughout the whole function while you only set it at the end.
Quoted 53 lines
drivers/gpu/drm/drm_irq.c +6
-4/* Before installing handler */ if (dev->driver->irq_preinstall)@@ -282,7 +284,7 @@ int drm_irq_install(struct drm_device *dev)else irqname = dev->driver->name; - ret =request_irq (drm_dev_to_irq (dev), dev->driver->irq_handler, + ret =request_irq (dev->irq, dev->driver->irq_handler, sh_flags, irqname, dev);if (ret <0 ) {@@ -301,7 +303,9 @@ int drm_irq_install(struct drm_device *dev) dev->irq_enabled = false;if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL ); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev); + }else { + dev->irq = irq; }return ret;@@ -344,7 +348,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (!irq_enabled)return -EINVAL ; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL );@@ -352,7 +356,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (dev->driver->irq_uninstall) dev->driver->irq_uninstall (dev); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev);return 0 ; }include/drm/drmP.h +2
-0@@ -1107,6 +1107,8 @@ struct drm_device {/** \name Context support */ /*@{ */ bool irq_enabled;/**< True if irq handler is enabled */ +int irq; +__volatile__ long context_flag;/**< Context swapping flag */ int last_context;/**< Last current context */ /*@} */
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 10/18] drm/irq: track the irq installed in drm_irq_install in dev->irq
In reply to Daniel VetterAnd another comment...
Quoted 24 lines · On Friday 11 April 2014 23:36:07 Daniel Vetter wrote:
To get rid of the
dev->bus->get_irqcallback we need to pass in the desired irq explicitly intodrm_irq_install. To avoid having to do the same fordrm_irq_unistalljust track it internally. That leaves drivers with less room to botch things up.v2: Add the hunk lost in an earlier patch to this one (Thierry).
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_irq.c +1
-1@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device*dev) */ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device · line 261
Quoted 10 lines
drivers/gpu/drm/drm_irq.c +3
-1unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )
Isn't 0 a valid IRQ number ? Shouldn't you check for irq < 0 instead ? At least platform_get_irq() returns a negative error value on failure.
Quoted 63 lines
drivers/gpu/drm/drm_irq.c +7
-5return -EINVAL ;/* Driver must have been initialized */ @@ -267,7 +269,7 @@ int drm_irq_install(struct drm_device *dev)return -EBUSY ; dev->irq_enabled = true; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);/* Before installing handler */ if (dev->driver->irq_preinstall)@@ -282,7 +284,7 @@ int drm_irq_install(struct drm_device *dev)else irqname = dev->driver->name; - ret =request_irq (drm_dev_to_irq (dev), dev->driver->irq_handler, + ret =request_irq (dev->irq, dev->driver->irq_handler, sh_flags, irqname, dev);if (ret <0 ) {@@ -301,7 +303,9 @@ int drm_irq_install(struct drm_device *dev) dev->irq_enabled = false;if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL ); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev); + }else { + dev->irq = irq; }return ret;@@ -344,7 +348,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (!irq_enabled)return -EINVAL ; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL );@@ -352,7 +356,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (dev->driver->irq_uninstall) dev->driver->irq_uninstall (dev); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev);return 0 ; }include/drm/drmP.h +2
-0@@ -1107,6 +1107,8 @@ struct drm_device {/** \name Context support */ /*@{ */ bool irq_enabled;/**< True if irq handler is enabled */ +int irq; +__volatile__ long context_flag;/**< Context swapping flag */ int last_context;/**< Last current context */ /*@} */
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 10/18] drm/irq: track the irq installed in drm_irq_install in dev->irq
Quoted 35 lines · Laurent Pinchart
And another comment...
Quoted 32 lines · On Friday 11 April 2014 23:36:07 Daniel Vetter wrote:
To get rid of the
dev->bus->get_irqcallback we need to pass in the desired irq explicitly intodrm_irq_install. To avoid having to do the same fordrm_irq_unistalljust track it internally. That leaves drivers with less room to botch things up.v2: Add the hunk lost in an earlier patch to this one (Thierry).
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_irq.c +3
-1@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device*dev) */ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ;
Quoted 5 lines
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 261
Quoted 2 lines
drivers/gpu/drm/drm_irq.c +1
-1-if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )Isn't 0 a valid IRQ number ? Shouldn't you check for irq < 0 instead ? At least
platform_get_irq()returns a negative error value on failure.
tbh I'm not really clear on how this works. If we want to change this then I think that should be a separate patch. Also it might be better to extract this check into drm_control, which is the only function that really needs it since it is called by userspace.
For all other places it is a simple driver bug and I'm not sure how much we should care - request_irq should catch any abuse already.
In any case this should be a separate patch.
-Daniel
Quoted 70 lines
Quoted 64 lines
drivers/gpu/drm/drm_irq.c +7
-5return -EINVAL ;/* Driver must have been initialized */ @@ -267,7 +269,7 @@ int drm_irq_install(struct drm_device *dev)return -EBUSY ; dev->irq_enabled = true; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);/* Before installing handler */ if (dev->driver->irq_preinstall)@@ -282,7 +284,7 @@ int drm_irq_install(struct drm_device *dev)else irqname = dev->driver->name; - ret =request_irq (drm_dev_to_irq (dev), dev->driver->irq_handler, + ret =request_irq (dev->irq, dev->driver->irq_handler, sh_flags, irqname, dev);if (ret <0 ) {@@ -301,7 +303,9 @@ int drm_irq_install(struct drm_device *dev) dev->irq_enabled = false;if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL ); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev); + }else { + dev->irq = irq; }return ret;@@ -344,7 +348,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (!irq_enabled)return -EINVAL ; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL );@@ -352,7 +356,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (dev->driver->irq_uninstall) dev->driver->irq_uninstall (dev); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev);return 0 ; }include/drm/drmP.h +2
-0@@ -1107,6 +1107,8 @@ struct drm_device {/** \name Context support */ /*@{ */ bool irq_enabled;/**< True if irq handler is enabled */ +int irq; +__volatile__ long context_flag;/**< Context swapping flag */ int last_context;/**< Last current context */ /*@} */ Signature · 3 lines
Regards, Laurent Pinchart
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 10/18] drm/irq: track the irq installed in drm_irq_install in dev->irq
Quoted 47 lines · Daniel Vetter
Quoted 35 lines · Laurent Pinchart
And another comment...
Quoted 32 lines · On Friday 11 April 2014 23:36:07 Daniel Vetter wrote:
To get rid of the
dev->bus->get_irqcallback we need to pass in the desired irq explicitly intodrm_irq_install. To avoid having to do the same fordrm_irq_unistalljust track it internally. That leaves drivers with less room to botch things up.v2: Add the hunk lost in an earlier patch to this one (Thierry).
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_irq.c +3
-1@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device*dev) */ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ;Quoted 5 lines
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 261
Quoted 2 lines
drivers/gpu/drm/drm_irq.c +1
-1-if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )Isn't 0 a valid IRQ number ? Shouldn't you check for irq < 0 instead ? At least
platform_get_irq()returns a negative error value on failure.tbh I'm not really clear on how this works. If we want to change this then I think that should be a separate patch. Also it might be better to extract this check into
drm_control, which is the only function that really needs it since it is called by userspace.
Quoted 4 lines
For all other places it is a simple driver bug and I'm not sure how much we should care -
request_irqshould catch any abuse already.In any case this should be a separate patch.
I agree. This patch mostly mechanically replaces things and this bug did already exist previously. So let's fix it separately (if at all).
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 10/18] drm/irq: track the irq installed in drm_irq_install in dev->irq
In reply to Daniel VetterQuoted 19 lines · Daniel Vetter
To get rid of the
dev->bus->get_irqcallback we need to pass in the desired irq explicitly intodrm_irq_install. To avoid having to do the same fordrm_irq_unistalljust track it internally. That leaves drivers with less room to botch things up.v2: Add the hunk lost in an earlier patch to this one (Thierry).
Cc Thierry Reding <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_irq.c +0
-0
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 257
Quoted 10 lines
drivers/gpu/drm/drm_irq.c +3
-1@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device *dev)*/ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +
This looks odd...
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 262
Quoted 6 lines
drivers/gpu/drm/drm_irq.c +1
-1if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )return -EINVAL ;
Wouldn't it make more sense to assign irq only here? And while at it, perhaps you meant to store irq directly within dev->irq, rather than in a local variable? That would address Laurent's comment as well.
Quoted 21 lines
drivers/gpu/drm/drm_irq.c +2
-2/* Driver must have been initialized */ @@ -267,7 +269,7 @@ int drm_irq_install(struct drm_device *dev)return -EBUSY ; dev->irq_enabled = true; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);/* Before installing handler */ if (dev->driver->irq_preinstall)@@ -282,7 +284,7 @@ int drm_irq_install(struct drm_device *dev)else irqname = dev->driver->name; - ret =request_irq (drm_dev_to_irq (dev), dev->driver->irq_handler, + ret =request_irq (dev->irq, dev->driver->irq_handler, sh_flags, irqname, dev);if (ret <0 ) {
drivers/gpu/drm/drm_irq.c int drm_irq_install(struct drm_device *dev) · line 309
Quoted 8 lines
drivers/gpu/drm/drm_irq.c +3
-1@@ -301,7 +303,9 @@ int drm_irq_install(struct drm_device *dev) dev->irq_enabled = false;if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL ); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev); + }else { + dev->irq = irq; }
But perhaps you really only want to assign it after it's been properly initialized, so I guess the local variable is fine. But in that case you probably need to make sure to not use dev->irq until after this assignment.
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/irq: track the irq installed in drm_irq_install in dev->irq
In reply to Daniel VetterTo get rid of the dev->bus->get_irq callback we need to pass in the desired irq explicitly into drm_irq_install. To avoid having to do the same for drm_irq_unistall just track it internally. That leaves drivers with less room to botch things up.
v2: Add the hunk lost in an earlier patch to this one (Thierry).
v3: Fix up the totally fumbled logic in drm_irq_install and use the local variable consistently. Spotted by both Thierry and Laurent. Shame on me for failing to properly test the rebase version of this patch ...
--- drivers/gpu/drm/drm_irq.c | 18 +++++++++++------- include/drm/drmP.h | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_irq.c +11 -7
@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device *dev)*/ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev); +if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )return -EINVAL ;/* Driver must have been initialized */
@@ -267,7 +269,7 @@ int drm_irq_install(struct drm_device *dev)return -EBUSY ; dev->irq_enabled = true; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , irq);/* Before installing handler */ if (dev->driver->irq_preinstall)
@@ -282,7 +284,7 @@ int drm_irq_install(struct drm_device *dev)else irqname = dev->driver->name; - ret =request_irq (drm_dev_to_irq (dev), dev->driver->irq_handler, + ret =request_irq (irq, dev->driver->irq_handler, sh_flags, irqname, dev);if (ret <0 ) {
@@ -301,7 +303,9 @@ int drm_irq_install(struct drm_device *dev) dev->irq_enabled = false;if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL ); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (irq, dev); + }else { + dev->irq = irq; }return ret;
@@ -344,7 +348,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (!irq_enabled)return -EINVAL ; -DRM_DEBUG ("irq=%d\n" ,drm_dev_to_irq (dev)); +DRM_DEBUG ("irq=%d\n" , dev->irq);if (!drm_core_check_feature (dev,DRIVER_MODESET ))vga_client_register (dev->pdev,NULL ,NULL ,NULL );
@@ -352,7 +356,7 @@ int drm_irq_uninstall(struct drm_device *dev)if (dev->driver->irq_uninstall) dev->driver->irq_uninstall (dev); -free_irq (drm_dev_to_irq (dev), dev); +free_irq (dev->irq, dev);return 0 ; }
include/drm/drmP.h +2 -0
@@ -1107,6 +1107,8 @@ struct drm_device {/** \name Context support */ /*@{ */ bool irq_enabled;/**< True if irq handler is enabled */ +int irq; +__volatile__ long context_flag;/**< Context swapping flag */ int last_context;/**< Last current context */ /*@} */
Signature · 1 line
1.9.2
Re: [PATCH] drm/irq: track the irq installed in drm_irq_install in dev->irq
On Tue, Apr 22, 2014 at 10:44:20PM +0200, Daniel Vetter wrote:
[...]
Quoted 5 lines
drivers/gpu/drm/drm_irq.c +0
-0
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 256
Quoted 9 lines
drivers/gpu/drm/drm_irq.c +2
-1@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device *dev)*/ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev);
I think the assignment could have happened either when the variable is declared, or...
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 261
Quoted 6 lines
drivers/gpu/drm/drm_irq.c +2
-1+if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ; -if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )
... right above this, since it is where it is first used (it may not be necessary to query it before here at all if the driver doesn't set DRIVER_HAVE_IRQ).
But I realize that that's pure bike-shedding, so either way:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/irq: track the irq installed in drm_irq_install in dev->irq
Quoted 24 lines · Thierry Reding
On Tue, Apr 22, 2014 at 10:44:20PM +0200, Daniel Vetter wrote:
[...]Quoted 5 lines
drivers/gpu/drm/drm_irq.c +0
-0drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 256
Quoted 9 lines
drivers/gpu/drm/drm_irq.c +2
-1@@ -249,14 +249,16 @@ static inline int drm_dev_to_irq(struct drm_device *dev)*/ int drm_irq_install (struct drm_device *dev) { -int ret; +int ret, irq;unsigned long sh_flags =0 ;char *irqname; + irq =drm_dev_to_irq (dev);I think the assignment could have happened either when the variable is declared, or...
Quoted 4 lines
drivers/gpu/drm/drm_irq.c +1
-0+if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ;
Quoted 8 lines
drivers/gpu/drm/drm_irq.c static inline int drm_dev_to_irq(struct drm_device *dev) · line 261
Quoted 2 lines
drivers/gpu/drm/drm_irq.c +1
-1-if (drm_dev_to_irq (dev) ==0 ) +if (irq ==0 )... right above this, since it is where it is first used (it may not be necessary to query it before here at all if the driver doesn't set
DRIVER_HAVE_IRQ).But I realize that that's pure bike-shedding, so either way:
Follow-on patches will move this assignement into drivers and make int irq an function parameter, so I think I'll leave this ;-)
Quoted 2 lines
Reviewed-by Thierry Reding <[email protected]>
Thanks for the review, I'll send the pull request to Dave now. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 11/18 drm/irq: Look up the pci irq directly in the drm_control ioctl
In reply to Daniel VetterIt's only ever called for legacy drivers, which are all pci.
--- drivers/gpu/drm/drm_irq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_irq.c +4 -2
@@ -377,7 +377,7 @@ int drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv) {struct drm_control *ctl = data; -int ret =0 ; +int ret =0 , irq;/* if we haven't irq we fallback for compatibility reasons - * this used to be a separate function in drm_dma.h
@@ -393,8 +393,10 @@ int drm_control(struct drm_device *dev, void *data,switch (ctl->func) {case DRM_INST_HANDLER : + irq = dev->pdev->irq; +if (dev->if_version <DRM_IF_VERSION (1 ,2 ) && - ctl->irq !=drm_dev_to_irq (dev)) + ctl->irq != irq)return -EINVAL ;mutex_lock (&dev->struct_mutex);
Signature · 1 line
1.8.5.2
PATCH 12/18 drm: pass the irq explicitly to drm_irq_install
In reply to Daniel VetterUnfortunately this requires a drm-wide change, and I didn't see a sane way around that. Luckily it's fairly simple, we just need to inline the respective get_irq implementation from either drm_pci.c or drm_platform.c.
With that we can now also remove drm_dev_to_irq from drm_irq.c.
--- Documentation/DocBook/drm.tmpl | 10 +--------- drivers/gpu/drm/armada/armada_drv.c | 2 +- drivers/gpu/drm/drm_irq.c | 13 +++---------- drivers/gpu/drm/gma500/psb_drv.c | 2 +- drivers/gpu/drm/i915/i915_dma.c | 2 +- drivers/gpu/drm/i915/i915_drv.c | 4 ++-- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/msm/msm_drv.c | 2 +- drivers/gpu/drm/qxl/qxl_irq.c | 2 +- drivers/gpu/drm/radeon/radeon_irq_kms.c | 2 +- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- include/drm/drmP.h | 2 +- 14 files changed, 17 insertions(+), 32 deletions(-)
Documentation/DocBook/drm.tmpl +1 -9
@@ -342,21 +342,13 @@ char *date;</synopsis> <sect4> <title>Managed IRQ Registration</title> <para> - Both the <function>drm_irq_install</function> and - <function>drm_irq_uninstall</function> functions get the device IRQ by - calling <function>drm_dev_to_irq</function>. This inline function will - call a bus-specific operation to retrieve the IRQ number. For platform - devices, <function>platform_get_irq</function>(..., 0) is used to - retrieve the IRQ number. - </para> - <para> <function>drm_irq_install</function> starts by calling the <methodname>irq_preinstall</methodname> driver operation. The operation is optional and must make sure that the interrupt will not get fired by clearing all pending interrupt flags or disabling the interrupt. </para> <para> - The IRQ will then be requested by a call to + The passed-in IRQ will then be requested by a call to <function>request_irq</function>. If the DRIVER_IRQ_SHARED driver feature flag is set, a shared (IRQF_SHARED) IRQ handler will be requested.
drivers/gpu/drm/armada/armada_drv.c +1 -1
@@ -173,7 +173,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)if (ret) goto err_kms; - ret =drm_irq_install (dev); + ret =drm_irq_install (dev,platform_get_irq (dev->platformdev,0 ));if (ret) goto err_kms;
drivers/gpu/drm/drm_irq.c +3 -10
@@ -233,11 +233,6 @@ static void drm_irq_vgaarb_nokms(void *cookie, bool state) } } -static inline int drm_dev_to_irq (struct drm_device *dev) -{ -return dev->driver->bus->get_irq (dev); -} -/** * Install IRQ handler. *
@@ -247,14 +242,12 @@ static inline int drm_dev_to_irq(struct drm_device *dev)* \c irq_preinstall() and \c irq_postinstall() functions * before and after the installation. */ -int drm_irq_install (struct drm_device *dev) +int drm_irq_install (struct drm_device *dev,int irq) { -int ret, irq; +int ret;unsigned long sh_flags =0 ;char *irqname; - irq =drm_dev_to_irq (dev); -if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ;
@@ -400,7 +393,7 @@ int drm_control(struct drm_device *dev, void *data,return -EINVAL ;mutex_lock (&dev->struct_mutex); - ret =drm_irq_install (dev); + ret =drm_irq_install (dev, irq);mutex_unlock (&dev->struct_mutex);return ret;
drivers/gpu/drm/gma500/psb_drv.c +1 -1
@@ -354,7 +354,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)PSB_WVDC32 (0xFFFFFFFF ,PSB_INT_MASK_R );spin_unlock_irqrestore (&dev_priv->irqmask_lock, irqflags); -drm_irq_install (dev); +drm_irq_install (dev, dev->pdev->irq); dev->vblank_disable_allowed = true; dev->max_vblank_count =0xffffff ;/* only 24 bits of frame count */
drivers/gpu/drm/i915/i915_dma.c +1 -1
@@ -1336,7 +1336,7 @@ static int i915_load_modeset_init(struct drm_device *dev)intel_power_domains_init_hw (dev_priv); - ret =drm_irq_install (dev); + ret =drm_irq_install (dev, dev->pdev->irq);if (ret) goto cleanup_gem_stolen;
drivers/gpu/drm/i915/i915_drv.c +2 -2
@@ -574,7 +574,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)mutex_unlock (&dev->struct_mutex);/* We need working interrupts for modeset enabling ... */ -drm_irq_install (dev); +drm_irq_install (dev, dev->pdev->irq);intel_modeset_init_hw (dev);
@@ -752,7 +752,7 @@ int i915_reset(struct drm_device *dev)* being false when they shouldn't be able to. */ drm_irq_uninstall (dev); -drm_irq_install (dev); +drm_irq_install (dev, dev->pdev->irq);/* rps/rc6 re-init is necessary to restore state lost after the * reset and the re-install of drm irq. Skip for ironlake per
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -4523,7 +4523,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,BUG_ON (!list_empty (&dev_priv->gtt.base.active_list)); - ret =drm_irq_install (dev); + ret =drm_irq_install (dev, dev->pdev->irq);if (ret) goto cleanup_ringbuffer;mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -288,7 +288,7 @@ static int msm_load(struct drm_device *dev, unsigned long flags) }pm_runtime_get_sync (dev->dev); - ret =drm_irq_install (dev); + ret =drm_irq_install (dev,platform_get_irq (dev->platformdev,0 ));pm_runtime_put_sync (dev->dev);if (ret <0 ) {dev_err (dev->dev,"failed to install IRQ handler\n" );
drivers/gpu/drm/qxl/qxl_irq.c +1 -1
@@ -87,7 +87,7 @@ int qxl_irq_init(struct qxl_device *qdev)atomic_set (&qdev->irq_received_cursor,0 );atomic_set (&qdev->irq_received_io_cmd,0 ); qdev->irq_received_error =0 ; - ret =drm_irq_install (qdev->ddev); + ret =drm_irq_install (qdev->ddev, qdev->ddev->pdev->irq); qdev->ram_header->int_mask =QXL_INTERRUPT_MASK ;if (unlikely (ret !=0 )) {DRM_ERROR ("Failed installing irq: %d\n" , ret);
drivers/gpu/drm/radeon/radeon_irq_kms.c +1 -1
@@ -287,7 +287,7 @@ int radeon_irq_kms_init(struct radeon_device *rdev)INIT_WORK (&rdev->reset_work, radeon_irq_reset_work_func); rdev->irq.installed = true; - r =drm_irq_install (rdev->ddev); + r =drm_irq_install (rdev->ddev, rdev->ddev->pdev->irq);if (r) { rdev->irq.installed = false;flush_work (&rdev->hotplug_work);
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -1
@@ -185,7 +185,7 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags) goto done; } - ret =drm_irq_install (dev); + ret =drm_irq_install (dev,platform_get_irq (dev->platformdev,0 ));if (ret <0 ) {dev_err (&pdev->dev,"failed to install IRQ handler\n" ); goto done;
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
@@ -268,7 +268,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags) }pm_runtime_get_sync (dev->dev); - ret =drm_irq_install (dev); + ret =drm_irq_install (dev,platform_get_irq (dev->platformdev,0 ));pm_runtime_put_sync (dev->dev);if (ret <0 ) {dev_err (dev->dev,"failed to install IRQ handler\n" );
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -1
@@ -806,7 +806,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) }if (dev_priv->capabilities &SVGA_CAP_IRQMASK ) { - ret =drm_irq_install (dev); + ret =drm_irq_install (dev, dev->pdev->irq);if (ret !=0 ) {DRM_ERROR ("Failed installing irq: %d\n" , ret); goto out_no_irq;
include/drm/drmP.h +1 -1
@@ -1353,7 +1353,7 @@ extern void drm_core_reclaim_buffers(struct drm_device *dev,/* IRQ support (drm_irq.h) */ extern int drm_control (struct drm_device *dev,void *data,struct drm_file *file_priv); -extern int drm_irq_install (struct drm_device *dev); +extern int drm_irq_install (struct drm_device *dev,int irq);extern int drm_irq_uninstall (struct drm_device *dev);extern int drm_vblank_init (struct drm_device *dev,int num_crtcs);
Signature · 1 line
1.8.5.2
Re: [PATCH 12/18] drm: pass the irq explicitly to drm_irq_install
Quoted 8 lines · Daniel Vetter
Unfortunately this requires a drm-wide change, and I didn't see a sane way around that. Luckily it's fairly simple, we just need to inline the respective
get_irqimplementation from eitherdrm_pci.cordrm_platform.c.With that we can now also remove
drm_dev_to_irqfromdrm_irq.c.Signed-off-by Daniel Vetter <[email protected]>
Quoted 16 lines
--- Documentation/DocBook/drm.tmpl | 10 +--------- drivers/gpu/drm/armada/armada_drv.c | 2 +- drivers/gpu/drm/drm_irq.c | 13 +++---------- drivers/gpu/drm/gma500/psb_drv.c | 2 +- drivers/gpu/drm/i915/i915_dma.c | 2 +- drivers/gpu/drm/i915/i915_drv.c | 4 ++-- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/msm/msm_drv.c | 2 +- drivers/gpu/drm/qxl/qxl_irq.c | 2 +- drivers/gpu/drm/radeon/radeon_irq_kms.c | 2 +- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +- include/drm/drmP.h | 2 +- 14 files changed, 17 insertions(+), 32 deletions(-)
Looks good to me:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 13/18 drm: remove bus->get_irq implementations
In reply to Daniel VetterNow that they're all unused we can get rid of them, including the dummy version in drm_usb.c.
--- drivers/gpu/drm/drm_pci.c | 6 ------ drivers/gpu/drm/drm_platform.c | 6 ------ drivers/gpu/drm/drm_usb.c | 6 ------ include/drm/drmP.h | 1 - 4 files changed, 19 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -6
@@ -137,11 +137,6 @@ static int drm_get_pci_domain(struct drm_device *dev)return pci_domain_nr (dev->pdev->bus); } -static int drm_pci_get_irq (struct drm_device *dev) -{ -return dev->pdev->irq; -} -static const char *drm_pci_get_name (struct drm_device *dev) {struct pci_driver *pdriver = dev->driver->kdriver.pci;
@@ -318,7 +313,6 @@ void drm_pci_agp_destroy(struct drm_device *dev) }static struct drm_bus drm_pci_bus = { - .get_irq = drm_pci_get_irq, .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, .set_unique = drm_pci_set_unique,
drivers/gpu/drm/drm_platform.c +0 -6
@@ -68,11 +68,6 @@ err_free:return ret; } -static int drm_platform_get_irq (struct drm_device *dev) -{ -return platform_get_irq (dev->platformdev,0 ); -} -static const char *drm_platform_get_name (struct drm_device *dev) {return dev->platformdev->name;
@@ -123,7 +118,6 @@ err: }static struct drm_bus drm_platform_bus = { - .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 -6
@@ -36,11 +36,6 @@ err_free: }EXPORT_SYMBOL (drm_get_usb_dev); -static int drm_usb_get_irq (struct drm_device *dev) -{ -return 0 ; -} -static const char *drm_usb_get_name (struct drm_device *dev) {return "USB" ;
@@ -53,7 +48,6 @@ static int drm_usb_set_busid(struct drm_device *dev, }static struct drm_bus drm_usb_bus = { - .get_irq = drm_usb_get_irq, .get_name = drm_usb_get_name, .set_busid = drm_usb_set_busid, };
include/drm/drmP.h +0 -1
@@ -726,7 +726,6 @@ struct drm_master {#define DRM_SCANOUTPOS_ACCURATE (1 << 2)struct drm_bus { -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); int (*set_unique)(struct drm_device *dev, struct drm_master *master,
Signature · 1 line
1.8.5.2
Re: [PATCH 13/18] drm: remove bus->get_irq implementations
Quoted 10 lines · Daniel Vetter
Now that they're all unused we can get rid of them, including the dummy version in
drm_usb.c.Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_pci.c | 6 ------ drivers/gpu/drm/drm_platform.c | 6 ------ drivers/gpu/drm/drm_usb.c | 6 ------ include/drm/drmP.h | 1 - 4 files changed, 19 deletions(-)
Nice!
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 14/18 drm: inline drm_pci_set_unique
In reply to Daniel VetterThis is only used for drm versions 1.0, and kms drivers have never been there. So we can appropriately restrict this to legacy and hence pci devices and inline everything.
v2: Make the dummy function actually return something, caught by Wu Fengguang's 0-day tester.
--- drivers/gpu/drm/drm_ioctl.c | 10 +++++++--- drivers/gpu/drm/drm_pci.c | 14 ++++++++++---- include/drm/drmP.h | 5 +++-- 3 files changed, 20 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_ioctl.c +7 -3
@@ -93,7 +93,8 @@ drm_unset_busid(struct drm_device *dev,* Copies the bus id from userspace into drm_device::unique, and verifies that * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated * in interface version 1.1 and will return EBUSY when setversion has requested -* version 1.1 or greater. +* version 1.1 or greater. Also note that KMS is all version 1.1 and later and +* UMS was only ever support on pci devices. */ int drm_setunique (struct drm_device *dev,void *data,struct drm_file *file_priv)
@@ -108,10 +109,13 @@ int drm_setunique(struct drm_device *dev, void *data,if (!u->unique_len || u->unique_len >1024 )return -EINVAL ; -if (!dev->driver->bus->set_unique) +if (drm_core_check_feature (dev,DRIVER_MODESET )) +return 0 ; + +if (WARN_ON (!dev->pdev))return -EINVAL ; - ret = dev->driver->bus->set_unique (dev, master, u); + ret =drm_pci_set_unique (dev, master, u);if (ret) goto err;
drivers/gpu/drm/drm_pci.c +10 -4
@@ -185,9 +185,9 @@ err:return ret; } -static int drm_pci_set_unique (struct drm_device *dev, -struct drm_master *master, -struct drm_unique *u) +int drm_pci_set_unique (struct drm_device *dev, +struct drm_master *master, +struct drm_unique *u) {int domain, bus, slot, func, ret;const char *bus_name;
@@ -315,7 +315,6 @@ void drm_pci_agp_destroy(struct drm_device *dev)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, };/**
@@ -482,6 +481,13 @@ int drm_irq_by_busid(struct drm_device *dev, void *data, {return -EINVAL ; } + +int drm_pci_set_unique (struct drm_device *dev, +struct drm_master *master, +struct drm_unique *u) +{ +return -EINVAL ; +}#endif EXPORT_SYMBOL (drm_pci_init);
include/drm/drmP.h +3 -2
@@ -728,8 +728,6 @@ struct drm_master {struct drm_bus {const char *(*get_name)(struct drm_device *dev);int (*set_busid)(struct drm_device *dev,struct drm_master *master); -int (*set_unique)(struct drm_device *dev,struct drm_master *master, -struct drm_unique *unique); };/**
@@ -1511,6 +1509,9 @@ extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, size_t align);extern void __drm_pci_free (struct drm_device *dev,drm_dma_handle_t * dmah);extern void drm_pci_free (struct drm_device *dev,drm_dma_handle_t * dmah); +extern int drm_pci_set_unique (struct drm_device *dev, +struct drm_master *master, +struct drm_unique *u);/* sysfs support (drm_sysfs.c) */ struct drm_sysfs_class ;
Signature · 1 line
1.8.5.2
Re: [PATCH 14/18] drm: inline drm_pci_set_unique
On Fri, Apr 11, 2014 at 11:36:11PM +0200, Daniel Vetter wrote:
[...]
drivers/gpu/drm/drm_ioctl.c drm_unset_busid(struct drm_device *dev, · line 97
Quoted 11 lines
drivers/gpu/drm/drm_ioctl.c +2
-1@@ -93,7 +93,8 @@ drm_unset_busid(struct drm_device *dev,* Copies the bus id from userspace into drm_device::unique, and verifies that * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated * in interface version 1.1 and will return EBUSY when setversion has requested -* version 1.1 or greater. +* version 1.1 or greater. Also note that KMS is all version 1.1 and later and +* UMS was only ever support on pci devices.
Nit: s/support on/supported on/, otherwise:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 15/18 drm: rip out dev->devname
In reply to Daniel VetterThis was only ever used to pretty-print the irq driver name. And on kms systems due to set_version bonghits we never set up the prettier name, ever. Which make this a bit pointless.
Also, we can always dig out the driver-instance/irq relationship through other means, so this isn't that useful. So just rip it out to simplify the set_version/set_busid insanity a bit.
Also delete the temporary busname from drm_pci_set_busid, it's now unused.
v2: Rebase on top of the new host1x drm_bus for tegra.
--- drivers/gpu/drm/drm_ioctl.c | 3 --- drivers/gpu/drm/drm_irq.c | 8 +------- drivers/gpu/drm/drm_pci.c | 25 ------------------------- drivers/gpu/drm/drm_platform.c | 11 ----------- drivers/gpu/drm/drm_stub.c | 5 ----- drivers/gpu/drm/tegra/bus.c | 10 ---------- include/drm/drmP.h | 1 - 7 files changed, 1 insertion(+), 62 deletions(-)
drivers/gpu/drm/drm_ioctl.c +0 -3
@@ -72,9 +72,6 @@ static void drm_unset_busid(struct drm_device *dev, struct drm_master *master) { - kfree(dev->devname); - dev->devname =NULL ; - kfree(master->unique); master->unique =NULL ; master->unique_len =0 ;
drivers/gpu/drm/drm_irq.c +1 -7
@@ -246,7 +246,6 @@ int drm_irq_install(struct drm_device *dev, int irq) {int ret;unsigned long sh_flags =0 ; -char *irqname;if (!drm_core_check_feature (dev,DRIVER_HAVE_IRQ ))return -EINVAL ;
@@ -272,13 +271,8 @@ int drm_irq_install(struct drm_device *dev, int irq)if (drm_core_check_feature (dev,DRIVER_IRQ_SHARED )) sh_flags =IRQF_SHARED ; -if (dev->devname) - irqname = dev->devname; -else - irqname = dev->driver->name; - ret =request_irq (dev->irq, dev->driver->irq_handler, - sh_flags, irqname, dev); + sh_flags, dev->driver->name, dev);if (ret <0 ) { dev->irq_enabled = false;
drivers/gpu/drm/drm_pci.c +0 -25
@@ -146,7 +146,6 @@ static const char *drm_pci_get_name(struct drm_device *dev)static 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 );
@@ -168,18 +167,6 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) }else master->unique_len = len; - dev->devname = -kmalloc (strlen (pdriver->name) + - master->unique_len +2 ,GFP_KERNEL ); - -if (dev->devname ==NULL ) { - ret = -ENOMEM ; - goto err; - } - -sprintf (dev->devname,"%s@%s" , pdriver->name, - master->unique); -return 0 ; err:return ret;
@@ -190,7 +177,6 @@ int drm_pci_set_unique(struct drm_device *dev, struct drm_unique *u) {int domain, bus, slot, func, ret; -const char *bus_name; master->unique_len = u->unique_len; master->unique_size = u->unique_len +1 ;
@@ -207,17 +193,6 @@ int drm_pci_set_unique(struct drm_device *dev, master->unique[master->unique_len] ='\0' ; - bus_name = dev->driver->bus->get_name (dev); - dev->devname =kmalloc (strlen (bus_name) + -strlen (master->unique) +2 ,GFP_KERNEL ); -if (!dev->devname) { - ret = -ENOMEM ; - goto err; - } - -sprintf (dev->devname,"%s@%s" , bus_name, - master->unique); -/* Return error if the busid submitted doesn't match the device's actual * busid. */
drivers/gpu/drm/drm_platform.c +0 -11
@@ -101,17 +101,6 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas goto err; } - dev->devname = -kmalloc (strlen (dev->platformdev->name) + - master->unique_len +2 ,GFP_KERNEL ); - -if (dev->devname ==NULL ) { - ret = -ENOMEM ; - goto err; - } - -sprintf (dev->devname,"%s@%s" , dev->platformdev->name, - master->unique);return 0 ; err:return ret;
drivers/gpu/drm/drm_stub.c +0 -5
@@ -166,9 +166,6 @@ static void drm_master_destroy(struct kref *kref) master->unique_len =0 ; } -kfree (dev->devname); - dev->devname =NULL ; -list_for_each_entry_safe (pt, next, &master->magicfree, head) {list_del (&pt->head);drm_ht_remove_item (&master->magiclist, &pt->hash_item);
@@ -648,8 +645,6 @@ static void drm_dev_release(struct kref *ref)drm_minor_free (dev,DRM_MINOR_RENDER );drm_minor_free (dev,DRM_MINOR_CONTROL ); -kfree (dev->devname); -mutex_destroy (&dev->master_mutex);kfree (dev); }
drivers/gpu/drm/tegra/bus.c +0 -10
@@ -12,9 +12,7 @@ static int drm_host1x_set_busid(struct drm_device *dev, struct drm_master *master) {const char *device =dev_name (dev->dev); -const char *driver = dev->driver->name;const char *bus = dev->dev->bus->name; -int length; master->unique_len =strlen (bus) +1 +strlen (device); master->unique_size = master->unique_len;
@@ -25,14 +23,6 @@ static int drm_host1x_set_busid(struct drm_device *dev,snprintf (master->unique, master->unique_len +1 ,"%s:%s" , bus, device); - length =strlen (driver) +1 + master->unique_len; - - dev->devname =kmalloc (length +1 ,GFP_KERNEL ); -if (!dev->devname) -return -ENOMEM ; - -snprintf (dev->devname, length +1 ,"%s@%s" , driver, master->unique); -return 0 ; }
include/drm/drmP.h +0 -1
@@ -1048,7 +1048,6 @@ struct drm_vblank_crtc {*/ struct drm_device {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 */ /** \name Lifetime Management */
Signature · 1 line
1.8.5.2
Re: [PATCH 15/18] drm: rip out dev->devname
Quoted 14 lines · Daniel Vetter
This was only ever used to pretty-print the irq driver name. And on kms systems due to
set_versionbonghits we never set up the prettier name, ever. Which make this a bit pointless.Also, we can always dig out the driver-instance/irq relationship through other means, so this isn't that useful. So just rip it out to simplify the set_version/set_busid insanity a bit.
Also delete the temporary busname from
drm_pci_set_busid, it's now unused.v2: Rebase on top of the new host1x
drm_busfor tegra.Signed-off-by Daniel Vetter <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/drm_ioctl.c | 3 --- drivers/gpu/drm/drm_irq.c | 8 +------- drivers/gpu/drm/drm_pci.c | 25 ------------------------- drivers/gpu/drm/drm_platform.c | 11 ----------- drivers/gpu/drm/drm_stub.c | 5 ----- drivers/gpu/drm/tegra/bus.c | 10 ---------- include/drm/drmP.h | 1 - 7 files changed, 1 insertion(+), 62 deletions(-)
Excellent!
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 16/18 drm: remove drm_bus->get_name
In reply to Daniel VetterThe only user is the info debugfs file, so we only need something human readable. Now for both pci and platform devices we've used the name of the underlying device driver, which matches the name of the drm driver in all cases. So we can just use that instead.
The exception is usb, which used a generic "USB". Not to harmful with just one usb driver, but better to use "udl", too.
With that converted we can rip out all the ->get_name implementations.
--- drivers/gpu/drm/drm_info.c | 6 ++---- drivers/gpu/drm/drm_pci.c | 7 ------- drivers/gpu/drm/drm_platform.c | 6 ------ drivers/gpu/drm/drm_usb.c | 6 ------ include/drm/drmP.h | 1 - 5 files changed, 2 insertions(+), 24 deletions(-)
drivers/gpu/drm/drm_info.c +2 -4
@@ -47,18 +47,16 @@ int drm_name_info(struct seq_file *m, void *data)struct drm_minor *minor = node->minor;struct drm_device *dev = minor->dev;struct drm_master *master = minor->master; -const char *bus_name;if (!master)return 0 ; - bus_name = dev->driver->bus->get_name (dev);if (master->unique) {seq_printf (m,"%s %s %s\n" , - bus_name, + dev->driver->name,dev_name (dev->dev), master->unique); }else {seq_printf (m,"%s %s\n" , - bus_name,dev_name (dev->dev)); + dev->driver->name,dev_name (dev->dev)); }return 0 ; }
drivers/gpu/drm/drm_pci.c +0 -7
@@ -137,12 +137,6 @@ static int drm_get_pci_domain(struct drm_device *dev)return pci_domain_nr (dev->pdev->bus); } -static const char *drm_pci_get_name (struct drm_device *dev) -{ -struct pci_driver *pdriver = dev->driver->kdriver.pci; -return pdriver->name; -} -static int drm_pci_set_busid (struct drm_device *dev,struct drm_master *master) {int len, ret;
@@ -288,7 +282,6 @@ void drm_pci_agp_destroy(struct drm_device *dev) }static struct drm_bus drm_pci_bus = { - .get_name = drm_pci_get_name, .set_busid = drm_pci_set_busid, };
drivers/gpu/drm/drm_platform.c +0 -6
@@ -68,11 +68,6 @@ err_free:return ret; } -static const char *drm_platform_get_name (struct drm_device *dev) -{ -return dev->platformdev->name; -} -static int drm_platform_set_busid (struct drm_device *dev,struct drm_master *master) {int len, ret, id;
@@ -107,7 +102,6 @@ err: }static struct drm_bus drm_platform_bus = { - .get_name = drm_platform_get_name, .set_busid = drm_platform_set_busid, };
drivers/gpu/drm/drm_usb.c +0 -6
@@ -36,11 +36,6 @@ err_free: }EXPORT_SYMBOL (drm_get_usb_dev); -static const char *drm_usb_get_name (struct drm_device *dev) -{ -return "USB" ; -} -static int drm_usb_set_busid (struct drm_device *dev,struct drm_master *master) {
@@ -48,7 +43,6 @@ static int drm_usb_set_busid(struct drm_device *dev, }static struct drm_bus drm_usb_bus = { - .get_name = drm_usb_get_name, .set_busid = drm_usb_set_busid, };
include/drm/drmP.h +0 -1
@@ -726,7 +726,6 @@ struct drm_master {#define DRM_SCANOUTPOS_ACCURATE (1 << 2)struct drm_bus { -const char *(*get_name)(struct drm_device *dev);int (*set_busid)(struct drm_device *dev,struct drm_master *master); };
Signature · 1 line
1.8.5.2
Re: [PATCH 16/18] drm: remove drm_bus->get_name
Quoted 10 lines · Daniel Vetter
The only user is the info debugfs file, so we only need something human readable. Now for both pci and platform devices we've used the name of the underlying device driver, which matches the name of the drm driver in all cases. So we can just use that instead.
The exception is usb, which used a generic "USB". Not to harmful with just one usb driver, but better to use "udl", too.
With that converted we can rip out all the ->get_name implementations.
Quoted 8 lines
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_info.c | 6 ++---- drivers/gpu/drm/drm_pci.c | 7 ------- drivers/gpu/drm/drm_platform.c | 6 ------ drivers/gpu/drm/drm_usb.c | 6 ------ include/drm/drmP.h | 1 - 5 files changed, 2 insertions(+), 24 deletions(-)
Happy to see it gone:
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 17/18 drm: Remove dev->kdriver
In reply to Daniel VetterWith the last patch to ditch the ->get_name callbacks the last user is now gone.
--- 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, 8 deletions(-)
drivers/gpu/drm/drm_pci.c +0 -1
@@ -365,7 +365,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)DRM_DEBUG ("\n" ); - driver->kdriver.pci = pdriver; driver->bus = &drm_pci_bus;if (driver->driver_features &DRIVER_MODESET )
drivers/gpu/drm/drm_platform.c +0 -1
@@ -121,7 +121,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;return drm_get_platform_dev (platform_device, driver); }
drivers/gpu/drm/drm_usb.c +0 -1
@@ -51,7 +51,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)int res;DRM_DEBUG ("\n" ); - driver->kdriver.usb = udriver; driver->bus = &drm_usb_bus; res =usb_register (udriver);
include/drm/drmP.h +0 -5
@@ -963,11 +963,6 @@ struct drm_driver {const 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 with stealth attach. */
Signature · 1 line
1.8.5.2
Re: [PATCH 17/18] drm: Remove dev->kdriver
Quoted 10 lines · Daniel Vetter
With the last patch to ditch the ->get_name callbacks the last user is now gone.
Signed-off-by Daniel Vetter <[email protected]>--- 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, 8 deletions(-)
More goodness... thank you.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 18/18 drm/<drivers>: don't set driver->dev_priv_size to 0
In reply to Daniel VetterEspecially not on modesetting drivers - this is used to size the driver private structure for legacy drm buffers.
--- drivers/gpu/drm/ast/ast_drv.c | 1 - drivers/gpu/drm/qxl/qxl_drv.c | 1 - drivers/gpu/drm/radeon/radeon_drv.c | 1 - 3 files changed, 3 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +0 -1
@@ -198,7 +198,6 @@ static const struct file_operations ast_fops = {static struct drm_driver driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM , - .dev_priv_size =0 , .load = ast_driver_load, .unload = ast_driver_unload,
drivers/gpu/drm/qxl/qxl_drv.c +0 -1
@@ -214,7 +214,6 @@ static struct pci_driver qxl_pci_driver = {static struct drm_driver qxl_driver = { .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED , - .dev_priv_size =0 , .load = qxl_driver_load, .unload = qxl_driver_unload,
drivers/gpu/drm/radeon/radeon_drv.c +0 -1
@@ -535,7 +535,6 @@ static struct drm_driver kms_driver = {DRIVER_USE_AGP |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED |DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER, - .dev_priv_size = 0, .load = radeon_driver_load_kms, .open = radeon_driver_open_kms, .preclose = radeon_driver_preclose_kms,
Signature · 1 line
1.8.5.2
Re: [PATCH 18/18] drm/<drivers>: don't set driver->dev_priv_size to 0
Quoted 2 lines · Daniel Vetter
Especially not on modesetting drivers - this is used to size the driver private structure for legacy drm buffers.
Besides being pointless anyway, since that's what it will be initialized by default...
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Daniel,
Quoted 13 lines · On Friday 11 April 2014 23:35:57 Daniel Vetter wrote:
Hi all,
I've chatted a bit with Thierry about how we could allow drivers to not even required a
drm_busany more. Which is relevant when e.g. due to the new master/component no platform device is conveniently around.So I've brushed off my old series to remove some
drm_busfunctions and other cruft and rebased it onto latest drm-next.It gets rid of everything but
drm_bus->set_busid, but Thierry has a good plan to make that one optional too - it's only really needed for backwards compat with some old libdrm versions on pci drm drivers.
Quoted 5 lines
Comments and review highly welcome.
Presuming no one screams I plan to send a pull request with these patches to Dave fairly early for 3.16 so that Thierry can base his tegra rework on top of it.
Apart from a few comments on patch 10/16, there's nothing I could complain about. Great work, as usual :-)
Signature · 3 lines
Regards, Laurent Pinchart
Hi
Quoted 13 lines · Daniel Vetter
Hi all,
I've chatted a bit with Thierry about how we could allow drivers to not even required a
drm_busany more. Which is relevant when e.g. due to the new master/component no platform device is conveniently around.So I've brushed off my old series to remove some
drm_busfunctions and other cruft and rebased it onto latest drm-next.It gets rid of everything but
drm_bus->set_busid, but Thierry has a good plan to make that one optional too - it's only really needed for backwards compat with some old libdrm versions on pci drm drivers.
Quoted 5 lines
Comments and review highly welcome.
Presuming no one screams I plan to send a pull request with these patches to Dave fairly early for 3.16 so that Thierry can base his tegra rework on top of it.
Apart from the irq patches, this looks all good. Thierry caught all the typos, so please go ahead and send a pull-request. No objections from me.
Thanks
David