All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/50] more drm de-midlayering
@ 2013-12-11 10:34 Daniel Vetter
  2013-12-11 10:34 ` [PATCH 01/50] drm/rcar: call drm_put_dev directly in the ->remove hook Daniel Vetter
                   ` (50 more replies)
  0 siblings, 51 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Hi all,

This series almost removes drm_bus, the last thing remaining is the ->setversion
callback. Unfortunately we can't kill that completely since we need the
backwards compat cruft for pci domain bonghits on alpha/ppc.

I've also shot at a few easy marks on the road while at it.

My plan is to tackle the setversion mess in 3.15 with a Gross Hack. And then
convert a few drivers to allocate struct drm_device themselves and so complete
the demidlayering in the driver load paths. For simplicity that'd probably be
udl or the arm drivers due to lack of legacy baggage. That should allow us to
ditch drm_usb.c and drm_platform.c from the tree.

My real long-term goal is to eventually use devres.c and similar cool stuff to
clean up the setup/teardown hell we have in i915.ko. Hence also why I've
deprecated the legacy agp/ums support in i915 in the hope that I'll get to deal
with less cruft. Also maybe we can sort out the lifetime issues around sysfs and
debugfs at driver/module unload time eventually ... just let me dream ;-)

Also a cleanup from Dan on top. All the little fixes for Wu Fengguang reported are
squashed in - he's now also doing some arm builds!

Dan Carpenter (1):
  drm: use memdup_user() as a cleanup

Daniel Vetter (49):
  drm/rcar: call drm_put_dev directly in the ->remove hook
  drm/exynos: call drm_put_dev directly from ->remove
  drm/imx: directly call drm_put_dev in ->remove
  drm/tilcdc: call drm_put_dev directly from ->remove
  drm/omap: call drm_put_dev directly in ->remove
  drm/shmob: call drm_put_dev directly from ->remove hook
  drm/armada: directly call drm_put_dev in ->remove
  drm/msm: call drm_put_dev directly in ->remove
  drm: rip out drm_platform_exit
  drm: restrict the device list for shadow attached drivers
  drm/bufs: remove handling of _DRM_GEM mappings
  drm: kill DRIVER_REQUIRE_AGP
  drm: ->agp_init can't fail
  drm: rip out drm_core_has_AGP
  drm: remove agp_init() bus callback
  drm: inline drm_agp_destroy
  drm: kill the ->agp_destroy callback
  drm: remove global_mutex locking around agp_init
  drm: rip out DRM_AGP_MEM and DRM_AGP_KERN
  drm: Kill DRM_HZ
  drm: Kill DRM_IRQ_ARGS
  drm: Kill DRM_WAKUP and DRM_INIT_WAITQUEUE
  drm: Kill DRM_COPY_(TO|FROM)_USER
  drm: Kill DRM_*MEMORYBARRIER
  drm: Kill DRM_SUSER
  drm/gma500: Remove dead code
  drm/irq: Replace DRM_WAIT_ON with wait_event
  drm: Remove DRM_WAIT_ON from all drivers
  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
  drm: store the gem vma offset manager in a typed pointer
  drm: rip out dev->ioctl_count tracking
  drm: Kill file_priv->ioctl_count tracking
  drm: remove dev->vma_count

 Documentation/DocBook/drm.tmpl           |  10 +--
 drivers/gpu/drm/armada/armada_drv.c      |   5 +-
 drivers/gpu/drm/ast/ast_drv.c            |   1 -
 drivers/gpu/drm/cirrus/cirrus_drv.h      |   2 +-
 drivers/gpu/drm/drm_agpsupport.c         |  28 ++-----
 drivers/gpu/drm/drm_buffer.c             |   2 +-
 drivers/gpu/drm/drm_bufs.c               |  42 +++++-----
 drivers/gpu/drm/drm_drv.c                |   4 -
 drivers/gpu/drm/drm_fops.c               |  11 +--
 drivers/gpu/drm/drm_gem.c                |  27 +++----
 drivers/gpu/drm/drm_info.c               |  22 +++---
 drivers/gpu/drm/drm_ioctl.c              |  13 +--
 drivers/gpu/drm/drm_irq.c                | 125 +++++++++++------------------
 drivers/gpu/drm/drm_memory.c             |  15 ++--
 drivers/gpu/drm/drm_pci.c                | 132 ++++++++++++++++---------------
 drivers/gpu/drm/drm_platform.c           |  37 ---------
 drivers/gpu/drm/drm_stub.c               |  25 +-----
 drivers/gpu/drm/drm_usb.c                |  15 ----
 drivers/gpu/drm/drm_vm.c                 |  10 +--
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |   4 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |   2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c    |   6 +-
 drivers/gpu/drm/gma500/accel_2d.c        |   2 +-
 drivers/gpu/drm/gma500/psb_drv.c         |   2 +-
 drivers/gpu/drm/gma500/psb_drv.h         |   8 +-
 drivers/gpu/drm/gma500/psb_intel_drv.h   |   5 --
 drivers/gpu/drm/gma500/psb_irq.c         |  19 +----
 drivers/gpu/drm/gma500/psb_irq.h         |   2 +-
 drivers/gpu/drm/i810/i810_dma.c          |   4 +
 drivers/gpu/drm/i810/i810_drv.c          |   2 +-
 drivers/gpu/drm/i915/i915_dma.c          |  31 ++++++--
 drivers/gpu/drm/i915/i915_drv.c          |  14 ++--
 drivers/gpu/drm/i915/i915_gem.c          |   7 +-
 drivers/gpu/drm/mga/mga_dma.c            |   4 +-
 drivers/gpu/drm/mga/mga_drv.h            |   4 +-
 drivers/gpu/drm/mga/mga_irq.c            |  18 +++--
 drivers/gpu/drm/mga/mga_state.c          |   4 +-
 drivers/gpu/drm/msm/msm_drv.c            |   8 +-
 drivers/gpu/drm/nouveau/nouveau_dma.c    |   2 +-
 drivers/gpu/drm/nouveau/nouveau_dma.h    |   2 +-
 drivers/gpu/drm/nouveau/nouveau_fence.c  |   2 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c    |   4 +-
 drivers/gpu/drm/nouveau/nouveau_vga.c    |   7 +-
 drivers/gpu/drm/omapdrm/omap_debugfs.c   |   2 +-
 drivers/gpu/drm/omapdrm/omap_drv.c       |   4 +-
 drivers/gpu/drm/omapdrm/omap_drv.h       |   2 +-
 drivers/gpu/drm/omapdrm/omap_irq.c       |   4 +-
 drivers/gpu/drm/qxl/qxl_drv.c            |   1 -
 drivers/gpu/drm/qxl/qxl_drv.h            |   2 +-
 drivers/gpu/drm/qxl/qxl_ioctl.c          |   4 +-
 drivers/gpu/drm/qxl/qxl_irq.c            |   4 +-
 drivers/gpu/drm/r128/r128_cce.c          |   4 +-
 drivers/gpu/drm/r128/r128_drv.h          |   4 +-
 drivers/gpu/drm/r128/r128_irq.c          |   2 +-
 drivers/gpu/drm/r128/r128_state.c        |  68 ++++++----------
 drivers/gpu/drm/radeon/r300_cmdbuf.c     |   8 +-
 drivers/gpu/drm/radeon/r600_cp.c         |   4 +-
 drivers/gpu/drm/radeon/r600_cs.c         |   2 +-
 drivers/gpu/drm/radeon/radeon_cp.c       |   6 +-
 drivers/gpu/drm/radeon/radeon_cs.c       |  10 +--
 drivers/gpu/drm/radeon/radeon_device.c   |   7 +-
 drivers/gpu/drm/radeon/radeon_drv.c      |   3 +-
 drivers/gpu/drm/radeon/radeon_drv.h      |   2 +-
 drivers/gpu/drm/radeon/radeon_irq.c      |  19 +++--
 drivers/gpu/drm/radeon/radeon_irq_kms.c  |   6 +-
 drivers/gpu/drm/radeon/radeon_kms.c      |  10 +--
 drivers/gpu/drm/radeon/radeon_mem.c      |   2 +-
 drivers/gpu/drm/radeon/radeon_ring.c     |   2 +-
 drivers/gpu/drm/radeon/radeon_state.c    |  20 ++---
 drivers/gpu/drm/radeon/radeon_ttm.c      |   2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |   4 +-
 drivers/gpu/drm/savage/savage_bci.c      |  10 +--
 drivers/gpu/drm/savage/savage_state.c    |   8 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |   6 +-
 drivers/gpu/drm/sis/sis_mm.c             |   2 +-
 drivers/gpu/drm/tegra/bus.c              |  12 ---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   8 +-
 drivers/gpu/drm/ttm/ttm_bo_util.c        |   2 +-
 drivers/gpu/drm/via/via_dma.c            |  12 +--
 drivers/gpu/drm/via/via_dmablit.c        |  39 +++++----
 drivers/gpu/drm/via/via_drv.h            |   2 +-
 drivers/gpu/drm/via/via_irq.c            |  21 +++--
 drivers/gpu/drm/via/via_video.c          |  18 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_irq.c      |   2 +-
 drivers/staging/imx-drm/imx-drm-core.c   |   4 +-
 include/drm/drmP.h                       |  60 ++++----------
 include/drm/drm_agpsupport.h             |  33 ++------
 include/drm/drm_os_linux.h               |  61 --------------
 include/uapi/drm/drm.h                   |   1 -
 91 files changed, 485 insertions(+), 717 deletions(-)

-- 
1.8.4.3

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [PATCH 01/50] drm/rcar: call drm_put_dev directly in the ->remove hook
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 02/50] drm/exynos: call drm_put_dev directly from ->remove Daniel Vetter
                   ` (49 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

The magic dance drm_platform_exit does is actually a remnant of the
old legacy shadow attach support for platform devices. Modern modesetting
drm drivers shouldn't do this any more (and usb/pci devices actually don't
do this).

Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 0023f9719cf1..4ec6272a1c11 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -224,7 +224,9 @@ static int rcar_du_probe(struct platform_device *pdev)
 
 static int rcar_du_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&rcar_du_driver, pdev);
+	struct rcar_du_device *rcdu = platform_get_drvdata(pdev);
+
+	drm_put_dev(rcdu->ddev);
 
 	return 0;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 02/50] drm/exynos: call drm_put_dev directly from ->remove
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
  2013-12-11 10:34 ` [PATCH 01/50] drm/rcar: call drm_put_dev directly in the ->remove hook Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 03/50] drm/imx: directly call drm_put_dev in ->remove Daniel Vetter
                   ` (48 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

I didn't find any user of the driver data yet, so store the
drm_device pointer in there.

Cc: Inki Dae <inki.dae@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index b676006a95a0..01d6cb1689fc 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -119,6 +119,8 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
 
 	drm_vblank_offdelay = VBLANK_OFF_DELAY;
 
+	platform_set_drvdata(dev->platformdev, dev);
+
 	return 0;
 
 err_drm_device:
@@ -296,7 +298,7 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
 
 static int exynos_drm_platform_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&exynos_drm_driver, pdev);
+	drm_put_dev(platform_get_drvdata(pdev));
 
 	return 0;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 03/50] drm/imx: directly call drm_put_dev in ->remove
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
  2013-12-11 10:34 ` [PATCH 01/50] drm/rcar: call drm_put_dev directly in the ->remove hook Daniel Vetter
  2013-12-11 10:34 ` [PATCH 02/50] drm/exynos: call drm_put_dev directly from ->remove Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 04/50] drm/tilcdc: call drm_put_dev directly from ->remove Daniel Vetter
                   ` (47 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Greg Kroah-Hartman

Again no apparent user of the driver data field.

Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/staging/imx-drm/imx-drm-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 51aa9772f959..dfd8a79032dd 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -443,6 +443,8 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
 	if (!imx_drm_device_get())
 		ret = -EINVAL;
 
+	platform_set_drvdata(drm->platformdev, drm);
+
 	ret = 0;
 
 err_init:
@@ -828,7 +830,7 @@ static int imx_drm_platform_probe(struct platform_device *pdev)
 
 static int imx_drm_platform_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&imx_drm_driver, pdev);
+	drm_put_dev(platform_get_drvdata(pdev));
 
 	return 0;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 04/50] drm/tilcdc: call drm_put_dev directly from ->remove
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (2 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 03/50] drm/imx: directly call drm_put_dev in ->remove Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 19:39   ` Rob Clark
  2013-12-11 10:34 ` [PATCH 05/50] drm/omap: call drm_put_dev directly in ->remove Daniel Vetter
                   ` (46 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

tilcdc already stores the drm_device in the driver data pointer. So
use that.

Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 116da199b942..e6d77d02e444 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -594,7 +594,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
 
 static int tilcdc_pdev_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&tilcdc_driver, pdev);
+	drm_put_dev(platform_get_drvdata(pdev));
 
 	return 0;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 05/50] drm/omap: call drm_put_dev directly in ->remove
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (3 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 04/50] drm/tilcdc: call drm_put_dev directly from ->remove Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 12:02   ` Rob Clark
  2013-12-11 10:34 ` [PATCH 06/50] drm/shmob: call drm_put_dev directly from ->remove hook Daniel Vetter
                   ` (45 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again omap already sets the driver data pointer to the drm_device.

Also drop the driver unregister call, that should be (and already is)
done in the module unload hook.

Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index e7fa3cd96743..13f294aeaefd 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -665,9 +665,9 @@ static int pdev_probe(struct platform_device *device)
 static int pdev_remove(struct platform_device *device)
 {
 	DBG("");
-	drm_platform_exit(&omap_drm_driver, device);
 
-	platform_driver_unregister(&omap_dmm_driver);
+	drm_put_dev(platform_get_drvdata(device));
+
 	return 0;
 }
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 06/50] drm/shmob: call drm_put_dev directly from ->remove hook
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (4 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 05/50] drm/omap: call drm_put_dev directly in ->remove Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 12:21   ` Laurent Pinchart
  2013-12-11 10:34 ` [PATCH 07/50] drm/armada: directly call drm_put_dev in ->remove Daniel Vetter
                   ` (44 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

We need to chase one pointer here.

Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 015551866b4a..c839c9c89efb 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -336,7 +336,9 @@ static int shmob_drm_probe(struct platform_device *pdev)
 
 static int shmob_drm_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&shmob_drm_driver, pdev);
+	struct shmob_drm_device *sdev = platform_get_drvdata(pdev);
+
+	drm_put_dev(sdev->ddev);
 
 	return 0;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 07/50] drm/armada: directly call drm_put_dev in ->remove
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (5 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 06/50] drm/shmob: call drm_put_dev directly from ->remove hook Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 08/50] drm/msm: call drm_put_dev directly " Daniel Vetter
                   ` (43 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Russell King

Again no apparent user of the driver data field.

Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/armada/armada_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 4f2b28354915..069f64533ac3 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -128,6 +128,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
 		return -ENOMEM;
 	}
 
+	platform_set_drvdata(dev->platformdev, dev);
 	dev->dev_private = priv;
 
 	/* Get the implementation specific driver data. */
@@ -376,7 +377,7 @@ static int armada_drm_probe(struct platform_device *pdev)
 
 static int armada_drm_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&armada_drm_driver, pdev);
+	drm_put_dev(platform_get_drvdata(pdev));
 	return 0;
 }
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 08/50] drm/msm: call drm_put_dev directly in ->remove
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (6 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 07/50] drm/armada: directly call drm_put_dev in ->remove Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 19:38   ` Rob Clark
  2013-12-11 10:34 ` [PATCH 09/50] drm: rip out drm_platform_exit Daniel Vetter
                   ` (42 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The drvdata pointer is already assigned to something useful.

Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 86537692e45c..aa5f3546bbec 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -783,7 +783,7 @@ static int msm_pdev_probe(struct platform_device *pdev)
 
 static int msm_pdev_remove(struct platform_device *pdev)
 {
-	drm_platform_exit(&msm_driver, pdev);
+	drm_put_dev(platform_get_drvdata(pdev));
 
 	return 0;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 09/50] drm: rip out drm_platform_exit
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (7 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 08/50] drm/msm: call drm_put_dev directly " Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 10/50] drm: restrict the device list for shadow attached drivers Daniel Vetter
                   ` (41 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This very much looks like a remnant of the old legady ums shadow
attach days. Now with the last users gone we can rip it out since
we won't ever support an ums drm driver again.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_platform.c | 11 -----------
 include/drm/drmP.h             |  1 -
 2 files changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index fc24fee8ec83..56a48033eced 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -151,14 +151,3 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor
 	return drm_get_platform_dev(platform_device, driver);
 }
 EXPORT_SYMBOL(drm_platform_init);
-
-void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device)
-{
-	struct drm_device *dev, *tmp;
-	DRM_DEBUG("\n");
-
-	list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
-		drm_put_dev(dev);
-	DRM_INFO("Module unloaded\n");
-}
-EXPORT_SYMBOL(drm_platform_exit);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1d4a920ef7ff..43f69bb2cff4 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1660,7 +1660,6 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
 
 /* platform section */
 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
-extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device);
 
 /* returns true if currently okay to sleep */
 static __inline__ bool drm_can_sleep(void)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 10/50] drm: restrict the device list for shadow attached drivers
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (8 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 09/50] drm: rip out drm_platform_exit Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 11/50] drm/bufs: remove handling of _DRM_GEM mappings Daniel Vetter
                   ` (40 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

There's really no need for the drm core to keep a list of all
devices of a given driver - the linux device model keeps perfect
track of this already for us.

The exception is old legacy ums drivers using pci shadow attaching.
So rename the lists to make the use case clearer and rip out everything
else.

v2: Rebase on top of David Herrmann's drm device register changes.
Also drop the bogus dev_set_drvdata for platform drivers that somehow
crept into the original version - drivers really should be in full
control of that field.

v3: Initialize driver->legacy_dev_list outside of the loop, spotted by
David Herrmann.

v4: Rebase on top of the newly created host1x drm_bus for tegra.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_pci.c      | 12 ++++++++++--
 drivers/gpu/drm/drm_platform.c |  1 -
 drivers/gpu/drm/drm_stub.c     |  4 ----
 drivers/gpu/drm/drm_usb.c      |  1 -
 drivers/gpu/drm/tegra/bus.c    |  1 -
 include/drm/drmP.h             |  6 +++---
 6 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 02679793c9e2..efadad850288 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -346,6 +346,11 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 		 driver->name, driver->major, driver->minor, driver->patchlevel,
 		 driver->date, pci_name(pdev), dev->primary->index);
 
+	/* No locking needed since shadow-attach is single-threaded since it may
+	 * only be called from the per-driver module init hook. */
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
+
 	return 0;
 
 err_pci:
@@ -375,7 +380,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 
 	DRM_DEBUG("\n");
 
-	INIT_LIST_HEAD(&driver->device_list);
 	driver->kdriver.pci = pdriver;
 	driver->bus = &drm_pci_bus;
 
@@ -383,6 +387,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 		return pci_register_driver(pdriver);
 
 	/* If not using KMS, fall back to stealth mode manual scanning. */
+	INIT_LIST_HEAD(&driver->legacy_dev_list);
 	for (i = 0; pdriver->id_table[i].vendor != 0; i++) {
 		pid = &pdriver->id_table[i];
 
@@ -465,8 +470,11 @@ void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
 	if (driver->driver_features & DRIVER_MODESET) {
 		pci_unregister_driver(pdriver);
 	} else {
-		list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
+		list_for_each_entry_safe(dev, tmp, &driver->legacy_dev_list,
+					 legacy_dev_list) {
 			drm_put_dev(dev);
+			list_del(&dev->legacy_dev_list);
+		}
 	}
 	DRM_INFO("Module unloaded\n");
 }
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 56a48033eced..21fc82006b78 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -147,7 +147,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor
 
 	driver->kdriver.platform_device = platform_device;
 	driver->bus = &drm_platform_bus;
-	INIT_LIST_HEAD(&driver->device_list);
 	return drm_get_platform_dev(platform_device, driver);
 }
 EXPORT_SYMBOL(drm_platform_init);
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index f53d5246979c..4c57da81c141 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -557,8 +557,6 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 			goto err_unload;
 	}
 
-	list_add_tail(&dev->driver_item, &dev->driver->device_list);
-
 	ret = 0;
 	goto out_unlock;
 
@@ -608,7 +606,5 @@ void drm_dev_unregister(struct drm_device *dev)
 	drm_unplug_minor(dev->control);
 	drm_unplug_minor(dev->render);
 	drm_unplug_minor(dev->primary);
-
-	list_del(&dev->driver_item);
 }
 EXPORT_SYMBOL(drm_dev_unregister);
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index b179b70e7853..21ae8d96880b 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -63,7 +63,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
 	int res;
 	DRM_DEBUG("\n");
 
-	INIT_LIST_HEAD(&driver->device_list);
 	driver->kdriver.usb = udriver;
 	driver->bus = &drm_usb_bus;
 
diff --git a/drivers/gpu/drm/tegra/bus.c b/drivers/gpu/drm/tegra/bus.c
index 565f8f7b9a47..e38e5967d77b 100644
--- a/drivers/gpu/drm/tegra/bus.c
+++ b/drivers/gpu/drm/tegra/bus.c
@@ -46,7 +46,6 @@ int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
 	struct drm_device *drm;
 	int ret;
 
-	INIT_LIST_HEAD(&driver->device_list);
 	driver->bus = &drm_host1x_bus;
 
 	drm = drm_dev_alloc(driver, &device->dev);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 43f69bb2cff4..8654a8b27fee 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -995,8 +995,8 @@ struct drm_driver {
 	} kdriver;
 	struct drm_bus *bus;
 
-	/* List of devices hanging off this driver */
-	struct list_head device_list;
+	/* List of devices hanging off this driver with stealth attach. */
+	struct list_head legacy_dev_list;
 };
 
 #define DRM_MINOR_UNASSIGNED 0
@@ -1085,7 +1085,7 @@ struct drm_vblank_crtc {
  * may contain multiple heads.
  */
 struct drm_device {
-	struct list_head driver_item;	/**< list of devices per driver */
+	struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
 	char *devname;			/**< For /proc/interrupts */
 	int if_version;			/**< Highest interface version set */
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 11/50] drm/bufs: remove handling of _DRM_GEM mappings
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (9 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 10/50] drm: restrict the device list for shadow attached drivers Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 12/50] drm: kill DRIVER_REQUIRE_AGP Daniel Vetter
                   ` (39 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Gone with the new gem vma offset manager from David.

We can also ditch the uapi header definition from the enum since
userspace never used this. It ended up in there purely for historical
reasons (for reusing the old drm mmap code essentially), not because
userspace ever needed it.

Cc: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_bufs.c | 6 ------
 drivers/gpu/drm/drm_vm.c   | 3 ---
 include/uapi/drm/drm.h     | 1 -
 3 files changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 471e051d295e..766a5474fdbd 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -303,9 +303,6 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 
 		break;
 	}
-	case _DRM_GEM:
-		DRM_ERROR("tried to addmap GEM object\n");
-		break;
 	case _DRM_SCATTER_GATHER:
 		if (!dev->sg) {
 			kfree(map);
@@ -483,9 +480,6 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
 		dmah.size = map->size;
 		__drm_pci_free(dev, &dmah);
 		break;
-	case _DRM_GEM:
-		DRM_ERROR("tried to rmmap GEM object\n");
-		break;
 	}
 	kfree(map);
 
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 93e95d7efd57..79873bb2923f 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -266,9 +266,6 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
 				dmah.size = map->size;
 				__drm_pci_free(dev, &dmah);
 				break;
-			case _DRM_GEM:
-				DRM_ERROR("tried to rmmap GEM object\n");
-				break;
 			}
 			kfree(map);
 		}
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 9b24d65fed72..3c9a833992e8 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -181,7 +181,6 @@ enum drm_map_type {
 	_DRM_AGP = 3,		  /**< AGP/GART */
 	_DRM_SCATTER_GATHER = 4,  /**< Scatter/gather memory for PCI DMA */
 	_DRM_CONSISTENT = 5,	  /**< Consistent memory for PCI DMA */
-	_DRM_GEM = 6,		  /**< GEM object (obsolete) */
 };
 
 /**
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 12/50] drm: kill DRIVER_REQUIRE_AGP
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (10 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 11/50] drm/bufs: remove handling of _DRM_GEM mappings Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 13/50] drm: ->agp_init can't fail Daniel Vetter
                   ` (38 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Only the two intel drivers need this and they can easily check for
working agp support in their driver ->load callbacks.

This is the only reason why agp initialization could fail, so allows
us to rip out a bit of error handling code in the next patch.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_pci.c       | 5 -----
 drivers/gpu/drm/i810/i810_dma.c | 4 ++++
 drivers/gpu/drm/i810/i810_drv.c | 2 +-
 drivers/gpu/drm/i915/i915_dma.c | 5 +++++
 drivers/gpu/drm/i915/i915_drv.c | 5 ++---
 include/drm/drmP.h              | 1 -
 6 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index efadad850288..c99c71b3d220 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -267,11 +267,6 @@ static int drm_pci_agp_init(struct drm_device *dev)
 	if (drm_core_has_AGP(dev)) {
 		if (drm_pci_device_is_agp(dev))
 			dev->agp = drm_agp_init(dev);
-		if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP)
-		    && (dev->agp == NULL)) {
-			DRM_ERROR("Cannot initialize the agpgart module.\n");
-			return -EINVAL;
-		}
 		if (dev->agp) {
 			dev->agp->agp_mtrr = arch_phys_wc_add(
 				dev->agp->agp_info.aper_base,
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 249fdff305c6..aeace37415aa 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -1193,6 +1193,10 @@ static int i810_flip_bufs(struct drm_device *dev, void *data,
 
 int i810_driver_load(struct drm_device *dev, unsigned long flags)
 {
+	/* Our userspace depends upon the agp mapping support. */
+	if (!dev->agp)
+		return -EINVAL;
+
 	pci_set_master(dev->pdev);
 
 	return 0;
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index d8180d22cedd..441ccf8f5bdc 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -57,7 +57,7 @@ static const struct file_operations i810_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
+	    DRIVER_USE_AGP |
 	    DRIVER_HAVE_DMA,
 	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
 	.load = i810_driver_load,
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 0cab2d045135..1244280946c2 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1476,7 +1476,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 		return -ENODEV;
 	}
 
+	/* UMS needs agp support. */
+	if (!drm_core_check_feature(dev, DRIVER_MODESET) && !dev->agp)
+		return -EINVAL;
+
 	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
+
 	if (dev_priv == NULL)
 		return -ENOMEM;
 
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 989be12cdd6e..06600ac18716 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -833,8 +833,7 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	 * (gasp!) to share buffers between X and the client. Hence we need to
 	 * keep around the fake agp stuff for gen3, even when kms is enabled. */
 	if (intel_info->gen != 3) {
-		driver.driver_features &=
-			~(DRIVER_USE_AGP | DRIVER_REQUIRE_AGP);
+		driver.driver_features &= ~DRIVER_USE_AGP;
 	} else if (!intel_agp_enabled) {
 		DRM_ERROR("drm/i915 can't work without intel_agp module!\n");
 		return -ENODEV;
@@ -946,7 +945,7 @@ static struct drm_driver driver = {
 	 * deal with them for Intel hardware.
 	 */
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
+	    DRIVER_USE_AGP |
 	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME |
 	    DRIVER_RENDER,
 	.load = i915_driver_load,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8654a8b27fee..e4eb653ac4cd 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -136,7 +136,6 @@ int drm_err(const char *func, const char *format, ...);
 
 /* driver capabilities and requirements mask */
 #define DRIVER_USE_AGP     0x1
-#define DRIVER_REQUIRE_AGP 0x2
 #define DRIVER_PCI_DMA     0x8
 #define DRIVER_SG          0x10
 #define DRIVER_HAVE_DMA    0x20
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 13/50] drm: ->agp_init can't fail
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (11 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 12/50] drm: kill DRIVER_REQUIRE_AGP Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 14/50] drm: rip out drm_core_has_AGP Daniel Vetter
                   ` (37 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Thanks to the removal of REQUIRE_AGP we can use a void return value
and shed a bit of complexity.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_pci.c  | 3 +--
 drivers/gpu/drm/drm_stub.c | 7 ++-----
 include/drm/drmP.h         | 2 +-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index c99c71b3d220..d3875e3f9d9c 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -262,7 +262,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
 	return 0;
 }
 
-static int drm_pci_agp_init(struct drm_device *dev)
+static void drm_pci_agp_init(struct drm_device *dev)
 {
 	if (drm_core_has_AGP(dev)) {
 		if (drm_pci_device_is_agp(dev))
@@ -274,7 +274,6 @@ static int drm_pci_agp_init(struct drm_device *dev)
 				1024 * 1024);
 		}
 	}
-	return 0;
 }
 
 static void drm_pci_agp_destroy(struct drm_device *dev)
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 4c57da81c141..085eb84a380c 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -521,11 +521,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 
 	mutex_lock(&drm_global_mutex);
 
-	if (dev->driver->bus->agp_init) {
-		ret = dev->driver->bus->agp_init(dev);
-		if (ret)
-			goto out_unlock;
-	}
+	if (dev->driver->bus->agp_init)
+		dev->driver->bus->agp_init(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e4eb653ac4cd..9b53031d04ed 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -750,7 +750,7 @@ struct drm_bus {
 			  struct drm_unique *unique);
 	int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
 	/* hooks that are for PCI */
-	int (*agp_init)(struct drm_device *dev);
+	void (*agp_init)(struct drm_device *dev);
 	void (*agp_destroy)(struct drm_device *dev);
 
 };
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 14/50] drm: rip out drm_core_has_AGP
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (12 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 13/50] drm: ->agp_init can't fail Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 15/50] drm: remove agp_init() bus callback Daniel Vetter
                   ` (36 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Most place actually want to just check for dev->agp (most do, but a
few don't so this fixes a few potential NULL derefs). The only
exception is the agp init code which should check for the AGP driver
feature flag.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_agpsupport.c    |  2 +-
 drivers/gpu/drm/drm_bufs.c          |  4 ++--
 drivers/gpu/drm/drm_memory.c        |  9 +++------
 drivers/gpu/drm/drm_pci.c           |  4 ++--
 drivers/gpu/drm/drm_vm.c            |  4 ++--
 drivers/gpu/drm/radeon/radeon_ttm.c |  2 +-
 include/drm/drm_agpsupport.h        | 12 ------------
 7 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index e301d653d97e..084a674e4b56 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -439,7 +439,7 @@ void drm_agp_clear(struct drm_device *dev)
 {
 	struct drm_agp_mem *entry, *tempe;
 
-	if (!drm_core_has_AGP(dev) || !dev->agp)
+	if (!dev->agp)
 		return;
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return;
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 766a5474fdbd..edec31fe3fed 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -261,7 +261,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 		struct drm_agp_mem *entry;
 		int valid = 0;
 
-		if (!drm_core_has_AGP(dev)) {
+		if (!dev->agp) {
 			kfree(map);
 			return -EINVAL;
 		}
@@ -1390,7 +1390,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	spin_unlock(&dev->count_lock);
 
 	if (request->count >= dma->buf_count) {
-		if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP))
+		if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP))
 		    || (drm_core_check_feature(dev, DRIVER_SG)
 			&& (dma->flags & _DRM_DMA_USE_SG))) {
 			struct drm_local_map *map = dev->agp_buffer_map;
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 64e44fad8ae8..3359bc453e11 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -110,8 +110,7 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
 
 void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
 {
-	if (drm_core_has_AGP(dev) &&
-	    dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
+	if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
 		map->handle = agp_remap(map->offset, map->size, dev);
 	else
 		map->handle = ioremap(map->offset, map->size);
@@ -120,8 +119,7 @@ EXPORT_SYMBOL(drm_core_ioremap);
 
 void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
 {
-	if (drm_core_has_AGP(dev) &&
-	    dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
+	if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
 		map->handle = agp_remap(map->offset, map->size, dev);
 	else
 		map->handle = ioremap_wc(map->offset, map->size);
@@ -133,8 +131,7 @@ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
 	if (!map->handle || !map->size)
 		return;
 
-	if (drm_core_has_AGP(dev) &&
-	    dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
+	if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
 		vunmap(map->handle);
 	else
 		iounmap(map->handle);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index d3875e3f9d9c..626e9cfd8aa5 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -264,7 +264,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
 
 static void drm_pci_agp_init(struct drm_device *dev)
 {
-	if (drm_core_has_AGP(dev)) {
+	if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
 		if (drm_pci_device_is_agp(dev))
 			dev->agp = drm_agp_init(dev);
 		if (dev->agp) {
@@ -278,7 +278,7 @@ static void drm_pci_agp_init(struct drm_device *dev)
 
 static void drm_pci_agp_destroy(struct drm_device *dev)
 {
-	if (drm_core_has_AGP(dev) && dev->agp) {
+	if (dev->agp) {
 		arch_phys_wc_del(dev->agp->agp_mtrr);
 		drm_agp_clear(dev);
 		drm_agp_destroy(dev->agp);
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 79873bb2923f..ef5540b6b451 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -101,7 +101,7 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	/*
 	 * Find the right map
 	 */
-	if (!drm_core_has_AGP(dev))
+	if (!dev->agp)
 		goto vm_fault_error;
 
 	if (!dev->agp || !dev->agp->cant_use_aperture)
@@ -592,7 +592,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
 	switch (map->type) {
 #if !defined(__arm__)
 	case _DRM_AGP:
-		if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
+		if (dev->agp && dev->agp->cant_use_aperture) {
 			/*
 			 * On some platforms we can't talk to bus dma address from the CPU, so for
 			 * memory of type DRM_AGP, we'll deal with sorting out the real physical
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 71245d6f34a2..051fa874065a 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -142,7 +142,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
 		man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
 #if __OS_HAS_AGP
 		if (rdev->flags & RADEON_IS_AGP) {
-			if (!(drm_core_has_AGP(rdev->ddev) && rdev->ddev->agp)) {
+			if (!rdev->ddev->agp) {
 				DRM_ERROR("AGP is not enabled for memory type %u\n",
 					  (unsigned)type);
 				return -EINVAL;
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index a184eeee9c96..a12b0e011e44 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -46,12 +46,6 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
 int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
-
-static inline int drm_core_has_AGP(struct drm_device *dev)
-{
-	return drm_core_check_feature(dev, DRIVER_USE_AGP);
-}
-
 #else /* __OS_HAS_AGP */
 
 static inline void drm_free_agp(DRM_AGP_MEM * handle, int pages)
@@ -183,12 +177,6 @@ static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
 {
 	return -ENODEV;
 }
-
-static inline int drm_core_has_AGP(struct drm_device *dev)
-{
-	return 0;
-}
-
 #endif /* __OS_HAS_AGP */
 
 #endif /* _DRM_AGPSUPPORT_H_ */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 15/50] drm: remove agp_init() bus callback
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (13 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 14/50] drm: rip out drm_core_has_AGP Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 16/50] drm: inline drm_agp_destroy Daniel Vetter
                   ` (35 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The PCI bus helper is the only user of it. Call it directly before
device-registration to get rid of the callback.

Note that all drm_agp_*() calls are locked with the drm-global-mutex so we
need to explicitly lock it during initialization. It's not really clear
why it's needed, but lets be safe.

v2: Rebase on top of the agp_init interface change.

v3: Remove the rebase-fail where I've accidentally killed the ->irq_by_busid
callback a bit too early.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com> (v1)
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_pci.c  | 12 +++++++++---
 drivers/gpu/drm/drm_stub.c |  8 +-------
 include/drm/drmP.h         |  1 -
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 626e9cfd8aa5..2211c4d70c2d 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -293,7 +293,6 @@ static struct drm_bus drm_pci_bus = {
 	.set_busid = drm_pci_set_busid,
 	.set_unique = drm_pci_set_unique,
 	.irq_by_busid = drm_pci_irq_by_busid,
-	.agp_init = drm_pci_agp_init,
 	.agp_destroy = drm_pci_agp_destroy,
 };
 
@@ -332,9 +331,13 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		pci_set_drvdata(pdev, dev);
 
+	mutex_lock(&drm_global_mutex);
+	drm_pci_agp_init(dev);
+	mutex_unlock(&drm_global_mutex);
+
 	ret = drm_dev_register(dev, ent->driver_data);
 	if (ret)
-		goto err_pci;
+		goto err_agp;
 
 	DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
 		 driver->name, driver->major, driver->minor, driver->patchlevel,
@@ -347,7 +350,10 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 
 	return 0;
 
-err_pci:
+err_agp:
+	mutex_lock(&drm_global_mutex);
+	drm_pci_agp_destroy(dev);
+	mutex_unlock(&drm_global_mutex);
 	pci_disable_device(pdev);
 err_free:
 	drm_dev_free(dev);
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 085eb84a380c..7fca4c6c9a30 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -521,13 +521,10 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 
 	mutex_lock(&drm_global_mutex);
 
-	if (dev->driver->bus->agp_init)
-		dev->driver->bus->agp_init(dev);
-
 	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
 		if (ret)
-			goto err_agp;
+			goto out_unlock;
 	}
 
 	if (drm_core_check_feature(dev, DRIVER_RENDER) && drm_rnodes) {
@@ -566,9 +563,6 @@ err_render_node:
 	drm_put_minor(dev->render);
 err_control_node:
 	drm_put_minor(dev->control);
-err_agp:
-	if (dev->driver->bus->agp_destroy)
-		dev->driver->bus->agp_destroy(dev);
 out_unlock:
 	mutex_unlock(&drm_global_mutex);
 	return ret;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 9b53031d04ed..097d93a6138d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -750,7 +750,6 @@ struct drm_bus {
 			  struct drm_unique *unique);
 	int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
 	/* hooks that are for PCI */
-	void (*agp_init)(struct drm_device *dev);
 	void (*agp_destroy)(struct drm_device *dev);
 
 };
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 16/50] drm: inline drm_agp_destroy
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (14 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 15/50] drm: remove agp_init() bus callback Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 17/50] drm: kill the ->agp_destroy callback Daniel Vetter
                   ` (34 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Wrapping a kfree is pointless.

v2: Add a comment to the kerneldoc for drm_agp_init to explain where
the kfree happens as requested by David. Note that for modeset drivers
agp cleanup is fairly complicated anyway: The drm_agp_clear is a noop
and drivers must call drm_agp_release on their own. Which they all
seem to do properly.

Cc: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_agpsupport.c | 18 +++---------------
 drivers/gpu/drm/drm_pci.c        |  2 +-
 include/drm/drm_agpsupport.h     |  5 -----
 3 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 084a674e4b56..1f544af43617 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -393,6 +393,9 @@ int drm_agp_free_ioctl(struct drm_device *dev, void *data,
  * Gets the drm_agp_t structure which is made available by the agpgart module
  * via the inter_module_* functions. Creates and initializes a drm_agp_head
  * structure.
+ *
+ * Note that final cleanup of the kmalloced structure is directly done in
+ * drm_pci_agp_destroy.
  */
 struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 {
@@ -460,21 +463,6 @@ void drm_agp_clear(struct drm_device *dev)
 }
 
 /**
- * drm_agp_destroy - Destroy AGP head
- * @dev: DRM device
- *
- * Destroy resources that were previously allocated via drm_agp_initp. Caller
- * must ensure to clean up all AGP resources before calling this. See
- * drm_agp_clear().
- *
- * Call this to destroy AGP heads allocated via drm_agp_init().
- */
-void drm_agp_destroy(struct drm_agp_head *agp)
-{
-	kfree(agp);
-}
-
-/**
  * Binds a collection of pages into AGP memory at the given offset, returning
  * the AGP memory structure containing them.
  *
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 2211c4d70c2d..f710e3d9d847 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -281,7 +281,7 @@ static void drm_pci_agp_destroy(struct drm_device *dev)
 	if (dev->agp) {
 		arch_phys_wc_del(dev->agp->agp_mtrr);
 		drm_agp_clear(dev);
-		drm_agp_destroy(dev->agp);
+		kfree(dev->agp);
 		dev->agp = NULL;
 	}
 }
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index a12b0e011e44..56a861b2ceaa 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -20,7 +20,6 @@ DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
 				uint32_t type);
 
 struct drm_agp_head *drm_agp_init(struct drm_device *dev);
-void drm_agp_destroy(struct drm_agp_head *agp);
 void drm_agp_clear(struct drm_device *dev);
 int drm_agp_acquire(struct drm_device *dev);
 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
@@ -76,10 +75,6 @@ static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 	return NULL;
 }
 
-static inline void drm_agp_destroy(struct drm_agp_head *agp)
-{
-}
-
 static inline void drm_agp_clear(struct drm_device *dev)
 {
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 17/50] drm: kill the ->agp_destroy callback
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (15 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 16/50] drm: inline drm_agp_destroy Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 18/50] drm: remove global_mutex locking around agp_init Daniel Vetter
                   ` (33 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Call drm_pci_agp_destroy directly, there's no point in the
indirection. Long term we want to shuffle this into each driver's
unload logic, but that needs cleared-up drm lifetime rules first.

v2: Add a dummy function for !CONFIG_PCI, spotted my David Herrmann.

v3: Fixup for the coding style police.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_pci.c  | 4 ++--
 drivers/gpu/drm/drm_stub.c | 4 ++--
 include/drm/drmP.h         | 4 +---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index f710e3d9d847..6dfae6b3c0bc 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -276,7 +276,7 @@ static void drm_pci_agp_init(struct drm_device *dev)
 	}
 }
 
-static void drm_pci_agp_destroy(struct drm_device *dev)
+void drm_pci_agp_destroy(struct drm_device *dev)
 {
 	if (dev->agp) {
 		arch_phys_wc_del(dev->agp->agp_mtrr);
@@ -293,7 +293,6 @@ static struct drm_bus drm_pci_bus = {
 	.set_busid = drm_pci_set_busid,
 	.set_unique = drm_pci_set_unique,
 	.irq_by_busid = drm_pci_irq_by_busid,
-	.agp_destroy = drm_pci_agp_destroy,
 };
 
 /**
@@ -457,6 +456,7 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 	return -1;
 }
 
+void drm_pci_agp_destroy(struct drm_device *dev) {}
 #endif
 
 EXPORT_SYMBOL(drm_pci_init);
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 7fca4c6c9a30..6299c197bd6f 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -586,8 +586,8 @@ void drm_dev_unregister(struct drm_device *dev)
 	if (dev->driver->unload)
 		dev->driver->unload(dev);
 
-	if (dev->driver->bus->agp_destroy)
-		dev->driver->bus->agp_destroy(dev);
+	if (dev->agp)
+		drm_pci_agp_destroy(dev);
 
 	drm_vblank_cleanup(dev);
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 097d93a6138d..9d4c318f292c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -749,9 +749,6 @@ struct drm_bus {
 	int (*set_unique)(struct drm_device *dev, struct drm_master *master,
 			  struct drm_unique *unique);
 	int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p);
-	/* hooks that are for PCI */
-	void (*agp_destroy)(struct drm_device *dev);
-
 };
 
 /**
@@ -1643,6 +1640,7 @@ static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
 
 	return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
 }
+void drm_pci_agp_destroy(struct drm_device *dev);
 
 extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
 extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 18/50] drm: remove global_mutex locking around agp_init
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (16 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 17/50] drm: kill the ->agp_destroy callback Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 19/50] drm: rip out DRM_AGP_MEM and DRM_AGP_KERN Daniel Vetter
                   ` (32 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

David Herrmann dutifully moved this locking along when moving the
agp_init call out of the generic drm_dev_register into the pci
specific load helpers.

But afaict there's no need and the reason for that locking has been
purely a historical accident - we need the lock around the driver dev
node registration to paper over the midlayer init races, and the agp
init simply ended up in there. The real fix for all this is of course
to delay the dev (and sysfs/debugfs) interface registration until
everything is fully set up.

Until then stop the cargo-cult locking from spreading and remove the
locking.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_pci.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 6dfae6b3c0bc..5736aaa7e86c 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -330,9 +330,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		pci_set_drvdata(pdev, dev);
 
-	mutex_lock(&drm_global_mutex);
 	drm_pci_agp_init(dev);
-	mutex_unlock(&drm_global_mutex);
 
 	ret = drm_dev_register(dev, ent->driver_data);
 	if (ret)
@@ -350,9 +348,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 	return 0;
 
 err_agp:
-	mutex_lock(&drm_global_mutex);
 	drm_pci_agp_destroy(dev);
-	mutex_unlock(&drm_global_mutex);
 	pci_disable_device(pdev);
 err_free:
 	drm_dev_free(dev);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 19/50] drm: rip out DRM_AGP_MEM and DRM_AGP_KERN
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (17 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 18/50] drm: remove global_mutex locking around agp_init Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 20/50] drm: Kill DRM_HZ Daniel Vetter
                   ` (31 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The <linux/agp_backend.h> header provides dummy functions and
fallbacks, so no need for screaming macros.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_agpsupport.c |  8 ++++----
 drivers/gpu/drm/drm_memory.c     |  6 +++---
 include/drm/drmP.h               |  5 +++--
 include/drm/drm_agpsupport.h     | 16 ++++++++--------
 include/drm/drm_os_linux.h       | 14 --------------
 5 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 1f544af43617..ddfc5e6e8812 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -53,7 +53,7 @@
  */
 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)
 {
-	DRM_AGP_KERN *kern;
+	struct agp_kern_info *kern;
 
 	if (!dev->agp || !dev->agp->acquired)
 		return -EINVAL;
@@ -198,7 +198,7 @@ int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
 {
 	struct drm_agp_mem *entry;
-	DRM_AGP_MEM *memory;
+	struct agp_memory *memory;
 	unsigned long pages;
 	u32 type;
 
@@ -469,14 +469,14 @@ void drm_agp_clear(struct drm_device *dev)
  * No reference is held on the pages during this time -- it is up to the
  * caller to handle that.
  */
-DRM_AGP_MEM *
+struct agp_memory *
 drm_agp_bind_pages(struct drm_device *dev,
 		   struct page **pages,
 		   unsigned long num_pages,
 		   uint32_t gtt_offset,
 		   u32 type)
 {
-	DRM_AGP_MEM *mem;
+	struct agp_memory *mem;
 	int ret, i;
 
 	DRM_DEBUG("\n");
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 3359bc453e11..00c67c0f2381 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -82,19 +82,19 @@ static void *agp_remap(unsigned long offset, unsigned long size,
 }
 
 /** Wrapper around agp_free_memory() */
-void drm_free_agp(DRM_AGP_MEM * handle, int pages)
+void drm_free_agp(struct agp_memory * handle, int pages)
 {
 	agp_free_memory(handle);
 }
 
 /** Wrapper around agp_bind_memory() */
-int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start)
+int drm_bind_agp(struct agp_memory * handle, unsigned int start)
 {
 	return agp_bind_memory(handle, start);
 }
 
 /** Wrapper around agp_unbind_memory() */
-int drm_unbind_agp(DRM_AGP_MEM * handle)
+int drm_unbind_agp(struct agp_memory * handle)
 {
 	return agp_unbind_memory(handle);
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 9d4c318f292c..a253b835f5a8 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -510,7 +510,7 @@ struct drm_device_dma {
  */
 struct drm_agp_mem {
 	unsigned long handle;		/**< handle */
-	DRM_AGP_MEM *memory;
+	struct agp_memory *memory;
 	unsigned long bound;		/**< address */
 	int pages;
 	struct list_head head;
@@ -522,7 +522,7 @@ struct drm_agp_mem {
  * \sa drm_agp_init() and drm_device::agp.
  */
 struct drm_agp_head {
-	DRM_AGP_KERN agp_info;		/**< AGP device information */
+	struct agp_kern_info agp_info;		/**< AGP device information */
 	struct list_head memory;
 	unsigned long mode;		/**< AGP mode */
 	struct agp_bridge_data *bridge;
@@ -1263,6 +1263,7 @@ extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
 				/* Memory management support (drm_memory.h) */
 #include <drm/drm_memory.h>
 
+
 				/* Misc. IOCTL support (drm_ioctl.h) */
 extern int drm_irq_by_busid(struct drm_device *dev, void *data,
 			    struct drm_file *file_priv);
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 56a861b2ceaa..86a02188074b 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -10,10 +10,10 @@
 
 #if __OS_HAS_AGP
 
-void drm_free_agp(DRM_AGP_MEM * handle, int pages);
-int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
-int drm_unbind_agp(DRM_AGP_MEM * handle);
-DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
+void drm_free_agp(struct agp_memory * handle, int pages);
+int drm_bind_agp(struct agp_memory * handle, unsigned int start);
+int drm_unbind_agp(struct agp_memory * handle);
+struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
 				struct page **pages,
 				unsigned long num_pages,
 				uint32_t gtt_offset,
@@ -47,21 +47,21 @@ int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 #else /* __OS_HAS_AGP */
 
-static inline void drm_free_agp(DRM_AGP_MEM * handle, int pages)
+static inline void drm_free_agp(struct agp_memory * handle, int pages)
 {
 }
 
-static inline int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start)
+static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
 {
 	return -ENODEV;
 }
 
-static inline int drm_unbind_agp(DRM_AGP_MEM * handle)
+static inline int drm_unbind_agp(struct agp_memory * handle)
 {
 	return -ENODEV;
 }
 
-static inline DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
+static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev,
 					      struct page **pages,
 					      unsigned long num_pages,
 					      uint32_t gtt_offset,
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index 815fafc6b4ad..fb90132b912e 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -51,20 +51,6 @@ static inline void writeq(u64 val, void __iomem *reg)
 /** IRQ handler arguments and return type and values */
 #define DRM_IRQ_ARGS		int irq, void *arg
 
-/** AGP types */
-#if __OS_HAS_AGP
-#define DRM_AGP_MEM		struct agp_memory
-#define DRM_AGP_KERN		struct agp_kern_info
-#else
-/* define some dummy types for non AGP supporting kernels */
-struct no_agp_kern {
-	unsigned long aper_base;
-	unsigned long aper_size;
-};
-#define DRM_AGP_MEM             int
-#define DRM_AGP_KERN            struct no_agp_kern
-#endif
-
 /** Other copying of data to kernel space */
 #define DRM_COPY_FROM_USER(arg1, arg2, arg3)		\
 	copy_from_user(arg1, arg2, arg3)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 20/50] drm: Kill DRM_HZ
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (18 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 19/50] drm: rip out DRM_AGP_MEM and DRM_AGP_KERN Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 21/50] drm: Kill DRM_IRQ_ARGS Daniel Vetter
                   ` (30 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

We don't have any userspace interfaces that use HZ as a time unit, so
having our own DRM define is useless.

Remove this remnant from the shared drm core days.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c               | 4 ++--
 drivers/gpu/drm/exynos/exynos_mixer.c   | 2 +-
 drivers/gpu/drm/gma500/accel_2d.c       | 2 +-
 drivers/gpu/drm/gma500/psb_drv.h        | 6 +++---
 drivers/gpu/drm/gma500/psb_irq.c        | 2 +-
 drivers/gpu/drm/i915/i915_dma.c         | 2 +-
 drivers/gpu/drm/mga/mga_irq.c           | 2 +-
 drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +-
 drivers/gpu/drm/radeon/radeon_irq.c     | 2 +-
 drivers/gpu/drm/sis/sis_mm.c            | 2 +-
 drivers/gpu/drm/via/via_dmablit.c       | 8 ++++----
 drivers/gpu/drm/via/via_irq.c           | 4 ++--
 drivers/gpu/drm/via/via_video.c         | 2 +-
 include/drm/drm_os_linux.h              | 2 --
 14 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 64c34d5876ff..b52ff052b785 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -960,7 +960,7 @@ void drm_vblank_put(struct drm_device *dev, int crtc)
 	if (atomic_dec_and_test(&dev->vblank[crtc].refcount) &&
 	    (drm_vblank_offdelay > 0))
 		mod_timer(&dev->vblank_disable_timer,
-			  jiffies + ((drm_vblank_offdelay * DRM_HZ)/1000));
+			  jiffies + ((drm_vblank_offdelay * HZ)/1000));
 }
 EXPORT_SYMBOL(drm_vblank_put);
 
@@ -1244,7 +1244,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
 	DRM_DEBUG("waiting on vblank count %d, crtc %d\n",
 		  vblwait->request.sequence, crtc);
 	dev->vblank[crtc].last_wait = vblwait->request.sequence;
-	DRM_WAIT_ON(ret, dev->vblank[crtc].queue, 3 * DRM_HZ,
+	DRM_WAIT_ON(ret, dev->vblank[crtc].queue, 3 * HZ,
 		    (((drm_vblank_count(dev, crtc) -
 		       vblwait->request.sequence) <= (1 << 23)) ||
 		     !dev->irq_enabled));
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 63bc5f92fbb3..1433300565e5 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -868,7 +868,7 @@ static void mixer_wait_for_vblank(void *ctx)
 	 */
 	if (!wait_event_timeout(mixer_ctx->wait_vsync_queue,
 				!atomic_read(&mixer_ctx->wait_vsync_event),
-				DRM_HZ/20))
+				HZ/20))
 		DRM_DEBUG_KMS("vblank wait timed out.\n");
 }
 
diff --git a/drivers/gpu/drm/gma500/accel_2d.c b/drivers/gpu/drm/gma500/accel_2d.c
index d5ef1a5793c8..de6f62a6ceb7 100644
--- a/drivers/gpu/drm/gma500/accel_2d.c
+++ b/drivers/gpu/drm/gma500/accel_2d.c
@@ -326,7 +326,7 @@ int psbfb_sync(struct fb_info *info)
 	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	struct drm_device *dev = psbfb->base.dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	unsigned long _end = jiffies + DRM_HZ;
+	unsigned long _end = jiffies + HZ;
 	int busy = 0;
 	unsigned long flags;
 
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index b59e6588c343..8d2a395edbd2 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -212,8 +212,8 @@ enum {
 #define PSB_HIGH_REG_OFFS 0x0600
 
 #define PSB_NUM_VBLANKS 2
-#define PSB_WATCHDOG_DELAY (DRM_HZ * 2)
-#define PSB_LID_DELAY (DRM_HZ / 10)
+#define PSB_WATCHDOG_DELAY (HZ * 2)
+#define PSB_LID_DELAY (HZ / 10)
 
 #define MDFLD_PNW_B0 0x04
 #define MDFLD_PNW_C0 0x08
@@ -232,7 +232,7 @@ enum {
 #define MDFLD_DSR_RR		45
 #define MDFLD_DPU_ENABLE 	(1 << 31)
 #define MDFLD_DSR_FULLSCREEN 	(1 << 30)
-#define MDFLD_DSR_DELAY		(DRM_HZ / MDFLD_DSR_RR)
+#define MDFLD_DSR_DELAY		(HZ / MDFLD_DSR_RR)
 
 #define PSB_PWR_STATE_ON		1
 #define PSB_PWR_STATE_OFF		2
diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index ba4830342d34..76224721177e 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -456,7 +456,7 @@ static int psb_vblank_do_wait(struct drm_device *dev,
 {
 	unsigned int cur_vblank;
 	int ret = 0;
-	DRM_WAIT_ON(ret, dev->vblank.queue, 3 * DRM_HZ,
+	DRM_WAIT_ON(ret, dev->vblank.queue, 3 * HZ,
 		    (((cur_vblank = atomic_read(counter))
 		      - *sequence) <= (1 << 23)));
 	*sequence = cur_vblank;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 1244280946c2..e8ebbd8ad83b 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -783,7 +783,7 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
 		master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
 
 	if (ring->irq_get(ring)) {
-		DRM_WAIT_ON(ret, ring->irq_queue, 3 * DRM_HZ,
+		DRM_WAIT_ON(ret, ring->irq_queue, 3 * HZ,
 			    READ_BREADCRUMB(dev_priv) >= irq_nr);
 		ring->irq_put(ring);
 	} else if (wait_for(READ_BREADCRUMB(dev_priv) >= irq_nr, 3000))
diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
index 2b0ceb8dc11b..8a92edb6bd61 100644
--- a/drivers/gpu/drm/mga/mga_irq.c
+++ b/drivers/gpu/drm/mga/mga_irq.c
@@ -128,7 +128,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
 	 * by about a day rather than she wants to wait for years
 	 * using fences.
 	 */
-	DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
+	DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
 		    (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
 		      - *sequence) <= (1 << 23)));
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 40cf52e6d6d2..90074d620e31 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -143,7 +143,7 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan)
 	int ret;
 
 	fence->channel  = chan;
-	fence->timeout  = jiffies + (15 * DRM_HZ);
+	fence->timeout  = jiffies + (15 * HZ);
 	fence->sequence = ++fctx->sequence;
 
 	ret = fctx->emit(fence);
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 8d68e972789a..0b69d6ab869d 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -249,7 +249,7 @@ static int radeon_wait_irq(struct drm_device * dev, int swi_nr)
 
 	dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE;
 
-	DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * DRM_HZ,
+	DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * HZ,
 		    RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr);
 
 	return ret;
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index 01857d836350..0573be0d2933 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -266,7 +266,7 @@ int sis_idle(struct drm_device *dev)
 	 * because its polling frequency is too low.
 	 */
 
-	end = jiffies + (DRM_HZ * 3);
+	end = jiffies + (HZ * 3);
 
 	for (i = 0; i < 4; ++i) {
 		do {
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index 8b0f25904e6d..9236ef1de270 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -363,7 +363,7 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
 
 		via_abort_dmablit(dev, engine);
 		blitq->aborting = 1;
-		blitq->end = jiffies + DRM_HZ;
+		blitq->end = jiffies + HZ;
 	}
 
 	if (!blitq->is_active) {
@@ -372,7 +372,7 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
 			blitq->is_active = 1;
 			blitq->cur = cur;
 			blitq->num_outstanding--;
-			blitq->end = jiffies + DRM_HZ;
+			blitq->end = jiffies + HZ;
 			if (!timer_pending(&blitq->poll_timer))
 				mod_timer(&blitq->poll_timer, jiffies + 1);
 		} else {
@@ -436,7 +436,7 @@ via_dmablit_sync(struct drm_device *dev, uint32_t handle, int engine)
 	int ret = 0;
 
 	if (via_dmablit_active(blitq, engine, handle, &queue)) {
-		DRM_WAIT_ON(ret, *queue, 3 * DRM_HZ,
+		DRM_WAIT_ON(ret, *queue, 3 * HZ,
 			    !via_dmablit_active(blitq, engine, handle, NULL));
 	}
 	DRM_DEBUG("DMA blit sync handle 0x%x engine %d returned %d\n",
@@ -688,7 +688,7 @@ via_dmablit_grab_slot(drm_via_blitq_t *blitq, int engine)
 	while (blitq->num_free == 0) {
 		spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
 
-		DRM_WAIT_ON(ret, blitq->busy_queue, DRM_HZ, blitq->num_free > 0);
+		DRM_WAIT_ON(ret, blitq->busy_queue, HZ, blitq->num_free > 0);
 		if (ret)
 			return (-EINTR == ret) ? -EAGAIN : ret;
 
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index ac98964297cf..d0e2b988d067 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -239,12 +239,12 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
 	cur_irq = dev_priv->via_irqs + real_irq;
 
 	if (masks[real_irq][2] && !force_sequence) {
-		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
+		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
 			    ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
 			     masks[irq][4]));
 		cur_irq_sequence = atomic_read(&cur_irq->irq_received);
 	} else {
-		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
+		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
 			    (((cur_irq_sequence =
 			       atomic_read(&cur_irq->irq_received)) -
 			      *sequence) <= (1 << 23)));
diff --git a/drivers/gpu/drm/via/via_video.c b/drivers/gpu/drm/via/via_video.c
index 6569efa2ff6e..f60cfb654428 100644
--- a/drivers/gpu/drm/via/via_video.c
+++ b/drivers/gpu/drm/via/via_video.c
@@ -83,7 +83,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_
 	switch (fx->func) {
 	case VIA_FUTEX_WAIT:
 		DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock],
-			    (fx->ms / 10) * (DRM_HZ / 100), *lock != fx->val);
+			    (fx->ms / 10) * (HZ / 100), *lock != fx->val);
 		return ret;
 	case VIA_FUTEX_WAKE:
 		DRM_WAKEUP(&(dev_priv->decoder_queue[fx->lock]));
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index fb90132b912e..42ce450420dd 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -58,8 +58,6 @@ static inline void writeq(u64 val, void __iomem *reg)
 #define DRM_COPY_TO_USER(arg1, arg2, arg3)		\
 	copy_to_user(arg1, arg2, arg3)
 
-#define DRM_HZ HZ
-
 #define DRM_WAIT_ON( ret, queue, timeout, condition )		\
 do {								\
 	DECLARE_WAITQUEUE(entry, current);			\
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 21/50] drm: Kill DRM_IRQ_ARGS
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (19 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 20/50] drm: Kill DRM_HZ Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 22/50] drm: Kill DRM_WAKUP and DRM_INIT_WAITQUEUE Daniel Vetter
                   ` (29 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

I've killed them a long time ago in drm/i915, let's get rid of this
remnant of shared drm core days for good.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/cirrus/cirrus_drv.h     | 2 +-
 drivers/gpu/drm/gma500/psb_drv.h        | 2 +-
 drivers/gpu/drm/gma500/psb_irq.c        | 2 +-
 drivers/gpu/drm/gma500/psb_irq.h        | 2 +-
 drivers/gpu/drm/mga/mga_drv.h           | 2 +-
 drivers/gpu/drm/mga/mga_irq.c           | 2 +-
 drivers/gpu/drm/msm/msm_drv.c           | 2 +-
 drivers/gpu/drm/omapdrm/omap_drv.h      | 2 +-
 drivers/gpu/drm/omapdrm/omap_irq.c      | 2 +-
 drivers/gpu/drm/qxl/qxl_drv.h           | 2 +-
 drivers/gpu/drm/qxl/qxl_irq.c           | 2 +-
 drivers/gpu/drm/r128/r128_drv.h         | 2 +-
 drivers/gpu/drm/r128/r128_irq.c         | 2 +-
 drivers/gpu/drm/radeon/radeon_drv.c     | 2 +-
 drivers/gpu/drm/radeon/radeon_drv.h     | 2 +-
 drivers/gpu/drm/radeon/radeon_irq.c     | 2 +-
 drivers/gpu/drm/radeon/radeon_irq_kms.c | 4 ++--
 drivers/gpu/drm/tilcdc/tilcdc_drv.c     | 2 +-
 drivers/gpu/drm/via/via_drv.h           | 2 +-
 drivers/gpu/drm/via/via_irq.c           | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h     | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_irq.c     | 2 +-
 include/drm/drmP.h                      | 2 +-
 include/drm/drm_os_linux.h              | 3 ---
 24 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h
index b6aded73838b..117d3eca5e37 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -222,7 +222,7 @@ void cirrus_fbdev_fini(struct cirrus_device *cdev);
 void cirrus_driver_irq_preinstall(struct drm_device *dev);
 int cirrus_driver_irq_postinstall(struct drm_device *dev);
 void cirrus_driver_irq_uninstall(struct drm_device *dev);
-irqreturn_t cirrus_driver_irq_handler(DRM_IRQ_ARGS);
+irqreturn_t cirrus_driver_irq_handler(int irq, void *arg);
 
 				/* cirrus_kms.c */
 int cirrus_driver_load(struct drm_device *dev, unsigned long flags);
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index 8d2a395edbd2..5ad6a03e477e 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -769,7 +769,7 @@ extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd,
  *psb_irq.c
  */
 
-extern irqreturn_t psb_irq_handler(DRM_IRQ_ARGS);
+extern irqreturn_t psb_irq_handler(int irq, void *arg);
 extern int psb_irq_enable_dpst(struct drm_device *dev);
 extern int psb_irq_disable_dpst(struct drm_device *dev);
 extern void psb_irq_preinstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index 76224721177e..ef00bce9991a 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -200,7 +200,7 @@ static void psb_vdc_interrupt(struct drm_device *dev, uint32_t vdc_stat)
 		mid_pipe_event_handler(dev, 1);
 }
 
-irqreturn_t psb_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t psb_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = arg;
 	struct drm_psb_private *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/gma500/psb_irq.h b/drivers/gpu/drm/gma500/psb_irq.h
index debb7f190c06..d0b45ffa1126 100644
--- a/drivers/gpu/drm/gma500/psb_irq.h
+++ b/drivers/gpu/drm/gma500/psb_irq.h
@@ -32,7 +32,7 @@ void sysirq_uninit(struct drm_device *dev);
 void psb_irq_preinstall(struct drm_device *dev);
 int  psb_irq_postinstall(struct drm_device *dev);
 void psb_irq_uninstall(struct drm_device *dev);
-irqreturn_t psb_irq_handler(DRM_IRQ_ARGS);
+irqreturn_t psb_irq_handler(int irq, void *arg);
 
 int psb_irq_enable_dpst(struct drm_device *dev);
 int psb_irq_disable_dpst(struct drm_device *dev);
diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
index ca4bc54ea214..901e4f935fed 100644
--- a/drivers/gpu/drm/mga/mga_drv.h
+++ b/drivers/gpu/drm/mga/mga_drv.h
@@ -186,7 +186,7 @@ extern void mga_disable_vblank(struct drm_device *dev, int crtc);
 extern u32 mga_get_vblank_counter(struct drm_device *dev, int crtc);
 extern int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence);
 extern int mga_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence);
-extern irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS);
+extern irqreturn_t mga_driver_irq_handler(int irq, void *arg);
 extern void mga_driver_irq_preinstall(struct drm_device *dev);
 extern int mga_driver_irq_postinstall(struct drm_device *dev);
 extern void mga_driver_irq_uninstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
index 8a92edb6bd61..14c0e3ca2b07 100644
--- a/drivers/gpu/drm/mga/mga_irq.c
+++ b/drivers/gpu/drm/mga/mga_irq.c
@@ -47,7 +47,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
 }
 
 
-irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t mga_driver_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index aa5f3546bbec..28b57eb6f9a1 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -326,7 +326,7 @@ static void msm_lastclose(struct drm_device *dev)
 	}
 }
 
-static irqreturn_t msm_irq(DRM_IRQ_ARGS)
+static irqreturn_t msm_irq(int irq, void *arg)
 {
 	struct drm_device *dev = arg;
 	struct msm_drm_private *priv = dev->dev_private;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 07847693cf49..c88fea32dbf6 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -141,7 +141,7 @@ int omap_gem_resume(struct device *dev);
 
 int omap_irq_enable_vblank(struct drm_device *dev, int crtc_id);
 void omap_irq_disable_vblank(struct drm_device *dev, int crtc_id);
-irqreturn_t omap_irq_handler(DRM_IRQ_ARGS);
+irqreturn_t omap_irq_handler(int irq, void *arg);
 void omap_irq_preinstall(struct drm_device *dev);
 int omap_irq_postinstall(struct drm_device *dev);
 void omap_irq_uninstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
index cb858600185f..615bea967337 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -173,7 +173,7 @@ void omap_irq_disable_vblank(struct drm_device *dev, int crtc_id)
 	dispc_runtime_put();
 }
 
-irqreturn_t omap_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t omap_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	struct omap_drm_private *priv = dev->dev_private;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 7bda32f68d3b..36ed40ba773f 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -534,7 +534,7 @@ void qxl_debugfs_takedown(struct drm_minor *minor);
 
 /* qxl_irq.c */
 int qxl_irq_init(struct qxl_device *qdev);
-irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS);
+irqreturn_t qxl_irq_handler(int irq, void *arg);
 
 /* qxl_fb.c */
 int qxl_fb_init(struct qxl_device *qdev);
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index 21393dc4700a..28f84b4fce32 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -25,7 +25,7 @@
 
 #include "qxl_drv.h"
 
-irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t qxl_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	struct qxl_device *qdev = (struct qxl_device *)dev->dev_private;
diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
index 56eb5e3f5439..4318bfa845cb 100644
--- a/drivers/gpu/drm/r128/r128_drv.h
+++ b/drivers/gpu/drm/r128/r128_drv.h
@@ -154,7 +154,7 @@ extern int r128_do_cleanup_cce(struct drm_device *dev);
 extern int r128_enable_vblank(struct drm_device *dev, int crtc);
 extern void r128_disable_vblank(struct drm_device *dev, int crtc);
 extern u32 r128_get_vblank_counter(struct drm_device *dev, int crtc);
-extern irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS);
+extern irqreturn_t r128_driver_irq_handler(int irq, void *arg);
 extern void r128_driver_irq_preinstall(struct drm_device *dev);
 extern int r128_driver_irq_postinstall(struct drm_device *dev);
 extern void r128_driver_irq_uninstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
index 2ea4f09d2691..c2ae496babb7 100644
--- a/drivers/gpu/drm/r128/r128_irq.c
+++ b/drivers/gpu/drm/r128/r128_irq.c
@@ -44,7 +44,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
 	return atomic_read(&dev_priv->vbl_received);
 }
 
-irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t r128_driver_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	drm_r128_private_t *dev_priv = (drm_r128_private_t *) dev->dev_private;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 9f5ff28864f6..f6f30b9e9ff5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -101,7 +101,7 @@ int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 void radeon_driver_irq_preinstall_kms(struct drm_device *dev);
 int radeon_driver_irq_postinstall_kms(struct drm_device *dev);
 void radeon_driver_irq_uninstall_kms(struct drm_device *dev);
-irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS);
+irqreturn_t radeon_driver_irq_handler_kms(int irq, void *arg);
 void radeon_gem_object_free(struct drm_gem_object *obj);
 int radeon_gem_object_open(struct drm_gem_object *obj,
 				struct drm_file *file_priv);
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 543dcfae7e6f..0049ac481ef5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -404,7 +404,7 @@ extern void radeon_do_release(struct drm_device * dev);
 extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
 extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
 extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
-extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
+extern irqreturn_t radeon_driver_irq_handler(int irq, void *arg);
 extern void radeon_driver_irq_preinstall(struct drm_device * dev);
 extern int radeon_driver_irq_postinstall(struct drm_device *dev);
 extern void radeon_driver_irq_uninstall(struct drm_device * dev);
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 0b69d6ab869d..22fa979163fd 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -181,7 +181,7 @@ static u32 radeon_acknowledge_irqs(drm_radeon_private_t *dev_priv, u32 *r500_dis
  * tied to dma at all, this is just a hangover from dri prehistory.
  */
 
-irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t radeon_driver_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	drm_radeon_private_t *dev_priv =
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index ec6240b00469..089c9ffb0aa9 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -39,13 +39,13 @@
 /**
  * radeon_driver_irq_handler_kms - irq handler for KMS
  *
- * @DRM_IRQ_ARGS: args
+ * @int irq, void *arg: args
  *
  * This is the irq handler for the radeon KMS driver (all asics).
  * radeon_irq_process is a macro that points to the per-asic
  * irq handler callback.
  */
-irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS)
+irqreturn_t radeon_driver_irq_handler_kms(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	struct radeon_device *rdev = dev->dev_private;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index e6d77d02e444..0c22b6ca7fd2 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -311,7 +311,7 @@ static void tilcdc_lastclose(struct drm_device *dev)
 	drm_fbdev_cma_restore_mode(priv->fbdev);
 }
 
-static irqreturn_t tilcdc_irq(DRM_IRQ_ARGS)
+static irqreturn_t tilcdc_irq(int irq, void *arg)
 {
 	struct drm_device *dev = arg;
 	struct tilcdc_drm_private *priv = dev->dev_private;
diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index a811ef2b505f..ad0273256beb 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -138,7 +138,7 @@ extern u32 via_get_vblank_counter(struct drm_device *dev, int crtc);
 extern int via_enable_vblank(struct drm_device *dev, int crtc);
 extern void via_disable_vblank(struct drm_device *dev, int crtc);
 
-extern irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS);
+extern irqreturn_t via_driver_irq_handler(int irq, void *arg);
 extern void via_driver_irq_preinstall(struct drm_device *dev);
 extern int via_driver_irq_postinstall(struct drm_device *dev);
 extern void via_driver_irq_uninstall(struct drm_device *dev);
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index d0e2b988d067..85a4cb955204 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -104,7 +104,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
 	return atomic_read(&dev_priv->vbl_received);
 }
 
-irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t via_driver_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *) arg;
 	drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index db85985c7086..1f89aad0ac02 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -700,7 +700,7 @@ extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
  * IRQs and wating - vmwgfx_irq.c
  */
 
-extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS);
+extern irqreturn_t vmw_irq_handler(int irq, void *arg);
 extern int vmw_wait_seqno(struct vmw_private *dev_priv, bool lazy,
 			     uint32_t seqno, bool interruptible,
 			     unsigned long timeout);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
index 4640adbcaf91..0c423766c441 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
@@ -30,7 +30,7 @@
 
 #define VMW_FENCE_WRAP (1 << 24)
 
-irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS)
+irqreturn_t vmw_irq_handler(int irq, void *arg)
 {
 	struct drm_device *dev = (struct drm_device *)arg;
 	struct vmw_private *dev_priv = vmw_priv(dev);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a253b835f5a8..472b08f11073 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -898,7 +898,7 @@ struct drm_driver {
 
 	/* these have to be filled in */
 
-	irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
+	irqreturn_t(*irq_handler) (int irq, void *arg);
 	void (*irq_preinstall) (struct drm_device *dev);
 	int (*irq_postinstall) (struct drm_device *dev);
 	void (*irq_uninstall) (struct drm_device *dev);
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index 42ce450420dd..2794cfeb4dfb 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -48,9 +48,6 @@ static inline void writeq(u64 val, void __iomem *reg)
 /** Read/write memory barrier */
 #define DRM_MEMORYBARRIER()		mb()
 
-/** IRQ handler arguments and return type and values */
-#define DRM_IRQ_ARGS		int irq, void *arg
-
 /** Other copying of data to kernel space */
 #define DRM_COPY_FROM_USER(arg1, arg2, arg3)		\
 	copy_from_user(arg1, arg2, arg3)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 22/50] drm: Kill DRM_WAKUP and DRM_INIT_WAITQUEUE
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (20 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 21/50] drm: Kill DRM_IRQ_ARGS Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 23/50] drm: Kill DRM_COPY_(TO|FROM)_USER Daniel Vetter
                   ` (28 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Less yelling ftw!

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c                |  6 +++---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |  2 +-
 drivers/gpu/drm/exynos/exynos_mixer.c    |  4 ++--
 drivers/gpu/drm/mga/mga_irq.c            |  4 ++--
 drivers/gpu/drm/omapdrm/omap_irq.c       |  2 +-
 drivers/gpu/drm/radeon/radeon_irq.c      |  4 ++--
 drivers/gpu/drm/via/via_dmablit.c        | 10 +++++-----
 drivers/gpu/drm/via/via_irq.c            |  4 ++--
 drivers/gpu/drm/via/via_video.c          |  6 +++---
 include/drm/drm_os_linux.h               |  3 ---
 10 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index b52ff052b785..e7de2da57234 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -368,7 +368,7 @@ int drm_irq_uninstall(struct drm_device *dev)
 	if (dev->num_crtcs) {
 		spin_lock_irqsave(&dev->vbl_lock, irqflags);
 		for (i = 0; i < dev->num_crtcs; i++) {
-			DRM_WAKEUP(&dev->vblank[i].queue);
+			wake_up(&dev->vblank[i].queue);
 			dev->vblank[i].enabled = false;
 			dev->vblank[i].last =
 				dev->driver->get_vblank_counter(dev, i);
@@ -980,7 +980,7 @@ void drm_vblank_off(struct drm_device *dev, int crtc)
 
 	spin_lock_irqsave(&dev->vbl_lock, irqflags);
 	vblank_disable_and_save(dev, crtc);
-	DRM_WAKEUP(&dev->vblank[crtc].queue);
+	wake_up(&dev->vblank[crtc].queue);
 
 	/* Send any queued vblank events, lest the natives grow disquiet */
 	seq = drm_vblank_count_and_time(dev, crtc, &now);
@@ -1363,7 +1363,7 @@ bool drm_handle_vblank(struct drm_device *dev, int crtc)
 			  crtc, (int) diff_ns);
 	}
 
-	DRM_WAKEUP(&dev->vblank[crtc].queue);
+	wake_up(&dev->vblank[crtc].queue);
 	drm_handle_vblank_events(dev, crtc);
 
 	spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 23da72b5eae9..b356f7eea53a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -954,7 +954,7 @@ static int fimd_probe(struct platform_device *pdev)
 	}
 
 	ctx->driver_data = drm_fimd_get_driver_data(pdev);
-	DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue);
+	init_waitqueue_head(&ctx->wait_vsync_queue);
 	atomic_set(&ctx->wait_vsync_event, 0);
 
 	subdrv = &ctx->subdrv;
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 1433300565e5..2dfa48c76f54 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -1019,7 +1019,7 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg)
 		/* set wait vsync event to zero and wake up queue. */
 		if (atomic_read(&ctx->wait_vsync_event)) {
 			atomic_set(&ctx->wait_vsync_event, 0);
-			DRM_WAKEUP(&ctx->wait_vsync_queue);
+			wake_up(&ctx->wait_vsync_queue);
 		}
 	}
 
@@ -1209,7 +1209,7 @@ static int mixer_probe(struct platform_device *pdev)
 	drm_hdmi_ctx->ctx = (void *)ctx;
 	ctx->vp_enabled = drv->is_vp_enabled;
 	ctx->mxr_ver = drv->version;
-	DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue);
+	init_waitqueue_head(&ctx->wait_vsync_queue);
 	atomic_set(&ctx->wait_vsync_event, 0);
 
 	platform_set_drvdata(pdev, drm_hdmi_ctx);
diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
index 14c0e3ca2b07..1b071b8ff9dc 100644
--- a/drivers/gpu/drm/mga/mga_irq.c
+++ b/drivers/gpu/drm/mga/mga_irq.c
@@ -79,7 +79,7 @@ irqreturn_t mga_driver_irq_handler(int irq, void *arg)
 			MGA_WRITE(MGA_PRIMEND, prim_end);
 
 		atomic_inc(&dev_priv->last_fence_retired);
-		DRM_WAKEUP(&dev_priv->fence_queue);
+		wake_up(&dev_priv->fence_queue);
 		handled = 1;
 	}
 
@@ -151,7 +151,7 @@ int mga_driver_irq_postinstall(struct drm_device *dev)
 {
 	drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
 
-	DRM_INIT_WAITQUEUE(&dev_priv->fence_queue);
+	init_waitqueue_head(&dev_priv->fence_queue);
 
 	/* Turn on soft trap interrupt.  Vertical blank interrupts are enabled
 	 * in mga_enable_vblank.
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c
index 615bea967337..0e5336e5a791 100644
--- a/drivers/gpu/drm/omapdrm/omap_irq.c
+++ b/drivers/gpu/drm/omapdrm/omap_irq.c
@@ -308,7 +308,7 @@ int omap_drm_irq_uninstall(struct drm_device *dev)
 	if (dev->num_crtcs) {
 		spin_lock_irqsave(&dev->vbl_lock, irqflags);
 		for (i = 0; i < dev->num_crtcs; i++) {
-			DRM_WAKEUP(&dev->vblank[i].queue);
+			wake_up(&dev->vblank[i].queue);
 			dev->vblank[i].enabled = false;
 			dev->vblank[i].last =
 				dev->driver->get_vblank_counter(dev, i);
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 22fa979163fd..ded2f0564b83 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -203,7 +203,7 @@ irqreturn_t radeon_driver_irq_handler(int irq, void *arg)
 
 	/* SW interrupt */
 	if (stat & RADEON_SW_INT_TEST)
-		DRM_WAKEUP(&dev_priv->swi_queue);
+		wake_up(&dev_priv->swi_queue);
 
 	/* VBLANK interrupt */
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
@@ -354,7 +354,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
 	    (drm_radeon_private_t *) dev->dev_private;
 
 	atomic_set(&dev_priv->swi_emitted, 0);
-	DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
+	init_waitqueue_head(&dev_priv->swi_queue);
 
 	dev->max_vblank_count = 0x001fffff;
 
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index 9236ef1de270..694b9954cbbc 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -338,7 +338,7 @@ via_dmablit_handler(struct drm_device *dev, int engine, int from_irq)
 
 		blitq->blits[cur]->aborted = blitq->aborting;
 		blitq->done_blit_handle++;
-		DRM_WAKEUP(blitq->blit_queue + cur);
+		wake_up(blitq->blit_queue + cur);
 
 		cur++;
 		if (cur >= VIA_NUM_BLIT_SLOTS)
@@ -521,7 +521,7 @@ via_dmablit_workqueue(struct work_struct *work)
 
 		spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
 
-		DRM_WAKEUP(&blitq->busy_queue);
+		wake_up(&blitq->busy_queue);
 
 		via_free_sg_info(dev->pdev, cur_sg);
 		kfree(cur_sg);
@@ -561,8 +561,8 @@ via_init_dmablit(struct drm_device *dev)
 		blitq->aborting = 0;
 		spin_lock_init(&blitq->blit_lock);
 		for (j = 0; j < VIA_NUM_BLIT_SLOTS; ++j)
-			DRM_INIT_WAITQUEUE(blitq->blit_queue + j);
-		DRM_INIT_WAITQUEUE(&blitq->busy_queue);
+			init_waitqueue_head(blitq->blit_queue + j);
+		init_waitqueue_head(&blitq->busy_queue);
 		INIT_WORK(&blitq->wq, via_dmablit_workqueue);
 		setup_timer(&blitq->poll_timer, via_dmablit_timer,
 				(unsigned long)blitq);
@@ -713,7 +713,7 @@ via_dmablit_release_slot(drm_via_blitq_t *blitq)
 	spin_lock_irqsave(&blitq->blit_lock, irqsave);
 	blitq->num_free++;
 	spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
-	DRM_WAKEUP(&blitq->busy_queue);
+	wake_up(&blitq->busy_queue);
 }
 
 /*
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index 85a4cb955204..1319433816d3 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -138,7 +138,7 @@ irqreturn_t via_driver_irq_handler(int irq, void *arg)
 	for (i = 0; i < dev_priv->num_irqs; ++i) {
 		if (status & cur_irq->pending_mask) {
 			atomic_inc(&cur_irq->irq_received);
-			DRM_WAKEUP(&cur_irq->irq_queue);
+			wake_up(&cur_irq->irq_queue);
 			handled = 1;
 			if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
 				via_dmablit_handler(dev, 0, 1);
@@ -287,7 +287,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
 			atomic_set(&cur_irq->irq_received, 0);
 			cur_irq->enable_mask = dev_priv->irq_masks[i][0];
 			cur_irq->pending_mask = dev_priv->irq_masks[i][1];
-			DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
+			init_waitqueue_head(&cur_irq->irq_queue);
 			dev_priv->irq_enable_mask |= cur_irq->enable_mask;
 			dev_priv->irq_pending_mask |= cur_irq->pending_mask;
 			cur_irq++;
diff --git a/drivers/gpu/drm/via/via_video.c b/drivers/gpu/drm/via/via_video.c
index f60cfb654428..a9ffbad1cfdd 100644
--- a/drivers/gpu/drm/via/via_video.c
+++ b/drivers/gpu/drm/via/via_video.c
@@ -36,7 +36,7 @@ void via_init_futex(drm_via_private_t *dev_priv)
 	DRM_DEBUG("\n");
 
 	for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
-		DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
+		init_waitqueue_head(&(dev_priv->decoder_queue[i]));
 		XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
 	}
 }
@@ -58,7 +58,7 @@ void via_release_futex(drm_via_private_t *dev_priv, int context)
 		if ((_DRM_LOCKING_CONTEXT(*lock) == context)) {
 			if (_DRM_LOCK_IS_HELD(*lock)
 			    && (*lock & _DRM_LOCK_CONT)) {
-				DRM_WAKEUP(&(dev_priv->decoder_queue[i]));
+				wake_up(&(dev_priv->decoder_queue[i]));
 			}
 			*lock = 0;
 		}
@@ -86,7 +86,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_
 			    (fx->ms / 10) * (HZ / 100), *lock != fx->val);
 		return ret;
 	case VIA_FUTEX_WAKE:
-		DRM_WAKEUP(&(dev_priv->decoder_queue[fx->lock]));
+		wake_up(&(dev_priv->decoder_queue[fx->lock]));
 		return 0;
 	}
 	return 0;
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index 2794cfeb4dfb..cf12233ef7ed 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -78,6 +78,3 @@ do {								\
 	__set_current_state(TASK_RUNNING);			\
 	remove_wait_queue(&(queue), &entry);			\
 } while (0)
-
-#define DRM_WAKEUP( queue ) wake_up( queue )
-#define DRM_INIT_WAITQUEUE( queue ) init_waitqueue_head( queue )
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 23/50] drm: Kill DRM_COPY_(TO|FROM)_USER
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (21 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 22/50] drm: Kill DRM_WAKUP and DRM_INIT_WAITQUEUE Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 24/50] drm: Kill DRM_*MEMORYBARRIER Daniel Vetter
                   ` (27 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Less yelling ftw!

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_buffer.c          |  2 +-
 drivers/gpu/drm/i915/i915_dma.c       |  6 +++---
 drivers/gpu/drm/mga/mga_dma.c         |  4 ++--
 drivers/gpu/drm/mga/mga_state.c       |  2 +-
 drivers/gpu/drm/nouveau/nouveau_gem.c |  4 ++--
 drivers/gpu/drm/qxl/qxl_ioctl.c       |  4 ++--
 drivers/gpu/drm/r128/r128_cce.c       |  4 ++--
 drivers/gpu/drm/r128/r128_state.c     | 28 ++++++++++++++--------------
 drivers/gpu/drm/radeon/r300_cmdbuf.c  |  8 ++++----
 drivers/gpu/drm/radeon/r600_cp.c      |  4 ++--
 drivers/gpu/drm/radeon/r600_cs.c      |  2 +-
 drivers/gpu/drm/radeon/radeon_cp.c    |  4 ++--
 drivers/gpu/drm/radeon/radeon_cs.c    | 10 +++++-----
 drivers/gpu/drm/radeon/radeon_irq.c   |  2 +-
 drivers/gpu/drm/radeon/radeon_kms.c   | 10 +++++-----
 drivers/gpu/drm/radeon/radeon_mem.c   |  2 +-
 drivers/gpu/drm/radeon/radeon_state.c | 18 +++++++++---------
 drivers/gpu/drm/savage/savage_bci.c   |  4 ++--
 drivers/gpu/drm/savage/savage_state.c |  6 +++---
 drivers/gpu/drm/via/via_dma.c         |  4 ++--
 include/drm/drm_os_linux.h            |  7 -------
 21 files changed, 64 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/drm_buffer.c b/drivers/gpu/drm/drm_buffer.c
index 39a718340319..0406110f83ed 100644
--- a/drivers/gpu/drm/drm_buffer.c
+++ b/drivers/gpu/drm/drm_buffer.c
@@ -114,7 +114,7 @@ int drm_buffer_copy_from_user(struct drm_buffer *buf,
 
 	for (idx = 0; idx < nr_pages; ++idx) {
 
-		if (DRM_COPY_FROM_USER(buf->data[idx],
+		if (copy_from_user(buf->data[idx],
 			user_data + idx * PAGE_SIZE,
 			min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
 			DRM_ERROR("Failed to copy user data (%p) to drm buffer"
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index e8ebbd8ad83b..be8d4720d961 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -820,7 +820,7 @@ static int i915_irq_emit(struct drm_device *dev, void *data,
 	result = i915_emit_irq(dev);
 	mutex_unlock(&dev->struct_mutex);
 
-	if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
+	if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
 		DRM_ERROR("copy_to_user\n");
 		return -EFAULT;
 	}
@@ -1008,8 +1008,8 @@ static int i915_getparam(struct drm_device *dev, void *data,
 		return -EINVAL;
 	}
 
-	if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
-		DRM_ERROR("DRM_COPY_TO_USER failed\n");
+	if (copy_to_user(param->value, &value, sizeof(int))) {
+		DRM_ERROR("copy_to_user failed\n");
 		return -EFAULT;
 	}
 
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index 087db33f6cff..c3bf059ba720 100644
--- a/drivers/gpu/drm/mga/mga_dma.c
+++ b/drivers/gpu/drm/mga/mga_dma.c
@@ -1075,10 +1075,10 @@ static int mga_dma_get_buffers(struct drm_device *dev,
 
 		buf->file_priv = file_priv;
 
-		if (DRM_COPY_TO_USER(&d->request_indices[i],
+		if (copy_to_user(&d->request_indices[i],
 				     &buf->idx, sizeof(buf->idx)))
 			return -EFAULT;
-		if (DRM_COPY_TO_USER(&d->request_sizes[i],
+		if (copy_to_user(&d->request_sizes[i],
 				     &buf->total, sizeof(buf->total)))
 			return -EFAULT;
 
diff --git a/drivers/gpu/drm/mga/mga_state.c b/drivers/gpu/drm/mga/mga_state.c
index 37cc2fb4eadd..314685b7f41f 100644
--- a/drivers/gpu/drm/mga/mga_state.c
+++ b/drivers/gpu/drm/mga/mga_state.c
@@ -1029,7 +1029,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil
 		return -EINVAL;
 	}
 
-	if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
+	if (copy_to_user(param->value, &value, sizeof(int))) {
 		DRM_ERROR("copy_to_user\n");
 		return -EFAULT;
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 78a27f8ad7d9..0447163cd2b4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -506,7 +506,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
 			b->presumed.valid = 0;
 			relocs++;
 
-			if (DRM_COPY_TO_USER(&upbbo[nvbo->pbbo_index].presumed,
+			if (copy_to_user(&upbbo[nvbo->pbbo_index].presumed,
 					     &b->presumed, sizeof(b->presumed)))
 				return -EFAULT;
 		}
@@ -593,7 +593,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
 	if (!mem)
 		return ERR_PTR(-ENOMEM);
 
-	if (DRM_COPY_FROM_USER(mem, userptr, size)) {
+	if (copy_from_user(mem, userptr, size)) {
 		u_free(mem);
 		return ERR_PTR(-EFAULT);
 	}
diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c
index 7b95c75e9626..0bb86e6d41b4 100644
--- a/drivers/gpu/drm/qxl/qxl_ioctl.c
+++ b/drivers/gpu/drm/qxl/qxl_ioctl.c
@@ -200,7 +200,7 @@ static int qxl_process_single_command(struct qxl_device *qdev,
 	for (i = 0; i < cmd->relocs_num; ++i) {
 		struct drm_qxl_reloc reloc;
 
-		if (DRM_COPY_FROM_USER(&reloc,
+		if (copy_from_user(&reloc,
 				       &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
 				       sizeof(reloc))) {
 			ret = -EFAULT;
@@ -297,7 +297,7 @@ static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
 		struct drm_qxl_command *commands =
 			(struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
 
-		if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num],
+		if (copy_from_user(&user_cmd, &commands[cmd_num],
 				       sizeof(user_cmd)))
 			return -EFAULT;
 
diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index c451257f08fb..59459fe4e8c5 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -892,10 +892,10 @@ static int r128_cce_get_buffers(struct drm_device *dev,
 
 		buf->file_priv = file_priv;
 
-		if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx,
+		if (copy_to_user(&d->request_indices[i], &buf->idx,
 				     sizeof(buf->idx)))
 			return -EFAULT;
-		if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total,
+		if (copy_to_user(&d->request_sizes[i], &buf->total,
 				     sizeof(buf->total)))
 			return -EFAULT;
 
diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
index 01dd9aef9f0e..818986b52e8c 100644
--- a/drivers/gpu/drm/r128/r128_state.c
+++ b/drivers/gpu/drm/r128/r128_state.c
@@ -895,16 +895,16 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
 	if (count > 4096 || count <= 0)
 		return -EMSGSIZE;
 
-	if (DRM_COPY_FROM_USER(&x, depth->x, sizeof(x)))
+	if (copy_from_user(&x, depth->x, sizeof(x)))
 		return -EFAULT;
-	if (DRM_COPY_FROM_USER(&y, depth->y, sizeof(y)))
+	if (copy_from_user(&y, depth->y, sizeof(y)))
 		return -EFAULT;
 
 	buffer_size = depth->n * sizeof(u32);
 	buffer = kmalloc(buffer_size, GFP_KERNEL);
 	if (buffer == NULL)
 		return -ENOMEM;
-	if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
+	if (copy_from_user(buffer, depth->buffer, buffer_size)) {
 		kfree(buffer);
 		return -EFAULT;
 	}
@@ -916,7 +916,7 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
 			kfree(buffer);
 			return -ENOMEM;
 		}
-		if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
+		if (copy_from_user(mask, depth->mask, mask_size)) {
 			kfree(buffer);
 			kfree(mask);
 			return -EFAULT;
@@ -999,12 +999,12 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
 		kfree(x);
 		return -ENOMEM;
 	}
-	if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
+	if (copy_from_user(x, depth->x, xbuf_size)) {
 		kfree(x);
 		kfree(y);
 		return -EFAULT;
 	}
-	if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) {
+	if (copy_from_user(y, depth->y, xbuf_size)) {
 		kfree(x);
 		kfree(y);
 		return -EFAULT;
@@ -1017,7 +1017,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
 		kfree(y);
 		return -ENOMEM;
 	}
-	if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
+	if (copy_from_user(buffer, depth->buffer, buffer_size)) {
 		kfree(x);
 		kfree(y);
 		kfree(buffer);
@@ -1033,7 +1033,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
 			kfree(buffer);
 			return -ENOMEM;
 		}
-		if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
+		if (copy_from_user(mask, depth->mask, mask_size)) {
 			kfree(x);
 			kfree(y);
 			kfree(buffer);
@@ -1107,9 +1107,9 @@ static int r128_cce_dispatch_read_span(struct drm_device *dev,
 	if (count > 4096 || count <= 0)
 		return -EMSGSIZE;
 
-	if (DRM_COPY_FROM_USER(&x, depth->x, sizeof(x)))
+	if (copy_from_user(&x, depth->x, sizeof(x)))
 		return -EFAULT;
-	if (DRM_COPY_FROM_USER(&y, depth->y, sizeof(y)))
+	if (copy_from_user(&y, depth->y, sizeof(y)))
 		return -EFAULT;
 
 	BEGIN_RING(7);
@@ -1162,12 +1162,12 @@ static int r128_cce_dispatch_read_pixels(struct drm_device *dev,
 		kfree(x);
 		return -ENOMEM;
 	}
-	if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
+	if (copy_from_user(x, depth->x, xbuf_size)) {
 		kfree(x);
 		kfree(y);
 		return -EFAULT;
 	}
-	if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) {
+	if (copy_from_user(y, depth->y, ybuf_size)) {
 		kfree(x);
 		kfree(y);
 		return -EFAULT;
@@ -1524,7 +1524,7 @@ static int r128_cce_stipple(struct drm_device *dev, void *data, struct drm_file
 
 	DEV_INIT_TEST_WITH_RETURN(dev_priv);
 
-	if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32)))
+	if (copy_from_user(&mask, stipple->mask, 32 * sizeof(u32)))
 		return -EFAULT;
 
 	RING_SPACE_TEST_WITH_RETURN(dev_priv);
@@ -1622,7 +1622,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fi
 		return -EINVAL;
 	}
 
-	if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
+	if (copy_to_user(param->value, &value, sizeof(int))) {
 		DRM_ERROR("copy_to_user\n");
 		return -EFAULT;
 	}
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
index 60170ea5e3a2..84b1d5367a11 100644
--- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
+++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
@@ -75,7 +75,7 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
 		OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1));
 
 		for (i = 0; i < nr; ++i) {
-			if (DRM_COPY_FROM_USER
+			if (copy_from_user
 			    (&box, &cmdbuf->boxes[n + i], sizeof(box))) {
 				DRM_ERROR("copy cliprect faulted\n");
 				return -EFAULT;
@@ -928,12 +928,12 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
 		buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0);
 		*buf_idx *= 2; /* 8 bytes per buf */
 
-		if (DRM_COPY_TO_USER(ref_age_base + *buf_idx,
+		if (copy_to_user(ref_age_base + *buf_idx,
 				&dev_priv->scratch_ages[header.scratch.reg],
 				sizeof(u32)))
 			return -EINVAL;
 
-		if (DRM_COPY_FROM_USER(&h_pending,
+		if (copy_from_user(&h_pending,
 				ref_age_base + *buf_idx + 1,
 				sizeof(u32)))
 			return -EINVAL;
@@ -943,7 +943,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
 
 		h_pending--;
 
-		if (DRM_COPY_TO_USER(ref_age_base + *buf_idx + 1,
+		if (copy_to_user(ref_age_base + *buf_idx + 1,
 					&h_pending,
 					sizeof(u32)))
 			return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index d8eb48bff0ed..8c9b7e26533c 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -2515,7 +2515,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev,
 		buf = radeon_freelist_get(dev);
 		if (!buf) {
 			DRM_DEBUG("EAGAIN\n");
-			if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image)))
+			if (copy_to_user(tex->image, image, sizeof(*image)))
 				return -EFAULT;
 			return -EAGAIN;
 		}
@@ -2528,7 +2528,7 @@ int r600_cp_dispatch_texture(struct drm_device *dev,
 		buffer =
 		    (u32 *) ((char *)dev->agp_buffer_map->handle + buf->offset);
 
-		if (DRM_COPY_FROM_USER(buffer, data, pass_size)) {
+		if (copy_from_user(buffer, data, pass_size)) {
 			DRM_ERROR("EFAULT on pad, %d bytes\n", pass_size);
 			return -EFAULT;
 		}
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index 5dceea6f71ae..d824f7fed47d 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -2386,7 +2386,7 @@ int r600_cs_legacy(struct drm_device *dev, void *data, struct drm_file *filp,
 	ib_chunk = &parser.chunks[parser.chunk_ib_idx];
 	parser.ib.length_dw = ib_chunk->length_dw;
 	*l = parser.ib.length_dw;
-	if (DRM_COPY_FROM_USER(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) {
+	if (copy_from_user(ib, ib_chunk->user_ptr, ib_chunk->length_dw * 4)) {
 		r = -EFAULT;
 		r600_cs_parser_fini(&parser, r);
 		return r;
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 3cae2bbc1854..d73013e6f58a 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -2020,10 +2020,10 @@ static int radeon_cp_get_buffers(struct drm_device *dev,
 
 		buf->file_priv = file_priv;
 
-		if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx,
+		if (copy_to_user(&d->request_indices[i], &buf->idx,
 				     sizeof(buf->idx)))
 			return -EFAULT;
-		if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total,
+		if (copy_to_user(&d->request_sizes[i], &buf->total,
 				     sizeof(buf->total)))
 			return -EFAULT;
 
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index f41594b2eeac..9f06a24f5ac8 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -192,7 +192,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
 		return -ENOMEM;
 	}
 	chunk_array_ptr = (uint64_t *)(unsigned long)(cs->chunks);
-	if (DRM_COPY_FROM_USER(p->chunks_array, chunk_array_ptr,
+	if (copy_from_user(p->chunks_array, chunk_array_ptr,
 			       sizeof(uint64_t)*cs->num_chunks)) {
 		return -EFAULT;
 	}
@@ -208,7 +208,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
 		uint32_t __user *cdata;
 
 		chunk_ptr = (void __user*)(unsigned long)p->chunks_array[i];
-		if (DRM_COPY_FROM_USER(&user_chunk, chunk_ptr,
+		if (copy_from_user(&user_chunk, chunk_ptr,
 				       sizeof(struct drm_radeon_cs_chunk))) {
 			return -EFAULT;
 		}
@@ -252,7 +252,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
 		if (p->chunks[i].kdata == NULL) {
 			return -ENOMEM;
 		}
-		if (DRM_COPY_FROM_USER(p->chunks[i].kdata, cdata, size)) {
+		if (copy_from_user(p->chunks[i].kdata, cdata, size)) {
 			return -EFAULT;
 		}
 		if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) {
@@ -472,7 +472,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser
 			}
 			parser->const_ib.is_const_ib = true;
 			parser->const_ib.length_dw = ib_chunk->length_dw;
-			if (DRM_COPY_FROM_USER(parser->const_ib.ptr,
+			if (copy_from_user(parser->const_ib.ptr,
 					       ib_chunk->user_ptr,
 					       ib_chunk->length_dw * 4))
 				return -EFAULT;
@@ -495,7 +495,7 @@ static int radeon_cs_ib_fill(struct radeon_device *rdev, struct radeon_cs_parser
 	parser->ib.length_dw = ib_chunk->length_dw;
 	if (ib_chunk->kdata)
 		memcpy(parser->ib.ptr, ib_chunk->kdata, ib_chunk->length_dw * 4);
-	else if (DRM_COPY_FROM_USER(parser->ib.ptr, ib_chunk->user_ptr, ib_chunk->length_dw * 4))
+	else if (copy_from_user(parser->ib.ptr, ib_chunk->user_ptr, ib_chunk->length_dw * 4))
 		return -EFAULT;
 	return 0;
 }
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index ded2f0564b83..244b19bab2e7 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -302,7 +302,7 @@ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_pr
 
 	result = radeon_emit_irq(dev);
 
-	if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
+	if (copy_to_user(emit->irq_seq, &result, sizeof(int))) {
 		DRM_ERROR("copy_to_user\n");
 		return -EFAULT;
 	}
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 55d0b474bd37..daa28b6a6832 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -223,7 +223,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 			*value = rdev->accel_working;
 		break;
 	case RADEON_INFO_CRTC_FROM_ID:
-		if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
+		if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
 			DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
 			return -EFAULT;
 		}
@@ -269,7 +269,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 		 *
 		 * When returning, the value is 1 if filp owns hyper-z access,
 		 * 0 otherwise. */
-		if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
+		if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
 			DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
 			return -EFAULT;
 		}
@@ -281,7 +281,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 		break;
 	case RADEON_INFO_WANT_CMASK:
 		/* The same logic as Hyper-Z. */
-		if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
+		if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
 			DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
 			return -EFAULT;
 		}
@@ -417,7 +417,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 		*value = rdev->fastfb_working;
 		break;
 	case RADEON_INFO_RING_WORKING:
-		if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
+		if (copy_from_user(value, value_ptr, sizeof(uint32_t))) {
 			DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
 			return -EFAULT;
 		}
@@ -465,7 +465,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 		DRM_DEBUG_KMS("Invalid request %d\n", info->request);
 		return -EINVAL;
 	}
-	if (DRM_COPY_TO_USER(value_ptr, (char*)value, value_size)) {
+	if (copy_to_user(value_ptr, (char*)value, value_size)) {
 		DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__);
 		return -EFAULT;
 	}
diff --git a/drivers/gpu/drm/radeon/radeon_mem.c b/drivers/gpu/drm/radeon/radeon_mem.c
index d54d2d7c9031..146d253f1131 100644
--- a/drivers/gpu/drm/radeon/radeon_mem.c
+++ b/drivers/gpu/drm/radeon/radeon_mem.c
@@ -243,7 +243,7 @@ int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_p
 	if (!block)
 		return -ENOMEM;
 
-	if (DRM_COPY_TO_USER(alloc->region_offset, &block->start,
+	if (copy_to_user(alloc->region_offset, &block->start,
 			     sizeof(int))) {
 		DRM_ERROR("copy_to_user\n");
 		return -EFAULT;
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 4d20910899d4..956ab7f14e16 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -1810,7 +1810,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
 		}
 		if (!buf) {
 			DRM_DEBUG("EAGAIN\n");
-			if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image)))
+			if (copy_to_user(tex->image, image, sizeof(*image)))
 				return -EFAULT;
 			return -EAGAIN;
 		}
@@ -1823,7 +1823,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
 
 #define RADEON_COPY_MT(_buf, _data, _width) \
 	do { \
-		if (DRM_COPY_FROM_USER(_buf, _data, (_width))) {\
+		if (copy_from_user(_buf, _data, (_width))) {\
 			DRM_ERROR("EFAULT on pad, %d bytes\n", (_width)); \
 			return -EFAULT; \
 		} \
@@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
 	if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
 		sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
 
-	if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
+	if (copy_from_user(&depth_boxes, clear->depth_boxes,
 			       sarea_priv->nbox * sizeof(depth_boxes[0])))
 		return -EFAULT;
 
@@ -2436,7 +2436,7 @@ static int radeon_cp_texture(struct drm_device *dev, void *data, struct drm_file
 		return -EINVAL;
 	}
 
-	if (DRM_COPY_FROM_USER(&image,
+	if (copy_from_user(&image,
 			       (drm_radeon_tex_image_t __user *) tex->image,
 			       sizeof(image)))
 		return -EFAULT;
@@ -2460,7 +2460,7 @@ static int radeon_cp_stipple(struct drm_device *dev, void *data, struct drm_file
 
 	LOCK_TEST_WITH_RETURN(dev, file_priv);
 
-	if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32)))
+	if (copy_from_user(&mask, stipple->mask, 32 * sizeof(u32)))
 		return -EFAULT;
 
 	RING_SPACE_TEST_WITH_RETURN(dev_priv);
@@ -2585,13 +2585,13 @@ static int radeon_cp_vertex2(struct drm_device *dev, void *data, struct drm_file
 		drm_radeon_prim_t prim;
 		drm_radeon_tcl_prim_t tclprim;
 
-		if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim)))
+		if (copy_from_user(&prim, &vertex->prim[i], sizeof(prim)))
 			return -EFAULT;
 
 		if (prim.stateidx != laststate) {
 			drm_radeon_state_t state;
 
-			if (DRM_COPY_FROM_USER(&state,
+			if (copy_from_user(&state,
 					       &vertex->state[prim.stateidx],
 					       sizeof(state)))
 				return -EFAULT;
@@ -2799,7 +2799,7 @@ static int radeon_emit_packet3_cliprect(struct drm_device *dev,
 
 	do {
 		if (i < cmdbuf->nbox) {
-			if (DRM_COPY_FROM_USER(&box, &boxes[i], sizeof(box)))
+			if (copy_from_user(&box, &boxes[i], sizeof(box)))
 				return -EFAULT;
 			/* FIXME The second and subsequent times round
 			 * this loop, send a WAIT_UNTIL_3D_IDLE before
@@ -3116,7 +3116,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
 		return -EINVAL;
 	}
 
-	if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) {
+	if (copy_to_user(param->value, &value, sizeof(int))) {
 		DRM_ERROR("copy_to_user\n");
 		return -EFAULT;
 	}
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index b17d0710871a..6e673fa968e5 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -990,10 +990,10 @@ static int savage_bci_get_buffers(struct drm_device *dev,
 
 		buf->file_priv = file_priv;
 
-		if (DRM_COPY_TO_USER(&d->request_indices[i],
+		if (copy_to_user(&d->request_indices[i],
 				     &buf->idx, sizeof(buf->idx)))
 			return -EFAULT;
-		if (DRM_COPY_TO_USER(&d->request_sizes[i],
+		if (copy_to_user(&d->request_sizes[i],
 				     &buf->total, sizeof(buf->total)))
 			return -EFAULT;
 
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index b35e75ed890c..2d3e56d94be3 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -992,7 +992,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 		if (kcmd_addr == NULL)
 			return -ENOMEM;
 
-		if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr,
+		if (copy_from_user(kcmd_addr, cmdbuf->cmd_addr,
 				       cmdbuf->size * 8))
 		{
 			kfree(kcmd_addr);
@@ -1007,7 +1007,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 			goto done;
 		}
 
-		if (DRM_COPY_FROM_USER(kvb_addr, cmdbuf->vb_addr,
+		if (copy_from_user(kvb_addr, cmdbuf->vb_addr,
 				       cmdbuf->vb_size)) {
 			ret = -EFAULT;
 			goto done;
@@ -1022,7 +1022,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 			goto done;
 		}
 
-		if (DRM_COPY_FROM_USER(kbox_addr, cmdbuf->box_addr,
+		if (copy_from_user(kbox_addr, cmdbuf->box_addr,
 				       cmdbuf->nbox * sizeof(struct drm_clip_rect))) {
 			ret = -EFAULT;
 			goto done;
diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 652f9b43ec9d..3436fdad22c5 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -273,7 +273,7 @@ static int via_dispatch_cmdbuffer(struct drm_device *dev, drm_via_cmdbuffer_t *c
 	if (cmd->size > VIA_PCI_BUF_SIZE)
 		return -ENOMEM;
 
-	if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size))
+	if (copy_from_user(dev_priv->pci_buf, cmd->buf, cmd->size))
 		return -EFAULT;
 
 	/*
@@ -346,7 +346,7 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device *dev,
 
 	if (cmd->size > VIA_PCI_BUF_SIZE)
 		return -ENOMEM;
-	if (DRM_COPY_FROM_USER(dev_priv->pci_buf, cmd->buf, cmd->size))
+	if (copy_from_user(dev_priv->pci_buf, cmd->buf, cmd->size))
 		return -EFAULT;
 
 	if ((ret =
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index cf12233ef7ed..2953b1d83022 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -48,13 +48,6 @@ static inline void writeq(u64 val, void __iomem *reg)
 /** Read/write memory barrier */
 #define DRM_MEMORYBARRIER()		mb()
 
-/** Other copying of data to kernel space */
-#define DRM_COPY_FROM_USER(arg1, arg2, arg3)		\
-	copy_from_user(arg1, arg2, arg3)
-/** Other copying of data from kernel space */
-#define DRM_COPY_TO_USER(arg1, arg2, arg3)		\
-	copy_to_user(arg1, arg2, arg3)
-
 #define DRM_WAIT_ON( ret, queue, timeout, condition )		\
 do {								\
 	DECLARE_WAITQUEUE(entry, current);			\
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 24/50] drm: Kill DRM_*MEMORYBARRIER
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (22 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 23/50] drm: Kill DRM_COPY_(TO|FROM)_USER Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 25/50] drm: Kill DRM_SUSER Daniel Vetter
                   ` (26 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The real linux interfaces are soooo much easier on the eyes ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/gma500/psb_irq.c      | 2 +-
 drivers/gpu/drm/mga/mga_drv.h         | 2 +-
 drivers/gpu/drm/nouveau/nouveau_dma.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_dma.h | 2 +-
 drivers/gpu/drm/r128/r128_drv.h       | 2 +-
 drivers/gpu/drm/radeon/radeon_cp.c    | 2 +-
 drivers/gpu/drm/radeon/radeon_ring.c  | 2 +-
 drivers/gpu/drm/savage/savage_bci.c   | 6 +++---
 drivers/gpu/drm/savage/savage_state.c | 2 +-
 drivers/gpu/drm/via/via_dma.c         | 4 ++--
 drivers/gpu/drm/via/via_dmablit.c     | 2 +-
 include/drm/drm_os_linux.h            | 7 -------
 12 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index ef00bce9991a..a9bb34704738 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -253,7 +253,7 @@ irqreturn_t psb_irq_handler(int irq, void *arg)
 
 	PSB_WVDC32(vdc_stat, PSB_INT_IDENTITY_R);
 	(void) PSB_RVDC32(PSB_INT_IDENTITY_R);
-	DRM_READMEMORYBARRIER();
+	rmb();
 
 	if (!handled)
 		return IRQ_NONE;
diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
index 901e4f935fed..fe453213600a 100644
--- a/drivers/gpu/drm/mga/mga_drv.h
+++ b/drivers/gpu/drm/mga/mga_drv.h
@@ -193,7 +193,7 @@ extern void mga_driver_irq_uninstall(struct drm_device *dev);
 extern long mga_compat_ioctl(struct file *filp, unsigned int cmd,
 			     unsigned long arg);
 
-#define mga_flush_write_combine()	DRM_WRITEMEMORYBARRIER()
+#define mga_flush_write_combine()	wmb()
 
 #define MGA_READ8(reg)		DRM_READ8(dev_priv->mmio, (reg))
 #define MGA_READ(reg)		DRM_READ32(dev_priv->mmio, (reg))
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index 40f91e1e5842..c177272152e2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -100,7 +100,7 @@ nv50_dma_push(struct nouveau_channel *chan, struct nouveau_bo *bo,
 
 	chan->dma.ib_put = (chan->dma.ib_put + 1) & chan->dma.ib_max;
 
-	DRM_MEMORYBARRIER();
+	mb();
 	/* Flush writes. */
 	nouveau_bo_rd32(pb, 0);
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.h b/drivers/gpu/drm/nouveau/nouveau_dma.h
index 984004d66a6d..dc0e0c5cadb4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.h
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.h
@@ -155,7 +155,7 @@ BEGIN_IMC0(struct nouveau_channel *chan, int subc, int mthd, u16 data)
 }
 
 #define WRITE_PUT(val) do {                                                    \
-	DRM_MEMORYBARRIER();                                                   \
+	mb();                                                   \
 	nouveau_bo_rd32(chan->push.buffer, 0);                                 \
 	nv_wo32(chan->object, chan->user_put, ((val) << 2) + chan->push.vma.offset);  \
 } while (0)
diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
index 4318bfa845cb..5bf3f5ff805d 100644
--- a/drivers/gpu/drm/r128/r128_drv.h
+++ b/drivers/gpu/drm/r128/r128_drv.h
@@ -514,7 +514,7 @@ do {									\
 	if (R128_VERBOSE)						\
 		DRM_INFO("COMMIT_RING() tail=0x%06x\n",			\
 			 dev_priv->ring.tail);				\
-	DRM_MEMORYBARRIER();						\
+	mb();						\
 	R128_WRITE(R128_PM4_BUFFER_DL_WPTR, dev_priv->ring.tail);	\
 	R128_READ(R128_PM4_BUFFER_DL_WPTR);				\
 } while (0)
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index d73013e6f58a..bb0d5c3a8311 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -2228,7 +2228,7 @@ void radeon_commit_ring(drm_radeon_private_t *dev_priv)
 
 	dev_priv->ring.tail &= dev_priv->ring.tail_mask;
 
-	DRM_MEMORYBARRIER();
+	mb();
 	GET_RING_HEAD( dev_priv );
 
 	if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) {
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 9214403ae173..ca2d71afeb02 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -463,7 +463,7 @@ void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *ring)
 	while (ring->wptr & ring->align_mask) {
 		radeon_ring_write(ring, ring->nop);
 	}
-	DRM_MEMORYBARRIER();
+	mb();
 	radeon_ring_set_wptr(rdev, ring);
 }
 
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index 6e673fa968e5..d2b2df9e26f3 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -49,7 +49,7 @@ savage_bci_wait_fifo_shadow(drm_savage_private_t * dev_priv, unsigned int n)
 #endif
 
 	for (i = 0; i < SAVAGE_DEFAULT_USEC_TIMEOUT; i++) {
-		DRM_MEMORYBARRIER();
+		mb();
 		status = dev_priv->status_ptr[0];
 		if ((status & mask) < threshold)
 			return 0;
@@ -123,7 +123,7 @@ savage_bci_wait_event_shadow(drm_savage_private_t * dev_priv, uint16_t e)
 	int i;
 
 	for (i = 0; i < SAVAGE_EVENT_USEC_TIMEOUT; i++) {
-		DRM_MEMORYBARRIER();
+		mb();
 		status = dev_priv->status_ptr[1];
 		if ((((status & 0xffff) - e) & 0xffff) <= 0x7fff ||
 		    (status & 0xffff) == 0)
@@ -449,7 +449,7 @@ static void savage_dma_flush(drm_savage_private_t * dev_priv)
 		}
 	}
 
-	DRM_MEMORYBARRIER();
+	mb();
 
 	/* do flush ... */
 	phys_addr = dev_priv->cmd_dma->offset +
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index 2d3e56d94be3..c01ad0aeaa58 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -1032,7 +1032,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 
 	/* Make sure writes to DMA buffers are finished before sending
 	 * DMA commands to the graphics hardware. */
-	DRM_MEMORYBARRIER();
+	mb();
 
 	/* Coming from user space. Don't know if the Xserver has
 	 * emitted wait commands. Assuming the worst. */
diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 3436fdad22c5..5d4179284964 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -60,7 +60,7 @@
 	dev_priv->dma_low += 8;					\
 }
 
-#define via_flush_write_combine() DRM_MEMORYBARRIER()
+#define via_flush_write_combine() mb()
 
 #define VIA_OUT_RING_QW(w1, w2)	do {		\
 	*vb++ = (w1);				\
@@ -543,7 +543,7 @@ static void via_cmdbuf_start(drm_via_private_t *dev_priv)
 
 	VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_hi);
 	VIA_WRITE(VIA_REG_TRANSPACE, pause_addr_lo);
-	DRM_WRITEMEMORYBARRIER();
+	wmb();
 	VIA_WRITE(VIA_REG_TRANSPACE, command | HC_HAGPCMNT_MASK);
 	VIA_READ(VIA_REG_TRANSPACE);
 
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index 694b9954cbbc..ba33cf679180 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -217,7 +217,7 @@ via_fire_dmablit(struct drm_device *dev, drm_via_sg_info_t *vsg, int engine)
 	VIA_WRITE(VIA_PCI_DMA_MR0  + engine*0x04, VIA_DMA_MR_CM | VIA_DMA_MR_TDIE);
 	VIA_WRITE(VIA_PCI_DMA_BCR0 + engine*0x10, 0);
 	VIA_WRITE(VIA_PCI_DMA_DPR0 + engine*0x10, vsg->chain_start);
-	DRM_WRITEMEMORYBARRIER();
+	wmb();
 	VIA_WRITE(VIA_PCI_DMA_CSR0 + engine*0x04, VIA_DMA_CSR_DE | VIA_DMA_CSR_TS);
 	VIA_READ(VIA_PCI_DMA_CSR0 + engine*0x04);
 }
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index 2953b1d83022..43008938b6b2 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -35,19 +35,12 @@ static inline void writeq(u64 val, void __iomem *reg)
 #define DRM_WRITE16(map, offset, val)   writew(val, ((void __iomem *)(map)->handle) + (offset))
 /** Write a dword into a MMIO region */
 #define DRM_WRITE32(map, offset, val)	writel(val, ((void __iomem *)(map)->handle) + (offset))
-/** Read memory barrier */
 
 /** Read a qword from a MMIO region - be careful using these unless you really understand them */
 #define DRM_READ64(map, offset)		readq(((void __iomem *)(map)->handle) + (offset))
 /** Write a qword into a MMIO region */
 #define DRM_WRITE64(map, offset, val)	writeq(val, ((void __iomem *)(map)->handle) + (offset))
 
-#define DRM_READMEMORYBARRIER()		rmb()
-/** Write memory barrier */
-#define DRM_WRITEMEMORYBARRIER()	wmb()
-/** Read/write memory barrier */
-#define DRM_MEMORYBARRIER()		mb()
-
 #define DRM_WAIT_ON( ret, queue, timeout, condition )		\
 do {								\
 	DECLARE_WAITQUEUE(entry, current);			\
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 25/50] drm: Kill DRM_SUSER
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (23 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 24/50] drm: Kill DRM_*MEMORYBARRIER Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 26/50] drm/gma500: Remove dead code Daniel Vetter
                   ` (25 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Checking directly for the right capability is simpler. Also this rids
us of a few places that use DRM_CURRENTPID.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
 drivers/gpu/drm/via/via_dma.c     | 4 ++--
 include/drm/drm_os_linux.h        | 1 -
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 15b86a94949d..99aab8639089 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -593,7 +593,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo,
 	if (start_page > bo->num_pages)
 		return -EINVAL;
 #if 0
-	if (num_pages > 1 && !DRM_SUSER(DRM_CURPROC))
+	if (num_pages > 1 && !capable(CAP_SYS_ADMIN))
 		return -EPERM;
 #endif
 	(void) ttm_mem_io_lock(man, false);
diff --git a/drivers/gpu/drm/via/via_dma.c b/drivers/gpu/drm/via/via_dma.c
index 5d4179284964..a18479c6b6da 100644
--- a/drivers/gpu/drm/via/via_dma.c
+++ b/drivers/gpu/drm/via/via_dma.c
@@ -234,13 +234,13 @@ static int via_dma_init(struct drm_device *dev, void *data, struct drm_file *fil
 
 	switch (init->func) {
 	case VIA_INIT_DMA:
-		if (!DRM_SUSER(DRM_CURPROC))
+		if (!capable(CAP_SYS_ADMIN))
 			retcode = -EPERM;
 		else
 			retcode = via_initialize(dev, dev_priv, init);
 		break;
 	case VIA_CLEANUP_DMA:
-		if (!DRM_SUSER(DRM_CURPROC))
+		if (!capable(CAP_SYS_ADMIN))
 			retcode = -EPERM;
 		else
 			retcode = via_dma_cleanup(dev);
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index 43008938b6b2..86ab99bc0ac5 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -21,7 +21,6 @@ static inline void writeq(u64 val, void __iomem *reg)
 
 /** Current process ID */
 #define DRM_CURRENTPID			task_pid_nr(current)
-#define DRM_SUSER(p)			capable(CAP_SYS_ADMIN)
 #define DRM_UDELAY(d)			udelay(d)
 /** Read a byte from a MMIO region */
 #define DRM_READ8(map, offset)		readb(((void __iomem *)(map)->handle) + (offset))
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 26/50] drm/gma500: Remove dead code
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (24 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 25/50] drm: Kill DRM_SUSER Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:46   ` Patrik Jakobsson
  2013-12-11 10:34 ` [PATCH 27/50] drm/irq: Replace DRM_WAIT_ON with wait_event Daniel Vetter
                   ` (24 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Alan Cox

This has the nice advantage that we'll get rid of a DRM_WAIT_ON user
for free.

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/gma500/psb_irq.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index a9bb34704738..f883f9e4c524 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -450,21 +450,6 @@ int psb_irq_disable_dpst(struct drm_device *dev)
 	return 0;
 }
 
-#ifdef PSB_FIXME
-static int psb_vblank_do_wait(struct drm_device *dev,
-			      unsigned int *sequence, atomic_t *counter)
-{
-	unsigned int cur_vblank;
-	int ret = 0;
-	DRM_WAIT_ON(ret, dev->vblank.queue, 3 * HZ,
-		    (((cur_vblank = atomic_read(counter))
-		      - *sequence) <= (1 << 23)));
-	*sequence = cur_vblank;
-
-	return ret;
-}
-#endif
-
 /*
  * It is used to enable VBLANK interrupt
  */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 27/50] drm/irq: Replace DRM_WAIT_ON with wait_event
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (25 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 26/50] drm/gma500: Remove dead code Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers Daniel Vetter
                   ` (23 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Note that I've dropped the timeout - we don't expect the display
hardware to ever hang, and the current code isn't really up to handle
this correctly anyway.

The only risk I see is that old user modesetting drivers wreak havoc
with themselves by disabling the interrupt support at the wrong time.
But then again this means we're running X and will get a signal sooner
or later anyway. So it should get out of the loop latest when the user
attempts to do a vt switch.

Also extract the condition into a temporary macro for better
readability.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index e7de2da57234..c0c6bdedefef 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1244,12 +1244,14 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
 	DRM_DEBUG("waiting on vblank count %d, crtc %d\n",
 		  vblwait->request.sequence, crtc);
 	dev->vblank[crtc].last_wait = vblwait->request.sequence;
-	DRM_WAIT_ON(ret, dev->vblank[crtc].queue, 3 * HZ,
-		    (((drm_vblank_count(dev, crtc) -
-		       vblwait->request.sequence) <= (1 << 23)) ||
-		     !dev->irq_enabled));
-
-	if (ret != -EINTR) {
+#define C \
+	(((drm_vblank_count(dev, crtc) - vblwait->request.sequence) \
+	  <= (1 << 23)) || \
+	 !dev->irq_enabled)
+	ret = wait_event_interruptible(dev->vblank[crtc].queue, C);
+#undef C
+
+	if (ret == 0) {
 		struct timeval now;
 
 		vblwait->reply.sequence = drm_vblank_count_and_time(dev, crtc, &now);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (26 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 27/50] drm/irq: Replace DRM_WAIT_ON with wait_event Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-18  1:39   ` Dave Airlie
  2013-12-11 10:34 ` [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank Daniel Vetter
                   ` (22 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Since this is all old ums stuff (including the one in the radeon
driver) I've just tried to perfectly replicate the existing semantics.

Reinventing wait queue code with semantics that differ from all the
standard linux wait functions is just hairy, so now we can get rid of
this and so make sure it'll never again be used.

Oh and: via futexes ... *shudder*

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_dma.c     | 11 +++++++++--
 drivers/gpu/drm/mga/mga_irq.c       | 12 +++++++++---
 drivers/gpu/drm/radeon/radeon_irq.c | 11 ++++++++---
 drivers/gpu/drm/via/via_dmablit.c   | 23 +++++++++++++++++------
 drivers/gpu/drm/via/via_irq.c       | 15 ++++++++++-----
 drivers/gpu/drm/via/via_video.c     | 12 +++++++++---
 include/drm/drm_os_linux.h          | 24 ------------------------
 7 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index be8d4720d961..7f653ab59db4 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -783,8 +783,15 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
 		master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
 
 	if (ring->irq_get(ring)) {
-		DRM_WAIT_ON(ret, ring->irq_queue, 3 * HZ,
-			    READ_BREADCRUMB(dev_priv) >= irq_nr);
+		ret = wait_event_interruptible_timeout(ring->irq_queue,
+						       READ_BREADCRUMB(dev_priv) >= irq_nr,
+						       3 * HZ);
+		if (ret == 0)
+			ret = -EBUSY;
+		else if (ret == -ERESTARTSYS)
+			ret = -EINTR;
+		else
+			ret = 0;
 		ring->irq_put(ring);
 	} else if (wait_for(READ_BREADCRUMB(dev_priv) >= irq_nr, 3000))
 		ret = -EBUSY;
diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
index 1b071b8ff9dc..8ceeb5fc6d97 100644
--- a/drivers/gpu/drm/mga/mga_irq.c
+++ b/drivers/gpu/drm/mga/mga_irq.c
@@ -128,13 +128,19 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
 	 * by about a day rather than she wants to wait for years
 	 * using fences.
 	 */
-	DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * HZ,
+	ret = wait_event_interruptible_timeout(dev_priv->fence_queue,
 		    (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
-		      - *sequence) <= (1 << 23)));
+		      - *sequence) <= (1 << 23)),
+		     3 * HZ);
 
 	*sequence = cur_fence;
 
-	return ret;
+	if (ret == 0)
+		return -EBUSY;
+	else if (ret == -ERESTARTSYS)
+		return -EINTR;
+	else
+		return 0;
 }
 
 void mga_driver_irq_preinstall(struct drm_device *dev)
diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
index 244b19bab2e7..b8eeadecd5d9 100644
--- a/drivers/gpu/drm/radeon/radeon_irq.c
+++ b/drivers/gpu/drm/radeon/radeon_irq.c
@@ -249,10 +249,15 @@ static int radeon_wait_irq(struct drm_device * dev, int swi_nr)
 
 	dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE;
 
-	DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * HZ,
-		    RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr);
+	ret = wait_event_interruptible_timeout(dev_priv->swi_queue,
+		    RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr, 3 * HZ);
 
-	return ret;
+	if (ret == 0)
+		return -EBUSY;
+	else if (ret == -ERESTARTSYS)
+		return -EINTR;
+	else
+		return 0;
 }
 
 u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index ba33cf679180..929767ec428e 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -436,13 +436,19 @@ via_dmablit_sync(struct drm_device *dev, uint32_t handle, int engine)
 	int ret = 0;
 
 	if (via_dmablit_active(blitq, engine, handle, &queue)) {
-		DRM_WAIT_ON(ret, *queue, 3 * HZ,
-			    !via_dmablit_active(blitq, engine, handle, NULL));
+		ret = wait_event_interruptible_timeout(*queue,
+			    !via_dmablit_active(blitq, engine, handle, NULL),
+			    3 * HZ);
 	}
 	DRM_DEBUG("DMA blit sync handle 0x%x engine %d returned %d\n",
 		  handle, engine, ret);
 
-	return ret;
+	if (ret == 0)
+		return -EBUSY;
+	else if (ret == -ERESTARTSYS)
+		return -EINTR;
+	else
+		return 0;
 }
 
 
@@ -688,9 +694,14 @@ via_dmablit_grab_slot(drm_via_blitq_t *blitq, int engine)
 	while (blitq->num_free == 0) {
 		spin_unlock_irqrestore(&blitq->blit_lock, irqsave);
 
-		DRM_WAIT_ON(ret, blitq->busy_queue, HZ, blitq->num_free > 0);
-		if (ret)
-			return (-EINTR == ret) ? -EAGAIN : ret;
+		ret = wait_event_interruptible_timeout(blitq->busy_queue,
+						       blitq->num_free > 0, HZ);
+		if (ret == 0)
+			return -EBUSY;
+		else if (ret == -ERESTARTSYS)
+			return -EAGAIN;
+		else
+			return 0;
 
 		spin_lock_irqsave(&blitq->blit_lock, irqsave);
 	}
diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
index 1319433816d3..4e3afef9fa0b 100644
--- a/drivers/gpu/drm/via/via_irq.c
+++ b/drivers/gpu/drm/via/via_irq.c
@@ -239,18 +239,23 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
 	cur_irq = dev_priv->via_irqs + real_irq;
 
 	if (masks[real_irq][2] && !force_sequence) {
-		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
+		ret = wait_event_interruptible_timeout(cur_irq->irq_queue,
 			    ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
-			     masks[irq][4]));
+			     masks[irq][4]), 3 * HZ);
 		cur_irq_sequence = atomic_read(&cur_irq->irq_received);
 	} else {
-		DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
+		ret = wait_event_interruptible_timeout(cur_irq->irq_queue,
 			    (((cur_irq_sequence =
 			       atomic_read(&cur_irq->irq_received)) -
-			      *sequence) <= (1 << 23)));
+			      *sequence) <= (1 << 23)), 3 * HZ);
 	}
 	*sequence = cur_irq_sequence;
-	return ret;
+	if (ret == 0)
+		return -EBUSY;
+	else if (ret == -ERESTARTSYS)
+		return -EINTR;
+	else
+		return 0;
 }
 
 
diff --git a/drivers/gpu/drm/via/via_video.c b/drivers/gpu/drm/via/via_video.c
index a9ffbad1cfdd..6944b675020f 100644
--- a/drivers/gpu/drm/via/via_video.c
+++ b/drivers/gpu/drm/via/via_video.c
@@ -82,9 +82,15 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_
 
 	switch (fx->func) {
 	case VIA_FUTEX_WAIT:
-		DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock],
-			    (fx->ms / 10) * (HZ / 100), *lock != fx->val);
-		return ret;
+		ret = wait_event_interruptible_timeout(dev_priv->decoder_queue[fx->lock],
+						       *lock != fx->val,
+						       (fx->ms / 10) * (HZ / 100));
+		if (ret == 0)
+			return -EBUSY;
+		else if (ret == -ERESTARTSYS)
+			return -EINTR;
+		else
+			return 0;
 	case VIA_FUTEX_WAKE:
 		wake_up(&(dev_priv->decoder_queue[fx->lock]));
 		return 0;
diff --git a/include/drm/drm_os_linux.h b/include/drm/drm_os_linux.h
index 86ab99bc0ac5..ad5f874195b1 100644
--- a/include/drm/drm_os_linux.h
+++ b/include/drm/drm_os_linux.h
@@ -39,27 +39,3 @@ static inline void writeq(u64 val, void __iomem *reg)
 #define DRM_READ64(map, offset)		readq(((void __iomem *)(map)->handle) + (offset))
 /** Write a qword into a MMIO region */
 #define DRM_WRITE64(map, offset, val)	writeq(val, ((void __iomem *)(map)->handle) + (offset))
-
-#define DRM_WAIT_ON( ret, queue, timeout, condition )		\
-do {								\
-	DECLARE_WAITQUEUE(entry, current);			\
-	unsigned long end = jiffies + (timeout);		\
-	add_wait_queue(&(queue), &entry);			\
-								\
-	for (;;) {						\
-		__set_current_state(TASK_INTERRUPTIBLE);	\
-		if (condition)					\
-			break;					\
-		if (time_after_eq(jiffies, end)) {		\
-			ret = -EBUSY;				\
-			break;					\
-		}						\
-		schedule_timeout((HZ/100 > 1) ? HZ/100 : 1);	\
-		if (signal_pending(current)) {			\
-			ret = -EINTR;				\
-			break;					\
-		}						\
-	}							\
-	__set_current_state(TASK_RUNNING);			\
-	remove_wait_queue(&(queue), &entry);			\
-} while (0)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (27 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-12 11:29   ` Thierry Reding
  2013-12-16 10:30   ` [PATCH] " Daniel Vetter
  2013-12-11 10:34 ` [PATCH 30/50] drm/pci: fold in irq_by_busid support Daniel Vetter
                   ` (21 subsequent siblings)
  50 siblings, 2 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Checking for both an irq number _and_ whether it's enabled is
redundant. Also this will breakd drivers which do their own irq
management and just set dev->irq_enabled once the irq stuff is all set
up.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c0c6bdedefef..85d88cadc543 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1186,7 +1186,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
 	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))
+		if (!dev->irq_enabled)
 			return -EINVAL;
 
 	if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 30/50] drm/pci: fold in irq_by_busid support
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (28 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 31/50] drm/irq: drm_control is a legacy ioctl, so pci devices only Daniel Vetter
                   ` (20 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 85d88cadc543..f70d3b9b7b22 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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.
  */
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 5736aaa7e86c..e0f0d20090c4 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 472b08f11073..847e314b1740 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -748,7 +748,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);
 };
 
 /**
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 31/50] drm/irq: drm_control is a legacy ioctl, so pci devices only
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (29 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 30/50] drm/pci: fold in irq_by_busid support Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 32/50] drm/irq: remove cargo-culted locking from irq_install/unistall Daniel Vetter
                   ` (19 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This just adds a correspdonding check, follow-up patches will exploit
this.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index f70d3b9b7b22..3faf1e94df02 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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;
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 32/50] drm/irq: remove cargo-culted locking from irq_install/unistall
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (30 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 31/50] drm/irq: drm_control is a legacy ioctl, so pci devices only Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 33/50] drm: remove drm_dev_to_irq from drivers Daniel Vetter
                   ` (18 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 3faf1e94df02..d24ac519c6f3 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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;
 	}
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 06600ac18716..95541d1e5b43 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -799,6 +799,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);
 		intel_hpd_init(dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 12bbd5eac70d..b8c500bf56b7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4543,16 +4543,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);
@@ -4567,7 +4566,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);
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 33/50] drm: remove drm_dev_to_irq from drivers
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (31 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 32/50] drm/irq: remove cargo-culted locking from irq_install/unistall Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 34/50] drm: kill drm_bus->bus_type Daniel Vetter
                   ` (17 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: 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_irq from the tree except
in drm_irq.c, move the inline helper in there. It'll disappear soon,
too.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index d24ac519c6f3..38c0bab3296e 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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.
  *
diff --git a/drivers/gpu/drm/mga/mga_state.c b/drivers/gpu/drm/mga/mga_state.c
index 314685b7f41f..3cb58df5237e 100644
--- a/drivers/gpu/drm/mga/mga_state.c
+++ b/drivers/gpu/drm/mga/mga_state.c
@@ -1020,7 +1020,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil
 
 	switch (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;
diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
index 818986b52e8c..22a5545c5f49 100644
--- a/drivers/gpu/drm/r128/r128_state.c
+++ b/drivers/gpu/drm/r128/r128_state.c
@@ -1616,7 +1616,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fi
 
 	switch (param->param) {
 	case R128_PARAM_IRQ_NR:
-		value = drm_dev_to_irq(dev);
+		value = dev->pdev->irq;
 		break;
 	default:
 		return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 956ab7f14e16..b576549fc783 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -3054,7 +3054,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
 		if ((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;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 847e314b1740..7eac463efc10 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1205,11 +1205,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();
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 34/50] drm: kill drm_bus->bus_type
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (32 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 33/50] drm: remove drm_dev_to_irq from drivers Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 35/50] drm: Rip out totally bogus vga_switcheroo->can_switch locking Daniel Vetter
                   ` (16 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Completely 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index e0f0d20090c4..fe3a30d06aca 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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,
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 21fc82006b78..5bbf83817628 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -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,
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index 21ae8d96880b..91b654938274 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -52,7 +52,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,
diff --git a/drivers/gpu/drm/tegra/bus.c b/drivers/gpu/drm/tegra/bus.c
index e38e5967d77b..8ad500794a6f 100644
--- a/drivers/gpu/drm/tegra/bus.c
+++ b/drivers/gpu/drm/tegra/bus.c
@@ -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,
 };
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 7eac463efc10..1016ecc8de95 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -146,11 +146,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... */
 /*@{*/
@@ -742,7 +737,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);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 35/50] drm: Rip out totally bogus vga_switcheroo->can_switch locking
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (33 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 34/50] drm: kill drm_bus->bus_type Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:34 ` [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock Daniel Vetter
                   ` (15 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 7f653ab59db4..2babb597d23c 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1269,9 +1269,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;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 81638d7f2eff..db721b4d778b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -64,9 +64,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;
 }
 
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 39b033b441d2..d67140811ca5 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1119,9 +1119,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;
 }
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1016ecc8de95..ee65c25e25d3 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1085,7 +1085,7 @@ struct drm_device {
 
 	/** \name Usage Counters */
 	/*@{ */
-	int open_count;			/**< Outstanding files open */
+	int open_count;			/**< Outstanding files open, protected by drm_global_lock. */
 	atomic_t ioctl_count;		/**< Outstanding IOCTLs pending */
 	atomic_t vma_count;		/**< Outstanding vma areas open */
 	int buf_use;			/**< Buffers in use -- cannot alloc */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (34 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 35/50] drm: Rip out totally bogus vga_switcheroo->can_switch locking Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-12 11:33   ` Thierry Reding
  2013-12-16 10:29   ` [PATCH] " Daniel Vetter
  2013-12-11 10:34 ` [PATCH 37/50] drm/irq: track the irq installed in drm_irq_install in dev->irq Daniel Vetter
                   ` (14 subsequent siblings)
  50 siblings, 2 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_bufs.c | 32 ++++++++++++++++----------------
 drivers/gpu/drm/drm_stub.c |  2 +-
 include/drm/drmP.h         |  4 +++-
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index edec31fe3fed..ef7f0199a0f1 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -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 * request
 	if (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))
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 6299c197bd6f..8de201fde4a6 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -441,7 +441,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);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ee65c25e25d3..0219ceae5270 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1079,7 +1079,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 */
 	/*@} */
 
@@ -1088,6 +1087,7 @@ struct drm_device {
 	int open_count;			/**< Outstanding files open, protected by drm_global_lock. */
 	atomic_t ioctl_count;		/**< Outstanding IOCTLs pending */
 	atomic_t vma_count;		/**< Outstanding vma areas open */
+	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 */
 	/*@} */
@@ -1118,6 +1118,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 */
 	/*@} */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 37/50] drm/irq: track the irq installed in drm_irq_install in dev->irq
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (35 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-16 10:29   ` [PATCH] " Daniel Vetter
  2013-12-11 10:34 ` [PATCH 38/50] drm/irq: Look up the pci irq directly in the drm_control ioctl Daniel Vetter
                   ` (13 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

To 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 38c0bab3296e..1348e041c2af 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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;
 }
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 38/50] drm/irq: Look up the pci irq directly in the drm_control ioctl
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (36 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 37/50] drm/irq: track the irq installed in drm_irq_install in dev->irq Daniel Vetter
@ 2013-12-11 10:34 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 39/50] drm: pass the irq explicitly to drm_irq_install Daniel Vetter
                   ` (12 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:34 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

It's only ever called for legacy drivers, which are all pci.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 1348e041c2af..24c6590bb33e 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 39/50] drm: pass the irq explicitly to drm_irq_install
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (37 preceding siblings ...)
  2013-12-11 10:34 ` [PATCH 38/50] drm/irq: Look up the pci irq directly in the drm_control ioctl Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 40/50] drm: remove bus->get_irq implementations Daniel Vetter
                   ` (11 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: 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_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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index ed1d6d289022..f716c650af88 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -328,21 +328,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.
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 069f64533ac3..7d6d1ad4fcc9 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -181,7 +181,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;
 
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 24c6590bb33e..c1d1d909d24e 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 1199180667c9..d00382632c7e 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -387,7 +387,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 	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;
 
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2babb597d23c..c9101bde96be 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1317,7 +1317,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 	if (ret)
 		goto cleanup_vga_switcheroo;
 
-	ret = drm_irq_install(dev);
+	ret = drm_irq_install(dev, dev->pdev->irq);
 	if (ret)
 		goto cleanup_gem_stolen;
 
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 95541d1e5b43..f92855ba08f3 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -644,7 +644,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);
 
@@ -805,7 +805,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);
 		intel_hpd_init(dev);
 	} else {
 		mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b8c500bf56b7..c7b51d0972dc 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4544,7 +4544,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);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 28b57eb6f9a1..233246641ae9 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -228,7 +228,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");
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index 28f84b4fce32..34d6a85e9023 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -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);
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 089c9ffb0aa9..16807afab362 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -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);
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index c839c9c89efb..82c84c7fd4f6 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -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;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 0c22b6ca7fd2..4fad1efbce03 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -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");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c7a549694e59..5066cc7d477b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -704,7 +704,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;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0219ceae5270..1633a89fb6ad 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1362,7 +1362,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);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 40/50] drm: remove bus->get_irq implementations
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (38 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 39/50] drm: pass the irq explicitly to drm_irq_install Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 41/50] drm: inline drm_pci_set_unique Daniel Vetter
                   ` (10 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: 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 <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index fe3a30d06aca..a765cf00e293 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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,
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 5bbf83817628..4c50cf991f31 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -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,
 };
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index 91b654938274..c6cc12cf21ee 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -35,11 +35,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";
@@ -52,7 +47,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,
 };
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1633a89fb6ad..eeb652af9160 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -737,7 +737,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,
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 41/50] drm: inline drm_pci_set_unique
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (39 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 40/50] drm: remove bus->get_irq implementations Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 42/50] drm: rip out dev->devname Daniel Vetter
                   ` (9 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index dffc836144cc..0db3b56228cd 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -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;
 
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index a765cf00e293..197dc069f679 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index eeb652af9160..b0e99f76bbb6 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -739,8 +739,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);
 };
 
 /**
@@ -1507,6 +1505,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;
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 42/50] drm: rip out dev->devname
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (40 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 41/50] drm: inline drm_pci_set_unique Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 43/50] drm: remove drm_bus->get_name Daniel Vetter
                   ` (8 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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     |  4 ----
 drivers/gpu/drm/tegra/bus.c    | 10 ----------
 include/drm/drmP.h             |  1 -
 7 files changed, 1 insertion(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 0db3b56228cd..14610d01d662 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c1d1d909d24e..8c0f786107d6 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 197dc069f679..6de8676bbd1c 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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.
 	 */
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 4c50cf991f31..88ff71076cde 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -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;
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 8de201fde4a6..00c0f4b2c7bc 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -183,9 +183,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);
@@ -497,7 +494,6 @@ void drm_dev_free(struct drm_device *dev)
 	drm_ctxbitmap_cleanup(dev);
 	drm_ht_remove(&dev->map_hash);
 
-	kfree(dev->devname);
 	kfree(dev);
 }
 EXPORT_SYMBOL(drm_dev_free);
diff --git a/drivers/gpu/drm/tegra/bus.c b/drivers/gpu/drm/tegra/bus.c
index 8ad500794a6f..33c339b66ae0 100644
--- a/drivers/gpu/drm/tegra/bus.c
+++ b/drivers/gpu/drm/tegra/bus.c
@@ -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;
 }
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index b0e99f76bbb6..1fde90406605 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1071,7 +1071,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 Locks */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 43/50] drm: remove drm_bus->get_name
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (41 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 42/50] drm: rip out dev->devname Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 44/50] drm: Remove dev->kdriver Daniel Vetter
                   ` (7 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: 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.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 7d5a152eeb02..2cafa3f16cd3 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -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;
 }
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 6de8676bbd1c..2df5eb1ea207 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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,
 };
 
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 88ff71076cde..a934f6e1b1bb 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -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,
 };
 
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index c6cc12cf21ee..899eaeeb1992 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -35,11 +35,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)
 {
@@ -47,7 +42,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,
 };
     
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1fde90406605..c508bc2aa70c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -737,7 +737,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);
 };
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 44/50] drm: Remove dev->kdriver
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (42 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 43/50] drm: remove drm_bus->get_name Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 45/50] drm/<drivers>: don't set driver->dev_priv_size to 0 Daniel Vetter
                   ` (6 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

With the last patch to ditch the ->get_name callbacks the last
user is now gone.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 2df5eb1ea207..847beee462fa 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -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)
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index a934f6e1b1bb..a13444a8a12d 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -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);
 }
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index 899eaeeb1992..f1c780fdc74f 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -50,7 +50,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);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c508bc2aa70c..3b946beba2e0 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -972,11 +972,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. */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 45/50] drm/<drivers>: don't set driver->dev_priv_size to 0
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (43 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 44/50] drm: Remove dev->kdriver Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2014-01-10 15:25   ` Damien Lespiau
  2013-12-11 10:35 ` [PATCH 46/50] drm: store the gem vma offset manager in a typed pointer Daniel Vetter
                   ` (5 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Especially not on modesetting drivers - this is used to size
the driver private structure for legacy drm buffers.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 5137f15dba19..2ba39ac7d222 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -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,
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index fee8748bdca5..6e936634d65c 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -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,
 
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index f6f30b9e9ff5..a16e56325bfd 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -522,7 +522,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,
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 46/50] drm: store the gem vma offset manager in a typed pointer
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (44 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 45/50] drm/<drivers>: don't set driver->dev_priv_size to 0 Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:53   ` David Herrmann
  2013-12-11 10:35 ` [PATCH 47/50] drm: rip out dev->ioctl_count tracking Daniel Vetter
                   ` (4 subsequent siblings)
  50 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This was hidden in a generic void * dev->mm_private. But only ever
used for gem. But thanks to this fake generic pretension no one
noticed that Rob's drm drivers are now all broken.

So just give the offset manager a type pointer and fix up msm, omapdrm
and tilcdc.

v2: Fixup compile fail.

Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_gem.c              | 27 ++++++++++++---------------
 drivers/gpu/drm/gma500/psb_intel_drv.h |  5 -----
 drivers/gpu/drm/msm/msm_drv.c          |  2 +-
 drivers/gpu/drm/omapdrm/omap_debugfs.c |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c    |  2 +-
 include/drm/drmP.h                     | 14 ++++++--------
 6 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4761adedad2a..32525b0a473a 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -91,19 +91,19 @@
 int
 drm_gem_init(struct drm_device *dev)
 {
-	struct drm_gem_mm *mm;
+	struct drm_vma_offset_manager *vma_offset_manager;
 
 	mutex_init(&dev->object_name_lock);
 	idr_init(&dev->object_name_idr);
 
-	mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL);
-	if (!mm) {
+	vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
+	if (!vma_offset_manager) {
 		DRM_ERROR("out of memory\n");
 		return -ENOMEM;
 	}
 
-	dev->mm_private = mm;
-	drm_vma_offset_manager_init(&mm->vma_manager,
+	dev->vma_offset_manager = vma_offset_manager;
+	drm_vma_offset_manager_init(vma_offset_manager,
 				    DRM_FILE_PAGE_OFFSET_START,
 				    DRM_FILE_PAGE_OFFSET_SIZE);
 
@@ -113,11 +113,10 @@ drm_gem_init(struct drm_device *dev)
 void
 drm_gem_destroy(struct drm_device *dev)
 {
-	struct drm_gem_mm *mm = dev->mm_private;
 
-	drm_vma_offset_manager_destroy(&mm->vma_manager);
-	kfree(mm);
-	dev->mm_private = NULL;
+	drm_vma_offset_manager_destroy(dev->vma_offset_manager);
+	kfree(dev->vma_offset_manager);
+	dev->vma_offset_manager = NULL;
 }
 
 /**
@@ -374,9 +373,8 @@ void
 drm_gem_free_mmap_offset(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
-	struct drm_gem_mm *mm = dev->mm_private;
 
-	drm_vma_offset_remove(&mm->vma_manager, &obj->vma_node);
+	drm_vma_offset_remove(dev->vma_offset_manager, &obj->vma_node);
 }
 EXPORT_SYMBOL(drm_gem_free_mmap_offset);
 
@@ -398,9 +396,8 @@ int
 drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)
 {
 	struct drm_device *dev = obj->dev;
-	struct drm_gem_mm *mm = dev->mm_private;
 
-	return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node,
+	return drm_vma_offset_add(dev->vma_offset_manager, &obj->vma_node,
 				  size / PAGE_SIZE);
 }
 EXPORT_SYMBOL(drm_gem_create_mmap_offset_size);
@@ -833,7 +830,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 {
 	struct drm_file *priv = filp->private_data;
 	struct drm_device *dev = priv->minor->dev;
-	struct drm_gem_mm *mm = dev->mm_private;
 	struct drm_gem_object *obj;
 	struct drm_vma_offset_node *node;
 	int ret = 0;
@@ -843,7 +839,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 
 	mutex_lock(&dev->struct_mutex);
 
-	node = drm_vma_offset_exact_lookup(&mm->vma_manager, vma->vm_pgoff,
+	node = drm_vma_offset_exact_lookup(dev->vma_offset_manager,
+					   vma->vm_pgoff,
 					   vma_pages(vma));
 	if (!node) {
 		mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
index bde27fdb41bf..dc2c8eb030fa 100644
--- a/drivers/gpu/drm/gma500/psb_intel_drv.h
+++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
@@ -250,11 +250,6 @@ extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
 extern int intelfb_probe(struct drm_device *dev);
 extern int intelfb_remove(struct drm_device *dev,
 			  struct drm_framebuffer *fb);
-extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
-							*dev, struct
-							drm_mode_fb_cmd
-							*mode_cmd,
-							void *mm_private);
 extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
 				      const struct drm_display_mode *mode,
 				      struct drm_display_mode *adjusted_mode);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 233246641ae9..177169ce01f0 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -415,7 +415,7 @@ static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
 
 static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
 {
-	return drm_mm_dump_table(m, dev->mm_private);
+	return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c b/drivers/gpu/drm/omapdrm/omap_debugfs.c
index c27f59da7f29..d4c04d69fc4d 100644
--- a/drivers/gpu/drm/omapdrm/omap_debugfs.c
+++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c
@@ -48,7 +48,7 @@ static int mm_show(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
-	return drm_mm_dump_table(m, dev->mm_private);
+	return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static int fb_show(struct seq_file *m, void *arg)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 4fad1efbce03..b20b69488dc9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -444,7 +444,7 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
-	return drm_mm_dump_table(m, dev->mm_private);
+	return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static struct drm_info_list tilcdc_debugfs_list[] = {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 3b946beba2e0..610eb5c221c4 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -601,13 +601,6 @@ struct drm_ati_pcigart_info {
 };
 
 /**
- * GEM specific mm private for tracking GEM objects
- */
-struct drm_gem_mm {
-	struct drm_vma_offset_manager vma_manager;
-};
-
-/**
  * This structure defines the drm_mm memory object, which will be used by the
  * DRM for its buffer objects.
  */
@@ -972,6 +965,11 @@ 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. */
@@ -1156,7 +1154,6 @@ struct drm_device {
 	struct drm_sg_mem *sg;	/**< Scatter gather memory */
 	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
 	void *dev_private;		/**< device private data */
-	void *mm_private;
 	struct address_space *dev_mapping;
 	struct drm_sigdata sigdata;	   /**< For block_all_signals */
 	sigset_t sigmask;
@@ -1174,6 +1171,7 @@ struct drm_device {
 	/*@{ */
 	struct mutex object_name_lock;
 	struct idr object_name_idr;
+	struct drm_vma_offset_manager *vma_offset_manager;
 	/*@} */
 	int switch_power_state;
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 47/50] drm: rip out dev->ioctl_count tracking
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (45 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 46/50] drm: store the gem vma offset manager in a typed pointer Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 48/50] drm: Kill file_priv->ioctl_count tracking Daniel Vetter
                   ` (3 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Now dev->ioctl_count tries to prevent the device from disappearing if
it's still in use. And if we'd actually need this code it would be
hopelessly racy and broken.

But luckily the vfs already takes care of this. So we can just rip it
out.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_drv.c  | 2 --
 drivers/gpu/drm/drm_fops.c | 8 +-------
 include/drm/drmP.h         | 1 -
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index d9137e49c4e8..9fd4dd476d33 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -315,7 +315,6 @@ long drm_ioctl(struct file *filp,
 	if (drm_device_is_unplugged(dev))
 		return -ENODEV;
 
-	atomic_inc(&dev->ioctl_count);
 	++file_priv->ioctl_count;
 
 	if ((nr >= DRM_CORE_IOCTL_COUNT) &&
@@ -410,7 +409,6 @@ long drm_ioctl(struct file *filp,
 
 	if (kdata != stack_kdata)
 		kfree(kdata);
-	atomic_dec(&dev->ioctl_count);
 	if (retcode)
 		DRM_DEBUG("ret = %d\n", retcode);
 	return retcode;
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index c5b929c3f77a..97ebc828de5b 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -392,7 +392,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return;
 
-	atomic_set(&dev->ioctl_count, 0);
 	atomic_set(&dev->vma_count, 0);
 
 	dev->sigdata.lock = NULL;
@@ -578,12 +577,7 @@ int drm_release(struct inode *inode, struct file *filp)
 	 */
 
 	if (!--dev->open_count) {
-		if (atomic_read(&dev->ioctl_count)) {
-			DRM_ERROR("Device busy: %d\n",
-				  atomic_read(&dev->ioctl_count));
-			retcode = -EBUSY;
-		} else
-			retcode = drm_lastclose(dev);
+		retcode = drm_lastclose(dev);
 		if (drm_device_is_unplugged(dev))
 			drm_put_dev(dev);
 	}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 610eb5c221c4..2644ba1564eb 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1073,7 +1073,6 @@ struct drm_device {
 	/** \name Usage Counters */
 	/*@{ */
 	int open_count;			/**< Outstanding files open, protected by drm_global_lock. */
-	atomic_t ioctl_count;		/**< Outstanding IOCTLs pending */
 	atomic_t vma_count;		/**< Outstanding vma areas open */
 	spinlock_t buf_lock;		/**< For drm_device::buf_use and a few other things. */
 	int buf_use;			/**< Buffers in use -- cannot alloc */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 48/50] drm: Kill file_priv->ioctl_count tracking
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (46 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 47/50] drm: rip out dev->ioctl_count tracking Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 49/50] drm: remove dev->vma_count Daniel Vetter
                   ` (2 subsequent siblings)
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

It's racy, and it's only used in debugfs. There are simpler ways to
know whether something is going on (like looking at dmesg with full
debugging enabled). And they're all much more useful.

So let's just rip this out.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_drv.c  | 2 --
 drivers/gpu/drm/drm_fops.c | 1 -
 drivers/gpu/drm/drm_info.c | 6 +++---
 include/drm/drmP.h         | 1 -
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 9fd4dd476d33..345be03c23db 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -315,8 +315,6 @@ long drm_ioctl(struct file *filp,
 	if (drm_device_is_unplugged(dev))
 		return -ENODEV;
 
-	++file_priv->ioctl_count;
-
 	if ((nr >= DRM_CORE_IOCTL_COUNT) &&
 	    ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
 		goto err_i1;
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 97ebc828de5b..330f3dd8e9d0 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -232,7 +232,6 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 		goto out_put_pid;
 	}
 
-	priv->ioctl_count = 0;
 	/* for compatibility root is always authenticated */
 	priv->always_authenticated = capable(CAP_SYS_ADMIN);
 	priv->authenticated = priv->always_authenticated;
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 2cafa3f16cd3..9337f8e210f8 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -184,14 +184,14 @@ int drm_clients_info(struct seq_file *m, void *data)
 	struct drm_file *priv;
 
 	mutex_lock(&dev->struct_mutex);
-	seq_printf(m, "a dev	pid    uid	magic	  ioctls\n\n");
+	seq_printf(m, "a dev	pid    uid	magic\n\n");
 	list_for_each_entry(priv, &dev->filelist, lhead) {
-		seq_printf(m, "%c %3d %5d %5d %10u %10lu\n",
+		seq_printf(m, "%c %3d %5d %5d %10u\n",
 			   priv->authenticated ? 'y' : 'n',
 			   priv->minor->index,
 			   pid_vnr(priv->pid),
 			   from_kuid_munged(seq_user_ns(m), priv->uid),
-			   priv->magic, priv->ioctl_count);
+			   priv->magic);
 	}
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2644ba1564eb..a61d09b857a5 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -416,7 +416,6 @@ struct drm_file {
 	struct pid *pid;
 	kuid_t uid;
 	drm_magic_t magic;
-	unsigned long ioctl_count;
 	struct list_head lhead;
 	struct drm_minor *minor;
 	unsigned long lock_count;
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 49/50] drm: remove dev->vma_count
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (47 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 48/50] drm: Kill file_priv->ioctl_count tracking Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-11 10:35 ` [PATCH 50/50] drm: use memdup_user() as a cleanup Daniel Vetter
  2013-12-12 18:08 ` [PATCH 00/50] more drm de-midlayering Jakob Bornecrantz
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This is just used for a debugfs file, and we can easily reconstruct
this number by just walking the list twice. Which isn't really bad for
a debugfs file anyway.

So let's rip this out.

There's the other issue that the dev->vmalist itself is a bit useless,
since that can be reconstructed with all the memory mapping
information from proc. But remove that is a different topic entirely.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_fops.c |  2 --
 drivers/gpu/drm/drm_info.c | 10 +++++++---
 drivers/gpu/drm/drm_vm.c   |  3 ---
 include/drm/drmP.h         |  1 -
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 330f3dd8e9d0..7f2af9aca038 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -391,8 +391,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return;
 
-	atomic_set(&dev->vma_count, 0);
-
 	dev->sigdata.lock = NULL;
 
 	dev->context_flag = 0;
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 9337f8e210f8..86feedd5e6f6 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -232,14 +232,18 @@ int drm_vma_info(struct seq_file *m, void *data)
 	struct drm_device *dev = node->minor->dev;
 	struct drm_vma_entry *pt;
 	struct vm_area_struct *vma;
+	unsigned long vma_count = 0;
 #if defined(__i386__)
 	unsigned int pgprot;
 #endif
 
 	mutex_lock(&dev->struct_mutex);
-	seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",
-		   atomic_read(&dev->vma_count),
-		   high_memory, (void *)(unsigned long)virt_to_phys(high_memory));
+	list_for_each_entry(pt, &dev->vmalist, head)
+		vma_count++;
+
+	seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n",
+		   vma_count, high_memory,
+		   (void *)(unsigned long)virt_to_phys(high_memory));
 
 	list_for_each_entry(pt, &dev->vmalist, head) {
 		vma = pt->vma;
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index ef5540b6b451..24e045c4f531 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -220,7 +220,6 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
 
 	DRM_DEBUG("0x%08lx,0x%08lx\n",
 		  vma->vm_start, vma->vm_end - vma->vm_start);
-	atomic_dec(&dev->vma_count);
 
 	map = vma->vm_private_data;
 
@@ -405,7 +404,6 @@ void drm_vm_open_locked(struct drm_device *dev,
 
 	DRM_DEBUG("0x%08lx,0x%08lx\n",
 		  vma->vm_start, vma->vm_end - vma->vm_start);
-	atomic_inc(&dev->vma_count);
 
 	vma_entry = kmalloc(sizeof(*vma_entry), GFP_KERNEL);
 	if (vma_entry) {
@@ -433,7 +431,6 @@ void drm_vm_close_locked(struct drm_device *dev,
 
 	DRM_DEBUG("0x%08lx,0x%08lx\n",
 		  vma->vm_start, vma->vm_end - vma->vm_start);
-	atomic_dec(&dev->vma_count);
 
 	list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
 		if (pt->vma == vma) {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a61d09b857a5..311d182c521d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1072,7 +1072,6 @@ struct drm_device {
 	/** \name Usage Counters */
 	/*@{ */
 	int open_count;			/**< Outstanding files open, protected by drm_global_lock. */
-	atomic_t vma_count;		/**< Outstanding vma areas open */
 	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 */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 50/50] drm: use memdup_user() as a cleanup
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (48 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 49/50] drm: remove dev->vma_count Daniel Vetter
@ 2013-12-11 10:35 ` Daniel Vetter
  2013-12-12 18:08 ` [PATCH 00/50] more drm de-midlayering Jakob Bornecrantz
  50 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 10:35 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Dan Carpenter

From: Dan Carpenter <dan.carpenter@oracle.com>

drivers/gpu/drm/r128/r128_state.c:1014:10-17: WARNING opportunity for memdup_user
/c/kernel-tests/src/cocci/drivers/gpu/drm/r128/r128_state.c:1029:9-16: WARNING opportunity for memdup_user
/c/kernel-tests/src/cocci/drivers/gpu/drm/r128/r128_state.c:904:10-17: WARNING opportunity for memdup_user
/c/kernel-tests/src/cocci/drivers/gpu/drm/r128/r128_state.c:914:9-16: WARNING opportunity for memdup_user

 Use memdup_user rather than duplicating its implementation
 This is a little bit restricted to reduce false positives

Generated by: coccinelle/api/memdup_user.cocci

CC: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/r128/r128_state.c | 46 ++++++++++-----------------------------
 1 file changed, 12 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
index 22a5545c5f49..97064dd434c2 100644
--- a/drivers/gpu/drm/r128/r128_state.c
+++ b/drivers/gpu/drm/r128/r128_state.c
@@ -901,25 +901,16 @@ static int r128_cce_dispatch_write_span(struct drm_device *dev,
 		return -EFAULT;
 
 	buffer_size = depth->n * sizeof(u32);
-	buffer = kmalloc(buffer_size, GFP_KERNEL);
-	if (buffer == NULL)
-		return -ENOMEM;
-	if (copy_from_user(buffer, depth->buffer, buffer_size)) {
-		kfree(buffer);
-		return -EFAULT;
-	}
+	buffer = memdup_user(depth->buffer, buffer_size);
+	if (IS_ERR(buffer))
+		return PTR_ERR(buffer);
 
 	mask_size = depth->n * sizeof(u8);
 	if (depth->mask) {
-		mask = kmalloc(mask_size, GFP_KERNEL);
-		if (mask == NULL) {
+		mask = memdup_user(depth->mask, mask_size);
+		if (IS_ERR(mask)) {
 			kfree(buffer);
-			return -ENOMEM;
-		}
-		if (copy_from_user(mask, depth->mask, mask_size)) {
-			kfree(buffer);
-			kfree(mask);
-			return -EFAULT;
+			return PTR_ERR(mask);
 		}
 
 		for (i = 0; i < count; i++, x++) {
@@ -1011,34 +1002,21 @@ static int r128_cce_dispatch_write_pixels(struct drm_device *dev,
 	}
 
 	buffer_size = depth->n * sizeof(u32);
-	buffer = kmalloc(buffer_size, GFP_KERNEL);
-	if (buffer == NULL) {
-		kfree(x);
-		kfree(y);
-		return -ENOMEM;
-	}
-	if (copy_from_user(buffer, depth->buffer, buffer_size)) {
+	buffer = memdup_user(depth->buffer, buffer_size);
+	if (IS_ERR(buffer)) {
 		kfree(x);
 		kfree(y);
-		kfree(buffer);
-		return -EFAULT;
+		return PTR_ERR(buffer);
 	}
 
 	if (depth->mask) {
 		mask_size = depth->n * sizeof(u8);
-		mask = kmalloc(mask_size, GFP_KERNEL);
-		if (mask == NULL) {
-			kfree(x);
-			kfree(y);
-			kfree(buffer);
-			return -ENOMEM;
-		}
-		if (copy_from_user(mask, depth->mask, mask_size)) {
+		mask = memdup_user(depth->mask, mask_size);
+		if (IS_ERR(mask)) {
 			kfree(x);
 			kfree(y);
 			kfree(buffer);
-			kfree(mask);
-			return -EFAULT;
+			return PTR_ERR(mask);
 		}
 
 		for (i = 0; i < count; i++) {
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* Re: [PATCH 26/50] drm/gma500: Remove dead code
  2013-12-11 10:34 ` [PATCH 26/50] drm/gma500: Remove dead code Daniel Vetter
@ 2013-12-11 10:46   ` Patrik Jakobsson
  0 siblings, 0 replies; 79+ messages in thread
From: Patrik Jakobsson @ 2013-12-11 10:46 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development, Alan Cox

On Wed, Dec 11, 2013 at 11:34 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> This has the nice advantage that we'll get rid of a DRM_WAIT_ON user
> for free.
>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Cc: Alan Cox <alan@linux.intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/gma500/psb_irq.c | 15 ---------------
>  1 file changed, 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
> index a9bb34704738..f883f9e4c524 100644
> --- a/drivers/gpu/drm/gma500/psb_irq.c
> +++ b/drivers/gpu/drm/gma500/psb_irq.c
> @@ -450,21 +450,6 @@ int psb_irq_disable_dpst(struct drm_device *dev)
>         return 0;
>  }
>
> -#ifdef PSB_FIXME
> -static int psb_vblank_do_wait(struct drm_device *dev,
> -                             unsigned int *sequence, atomic_t *counter)
> -{
> -       unsigned int cur_vblank;
> -       int ret = 0;
> -       DRM_WAIT_ON(ret, dev->vblank.queue, 3 * HZ,
> -                   (((cur_vblank = atomic_read(counter))
> -                     - *sequence) <= (1 << 23)));
> -       *sequence = cur_vblank;
> -
> -       return ret;
> -}
> -#endif
> -
>  /*
>   * It is used to enable VBLANK interrupt
>   */
> --
> 1.8.4.3
>

Yes, that can just go away. Thanks.

Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 46/50] drm: store the gem vma offset manager in a typed pointer
  2013-12-11 10:35 ` [PATCH 46/50] drm: store the gem vma offset manager in a typed pointer Daniel Vetter
@ 2013-12-11 10:53   ` David Herrmann
  2013-12-11 13:24     ` [PATCH 1/2] " Daniel Vetter
  0 siblings, 1 reply; 79+ messages in thread
From: David Herrmann @ 2013-12-11 10:53 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi Daniel

On Wed, Dec 11, 2013 at 11:35 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> This was hidden in a generic void * dev->mm_private. But only ever
> used for gem. But thanks to this fake generic pretension no one
> noticed that Rob's drm drivers are now all broken.
>
> So just give the offset manager a type pointer and fix up msm, omapdrm
> and tilcdc.
>
> v2: Fixup compile fail.
>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_gem.c              | 27 ++++++++++++---------------
>  drivers/gpu/drm/gma500/psb_intel_drv.h |  5 -----
>  drivers/gpu/drm/msm/msm_drv.c          |  2 +-
>  drivers/gpu/drm/omapdrm/omap_debugfs.c |  2 +-
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c    |  2 +-
>  include/drm/drmP.h                     | 14 ++++++--------
>  6 files changed, 21 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 4761adedad2a..32525b0a473a 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -91,19 +91,19 @@
>  int
>  drm_gem_init(struct drm_device *dev)
>  {
> -       struct drm_gem_mm *mm;
> +       struct drm_vma_offset_manager *vma_offset_manager;
>
>         mutex_init(&dev->object_name_lock);
>         idr_init(&dev->object_name_idr);
>
> -       mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL);
> -       if (!mm) {
> +       vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
> +       if (!vma_offset_manager) {
>                 DRM_ERROR("out of memory\n");
>                 return -ENOMEM;
>         }
>
> -       dev->mm_private = mm;
> -       drm_vma_offset_manager_init(&mm->vma_manager,
> +       dev->vma_offset_manager = vma_offset_manager;
> +       drm_vma_offset_manager_init(vma_offset_manager,
>                                     DRM_FILE_PAGE_OFFSET_START,
>                                     DRM_FILE_PAGE_OFFSET_SIZE);
>
> @@ -113,11 +113,10 @@ drm_gem_init(struct drm_device *dev)
>  void
>  drm_gem_destroy(struct drm_device *dev)
>  {
> -       struct drm_gem_mm *mm = dev->mm_private;
>
> -       drm_vma_offset_manager_destroy(&mm->vma_manager);
> -       kfree(mm);
> -       dev->mm_private = NULL;
> +       drm_vma_offset_manager_destroy(dev->vma_offset_manager);
> +       kfree(dev->vma_offset_manager);
> +       dev->vma_offset_manager = NULL;
>  }
>
>  /**
> @@ -374,9 +373,8 @@ void
>  drm_gem_free_mmap_offset(struct drm_gem_object *obj)
>  {
>         struct drm_device *dev = obj->dev;
> -       struct drm_gem_mm *mm = dev->mm_private;
>
> -       drm_vma_offset_remove(&mm->vma_manager, &obj->vma_node);
> +       drm_vma_offset_remove(dev->vma_offset_manager, &obj->vma_node);
>  }
>  EXPORT_SYMBOL(drm_gem_free_mmap_offset);
>
> @@ -398,9 +396,8 @@ int
>  drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)
>  {
>         struct drm_device *dev = obj->dev;
> -       struct drm_gem_mm *mm = dev->mm_private;
>
> -       return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node,
> +       return drm_vma_offset_add(dev->vma_offset_manager, &obj->vma_node,
>                                   size / PAGE_SIZE);
>  }
>  EXPORT_SYMBOL(drm_gem_create_mmap_offset_size);
> @@ -833,7 +830,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>  {
>         struct drm_file *priv = filp->private_data;
>         struct drm_device *dev = priv->minor->dev;
> -       struct drm_gem_mm *mm = dev->mm_private;
>         struct drm_gem_object *obj;
>         struct drm_vma_offset_node *node;
>         int ret = 0;
> @@ -843,7 +839,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
>
>         mutex_lock(&dev->struct_mutex);
>
> -       node = drm_vma_offset_exact_lookup(&mm->vma_manager, vma->vm_pgoff,
> +       node = drm_vma_offset_exact_lookup(dev->vma_offset_manager,
> +                                          vma->vm_pgoff,
>                                            vma_pages(vma));
>         if (!node) {
>                 mutex_unlock(&dev->struct_mutex);
> diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
> index bde27fdb41bf..dc2c8eb030fa 100644
> --- a/drivers/gpu/drm/gma500/psb_intel_drv.h
> +++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
> @@ -250,11 +250,6 @@ extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
>  extern int intelfb_probe(struct drm_device *dev);
>  extern int intelfb_remove(struct drm_device *dev,
>                           struct drm_framebuffer *fb);
> -extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
> -                                                       *dev, struct
> -                                                       drm_mode_fb_cmd
> -                                                       *mode_cmd,
> -                                                       void *mm_private);

Where does that come from?

>  extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
>                                       const struct drm_display_mode *mode,
>                                       struct drm_display_mode *adjusted_mode);
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 233246641ae9..177169ce01f0 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -415,7 +415,7 @@ static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
>
>  static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
>  {
> -       return drm_mm_dump_table(m, dev->mm_private);
> +       return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
>  }
>
>  static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
> diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c b/drivers/gpu/drm/omapdrm/omap_debugfs.c
> index c27f59da7f29..d4c04d69fc4d 100644
> --- a/drivers/gpu/drm/omapdrm/omap_debugfs.c
> +++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c
> @@ -48,7 +48,7 @@ static int mm_show(struct seq_file *m, void *arg)
>  {
>         struct drm_info_node *node = (struct drm_info_node *) m->private;
>         struct drm_device *dev = node->minor->dev;
> -       return drm_mm_dump_table(m, dev->mm_private);
> +       return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
>  }
>
>  static int fb_show(struct seq_file *m, void *arg)
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 4fad1efbce03..b20b69488dc9 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -444,7 +444,7 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg)
>  {
>         struct drm_info_node *node = (struct drm_info_node *) m->private;
>         struct drm_device *dev = node->minor->dev;
> -       return drm_mm_dump_table(m, dev->mm_private);
> +       return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
>  }
>
>  static struct drm_info_list tilcdc_debugfs_list[] = {
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 3b946beba2e0..610eb5c221c4 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -601,13 +601,6 @@ struct drm_ati_pcigart_info {
>  };
>
>  /**
> - * GEM specific mm private for tracking GEM objects
> - */
> -struct drm_gem_mm {
> -       struct drm_vma_offset_manager vma_manager;
> -};
> -
> -/**
>   * This structure defines the drm_mm memory object, which will be used by the
>   * DRM for its buffer objects.
>   */
> @@ -972,6 +965,11 @@ 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;

Ugh? I think you got some rebase issues in the series. Otherwise, this
patch looks good.

Thanks
David

>         struct drm_bus *bus;
>
>         /* List of devices hanging off this driver with stealth attach. */
> @@ -1156,7 +1154,6 @@ struct drm_device {
>         struct drm_sg_mem *sg;  /**< Scatter gather memory */
>         unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
>         void *dev_private;              /**< device private data */
> -       void *mm_private;
>         struct address_space *dev_mapping;
>         struct drm_sigdata sigdata;        /**< For block_all_signals */
>         sigset_t sigmask;
> @@ -1174,6 +1171,7 @@ struct drm_device {
>         /*@{ */
>         struct mutex object_name_lock;
>         struct idr object_name_idr;
> +       struct drm_vma_offset_manager *vma_offset_manager;
>         /*@} */
>         int switch_power_state;
>
> --
> 1.8.4.3
>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 05/50] drm/omap: call drm_put_dev directly in ->remove
  2013-12-11 10:34 ` [PATCH 05/50] drm/omap: call drm_put_dev directly in ->remove Daniel Vetter
@ 2013-12-11 12:02   ` Rob Clark
  2013-12-11 13:20     ` [PATCH] " Daniel Vetter
  0 siblings, 1 reply; 79+ messages in thread
From: Rob Clark @ 2013-12-11 12:02 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 5:34 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Again omap already sets the driver data pointer to the drm_device.
>
> Also drop the driver unregister call, that should be (and already is)
> done in the module unload hook.

umm..  there are two devices+drivers at play in there.  The dmm/tiler
is split out into a different device (mainly just because it's irq and
memory resources were associated to a different device).  The one that
is dropped in omap_drm_fini() is the toplevel drm device, not the
*dmm* driver

(for extra fun, use a really small font and try to tell the difference
between dmm and drm ;-))

BR,
-R

>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index e7fa3cd96743..13f294aeaefd 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -665,9 +665,9 @@ static int pdev_probe(struct platform_device *device)
>  static int pdev_remove(struct platform_device *device)
>  {
>         DBG("");
> -       drm_platform_exit(&omap_drm_driver, device);
>
> -       platform_driver_unregister(&omap_dmm_driver);
> +       drm_put_dev(platform_get_drvdata(device));
> +
>         return 0;
>  }
>
> --
> 1.8.4.3
>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 06/50] drm/shmob: call drm_put_dev directly from ->remove hook
  2013-12-11 10:34 ` [PATCH 06/50] drm/shmob: call drm_put_dev directly from ->remove hook Daniel Vetter
@ 2013-12-11 12:21   ` Laurent Pinchart
  0 siblings, 0 replies; 79+ messages in thread
From: Laurent Pinchart @ 2013-12-11 12:21 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi Daniel,

Thank you for the patch.

On Wednesday 11 December 2013 11:34:27 Daniel Vetter wrote:
> We need to chase one pointer here.
> 
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Acked-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index 015551866b4a..c839c9c89efb
> 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -336,7 +336,9 @@ static int shmob_drm_probe(struct platform_device *pdev)
> 
>  static int shmob_drm_remove(struct platform_device *pdev)
>  {
> -	drm_platform_exit(&shmob_drm_driver, pdev);
> +	struct shmob_drm_device *sdev = platform_get_drvdata(pdev);
> +
> +	drm_put_dev(sdev->ddev);
> 
>  	return 0;
>  }
-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [PATCH] drm/omap: call drm_put_dev directly in ->remove
  2013-12-11 12:02   ` Rob Clark
@ 2013-12-11 13:20     ` Daniel Vetter
  2013-12-11 19:35       ` Rob Clark
  0 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 13:20 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again omap already sets the driver data pointer to the drm_device.

v2: Don't rip out the platform_driver_unregister call for omap_dmm_driver.
Pesky difference between drm and dmm ...

Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index e7fa3cd96743..7be34b7d06f2 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -665,7 +665,7 @@ static int pdev_probe(struct platform_device *device)
 static int pdev_remove(struct platform_device *device)
 {
 	DBG("");
-	drm_platform_exit(&omap_drm_driver, device);
+	drm_put_dev(platform_get_drvdata(device));
 
 	platform_driver_unregister(&omap_dmm_driver);
 	return 0;
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer
  2013-12-11 10:53   ` David Herrmann
@ 2013-12-11 13:24     ` Daniel Vetter
  2013-12-11 13:24       ` [PATCH 2/2] drm/gma500: Remove unused function declaration Daniel Vetter
  2013-12-18  1:04       ` [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer Dave Airlie
  0 siblings, 2 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 13:24 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

This was hidden in a generic void * dev->mm_private. But only ever
used for gem. But thanks to this fake generic pretension no one
noticed that Rob's drm drivers are now all broken.

So just give the offset manager a type pointer and fix up msm, omapdrm
and tilcdc.

v2: Fixup compile fail.

v3: Fixup rebase fail that David spotted.

Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_gem.c              | 27 ++++++++++++---------------
 drivers/gpu/drm/msm/msm_drv.c          |  2 +-
 drivers/gpu/drm/omapdrm/omap_debugfs.c |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c    |  2 +-
 include/drm/drmP.h                     |  9 +--------
 5 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4761adedad2a..32525b0a473a 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -91,19 +91,19 @@
 int
 drm_gem_init(struct drm_device *dev)
 {
-	struct drm_gem_mm *mm;
+	struct drm_vma_offset_manager *vma_offset_manager;
 
 	mutex_init(&dev->object_name_lock);
 	idr_init(&dev->object_name_idr);
 
-	mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL);
-	if (!mm) {
+	vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
+	if (!vma_offset_manager) {
 		DRM_ERROR("out of memory\n");
 		return -ENOMEM;
 	}
 
-	dev->mm_private = mm;
-	drm_vma_offset_manager_init(&mm->vma_manager,
+	dev->vma_offset_manager = vma_offset_manager;
+	drm_vma_offset_manager_init(vma_offset_manager,
 				    DRM_FILE_PAGE_OFFSET_START,
 				    DRM_FILE_PAGE_OFFSET_SIZE);
 
@@ -113,11 +113,10 @@ drm_gem_init(struct drm_device *dev)
 void
 drm_gem_destroy(struct drm_device *dev)
 {
-	struct drm_gem_mm *mm = dev->mm_private;
 
-	drm_vma_offset_manager_destroy(&mm->vma_manager);
-	kfree(mm);
-	dev->mm_private = NULL;
+	drm_vma_offset_manager_destroy(dev->vma_offset_manager);
+	kfree(dev->vma_offset_manager);
+	dev->vma_offset_manager = NULL;
 }
 
 /**
@@ -374,9 +373,8 @@ void
 drm_gem_free_mmap_offset(struct drm_gem_object *obj)
 {
 	struct drm_device *dev = obj->dev;
-	struct drm_gem_mm *mm = dev->mm_private;
 
-	drm_vma_offset_remove(&mm->vma_manager, &obj->vma_node);
+	drm_vma_offset_remove(dev->vma_offset_manager, &obj->vma_node);
 }
 EXPORT_SYMBOL(drm_gem_free_mmap_offset);
 
@@ -398,9 +396,8 @@ int
 drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)
 {
 	struct drm_device *dev = obj->dev;
-	struct drm_gem_mm *mm = dev->mm_private;
 
-	return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node,
+	return drm_vma_offset_add(dev->vma_offset_manager, &obj->vma_node,
 				  size / PAGE_SIZE);
 }
 EXPORT_SYMBOL(drm_gem_create_mmap_offset_size);
@@ -833,7 +830,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 {
 	struct drm_file *priv = filp->private_data;
 	struct drm_device *dev = priv->minor->dev;
-	struct drm_gem_mm *mm = dev->mm_private;
 	struct drm_gem_object *obj;
 	struct drm_vma_offset_node *node;
 	int ret = 0;
@@ -843,7 +839,8 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 
 	mutex_lock(&dev->struct_mutex);
 
-	node = drm_vma_offset_exact_lookup(&mm->vma_manager, vma->vm_pgoff,
+	node = drm_vma_offset_exact_lookup(dev->vma_offset_manager,
+					   vma->vm_pgoff,
 					   vma_pages(vma));
 	if (!node) {
 		mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 233246641ae9..177169ce01f0 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -415,7 +415,7 @@ static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
 
 static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
 {
-	return drm_mm_dump_table(m, dev->mm_private);
+	return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c b/drivers/gpu/drm/omapdrm/omap_debugfs.c
index c27f59da7f29..d4c04d69fc4d 100644
--- a/drivers/gpu/drm/omapdrm/omap_debugfs.c
+++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c
@@ -48,7 +48,7 @@ static int mm_show(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
-	return drm_mm_dump_table(m, dev->mm_private);
+	return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static int fb_show(struct seq_file *m, void *arg)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 4fad1efbce03..b20b69488dc9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -444,7 +444,7 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
-	return drm_mm_dump_table(m, dev->mm_private);
+	return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
 }
 
 static struct drm_info_list tilcdc_debugfs_list[] = {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 3b946beba2e0..79208fc135cc 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -601,13 +601,6 @@ struct drm_ati_pcigart_info {
 };
 
 /**
- * GEM specific mm private for tracking GEM objects
- */
-struct drm_gem_mm {
-	struct drm_vma_offset_manager vma_manager;
-};
-
-/**
  * This structure defines the drm_mm memory object, which will be used by the
  * DRM for its buffer objects.
  */
@@ -1156,7 +1149,6 @@ struct drm_device {
 	struct drm_sg_mem *sg;	/**< Scatter gather memory */
 	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
 	void *dev_private;		/**< device private data */
-	void *mm_private;
 	struct address_space *dev_mapping;
 	struct drm_sigdata sigdata;	   /**< For block_all_signals */
 	sigset_t sigmask;
@@ -1174,6 +1166,7 @@ struct drm_device {
 	/*@{ */
 	struct mutex object_name_lock;
 	struct idr object_name_idr;
+	struct drm_vma_offset_manager *vma_offset_manager;
 	/*@} */
 	int switch_power_state;
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH 2/2] drm/gma500: Remove unused function declaration
  2013-12-11 13:24     ` [PATCH 1/2] " Daniel Vetter
@ 2013-12-11 13:24       ` Daniel Vetter
  2013-12-11 16:04         ` Patrik Jakobsson
  2013-12-18  1:04       ` [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer Dave Airlie
  1 sibling, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-11 13:24 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/gma500/psb_intel_drv.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
index bde27fdb41bf..dc2c8eb030fa 100644
--- a/drivers/gpu/drm/gma500/psb_intel_drv.h
+++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
@@ -250,11 +250,6 @@ extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
 extern int intelfb_probe(struct drm_device *dev);
 extern int intelfb_remove(struct drm_device *dev,
 			  struct drm_framebuffer *fb);
-extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
-							*dev, struct
-							drm_mode_fb_cmd
-							*mode_cmd,
-							void *mm_private);
 extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
 				      const struct drm_display_mode *mode,
 				      struct drm_display_mode *adjusted_mode);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* Re: [PATCH 2/2] drm/gma500: Remove unused function declaration
  2013-12-11 13:24       ` [PATCH 2/2] drm/gma500: Remove unused function declaration Daniel Vetter
@ 2013-12-11 16:04         ` Patrik Jakobsson
  0 siblings, 0 replies; 79+ messages in thread
From: Patrik Jakobsson @ 2013-12-11 16:04 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 2:24 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/gma500/psb_intel_drv.h | 5 -----
>  1 file changed, 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
> index bde27fdb41bf..dc2c8eb030fa 100644
> --- a/drivers/gpu/drm/gma500/psb_intel_drv.h
> +++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
> @@ -250,11 +250,6 @@ extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector,
>  extern int intelfb_probe(struct drm_device *dev);
>  extern int intelfb_remove(struct drm_device *dev,
>                           struct drm_framebuffer *fb);
> -extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device
> -                                                       *dev, struct
> -                                                       drm_mode_fb_cmd
> -                                                       *mode_cmd,
> -                                                       void *mm_private);
>  extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
>                                       const struct drm_display_mode *mode,
>                                       struct drm_display_mode *adjusted_mode);
> --
> 1.8.4.3
>

Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH] drm/omap: call drm_put_dev directly in ->remove
  2013-12-11 13:20     ` [PATCH] " Daniel Vetter
@ 2013-12-11 19:35       ` Rob Clark
  0 siblings, 0 replies; 79+ messages in thread
From: Rob Clark @ 2013-12-11 19:35 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 8:20 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Again omap already sets the driver data pointer to the drm_device.
>
> v2: Don't rip out the platform_driver_unregister call for omap_dmm_driver.
> Pesky difference between drm and dmm ...
>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

looks better, thanks

Reviewed-by: Rob Clark <robdclark@gmail.com>


> ---
>  drivers/gpu/drm/omapdrm/omap_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index e7fa3cd96743..7be34b7d06f2 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -665,7 +665,7 @@ static int pdev_probe(struct platform_device *device)
>  static int pdev_remove(struct platform_device *device)
>  {
>         DBG("");
> -       drm_platform_exit(&omap_drm_driver, device);
> +       drm_put_dev(platform_get_drvdata(device));
>
>         platform_driver_unregister(&omap_dmm_driver);
>         return 0;
> --
> 1.8.4.3
>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 08/50] drm/msm: call drm_put_dev directly in ->remove
  2013-12-11 10:34 ` [PATCH 08/50] drm/msm: call drm_put_dev directly " Daniel Vetter
@ 2013-12-11 19:38   ` Rob Clark
  0 siblings, 0 replies; 79+ messages in thread
From: Rob Clark @ 2013-12-11 19:38 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 5:34 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> The drvdata pointer is already assigned to something useful.
>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  drivers/gpu/drm/msm/msm_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 86537692e45c..aa5f3546bbec 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -783,7 +783,7 @@ static int msm_pdev_probe(struct platform_device *pdev)
>
>  static int msm_pdev_remove(struct platform_device *pdev)
>  {
> -       drm_platform_exit(&msm_driver, pdev);
> +       drm_put_dev(platform_get_drvdata(pdev));
>
>         return 0;
>  }
> --
> 1.8.4.3
>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 04/50] drm/tilcdc: call drm_put_dev directly from ->remove
  2013-12-11 10:34 ` [PATCH 04/50] drm/tilcdc: call drm_put_dev directly from ->remove Daniel Vetter
@ 2013-12-11 19:39   ` Rob Clark
  0 siblings, 0 replies; 79+ messages in thread
From: Rob Clark @ 2013-12-11 19:39 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 5:34 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> tilcdc already stores the drm_device in the driver data pointer. So
> use that.
>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 116da199b942..e6d77d02e444 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -594,7 +594,7 @@ static int tilcdc_pdev_probe(struct platform_device *pdev)
>
>  static int tilcdc_pdev_remove(struct platform_device *pdev)
>  {
> -       drm_platform_exit(&tilcdc_driver, pdev);
> +       drm_put_dev(platform_get_drvdata(pdev));
>
>         return 0;
>  }
> --
> 1.8.4.3
>

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank
  2013-12-11 10:34 ` [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank Daniel Vetter
@ 2013-12-12 11:29   ` Thierry Reding
  2013-12-12 12:51     ` Daniel Vetter
  2013-12-16 10:30   ` [PATCH] " Daniel Vetter
  1 sibling, 1 reply; 79+ messages in thread
From: Thierry Reding @ 2013-12-12 11:29 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development


[-- Attachment #1.1: Type: text/plain, Size: 1649 bytes --]

On Wed, Dec 11, 2013 at 11:34:50AM +0100, Daniel Vetter wrote:
> Checking for both an irq number _and_ whether it's enabled is
> redundant. Also this will breakd drivers which do their own irq
> management and just set dev->irq_enabled once the irq stuff is all set
> up.

I don't think it'll break such drivers because they shouldn't have
DRIVER_HAVE_IRQ set in the first place.

> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_irq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index c0c6bdedefef..85d88cadc543 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -1186,7 +1186,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>  	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))
> +		if (!dev->irq_enabled)

In fact, unbreaking drivers was one of the reasons I added this check a
few months back (see commit 03f6509df921 'drm: Allow vblank support
without DRIVER_HAVE_IRQ'). At the time I could've probably removed the
call to drm_dev_to_irq() as well.

I'm now thinking that perhaps we could remove the DRIVER_HAVE_IRQ check
altogether now, given how I've had to explicitly make the Tegra driver
set dev->irq_enabled since there are other places that require it to be
set (amongst other things the conditional wait further below in the
drm_wait_vblank() function). See commit 603f0cc9482e 'drm/tegra:
Explicitly set irq_enabled'.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock
  2013-12-11 10:34 ` [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock Daniel Vetter
@ 2013-12-12 11:33   ` Thierry Reding
  2013-12-12 12:52     ` Daniel Vetter
  2013-12-16 10:29   ` [PATCH] " Daniel Vetter
  1 sibling, 1 reply; 79+ messages in thread
From: Thierry Reding @ 2013-12-12 11:33 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development


[-- Attachment #1.1: Type: text/plain, Size: 385 bytes --]

On Wed, Dec 11, 2013 at 11:34:57AM +0100, Daniel Vetter wrote:
[...]
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
[...]
> @@ -1118,6 +1118,8 @@ struct drm_device {
>  	/** \name Context support */
>  	/*@{ */
>  	bool irq_enabled;		/**< True if irq handler is enabled */
> +	int irq;

This probably should be in a different patch. I think it belongs in
patch 37/50.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank
  2013-12-12 11:29   ` Thierry Reding
@ 2013-12-12 12:51     ` Daniel Vetter
  0 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-12 12:51 UTC (permalink / raw)
  To: Thierry Reding; +Cc: DRI Development

On Thu, Dec 12, 2013 at 12:29 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> On Wed, Dec 11, 2013 at 11:34:50AM +0100, Daniel Vetter wrote:
>> Checking for both an irq number _and_ whether it's enabled is
>> redundant. Also this will breakd drivers which do their own irq
>> management and just set dev->irq_enabled once the irq stuff is all set
>> up.
>
> I don't think it'll break such drivers because they shouldn't have
> DRIVER_HAVE_IRQ set in the first place.

Hm right.

>> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> ---
>>  drivers/gpu/drm/drm_irq.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
>> index c0c6bdedefef..85d88cadc543 100644
>> --- a/drivers/gpu/drm/drm_irq.c
>> +++ b/drivers/gpu/drm/drm_irq.c
>> @@ -1186,7 +1186,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>>       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))
>> +             if (!dev->irq_enabled)
>
> In fact, unbreaking drivers was one of the reasons I added this check a
> few months back (see commit 03f6509df921 'drm: Allow vblank support
> without DRIVER_HAVE_IRQ'). At the time I could've probably removed the
> call to drm_dev_to_irq() as well.
>
> I'm now thinking that perhaps we could remove the DRIVER_HAVE_IRQ check
> altogether now, given how I've had to explicitly make the Tegra driver
> set dev->irq_enabled since there are other places that require it to be
> set (amongst other things the conditional wait further below in the
> drm_wait_vblank() function). See commit 603f0cc9482e 'drm/tegra:
> Explicitly set irq_enabled'.

Yeah, I think I'll respin the patch and also drop the HAVE_IRQ check -
this function here really should only care about dev->irq_enabled. And
even that is kinda just a curtesy to dri1 drivers, for kms drivers
interrupt support should always be available for vblank. Of course the
driver can internally enabel/disable the vblank source on demand (like
e.g. i915 does). I'll respin the patch.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock
  2013-12-12 11:33   ` Thierry Reding
@ 2013-12-12 12:52     ` Daniel Vetter
  0 siblings, 0 replies; 79+ messages in thread
From: Daniel Vetter @ 2013-12-12 12:52 UTC (permalink / raw)
  To: Thierry Reding; +Cc: DRI Development

On Thu, Dec 12, 2013 at 12:33 PM, Thierry Reding
<thierry.reding@gmail.com> wrote:
>> @@ -1118,6 +1118,8 @@ struct drm_device {
>>       /** \name Context support */
>>       /*@{ */
>>       bool irq_enabled;               /**< True if irq handler is enabled */
>> +     int irq;
>
> This probably should be in a different patch. I think it belongs in
> patch 37/50.

Oops indeed that hunk escaped. I'll respin both patches.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 00/50] more drm de-midlayering
  2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
                   ` (49 preceding siblings ...)
  2013-12-11 10:35 ` [PATCH 50/50] drm: use memdup_user() as a cleanup Daniel Vetter
@ 2013-12-12 18:08 ` Jakob Bornecrantz
  50 siblings, 0 replies; 79+ messages in thread
From: Jakob Bornecrantz @ 2013-12-12 18:08 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

The vmwgfx changes are:
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>

On Wed, Dec 11, 2013 at 11:34 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Hi all,
>
> This series almost removes drm_bus, the last thing remaining is the ->setversion
> callback. Unfortunately we can't kill that completely since we need the
> backwards compat cruft for pci domain bonghits on alpha/ppc.
>
> I've also shot at a few easy marks on the road while at it.
>
> My plan is to tackle the setversion mess in 3.15 with a Gross Hack. And then
> convert a few drivers to allocate struct drm_device themselves and so complete
> the demidlayering in the driver load paths. For simplicity that'd probably be
> udl or the arm drivers due to lack of legacy baggage. That should allow us to
> ditch drm_usb.c and drm_platform.c from the tree.
>
> My real long-term goal is to eventually use devres.c and similar cool stuff to
> clean up the setup/teardown hell we have in i915.ko. Hence also why I've
> deprecated the legacy agp/ums support in i915 in the hope that I'll get to deal
> with less cruft. Also maybe we can sort out the lifetime issues around sysfs and
> debugfs at driver/module unload time eventually ... just let me dream ;-)
>
> Also a cleanup from Dan on top. All the little fixes for Wu Fengguang reported are
> squashed in - he's now also doing some arm builds!
>
> Dan Carpenter (1):
>   drm: use memdup_user() as a cleanup
>
> Daniel Vetter (49):
>   drm/rcar: call drm_put_dev directly in the ->remove hook
>   drm/exynos: call drm_put_dev directly from ->remove
>   drm/imx: directly call drm_put_dev in ->remove
>   drm/tilcdc: call drm_put_dev directly from ->remove
>   drm/omap: call drm_put_dev directly in ->remove
>   drm/shmob: call drm_put_dev directly from ->remove hook
>   drm/armada: directly call drm_put_dev in ->remove
>   drm/msm: call drm_put_dev directly in ->remove
>   drm: rip out drm_platform_exit
>   drm: restrict the device list for shadow attached drivers
>   drm/bufs: remove handling of _DRM_GEM mappings
>   drm: kill DRIVER_REQUIRE_AGP
>   drm: ->agp_init can't fail
>   drm: rip out drm_core_has_AGP
>   drm: remove agp_init() bus callback
>   drm: inline drm_agp_destroy
>   drm: kill the ->agp_destroy callback
>   drm: remove global_mutex locking around agp_init
>   drm: rip out DRM_AGP_MEM and DRM_AGP_KERN
>   drm: Kill DRM_HZ
>   drm: Kill DRM_IRQ_ARGS
>   drm: Kill DRM_WAKUP and DRM_INIT_WAITQUEUE
>   drm: Kill DRM_COPY_(TO|FROM)_USER
>   drm: Kill DRM_*MEMORYBARRIER
>   drm: Kill DRM_SUSER
>   drm/gma500: Remove dead code
>   drm/irq: Replace DRM_WAIT_ON with wait_event
>   drm: Remove DRM_WAIT_ON from all drivers
>   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
>   drm: store the gem vma offset manager in a typed pointer
>   drm: rip out dev->ioctl_count tracking
>   drm: Kill file_priv->ioctl_count tracking
>   drm: remove dev->vma_count
>
>  Documentation/DocBook/drm.tmpl           |  10 +--
>  drivers/gpu/drm/armada/armada_drv.c      |   5 +-
>  drivers/gpu/drm/ast/ast_drv.c            |   1 -
>  drivers/gpu/drm/cirrus/cirrus_drv.h      |   2 +-
>  drivers/gpu/drm/drm_agpsupport.c         |  28 ++-----
>  drivers/gpu/drm/drm_buffer.c             |   2 +-
>  drivers/gpu/drm/drm_bufs.c               |  42 +++++-----
>  drivers/gpu/drm/drm_drv.c                |   4 -
>  drivers/gpu/drm/drm_fops.c               |  11 +--
>  drivers/gpu/drm/drm_gem.c                |  27 +++----
>  drivers/gpu/drm/drm_info.c               |  22 +++---
>  drivers/gpu/drm/drm_ioctl.c              |  13 +--
>  drivers/gpu/drm/drm_irq.c                | 125 +++++++++++------------------
>  drivers/gpu/drm/drm_memory.c             |  15 ++--
>  drivers/gpu/drm/drm_pci.c                | 132 ++++++++++++++++---------------
>  drivers/gpu/drm/drm_platform.c           |  37 ---------
>  drivers/gpu/drm/drm_stub.c               |  25 +-----
>  drivers/gpu/drm/drm_usb.c                |  15 ----
>  drivers/gpu/drm/drm_vm.c                 |  10 +--
>  drivers/gpu/drm/exynos/exynos_drm_drv.c  |   4 +-
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c |   2 +-
>  drivers/gpu/drm/exynos/exynos_mixer.c    |   6 +-
>  drivers/gpu/drm/gma500/accel_2d.c        |   2 +-
>  drivers/gpu/drm/gma500/psb_drv.c         |   2 +-
>  drivers/gpu/drm/gma500/psb_drv.h         |   8 +-
>  drivers/gpu/drm/gma500/psb_intel_drv.h   |   5 --
>  drivers/gpu/drm/gma500/psb_irq.c         |  19 +----
>  drivers/gpu/drm/gma500/psb_irq.h         |   2 +-
>  drivers/gpu/drm/i810/i810_dma.c          |   4 +
>  drivers/gpu/drm/i810/i810_drv.c          |   2 +-
>  drivers/gpu/drm/i915/i915_dma.c          |  31 ++++++--
>  drivers/gpu/drm/i915/i915_drv.c          |  14 ++--
>  drivers/gpu/drm/i915/i915_gem.c          |   7 +-
>  drivers/gpu/drm/mga/mga_dma.c            |   4 +-
>  drivers/gpu/drm/mga/mga_drv.h            |   4 +-
>  drivers/gpu/drm/mga/mga_irq.c            |  18 +++--
>  drivers/gpu/drm/mga/mga_state.c          |   4 +-
>  drivers/gpu/drm/msm/msm_drv.c            |   8 +-
>  drivers/gpu/drm/nouveau/nouveau_dma.c    |   2 +-
>  drivers/gpu/drm/nouveau/nouveau_dma.h    |   2 +-
>  drivers/gpu/drm/nouveau/nouveau_fence.c  |   2 +-
>  drivers/gpu/drm/nouveau/nouveau_gem.c    |   4 +-
>  drivers/gpu/drm/nouveau/nouveau_vga.c    |   7 +-
>  drivers/gpu/drm/omapdrm/omap_debugfs.c   |   2 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c       |   4 +-
>  drivers/gpu/drm/omapdrm/omap_drv.h       |   2 +-
>  drivers/gpu/drm/omapdrm/omap_irq.c       |   4 +-
>  drivers/gpu/drm/qxl/qxl_drv.c            |   1 -
>  drivers/gpu/drm/qxl/qxl_drv.h            |   2 +-
>  drivers/gpu/drm/qxl/qxl_ioctl.c          |   4 +-
>  drivers/gpu/drm/qxl/qxl_irq.c            |   4 +-
>  drivers/gpu/drm/r128/r128_cce.c          |   4 +-
>  drivers/gpu/drm/r128/r128_drv.h          |   4 +-
>  drivers/gpu/drm/r128/r128_irq.c          |   2 +-
>  drivers/gpu/drm/r128/r128_state.c        |  68 ++++++----------
>  drivers/gpu/drm/radeon/r300_cmdbuf.c     |   8 +-
>  drivers/gpu/drm/radeon/r600_cp.c         |   4 +-
>  drivers/gpu/drm/radeon/r600_cs.c         |   2 +-
>  drivers/gpu/drm/radeon/radeon_cp.c       |   6 +-
>  drivers/gpu/drm/radeon/radeon_cs.c       |  10 +--
>  drivers/gpu/drm/radeon/radeon_device.c   |   7 +-
>  drivers/gpu/drm/radeon/radeon_drv.c      |   3 +-
>  drivers/gpu/drm/radeon/radeon_drv.h      |   2 +-
>  drivers/gpu/drm/radeon/radeon_irq.c      |  19 +++--
>  drivers/gpu/drm/radeon/radeon_irq_kms.c  |   6 +-
>  drivers/gpu/drm/radeon/radeon_kms.c      |  10 +--
>  drivers/gpu/drm/radeon/radeon_mem.c      |   2 +-
>  drivers/gpu/drm/radeon/radeon_ring.c     |   2 +-
>  drivers/gpu/drm/radeon/radeon_state.c    |  20 ++---
>  drivers/gpu/drm/radeon/radeon_ttm.c      |   2 +-
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c    |   4 +-
>  drivers/gpu/drm/savage/savage_bci.c      |  10 +--
>  drivers/gpu/drm/savage/savage_state.c    |   8 +-
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c |   6 +-
>  drivers/gpu/drm/sis/sis_mm.c             |   2 +-
>  drivers/gpu/drm/tegra/bus.c              |  12 ---
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   8 +-
>  drivers/gpu/drm/ttm/ttm_bo_util.c        |   2 +-
>  drivers/gpu/drm/via/via_dma.c            |  12 +--
>  drivers/gpu/drm/via/via_dmablit.c        |  39 +++++----
>  drivers/gpu/drm/via/via_drv.h            |   2 +-
>  drivers/gpu/drm/via/via_irq.c            |  21 +++--
>  drivers/gpu/drm/via/via_video.c          |  18 +++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |   2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |   2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_irq.c      |   2 +-
>  drivers/staging/imx-drm/imx-drm-core.c   |   4 +-
>  include/drm/drmP.h                       |  60 ++++----------
>  include/drm/drm_agpsupport.h             |  33 ++------
>  include/drm/drm_os_linux.h               |  61 --------------
>  include/uapi/drm/drm.h                   |   1 -
>  91 files changed, 485 insertions(+), 717 deletions(-)
>
> --
> 1.8.4.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* [PATCH] drm/irq: track the irq installed in drm_irq_install in dev->irq
  2013-12-11 10:34 ` [PATCH 37/50] drm/irq: track the irq installed in drm_irq_install in dev->irq Daniel Vetter
@ 2013-12-16 10:29   ` Daniel Vetter
  2013-12-16 11:17     ` Thierry Reding
  0 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-16 10:29 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

To 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).

Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 18 +++++++++++-------
 include/drm/drmP.h        |  2 ++
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 64fd3fcf958a..0d1aef32ef10 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -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;
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 386745913d2a..0219ceae5270 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1118,6 +1118,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 */
 	/*@} */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH] drm: rename dev->count_lock to dev->buf_lock
  2013-12-11 10:34 ` [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock Daniel Vetter
  2013-12-12 11:33   ` Thierry Reding
@ 2013-12-16 10:29   ` Daniel Vetter
  2013-12-16 11:17     ` Thierry Reding
  1 sibling, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-16 10:29 UTC (permalink / raw)
  To: DRI Development; +Cc: 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).

Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index edec31fe3fed..ef7f0199a0f1 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -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 * request
 	if (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))
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 6299c197bd6f..8de201fde4a6 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -441,7 +441,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);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ee65c25e25d3..386745913d2a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1079,7 +1079,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 */
 	/*@} */
 
@@ -1088,6 +1087,7 @@ struct drm_device {
 	int open_count;			/**< Outstanding files open, protected by drm_global_lock. */
 	atomic_t ioctl_count;		/**< Outstanding IOCTLs pending */
 	atomic_t vma_count;		/**< Outstanding vma areas open */
+	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 */
 	/*@} */
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* [PATCH] drm/irq: simplify irq checks in drm_wait_vblank
  2013-12-11 10:34 ` [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank Daniel Vetter
  2013-12-12 11:29   ` Thierry Reding
@ 2013-12-16 10:30   ` Daniel Vetter
  2013-12-16 11:18     ` Thierry Reding
  1 sibling, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-16 10:30 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Checking 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.

Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_irq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c0c6bdedefef..f83e72cd5215 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -1185,9 +1185,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;
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 79+ messages in thread

* Re: [PATCH] drm/irq: track the irq installed in drm_irq_install in dev->irq
  2013-12-16 10:29   ` [PATCH] " Daniel Vetter
@ 2013-12-16 11:17     ` Thierry Reding
  0 siblings, 0 replies; 79+ messages in thread
From: Thierry Reding @ 2013-12-16 11:17 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development


[-- Attachment #1.1: Type: text/plain, Size: 709 bytes --]

On Mon, Dec 16, 2013 at 11:29:13AM +0100, Daniel Vetter wrote:
> To 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).
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_irq.c | 18 +++++++++++-------
>  include/drm/drmP.h        |  2 ++
>  2 files changed, 13 insertions(+), 7 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH] drm: rename dev->count_lock to dev->buf_lock
  2013-12-16 10:29   ` [PATCH] " Daniel Vetter
@ 2013-12-16 11:17     ` Thierry Reding
  0 siblings, 0 replies; 79+ messages in thread
From: Thierry Reding @ 2013-12-16 11:17 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development


[-- Attachment #1.1: Type: text/plain, Size: 732 bytes --]

On Mon, Dec 16, 2013 at 11:29:42AM +0100, Daniel Vetter wrote:
> 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).
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  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(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH] drm/irq: simplify irq checks in drm_wait_vblank
  2013-12-16 10:30   ` [PATCH] " Daniel Vetter
@ 2013-12-16 11:18     ` Thierry Reding
  0 siblings, 0 replies; 79+ messages in thread
From: Thierry Reding @ 2013-12-16 11:18 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development


[-- Attachment #1.1: Type: text/plain, Size: 750 bytes --]

On Mon, Dec 16, 2013 at 11:30:13AM +0100, Daniel Vetter wrote:
> Checking 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.
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_irq.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer
  2013-12-11 13:24     ` [PATCH 1/2] " Daniel Vetter
  2013-12-11 13:24       ` [PATCH 2/2] drm/gma500: Remove unused function declaration Daniel Vetter
@ 2013-12-18  1:04       ` Dave Airlie
  2013-12-18  1:22         ` Rob Clark
  1 sibling, 1 reply; 79+ messages in thread
From: Dave Airlie @ 2013-12-18  1:04 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 11:24 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> This was hidden in a generic void * dev->mm_private. But only ever
> used for gem. But thanks to this fake generic pretension no one
> noticed that Rob's drm drivers are now all broken.

Should this go to fixes?

Or is the problem only introduced in this series?

Dave.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer
  2013-12-18  1:04       ` [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer Dave Airlie
@ 2013-12-18  1:22         ` Rob Clark
  0 siblings, 0 replies; 79+ messages in thread
From: Rob Clark @ 2013-12-18  1:22 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Daniel Vetter, DRI Development

On Tue, Dec 17, 2013 at 8:04 PM, Dave Airlie <airlied@gmail.com> wrote:
> On Wed, Dec 11, 2013 at 11:24 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> This was hidden in a generic void * dev->mm_private. But only ever
>> used for gem. But thanks to this fake generic pretension no one
>> noticed that Rob's drm drivers are now all broken.
>
> Should this go to fixes?

I think should go in fixes probably.. wasn't it broken since vma
offset mgr?  I guess I don't test debugfs enough.

oh, and:

Signed-off-by: Rob Clark <robdclark@gmail.com>

(sorry, overlooked this thread earlier, even though I think Daniel
mentioned the issue on irc)

> Or is the problem only introduced in this series?
>
> Dave.
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers
  2013-12-11 10:34 ` [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers Daniel Vetter
@ 2013-12-18  1:39   ` Dave Airlie
  2013-12-18  8:25     ` Daniel Vetter
  0 siblings, 1 reply; 79+ messages in thread
From: Dave Airlie @ 2013-12-18  1:39 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 8:34 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Since this is all old ums stuff (including the one in the radeon
> driver) I've just tried to perfectly replicate the existing semantics.
>
> Reinventing wait queue code with semantics that differ from all the
> standard linux wait functions is just hairy, so now we can get rid of
> this and so make sure it'll never again be used.
>
> Oh and: via futexes ... *shudder*

This one worries me, I've had numerous attempts to rip this out in the
past and they always changed semantics on some devices and broke
stuff.

The sneaky timeout is essential for a lot of the hardware

http://marc.info/?l=dri-devel&m=111383274225047&w=1

So I think I'd like a few more people to review this one before I go
near it again :-)

Dave.

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers
  2013-12-18  1:39   ` Dave Airlie
@ 2013-12-18  8:25     ` Daniel Vetter
  2013-12-18  9:37       ` Thomas Hellstrom
  0 siblings, 1 reply; 79+ messages in thread
From: Daniel Vetter @ 2013-12-18  8:25 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Daniel Vetter, Thomas Hellstrom, DRI Development

On Wed, Dec 18, 2013 at 11:39:27AM +1000, Dave Airlie wrote:
> On Wed, Dec 11, 2013 at 8:34 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > Since this is all old ums stuff (including the one in the radeon
> > driver) I've just tried to perfectly replicate the existing semantics.
> >
> > Reinventing wait queue code with semantics that differ from all the
> > standard linux wait functions is just hairy, so now we can get rid of
> > this and so make sure it'll never again be used.
> >
> > Oh and: via futexes ... *shudder*
> 
> This one worries me, I've had numerous attempts to rip this out in the
> past and they always changed semantics on some devices and broke
> stuff.
> 
> The sneaky timeout is essential for a lot of the hardware
> 
> http://marc.info/?l=dri-devel&m=111383274225047&w=1
> 
> So I think I'd like a few more people to review this one before I go
> near it again :-)

Oh, and I've thought the only tricky stuff is mapping the errno's
correctly. I think if we have such cases of racy drivers then the right
thing to do is to shovel this macro into drivers and slap a big comment
about signalling races on top of that code.

Thomas report doesn't say so, but I guess it's for via. Thomas, do you
still have a vague recollection of what this has been about?

Dave, do you want me to just respin this one with via left as-is (and the
macro pushed into the via driver)?

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers
  2013-12-18  8:25     ` Daniel Vetter
@ 2013-12-18  9:37       ` Thomas Hellstrom
  0 siblings, 0 replies; 79+ messages in thread
From: Thomas Hellstrom @ 2013-12-18  9:37 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, DRI Development

On 12/18/2013 09:25 AM, Daniel Vetter wrote:
> On Wed, Dec 18, 2013 at 11:39:27AM +1000, Dave Airlie wrote:
>> On Wed, Dec 11, 2013 at 8:34 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>>> Since this is all old ums stuff (including the one in the radeon
>>> driver) I've just tried to perfectly replicate the existing semantics.
>>>
>>> Reinventing wait queue code with semantics that differ from all the
>>> standard linux wait functions is just hairy, so now we can get rid of
>>> this and so make sure it'll never again be used.
>>>
>>> Oh and: via futexes ... *shudder*
>> This one worries me, I've had numerous attempts to rip this out in the
>> past and they always changed semantics on some devices and broke
>> stuff.
>>
>> The sneaky timeout is essential for a lot of the hardware
>>
>> https://urldefense.proofpoint.com/v1/url?u=http://marc.info/?l%3Ddri-devel%26m%3D111383274225047%26w%3D1&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=l5Ago9ekmVFZ3c4M6eauqrJWGwjf6fTb%2BP3CxbBFkVM%3D%0A&m=wgfMdGK1q8n48mRclOyEBEeb4OB1u5PwhRxswGxwjGY%3D%0A&s=6e87c42702c679927c4e0fab27ef8874b2a22707cb860f0de000df4798199e63
>>
>> So I think I'd like a few more people to review this one before I go
>> near it again :-)
> Oh, and I've thought the only tricky stuff is mapping the errno's
> correctly. I think if we have such cases of racy drivers then the right
> thing to do is to shovel this macro into drivers and slap a big comment
> about signalling races on top of that code.
>
> Thomas report doesn't say so, but I guess it's for via. Thomas, do you
> still have a vague recollection of what this has been about?

Yes, this was with via, but IIRC there were other drivers affected as well,
but OTOH, I think the kernel wait code was fixed for races some time
after that....

/Thomas





>
> Dave, do you want me to just respin this one with via left as-is (and the
> macro pushed into the via driver)?
>
> Thanks, Daniel

^ permalink raw reply	[flat|nested] 79+ messages in thread

* Re: [PATCH 45/50] drm/<drivers>: don't set driver->dev_priv_size to 0
  2013-12-11 10:35 ` [PATCH 45/50] drm/<drivers>: don't set driver->dev_priv_size to 0 Daniel Vetter
@ 2014-01-10 15:25   ` Damien Lespiau
  0 siblings, 0 replies; 79+ messages in thread
From: Damien Lespiau @ 2014-01-10 15:25 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Dec 11, 2013 at 11:35:06AM +0100, Daniel Vetter wrote:
> Especially not on modesetting drivers - this is used to size
> the driver private structure for legacy drm buffers.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

I managed to write the same patch one month later, so:

Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>

-- 
Damien

> ---
>  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(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index 5137f15dba19..2ba39ac7d222 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -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,
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index fee8748bdca5..6e936634d65c 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -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,
>  
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index f6f30b9e9ff5..a16e56325bfd 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -522,7 +522,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,
> -- 
> 1.8.4.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 79+ messages in thread

end of thread, other threads:[~2014-01-10 15:25 UTC | newest]

Thread overview: 79+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-11 10:34 [PATCH 00/50] more drm de-midlayering Daniel Vetter
2013-12-11 10:34 ` [PATCH 01/50] drm/rcar: call drm_put_dev directly in the ->remove hook Daniel Vetter
2013-12-11 10:34 ` [PATCH 02/50] drm/exynos: call drm_put_dev directly from ->remove Daniel Vetter
2013-12-11 10:34 ` [PATCH 03/50] drm/imx: directly call drm_put_dev in ->remove Daniel Vetter
2013-12-11 10:34 ` [PATCH 04/50] drm/tilcdc: call drm_put_dev directly from ->remove Daniel Vetter
2013-12-11 19:39   ` Rob Clark
2013-12-11 10:34 ` [PATCH 05/50] drm/omap: call drm_put_dev directly in ->remove Daniel Vetter
2013-12-11 12:02   ` Rob Clark
2013-12-11 13:20     ` [PATCH] " Daniel Vetter
2013-12-11 19:35       ` Rob Clark
2013-12-11 10:34 ` [PATCH 06/50] drm/shmob: call drm_put_dev directly from ->remove hook Daniel Vetter
2013-12-11 12:21   ` Laurent Pinchart
2013-12-11 10:34 ` [PATCH 07/50] drm/armada: directly call drm_put_dev in ->remove Daniel Vetter
2013-12-11 10:34 ` [PATCH 08/50] drm/msm: call drm_put_dev directly " Daniel Vetter
2013-12-11 19:38   ` Rob Clark
2013-12-11 10:34 ` [PATCH 09/50] drm: rip out drm_platform_exit Daniel Vetter
2013-12-11 10:34 ` [PATCH 10/50] drm: restrict the device list for shadow attached drivers Daniel Vetter
2013-12-11 10:34 ` [PATCH 11/50] drm/bufs: remove handling of _DRM_GEM mappings Daniel Vetter
2013-12-11 10:34 ` [PATCH 12/50] drm: kill DRIVER_REQUIRE_AGP Daniel Vetter
2013-12-11 10:34 ` [PATCH 13/50] drm: ->agp_init can't fail Daniel Vetter
2013-12-11 10:34 ` [PATCH 14/50] drm: rip out drm_core_has_AGP Daniel Vetter
2013-12-11 10:34 ` [PATCH 15/50] drm: remove agp_init() bus callback Daniel Vetter
2013-12-11 10:34 ` [PATCH 16/50] drm: inline drm_agp_destroy Daniel Vetter
2013-12-11 10:34 ` [PATCH 17/50] drm: kill the ->agp_destroy callback Daniel Vetter
2013-12-11 10:34 ` [PATCH 18/50] drm: remove global_mutex locking around agp_init Daniel Vetter
2013-12-11 10:34 ` [PATCH 19/50] drm: rip out DRM_AGP_MEM and DRM_AGP_KERN Daniel Vetter
2013-12-11 10:34 ` [PATCH 20/50] drm: Kill DRM_HZ Daniel Vetter
2013-12-11 10:34 ` [PATCH 21/50] drm: Kill DRM_IRQ_ARGS Daniel Vetter
2013-12-11 10:34 ` [PATCH 22/50] drm: Kill DRM_WAKUP and DRM_INIT_WAITQUEUE Daniel Vetter
2013-12-11 10:34 ` [PATCH 23/50] drm: Kill DRM_COPY_(TO|FROM)_USER Daniel Vetter
2013-12-11 10:34 ` [PATCH 24/50] drm: Kill DRM_*MEMORYBARRIER Daniel Vetter
2013-12-11 10:34 ` [PATCH 25/50] drm: Kill DRM_SUSER Daniel Vetter
2013-12-11 10:34 ` [PATCH 26/50] drm/gma500: Remove dead code Daniel Vetter
2013-12-11 10:46   ` Patrik Jakobsson
2013-12-11 10:34 ` [PATCH 27/50] drm/irq: Replace DRM_WAIT_ON with wait_event Daniel Vetter
2013-12-11 10:34 ` [PATCH 28/50] drm: Remove DRM_WAIT_ON from all drivers Daniel Vetter
2013-12-18  1:39   ` Dave Airlie
2013-12-18  8:25     ` Daniel Vetter
2013-12-18  9:37       ` Thomas Hellstrom
2013-12-11 10:34 ` [PATCH 29/50] drm/irq: simplify irq checks in drm_wait_vblank Daniel Vetter
2013-12-12 11:29   ` Thierry Reding
2013-12-12 12:51     ` Daniel Vetter
2013-12-16 10:30   ` [PATCH] " Daniel Vetter
2013-12-16 11:18     ` Thierry Reding
2013-12-11 10:34 ` [PATCH 30/50] drm/pci: fold in irq_by_busid support Daniel Vetter
2013-12-11 10:34 ` [PATCH 31/50] drm/irq: drm_control is a legacy ioctl, so pci devices only Daniel Vetter
2013-12-11 10:34 ` [PATCH 32/50] drm/irq: remove cargo-culted locking from irq_install/unistall Daniel Vetter
2013-12-11 10:34 ` [PATCH 33/50] drm: remove drm_dev_to_irq from drivers Daniel Vetter
2013-12-11 10:34 ` [PATCH 34/50] drm: kill drm_bus->bus_type Daniel Vetter
2013-12-11 10:34 ` [PATCH 35/50] drm: Rip out totally bogus vga_switcheroo->can_switch locking Daniel Vetter
2013-12-11 10:34 ` [PATCH 36/50] drm: rename dev->count_lock to dev->buf_lock Daniel Vetter
2013-12-12 11:33   ` Thierry Reding
2013-12-12 12:52     ` Daniel Vetter
2013-12-16 10:29   ` [PATCH] " Daniel Vetter
2013-12-16 11:17     ` Thierry Reding
2013-12-11 10:34 ` [PATCH 37/50] drm/irq: track the irq installed in drm_irq_install in dev->irq Daniel Vetter
2013-12-16 10:29   ` [PATCH] " Daniel Vetter
2013-12-16 11:17     ` Thierry Reding
2013-12-11 10:34 ` [PATCH 38/50] drm/irq: Look up the pci irq directly in the drm_control ioctl Daniel Vetter
2013-12-11 10:35 ` [PATCH 39/50] drm: pass the irq explicitly to drm_irq_install Daniel Vetter
2013-12-11 10:35 ` [PATCH 40/50] drm: remove bus->get_irq implementations Daniel Vetter
2013-12-11 10:35 ` [PATCH 41/50] drm: inline drm_pci_set_unique Daniel Vetter
2013-12-11 10:35 ` [PATCH 42/50] drm: rip out dev->devname Daniel Vetter
2013-12-11 10:35 ` [PATCH 43/50] drm: remove drm_bus->get_name Daniel Vetter
2013-12-11 10:35 ` [PATCH 44/50] drm: Remove dev->kdriver Daniel Vetter
2013-12-11 10:35 ` [PATCH 45/50] drm/<drivers>: don't set driver->dev_priv_size to 0 Daniel Vetter
2014-01-10 15:25   ` Damien Lespiau
2013-12-11 10:35 ` [PATCH 46/50] drm: store the gem vma offset manager in a typed pointer Daniel Vetter
2013-12-11 10:53   ` David Herrmann
2013-12-11 13:24     ` [PATCH 1/2] " Daniel Vetter
2013-12-11 13:24       ` [PATCH 2/2] drm/gma500: Remove unused function declaration Daniel Vetter
2013-12-11 16:04         ` Patrik Jakobsson
2013-12-18  1:04       ` [PATCH 1/2] drm: store the gem vma offset manager in a typed pointer Dave Airlie
2013-12-18  1:22         ` Rob Clark
2013-12-11 10:35 ` [PATCH 47/50] drm: rip out dev->ioctl_count tracking Daniel Vetter
2013-12-11 10:35 ` [PATCH 48/50] drm: Kill file_priv->ioctl_count tracking Daniel Vetter
2013-12-11 10:35 ` [PATCH 49/50] drm: remove dev->vma_count Daniel Vetter
2013-12-11 10:35 ` [PATCH 50/50] drm: use memdup_user() as a cleanup Daniel Vetter
2013-12-12 18:08 ` [PATCH 00/50] more drm de-midlayering Jakob Bornecrantz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.