All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/39] clean out drm cruft and hide it better for kms drivers
@ 2013-07-10 12:11 Daniel Vetter
  2013-07-10 12:11 ` [PATCH 01/39] drm: remove drm_modctx ioctl and use drm_noop instead Daniel Vetter
                   ` (41 more replies)
  0 siblings, 42 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Hi all,

I've figured that it's again time for a bit of (late) drm spring cleanup. This
series here consists of a pile of "rip old stuff out" patches interleaved with
"disable old cruft for kms drivers and hide it better".

Comments, flames and review highly welcome. I'd be especially happy if the arm
guys could check whether I haven't badly broken their drivers - compile-testing
arm is a pita, so I haven't yet done that.

There's a few driver-wide patches included, but the more invasive ones (i.e.
changing more than the drm driver vtable) are split out per-driver for easier
merging. If no one screams my plan is to rebase this pile on top of -rc1, give
it some more testing (check arm, ugh) and then send a pull request to Dave.
That should reduce interference with ongoing driver work as much as possible I
hope.

My drm cruft todo list still has a pile of ideas, but I've figured I need to
stop now for 3.12. For those interested further cleanups could include:

- setversion/set_busid: All drm core version 1.1 is legacy cruft, kms drivers
  should never run in this mode. We could clean up the setversion ioclt (and
  move the drm core version handling into a legacy function) and set up the bus
  id unconditionally at driver load time.

- There's a few more legacy ioctls/subsystems that could be blocked out for kms
  drivers (but the required git history digging tends to be tedious). Also I
  think we could more aggressively move legacy cruft setup/teardown code
  out-of-line from the main code by extracting it into drm_legacy_ functions
  (like this series here already does for the context and dma stuff).

- I think creating a drm_internal.h header for functions not exported to drivers
  would be useful. That way we could move all the legacy functions out of drmP.h
  (which are a lot of them), which should make it much clearer what the real drm
  driver interface actually is.

- drm_os_linux.h should just die in fire.

- There's a pile of needless indirection around our agp handling, we duplicate
  the agp core's CONFIG_AGP=n no-oping function handling in large parts, among
  other stuff.

- The drm coherent dma alloc helpers could get ripped out, at least for kms
  drivers. For ums drivers there's some funny cases where this mapping is
  exchanged with userspace for e.g. register access. In a least one case
  (i810.ko) userspace even sets up that mapping, which allows it to crash the
  kernel at will (since those maps aren't refcounted). Maybe we need to shovel
  those interfaces into a drm_legacy.ko module to keep them around but make sure
  that no new driver even thinks about using them.

- There's also the matter of the vblank support code, imo that should be split
  int a ums and a kms part. That'd would allow us to use struct drm_crtc * in
  interfaces and proper locking (by grabbing crtc->mutex to exclude races with
  dpms/modesets).

If anyone wants to dig around in those areas please poke me.

Cheers, Daniel

Daniel Vetter (39):
  drm: remove drm_modctx ioctl and use drm_noop instead
  drm: kill dev->context_wait
  drm: remove dev->last_switch
  drm: kill dev->interrupt_flag and dev->dma_flag
  drm: kill dev->ctx_start and dev->lck_start
  drm/radoen: kill radeon_dma_ioctl_kms
  drm: kill dev->buf_readers and dev->buf_writers
  drm: remove redundant clears from drm_setup
  drm/omap: kill firstopen callback
  drm/radeon: kill firstopen callback for kms driver
  drm/imx: kill firstopen callback
  drm/vmwgfx: remove ->firstopen callback
  drm: don't call ->firstopen for KMS drivers
  drm: kill dev->driver->set_version
  drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver
  drm: fold in drm_sg_alloc into the ioctl
  drm: hide legacy sg cleanup better from common code
  drm: disallow legacy sg ioctls for modesetting drivers
  drm: mark dma setup/teardown as legacy systems
  drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG
  drm: disallow legacy dma ioctls for modesetting drivers
  drm: move drm_getsarea into drm_bufs.c
  drm/bufs: s/drm_order/order_base_2/
  drm/r128: s/drm_order/order_base_2/
  drm/radeon: s/drm_order/order_base_2/
  drm: remove drm_order
  drm: mark context support as a legacy subsystem
  drm/vmwgfx: remove redundant clearing of driver->dma_quiescent
  drm: remove FASYNC support
  drm: rip out DRIVER_FB_DMA and related code
  drm: rip out a few unused DRIVER flags
  drm: remove a bunch of unused #defines from drmP.h
  drm: rip out drm_core_has_MTRR checks
  drm: remove the dma_ioctl special-case
  drm/memory: don't export agp helpers
  drm: hollow-out GET_CLIENT ioctl
  drm: no-op out GET_STATS ioctl
  drm: fix locking in gem debugfs/procfs file
  drm: remove procfs code, take 2

 drivers/gpu/drm/Makefile                 |   2 +-
 drivers/gpu/drm/ast/ast_drv.c            |   1 -
 drivers/gpu/drm/cirrus/cirrus_drv.c      |   1 -
 drivers/gpu/drm/drm_bufs.c               | 238 +++++++------------------------
 drivers/gpu/drm/drm_context.c            |  81 ++++++++---
 drivers/gpu/drm/drm_dma.c                |  17 ++-
 drivers/gpu/drm/drm_drv.c                |  44 +-----
 drivers/gpu/drm/drm_fops.c               |  66 +--------
 drivers/gpu/drm/drm_info.c               |   4 +
 drivers/gpu/drm/drm_ioctl.c              |  43 +-----
 drivers/gpu/drm/drm_memory.c             |   2 -
 drivers/gpu/drm/drm_pci.c                |  11 +-
 drivers/gpu/drm/drm_proc.c               | 209 ---------------------------
 drivers/gpu/drm/drm_scatter.c            |  29 ++--
 drivers/gpu/drm/drm_stub.c               |  44 ++----
 drivers/gpu/drm/drm_vm.c                 |   3 +-
 drivers/gpu/drm/gma500/psb_drv.c         |   3 +-
 drivers/gpu/drm/i810/i810_dma.c          |   1 -
 drivers/gpu/drm/i810/i810_drv.c          |   1 -
 drivers/gpu/drm/i915/i915_drv.c          |   1 -
 drivers/gpu/drm/mga/mga_drv.c            |   1 -
 drivers/gpu/drm/mgag200/mgag200_drv.c    |   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c    |   3 +-
 drivers/gpu/drm/omapdrm/omap_drv.c       |   8 --
 drivers/gpu/drm/qxl/qxl_drv.c            |   1 -
 drivers/gpu/drm/r128/r128_cce.c          |   2 +-
 drivers/gpu/drm/r128/r128_drv.c          |   1 -
 drivers/gpu/drm/radeon/cik.c             |  14 +-
 drivers/gpu/drm/radeon/evergreen.c       |   4 +-
 drivers/gpu/drm/radeon/ni.c              |   6 +-
 drivers/gpu/drm/radeon/r100.c            |   2 +-
 drivers/gpu/drm/radeon/r600.c            |  14 +-
 drivers/gpu/drm/radeon/r600_cp.c         |   6 +-
 drivers/gpu/drm/radeon/radeon_cp.c       |   6 +-
 drivers/gpu/drm/radeon/radeon_drv.c      |  11 +-
 drivers/gpu/drm/radeon/radeon_kms.c      |  23 ---
 drivers/gpu/drm/radeon/si.c              |  14 +-
 drivers/gpu/drm/savage/savage_drv.c      |   1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |   1 -
 drivers/gpu/drm/sis/sis_drv.c            |   1 -
 drivers/gpu/drm/tdfx/tdfx_drv.c          |   1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   1 -
 drivers/gpu/drm/udl/udl_drv.c            |   1 -
 drivers/gpu/drm/via/via_drv.c            |   1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  20 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |   1 -
 drivers/gpu/host1x/drm/drm.c             |   1 -
 drivers/staging/imx-drm/imx-drm-core.c   |  20 +--
 include/drm/drmP.h                       |  65 ++-------
 49 files changed, 239 insertions(+), 793 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c

-- 
1.8.3.2

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

* [PATCH 01/39] drm: remove drm_modctx ioctl and use drm_noop instead
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 02/39] drm: kill dev->context_wait Daniel Vetter
                   ` (40 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

It doesn't do anything, so kill the code.

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

diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 725968d..6f9731f 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -342,12 +342,6 @@ int drm_addctx(struct drm_device *dev, void *data,
 	return 0;
 }
 
-int drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
-{
-	/* This does nothing */
-	return 0;
-}
-
 /**
  * Get context.
  *
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 99fcd7c..d668011 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -87,7 +87,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 
 	DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 12083dc..523e5f2 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1335,8 +1335,6 @@ extern int drm_resctx(struct drm_device *dev, void *data,
 		      struct drm_file *file_priv);
 extern int drm_addctx(struct drm_device *dev, void *data,
 		      struct drm_file *file_priv);
-extern int drm_modctx(struct drm_device *dev, void *data,
-		      struct drm_file *file_priv);
 extern int drm_getctx(struct drm_device *dev, void *data,
 		      struct drm_file *file_priv);
 extern int drm_switchctx(struct drm_device *dev, void *data,
-- 
1.8.3.2

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

* [PATCH 02/39] drm: kill dev->context_wait
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
  2013-07-10 12:11 ` [PATCH 01/39] drm: remove drm_modctx ioctl and use drm_noop instead Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 03/39] drm: remove dev->last_switch Daniel Vetter
                   ` (39 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

No one ever waits on this waitqueue, so the wake_up call is wasted.
Remove it all.

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

diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 6f9731f..5cc17f3 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -261,7 +261,6 @@ static int drm_context_switch_complete(struct drm_device *dev,
 	   when the kernel holds the lock, release
 	   that lock here. */
 	clear_bit(0, &dev->context_flag);
-	wake_up(&dev->context_wait);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 3a24385..0dcbbdb 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -81,7 +81,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->last_context = 0;
 	dev->last_switch = 0;
 	dev->last_checked = 0;
-	init_waitqueue_head(&dev->context_wait);
 	dev->if_version = 0;
 
 	dev->ctx_start = 0;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 523e5f2..4499133 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1133,7 +1133,6 @@ struct drm_device {
 	__volatile__ long context_flag;	/**< Context swapping flag */
 	__volatile__ long interrupt_flag; /**< Interruption handler flag */
 	__volatile__ long dma_flag;	/**< DMA dispatch flag */
-	wait_queue_head_t context_wait;	/**< Processes waiting on ctx switch */
 	int last_checked;		/**< Last context checked for DMA */
 	int last_context;		/**< Last current context */
 	unsigned long last_switch;	/**< jiffies at last context switch */
-- 
1.8.3.2

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

* [PATCH 03/39] drm: remove dev->last_switch
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
  2013-07-10 12:11 ` [PATCH 01/39] drm: remove drm_modctx ioctl and use drm_noop instead Daniel Vetter
  2013-07-10 12:11 ` [PATCH 02/39] drm: kill dev->context_wait Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 04/39] drm: kill dev->interrupt_flag and dev->dma_flag Daniel Vetter
                   ` (38 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Only ever assigned in the context code for real, with no readers
anywhere. Remove it.

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

diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 5cc17f3..224ff96 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -251,7 +251,6 @@ static int drm_context_switch_complete(struct drm_device *dev,
 				       struct drm_file *file_priv, int new)
 {
 	dev->last_context = new;	/* PRE/POST: This is the _only_ writer. */
-	dev->last_switch = jiffies;
 
 	if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) {
 		DRM_ERROR("Lock isn't held after context switch\n");
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 0dcbbdb..c14fdc1 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -79,7 +79,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->interrupt_flag = 0;
 	dev->dma_flag = 0;
 	dev->last_context = 0;
-	dev->last_switch = 0;
 	dev->last_checked = 0;
 	dev->if_version = 0;
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 4499133..089e820 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1135,7 +1135,6 @@ struct drm_device {
 	__volatile__ long dma_flag;	/**< DMA dispatch flag */
 	int last_checked;		/**< Last context checked for DMA */
 	int last_context;		/**< Last current context */
-	unsigned long last_switch;	/**< jiffies at last context switch */
 	/*@} */
 
 	struct work_struct work;
-- 
1.8.3.2

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

* [PATCH 04/39] drm: kill dev->interrupt_flag and dev->dma_flag
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (2 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 03/39] drm: remove dev->last_switch Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 05/39] drm: kill dev->ctx_start and dev->lck_start Daniel Vetter
                   ` (37 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Completely unused, so just remove them.

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

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index c14fdc1..386c304 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -76,8 +76,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->sigdata.lock = NULL;
 
 	dev->context_flag = 0;
-	dev->interrupt_flag = 0;
-	dev->dma_flag = 0;
 	dev->last_context = 0;
 	dev->last_checked = 0;
 	dev->if_version = 0;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 089e820..1ec806f 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1131,8 +1131,6 @@ struct drm_device {
 	/*@{ */
 	int irq_enabled;		/**< True if irq handler is enabled */
 	__volatile__ long context_flag;	/**< Context swapping flag */
-	__volatile__ long interrupt_flag; /**< Interruption handler flag */
-	__volatile__ long dma_flag;	/**< DMA dispatch flag */
 	int last_checked;		/**< Last context checked for DMA */
 	int last_context;		/**< Last current context */
 	/*@} */
-- 
1.8.3.2

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

* [PATCH 05/39] drm: kill dev->ctx_start and dev->lck_start
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (3 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 04/39] drm: kill dev->interrupt_flag and dev->dma_flag Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 06/39] drm/radoen: kill radeon_dma_ioctl_kms Daniel Vetter
                   ` (36 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again completely unused, so just remove it.

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

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 386c304..a3714a0 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -80,9 +80,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->last_checked = 0;
 	dev->if_version = 0;
 
-	dev->ctx_start = 0;
-	dev->lck_start = 0;
-
 	dev->buf_async = NULL;
 	init_waitqueue_head(&dev->buf_readers);
 	init_waitqueue_head(&dev->buf_writers);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1ec806f..0403695 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1170,8 +1170,6 @@ struct drm_device {
 	spinlock_t event_lock;
 
 	/*@} */
-	cycles_t ctx_start;
-	cycles_t lck_start;
 
 	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
 	wait_queue_head_t buf_readers;	/**< Processes waiting to read */
-- 
1.8.3.2

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

* [PATCH 06/39] drm/radoen: kill radeon_dma_ioctl_kms
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (4 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 05/39] drm: kill dev->ctx_start and dev->lck_start Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 07/39] drm: kill dev->buf_readers and dev->buf_writers Daniel Vetter
                   ` (35 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

No need to create a dummy ioctl function to return -EINVAL, since
that's what the core already does in the absence of the dma_ioctl
callback. So we can safely remove this.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/radeon/radeon_drv.c |  3 ---
 drivers/gpu/drm/radeon/radeon_kms.c | 10 ----------
 2 files changed, 13 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index e5419b3..c07b681 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -101,8 +101,6 @@ 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);
-int radeon_dma_ioctl_kms(struct drm_device *dev, void *data,
-			 struct drm_file *file_priv);
 int radeon_gem_object_init(struct drm_gem_object *obj);
 void radeon_gem_object_free(struct drm_gem_object *obj);
 int radeon_gem_object_open(struct drm_gem_object *obj,
@@ -417,7 +415,6 @@ static struct drm_driver kms_driver = {
 	.gem_free_object = radeon_gem_object_free,
 	.gem_open_object = radeon_gem_object_open,
 	.gem_close_object = radeon_gem_object_close,
-	.dma_ioctl = radeon_dma_ioctl_kms,
 	.dumb_create = radeon_mode_dumb_create,
 	.dumb_map_offset = radeon_mode_dumb_mmap,
 	.dumb_destroy = radeon_mode_dumb_destroy,
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 49ff3d1..07b0236 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -683,16 +683,6 @@ int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
 						     drmcrtc);
 }
 
-/*
- * IOCTL.
- */
-int radeon_dma_ioctl_kms(struct drm_device *dev, void *data,
-			 struct drm_file *file_priv)
-{
-	/* Not valid in KMS. */
-	return -EINVAL;
-}
-
 #define KMS_INVALID_IOCTL(name)						\
 int name(struct drm_device *dev, void *data, struct drm_file *file_priv)\
 {									\
-- 
1.8.3.2

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

* [PATCH 07/39] drm: kill dev->buf_readers and dev->buf_writers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (5 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 06/39] drm/radoen: kill radeon_dma_ioctl_kms Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 08/39] drm: remove redundant clears from drm_setup Daniel Vetter
                   ` (34 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again totally unused, so just remove them.

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

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index a3714a0..57e3014 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -81,8 +81,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->if_version = 0;
 
 	dev->buf_async = NULL;
-	init_waitqueue_head(&dev->buf_readers);
-	init_waitqueue_head(&dev->buf_writers);
 
 	DRM_DEBUG("\n");
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0403695..6cde924 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1172,8 +1172,6 @@ struct drm_device {
 	/*@} */
 
 	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
-	wait_queue_head_t buf_readers;	/**< Processes waiting to read */
-	wait_queue_head_t buf_writers;	/**< Processes waiting to ctx switch */
 
 	struct drm_agp_head *agp;	/**< AGP data */
 
-- 
1.8.3.2

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

* [PATCH 08/39] drm: remove redundant clears from drm_setup
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (6 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 07/39] drm: kill dev->buf_readers and dev->buf_writers Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 13:28   ` David Herrmann
  2013-07-10 12:11 ` [PATCH 09/39] drm/omap: kill firstopen callback Daniel Vetter
                   ` (33 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

We kzalloc the driver node at init time, so no need to do this again.

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

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 57e3014..9610997 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -73,15 +73,6 @@ static int drm_setup(struct drm_device * dev)
 	for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
 		atomic_set(&dev->counts[i], 0);
 
-	dev->sigdata.lock = NULL;
-
-	dev->context_flag = 0;
-	dev->last_context = 0;
-	dev->last_checked = 0;
-	dev->if_version = 0;
-
-	dev->buf_async = NULL;
-
 	DRM_DEBUG("\n");
 
 	/*
-- 
1.8.3.2

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

* [PATCH 09/39] drm/omap: kill firstopen callback
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (7 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 08/39] drm: remove redundant clears from drm_setup Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 10/39] drm/radeon: kill firstopen callback for kms driver Daniel Vetter
                   ` (32 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

KMS drivers really shouldn't need to do anything on firstopen, so kill
empty callbacks.

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

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 826586f..3f7c78a 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -509,12 +509,6 @@ static int dev_open(struct drm_device *dev, struct drm_file *file)
 	return 0;
 }
 
-static int dev_firstopen(struct drm_device *dev)
-{
-	DBG("firstopen: dev=%p", dev);
-	return 0;
-}
-
 /**
  * lastclose - clean up after all DRM clients have exited
  * @dev: DRM device
@@ -594,7 +588,6 @@ static struct drm_driver omap_drm_driver = {
 		.load = dev_load,
 		.unload = dev_unload,
 		.open = dev_open,
-		.firstopen = dev_firstopen,
 		.lastclose = dev_lastclose,
 		.preclose = dev_preclose,
 		.postclose = dev_postclose,
-- 
1.8.3.2

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

* [PATCH 10/39] drm/radeon: kill firstopen callback for kms driver
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (8 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 09/39] drm/omap: kill firstopen callback Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 11/39] drm/imx: kill firstopen callback Daniel Vetter
                   ` (31 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again, it does nothing.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/radeon/radeon_drv.c |  2 --
 drivers/gpu/drm/radeon/radeon_kms.c | 13 -------------
 2 files changed, 15 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index c07b681..1c2584f 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -81,7 +81,6 @@
 #define KMS_DRIVER_PATCHLEVEL	0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
-int radeon_driver_firstopen_kms(struct drm_device *dev);
 void radeon_driver_lastclose_kms(struct drm_device *dev);
 int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv);
 void radeon_driver_postclose_kms(struct drm_device *dev,
@@ -389,7 +388,6 @@ static struct drm_driver kms_driver = {
 	    DRIVER_PRIME,
 	.dev_priv_size = 0,
 	.load = radeon_driver_load_kms,
-	.firstopen = radeon_driver_firstopen_kms,
 	.open = radeon_driver_open_kms,
 	.preclose = radeon_driver_preclose_kms,
 	.postclose = radeon_driver_postclose_kms,
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 07b0236..bd6f1e8 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -449,19 +449,6 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
  * Outdated mess for old drm with Xorg being in charge (void function now).
  */
 /**
- * radeon_driver_firstopen_kms - drm callback for first open
- *
- * @dev: drm dev pointer
- *
- * Nothing to be done for KMS (all asics).
- * Returns 0 on success.
- */
-int radeon_driver_firstopen_kms(struct drm_device *dev)
-{
-	return 0;
-}
-
-/**
  * radeon_driver_firstopen_kms - drm callback for last close
  *
  * @dev: drm dev pointer
-- 
1.8.3.2

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

* [PATCH 11/39] drm/imx: kill firstopen callback
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (9 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 10/39] drm/radeon: kill firstopen callback for kms driver Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 12/39] drm/vmwgfx: remove ->firstopen callback Daniel Vetter
                   ` (30 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Greg Kroah-Hartman

This thing seems to do some kind of delayed setup. Really, real kms
drivers shouldn't do that at all. Either stuff needs to be dynamically
hotplugged or the driver setup sequence needs to be fixed.

This patch here just moves the setup at the very end of the driver
load callback, with the locking adjusted accordingly.

v2: Also move the corresponding put from ->lastclose to ->unload.

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

diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 6455305..70f9650 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -69,28 +69,20 @@ struct imx_drm_connector {
 	struct module				*owner;
 };
 
-static int imx_drm_driver_firstopen(struct drm_device *drm)
-{
-	if (!imx_drm_device_get())
-		return -EINVAL;
-
-	return 0;
-}
-
 static void imx_drm_driver_lastclose(struct drm_device *drm)
 {
 	struct imx_drm_device *imxdrm = drm->dev_private;
 
 	if (imxdrm->fbhelper)
 		drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
-
-	imx_drm_device_put();
 }
 
 static int imx_drm_driver_unload(struct drm_device *drm)
 {
 	struct imx_drm_device *imxdrm = drm->dev_private;
 
+	imx_drm_device_put();
+
 	drm_mode_config_cleanup(imxdrm->drm);
 	drm_kms_helper_poll_fini(imxdrm->drm);
 
@@ -226,8 +218,6 @@ struct drm_device *imx_drm_device_get(void)
 	struct imx_drm_connector *con;
 	struct imx_drm_crtc *crtc;
 
-	mutex_lock(&imxdrm->mutex);
-
 	list_for_each_entry(enc, &imxdrm->encoder_list, list) {
 		if (!try_module_get(enc->owner)) {
 			dev_err(imxdrm->dev, "could not get module %s\n",
@@ -254,8 +244,6 @@ struct drm_device *imx_drm_device_get(void)
 
 	imxdrm->references++;
 
-	mutex_unlock(&imxdrm->mutex);
-
 	return imxdrm->drm;
 
 unwind_crtc:
@@ -447,6 +435,9 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
 	 */
 	imxdrm->drm->vblank_disable_allowed = 1;
 
+	if (!imx_drm_device_get())
+		ret = -EINVAL;
+
 	ret = 0;
 
 err_init:
@@ -794,7 +785,6 @@ static struct drm_driver imx_drm_driver = {
 	.driver_features	= DRIVER_MODESET | DRIVER_GEM,
 	.load			= imx_drm_driver_load,
 	.unload			= imx_drm_driver_unload,
-	.firstopen		= imx_drm_driver_firstopen,
 	.lastclose		= imx_drm_driver_lastclose,
 	.gem_free_object	= drm_gem_cma_free_object,
 	.gem_vm_ops		= &drm_gem_cma_vm_ops,
-- 
1.8.3.2

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

* [PATCH 12/39] drm/vmwgfx: remove ->firstopen callback
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (10 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 11/39] drm/imx: kill firstopen callback Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 13/39] drm: don't call ->firstopen for KMS drivers Daniel Vetter
                   ` (29 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

So if we survey kms drivers there's a bunch of things they commonly do
in ->lastclose
- delayed processing of vga switcheroo requests (i915, nouveau,
  radeon)
- force-restoring the fbcon (most)
- resetting a bunch properties to make fbcon work better (omap)
- disabling all outputs (vmwgfx)

In short besides the semantically important vga switcheroo stuff they
all try very hard to keep fbcon working in case X dies.

But none of them try to not do this at driver unload time safe for
vmwgfx, and digging through logs I couldn't find any reason for why
vmwgfx is special.

Since ->firstopen has lots of potential for abuse with kms drivers
(like delaying driver setup to pamper over races in the load sequence)
it's imo very much worth it to remove this logic so that we can
stop using the ->firstopen callback for kms drivers.

Also module unloading is rather a debug feature and developers should
know how to restore the display to a sane configuration.

Cc: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 18 ------------------
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  1 -
 2 files changed, 19 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 78e2164..3e43578 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -795,29 +795,12 @@ static long vmw_unlocked_ioctl(struct file *filp, unsigned int cmd,
 	return drm_ioctl(filp, cmd, arg);
 }
 
-static int vmw_firstopen(struct drm_device *dev)
-{
-	struct vmw_private *dev_priv = vmw_priv(dev);
-	dev_priv->is_opened = true;
-
-	return 0;
-}
-
 static void vmw_lastclose(struct drm_device *dev)
 {
-	struct vmw_private *dev_priv = vmw_priv(dev);
 	struct drm_crtc *crtc;
 	struct drm_mode_set set;
 	int ret;
 
-	/**
-	 * Do nothing on the lastclose call from drm_unload.
-	 */
-
-	if (!dev_priv->is_opened)
-		return;
-
-	dev_priv->is_opened = false;
 	set.x = 0;
 	set.y = 0;
 	set.fb = NULL;
@@ -1132,7 +1115,6 @@ static struct drm_driver driver = {
 	DRIVER_MODESET,
 	.load = vmw_driver_load,
 	.unload = vmw_driver_unload,
-	.firstopen = vmw_firstopen,
 	.lastclose = vmw_lastclose,
 	.irq_preinstall = vmw_irq_preinstall,
 	.irq_postinstall = vmw_irq_postinstall,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 13aeda7..150ec64 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -324,7 +324,6 @@ struct vmw_private {
 	 */
 
 	bool stealth;
-	bool is_opened;
 	bool enable_fb;
 
 	/**
-- 
1.8.3.2

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

* [PATCH 13/39] drm: don't call ->firstopen for KMS drivers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (11 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 12/39] drm/vmwgfx: remove ->firstopen callback Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 18:17   ` [PATCH] " Daniel Vetter
  2013-07-10 12:11 ` [PATCH 14/39] drm: kill dev->driver->set_version Daniel Vetter
                   ` (28 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

It has way too much potential for driver writers to do stupid things
like delayed hw setup because the load sequence is somehow racy (e.g.
the imx driver in staging). So don't call it for modesetting drivers,
which reduces the complexity of the drm core -> driver interface a
notch.

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

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 9610997..ad58d32 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
 	int i;
 	int ret;
 
-	if (dev->driver->firstopen) {
+	if (dev->driver->firstopen &&
+	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = dev->driver->firstopen(dev);
 		if (ret != 0)
 			return ret;
-- 
1.8.3.2

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

* [PATCH 14/39] drm: kill dev->driver->set_version
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (12 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 13/39] drm: don't call ->firstopen for KMS drivers Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 15/39] drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver Daniel Vetter
                   ` (27 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Totally unused, so just rip it out. Anyway, we want drivers to be
fully backwards compatible, allowing them to change behaviour is just
a recipe for them to break badly.

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

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ffd7a7b..0acf080 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -352,9 +352,6 @@ int drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_pri
 			retcode = -EINVAL;
 			goto done;
 		}
-
-		if (dev->driver->set_version)
-			dev->driver->set_version(dev, sv);
 	}
 
 done:
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 6cde924..4a3b23f 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -885,8 +885,6 @@ struct drm_driver {
 	void (*irq_preinstall) (struct drm_device *dev);
 	int (*irq_postinstall) (struct drm_device *dev);
 	void (*irq_uninstall) (struct drm_device *dev);
-	void (*set_version) (struct drm_device *dev,
-			     struct drm_set_version *sv);
 
 	/* Master routines */
 	int (*master_create)(struct drm_device *dev, struct drm_master *master);
-- 
1.8.3.2

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

* [PATCH 15/39] drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (13 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 14/39] drm: kill dev->driver->set_version Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 16/39] drm: fold in drm_sg_alloc into the ioctl Daniel Vetter
                   ` (26 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Really, this is all old-style stuff and just copy-pasta from the
ums driver.

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

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 1c2584f..81b9baa 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -383,8 +383,8 @@ static const struct file_operations radeon_driver_kms_fops = {
 
 static struct drm_driver kms_driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
-	    DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_GEM |
+	    DRIVER_USE_AGP | DRIVER_USE_MTRR | 
+	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
 	    DRIVER_PRIME,
 	.dev_priv_size = 0,
 	.load = radeon_driver_load_kms,
-- 
1.8.3.2

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

* [PATCH 16/39] drm: fold in drm_sg_alloc into the ioctl
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (14 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 15/39] drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 17/39] drm: hide legacy sg cleanup better from common code Daniel Vetter
                   ` (25 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

There's no other caller from driver code, so we can fold this in.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_drv.c     |  2 +-
 drivers/gpu/drm/drm_scatter.c | 13 +++----------
 include/drm/drmP.h            |  3 +--
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index d668011..5993bfc 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -122,7 +122,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 #endif
 
-	DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, DRM_UNLOCKED),
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index d87f60b..a4a076f 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -70,8 +70,10 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
 # define ScatterHandle(x) (unsigned int)(x)
 #endif
 
-int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
+int drm_sg_alloc(struct drm_device *dev, void *data,
+		 struct drm_file *file_priv)
 {
+	struct drm_scatter_gather *request = data;
 	struct drm_sg_mem *entry;
 	unsigned long pages, i, j;
 
@@ -181,15 +183,6 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
 	return -ENOMEM;
 }
 
-int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
-		       struct drm_file *file_priv)
-{
-	struct drm_scatter_gather *request = data;
-
-	return drm_sg_alloc(dev, request);
-
-}
-
 int drm_sg_free(struct drm_device *dev, void *data,
 		struct drm_file *file_priv)
 {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 4a3b23f..fb03933 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1565,9 +1565,8 @@ extern int drm_vma_info(struct seq_file *m, void *data);
 
 				/* Scatter Gather Support (drm_scatter.h) */
 extern void drm_sg_cleanup(struct drm_sg_mem * entry);
-extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
+extern int drm_sg_alloc(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
-extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
 extern int drm_sg_free(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
-- 
1.8.3.2

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

* [PATCH 17/39] drm: hide legacy sg cleanup better from common code
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (15 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 16/39] drm: fold in drm_sg_alloc into the ioctl Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 18/39] drm: disallow legacy sg ioctls for modesetting drivers Daniel Vetter
                   ` (24 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

I've decided that some clear markers for what's legacy dri1/non-gem
code is useful. I've opted to use the drm_legacy prefix and then hide
all the checks in that function for better readability in the common
code.

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

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 5993bfc..4817546 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -216,11 +216,8 @@ int drm_lastclose(struct drm_device * dev)
 		dev->agp->acquired = 0;
 		dev->agp->enabled = 0;
 	}
-	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
-	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
-		drm_sg_cleanup(dev->sg);
-		dev->sg = NULL;
-	}
+
+	drm_legacy_sg_cleanup(dev);
 
 	/* Clear vma list (only built for debugging) */
 	list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index a4a076f..dd8a648 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -46,7 +46,7 @@ static inline void *drm_vmalloc_dma(unsigned long size)
 #endif
 }
 
-void drm_sg_cleanup(struct drm_sg_mem * entry)
+static void drm_sg_cleanup(struct drm_sg_mem * entry)
 {
 	struct page *page;
 	int i;
@@ -64,6 +64,14 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
 	kfree(entry);
 }
 
+void drm_legacy_sg_cleanup(struct drm_device *dev)
+{
+	if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg &&
+	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
+		drm_sg_cleanup(dev->sg);
+		dev->sg = NULL;
+	}
+}
 #ifdef _LP64
 # define ScatterHandle(x) (unsigned int)((x >> 32) + (x & ((1L << 32) - 1)))
 #else
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index fb03933..0fe9a08 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1564,7 +1564,7 @@ extern int drm_vma_info(struct seq_file *m, void *data);
 #endif
 
 				/* Scatter Gather Support (drm_scatter.h) */
-extern void drm_sg_cleanup(struct drm_sg_mem * entry);
+extern void drm_legacy_sg_cleanup(struct drm_device *dev);
 extern int drm_sg_alloc(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 extern int drm_sg_free(struct drm_device *dev, void *data,
-- 
1.8.3.2

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

* [PATCH 18/39] drm: disallow legacy sg ioctls for modesetting drivers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (16 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 17/39] drm: hide legacy sg cleanup better from common code Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 19/39] drm: mark dma setup/teardown as legacy systems Daniel Vetter
                   ` (23 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Only the radeon/r128/ati ums drivers use this. Furthermore the cleanup
was already only done for UMS drivers. Also a quick check of the ATI
ddx git history shows that only the UMS code ever used this facility.

So we can safely disallow these pair of ioctls for modesetting
drivers.

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

diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index dd8a648..1c78406 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -87,6 +87,9 @@ int drm_sg_alloc(struct drm_device *dev, void *data,
 
 	DRM_DEBUG("\n");
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_SG))
 		return -EINVAL;
 
@@ -197,6 +200,9 @@ int drm_sg_free(struct drm_device *dev, void *data,
 	struct drm_scatter_gather *request = data;
 	struct drm_sg_mem *entry;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_SG))
 		return -EINVAL;
 
-- 
1.8.3.2

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

* [PATCH 19/39] drm: mark dma setup/teardown as legacy systems
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (17 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 18/39] drm: disallow legacy sg ioctls for modesetting drivers Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 20/39] drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG Daniel Vetter
                   ` (22 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

And hide the checks a bit better. This was already disallowed for
modesetting drivers, so no functinal change here.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_dma.c  | 17 +++++++++++++++--
 drivers/gpu/drm/drm_drv.c  |  4 +---
 drivers/gpu/drm/drm_fops.c | 12 +++---------
 include/drm/drmP.h         |  4 ++--
 4 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
index 495b5fd..8a140a9 100644
--- a/drivers/gpu/drm/drm_dma.c
+++ b/drivers/gpu/drm/drm_dma.c
@@ -44,10 +44,18 @@
  *
  * Allocate and initialize a drm_device_dma structure.
  */
-int drm_dma_setup(struct drm_device *dev)
+int drm_legacy_dma_setup(struct drm_device *dev)
 {
 	int i;
 
+	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
+	    drm_core_check_feature(dev, DRIVER_MODESET)) {
+		return 0;
+	}
+
+	dev->buf_use = 0;
+	atomic_set(&dev->buf_alloc, 0);
+
 	dev->dma = kzalloc(sizeof(*dev->dma), GFP_KERNEL);
 	if (!dev->dma)
 		return -ENOMEM;
@@ -66,11 +74,16 @@ int drm_dma_setup(struct drm_device *dev)
  * Free all pages associated with DMA buffers, the buffers and pages lists, and
  * finally the drm_device::dma structure itself.
  */
-void drm_dma_takedown(struct drm_device *dev)
+void drm_legacy_dma_takedown(struct drm_device *dev)
 {
 	struct drm_device_dma *dma = dev->dma;
 	int i, j;
 
+	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
+	    drm_core_check_feature(dev, DRIVER_MODESET)) {
+		return;
+	}
+
 	if (!dma)
 		return;
 
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 4817546..5087cfb 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -225,9 +225,7 @@ int drm_lastclose(struct drm_device * dev)
 		kfree(vma);
 	}
 
-	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
-	    !drm_core_check_feature(dev, DRIVER_MODESET))
-		drm_dma_takedown(dev);
+	drm_legacy_dma_takedown(dev);
 
 	dev->dev_mapping = NULL;
 	mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index ad58d32..b293b60 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -61,15 +61,9 @@ static int drm_setup(struct drm_device * dev)
 	atomic_set(&dev->ioctl_count, 0);
 	atomic_set(&dev->vma_count, 0);
 
-	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
-	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
-		dev->buf_use = 0;
-		atomic_set(&dev->buf_alloc, 0);
-
-		i = drm_dma_setup(dev);
-		if (i < 0)
-			return i;
-	}
+	i = drm_legacy_dma_setup(dev);
+	if (i < 0)
+		return i;
 
 	for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
 		atomic_set(&dev->counts[i], 0);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0fe9a08..60307d1 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1396,8 +1396,8 @@ extern int drm_mapbufs(struct drm_device *dev, void *data,
 extern int drm_order(unsigned long size);
 
 				/* DMA support (drm_dma.h) */
-extern int drm_dma_setup(struct drm_device *dev);
-extern void drm_dma_takedown(struct drm_device *dev);
+extern int drm_legacy_dma_setup(struct drm_device *dev);
+extern void drm_legacy_dma_takedown(struct drm_device *dev);
 extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
 extern void drm_core_reclaim_buffers(struct drm_device *dev,
 				     struct drm_file *filp);
-- 
1.8.3.2

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

* [PATCH 20/39] drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (18 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 19/39] drm: mark dma setup/teardown as legacy systems Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 21/39] drm: disallow legacy dma ioctls for modesetting drivers Daniel Vetter
                   ` (21 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The former doesn't do anything without DRIVER_HAVE_DMA (which is
force-disabled for kms drivers anyway). The latter isn't used by the
(kms) nouveau ddx.

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

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 218a4b5..e990327 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -675,7 +675,7 @@ nouveau_driver_fops = {
 static struct drm_driver
 driver = {
 	.driver_features =
-		DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
+		DRIVER_USE_AGP |
 		DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME,
 
 	.load = nouveau_drm_load,
-- 
1.8.3.2

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

* [PATCH 21/39] drm: disallow legacy dma ioctls for modesetting drivers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (19 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 20/39] drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 22/39] drm: move drm_getsarea into drm_bufs.c Daniel Vetter
                   ` (20 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Now only legacy ums drivers have the DRIVER_HAVE_DMA driver feature
flag set, so strictly speaking the modesetting check is redundant. But
adding it has the upside that it makes it very clear that the dma
support is legacy stuff.

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

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 5a4dbb4..2e560c2 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1305,6 +1305,9 @@ int drm_addbufs(struct drm_device *dev, void *data,
 	struct drm_buf_desc *request = data;
 	int ret;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		return -EINVAL;
 
@@ -1348,6 +1351,9 @@ int drm_infobufs(struct drm_device *dev, void *data,
 	int i;
 	int count;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		return -EINVAL;
 
@@ -1427,6 +1433,9 @@ int drm_markbufs(struct drm_device *dev, void *data,
 	int order;
 	struct drm_buf_entry *entry;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		return -EINVAL;
 
@@ -1472,6 +1481,9 @@ int drm_freebufs(struct drm_device *dev, void *data,
 	int idx;
 	struct drm_buf *buf;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		return -EINVAL;
 
@@ -1524,6 +1536,9 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	struct drm_buf_map *request = data;
 	int i;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		return -EINVAL;
 
-- 
1.8.3.2

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

* [PATCH 22/39] drm: move drm_getsarea into drm_bufs.c
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (20 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 21/39] drm: disallow legacy dma ioctls for modesetting drivers Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 23/39] drm/bufs: s/drm_order/order_base_2/ Daniel Vetter
                   ` (19 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

It fiddles the sarea out of the maps which are also handled in
drm_bufs.c

With this drm_drv.c is a notch more legacy free.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_bufs.c | 14 ++++++++++++++
 drivers/gpu/drm/drm_drv.c  | 15 ---------------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 2e560c2..6a0ff32 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1615,6 +1615,20 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	return retcode;
 }
 
+struct drm_local_map *drm_getsarea(struct drm_device *dev)
+{
+	struct drm_map_list *entry;
+
+	list_for_each_entry(entry, &dev->maplist, head) {
+		if (entry->map && entry->map->type == _DRM_SHM &&
+		    (entry->map->flags & _DRM_CONTAINS_LOCK)) {
+			return entry->map;
+		}
+	}
+	return NULL;
+}
+EXPORT_SYMBOL(drm_getsarea);
+
 /**
  * Compute size order.  Returns the exponent of the smaller power of two which
  * is greater or equal to given number.
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 5087cfb..f2495e1 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -480,19 +480,4 @@ long drm_ioctl(struct file *filp,
 		DRM_DEBUG("ret = %d\n", retcode);
 	return retcode;
 }
-
 EXPORT_SYMBOL(drm_ioctl);
-
-struct drm_local_map *drm_getsarea(struct drm_device *dev)
-{
-	struct drm_map_list *entry;
-
-	list_for_each_entry(entry, &dev->maplist, head) {
-		if (entry->map && entry->map->type == _DRM_SHM &&
-		    (entry->map->flags & _DRM_CONTAINS_LOCK)) {
-			return entry->map;
-		}
-	}
-	return NULL;
-}
-EXPORT_SYMBOL(drm_getsarea);
-- 
1.8.3.2

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

* [PATCH 23/39] drm/bufs: s/drm_order/order_base_2/
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (21 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 22/39] drm: move drm_getsarea into drm_bufs.c Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 24/39] drm/r128: s/drm_order/order_base_2/ Daniel Vetter
                   ` (18 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The version offered by the core is ridiculously optimized and
does the same thing. So use it.

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

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 6a0ff32..31a971d 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -243,7 +243,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 		}
 		map->handle = vmalloc_user(map->size);
 		DRM_DEBUG("%lu %d %p\n",
-			  map->size, drm_order(map->size), map->handle);
+			  map->size, order_base_2(map->size), map->handle);
 		if (!map->handle) {
 			kfree(map);
 			return -ENOMEM;
@@ -630,7 +630,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
 		return -EINVAL;
 
 	count = request->count;
-	order = drm_order(request->size);
+	order = order_base_2(request->size);
 	size = 1 << order;
 
 	alignment = (request->flags & _DRM_PAGE_ALIGN)
@@ -800,7 +800,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
 		return -EPERM;
 
 	count = request->count;
-	order = drm_order(request->size);
+	order = order_base_2(request->size);
 	size = 1 << order;
 
 	DRM_DEBUG("count=%d, size=%d (%d), order=%d\n",
@@ -1002,7 +1002,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
 		return -EPERM;
 
 	count = request->count;
-	order = drm_order(request->size);
+	order = order_base_2(request->size);
 	size = 1 << order;
 
 	alignment = (request->flags & _DRM_PAGE_ALIGN)
@@ -1157,7 +1157,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
 		return -EPERM;
 
 	count = request->count;
-	order = drm_order(request->size);
+	order = order_base_2(request->size);
 	size = 1 << order;
 
 	alignment = (request->flags & _DRM_PAGE_ALIGN)
@@ -1444,7 +1444,7 @@ int drm_markbufs(struct drm_device *dev, void *data,
 
 	DRM_DEBUG("%d, %d, %d\n",
 		  request->size, request->low_mark, request->high_mark);
-	order = drm_order(request->size);
+	order = order_base_2(request->size);
 	if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
 		return -EINVAL;
 	entry = &dma->bufs[order];
-- 
1.8.3.2

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

* [PATCH 24/39] drm/r128: s/drm_order/order_base_2/
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (22 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 23/39] drm/bufs: s/drm_order/order_base_2/ Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:11 ` [PATCH 25/39] drm/radeon: s/drm_order/order_base_2/ Daniel Vetter
                   ` (17 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again just use the version provided by the linux core.

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

diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index d4660cf..c451257 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -540,7 +540,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
 	dev_priv->ring.end = ((u32 *) dev_priv->cce_ring->handle
 			      + init->ring_size / sizeof(u32));
 	dev_priv->ring.size = init->ring_size;
-	dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8);
+	dev_priv->ring.size_l2qw = order_base_2(init->ring_size / 8);
 
 	dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1;
 
-- 
1.8.3.2

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

* [PATCH 25/39] drm/radeon: s/drm_order/order_base_2/
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (23 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 24/39] drm/r128: s/drm_order/order_base_2/ Daniel Vetter
@ 2013-07-10 12:11 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 26/39] drm: remove drm_order Daniel Vetter
                   ` (16 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:11 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Last driver and pretty obviously a major user of this little function.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/radeon/cik.c       | 14 +++++++-------
 drivers/gpu/drm/radeon/evergreen.c |  4 ++--
 drivers/gpu/drm/radeon/ni.c        |  6 +++---
 drivers/gpu/drm/radeon/r100.c      |  2 +-
 drivers/gpu/drm/radeon/r600.c      | 14 +++++++-------
 drivers/gpu/drm/radeon/r600_cp.c   |  6 +++---
 drivers/gpu/drm/radeon/radeon_cp.c |  6 +++---
 drivers/gpu/drm/radeon/si.c        | 14 +++++++-------
 8 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index ed1d910..1a8aa89 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -2546,8 +2546,8 @@ static int cik_cp_gfx_resume(struct radeon_device *rdev)
 	/* ring 0 - compute and gfx */
 	/* Set ring buffer size */
 	ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
-	rb_bufsz = drm_order(ring->ring_size / 8);
-	tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
+	rb_bufsz = order_base_2(ring->ring_size / 8);
+	tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
 #ifdef __BIG_ENDIAN
 	tmp |= BUF_SWAP_32BIT;
 #endif
@@ -2926,7 +2926,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
 		/* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
 		tmp = RREG32(CP_HPD_EOP_CONTROL);
 		tmp &= ~EOP_SIZE_MASK;
-		tmp |= drm_order(MEC_HPD_SIZE / 8);
+		tmp |= order_base_2(MEC_HPD_SIZE / 8);
 		WREG32(CP_HPD_EOP_CONTROL, tmp);
 	}
 	cik_srbm_select(rdev, 0, 0, 0, 0);
@@ -3041,9 +3041,9 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
 			~(QUEUE_SIZE_MASK | RPTR_BLOCK_SIZE_MASK);
 
 		mqd->queue_state.cp_hqd_pq_control |=
-			drm_order(rdev->ring[idx].ring_size / 8);
+			order_base_2(rdev->ring[idx].ring_size / 8);
 		mqd->queue_state.cp_hqd_pq_control |=
-			(drm_order(RADEON_GPU_PAGE_SIZE/8) << 8);
+			(order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8);
 #ifdef __BIG_ENDIAN
 		mqd->queue_state.cp_hqd_pq_control |= BUF_SWAP_32BIT;
 #endif
@@ -3386,7 +3386,7 @@ static int cik_sdma_gfx_resume(struct radeon_device *rdev)
 		WREG32(SDMA0_SEM_WAIT_FAIL_TIMER_CNTL + reg_offset, 0);
 
 		/* Set ring buffer size in dwords */
-		rb_bufsz = drm_order(ring->ring_size / 4);
+		rb_bufsz = order_base_2(ring->ring_size / 4);
 		rb_cntl = rb_bufsz << 1;
 #ifdef __BIG_ENDIAN
 		rb_cntl |= SDMA_RB_SWAP_ENABLE | SDMA_RPTR_WRITEBACK_SWAP_ENABLE;
@@ -5018,7 +5018,7 @@ static int cik_irq_init(struct radeon_device *rdev)
 	WREG32(INTERRUPT_CNTL, interrupt_cntl);
 
 	WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8);
-	rb_bufsz = drm_order(rdev->ih.ring_size / 4);
+	rb_bufsz = order_base_2(rdev->ih.ring_size / 4);
 
 	ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE |
 		      IH_WPTR_OVERFLOW_CLEAR |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index e49059d..b4b5620 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2879,8 +2879,8 @@ static int evergreen_cp_resume(struct radeon_device *rdev)
 	RREG32(GRBM_SOFT_RESET);
 
 	/* Set ring buffer size */
-	rb_bufsz = drm_order(ring->ring_size / 8);
-	tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
+	rb_bufsz = order_base_2(ring->ring_size / 8);
+	tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
 #ifdef __BIG_ENDIAN
 	tmp |= BUF_SWAP_32BIT;
 #endif
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index f30127c..fd9a583 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1571,8 +1571,8 @@ static int cayman_cp_resume(struct radeon_device *rdev)
 
 		/* Set ring buffer size */
 		ring = &rdev->ring[ridx[i]];
-		rb_cntl = drm_order(ring->ring_size / 8);
-		rb_cntl |= drm_order(RADEON_GPU_PAGE_SIZE/8) << 8;
+		rb_cntl = order_base_2(ring->ring_size / 8);
+		rb_cntl |= order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8;
 #ifdef __BIG_ENDIAN
 		rb_cntl |= BUF_SWAP_32BIT;
 #endif
@@ -1731,7 +1731,7 @@ int cayman_dma_resume(struct radeon_device *rdev)
 		WREG32(DMA_SEM_WAIT_FAIL_TIMER_CNTL + reg_offset, 0);
 
 		/* Set ring buffer size in dwords */
-		rb_bufsz = drm_order(ring->ring_size / 4);
+		rb_bufsz = order_base_2(ring->ring_size / 4);
 		rb_cntl = rb_bufsz << 1;
 #ifdef __BIG_ENDIAN
 		rb_cntl |= DMA_RB_SWAP_ENABLE | DMA_RPTR_WRITEBACK_SWAP_ENABLE;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index c9affef..b0b2640 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1106,7 +1106,7 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
 	}
 
 	/* Align ring size */
-	rb_bufsz = drm_order(ring_size / 8);
+	rb_bufsz = order_base_2(ring_size / 8);
 	ring_size = (1 << (rb_bufsz + 1)) * 4;
 	r100_cp_load_microcode(rdev);
 	r = radeon_ring_init(rdev, ring, ring_size, RADEON_WB_CP_RPTR_OFFSET,
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 2d3655f..aea76eb 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2424,8 +2424,8 @@ int r600_cp_resume(struct radeon_device *rdev)
 	WREG32(GRBM_SOFT_RESET, 0);
 
 	/* Set ring buffer size */
-	rb_bufsz = drm_order(ring->ring_size / 8);
-	tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
+	rb_bufsz = order_base_2(ring->ring_size / 8);
+	tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
 #ifdef __BIG_ENDIAN
 	tmp |= BUF_SWAP_32BIT;
 #endif
@@ -2478,7 +2478,7 @@ void r600_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsign
 	int r;
 
 	/* Align ring size */
-	rb_bufsz = drm_order(ring_size / 8);
+	rb_bufsz = order_base_2(ring_size / 8);
 	ring_size = (1 << (rb_bufsz + 1)) * 4;
 	ring->ring_size = ring_size;
 	ring->align_mask = 16 - 1;
@@ -2558,7 +2558,7 @@ int r600_dma_resume(struct radeon_device *rdev)
 	WREG32(DMA_SEM_WAIT_FAIL_TIMER_CNTL, 0);
 
 	/* Set ring buffer size in dwords */
-	rb_bufsz = drm_order(ring->ring_size / 4);
+	rb_bufsz = order_base_2(ring->ring_size / 4);
 	rb_cntl = rb_bufsz << 1;
 #ifdef __BIG_ENDIAN
 	rb_cntl |= DMA_RB_SWAP_ENABLE | DMA_RPTR_WRITEBACK_SWAP_ENABLE;
@@ -2667,7 +2667,7 @@ int r600_uvd_rbc_start(struct radeon_device *rdev)
 	WREG32(UVD_RBC_RB_BASE, ring->gpu_addr);
 
 	/* Set ring buffer size */
-	rb_bufsz = drm_order(ring->ring_size);
+	rb_bufsz = order_base_2(ring->ring_size);
 	rb_bufsz = (0x1 << 8) | rb_bufsz;
 	WREG32(UVD_RBC_RB_CNTL, rb_bufsz);
 
@@ -3742,7 +3742,7 @@ void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size)
 	u32 rb_bufsz;
 
 	/* Align ring size */
-	rb_bufsz = drm_order(ring_size / 4);
+	rb_bufsz = order_base_2(ring_size / 4);
 	ring_size = (1 << rb_bufsz) * 4;
 	rdev->ih.ring_size = ring_size;
 	rdev->ih.ptr_mask = rdev->ih.ring_size - 1;
@@ -3979,7 +3979,7 @@ int r600_irq_init(struct radeon_device *rdev)
 	WREG32(INTERRUPT_CNTL, interrupt_cntl);
 
 	WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8);
-	rb_bufsz = drm_order(rdev->ih.ring_size / 4);
+	rb_bufsz = order_base_2(rdev->ih.ring_size / 4);
 
 	ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE |
 		      IH_WPTR_OVERFLOW_CLEAR |
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index 1c51c08..d8eb48b 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -2200,13 +2200,13 @@ int r600_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
 	dev_priv->ring.end = ((u32 *) dev_priv->cp_ring->handle
 			      + init->ring_size / sizeof(u32));
 	dev_priv->ring.size = init->ring_size;
-	dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8);
+	dev_priv->ring.size_l2qw = order_base_2(init->ring_size / 8);
 
 	dev_priv->ring.rptr_update = /* init->rptr_update */ 4096;
-	dev_priv->ring.rptr_update_l2qw = drm_order(/* init->rptr_update */ 4096 / 8);
+	dev_priv->ring.rptr_update_l2qw = order_base_2(/* init->rptr_update */ 4096 / 8);
 
 	dev_priv->ring.fetch_size = /* init->fetch_size */ 32;
-	dev_priv->ring.fetch_size_l2ow = drm_order(/* init->fetch_size */ 32 / 16);
+	dev_priv->ring.fetch_size_l2ow = order_base_2(/* init->fetch_size */ 32 / 16);
 
 	dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1;
 
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index efc4f64..3cae2bb 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -1444,13 +1444,13 @@ static int radeon_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
 	dev_priv->ring.end = ((u32 *) dev_priv->cp_ring->handle
 			      + init->ring_size / sizeof(u32));
 	dev_priv->ring.size = init->ring_size;
-	dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8);
+	dev_priv->ring.size_l2qw = order_base_2(init->ring_size / 8);
 
 	dev_priv->ring.rptr_update = /* init->rptr_update */ 4096;
-	dev_priv->ring.rptr_update_l2qw = drm_order( /* init->rptr_update */ 4096 / 8);
+	dev_priv->ring.rptr_update_l2qw = order_base_2( /* init->rptr_update */ 4096 / 8);
 
 	dev_priv->ring.fetch_size = /* init->fetch_size */ 32;
-	dev_priv->ring.fetch_size_l2ow = drm_order( /* init->fetch_size */ 32 / 16);
+	dev_priv->ring.fetch_size_l2ow = order_base_2( /* init->fetch_size */ 32 / 16);
 	dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1;
 
 	dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 2349067..9361c3e 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -3394,8 +3394,8 @@ static int si_cp_resume(struct radeon_device *rdev)
 	/* ring 0 - compute and gfx */
 	/* Set ring buffer size */
 	ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
-	rb_bufsz = drm_order(ring->ring_size / 8);
-	tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
+	rb_bufsz = order_base_2(ring->ring_size / 8);
+	tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
 #ifdef __BIG_ENDIAN
 	tmp |= BUF_SWAP_32BIT;
 #endif
@@ -3427,8 +3427,8 @@ static int si_cp_resume(struct radeon_device *rdev)
 	/* ring1  - compute only */
 	/* Set ring buffer size */
 	ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
-	rb_bufsz = drm_order(ring->ring_size / 8);
-	tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
+	rb_bufsz = order_base_2(ring->ring_size / 8);
+	tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
 #ifdef __BIG_ENDIAN
 	tmp |= BUF_SWAP_32BIT;
 #endif
@@ -3453,8 +3453,8 @@ static int si_cp_resume(struct radeon_device *rdev)
 	/* ring2 - compute only */
 	/* Set ring buffer size */
 	ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
-	rb_bufsz = drm_order(ring->ring_size / 8);
-	tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
+	rb_bufsz = order_base_2(ring->ring_size / 8);
+	tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
 #ifdef __BIG_ENDIAN
 	tmp |= BUF_SWAP_32BIT;
 #endif
@@ -5398,7 +5398,7 @@ static int si_irq_init(struct radeon_device *rdev)
 	WREG32(INTERRUPT_CNTL, interrupt_cntl);
 
 	WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8);
-	rb_bufsz = drm_order(rdev->ih.ring_size / 4);
+	rb_bufsz = order_base_2(rdev->ih.ring_size / 4);
 
 	ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE |
 		      IH_WPTR_OVERFLOW_CLEAR |
-- 
1.8.3.2

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

* [PATCH 26/39] drm: remove drm_order
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (24 preceding siblings ...)
  2013-07-10 12:11 ` [PATCH 25/39] drm/radeon: s/drm_order/order_base_2/ Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 27/39] drm: mark context support as a legacy subsystem Daniel Vetter
                   ` (15 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

All users of it are now gone!

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

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 31a971d..cccc25f 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1628,26 +1628,3 @@ struct drm_local_map *drm_getsarea(struct drm_device *dev)
 	return NULL;
 }
 EXPORT_SYMBOL(drm_getsarea);
-
-/**
- * Compute size order.  Returns the exponent of the smaller power of two which
- * is greater or equal to given number.
- *
- * \param size size.
- * \return order.
- *
- * \todo Can be made faster.
- */
-int drm_order(unsigned long size)
-{
-	int order;
-	unsigned long tmp;
-
-	for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ;
-
-	if (size & (size - 1))
-		++order;
-
-	return order;
-}
-EXPORT_SYMBOL(drm_order);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 60307d1..a483ba7 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1393,7 +1393,6 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 extern int drm_mapbufs(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
-extern int drm_order(unsigned long size);
 
 				/* DMA support (drm_dma.h) */
 extern int drm_legacy_dma_setup(struct drm_device *dev);
-- 
1.8.3.2

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

* [PATCH 27/39] drm: mark context support as a legacy subsystem
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (25 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 26/39] drm: remove drm_order Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 28/39] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent Daniel Vetter
                   ` (14 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

So after a lot of digging around in git histories it looks like this
has only ever be used by dri1 render clients. Hence we can fully
disable the entire thing for modesetting drivers and so greatly reduce
the attack surface for potential exploits (or at least tools like
trinity ...).

Also add the drm_legacy prefix for functions which are called from
common code. To further reduce the impact on common code also extract
all the ctx release handling into a function (instead of only
releasing individual handles) and make ctxbitmap_cleanup return void -
it can never fail.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_context.c | 73 ++++++++++++++++++++++++++++++++++++++-----
 drivers/gpu/drm/drm_fops.c    | 21 +------------
 drivers/gpu/drm/drm_stub.c    | 10 ++----
 include/drm/drmP.h            |  7 +++--
 4 files changed, 72 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 224ff96..b4fb86d 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -42,10 +42,6 @@
 
 #include <drm/drmP.h>
 
-/******************************************************************/
-/** \name Context bitmap support */
-/*@{*/
-
 /**
  * Free a handle from the context bitmap.
  *
@@ -56,13 +52,48 @@
  * in drm_device::ctx_idr, while holding the drm_device::struct_mutex
  * lock.
  */
-void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
+static void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
 {
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return;
+
 	mutex_lock(&dev->struct_mutex);
 	idr_remove(&dev->ctx_idr, ctx_handle);
 	mutex_unlock(&dev->struct_mutex);
 }
 
+/******************************************************************/
+/** \name Context bitmap support */
+/*@{*/
+
+void drm_legacy_ctxbitmap_release(struct drm_device *dev,
+				  struct drm_file *file_priv)
+{
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return;
+
+	mutex_lock(&dev->ctxlist_mutex);
+	if (!list_empty(&dev->ctxlist)) {
+		struct drm_ctx_list *pos, *n;
+
+		list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
+			if (pos->tag == file_priv &&
+			    pos->handle != DRM_KERNEL_CONTEXT) {
+				if (dev->driver->context_dtor)
+					dev->driver->context_dtor(dev,
+								  pos->handle);
+
+				drm_ctxbitmap_free(dev, pos->handle);
+
+				list_del(&pos->head);
+				kfree(pos);
+				--dev->ctx_count;
+			}
+		}
+	}
+	mutex_unlock(&dev->ctxlist_mutex);
+}
+
 /**
  * Context bitmap allocation.
  *
@@ -90,10 +121,12 @@ static int drm_ctxbitmap_next(struct drm_device * dev)
  *
  * Initialise the drm_device::ctx_idr
  */
-int drm_ctxbitmap_init(struct drm_device * dev)
+void drm_legacy_ctxbitmap_init(struct drm_device * dev)
 {
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return;
+
 	idr_init(&dev->ctx_idr);
-	return 0;
 }
 
 /**
@@ -104,7 +137,7 @@ int drm_ctxbitmap_init(struct drm_device * dev)
  * Free all idr members using drm_ctx_sarea_free helper function
  * while holding the drm_device::struct_mutex lock.
  */
-void drm_ctxbitmap_cleanup(struct drm_device * dev)
+void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev)
 {
 	mutex_lock(&dev->struct_mutex);
 	idr_destroy(&dev->ctx_idr);
@@ -136,6 +169,9 @@ int drm_getsareactx(struct drm_device *dev, void *data,
 	struct drm_local_map *map;
 	struct drm_map_list *_entry;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	mutex_lock(&dev->struct_mutex);
 
 	map = idr_find(&dev->ctx_idr, request->ctx_id);
@@ -180,6 +216,9 @@ int drm_setsareactx(struct drm_device *dev, void *data,
 	struct drm_local_map *map = NULL;
 	struct drm_map_list *r_list = NULL;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(r_list, &dev->maplist, head) {
 		if (r_list->map
@@ -280,6 +319,9 @@ int drm_resctx(struct drm_device *dev, void *data,
 	struct drm_ctx ctx;
 	int i;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	if (res->count >= DRM_RESERVED_CONTEXTS) {
 		memset(&ctx, 0, sizeof(ctx));
 		for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
@@ -310,6 +352,9 @@ int drm_addctx(struct drm_device *dev, void *data,
 	struct drm_ctx_list *ctx_entry;
 	struct drm_ctx *ctx = data;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	ctx->handle = drm_ctxbitmap_next(dev);
 	if (ctx->handle == DRM_KERNEL_CONTEXT) {
 		/* Skip kernel's context and get a new one. */
@@ -353,6 +398,9 @@ int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
 	struct drm_ctx *ctx = data;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	/* This is 0, because we don't handle any context flags */
 	ctx->flags = 0;
 
@@ -375,6 +423,9 @@ int drm_switchctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	DRM_DEBUG("%d\n", ctx->handle);
 	return drm_context_switch(dev, dev->last_context, ctx->handle);
 }
@@ -395,6 +446,9 @@ int drm_newctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	DRM_DEBUG("%d\n", ctx->handle);
 	drm_context_switch_complete(dev, file_priv, ctx->handle);
 
@@ -417,6 +471,9 @@ int drm_rmctx(struct drm_device *dev, void *data,
 {
 	struct drm_ctx *ctx = data;
 
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
 	DRM_DEBUG("%d\n", ctx->handle);
 	if (ctx->handle != DRM_KERNEL_CONTEXT) {
 		if (dev->driver->context_dtor)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index b293b60..ca6c946 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -467,26 +467,7 @@ int drm_release(struct inode *inode, struct file *filp)
 	if (dev->driver->driver_features & DRIVER_GEM)
 		drm_gem_release(dev, file_priv);
 
-	mutex_lock(&dev->ctxlist_mutex);
-	if (!list_empty(&dev->ctxlist)) {
-		struct drm_ctx_list *pos, *n;
-
-		list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
-			if (pos->tag == file_priv &&
-			    pos->handle != DRM_KERNEL_CONTEXT) {
-				if (dev->driver->context_dtor)
-					dev->driver->context_dtor(dev,
-								  pos->handle);
-
-				drm_ctxbitmap_free(dev, pos->handle);
-
-				list_del(&pos->head);
-				kfree(pos);
-				--dev->ctx_count;
-			}
-		}
-	}
-	mutex_unlock(&dev->ctxlist_mutex);
+	drm_legacy_ctxbitmap_release(dev, file_priv);
 
 	mutex_lock(&dev->struct_mutex);
 
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 327ca19..e7471ef 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -288,13 +288,7 @@ int drm_fill_in_dev(struct drm_device *dev,
 			goto error_out_unreg;
 	}
 
-
-
-	retcode = drm_ctxbitmap_init(dev);
-	if (retcode) {
-		DRM_ERROR("Cannot allocate memory for context bitmap.\n");
-		goto error_out_unreg;
-	}
+	drm_legacy_ctxbitmap_init(dev);
 
 	if (driver->driver_features & DRIVER_GEM) {
 		retcode = drm_gem_init(dev);
@@ -468,7 +462,7 @@ void drm_put_dev(struct drm_device *dev)
 		drm_rmmap(dev, r_list->map);
 	drm_ht_remove(&dev->map_hash);
 
-	drm_ctxbitmap_cleanup(dev);
+	drm_legacy_ctxbitmap_cleanup(dev);
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		drm_put_minor(&dev->control);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a483ba7..d38c358 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1334,9 +1334,10 @@ extern int drm_newctx(struct drm_device *dev, void *data,
 extern int drm_rmctx(struct drm_device *dev, void *data,
 		     struct drm_file *file_priv);
 
-extern int drm_ctxbitmap_init(struct drm_device *dev);
-extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
-extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
+extern void drm_legacy_ctxbitmap_init(struct drm_device *dev);
+extern void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
+extern void drm_legacy_ctxbitmap_release(struct drm_device *dev,
+					 struct drm_file *file_priv);
 
 extern int drm_setsareactx(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv);
-- 
1.8.3.2

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

* [PATCH 28/39] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (26 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 27/39] drm: mark context support as a legacy subsystem Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 29/39] drm: remove FASYNC support Daniel Vetter
                   ` (13 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

It's kzalloced ...

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

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 3e43578..3e75dfa 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1125,7 +1125,6 @@ static struct drm_driver driver = {
 	.disable_vblank = vmw_disable_vblank,
 	.ioctls = vmw_ioctls,
 	.num_ioctls = DRM_ARRAY_SIZE(vmw_ioctls),
-	.dma_quiescent = NULL,	/*vmw_dma_quiescent, */
 	.master_create = vmw_master_create,
 	.master_destroy = vmw_master_destroy,
 	.master_set = vmw_master_set,
-- 
1.8.3.2

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

* [PATCH 29/39] drm: remove FASYNC support
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (27 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 28/39] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 14:57   ` [PATCH] " Daniel Vetter
  2013-07-10 12:12 ` [PATCH 30/39] drm: rip out DRIVER_FB_DMA and related code Daniel Vetter
                   ` (12 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

So I've stumbled over drm_fasync and wondered what it does. Digging
that up is quite a story.

First I've had to read up on what this does and ended up being rather
bewildered why peopled loved signals so much back in the days that
they've created SIGIO just for that ...

Then I wondered how this ever works, and what that strange "No-op."
comment right above it should mean. After all calling the core fasync
helper is pretty obviously not a noop. After reading through the
kernels FASYNC implementation I've noticed that signals are only sent
out to the processes attached with FASYNC by calling kill_fasync.

No merged drm driver has ever done that.

After more digging I've found out that the only driver that ever used
this is the so called GAMMA driver. I've frankly never heard of such a
gpu brand ever before. Now FASYNC seems to not have been the only bad
thing with that driver, since Dave Airlie removed it from the drm
driver with prejudice:

commit 1430163b4bbf7b00367ea1066c1c5fe85dbeefed
Author: Dave Airlie <airlied@linux.ie>
Date:   Sun Aug 29 12:04:35 2004 +0000

    Drop GAMMA DRM from a great height ...

Long story short, the drm fasync support seems to be doing absolutely
nothing. And the only user of it was never merged into the upstream
kernel. And we don't need any fops->fasync callback since the fcntl
implementation in the kernel already implements the noop case
correctly.

So stop this particular cargo-cult and rip it all out.

Cc: Dave Airlie <airlied@linux.ie>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/ast/ast_drv.c            |  1 -
 drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 -
 drivers/gpu/drm/drm_fops.c               | 12 ------------
 drivers/gpu/drm/gma500/psb_drv.c         |  1 -
 drivers/gpu/drm/i810/i810_dma.c          |  1 -
 drivers/gpu/drm/i810/i810_drv.c          |  1 -
 drivers/gpu/drm/i915/i915_drv.c          |  1 -
 drivers/gpu/drm/mga/mga_drv.c            |  1 -
 drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c    |  1 -
 drivers/gpu/drm/omapdrm/omap_drv.c       |  1 -
 drivers/gpu/drm/qxl/qxl_drv.c            |  1 -
 drivers/gpu/drm/r128/r128_drv.c          |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c      |  2 --
 drivers/gpu/drm/savage/savage_drv.c      |  1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 -
 drivers/gpu/drm/sis/sis_drv.c            |  1 -
 drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 -
 drivers/gpu/drm/udl/udl_drv.c            |  1 -
 drivers/gpu/drm/via/via_drv.c            |  1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 -
 drivers/gpu/host1x/drm/drm.c             |  1 -
 include/drm/drmP.h                       |  3 ---
 24 files changed, 38 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index df0d0a0..16050ed 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -190,7 +190,6 @@ static const struct file_operations ast_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = ast_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 8ecb601..85748f6 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -85,7 +85,6 @@ static const struct file_operations cirrus_driver_fops = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
-	.fasync = drm_fasync,
 };
 static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index ca6c946..392ce89 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -365,18 +365,6 @@ out_put_pid:
 	return ret;
 }
 
-/** No-op. */
-int drm_fasync(int fd, struct file *filp, int on)
-{
-	struct drm_file *priv = filp->private_data;
-	struct drm_device *dev = priv->minor->dev;
-
-	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
-		  (long)old_encode_dev(priv->minor->device));
-	return fasync_helper(fd, filp, on, &dev->buf_async);
-}
-EXPORT_SYMBOL(drm_fasync);
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
 	struct drm_file *file_priv = filp->private_data;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index bddea58..c9c37ac 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -622,7 +622,6 @@ static const struct file_operations psb_gem_fops = {
 	.unlocked_ioctl = psb_unlocked_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 };
 
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 004ecdf..ef1c9c7 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -113,7 +113,6 @@ static const struct file_operations i810_buffer_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = i810_mmap_buffers,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 2e91fc3..d85c05b 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -49,7 +49,6 @@ static const struct file_operations i810_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 062cbda..999ef21 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1110,7 +1110,6 @@ static const struct file_operations i915_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = i915_compat_ioctl,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 17d0a63..fe71e1e 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -50,7 +50,6 @@ static const struct file_operations mga_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = mga_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 122b571..31ff081 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -81,7 +81,6 @@ static const struct file_operations mgag200_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = mgag200_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index e990327..e09debe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -664,7 +664,6 @@ nouveau_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = nouveau_ttm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = nouveau_compat_ioctl,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 3f7c78a..fd2cfed 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -577,7 +577,6 @@ static const struct file_operations omapdriver_fops = {
 		.release = drm_release,
 		.mmap = omap_gem_mmap,
 		.poll = drm_poll,
-		.fasync = drm_fasync,
 		.read = drm_read,
 		.llseek = noop_llseek,
 };
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index df0b577..4be5225 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -84,7 +84,6 @@ static const struct file_operations qxl_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.mmap = qxl_mmap,
 };
 
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 472c38f..c2338cb 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations r128_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = r128_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 81b9baa..ae94625 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -265,7 +265,6 @@ static const struct file_operations radeon_driver_old_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_compat_ioctl,
@@ -374,7 +373,6 @@ static const struct file_operations radeon_driver_kms_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = radeon_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_kms_compat_ioctl,
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 71b2081..9135c8b 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -42,7 +42,6 @@ static const struct file_operations savage_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index edc1018..db94f2f 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -257,7 +257,6 @@ static const struct file_operations shmob_drm_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 5a5325e..b88b2d3 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -72,7 +72,6 @@ static const struct file_operations sis_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index ddfa743..951ec13 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations tdfx_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 40b71da..ff920ff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -497,7 +497,6 @@ static const struct file_operations fops = {
 #endif
 	.poll               = drm_poll,
 	.read               = drm_read,
-	.fasync             = drm_fasync,
 	.llseek             = no_llseek,
 	.mmap               = drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index c0770db..c275adb 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -65,7 +65,6 @@ static const struct file_operations udl_driver_fops = {
 	.read = drm_read,
 	.unlocked_ioctl	= drm_ioctl,
 	.release = drm_release,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index f4ae203..4487999 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -64,7 +64,6 @@ static const struct file_operations via_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 3e75dfa..77d503a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1103,7 +1103,6 @@ static const struct file_operations vmwgfx_driver_fops = {
 	.mmap = vmw_mmap,
 	.poll = vmw_fops_poll,
 	.read = vmw_fops_read,
-	.fasync = drm_fasync,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index e184b00..f8b708f 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -508,7 +508,6 @@ static const struct file_operations tegra_drm_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = tegra_drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d38c358..3589736 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1169,8 +1169,6 @@ struct drm_device {
 
 	/*@} */
 
-	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
-
 	struct drm_agp_head *agp;	/**< AGP data */
 
 	struct device *dev;             /**< Device structure */
@@ -1277,7 +1275,6 @@ extern int drm_lastclose(struct drm_device *dev);
 extern struct mutex drm_global_mutex;
 extern int drm_open(struct inode *inode, struct file *filp);
 extern int drm_stub_open(struct inode *inode, struct file *filp);
-extern int drm_fasync(int fd, struct file *filp, int on);
 extern ssize_t drm_read(struct file *filp, char __user *buffer,
 			size_t count, loff_t *offset);
 extern int drm_release(struct inode *inode, struct file *filp);
-- 
1.8.3.2

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

* [PATCH 30/39] drm: rip out DRIVER_FB_DMA and related code
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (28 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 29/39] drm: remove FASYNC support Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 31/39] drm: rip out a few unused DRIVER flags Daniel Vetter
                   ` (11 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

No driver ever sets that flag, so good riddance!

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

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index cccc25f..5f73f0a 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1130,161 +1130,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
 	return 0;
 }
 
-static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request)
-{
-	struct drm_device_dma *dma = dev->dma;
-	struct drm_buf_entry *entry;
-	struct drm_buf *buf;
-	unsigned long offset;
-	unsigned long agp_offset;
-	int count;
-	int order;
-	int size;
-	int alignment;
-	int page_order;
-	int total;
-	int byte_count;
-	int i;
-	struct drm_buf **temp_buflist;
-
-	if (!drm_core_check_feature(dev, DRIVER_FB_DMA))
-		return -EINVAL;
-
-	if (!dma)
-		return -EINVAL;
-
-	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
-
-	count = request->count;
-	order = order_base_2(request->size);
-	size = 1 << order;
-
-	alignment = (request->flags & _DRM_PAGE_ALIGN)
-	    ? PAGE_ALIGN(size) : size;
-	page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
-	total = PAGE_SIZE << page_order;
-
-	byte_count = 0;
-	agp_offset = request->agp_start;
-
-	DRM_DEBUG("count:      %d\n", count);
-	DRM_DEBUG("order:      %d\n", order);
-	DRM_DEBUG("size:       %d\n", size);
-	DRM_DEBUG("agp_offset: %lu\n", agp_offset);
-	DRM_DEBUG("alignment:  %d\n", alignment);
-	DRM_DEBUG("page_order: %d\n", page_order);
-	DRM_DEBUG("total:      %d\n", total);
-
-	if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
-		return -EINVAL;
-
-	spin_lock(&dev->count_lock);
-	if (dev->buf_use) {
-		spin_unlock(&dev->count_lock);
-		return -EBUSY;
-	}
-	atomic_inc(&dev->buf_alloc);
-	spin_unlock(&dev->count_lock);
-
-	mutex_lock(&dev->struct_mutex);
-	entry = &dma->bufs[order];
-	if (entry->buf_count) {
-		mutex_unlock(&dev->struct_mutex);
-		atomic_dec(&dev->buf_alloc);
-		return -ENOMEM;	/* May only call once for each order */
-	}
-
-	if (count < 0 || count > 4096) {
-		mutex_unlock(&dev->struct_mutex);
-		atomic_dec(&dev->buf_alloc);
-		return -EINVAL;
-	}
-
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist),
-				GFP_KERNEL);
-	if (!entry->buflist) {
-		mutex_unlock(&dev->struct_mutex);
-		atomic_dec(&dev->buf_alloc);
-		return -ENOMEM;
-	}
-
-	entry->buf_size = size;
-	entry->page_order = page_order;
-
-	offset = 0;
-
-	while (entry->buf_count < count) {
-		buf = &entry->buflist[entry->buf_count];
-		buf->idx = dma->buf_count + entry->buf_count;
-		buf->total = alignment;
-		buf->order = order;
-		buf->used = 0;
-
-		buf->offset = (dma->byte_count + offset);
-		buf->bus_address = agp_offset + offset;
-		buf->address = (void *)(agp_offset + offset);
-		buf->next = NULL;
-		buf->waiting = 0;
-		buf->pending = 0;
-		buf->file_priv = NULL;
-
-		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = kzalloc(buf->dev_priv_size, GFP_KERNEL);
-		if (!buf->dev_private) {
-			/* Set count correctly so we free the proper amount. */
-			entry->buf_count = count;
-			drm_cleanup_buf_error(dev, entry);
-			mutex_unlock(&dev->struct_mutex);
-			atomic_dec(&dev->buf_alloc);
-			return -ENOMEM;
-		}
-
-		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
-
-		offset += alignment;
-		entry->buf_count++;
-		byte_count += PAGE_SIZE << page_order;
-	}
-
-	DRM_DEBUG("byte_count: %d\n", byte_count);
-
-	temp_buflist = krealloc(dma->buflist,
-				(dma->buf_count + entry->buf_count) *
-				sizeof(*dma->buflist), GFP_KERNEL);
-	if (!temp_buflist) {
-		/* Free the entry because it isn't valid */
-		drm_cleanup_buf_error(dev, entry);
-		mutex_unlock(&dev->struct_mutex);
-		atomic_dec(&dev->buf_alloc);
-		return -ENOMEM;
-	}
-	dma->buflist = temp_buflist;
-
-	for (i = 0; i < entry->buf_count; i++) {
-		dma->buflist[i + dma->buf_count] = &entry->buflist[i];
-	}
-
-	dma->buf_count += entry->buf_count;
-	dma->seg_count += entry->seg_count;
-	dma->page_count += byte_count >> PAGE_SHIFT;
-	dma->byte_count += byte_count;
-
-	DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
-	DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
-
-	mutex_unlock(&dev->struct_mutex);
-
-	request->count = entry->buf_count;
-	request->size = size;
-
-	dma->flags = _DRM_DMA_USE_FB;
-
-	atomic_dec(&dev->buf_alloc);
-	return 0;
-}
-
-
 /**
  * Add buffers for DMA transfers (ioctl).
  *
@@ -1319,7 +1164,7 @@ int drm_addbufs(struct drm_device *dev, void *data,
 	if (request->flags & _DRM_SG_BUFFER)
 		ret = drm_addbufs_sg(dev, request);
 	else if (request->flags & _DRM_FB_BUFFER)
-		ret = drm_addbufs_fb(dev, request);
+		ret = -EINVAL;
 	else
 		ret = drm_addbufs_pci(dev, request);
 
@@ -1556,9 +1401,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	if (request->count >= dma->buf_count) {
 		if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP))
 		    || (drm_core_check_feature(dev, DRIVER_SG)
-			&& (dma->flags & _DRM_DMA_USE_SG))
-		    || (drm_core_check_feature(dev, DRIVER_FB_DMA)
-			&& (dma->flags & _DRM_DMA_USE_FB))) {
+			&& (dma->flags & _DRM_DMA_USE_SG))) {
 			struct drm_local_map *map = dev->agp_buffer_map;
 			unsigned long token = dev->agp_buffer_token;
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 3589736..2084d3d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -148,7 +148,6 @@ int drm_err(const char *func, const char *format, ...);
 #define DRIVER_IRQ_SHARED  0x80
 #define DRIVER_IRQ_VBL     0x100
 #define DRIVER_DMA_QUEUE   0x200
-#define DRIVER_FB_DMA      0x400
 #define DRIVER_IRQ_VBL2    0x800
 #define DRIVER_GEM         0x1000
 #define DRIVER_MODESET     0x2000
-- 
1.8.3.2

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

* [PATCH 31/39] drm: rip out a few unused DRIVER flags
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (29 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 30/39] drm: rip out DRIVER_FB_DMA and related code Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 32/39] drm: remove a bunch of unused #defines from drmP.h Daniel Vetter
                   ` (10 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The gma500 driver somehow set the DRIVER_IRQ_VBL flag, but since
there's no code at all to check for this we can kill it. The other two
are completely unused.

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

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index c9c37ac..ce88945 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -627,7 +627,7 @@ static const struct file_operations psb_gem_fops = {
 
 static struct drm_driver driver = {
 	.driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \
-			   DRIVER_IRQ_VBL | DRIVER_MODESET | DRIVER_GEM ,
+			   DRIVER_MODESET | DRIVER_GEM ,
 	.load = psb_driver_load,
 	.unload = psb_driver_unload,
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2084d3d..2a7001f 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -146,9 +146,6 @@ int drm_err(const char *func, const char *format, ...);
 #define DRIVER_HAVE_DMA    0x20
 #define DRIVER_HAVE_IRQ    0x40
 #define DRIVER_IRQ_SHARED  0x80
-#define DRIVER_IRQ_VBL     0x100
-#define DRIVER_DMA_QUEUE   0x200
-#define DRIVER_IRQ_VBL2    0x800
 #define DRIVER_GEM         0x1000
 #define DRIVER_MODESET     0x2000
 #define DRIVER_PRIME       0x4000
-- 
1.8.3.2

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

* [PATCH 32/39] drm: remove a bunch of unused #defines from drmP.h
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (30 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 31/39] drm: rip out a few unused DRIVER flags Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Daniel Vetter
                   ` (9 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 include/drm/drmP.h | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2a7001f..62e9e41 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -164,13 +164,7 @@ int drm_err(const char *func, const char *format, ...);
 #define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
 #define DRM_KERNEL_CONTEXT    0	 /**< Change drm_resctx if changed */
 #define DRM_RESERVED_CONTEXTS 1	 /**< Change drm_resctx if changed */
-#define DRM_LOOPING_LIMIT     5000000
-#define DRM_TIME_SLICE	      (HZ/20)  /**< Time slice for GLXContexts */
-#define DRM_LOCK_SLICE	      1	/**< Time slice for lock, in jiffies */
 
-#define DRM_FLAG_DEBUG	  0x01
-
-#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
 #define DRM_MAP_HASH_OFFSET 0x10000000
 
 /*@}*/
@@ -259,9 +253,6 @@ int drm_err(const char *func, const char *format, ...);
 
 #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
 
-#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
-#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
-
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
 /**
-- 
1.8.3.2

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

* [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (31 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 32/39] drm: remove a bunch of unused #defines from drmP.h Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 13:51   ` David Herrmann
  2013-07-10 12:12 ` [PATCH 34/39] drm: remove the dma_ioctl special-case Daniel Vetter
                   ` (8 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Andy Lutomirski

The new arch_phys_wc_add/del functions do the right thing both with
and without MTRR support in the kernel. So we can drop these
additional checks.

Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_bufs.c | 13 +++++--------
 drivers/gpu/drm/drm_pci.c  | 11 +++++------
 drivers/gpu/drm/drm_stub.c |  2 +-
 drivers/gpu/drm/drm_vm.c   |  3 +--
 include/drm/drmP.h         | 10 ----------
 5 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 5f73f0a..f63133b 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -207,12 +207,10 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 			return 0;
 		}
 
-		if (drm_core_has_MTRR(dev)) {
-			if (map->type == _DRM_FRAME_BUFFER ||
-			    (map->flags & _DRM_WRITE_COMBINING)) {
-				map->mtrr =
-					arch_phys_wc_add(map->offset, map->size);
-			}
+		if (map->type == _DRM_FRAME_BUFFER ||
+		    (map->flags & _DRM_WRITE_COMBINING)) {
+			map->mtrr =
+				arch_phys_wc_add(map->offset, map->size);
 		}
 		if (map->type == _DRM_REGISTERS) {
 			if (map->flags & _DRM_WRITE_COMBINING)
@@ -464,8 +462,7 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
 		iounmap(map->handle);
 		/* FALLTHROUGH */
 	case _DRM_FRAME_BUFFER:
-		if (drm_core_has_MTRR(dev))
-			arch_phys_wc_del(map->mtrr);
+		arch_phys_wc_del(map->mtrr);
 		break;
 	case _DRM_SHM:
 		vfree(map->handle);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 80c0b2b..9e93ea5 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -276,12 +276,11 @@ static int drm_pci_agp_init(struct drm_device *dev)
 			DRM_ERROR("Cannot initialize the agpgart module.\n");
 			return -EINVAL;
 		}
-		if (drm_core_has_MTRR(dev)) {
-			if (dev->agp)
-				dev->agp->agp_mtrr = arch_phys_wc_add(
-					dev->agp->agp_info.aper_base,
-					dev->agp->agp_info.aper_size *
-					1024 * 1024);
+		if (dev->agp) {
+			dev->agp->agp_mtrr = arch_phys_wc_add(
+				dev->agp->agp_info.aper_base,
+				dev->agp->agp_info.aper_size *
+				1024 * 1024);
 		}
 	}
 	return 0;
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index e7471ef..30cbd62 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -445,7 +445,7 @@ void drm_put_dev(struct drm_device *dev)
 
 	drm_lastclose(dev);
 
-	if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp)
+	if (dev->agp)
 		arch_phys_wc_del(dev->agp->agp_mtrr);
 
 	if (dev->driver->unload)
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index feb2003..b5c5af7 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -251,8 +251,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
 			switch (map->type) {
 			case _DRM_REGISTERS:
 			case _DRM_FRAME_BUFFER:
-				if (drm_core_has_MTRR(dev))
-					arch_phys_wc_del(map->mtrr);
+				arch_phys_wc_del(map->mtrr);
 				iounmap(map->handle);
 				break;
 			case _DRM_SHM:
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 62e9e41..d933f06 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -75,7 +75,6 @@
 #include <linux/idr.h>
 
 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
-#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
 
 struct module;
 
@@ -1220,15 +1219,6 @@ static inline int drm_core_has_AGP(struct drm_device *dev)
 #define drm_core_has_AGP(dev) (0)
 #endif
 
-#if __OS_HAS_MTRR
-static inline int drm_core_has_MTRR(struct drm_device *dev)
-{
-	return drm_core_check_feature(dev, DRIVER_USE_MTRR);
-}
-#else
-#define drm_core_has_MTRR(dev) (0)
-#endif
-
 static inline void drm_device_set_unplugged(struct drm_device *dev)
 {
 	smp_wmb();
-- 
1.8.3.2

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

* [PATCH 34/39] drm: remove the dma_ioctl special-case
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (32 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 14:34   ` David Herrmann
  2013-07-10 12:12 ` [PATCH 35/39] drm/memory: don't export agp helpers Daniel Vetter
                   ` (7 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

We might as well have a real ioctl function which checks for the
callbacks. This seems to be a remnant from back in the days when each
drm driver had their own complete ioctl table, with no shared core
drm table at all.

To make really sure no mis-guided user in a kms driver pops up again
explicitly check for that in the new ioctl implementation.

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

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index f63133b..ff7fe80 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1455,6 +1455,20 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	return retcode;
 }
 
+int drm_dma_ioctl(struct drm_device *dev, void *data,
+		  struct drm_file *file_priv)
+{
+	struct drm_device_dma *dma = dev->dma;
+
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	if (dev->driver->dma_ioctl)
+		return dev->driver->dma_ioctl(dev, data, file_priv);
+	else
+		return -EINVAL;
+}
+
 struct drm_local_map *drm_getsarea(struct drm_device *dev)
 {
 	struct drm_map_list *entry;
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f2495e1..b349b5f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -106,8 +106,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
-	/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
-	DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma_ioctl, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
@@ -415,9 +414,6 @@ long drm_ioctl(struct file *filp,
 
 	/* Do not trust userspace, use our own definition */
 	func = ioctl->func;
-	/* is there a local override? */
-	if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
-		func = dev->driver->dma_ioctl;
 
 	if (!func) {
 		DRM_DEBUG("no function\n");
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d933f06..1afa431 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1368,6 +1368,8 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 extern int drm_mapbufs(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
+extern int drm_dma_ioctl(struct drm_device *dev, void *data,
+			 struct drm_file *file_priv);
 
 				/* DMA support (drm_dma.h) */
 extern int drm_legacy_dma_setup(struct drm_device *dev);
-- 
1.8.3.2

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

* [PATCH 35/39] drm/memory: don't export agp helpers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (33 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 34/39] drm: remove the dma_ioctl special-case Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
                   ` (6 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

They're only used by the agpgart support code in drm_agpgart.c,
not by any drivers.

I think long-term we should create a drm_internal.h include file with
all the various functions only used by the drm core and not exported
to drivers, and remove them from drmP.h. Oh, and someone should kill
that upper-case P sometimes ;-) But that's all stuff for future patch
bombs.

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

diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 126d50e..64e44fa 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -86,7 +86,6 @@ void drm_free_agp(DRM_AGP_MEM * handle, int pages)
 {
 	agp_free_memory(handle);
 }
-EXPORT_SYMBOL(drm_free_agp);
 
 /** Wrapper around agp_bind_memory() */
 int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start)
@@ -99,7 +98,6 @@ int drm_unbind_agp(DRM_AGP_MEM * handle)
 {
 	return agp_unbind_memory(handle);
 }
-EXPORT_SYMBOL(drm_unbind_agp);
 
 #else  /*  __OS_HAS_AGP  */
 static inline void *agp_remap(unsigned long offset, unsigned long size,
-- 
1.8.3.2

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

* [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (34 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 35/39] drm/memory: don't export agp helpers Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-16 12:33   ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 37/39] drm: no-op out GET_STATS ioctl Daniel Vetter
                   ` (5 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

We not only have debugfs files to do pretty much the equivalent of
lsof, we also have an ioctl. Not that compared to lsof this dumps a
wee bit more information, but we can still get at that from debugfs
easily.

I've dug around in mesa, libdrm and ddx histories and the only users
seem to be drm/tests/dristat.c and drm/tests/getclients.c. The later
is a testcase for the ioctl itself since up to

commit b018fcdaa5e8b4eabb8cffda687d00004a3c4785
Author: Eric Anholt <eric@anholt.net>
Date:   Thu Nov 22 18:46:54 2007 +1000

    drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx

there was actually no way at all for userspace to enumerate all
clients since the kernel just wouldn't tell it when to stop. Which
completely broke it's only user, dristat -c.

So obviously that ioctl wasn't much use for debugging. Hence I don't
see any point in keeping support for a tool which was pretty obviously
never really used, and while we have good replacements in the form of
equivalent debugfs files.

Still, to keep dristat -c from looping forever again stop it early by
returning an unconditional -EINVAL. Also add a comment in the code
about why.

Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_ioctl.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 0acf080..5159fa0 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -216,29 +216,10 @@ int drm_getmap(struct drm_device *dev, void *data,
 int drm_getclient(struct drm_device *dev, void *data,
 		  struct drm_file *file_priv)
 {
-	struct drm_client *client = data;
-	struct drm_file *pt;
-	int idx;
-	int i;
-
-	idx = client->idx;
-	i = 0;
-
-	mutex_lock(&dev->struct_mutex);
-	list_for_each_entry(pt, &dev->filelist, lhead) {
-		if (i++ >= idx) {
-			client->auth = pt->authenticated;
-			client->pid = pid_vnr(pt->pid);
-			client->uid = from_kuid_munged(current_user_ns(), pt->uid);
-			client->magic = pt->magic;
-			client->iocs = pt->ioctl_count;
-			mutex_unlock(&dev->struct_mutex);
-
-			return 0;
-		}
-	}
-	mutex_unlock(&dev->struct_mutex);
-
+	/* Hollowed-out getclient ioctl to keep some dead old drm tests/tools
+	 * not breaking completely. Userspace tools stop enumerating one they
+	 * get -EINVAL, hence this is the return value we need to hand back for
+	 * no clients tracked. */
 	return -EINVAL;
 }
 
-- 
1.8.3.2

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

* [PATCH 37/39] drm: no-op out GET_STATS ioctl
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (35 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 38/39] drm: fix locking in gem debugfs/procfs file Daniel Vetter
                   ` (4 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Again only used by a tests in libdrm and by dristat. Nowadays we have
much better tracing tools to get detailed insights into what a drm
driver is doing. And for a simple "does it work" kind of question that
these stats could answer we have plenty of dmesg debug log spew.

So I don't see any use for this stat gathering complexity at all.

To be able to gradually drop things start with ripping out the
interfaces to it, here the ioctl.

To prevent dristat from eating its own stack garbage we can't use the
drm_noop ioctl though, since we need to clear the return data with a
memset.

Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_ioctl.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 5159fa0..fbe9219 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -237,21 +237,10 @@ int drm_getstats(struct drm_device *dev, void *data,
 		 struct drm_file *file_priv)
 {
 	struct drm_stats *stats = data;
-	int i;
 
+	/* Clear stats to prevent userspace from eating its stack garbage. */
 	memset(stats, 0, sizeof(*stats));
 
-	for (i = 0; i < dev->counters; i++) {
-		if (dev->types[i] == _DRM_STAT_LOCK)
-			stats->data[i].value =
-			    (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
-		else
-			stats->data[i].value = atomic_read(&dev->counts[i]);
-		stats->data[i].type = dev->types[i];
-	}
-
-	stats->count = dev->counters;
-
 	return 0;
 }
 
-- 
1.8.3.2

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

* [PATCH 38/39] drm: fix locking in gem debugfs/procfs file
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (36 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 37/39] drm: no-op out GET_STATS ioctl Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 12:12 ` [PATCH 39/39] drm: remove procfs code, take 2 Daniel Vetter
                   ` (3 subsequent siblings)
  41 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

The idr is protected with our spinlock, if we don't hold that nothing
prevents the gem objects from disappearing from under us.

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

diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index d4b20ce..9f8fc4c 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -218,7 +218,11 @@ int drm_gem_name_info(struct seq_file *m, void *data)
 	struct drm_device *dev = node->minor->dev;
 
 	seq_printf(m, "  name     size handles refcount\n");
+
+	spin_lock(&dev->object_name_lock);
 	idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m);
+	spin_unlock(&dev->object_name_lock);
+
 	return 0;
 }
 
-- 
1.8.3.2

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

* [PATCH 39/39] drm: remove procfs code, take 2
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (37 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 38/39] drm: fix locking in gem debugfs/procfs file Daniel Vetter
@ 2013-07-10 12:12 ` Daniel Vetter
  2013-07-10 20:44   ` [PATCH] " Daniel Vetter
  2013-07-10 15:32 ` [PATCH 00/39] clean out drm cruft and hide it better for kms drivers David Herrmann
                   ` (2 subsequent siblings)
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 12:12 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

So almost two years ago I've tried to nuke the procfs code already
once before:

http://lists.freedesktop.org/archives/dri-devel/2011-October/015707.html

The conclusion was that userspace drivers (specifically libdrm device
node detection) stopped relying on procfs in 2011. But after some
digging it turned out that the drmstat tool in libdrm is still using
those files (but only when certain options are set). So we've decided
to keep profcs.

But I when I've started to dig around again what exactly this tool
does I've noticed that it tries to read the "mem", "vm", and "vma"
files from procfs. Now as far my git history digging shows "mem" never
did anything useful (at least in the version that first showed up in
upstream history in 2004) and the file was remove in

commit 955b12def42e83287c1bdb1411d99451753c1391
Author: Ben Gamari <bgamari@gmail.com>
Date:   Tue Feb 17 20:08:49 2009 -0500

    drm: Convert proc files to seq_file and introduce debugfs

Which means that for over 4 years drmstat has been broken, and no one
cared. In my opinion that's proof enough that no one is actually using
drmstat, and so that we can savely nuke the procfs support from drm.

While at it fix up the error case cleanup for debugfs in drm_get_minor.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/Makefile   |   2 +-
 drivers/gpu/drm/drm_drv.c  |   8 --
 drivers/gpu/drm/drm_proc.c | 209 ---------------------------------------------
 drivers/gpu/drm/drm_stub.c |  32 ++-----
 include/drm/drmP.h         |   8 --
 5 files changed, 9 insertions(+), 250 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 801bcaf..3ca730c 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -7,7 +7,7 @@ ccflags-y := -Iinclude/drm
 drm-y       :=	drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
 		drm_context.o drm_dma.o \
 		drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
-		drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
+		drm_lock.o drm_memory.o drm_stub.o drm_vm.o \
 		drm_agpsupport.o drm_scatter.o drm_pci.o \
 		drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_modes.o drm_edid.o \
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index b349b5f..a9f48ff 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -257,13 +257,6 @@ static int __init drm_core_init(void)
 		goto err_p2;
 	}
 
-	drm_proc_root = proc_mkdir("dri", NULL);
-	if (!drm_proc_root) {
-		DRM_ERROR("Cannot create /proc/dri\n");
-		ret = -1;
-		goto err_p3;
-	}
-
 	drm_debugfs_root = debugfs_create_dir("dri", NULL);
 	if (!drm_debugfs_root) {
 		DRM_ERROR("Cannot create /sys/kernel/debug/dri\n");
@@ -286,7 +279,6 @@ err_p1:
 
 static void __exit drm_core_exit(void)
 {
-	remove_proc_entry("dri", NULL);
 	debugfs_remove(drm_debugfs_root);
 	drm_sysfs_destroy();
 
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
deleted file mode 100644
index d7f2324..0000000
--- a/drivers/gpu/drm/drm_proc.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * \file drm_proc.c
- * /proc support for DRM
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- *
- * \par Acknowledgements:
- *    Matthew J Sottek <matthew.j.sottek@intel.com> sent in a patch to fix
- *    the problem with the proc files not outputting all their information.
- */
-
-/*
- * Created: Mon Jan 11 09:48:47 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/seq_file.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drmP.h>
-
-/***************************************************
- * Initialization, etc.
- **************************************************/
-
-/**
- * Proc file list.
- */
-static const struct drm_info_list drm_proc_list[] = {
-	{"name", drm_name_info, 0},
-	{"vm", drm_vm_info, 0},
-	{"clients", drm_clients_info, 0},
-	{"bufs", drm_bufs_info, 0},
-	{"gem_names", drm_gem_name_info, DRIVER_GEM},
-#if DRM_DEBUG_CODE
-	{"vma", drm_vma_info, 0},
-#endif
-};
-#define DRM_PROC_ENTRIES ARRAY_SIZE(drm_proc_list)
-
-static int drm_proc_open(struct inode *inode, struct file *file)
-{
-	struct drm_info_node* node = PDE_DATA(inode);
-
-	return single_open(file, node->info_ent->show, node);
-}
-
-static const struct file_operations drm_proc_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_proc_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-
-/**
- * Initialize a given set of proc files for a device
- *
- * \param files The array of files to create
- * \param count The number of files given
- * \param root DRI proc dir entry.
- * \param minor device minor number
- * \return Zero on success, non-zero on failure
- *
- * Create a given set of proc files represented by an array of
- * gdm_proc_lists in the given root directory.
- */
-static int drm_proc_create_files(const struct drm_info_list *files, int count,
-			  struct proc_dir_entry *root, struct drm_minor *minor)
-{
-	struct drm_device *dev = minor->dev;
-	struct proc_dir_entry *ent;
-	struct drm_info_node *tmp;
-	int i;
-
-	for (i = 0; i < count; i++) {
-		u32 features = files[i].driver_features;
-
-		if (features != 0 &&
-		    (dev->driver->driver_features & features) != features)
-			continue;
-
-		tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
-		if (!tmp)
-			return -1;
-
-		tmp->minor = minor;
-		tmp->info_ent = &files[i];
-		list_add(&tmp->list, &minor->proc_nodes.list);
-
-		ent = proc_create_data(files[i].name, S_IRUGO, root,
-				       &drm_proc_fops, tmp);
-		if (!ent) {
-			DRM_ERROR("Cannot create /proc/dri/%u/%s\n",
-				  minor->index, files[i].name);
-			list_del(&tmp->list);
-			kfree(tmp);
-			return -1;
-		}
-	}
-	return 0;
-}
-
-/**
- * Initialize the DRI proc filesystem for a device
- *
- * \param dev DRM device
- * \param root DRI proc dir entry.
- * \param dev_root resulting DRI device proc dir entry.
- * \return root entry pointer on success, or NULL on failure.
- *
- * Create the DRI proc root entry "/proc/dri", the device proc root entry
- * "/proc/dri/%minor%/", and each entry in proc_list as
- * "/proc/dri/%minor%/%name%".
- */
-int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root)
-{
-	char name[12];
-	int ret;
-
-	INIT_LIST_HEAD(&minor->proc_nodes.list);
-	sprintf(name, "%u", minor->index);
-	minor->proc_root = proc_mkdir(name, root);
-	if (!minor->proc_root) {
-		DRM_ERROR("Cannot create /proc/dri/%s\n", name);
-		return -1;
-	}
-
-	ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES,
-				    minor->proc_root, minor);
-	if (ret) {
-		remove_proc_subtree(name, root);
-		minor->proc_root = NULL;
-		DRM_ERROR("Failed to create core drm proc files\n");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int drm_proc_remove_files(const struct drm_info_list *files, int count,
-			  struct drm_minor *minor)
-{
-	struct list_head *pos, *q;
-	struct drm_info_node *tmp;
-	int i;
-
-	for (i = 0; i < count; i++) {
-		list_for_each_safe(pos, q, &minor->proc_nodes.list) {
-			tmp = list_entry(pos, struct drm_info_node, list);
-			if (tmp->info_ent == &files[i]) {
-				remove_proc_entry(files[i].name,
-						  minor->proc_root);
-				list_del(pos);
-				kfree(tmp);
-			}
-		}
-	}
-	return 0;
-}
-
-/**
- * Cleanup the proc filesystem resources.
- *
- * \param minor device minor number.
- * \param root DRI proc dir entry.
- * \param dev_root DRI device proc dir entry.
- * \return always zero.
- *
- * Remove all proc entries created by proc_init().
- */
-int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root)
-{
-	char name[64];
-
-	if (!root || !minor->proc_root)
-		return 0;
-
-	drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor);
-
-	sprintf(name, "%d", minor->index);
-	remove_proc_subtree(name, root);
-	return 0;
-}
-
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 30cbd62..f9cacf5 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -68,7 +68,6 @@ module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
 struct idr drm_minors_idr;
 
 struct class *drm_class;
-struct proc_dir_entry *drm_proc_root;
 struct dentry *drm_debugfs_root;
 
 int drm_err(const char *func, const char *format, ...)
@@ -315,9 +314,8 @@ EXPORT_SYMBOL(drm_fill_in_dev);
  * \param sec-minor structure to hold the assigned minor
  * \return negative number on failure.
  *
- * Search an empty entry and initialize it to the given parameters, and
- * create the proc init entry via proc_init(). This routines assigns
- * minor numbers to secondary heads of multi-headed cards
+ * Search an empty entry and initialize it to the given parameters. This
+ * routines assigns minor numbers to secondary heads of multi-headed cards
  */
 int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 {
@@ -345,20 +343,11 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 
 	idr_replace(&drm_minors_idr, new_minor, minor_id);
 
-	if (type == DRM_MINOR_LEGACY) {
-		ret = drm_proc_init(new_minor, drm_proc_root);
-		if (ret) {
-			DRM_ERROR("DRM: Failed to initialize /proc/dri.\n");
-			goto err_mem;
-		}
-	} else
-		new_minor->proc_root = NULL;
-
 #if defined(CONFIG_DEBUG_FS)
 	ret = drm_debugfs_init(new_minor, minor_id, drm_debugfs_root);
 	if (ret) {
 		DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n");
-		goto err_g2;
+		goto err_mem;
 	}
 #endif
 
@@ -366,7 +355,7 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 	if (ret) {
 		printk(KERN_ERR
 		       "DRM: Error sysfs_device_add.\n");
-		goto err_g2;
+		goto err_debugfs;
 	}
 	*minor = new_minor;
 
@@ -374,9 +363,10 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 	return 0;
 
 
-err_g2:
-	if (new_minor->type == DRM_MINOR_LEGACY)
-		drm_proc_cleanup(new_minor, drm_proc_root);
+err_debugfs:
+#if defined(CONFIG_DEBUG_FS)
+	drm_debugfs_cleanup(new_minor);
+#endif
 err_mem:
 	kfree(new_minor);
 err_idr:
@@ -391,10 +381,6 @@ EXPORT_SYMBOL(drm_get_minor);
  *
  * \param sec_minor - structure to be released
  * \return always zero
- *
- * Cleans up the proc resources. Not legal for this to be the
- * last minor released.
- *
  */
 int drm_put_minor(struct drm_minor **minor_p)
 {
@@ -402,8 +388,6 @@ int drm_put_minor(struct drm_minor **minor_p)
 
 	DRM_DEBUG("release secondary minor %d\n", minor->index);
 
-	if (minor->type == DRM_MINOR_LEGACY)
-		drm_proc_cleanup(minor, drm_proc_root);
 #if defined(CONFIG_DEBUG_FS)
 	drm_debugfs_cleanup(minor);
 #endif
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1afa431..d0043b8 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -45,7 +45,6 @@
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/fs.h>
-#include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/platform_device.h>
@@ -1021,8 +1020,6 @@ struct drm_minor {
 	struct device kdev;		/**< Linux device */
 	struct drm_device *dev;
 
-	struct proc_dir_entry *proc_root;  /**< proc directory entry */
-	struct drm_info_node proc_nodes;
 	struct dentry *debugfs_root;
 
 	struct list_head debugfs_list;
@@ -1474,17 +1471,12 @@ extern unsigned int drm_timestamp_precision;
 extern unsigned int drm_timestamp_monotonic;
 
 extern struct class *drm_class;
-extern struct proc_dir_entry *drm_proc_root;
 extern struct dentry *drm_debugfs_root;
 
 extern struct idr drm_minors_idr;
 
 extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
 
-				/* Proc support (drm_proc.h) */
-extern int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root);
-extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
-
 				/* Debugfs support */
 #if defined(CONFIG_DEBUG_FS)
 extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
-- 
1.8.3.2

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

* Re: [PATCH 08/39] drm: remove redundant clears from drm_setup
  2013-07-10 12:11 ` [PATCH 08/39] drm: remove redundant clears from drm_setup Daniel Vetter
@ 2013-07-10 13:28   ` David Herrmann
  2013-07-10 15:19     ` Daniel Vetter
  0 siblings, 1 reply; 71+ messages in thread
From: David Herrmann @ 2013-07-10 13:28 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi

On Wed, Jul 10, 2013 at 2:11 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> We kzalloc the driver node at init time, so no need to do this again.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_fops.c | 9 ---------
>  1 file changed, 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 57e3014..9610997 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -73,15 +73,6 @@ static int drm_setup(struct drm_device * dev)
>         for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
>                 atomic_set(&dev->counts[i], 0);
>
> -       dev->sigdata.lock = NULL;
> -
> -       dev->context_flag = 0;
> -       dev->last_context = 0;
> -       dev->last_checked = 0;
> -       dev->if_version = 0;
> -
> -       dev->buf_async = NULL;
> -

drm_setup() is called on every first open. I digged through core DRM
and noticed that we have a lot of code that cleans up on lastclose and
reinitializes on firstopen which is skipped for non-UMS drivers to
preserve KMS state if no user keeps DRM node open. I would like to
hear a comment in the commit-message which explains why we don't reset
"if_version", anymore. Are you sure UMS user-space does not depend on
this logic?

I have no idea of UMS, but if that reinitialization on
lastclose+firstopen is not relied on, I guess we can remove a lot more
code. Just wanted to make sure that this is right.

Cheers
David

>         DRM_DEBUG("\n");
>
>         /*
> --
> 1.8.3.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 12:12 ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Daniel Vetter
@ 2013-07-10 13:51   ` David Herrmann
  2013-07-10 15:22     ` Daniel Vetter
  0 siblings, 1 reply; 71+ messages in thread
From: David Herrmann @ 2013-07-10 13:51 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development, Andy Lutomirski

Hi

On Wed, Jul 10, 2013 at 2:12 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> The new arch_phys_wc_add/del functions do the right thing both with
> and without MTRR support in the kernel. So we can drop these
> additional checks.
>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_bufs.c | 13 +++++--------
>  drivers/gpu/drm/drm_pci.c  | 11 +++++------
>  drivers/gpu/drm/drm_stub.c |  2 +-
>  drivers/gpu/drm/drm_vm.c   |  3 +--
>  include/drm/drmP.h         | 10 ----------
>  5 files changed, 12 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 5f73f0a..f63133b 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -207,12 +207,10 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
>                         return 0;
>                 }
>
> -               if (drm_core_has_MTRR(dev)) {
> -                       if (map->type == _DRM_FRAME_BUFFER ||
> -                           (map->flags & _DRM_WRITE_COMBINING)) {
> -                               map->mtrr =
> -                                       arch_phys_wc_add(map->offset, map->size);
> -                       }
> +               if (map->type == _DRM_FRAME_BUFFER ||
> +                   (map->flags & _DRM_WRITE_COMBINING)) {
> +                       map->mtrr =
> +                               arch_phys_wc_add(map->offset, map->size);
>                 }
>                 if (map->type == _DRM_REGISTERS) {
>                         if (map->flags & _DRM_WRITE_COMBINING)
> @@ -464,8 +462,7 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
>                 iounmap(map->handle);
>                 /* FALLTHROUGH */
>         case _DRM_FRAME_BUFFER:
> -               if (drm_core_has_MTRR(dev))
> -                       arch_phys_wc_del(map->mtrr);
> +               arch_phys_wc_del(map->mtrr);
>                 break;
>         case _DRM_SHM:
>                 vfree(map->handle);
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 80c0b2b..9e93ea5 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -276,12 +276,11 @@ static int drm_pci_agp_init(struct drm_device *dev)
>                         DRM_ERROR("Cannot initialize the agpgart module.\n");
>                         return -EINVAL;
>                 }
> -               if (drm_core_has_MTRR(dev)) {
> -                       if (dev->agp)
> -                               dev->agp->agp_mtrr = arch_phys_wc_add(
> -                                       dev->agp->agp_info.aper_base,
> -                                       dev->agp->agp_info.aper_size *
> -                                       1024 * 1024);
> +               if (dev->agp) {
> +                       dev->agp->agp_mtrr = arch_phys_wc_add(
> +                               dev->agp->agp_info.aper_base,
> +                               dev->agp->agp_info.aper_size *
> +                               1024 * 1024);
>                 }
>         }
>         return 0;
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index e7471ef..30cbd62 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -445,7 +445,7 @@ void drm_put_dev(struct drm_device *dev)
>
>         drm_lastclose(dev);
>
> -       if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp)
> +       if (dev->agp)
>                 arch_phys_wc_del(dev->agp->agp_mtrr);
>
>         if (dev->driver->unload)
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index feb2003..b5c5af7 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -251,8 +251,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
>                         switch (map->type) {
>                         case _DRM_REGISTERS:
>                         case _DRM_FRAME_BUFFER:
> -                               if (drm_core_has_MTRR(dev))
> -                                       arch_phys_wc_del(map->mtrr);
> +                               arch_phys_wc_del(map->mtrr);
>                                 iounmap(map->handle);
>                                 break;
>                         case _DRM_SHM:
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 62e9e41..d933f06 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -75,7 +75,6 @@
>  #include <linux/idr.h>
>
>  #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
> -#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
>
>  struct module;
>
> @@ -1220,15 +1219,6 @@ static inline int drm_core_has_AGP(struct drm_device *dev)
>  #define drm_core_has_AGP(dev) (0)
>  #endif
>
> -#if __OS_HAS_MTRR
> -static inline int drm_core_has_MTRR(struct drm_device *dev)
> -{
> -       return drm_core_check_feature(dev, DRIVER_USE_MTRR);
> -}
> -#else
> -#define drm_core_has_MTRR(dev) (0)
> -#endif
> -

That was the last user of DRIVER_USE_MTRR (apart from drivers setting
it in .driver_features). Any reason to keep it around?

Cheers
David

>  static inline void drm_device_set_unplugged(struct drm_device *dev)
>  {
>         smp_wmb();
> --
> 1.8.3.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 34/39] drm: remove the dma_ioctl special-case
  2013-07-10 12:12 ` [PATCH 34/39] drm: remove the dma_ioctl special-case Daniel Vetter
@ 2013-07-10 14:34   ` David Herrmann
  2013-07-10 14:59     ` [PATCH] " Daniel Vetter
  0 siblings, 1 reply; 71+ messages in thread
From: David Herrmann @ 2013-07-10 14:34 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi

On Wed, Jul 10, 2013 at 2:12 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> We might as well have a real ioctl function which checks for the
> callbacks. This seems to be a remnant from back in the days when each
> drm driver had their own complete ioctl table, with no shared core
> drm table at all.
>
> To make really sure no mis-guided user in a kms driver pops up again
> explicitly check for that in the new ioctl implementation.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_bufs.c | 14 ++++++++++++++
>  drivers/gpu/drm/drm_drv.c  |  6 +-----
>  include/drm/drmP.h         |  2 ++
>  3 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index f63133b..ff7fe80 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -1455,6 +1455,20 @@ int drm_mapbufs(struct drm_device *dev, void *data,
>         return retcode;
>  }
>
> +int drm_dma_ioctl(struct drm_device *dev, void *data,
> +                 struct drm_file *file_priv)
> +{
> +       struct drm_device_dma *dma = dev->dma;

Unused variable.

Cheers
David

> +
> +       if (drm_core_check_feature(dev, DRIVER_MODESET))
> +               return -EINVAL;
> +
> +       if (dev->driver->dma_ioctl)
> +               return dev->driver->dma_ioctl(dev, data, file_priv);
> +       else
> +               return -EINVAL;
> +}
> +
>  struct drm_local_map *drm_getsarea(struct drm_device *dev)
>  {
>         struct drm_map_list *entry;
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index f2495e1..b349b5f 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -106,8 +106,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
>         DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
>         DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
>         DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
> -       /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
> -       DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
> +       DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma_ioctl, DRM_AUTH),
>
>         DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
>
> @@ -415,9 +414,6 @@ long drm_ioctl(struct file *filp,
>
>         /* Do not trust userspace, use our own definition */
>         func = ioctl->func;
> -       /* is there a local override? */
> -       if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
> -               func = dev->driver->dma_ioctl;
>
>         if (!func) {
>                 DRM_DEBUG("no function\n");
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index d933f06..1afa431 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1368,6 +1368,8 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
>                         struct drm_file *file_priv);
>  extern int drm_mapbufs(struct drm_device *dev, void *data,
>                        struct drm_file *file_priv);
> +extern int drm_dma_ioctl(struct drm_device *dev, void *data,
> +                        struct drm_file *file_priv);
>
>                                 /* DMA support (drm_dma.h) */
>  extern int drm_legacy_dma_setup(struct drm_device *dev);
> --
> 1.8.3.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] drm: remove FASYNC support
  2013-07-10 12:12 ` [PATCH 29/39] drm: remove FASYNC support Daniel Vetter
@ 2013-07-10 14:57   ` Daniel Vetter
  2013-07-10 15:24     ` Daniel Vetter
  2013-07-10 15:25     ` Daniel Vetter
  0 siblings, 2 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 14:57 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

So I've stumbled over drm_fasync and wondered what it does. Digging
that up is quite a story.

First I've had to read up on what this does and ended up being rather
bewildered why peopled loved signals so much back in the days that
they've created SIGIO just for that ...

Then I wondered how this ever works, and what that strange "No-op."
comment right above it should mean. After all calling the core fasync
helper is pretty obviously not a noop. After reading through the
kernels FASYNC implementation I've noticed that signals are only sent
out to the processes attached with FASYNC by calling kill_fasync.

No merged drm driver has ever done that.

After more digging I've found out that the only driver that ever used
this is the so called GAMMA driver. I've frankly never heard of such a
gpu brand ever before. Now FASYNC seems to not have been the only bad
thing with that driver, since Dave Airlie removed it from the drm
driver with prejudice:

commit 1430163b4bbf7b00367ea1066c1c5fe85dbeefed
Author: Dave Airlie <airlied@linux.ie>
Date:   Sun Aug 29 12:04:35 2004 +0000

    Drop GAMMA DRM from a great height ...

Long story short, the drm fasync support seems to be doing absolutely
nothing. And the only user of it was never merged into the upstream
kernel. And we don't need any fops->fasync callback since the fcntl
implementation in the kernel already implements the noop case
correctly.

So stop this particular cargo-cult and rip it all out.

v2: Kill drm_fasync assignments in rcar (newly added) and imx drivers
(somehow I've missed that one in staging). Also drop the reference in
the drm DocBook. ARM compile-fail reported by Rob Clark.

Cc: Dave Airlie <airlied@linux.ie>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl           |  1 -
 drivers/gpu/drm/ast/ast_drv.c            |  1 -
 drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 -
 drivers/gpu/drm/drm_fops.c               | 12 ------------
 drivers/gpu/drm/gma500/psb_drv.c         |  1 -
 drivers/gpu/drm/i810/i810_dma.c          |  1 -
 drivers/gpu/drm/i810/i810_drv.c          |  1 -
 drivers/gpu/drm/i915/i915_drv.c          |  1 -
 drivers/gpu/drm/mga/mga_drv.c            |  1 -
 drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c    |  1 -
 drivers/gpu/drm/omapdrm/omap_drv.c       |  1 -
 drivers/gpu/drm/qxl/qxl_drv.c            |  1 -
 drivers/gpu/drm/r128/r128_drv.c          |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c      |  2 --
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |  1 -
 drivers/gpu/drm/savage/savage_drv.c      |  1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 -
 drivers/gpu/drm/sis/sis_drv.c            |  1 -
 drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 -
 drivers/gpu/drm/udl/udl_drv.c            |  1 -
 drivers/gpu/drm/via/via_drv.c            |  1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 -
 drivers/gpu/host1x/drm/drm.c             |  1 -
 drivers/staging/imx-drm/imx-drm-core.c   |  1 -
 include/drm/drmP.h                       |  3 ---
 27 files changed, 41 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4d54ac8..79dd70e 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2498,7 +2498,6 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
 	<programlisting>
 	.poll = drm_poll,
 	.read = drm_read,
-	.fasync = drm_fasync,
 	.llseek = no_llseek,
 	</programlisting>
       </para>
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index df0d0a0..16050ed 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -190,7 +190,6 @@ static const struct file_operations ast_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = ast_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 8ecb601..85748f6 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -85,7 +85,6 @@ static const struct file_operations cirrus_driver_fops = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
-	.fasync = drm_fasync,
 };
 static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index ca6c946..392ce89 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -365,18 +365,6 @@ out_put_pid:
 	return ret;
 }
 
-/** No-op. */
-int drm_fasync(int fd, struct file *filp, int on)
-{
-	struct drm_file *priv = filp->private_data;
-	struct drm_device *dev = priv->minor->dev;
-
-	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
-		  (long)old_encode_dev(priv->minor->device));
-	return fasync_helper(fd, filp, on, &dev->buf_async);
-}
-EXPORT_SYMBOL(drm_fasync);
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
 	struct drm_file *file_priv = filp->private_data;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index bddea58..c9c37ac 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -622,7 +622,6 @@ static const struct file_operations psb_gem_fops = {
 	.unlocked_ioctl = psb_unlocked_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 };
 
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 004ecdf..ef1c9c7 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -113,7 +113,6 @@ static const struct file_operations i810_buffer_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = i810_mmap_buffers,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 2e91fc3..d85c05b 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -49,7 +49,6 @@ static const struct file_operations i810_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 062cbda..999ef21 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1110,7 +1110,6 @@ static const struct file_operations i915_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = i915_compat_ioctl,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 17d0a63..fe71e1e 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -50,7 +50,6 @@ static const struct file_operations mga_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = mga_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 122b571..31ff081 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -81,7 +81,6 @@ static const struct file_operations mgag200_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = mgag200_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index e990327..e09debe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -664,7 +664,6 @@ nouveau_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = nouveau_ttm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = nouveau_compat_ioctl,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 3f7c78a..fd2cfed 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -577,7 +577,6 @@ static const struct file_operations omapdriver_fops = {
 		.release = drm_release,
 		.mmap = omap_gem_mmap,
 		.poll = drm_poll,
-		.fasync = drm_fasync,
 		.read = drm_read,
 		.llseek = noop_llseek,
 };
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index df0b577..4be5225 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -84,7 +84,6 @@ static const struct file_operations qxl_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.mmap = qxl_mmap,
 };
 
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 472c38f..c2338cb 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations r128_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = r128_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 81b9baa..ae94625 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -265,7 +265,6 @@ static const struct file_operations radeon_driver_old_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_compat_ioctl,
@@ -374,7 +373,6 @@ static const struct file_operations radeon_driver_kms_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = radeon_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_kms_compat_ioctl,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index ff82877..46e5967 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -230,7 +230,6 @@ static const struct file_operations rcar_du_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 71b2081..9135c8b 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -42,7 +42,6 @@ static const struct file_operations savage_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index edc1018..db94f2f 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -257,7 +257,6 @@ static const struct file_operations shmob_drm_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 5a5325e..b88b2d3 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -72,7 +72,6 @@ static const struct file_operations sis_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index ddfa743..951ec13 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations tdfx_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 40b71da..ff920ff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -497,7 +497,6 @@ static const struct file_operations fops = {
 #endif
 	.poll               = drm_poll,
 	.read               = drm_read,
-	.fasync             = drm_fasync,
 	.llseek             = no_llseek,
 	.mmap               = drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index c0770db..c275adb 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -65,7 +65,6 @@ static const struct file_operations udl_driver_fops = {
 	.read = drm_read,
 	.unlocked_ioctl	= drm_ioctl,
 	.release = drm_release,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index f4ae203..4487999 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -64,7 +64,6 @@ static const struct file_operations via_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 3e75dfa..77d503a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1103,7 +1103,6 @@ static const struct file_operations vmwgfx_driver_fops = {
 	.mmap = vmw_mmap,
 	.poll = vmw_fops_poll,
 	.read = vmw_fops_read,
-	.fasync = drm_fasync,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index e184b00..f8b708f 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -508,7 +508,6 @@ static const struct file_operations tegra_drm_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = tegra_drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 70f9650..f1cde28 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -199,7 +199,6 @@ static const struct file_operations imx_drm_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_cma_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 	.llseek = noop_llseek,
 };
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d38c358..3589736 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1169,8 +1169,6 @@ struct drm_device {
 
 	/*@} */
 
-	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
-
 	struct drm_agp_head *agp;	/**< AGP data */
 
 	struct device *dev;             /**< Device structure */
@@ -1277,7 +1275,6 @@ extern int drm_lastclose(struct drm_device *dev);
 extern struct mutex drm_global_mutex;
 extern int drm_open(struct inode *inode, struct file *filp);
 extern int drm_stub_open(struct inode *inode, struct file *filp);
-extern int drm_fasync(int fd, struct file *filp, int on);
 extern ssize_t drm_read(struct file *filp, char __user *buffer,
 			size_t count, loff_t *offset);
 extern int drm_release(struct inode *inode, struct file *filp);
-- 
1.8.3.2

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

* [PATCH] drm: remove the dma_ioctl special-case
  2013-07-10 14:34   ` David Herrmann
@ 2013-07-10 14:59     ` Daniel Vetter
  0 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 14:59 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

We might as well have a real ioctl function which checks for the
callbacks. This seems to be a remnant from back in the days when each
drm driver had their own complete ioctl table, with no shared core
drm table at all.

To make really sure no mis-guided user in a kms driver pops up again
explicitly check for that in the new ioctl implementation.

v2: Drop the unused variable I've accidentally left in the code,
spotted by David Herrmann.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_bufs.c | 12 ++++++++++++
 drivers/gpu/drm/drm_drv.c  |  6 +-----
 include/drm/drmP.h         |  2 ++
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index f63133b..471e051d 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1455,6 +1455,18 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	return retcode;
 }
 
+int drm_dma_ioctl(struct drm_device *dev, void *data,
+		  struct drm_file *file_priv)
+{
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	if (dev->driver->dma_ioctl)
+		return dev->driver->dma_ioctl(dev, data, file_priv);
+	else
+		return -EINVAL;
+}
+
 struct drm_local_map *drm_getsarea(struct drm_device *dev)
 {
 	struct drm_map_list *entry;
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f2495e1..b349b5f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -106,8 +106,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
 	DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
-	/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
-	DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma_ioctl, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
@@ -415,9 +414,6 @@ long drm_ioctl(struct file *filp,
 
 	/* Do not trust userspace, use our own definition */
 	func = ioctl->func;
-	/* is there a local override? */
-	if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->driver->dma_ioctl)
-		func = dev->driver->dma_ioctl;
 
 	if (!func) {
 		DRM_DEBUG("no function\n");
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d933f06..1afa431 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1368,6 +1368,8 @@ extern int drm_freebufs(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 extern int drm_mapbufs(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
+extern int drm_dma_ioctl(struct drm_device *dev, void *data,
+			 struct drm_file *file_priv);
 
 				/* DMA support (drm_dma.h) */
 extern int drm_legacy_dma_setup(struct drm_device *dev);
-- 
1.8.3.2

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

* Re: [PATCH 08/39] drm: remove redundant clears from drm_setup
  2013-07-10 13:28   ` David Herrmann
@ 2013-07-10 15:19     ` Daniel Vetter
  0 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:19 UTC (permalink / raw)
  To: David Herrmann; +Cc: DRI Development

On Wed, Jul 10, 2013 at 3:28 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> drm_setup() is called on every first open. I digged through core DRM
> and noticed that we have a lot of code that cleans up on lastclose and
> reinitializes on firstopen which is skipped for non-UMS drivers to
> preserve KMS state if no user keeps DRM node open. I would like to
> hear a comment in the commit-message which explains why we don't reset
> "if_version", anymore. Are you sure UMS user-space does not depend on
> this logic?
>
> I have no idea of UMS, but if that reinitialization on
> lastclose+firstopen is not relied on, I guess we can remove a lot more
> code. Just wanted to make sure that this is right.

Yeah, you're right. I've been confused a bit with the need_setup logic
and though that's only done once. But for ums drivers this seems to be
done every time we restart X.

I think I'll rework this patch here and shovel stuff around some more.
E.g. the buf_async stuff can die with drm_fasync, and I think the
re-init is better handled in functions called by drm_lastclose.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 13:51   ` David Herrmann
@ 2013-07-10 15:22     ` Daniel Vetter
  2013-07-10 15:41       ` David Herrmann
  0 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:22 UTC (permalink / raw)
  To: David Herrmann; +Cc: DRI Development, Andy Lutomirski

On Wed, Jul 10, 2013 at 3:51 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>> -#if __OS_HAS_MTRR
>> -static inline int drm_core_has_MTRR(struct drm_device *dev)
>> -{
>> -       return drm_core_check_feature(dev, DRIVER_USE_MTRR);
>> -}
>> -#else
>> -#define drm_core_has_MTRR(dev) (0)
>> -#endif
>> -
>
> That was the last user of DRIVER_USE_MTRR (apart from drivers setting
> it in .driver_features). Any reason to keep it around?

Yeah, I guess we could rip things out. Which will also force me to
properly audit drivers for the eventual behaviour change this could
entail (in case there's an x86 driver which did not ask for an mtrr,
but iirc there isn't).
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* [PATCH] drm: remove FASYNC support
  2013-07-10 14:57   ` [PATCH] " Daniel Vetter
@ 2013-07-10 15:24     ` Daniel Vetter
  2013-07-10 15:25     ` Daniel Vetter
  1 sibling, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:24 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

So I've stumbled over drm_fasync and wondered what it does. Digging
that up is quite a story.

First I've had to read up on what this does and ended up being rather
bewildered why peopled loved signals so much back in the days that
they've created SIGIO just for that ...

Then I wondered how this ever works, and what that strange "No-op."
comment right above it should mean. After all calling the core fasync
helper is pretty obviously not a noop. After reading through the
kernels FASYNC implementation I've noticed that signals are only sent
out to the processes attached with FASYNC by calling kill_fasync.

No merged drm driver has ever done that.

After more digging I've found out that the only driver that ever used
this is the so called GAMMA driver. I've frankly never heard of such a
gpu brand ever before. Now FASYNC seems to not have been the only bad
thing with that driver, since Dave Airlie removed it from the drm
driver with prejudice:

commit 1430163b4bbf7b00367ea1066c1c5fe85dbeefed
Author: Dave Airlie <airlied@linux.ie>
Date:   Sun Aug 29 12:04:35 2004 +0000

    Drop GAMMA DRM from a great height ...

Long story short, the drm fasync support seems to be doing absolutely
nothing. And the only user of it was never merged into the upstream
kernel. And we don't need any fops->fasync callback since the fcntl
implementation in the kernel already implements the noop case
correctly.

So stop this particular cargo-cult and rip it all out.

v2: Kill drm_fasync assignments in rcar (newly added) and imx drivers
(somehow I've missed that one in staging). Also drop the reference in
the drm DocBook. ARM compile-fail reported by Rob Clark.

v3: Move the removal of dev->buf_asnyc assignment in drm_setup to this
patch here.

Cc: Dave Airlie <airlied@linux.ie>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl           |  1 -
 drivers/gpu/drm/ast/ast_drv.c            |  1 -
 drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 -
 drivers/gpu/drm/drm_fops.c               | 12 ------------
 drivers/gpu/drm/gma500/psb_drv.c         |  1 -
 drivers/gpu/drm/i810/i810_dma.c          |  1 -
 drivers/gpu/drm/i810/i810_drv.c          |  1 -
 drivers/gpu/drm/i915/i915_drv.c          |  1 -
 drivers/gpu/drm/mga/mga_drv.c            |  1 -
 drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c    |  1 -
 drivers/gpu/drm/omapdrm/omap_drv.c       |  1 -
 drivers/gpu/drm/qxl/qxl_drv.c            |  1 -
 drivers/gpu/drm/r128/r128_drv.c          |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c      |  2 --
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |  1 -
 drivers/gpu/drm/savage/savage_drv.c      |  1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 -
 drivers/gpu/drm/sis/sis_drv.c            |  1 -
 drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 -
 drivers/gpu/drm/udl/udl_drv.c            |  1 -
 drivers/gpu/drm/via/via_drv.c            |  1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 -
 drivers/gpu/host1x/drm/drm.c             |  1 -
 drivers/staging/imx-drm/imx-drm-core.c   |  1 -
 include/drm/drmP.h                       |  3 ---
 27 files changed, 41 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4d54ac8..79dd70e 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2498,7 +2498,6 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
 	<programlisting>
 	.poll = drm_poll,
 	.read = drm_read,
-	.fasync = drm_fasync,
 	.llseek = no_llseek,
 	</programlisting>
       </para>
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index df0d0a0..16050ed 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -190,7 +190,6 @@ static const struct file_operations ast_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = ast_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 8ecb601..85748f6 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -85,7 +85,6 @@ static const struct file_operations cirrus_driver_fops = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
-	.fasync = drm_fasync,
 };
 static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 14e0bb6..aa846df 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -374,18 +374,6 @@ out_put_pid:
 	return ret;
 }
 
-/** No-op. */
-int drm_fasync(int fd, struct file *filp, int on)
-{
-	struct drm_file *priv = filp->private_data;
-	struct drm_device *dev = priv->minor->dev;
-
-	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
-		  (long)old_encode_dev(priv->minor->device));
-	return fasync_helper(fd, filp, on, &dev->buf_async);
-}
-EXPORT_SYMBOL(drm_fasync);
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
 	struct drm_file *file_priv = filp->private_data;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index bddea58..c9c37ac 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -622,7 +622,6 @@ static const struct file_operations psb_gem_fops = {
 	.unlocked_ioctl = psb_unlocked_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 };
 
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 004ecdf..ef1c9c7 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -113,7 +113,6 @@ static const struct file_operations i810_buffer_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = i810_mmap_buffers,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 2e91fc3..d85c05b 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -49,7 +49,6 @@ static const struct file_operations i810_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 062cbda..999ef21 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1110,7 +1110,6 @@ static const struct file_operations i915_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = i915_compat_ioctl,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 17d0a63..fe71e1e 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -50,7 +50,6 @@ static const struct file_operations mga_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = mga_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 122b571..31ff081 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -81,7 +81,6 @@ static const struct file_operations mgag200_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = mgag200_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index e990327..e09debe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -664,7 +664,6 @@ nouveau_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = nouveau_ttm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = nouveau_compat_ioctl,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 3f7c78a..fd2cfed 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -577,7 +577,6 @@ static const struct file_operations omapdriver_fops = {
 		.release = drm_release,
 		.mmap = omap_gem_mmap,
 		.poll = drm_poll,
-		.fasync = drm_fasync,
 		.read = drm_read,
 		.llseek = noop_llseek,
 };
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index df0b577..4be5225 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -84,7 +84,6 @@ static const struct file_operations qxl_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.mmap = qxl_mmap,
 };
 
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 472c38f..c2338cb 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations r128_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = r128_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 81b9baa..ae94625 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -265,7 +265,6 @@ static const struct file_operations radeon_driver_old_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_compat_ioctl,
@@ -374,7 +373,6 @@ static const struct file_operations radeon_driver_kms_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = radeon_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_kms_compat_ioctl,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index ff82877..46e5967 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -230,7 +230,6 @@ static const struct file_operations rcar_du_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 71b2081..9135c8b 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -42,7 +42,6 @@ static const struct file_operations savage_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index edc1018..db94f2f 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -257,7 +257,6 @@ static const struct file_operations shmob_drm_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 5a5325e..b88b2d3 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -72,7 +72,6 @@ static const struct file_operations sis_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index ddfa743..951ec13 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations tdfx_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 40b71da..ff920ff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -497,7 +497,6 @@ static const struct file_operations fops = {
 #endif
 	.poll               = drm_poll,
 	.read               = drm_read,
-	.fasync             = drm_fasync,
 	.llseek             = no_llseek,
 	.mmap               = drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index c0770db..c275adb 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -65,7 +65,6 @@ static const struct file_operations udl_driver_fops = {
 	.read = drm_read,
 	.unlocked_ioctl	= drm_ioctl,
 	.release = drm_release,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index f4ae203..4487999 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -64,7 +64,6 @@ static const struct file_operations via_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 3e75dfa..77d503a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1103,7 +1103,6 @@ static const struct file_operations vmwgfx_driver_fops = {
 	.mmap = vmw_mmap,
 	.poll = vmw_fops_poll,
 	.read = vmw_fops_read,
-	.fasync = drm_fasync,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index e184b00..f8b708f 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -508,7 +508,6 @@ static const struct file_operations tegra_drm_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = tegra_drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 70f9650..f1cde28 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -199,7 +199,6 @@ static const struct file_operations imx_drm_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_cma_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 	.llseek = noop_llseek,
 };
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d38c358..3589736 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1169,8 +1169,6 @@ struct drm_device {
 
 	/*@} */
 
-	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
-
 	struct drm_agp_head *agp;	/**< AGP data */
 
 	struct device *dev;             /**< Device structure */
@@ -1277,7 +1275,6 @@ extern int drm_lastclose(struct drm_device *dev);
 extern struct mutex drm_global_mutex;
 extern int drm_open(struct inode *inode, struct file *filp);
 extern int drm_stub_open(struct inode *inode, struct file *filp);
-extern int drm_fasync(int fd, struct file *filp, int on);
 extern ssize_t drm_read(struct file *filp, char __user *buffer,
 			size_t count, loff_t *offset);
 extern int drm_release(struct inode *inode, struct file *filp);
-- 
1.8.3.2

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

* [PATCH] drm: remove FASYNC support
  2013-07-10 14:57   ` [PATCH] " Daniel Vetter
  2013-07-10 15:24     ` Daniel Vetter
@ 2013-07-10 15:25     ` Daniel Vetter
  2013-07-11  0:26       ` Laurent Pinchart
  1 sibling, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:25 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

So I've stumbled over drm_fasync and wondered what it does. Digging
that up is quite a story.

First I've had to read up on what this does and ended up being rather
bewildered why peopled loved signals so much back in the days that
they've created SIGIO just for that ...

Then I wondered how this ever works, and what that strange "No-op."
comment right above it should mean. After all calling the core fasync
helper is pretty obviously not a noop. After reading through the
kernels FASYNC implementation I've noticed that signals are only sent
out to the processes attached with FASYNC by calling kill_fasync.

No merged drm driver has ever done that.

After more digging I've found out that the only driver that ever used
this is the so called GAMMA driver. I've frankly never heard of such a
gpu brand ever before. Now FASYNC seems to not have been the only bad
thing with that driver, since Dave Airlie removed it from the drm
driver with prejudice:

commit 1430163b4bbf7b00367ea1066c1c5fe85dbeefed
Author: Dave Airlie <airlied@linux.ie>
Date:   Sun Aug 29 12:04:35 2004 +0000

    Drop GAMMA DRM from a great height ...

Long story short, the drm fasync support seems to be doing absolutely
nothing. And the only user of it was never merged into the upstream
kernel. And we don't need any fops->fasync callback since the fcntl
implementation in the kernel already implements the noop case
correctly.

So stop this particular cargo-cult and rip it all out.

v2: Kill drm_fasync assignments in rcar (newly added) and imx drivers
(somehow I've missed that one in staging). Also drop the reference in
the drm DocBook. ARM compile-fail reported by Rob Clark.

v3: Move the removal of dev->buf_asnyc assignment in drm_setup to this
patch here.

v4: Actually git add ... tsk.

Cc: Dave Airlie <airlied@linux.ie>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl           |  1 -
 drivers/gpu/drm/ast/ast_drv.c            |  1 -
 drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 -
 drivers/gpu/drm/drm_fops.c               | 14 --------------
 drivers/gpu/drm/gma500/psb_drv.c         |  1 -
 drivers/gpu/drm/i810/i810_dma.c          |  1 -
 drivers/gpu/drm/i810/i810_drv.c          |  1 -
 drivers/gpu/drm/i915/i915_drv.c          |  1 -
 drivers/gpu/drm/mga/mga_drv.c            |  1 -
 drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c    |  1 -
 drivers/gpu/drm/omapdrm/omap_drv.c       |  1 -
 drivers/gpu/drm/qxl/qxl_drv.c            |  1 -
 drivers/gpu/drm/r128/r128_drv.c          |  1 -
 drivers/gpu/drm/radeon/radeon_drv.c      |  2 --
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |  1 -
 drivers/gpu/drm/savage/savage_drv.c      |  1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 -
 drivers/gpu/drm/sis/sis_drv.c            |  1 -
 drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 -
 drivers/gpu/drm/udl/udl_drv.c            |  1 -
 drivers/gpu/drm/via/via_drv.c            |  1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 -
 drivers/gpu/host1x/drm/drm.c             |  1 -
 drivers/staging/imx-drm/imx-drm-core.c   |  1 -
 include/drm/drmP.h                       |  3 ---
 27 files changed, 43 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4d54ac8..79dd70e 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2498,7 +2498,6 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
 	<programlisting>
 	.poll = drm_poll,
 	.read = drm_read,
-	.fasync = drm_fasync,
 	.llseek = no_llseek,
 	</programlisting>
       </para>
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index df0d0a0..16050ed 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -190,7 +190,6 @@ static const struct file_operations ast_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = ast_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 8ecb601..85748f6 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -85,7 +85,6 @@ static const struct file_operations cirrus_driver_fops = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
-	.fasync = drm_fasync,
 };
 static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 14e0bb6..d1b4771 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -75,8 +75,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->last_checked = 0;
 	dev->if_version = 0;
 
-	dev->buf_async = NULL;
-
 	DRM_DEBUG("\n");
 
 	/*
@@ -374,18 +372,6 @@ out_put_pid:
 	return ret;
 }
 
-/** No-op. */
-int drm_fasync(int fd, struct file *filp, int on)
-{
-	struct drm_file *priv = filp->private_data;
-	struct drm_device *dev = priv->minor->dev;
-
-	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
-		  (long)old_encode_dev(priv->minor->device));
-	return fasync_helper(fd, filp, on, &dev->buf_async);
-}
-EXPORT_SYMBOL(drm_fasync);
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
 	struct drm_file *file_priv = filp->private_data;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index bddea58..c9c37ac 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -622,7 +622,6 @@ static const struct file_operations psb_gem_fops = {
 	.unlocked_ioctl = psb_unlocked_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 };
 
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 004ecdf..ef1c9c7 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -113,7 +113,6 @@ static const struct file_operations i810_buffer_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = i810_mmap_buffers,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 2e91fc3..d85c05b 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -49,7 +49,6 @@ static const struct file_operations i810_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 062cbda..999ef21 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1110,7 +1110,6 @@ static const struct file_operations i915_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = i915_compat_ioctl,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 17d0a63..fe71e1e 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -50,7 +50,6 @@ static const struct file_operations mga_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = mga_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 122b571..31ff081 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -81,7 +81,6 @@ static const struct file_operations mgag200_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = mgag200_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index e990327..e09debe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -664,7 +664,6 @@ nouveau_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = nouveau_ttm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = nouveau_compat_ioctl,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 3f7c78a..fd2cfed 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -577,7 +577,6 @@ static const struct file_operations omapdriver_fops = {
 		.release = drm_release,
 		.mmap = omap_gem_mmap,
 		.poll = drm_poll,
-		.fasync = drm_fasync,
 		.read = drm_read,
 		.llseek = noop_llseek,
 };
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index df0b577..4be5225 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -84,7 +84,6 @@ static const struct file_operations qxl_fops = {
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.mmap = qxl_mmap,
 };
 
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 472c38f..c2338cb 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations r128_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = r128_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 81b9baa..ae94625 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -265,7 +265,6 @@ static const struct file_operations radeon_driver_old_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_compat_ioctl,
@@ -374,7 +373,6 @@ static const struct file_operations radeon_driver_kms_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = radeon_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_kms_compat_ioctl,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index ff82877..46e5967 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -230,7 +230,6 @@ static const struct file_operations rcar_du_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 71b2081..9135c8b 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -42,7 +42,6 @@ static const struct file_operations savage_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index edc1018..db94f2f 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -257,7 +257,6 @@ static const struct file_operations shmob_drm_fops = {
 #endif
 	.poll		= drm_poll,
 	.read		= drm_read,
-	.fasync		= drm_fasync,
 	.llseek		= no_llseek,
 	.mmap		= drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 5a5325e..b88b2d3 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -72,7 +72,6 @@ static const struct file_operations sis_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index ddfa743..951ec13 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -48,7 +48,6 @@ static const struct file_operations tdfx_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 40b71da..ff920ff 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -497,7 +497,6 @@ static const struct file_operations fops = {
 #endif
 	.poll               = drm_poll,
 	.read               = drm_read,
-	.fasync             = drm_fasync,
 	.llseek             = no_llseek,
 	.mmap               = drm_gem_cma_mmap,
 };
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index c0770db..c275adb 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -65,7 +65,6 @@ static const struct file_operations udl_driver_fops = {
 	.read = drm_read,
 	.unlocked_ioctl	= drm_ioctl,
 	.release = drm_release,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index f4ae203..4487999 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -64,7 +64,6 @@ static const struct file_operations via_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 3e75dfa..77d503a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1103,7 +1103,6 @@ static const struct file_operations vmwgfx_driver_fops = {
 	.mmap = vmw_mmap,
 	.poll = vmw_fops_poll,
 	.read = vmw_fops_read,
-	.fasync = drm_fasync,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = drm_compat_ioctl,
 #endif
diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
index e184b00..f8b708f 100644
--- a/drivers/gpu/host1x/drm/drm.c
+++ b/drivers/gpu/host1x/drm/drm.c
@@ -508,7 +508,6 @@ static const struct file_operations tegra_drm_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = tegra_drm_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = drm_compat_ioctl,
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 70f9650..f1cde28 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -199,7 +199,6 @@ static const struct file_operations imx_drm_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_cma_mmap,
 	.poll = drm_poll,
-	.fasync = drm_fasync,
 	.read = drm_read,
 	.llseek = noop_llseek,
 };
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d38c358..3589736 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1169,8 +1169,6 @@ struct drm_device {
 
 	/*@} */
 
-	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
-
 	struct drm_agp_head *agp;	/**< AGP data */
 
 	struct device *dev;             /**< Device structure */
@@ -1277,7 +1275,6 @@ extern int drm_lastclose(struct drm_device *dev);
 extern struct mutex drm_global_mutex;
 extern int drm_open(struct inode *inode, struct file *filp);
 extern int drm_stub_open(struct inode *inode, struct file *filp);
-extern int drm_fasync(int fd, struct file *filp, int on);
 extern ssize_t drm_read(struct file *filp, char __user *buffer,
 			size_t count, loff_t *offset);
 extern int drm_release(struct inode *inode, struct file *filp);
-- 
1.8.3.2

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

* Re: [PATCH 00/39] clean out drm cruft and hide it better for kms drivers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (38 preceding siblings ...)
  2013-07-10 12:12 ` [PATCH 39/39] drm: remove procfs code, take 2 Daniel Vetter
@ 2013-07-10 15:32 ` David Herrmann
  2013-07-10 15:51 ` [PATCH 1/2] drm: rip out dev->last_checked Daniel Vetter
  2013-07-11 14:09 ` [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Alex Deucher
  41 siblings, 0 replies; 71+ messages in thread
From: David Herrmann @ 2013-07-10 15:32 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi

On Wed, Jul 10, 2013 at 2:11 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Hi all,
>
> I've figured that it's again time for a bit of (late) drm spring cleanup. This
> series here consists of a pile of "rip old stuff out" patches interleaved with
> "disable old cruft for kms drivers and hide it better".
>
> Comments, flames and review highly welcome. I'd be especially happy if the arm
> guys could check whether I haven't badly broken their drivers - compile-testing
> arm is a pita, so I haven't yet done that.
>
> There's a few driver-wide patches included, but the more invasive ones (i.e.
> changing more than the drm driver vtable) are split out per-driver for easier
> merging. If no one screams my plan is to rebase this pile on top of -rc1, give
> it some more testing (check arm, ugh) and then send a pull request to Dave.
> That should reduce interference with ongoing driver work as much as possible I
> hope.
>
> My drm cruft todo list still has a pile of ideas, but I've figured I need to
> stop now for 3.12. For those interested further cleanups could include:
>
> - setversion/set_busid: All drm core version 1.1 is legacy cruft, kms drivers
>   should never run in this mode. We could clean up the setversion ioclt (and
>   move the drm core version handling into a legacy function) and set up the bus
>   id unconditionally at driver load time.
>
> - There's a few more legacy ioctls/subsystems that could be blocked out for kms
>   drivers (but the required git history digging tends to be tedious). Also I
>   think we could more aggressively move legacy cruft setup/teardown code
>   out-of-line from the main code by extracting it into drm_legacy_ functions
>   (like this series here already does for the context and dma stuff).
>
> - I think creating a drm_internal.h header for functions not exported to drivers
>   would be useful. That way we could move all the legacy functions out of drmP.h
>   (which are a lot of them), which should make it much clearer what the real drm
>   driver interface actually is.

Please do that! It also reduces drmP.h and thus I don't have to
recompile all drivers once we change legacy core code.

> - drm_os_linux.h should just die in fire.
>
> - There's a pile of needless indirection around our agp handling, we duplicate
>   the agp core's CONFIG_AGP=n no-oping function handling in large parts, among
>   other stuff.

I have a cleanup patch for AGP setup+teardown which further simplifies
drm_fill_in_dev(). See:
  https://github.com/dvdhrm/linux/commits/drmdev
I will rebase the drm_dev_*() helpers once Dave merged your series.

> - The drm coherent dma alloc helpers could get ripped out, at least for kms
>   drivers. For ums drivers there's some funny cases where this mapping is
>   exchanged with userspace for e.g. register access. In a least one case
>   (i810.ko) userspace even sets up that mapping, which allows it to crash the
>   kernel at will (since those maps aren't refcounted). Maybe we need to shovel
>   those interfaces into a drm_legacy.ko module to keep them around but make sure
>   that no new driver even thinks about using them.
>
> - There's also the matter of the vblank support code, imo that should be split
>   int a ums and a kms part. That'd would allow us to use struct drm_crtc * in
>   interfaces and proper locking (by grabbing crtc->mutex to exclude races with
>   dpms/modesets).
>
> If anyone wants to dig around in those areas please poke me.
>
> Cheers, Daniel
>
> Daniel Vetter (39):
>   drm: remove drm_modctx ioctl and use drm_noop instead
>   drm: kill dev->context_wait
>   drm: remove dev->last_switch
>   drm: kill dev->interrupt_flag and dev->dma_flag
>   drm: kill dev->ctx_start and dev->lck_start
>   drm/radoen: kill radeon_dma_ioctl_kms
>   drm: kill dev->buf_readers and dev->buf_writers
>   drm: remove redundant clears from drm_setup
>   drm/omap: kill firstopen callback
>   drm/radeon: kill firstopen callback for kms driver
>   drm/imx: kill firstopen callback
>   drm/vmwgfx: remove ->firstopen callback
>   drm: don't call ->firstopen for KMS drivers
>   drm: kill dev->driver->set_version
>   drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver
>   drm: fold in drm_sg_alloc into the ioctl
>   drm: hide legacy sg cleanup better from common code
>   drm: disallow legacy sg ioctls for modesetting drivers
>   drm: mark dma setup/teardown as legacy systems
>   drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG
>   drm: disallow legacy dma ioctls for modesetting drivers
>   drm: move drm_getsarea into drm_bufs.c
>   drm/bufs: s/drm_order/order_base_2/
>   drm/r128: s/drm_order/order_base_2/
>   drm/radeon: s/drm_order/order_base_2/
>   drm: remove drm_order
>   drm: mark context support as a legacy subsystem
>   drm/vmwgfx: remove redundant clearing of driver->dma_quiescent
>   drm: remove FASYNC support
>   drm: rip out DRIVER_FB_DMA and related code
>   drm: rip out a few unused DRIVER flags
>   drm: remove a bunch of unused #defines from drmP.h
>   drm: rip out drm_core_has_MTRR checks
>   drm: remove the dma_ioctl special-case
>   drm/memory: don't export agp helpers
>   drm: hollow-out GET_CLIENT ioctl
>   drm: no-op out GET_STATS ioctl
>   drm: fix locking in gem debugfs/procfs file
>   drm: remove procfs code, take 2

Apart from driver chances, I reviewed all of them and they look good,
except for few things I mentioned for the individual patches. But most
of them are trivial, anyway.
Also (on nouveau):
  Tested-by: David Herrmann <dh.herrmann@gmail.com>

Cheers
David

>  drivers/gpu/drm/Makefile                 |   2 +-
>  drivers/gpu/drm/ast/ast_drv.c            |   1 -
>  drivers/gpu/drm/cirrus/cirrus_drv.c      |   1 -
>  drivers/gpu/drm/drm_bufs.c               | 238 +++++++------------------------
>  drivers/gpu/drm/drm_context.c            |  81 ++++++++---
>  drivers/gpu/drm/drm_dma.c                |  17 ++-
>  drivers/gpu/drm/drm_drv.c                |  44 +-----
>  drivers/gpu/drm/drm_fops.c               |  66 +--------
>  drivers/gpu/drm/drm_info.c               |   4 +
>  drivers/gpu/drm/drm_ioctl.c              |  43 +-----
>  drivers/gpu/drm/drm_memory.c             |   2 -
>  drivers/gpu/drm/drm_pci.c                |  11 +-
>  drivers/gpu/drm/drm_proc.c               | 209 ---------------------------
>  drivers/gpu/drm/drm_scatter.c            |  29 ++--
>  drivers/gpu/drm/drm_stub.c               |  44 ++----
>  drivers/gpu/drm/drm_vm.c                 |   3 +-
>  drivers/gpu/drm/gma500/psb_drv.c         |   3 +-
>  drivers/gpu/drm/i810/i810_dma.c          |   1 -
>  drivers/gpu/drm/i810/i810_drv.c          |   1 -
>  drivers/gpu/drm/i915/i915_drv.c          |   1 -
>  drivers/gpu/drm/mga/mga_drv.c            |   1 -
>  drivers/gpu/drm/mgag200/mgag200_drv.c    |   1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c    |   3 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c       |   8 --
>  drivers/gpu/drm/qxl/qxl_drv.c            |   1 -
>  drivers/gpu/drm/r128/r128_cce.c          |   2 +-
>  drivers/gpu/drm/r128/r128_drv.c          |   1 -
>  drivers/gpu/drm/radeon/cik.c             |  14 +-
>  drivers/gpu/drm/radeon/evergreen.c       |   4 +-
>  drivers/gpu/drm/radeon/ni.c              |   6 +-
>  drivers/gpu/drm/radeon/r100.c            |   2 +-
>  drivers/gpu/drm/radeon/r600.c            |  14 +-
>  drivers/gpu/drm/radeon/r600_cp.c         |   6 +-
>  drivers/gpu/drm/radeon/radeon_cp.c       |   6 +-
>  drivers/gpu/drm/radeon/radeon_drv.c      |  11 +-
>  drivers/gpu/drm/radeon/radeon_kms.c      |  23 ---
>  drivers/gpu/drm/radeon/si.c              |  14 +-
>  drivers/gpu/drm/savage/savage_drv.c      |   1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c |   1 -
>  drivers/gpu/drm/sis/sis_drv.c            |   1 -
>  drivers/gpu/drm/tdfx/tdfx_drv.c          |   1 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   1 -
>  drivers/gpu/drm/udl/udl_drv.c            |   1 -
>  drivers/gpu/drm/via/via_drv.c            |   1 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  20 ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |   1 -
>  drivers/gpu/host1x/drm/drm.c             |   1 -
>  drivers/staging/imx-drm/imx-drm-core.c   |  20 +--
>  include/drm/drmP.h                       |  65 ++-------
>  49 files changed, 239 insertions(+), 793 deletions(-)
>  delete mode 100644 drivers/gpu/drm/drm_proc.c
>
> --
> 1.8.3.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 15:22     ` Daniel Vetter
@ 2013-07-10 15:41       ` David Herrmann
  2013-07-10 15:59         ` Daniel Vetter
  0 siblings, 1 reply; 71+ messages in thread
From: David Herrmann @ 2013-07-10 15:41 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development, Andy Lutomirski

Hi

On Wed, Jul 10, 2013 at 5:22 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> On Wed, Jul 10, 2013 at 3:51 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>>> -#if __OS_HAS_MTRR
>>> -static inline int drm_core_has_MTRR(struct drm_device *dev)
>>> -{
>>> -       return drm_core_check_feature(dev, DRIVER_USE_MTRR);
>>> -}
>>> -#else
>>> -#define drm_core_has_MTRR(dev) (0)
>>> -#endif
>>> -
>>
>> That was the last user of DRIVER_USE_MTRR (apart from drivers setting
>> it in .driver_features). Any reason to keep it around?
>
> Yeah, I guess we could rip things out. Which will also force me to
> properly audit drivers for the eventual behaviour change this could
> entail (in case there's an x86 driver which did not ask for an mtrr,
> but iirc there isn't).

david@david-mb ~/dev/kernel/linux $ for i in drivers/gpu/drm/* ; do if
test -d "$i" ; then if ! grep -q USE_MTRR -r $i ; then echo $i ; fi ;
fi ; done
drivers/gpu/drm/exynos
drivers/gpu/drm/gma500
drivers/gpu/drm/i2c
drivers/gpu/drm/nouveau
drivers/gpu/drm/omapdrm
drivers/gpu/drm/qxl
drivers/gpu/drm/rcar-du
drivers/gpu/drm/shmobile
drivers/gpu/drm/tilcdc
drivers/gpu/drm/ttm
drivers/gpu/drm/udl
drivers/gpu/drm/vmwgfx
david@david-mb ~/dev/kernel/linux $

So for x86 gma500,nouveau,qxl,udl,vmwgfx don't set DRIVER_USE_MTRR.
But I cannot tell whether they break if we call arch_phys_wc_add/del,
anyway. At least nouveau seemed to work here, but it doesn't use AGP
or drm_bufs, I guess.

Cheers
David

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

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

* [PATCH 1/2] drm: rip out dev->last_checked
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (39 preceding siblings ...)
  2013-07-10 15:32 ` [PATCH 00/39] clean out drm cruft and hide it better for kms drivers David Herrmann
@ 2013-07-10 15:51 ` Daniel Vetter
  2013-07-10 15:51   ` [PATCH 2/2] drm: move dev data clearing from drm_setup to lastclose Daniel Vetter
  2013-07-11 14:09 ` [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Alex Deucher
  41 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:51 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Only ever re-cleared in drm_setup, otherwise completely unused.

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

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index d1b4771..5679971 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -72,7 +72,6 @@ static int drm_setup(struct drm_device * dev)
 
 	dev->context_flag = 0;
 	dev->last_context = 0;
-	dev->last_checked = 0;
 	dev->if_version = 0;
 
 	DRM_DEBUG("\n");
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d0043b8..374c2f1 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1112,7 +1112,6 @@ struct drm_device {
 	/*@{ */
 	int irq_enabled;		/**< True if irq handler is enabled */
 	__volatile__ long context_flag;	/**< Context swapping flag */
-	int last_checked;		/**< Last context checked for DMA */
 	int last_context;		/**< Last current context */
 	/*@} */
 
-- 
1.8.3.2

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

* [PATCH 2/2] drm: move dev data clearing from drm_setup to lastclose
  2013-07-10 15:51 ` [PATCH 1/2] drm: rip out dev->last_checked Daniel Vetter
@ 2013-07-10 15:51   ` Daniel Vetter
  0 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:51 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

We kzalloc this structure, and for real kms devices we should never
loose track of things really.

But ums/legacy drivers rely on the drm core to clean up a bit of cruft
between lastclose and firstopen (i.e. when X is being restarted), so
keep this around. But give it a clear drm_legacy_ prefix and
conditionalize the code on !DRIVER_MODESET.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_drv.c  | 27 +++++++++++++++++++++++++++
 drivers/gpu/drm/drm_fops.c | 27 +++------------------------
 2 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a9f48ff..7b4fd72 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -171,6 +171,31 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 #define DRM_CORE_IOCTL_COUNT	ARRAY_SIZE( drm_ioctls )
 
 /**
+ * drm_legacy_dev_reinit
+ *
+ * Reinitializes a legacy/ums drm device in it's lastclose function.
+ */
+static void drm_legacy_dev_reinit(struct drm_device *dev)
+{
+	int i;
+
+	if (drm_core_check_feature(dev, DRIVER_MODESET))
+		return;
+
+	atomic_set(&dev->ioctl_count, 0);
+	atomic_set(&dev->vma_count, 0);
+
+	for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
+		atomic_set(&dev->counts[i], 0);
+
+	dev->sigdata.lock = NULL;
+
+	dev->context_flag = 0;
+	dev->last_context = 0;
+	dev->if_version = 0;
+}
+
+/**
  * Take down the DRM device.
  *
  * \param dev DRM device structure.
@@ -229,6 +254,8 @@ int drm_lastclose(struct drm_device * dev)
 	dev->dev_mapping = NULL;
 	mutex_unlock(&dev->struct_mutex);
 
+	drm_legacy_dev_reinit(dev);
+
 	DRM_DEBUG("lastclose completed\n");
 	return 0;
 }
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 5679971..59f4592 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -48,7 +48,6 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 
 static int drm_setup(struct drm_device * dev)
 {
-	int i;
 	int ret;
 
 	if (dev->driver->firstopen &&
@@ -58,32 +57,12 @@ static int drm_setup(struct drm_device * dev)
 			return ret;
 	}
 
-	atomic_set(&dev->ioctl_count, 0);
-	atomic_set(&dev->vma_count, 0);
-
-	i = drm_legacy_dma_setup(dev);
-	if (i < 0)
-		return i;
-
-	for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
-		atomic_set(&dev->counts[i], 0);
-
-	dev->sigdata.lock = NULL;
+	ret = drm_legacy_dma_setup(dev);
+	if (ret < 0)
+		return ret;
 
-	dev->context_flag = 0;
-	dev->last_context = 0;
-	dev->if_version = 0;
 
 	DRM_DEBUG("\n");
-
-	/*
-	 * The kernel's context could be created here, but is now created
-	 * in drm_dma_enqueue.  This is more resource-efficient for
-	 * hardware that does not do DMA, but may mean that
-	 * drm_select_queue fails between the time the interrupt is
-	 * initialized and the time the queues are initialized.
-	 */
-
 	return 0;
 }
 
-- 
1.8.3.2

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

* Re: [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 15:41       ` David Herrmann
@ 2013-07-10 15:59         ` Daniel Vetter
  2013-07-10 16:13           ` [PATCH 1/2] " Daniel Vetter
  2013-07-10 16:27           ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Andy Lutomirski
  0 siblings, 2 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 15:59 UTC (permalink / raw)
  To: David Herrmann; +Cc: DRI Development, Andy Lutomirski

On Wed, Jul 10, 2013 at 5:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> On Wed, Jul 10, 2013 at 5:22 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> On Wed, Jul 10, 2013 at 3:51 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>>>> -#if __OS_HAS_MTRR
>>>> -static inline int drm_core_has_MTRR(struct drm_device *dev)
>>>> -{
>>>> -       return drm_core_check_feature(dev, DRIVER_USE_MTRR);
>>>> -}
>>>> -#else
>>>> -#define drm_core_has_MTRR(dev) (0)
>>>> -#endif
>>>> -
>>>
>>> That was the last user of DRIVER_USE_MTRR (apart from drivers setting
>>> it in .driver_features). Any reason to keep it around?
>>
>> Yeah, I guess we could rip things out. Which will also force me to
>> properly audit drivers for the eventual behaviour change this could
>> entail (in case there's an x86 driver which did not ask for an mtrr,
>> but iirc there isn't).
>
> david@david-mb ~/dev/kernel/linux $ for i in drivers/gpu/drm/* ; do if
> test -d "$i" ; then if ! grep -q USE_MTRR -r $i ; then echo $i ; fi ;
> fi ; done
> drivers/gpu/drm/exynos
> drivers/gpu/drm/gma500
> drivers/gpu/drm/i2c
> drivers/gpu/drm/nouveau
> drivers/gpu/drm/omapdrm
> drivers/gpu/drm/qxl
> drivers/gpu/drm/rcar-du
> drivers/gpu/drm/shmobile
> drivers/gpu/drm/tilcdc
> drivers/gpu/drm/ttm
> drivers/gpu/drm/udl
> drivers/gpu/drm/vmwgfx
> david@david-mb ~/dev/kernel/linux $
>
> So for x86 gma500,nouveau,qxl,udl,vmwgfx don't set DRIVER_USE_MTRR.
> But I cannot tell whether they break if we call arch_phys_wc_add/del,
> anyway. At least nouveau seemed to work here, but it doesn't use AGP
> or drm_bufs, I guess.

Cool, thanks a lot for stitching together the list of drivers to look
at. So for real KMS drivers it's the drives responsibility to add an
mtrr if it needs one. nouvea, radeon, mgag200, i915 and vmwgfx do that
already. Somehow the savage driver also ends up doing that, I have no
idea why.

Note that gma500 as a pure KMS driver doesn't need MTRR setup since
the platforms that it supports all support PAT. So no MTRRs needed to
get wc iomappings.

The mtrr support in the drm core is all for legacy mappings of garts,
framebuffers and registers. All legacy drivers set the USE_MTRR flag,
so we're good there.

All in all I think we can really just ditch this. I'll update the patch.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* [PATCH 1/2] drm: rip out drm_core_has_MTRR checks
  2013-07-10 15:59         ` Daniel Vetter
@ 2013-07-10 16:13           ` Daniel Vetter
  2013-07-10 16:13             ` [PATCH 2/2] drm/docs: rip out removed driver flags documentation Daniel Vetter
  2013-07-10 16:27           ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Andy Lutomirski
  1 sibling, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 16:13 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Andy Lutomirski

The new arch_phys_wc_add/del functions do the right thing both with
and without MTRR support in the kernel. So we can drop these
additional checks.

David Herrmann suggest to also kill the DRIVER_USE_MTRR flag since
it's now unused, which spurred me to do a bit a better audit of the
affected drivers. David helped a lot in that. Quoting our mail
discussion:

On Wed, Jul 10, 2013 at 5:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> On Wed, Jul 10, 2013 at 5:22 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> On Wed, Jul 10, 2013 at 3:51 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>>>> -#if __OS_HAS_MTRR
>>>> -static inline int drm_core_has_MTRR(struct drm_device *dev)
>>>> -{
>>>> -       return drm_core_check_feature(dev, DRIVER_USE_MTRR);
>>>> -}
>>>> -#else
>>>> -#define drm_core_has_MTRR(dev) (0)
>>>> -#endif
>>>> -
>>>
>>> That was the last user of DRIVER_USE_MTRR (apart from drivers setting
>>> it in .driver_features). Any reason to keep it around?
>>
>> Yeah, I guess we could rip things out. Which will also force me to
>> properly audit drivers for the eventual behaviour change this could
>> entail (in case there's an x86 driver which did not ask for an mtrr,
>> but iirc there isn't).
>
> david@david-mb ~/dev/kernel/linux $ for i in drivers/gpu/drm/* ; do if
> test -d "$i" ; then if ! grep -q USE_MTRR -r $i ; then echo $i ; fi ;
> fi ; done
> drivers/gpu/drm/exynos
> drivers/gpu/drm/gma500
> drivers/gpu/drm/i2c
> drivers/gpu/drm/nouveau
> drivers/gpu/drm/omapdrm
> drivers/gpu/drm/qxl
> drivers/gpu/drm/rcar-du
> drivers/gpu/drm/shmobile
> drivers/gpu/drm/tilcdc
> drivers/gpu/drm/ttm
> drivers/gpu/drm/udl
> drivers/gpu/drm/vmwgfx
> david@david-mb ~/dev/kernel/linux $
>
> So for x86 gma500,nouveau,qxl,udl,vmwgfx don't set DRIVER_USE_MTRR.
> But I cannot tell whether they break if we call arch_phys_wc_add/del,
> anyway. At least nouveau seemed to work here, but it doesn't use AGP
> or drm_bufs, I guess.

Cool, thanks a lot for stitching together the list of drivers to look
at. So for real KMS drivers it's the drives responsibility to add an
mtrr if it needs one. nouvea, radeon, mgag200, i915 and vmwgfx do that
already. Somehow the savage driver also ends up doing that, I have no
idea why.

Note that gma500 as a pure KMS driver doesn't need MTRR setup since
the platforms that it supports all support PAT. So no MTRRs needed to
get wc iomappings.

The mtrr support in the drm core is all for legacy mappings of garts,
framebuffers and registers. All legacy drivers set the USE_MTRR flag,
so we're good there.

All in all I think we can really just ditch this

/endquote

v2: Also kill DRIVER_USE_MTRR as suggested by David Herrmann

Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/ast/ast_drv.c         |  2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c   |  2 +-
 drivers/gpu/drm/drm_bufs.c            | 13 +++++--------
 drivers/gpu/drm/drm_pci.c             | 11 +++++------
 drivers/gpu/drm/drm_stub.c            |  2 +-
 drivers/gpu/drm/drm_vm.c              |  3 +--
 drivers/gpu/drm/i810/i810_drv.c       |  2 +-
 drivers/gpu/drm/i915/i915_drv.c       |  2 +-
 drivers/gpu/drm/mga/mga_drv.c         |  2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c |  2 +-
 drivers/gpu/drm/r128/r128_drv.c       |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c   |  4 ++--
 drivers/gpu/drm/savage/savage_drv.c   |  2 +-
 drivers/gpu/drm/sis/sis_drv.c         |  2 +-
 drivers/gpu/drm/tdfx/tdfx_drv.c       |  1 -
 drivers/gpu/drm/via/via_drv.c         |  2 +-
 include/drm/drmP.h                    | 11 -----------
 17 files changed, 24 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 16050ed..3233d7b 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -197,7 +197,7 @@ static const struct file_operations ast_fops = {
 };
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_USE_MTRR | DRIVER_MODESET | DRIVER_GEM,
+	.driver_features = DRIVER_MODESET | DRIVER_GEM,
 	.dev_priv_size = 0,
 
 	.load = ast_driver_load,
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 85748f6..bedad78 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -87,7 +87,7 @@ static const struct file_operations cirrus_driver_fops = {
 #endif
 };
 static struct drm_driver driver = {
-	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
+	.driver_features = DRIVER_MODESET | DRIVER_GEM,
 	.load = cirrus_driver_load,
 	.unload = cirrus_driver_unload,
 	.fops = &cirrus_driver_fops,
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 5f73f0a..f63133b 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -207,12 +207,10 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 			return 0;
 		}
 
-		if (drm_core_has_MTRR(dev)) {
-			if (map->type == _DRM_FRAME_BUFFER ||
-			    (map->flags & _DRM_WRITE_COMBINING)) {
-				map->mtrr =
-					arch_phys_wc_add(map->offset, map->size);
-			}
+		if (map->type == _DRM_FRAME_BUFFER ||
+		    (map->flags & _DRM_WRITE_COMBINING)) {
+			map->mtrr =
+				arch_phys_wc_add(map->offset, map->size);
 		}
 		if (map->type == _DRM_REGISTERS) {
 			if (map->flags & _DRM_WRITE_COMBINING)
@@ -464,8 +462,7 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
 		iounmap(map->handle);
 		/* FALLTHROUGH */
 	case _DRM_FRAME_BUFFER:
-		if (drm_core_has_MTRR(dev))
-			arch_phys_wc_del(map->mtrr);
+		arch_phys_wc_del(map->mtrr);
 		break;
 	case _DRM_SHM:
 		vfree(map->handle);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 80c0b2b..9e93ea5 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -276,12 +276,11 @@ static int drm_pci_agp_init(struct drm_device *dev)
 			DRM_ERROR("Cannot initialize the agpgart module.\n");
 			return -EINVAL;
 		}
-		if (drm_core_has_MTRR(dev)) {
-			if (dev->agp)
-				dev->agp->agp_mtrr = arch_phys_wc_add(
-					dev->agp->agp_info.aper_base,
-					dev->agp->agp_info.aper_size *
-					1024 * 1024);
+		if (dev->agp) {
+			dev->agp->agp_mtrr = arch_phys_wc_add(
+				dev->agp->agp_info.aper_base,
+				dev->agp->agp_info.aper_size *
+				1024 * 1024);
 		}
 	}
 	return 0;
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index e7471ef..30cbd62 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -445,7 +445,7 @@ void drm_put_dev(struct drm_device *dev)
 
 	drm_lastclose(dev);
 
-	if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp)
+	if (dev->agp)
 		arch_phys_wc_del(dev->agp->agp_mtrr);
 
 	if (dev->driver->unload)
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index feb2003..b5c5af7 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -251,8 +251,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
 			switch (map->type) {
 			case _DRM_REGISTERS:
 			case _DRM_FRAME_BUFFER:
-				if (drm_core_has_MTRR(dev))
-					arch_phys_wc_del(map->mtrr);
+				arch_phys_wc_del(map->mtrr);
 				iounmap(map->handle);
 				break;
 			case _DRM_SHM:
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index d85c05b..d8180d2 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_MTRR |
+	    DRIVER_USE_AGP | DRIVER_REQUIRE_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_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 999ef21..d253c75 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1122,7 +1122,7 @@ static struct drm_driver driver = {
 	 * deal with them for Intel hardware.
 	 */
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
+	    DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
 	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME,
 	.load = i915_driver_load,
 	.unload = i915_driver_unload,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index fe71e1e..6b1a87c 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -58,7 +58,7 @@ static const struct file_operations mga_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
+	    DRIVER_USE_AGP | DRIVER_PCI_DMA |
 	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
 	.dev_priv_size = sizeof(drm_mga_buf_priv_t),
 	.load = mga_driver_load,
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 31ff081..ccc329c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -88,7 +88,7 @@ static const struct file_operations mgag200_driver_fops = {
 };
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_USE_MTRR,
+	.driver_features = DRIVER_GEM | DRIVER_MODESET,
 	.load = mgag200_driver_load,
 	.unload = mgag200_driver_unload,
 	.fops = &mgag200_driver_fops,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index c2338cb..5bd307c 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -56,7 +56,7 @@ static const struct file_operations r128_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
+	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
 	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
 	.dev_priv_size = sizeof(drm_r128_buf_priv_t),
 	.load = r128_driver_load,
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index ae94625..f2eabc8 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -274,7 +274,7 @@ static const struct file_operations radeon_driver_old_fops = {
 
 static struct drm_driver driver_old = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
+	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
 	    DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED,
 	.dev_priv_size = sizeof(drm_radeon_buf_priv_t),
 	.load = radeon_driver_load,
@@ -381,7 +381,7 @@ static const struct file_operations radeon_driver_kms_fops = {
 
 static struct drm_driver kms_driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | 
+	    DRIVER_USE_AGP |
 	    DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
 	    DRIVER_PRIME,
 	.dev_priv_size = 0,
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 9135c8b..3c03021 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -50,7 +50,7 @@ static const struct file_operations savage_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
+	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
 	.dev_priv_size = sizeof(drm_savage_buf_priv_t),
 	.load = savage_driver_load,
 	.firstopen = savage_driver_firstopen,
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index b88b2d3..4383b74 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -102,7 +102,7 @@ void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
 }
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR,
+	.driver_features = DRIVER_USE_AGP,
 	.load = sis_driver_load,
 	.unload = sis_driver_unload,
 	.open = sis_driver_open,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 951ec13..3492ca5 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -55,7 +55,6 @@ static const struct file_operations tdfx_driver_fops = {
 };
 
 static struct drm_driver driver = {
-	.driver_features = DRIVER_USE_MTRR,
 	.fops = &tdfx_driver_fops,
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 4487999..92684a9 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -72,7 +72,7 @@ static const struct file_operations via_driver_fops = {
 
 static struct drm_driver driver = {
 	.driver_features =
-	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ |
+	    DRIVER_USE_AGP | DRIVER_HAVE_IRQ |
 	    DRIVER_IRQ_SHARED,
 	.load = via_driver_load,
 	.unload = via_driver_unload,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 62e9e41..5614da4 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -75,7 +75,6 @@
 #include <linux/idr.h>
 
 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
-#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
 
 struct module;
 
@@ -140,7 +139,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_USE_MTRR    0x4
 #define DRIVER_PCI_DMA     0x8
 #define DRIVER_SG          0x10
 #define DRIVER_HAVE_DMA    0x20
@@ -1220,15 +1218,6 @@ static inline int drm_core_has_AGP(struct drm_device *dev)
 #define drm_core_has_AGP(dev) (0)
 #endif
 
-#if __OS_HAS_MTRR
-static inline int drm_core_has_MTRR(struct drm_device *dev)
-{
-	return drm_core_check_feature(dev, DRIVER_USE_MTRR);
-}
-#else
-#define drm_core_has_MTRR(dev) (0)
-#endif
-
 static inline void drm_device_set_unplugged(struct drm_device *dev)
 {
 	smp_wmb();
-- 
1.8.3.2

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

* [PATCH 2/2] drm/docs: rip out removed driver flags documentation
  2013-07-10 16:13           ` [PATCH 1/2] " Daniel Vetter
@ 2013-07-10 16:13             ` Daniel Vetter
  0 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 16:13 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

I've forgotten this and shuffling all the little pieces into the
respective patches is rather cumbersome ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl | 29 -----------------------------
 1 file changed, 29 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 79dd70e..94f3abb 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -156,13 +156,6 @@
             </para></listitem>
           </varlistentry>
           <varlistentry>
-            <term>DRIVER_USE_MTRR</term>
-            <listitem><para>
-              Driver uses MTRR interface for mapping memory, the DRM core will
-              manage MTRR resources. Deprecated.
-            </para></listitem>
-          </varlistentry>
-          <varlistentry>
             <term>DRIVER_PCI_DMA</term>
             <listitem><para>
               Driver is capable of PCI DMA, mapping of PCI DMA buffers to
@@ -195,28 +188,6 @@
             </para></listitem>
           </varlistentry>
           <varlistentry>
-            <term>DRIVER_IRQ_VBL</term>
-            <listitem><para>Unused. Deprecated.</para></listitem>
-          </varlistentry>
-          <varlistentry>
-            <term>DRIVER_DMA_QUEUE</term>
-            <listitem><para>
-              Should be set if the driver queues DMA requests and completes them
-              asynchronously.  Deprecated.
-            </para></listitem>
-          </varlistentry>
-          <varlistentry>
-            <term>DRIVER_FB_DMA</term>
-            <listitem><para>
-              Driver supports DMA to/from the framebuffer, mapping of frambuffer
-              DMA buffers to userspace will be supported. Deprecated.
-            </para></listitem>
-          </varlistentry>
-          <varlistentry>
-            <term>DRIVER_IRQ_VBL2</term>
-            <listitem><para>Unused. Deprecated.</para></listitem>
-          </varlistentry>
-          <varlistentry>
             <term>DRIVER_GEM</term>
             <listitem><para>
               Driver use the GEM memory manager.
-- 
1.8.3.2

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

* Re: [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 15:59         ` Daniel Vetter
  2013-07-10 16:13           ` [PATCH 1/2] " Daniel Vetter
@ 2013-07-10 16:27           ` Andy Lutomirski
  2013-07-10 16:41             ` Daniel Vetter
  1 sibling, 1 reply; 71+ messages in thread
From: Andy Lutomirski @ 2013-07-10 16:27 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Jul 10, 2013 at 8:59 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> On Wed, Jul 10, 2013 at 5:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>> On Wed, Jul 10, 2013 at 5:22 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>>> On Wed, Jul 10, 2013 at 3:51 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>>>>> -#if __OS_HAS_MTRR
>>>>> -static inline int drm_core_has_MTRR(struct drm_device *dev)
>>>>> -{
>>>>> -       return drm_core_check_feature(dev, DRIVER_USE_MTRR);
>>>>> -}
>>>>> -#else
>>>>> -#define drm_core_has_MTRR(dev) (0)
>>>>> -#endif
>>>>> -
>>>>
>>>> That was the last user of DRIVER_USE_MTRR (apart from drivers setting
>>>> it in .driver_features). Any reason to keep it around?
>>>
>>> Yeah, I guess we could rip things out. Which will also force me to
>>> properly audit drivers for the eventual behaviour change this could
>>> entail (in case there's an x86 driver which did not ask for an mtrr,
>>> but iirc there isn't).
>>
>> david@david-mb ~/dev/kernel/linux $ for i in drivers/gpu/drm/* ; do if
>> test -d "$i" ; then if ! grep -q USE_MTRR -r $i ; then echo $i ; fi ;
>> fi ; done
>> drivers/gpu/drm/exynos
>> drivers/gpu/drm/gma500
>> drivers/gpu/drm/i2c
>> drivers/gpu/drm/nouveau
>> drivers/gpu/drm/omapdrm
>> drivers/gpu/drm/qxl
>> drivers/gpu/drm/rcar-du
>> drivers/gpu/drm/shmobile
>> drivers/gpu/drm/tilcdc
>> drivers/gpu/drm/ttm
>> drivers/gpu/drm/udl
>> drivers/gpu/drm/vmwgfx
>> david@david-mb ~/dev/kernel/linux $
>>
>> So for x86 gma500,nouveau,qxl,udl,vmwgfx don't set DRIVER_USE_MTRR.
>> But I cannot tell whether they break if we call arch_phys_wc_add/del,
>> anyway. At least nouveau seemed to work here, but it doesn't use AGP
>> or drm_bufs, I guess.
>
> Cool, thanks a lot for stitching together the list of drivers to look
> at. So for real KMS drivers it's the drives responsibility to add an
> mtrr if it needs one. nouvea, radeon, mgag200, i915 and vmwgfx do that
> already. Somehow the savage driver also ends up doing that, I have no
> idea why.
>
> Note that gma500 as a pure KMS driver doesn't need MTRR setup since
> the platforms that it supports all support PAT. So no MTRRs needed to
> get wc iomappings.
>
> The mtrr support in the drm core is all for legacy mappings of garts,
> framebuffers and registers. All legacy drivers set the USE_MTRR flag,
> so we're good there.
>

Are all of those codepaths really inaccessible in non-legacy drm
drivers?  I didn't try to fully unravel all the ioctls and such, but
it seems like userspace could add bufs and map them.  Since the mtrr
code isn't very robust (reference counting?  what reference
counting?), I'm a little bit worried that potentially enabling it in
more cases, which your patch does, could be harmful.

The arch_phys_wc stuff puts a prettier interface on the mtrr code and
turns it off when PAT is available, but the underlying code is still
just as bad.

--Andy

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

* Re: [PATCH 33/39] drm: rip out drm_core_has_MTRR checks
  2013-07-10 16:27           ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Andy Lutomirski
@ 2013-07-10 16:41             ` Daniel Vetter
  0 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 16:41 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: DRI Development

On Wed, Jul 10, 2013 at 6:27 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> Are all of those codepaths really inaccessible in non-legacy drm
> drivers?  I didn't try to fully unravel all the ioctls and such, but
> it seems like userspace could add bufs and map them.  Since the mtrr
> code isn't very robust (reference counting?  what reference
> counting?), I'm a little bit worried that potentially enabling it in
> more cases, which your patch does, could be harmful.
>
> The arch_phys_wc stuff puts a prettier interface on the mtrr code and
> turns it off when PAT is available, but the underlying code is still
> just as bad.

Well, the entire drm bufs stuff isn't refcounted and there are indeed
legacy driver that abused this in a completely unsafe way. E.g. for
i810.ko the ddx driver in userspace creates a register mapping through
the addbuf ioctl, which the kernel driver then uses. With no
refcounting at all to prevent an Oops (and I've seen them happen, you
simply need to kill X).

So I don't think this patch will make matters worse, especially since
most drivers set DRIVER_USE_MTRR. The way to fix this up is to
holesale block out these unsafe ioctls for kernel modesetting driver,
which this series here does for a lot of cases (still a bunch of them
left though). There's no way we can fix up the ums drm drivers without
breaking userspace :(

I haven't yet gotten around to blocking out the addmap ioctls since
reviewing existing userspace code will be a real pain. But at least
addmap is restrict to CAP_SYS_ADMIN, so not a that grave exploit
issue. But I very much plan to do that audit and then disable addmap
and friends for kms drivers.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* [PATCH] drm: don't call ->firstopen for KMS drivers
  2013-07-10 12:11 ` [PATCH 13/39] drm: don't call ->firstopen for KMS drivers Daniel Vetter
@ 2013-07-10 18:17   ` Daniel Vetter
  2013-07-11  7:54     ` Laurent Pinchart
  0 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 18:17 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

It has way too much potential for driver writers to do stupid things
like delayed hw setup because the load sequence is somehow racy (e.g.
the imx driver in staging). So don't call it for modesetting drivers,
which reduces the complexity of the drm core -> driver interface a
notch.

v2: Don't forget to update DocBook.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl | 2 ++
 drivers/gpu/drm/drm_fops.c     | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4d54ac8..0e8a5a3 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2423,6 +2423,8 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
       <para>
         The <methodname>firstopen</methodname> method is called by the DRM core
 	when an application opens a device that has no other opened file handle.
+	Not that this callback is only called for legacy ums drm drivers, not
+	for drm drivers that implement modesetting in the kernel.
 	Similarly the <methodname>lastclose</methodname> method is called when
 	the last application holding a file handle opened on the device closes
 	it. Both methods are mostly used for UMS (User Mode Setting) drivers to
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 57e3014..fcde7d4 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
 	int i;
 	int ret;
 
-	if (dev->driver->firstopen) {
+	if (dev->driver->firstopen &&
+	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = dev->driver->firstopen(dev);
 		if (ret != 0)
 			return ret;
-- 
1.8.3.2

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

* [PATCH] drm: remove procfs code, take 2
  2013-07-10 12:12 ` [PATCH 39/39] drm: remove procfs code, take 2 Daniel Vetter
@ 2013-07-10 20:44   ` Daniel Vetter
  0 siblings, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-10 20:44 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

So almost two years ago I've tried to nuke the procfs code already
once before:

http://lists.freedesktop.org/archives/dri-devel/2011-October/015707.html

The conclusion was that userspace drivers (specifically libdrm device
node detection) stopped relying on procfs in 2001. But after some
digging it turned out that the drmstat tool in libdrm is still using
those files (but only when certain options are set). So we've decided
to keep profcs.

But I when I've started to dig around again what exactly this tool
does I've noticed that it tries to read the "mem", "vm", and "vma"
files from procfs. Now as far my git history digging shows "mem" never
did anything useful (at least in the version that first showed up in
upstream history in 2004) and the file was remove in

commit 955b12def42e83287c1bdb1411d99451753c1391
Author: Ben Gamari <bgamari@gmail.com>
Date:   Tue Feb 17 20:08:49 2009 -0500

    drm: Convert proc files to seq_file and introduce debugfs

Which means that for over 4 years drmstat has been broken, and no one
cared. In my opinion that's proof enough that no one is actually using
drmstat, and so that we can savely nuke the procfs support from drm.

While at it fix up the error case cleanup for debugfs in drm_get_minor.

v2: Fix dates, libdrm stopped relying on procfs for drm node detection
in 2001.

Cc: Dave Airlie <airlied@linux.ie>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/Makefile   |   2 +-
 drivers/gpu/drm/drm_drv.c  |   8 --
 drivers/gpu/drm/drm_proc.c | 209 ---------------------------------------------
 drivers/gpu/drm/drm_stub.c |  32 ++-----
 include/drm/drmP.h         |   8 --
 5 files changed, 9 insertions(+), 250 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 801bcaf..3ca730c 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -7,7 +7,7 @@ ccflags-y := -Iinclude/drm
 drm-y       :=	drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
 		drm_context.o drm_dma.o \
 		drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
-		drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
+		drm_lock.o drm_memory.o drm_stub.o drm_vm.o \
 		drm_agpsupport.o drm_scatter.o drm_pci.o \
 		drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_modes.o drm_edid.o \
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index b349b5f..a9f48ff 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -257,13 +257,6 @@ static int __init drm_core_init(void)
 		goto err_p2;
 	}
 
-	drm_proc_root = proc_mkdir("dri", NULL);
-	if (!drm_proc_root) {
-		DRM_ERROR("Cannot create /proc/dri\n");
-		ret = -1;
-		goto err_p3;
-	}
-
 	drm_debugfs_root = debugfs_create_dir("dri", NULL);
 	if (!drm_debugfs_root) {
 		DRM_ERROR("Cannot create /sys/kernel/debug/dri\n");
@@ -286,7 +279,6 @@ err_p1:
 
 static void __exit drm_core_exit(void)
 {
-	remove_proc_entry("dri", NULL);
 	debugfs_remove(drm_debugfs_root);
 	drm_sysfs_destroy();
 
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
deleted file mode 100644
index d7f2324..0000000
--- a/drivers/gpu/drm/drm_proc.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * \file drm_proc.c
- * /proc support for DRM
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- *
- * \par Acknowledgements:
- *    Matthew J Sottek <matthew.j.sottek@intel.com> sent in a patch to fix
- *    the problem with the proc files not outputting all their information.
- */
-
-/*
- * Created: Mon Jan 11 09:48:47 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <linux/seq_file.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <drm/drmP.h>
-
-/***************************************************
- * Initialization, etc.
- **************************************************/
-
-/**
- * Proc file list.
- */
-static const struct drm_info_list drm_proc_list[] = {
-	{"name", drm_name_info, 0},
-	{"vm", drm_vm_info, 0},
-	{"clients", drm_clients_info, 0},
-	{"bufs", drm_bufs_info, 0},
-	{"gem_names", drm_gem_name_info, DRIVER_GEM},
-#if DRM_DEBUG_CODE
-	{"vma", drm_vma_info, 0},
-#endif
-};
-#define DRM_PROC_ENTRIES ARRAY_SIZE(drm_proc_list)
-
-static int drm_proc_open(struct inode *inode, struct file *file)
-{
-	struct drm_info_node* node = PDE_DATA(inode);
-
-	return single_open(file, node->info_ent->show, node);
-}
-
-static const struct file_operations drm_proc_fops = {
-	.owner = THIS_MODULE,
-	.open = drm_proc_open,
-	.read = seq_read,
-	.llseek = seq_lseek,
-	.release = single_release,
-};
-
-
-/**
- * Initialize a given set of proc files for a device
- *
- * \param files The array of files to create
- * \param count The number of files given
- * \param root DRI proc dir entry.
- * \param minor device minor number
- * \return Zero on success, non-zero on failure
- *
- * Create a given set of proc files represented by an array of
- * gdm_proc_lists in the given root directory.
- */
-static int drm_proc_create_files(const struct drm_info_list *files, int count,
-			  struct proc_dir_entry *root, struct drm_minor *minor)
-{
-	struct drm_device *dev = minor->dev;
-	struct proc_dir_entry *ent;
-	struct drm_info_node *tmp;
-	int i;
-
-	for (i = 0; i < count; i++) {
-		u32 features = files[i].driver_features;
-
-		if (features != 0 &&
-		    (dev->driver->driver_features & features) != features)
-			continue;
-
-		tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
-		if (!tmp)
-			return -1;
-
-		tmp->minor = minor;
-		tmp->info_ent = &files[i];
-		list_add(&tmp->list, &minor->proc_nodes.list);
-
-		ent = proc_create_data(files[i].name, S_IRUGO, root,
-				       &drm_proc_fops, tmp);
-		if (!ent) {
-			DRM_ERROR("Cannot create /proc/dri/%u/%s\n",
-				  minor->index, files[i].name);
-			list_del(&tmp->list);
-			kfree(tmp);
-			return -1;
-		}
-	}
-	return 0;
-}
-
-/**
- * Initialize the DRI proc filesystem for a device
- *
- * \param dev DRM device
- * \param root DRI proc dir entry.
- * \param dev_root resulting DRI device proc dir entry.
- * \return root entry pointer on success, or NULL on failure.
- *
- * Create the DRI proc root entry "/proc/dri", the device proc root entry
- * "/proc/dri/%minor%/", and each entry in proc_list as
- * "/proc/dri/%minor%/%name%".
- */
-int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root)
-{
-	char name[12];
-	int ret;
-
-	INIT_LIST_HEAD(&minor->proc_nodes.list);
-	sprintf(name, "%u", minor->index);
-	minor->proc_root = proc_mkdir(name, root);
-	if (!minor->proc_root) {
-		DRM_ERROR("Cannot create /proc/dri/%s\n", name);
-		return -1;
-	}
-
-	ret = drm_proc_create_files(drm_proc_list, DRM_PROC_ENTRIES,
-				    minor->proc_root, minor);
-	if (ret) {
-		remove_proc_subtree(name, root);
-		minor->proc_root = NULL;
-		DRM_ERROR("Failed to create core drm proc files\n");
-		return ret;
-	}
-
-	return 0;
-}
-
-static int drm_proc_remove_files(const struct drm_info_list *files, int count,
-			  struct drm_minor *minor)
-{
-	struct list_head *pos, *q;
-	struct drm_info_node *tmp;
-	int i;
-
-	for (i = 0; i < count; i++) {
-		list_for_each_safe(pos, q, &minor->proc_nodes.list) {
-			tmp = list_entry(pos, struct drm_info_node, list);
-			if (tmp->info_ent == &files[i]) {
-				remove_proc_entry(files[i].name,
-						  minor->proc_root);
-				list_del(pos);
-				kfree(tmp);
-			}
-		}
-	}
-	return 0;
-}
-
-/**
- * Cleanup the proc filesystem resources.
- *
- * \param minor device minor number.
- * \param root DRI proc dir entry.
- * \param dev_root DRI device proc dir entry.
- * \return always zero.
- *
- * Remove all proc entries created by proc_init().
- */
-int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root)
-{
-	char name[64];
-
-	if (!root || !minor->proc_root)
-		return 0;
-
-	drm_proc_remove_files(drm_proc_list, DRM_PROC_ENTRIES, minor);
-
-	sprintf(name, "%d", minor->index);
-	remove_proc_subtree(name, root);
-	return 0;
-}
-
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 30cbd62..f9cacf5 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -68,7 +68,6 @@ module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600);
 struct idr drm_minors_idr;
 
 struct class *drm_class;
-struct proc_dir_entry *drm_proc_root;
 struct dentry *drm_debugfs_root;
 
 int drm_err(const char *func, const char *format, ...)
@@ -315,9 +314,8 @@ EXPORT_SYMBOL(drm_fill_in_dev);
  * \param sec-minor structure to hold the assigned minor
  * \return negative number on failure.
  *
- * Search an empty entry and initialize it to the given parameters, and
- * create the proc init entry via proc_init(). This routines assigns
- * minor numbers to secondary heads of multi-headed cards
+ * Search an empty entry and initialize it to the given parameters. This
+ * routines assigns minor numbers to secondary heads of multi-headed cards
  */
 int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 {
@@ -345,20 +343,11 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 
 	idr_replace(&drm_minors_idr, new_minor, minor_id);
 
-	if (type == DRM_MINOR_LEGACY) {
-		ret = drm_proc_init(new_minor, drm_proc_root);
-		if (ret) {
-			DRM_ERROR("DRM: Failed to initialize /proc/dri.\n");
-			goto err_mem;
-		}
-	} else
-		new_minor->proc_root = NULL;
-
 #if defined(CONFIG_DEBUG_FS)
 	ret = drm_debugfs_init(new_minor, minor_id, drm_debugfs_root);
 	if (ret) {
 		DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n");
-		goto err_g2;
+		goto err_mem;
 	}
 #endif
 
@@ -366,7 +355,7 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 	if (ret) {
 		printk(KERN_ERR
 		       "DRM: Error sysfs_device_add.\n");
-		goto err_g2;
+		goto err_debugfs;
 	}
 	*minor = new_minor;
 
@@ -374,9 +363,10 @@ int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type)
 	return 0;
 
 
-err_g2:
-	if (new_minor->type == DRM_MINOR_LEGACY)
-		drm_proc_cleanup(new_minor, drm_proc_root);
+err_debugfs:
+#if defined(CONFIG_DEBUG_FS)
+	drm_debugfs_cleanup(new_minor);
+#endif
 err_mem:
 	kfree(new_minor);
 err_idr:
@@ -391,10 +381,6 @@ EXPORT_SYMBOL(drm_get_minor);
  *
  * \param sec_minor - structure to be released
  * \return always zero
- *
- * Cleans up the proc resources. Not legal for this to be the
- * last minor released.
- *
  */
 int drm_put_minor(struct drm_minor **minor_p)
 {
@@ -402,8 +388,6 @@ int drm_put_minor(struct drm_minor **minor_p)
 
 	DRM_DEBUG("release secondary minor %d\n", minor->index);
 
-	if (minor->type == DRM_MINOR_LEGACY)
-		drm_proc_cleanup(minor, drm_proc_root);
 #if defined(CONFIG_DEBUG_FS)
 	drm_debugfs_cleanup(minor);
 #endif
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index ae62442..5dfce86 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -45,7 +45,6 @@
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/fs.h>
-#include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/platform_device.h>
@@ -1020,8 +1019,6 @@ struct drm_minor {
 	struct device kdev;		/**< Linux device */
 	struct drm_device *dev;
 
-	struct proc_dir_entry *proc_root;  /**< proc directory entry */
-	struct drm_info_node proc_nodes;
 	struct dentry *debugfs_root;
 
 	struct list_head debugfs_list;
@@ -1473,17 +1470,12 @@ extern unsigned int drm_timestamp_precision;
 extern unsigned int drm_timestamp_monotonic;
 
 extern struct class *drm_class;
-extern struct proc_dir_entry *drm_proc_root;
 extern struct dentry *drm_debugfs_root;
 
 extern struct idr drm_minors_idr;
 
 extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
 
-				/* Proc support (drm_proc.h) */
-extern int drm_proc_init(struct drm_minor *minor, struct proc_dir_entry *root);
-extern int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
-
 				/* Debugfs support */
 #if defined(CONFIG_DEBUG_FS)
 extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
-- 
1.8.3.2

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

* Re: [PATCH] drm: remove FASYNC support
  2013-07-10 15:25     ` Daniel Vetter
@ 2013-07-11  0:26       ` Laurent Pinchart
  0 siblings, 0 replies; 71+ messages in thread
From: Laurent Pinchart @ 2013-07-11  0:26 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi Daniel,

Thank you for the patch.

On Wednesday 10 July 2013 17:25:04 Daniel Vetter wrote:
> So I've stumbled over drm_fasync and wondered what it does. Digging
> that up is quite a story.
> 
> First I've had to read up on what this does and ended up being rather
> bewildered why peopled loved signals so much back in the days that
> they've created SIGIO just for that ...
> 
> Then I wondered how this ever works, and what that strange "No-op."
> comment right above it should mean. After all calling the core fasync
> helper is pretty obviously not a noop. After reading through the
> kernels FASYNC implementation I've noticed that signals are only sent
> out to the processes attached with FASYNC by calling kill_fasync.
> 
> No merged drm driver has ever done that.
> 
> After more digging I've found out that the only driver that ever used
> this is the so called GAMMA driver. I've frankly never heard of such a
> gpu brand ever before. Now FASYNC seems to not have been the only bad
> thing with that driver, since Dave Airlie removed it from the drm
> driver with prejudice:
> 
> commit 1430163b4bbf7b00367ea1066c1c5fe85dbeefed
> Author: Dave Airlie <airlied@linux.ie>
> Date:   Sun Aug 29 12:04:35 2004 +0000
> 
>     Drop GAMMA DRM from a great height ...
> 
> Long story short, the drm fasync support seems to be doing absolutely
> nothing. And the only user of it was never merged into the upstream
> kernel. And we don't need any fops->fasync callback since the fcntl
> implementation in the kernel already implements the noop case
> correctly.
> 
> So stop this particular cargo-cult and rip it all out.
> 
> v2: Kill drm_fasync assignments in rcar (newly added) and imx drivers
> (somehow I've missed that one in staging). Also drop the reference in
> the drm DocBook. ARM compile-fail reported by Rob Clark.
> 
> v3: Move the removal of dev->buf_asnyc assignment in drm_setup to this
> patch here.
> 
> v4: Actually git add ... tsk.
> 
> Cc: Dave Airlie <airlied@linux.ie>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Rob Clark <robdclark@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

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

> ---
>  Documentation/DocBook/drm.tmpl           |  1 -
>  drivers/gpu/drm/ast/ast_drv.c            |  1 -
>  drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 -
>  drivers/gpu/drm/drm_fops.c               | 14 --------------
>  drivers/gpu/drm/gma500/psb_drv.c         |  1 -
>  drivers/gpu/drm/i810/i810_dma.c          |  1 -
>  drivers/gpu/drm/i810/i810_drv.c          |  1 -
>  drivers/gpu/drm/i915/i915_drv.c          |  1 -
>  drivers/gpu/drm/mga/mga_drv.c            |  1 -
>  drivers/gpu/drm/mgag200/mgag200_drv.c    |  1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c    |  1 -
>  drivers/gpu/drm/omapdrm/omap_drv.c       |  1 -
>  drivers/gpu/drm/qxl/qxl_drv.c            |  1 -
>  drivers/gpu/drm/r128/r128_drv.c          |  1 -
>  drivers/gpu/drm/radeon/radeon_drv.c      |  2 --
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c    |  1 -
>  drivers/gpu/drm/savage/savage_drv.c      |  1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c |  1 -
>  drivers/gpu/drm/sis/sis_drv.c            |  1 -
>  drivers/gpu/drm/tdfx/tdfx_drv.c          |  1 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c      |  1 -
>  drivers/gpu/drm/udl/udl_drv.c            |  1 -
>  drivers/gpu/drm/via/via_drv.c            |  1 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 -
>  drivers/gpu/host1x/drm/drm.c             |  1 -
>  drivers/staging/imx-drm/imx-drm-core.c   |  1 -
>  include/drm/drmP.h                       |  3 ---
>  27 files changed, 43 deletions(-)
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 4d54ac8..79dd70e 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2498,7 +2498,6 @@ void (*postclose) (struct drm_device *, struct
> drm_file *);</synopsis> <programlisting>
>  	.poll = drm_poll,
>  	.read = drm_read,
> -	.fasync = drm_fasync,
>  	.llseek = no_llseek,
>  	</programlisting>
>        </para>
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index df0d0a0..16050ed 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -190,7 +190,6 @@ static const struct file_operations ast_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = ast_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c
> b/drivers/gpu/drm/cirrus/cirrus_drv.c index 8ecb601..85748f6 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_drv.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
> @@ -85,7 +85,6 @@ static const struct file_operations cirrus_driver_fops = {
> #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> -	.fasync = drm_fasync,
>  };
>  static struct drm_driver driver = {
>  	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 14e0bb6..d1b4771 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -75,8 +75,6 @@ static int drm_setup(struct drm_device * dev)
>  	dev->last_checked = 0;
>  	dev->if_version = 0;
> 
> -	dev->buf_async = NULL;
> -
>  	DRM_DEBUG("\n");
> 
>  	/*
> @@ -374,18 +372,6 @@ out_put_pid:
>  	return ret;
>  }
> 
> -/** No-op. */
> -int drm_fasync(int fd, struct file *filp, int on)
> -{
> -	struct drm_file *priv = filp->private_data;
> -	struct drm_device *dev = priv->minor->dev;
> -
> -	DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
> -		  (long)old_encode_dev(priv->minor->device));
> -	return fasync_helper(fd, filp, on, &dev->buf_async);
> -}
> -EXPORT_SYMBOL(drm_fasync);
> -
>  static void drm_master_release(struct drm_device *dev, struct file *filp)
>  {
>  	struct drm_file *file_priv = filp->private_data;
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c
> b/drivers/gpu/drm/gma500/psb_drv.c index bddea58..c9c37ac 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -622,7 +622,6 @@ static const struct file_operations psb_gem_fops = {
>  	.unlocked_ioctl = psb_unlocked_ioctl,
>  	.mmap = drm_gem_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  };
> 
> diff --git a/drivers/gpu/drm/i810/i810_dma.c
> b/drivers/gpu/drm/i810/i810_dma.c index 004ecdf..ef1c9c7 100644
> --- a/drivers/gpu/drm/i810/i810_dma.c
> +++ b/drivers/gpu/drm/i810/i810_dma.c
> @@ -113,7 +113,6 @@ static const struct file_operations i810_buffer_fops = {
> .release = drm_release,
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = i810_mmap_buffers,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/i810/i810_drv.c
> b/drivers/gpu/drm/i810/i810_drv.c index 2e91fc3..d85c05b 100644
> --- a/drivers/gpu/drm/i810/i810_drv.c
> +++ b/drivers/gpu/drm/i810/i810_drv.c
> @@ -49,7 +49,6 @@ static const struct file_operations i810_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/i915/i915_drv.c
> b/drivers/gpu/drm/i915/i915_drv.c index 062cbda..999ef21 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1110,7 +1110,6 @@ static const struct file_operations i915_driver_fops =
> { .unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_gem_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = i915_compat_ioctl,
> diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
> index 17d0a63..fe71e1e 100644
> --- a/drivers/gpu/drm/mga/mga_drv.c
> +++ b/drivers/gpu/drm/mga/mga_drv.c
> @@ -50,7 +50,6 @@ static const struct file_operations mga_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = mga_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c
> b/drivers/gpu/drm/mgag200/mgag200_drv.c index 122b571..31ff081 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
> @@ -81,7 +81,6 @@ static const struct file_operations mgag200_driver_fops =
> { .unlocked_ioctl = drm_ioctl,
>  	.mmap = mgag200_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c
> b/drivers/gpu/drm/nouveau/nouveau_drm.c index e990327..e09debe 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -664,7 +664,6 @@ nouveau_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = nouveau_ttm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  #if defined(CONFIG_COMPAT)
>  	.compat_ioctl = nouveau_compat_ioctl,
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c
> b/drivers/gpu/drm/omapdrm/omap_drv.c index 3f7c78a..fd2cfed 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -577,7 +577,6 @@ static const struct file_operations omapdriver_fops = {
>  		.release = drm_release,
>  		.mmap = omap_gem_mmap,
>  		.poll = drm_poll,
> -		.fasync = drm_fasync,
>  		.read = drm_read,
>  		.llseek = noop_llseek,
>  };
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index df0b577..4be5225 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -84,7 +84,6 @@ static const struct file_operations qxl_fops = {
>  	.release = drm_release,
>  	.unlocked_ioctl = drm_ioctl,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.mmap = qxl_mmap,
>  };
> 
> diff --git a/drivers/gpu/drm/r128/r128_drv.c
> b/drivers/gpu/drm/r128/r128_drv.c index 472c38f..c2338cb 100644
> --- a/drivers/gpu/drm/r128/r128_drv.c
> +++ b/drivers/gpu/drm/r128/r128_drv.c
> @@ -48,7 +48,6 @@ static const struct file_operations r128_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = r128_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c
> b/drivers/gpu/drm/radeon/radeon_drv.c index 81b9baa..ae94625 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -265,7 +265,6 @@ static const struct file_operations
> radeon_driver_old_fops = { .unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = radeon_compat_ioctl,
> @@ -374,7 +373,6 @@ static const struct file_operations
> radeon_driver_kms_fops = { .unlocked_ioctl = drm_ioctl,
>  	.mmap = radeon_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = radeon_kms_compat_ioctl,
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index ff82877..46e5967 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -230,7 +230,6 @@ static const struct file_operations rcar_du_fops = {
>  #endif
>  	.poll		= drm_poll,
>  	.read		= drm_read,
> -	.fasync		= drm_fasync,
>  	.llseek		= no_llseek,
>  	.mmap		= drm_gem_cma_mmap,
>  };
> diff --git a/drivers/gpu/drm/savage/savage_drv.c
> b/drivers/gpu/drm/savage/savage_drv.c index 71b2081..9135c8b 100644
> --- a/drivers/gpu/drm/savage/savage_drv.c
> +++ b/drivers/gpu/drm/savage/savage_drv.c
> @@ -42,7 +42,6 @@ static const struct file_operations savage_driver_fops = {
> .unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index edc1018..db94f2f 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -257,7 +257,6 @@ static const struct file_operations shmob_drm_fops = {
>  #endif
>  	.poll		= drm_poll,
>  	.read		= drm_read,
> -	.fasync		= drm_fasync,
>  	.llseek		= no_llseek,
>  	.mmap		= drm_gem_cma_mmap,
>  };
> diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
> index 5a5325e..b88b2d3 100644
> --- a/drivers/gpu/drm/sis/sis_drv.c
> +++ b/drivers/gpu/drm/sis/sis_drv.c
> @@ -72,7 +72,6 @@ static const struct file_operations sis_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c
> b/drivers/gpu/drm/tdfx/tdfx_drv.c index ddfa743..951ec13 100644
> --- a/drivers/gpu/drm/tdfx/tdfx_drv.c
> +++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
> @@ -48,7 +48,6 @@ static const struct file_operations tdfx_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> b/drivers/gpu/drm/tilcdc/tilcdc_drv.c index 40b71da..ff920ff 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -497,7 +497,6 @@ static const struct file_operations fops = {
>  #endif
>  	.poll               = drm_poll,
>  	.read               = drm_read,
> -	.fasync             = drm_fasync,
>  	.llseek             = no_llseek,
>  	.mmap               = drm_gem_cma_mmap,
>  };
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index c0770db..c275adb 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -65,7 +65,6 @@ static const struct file_operations udl_driver_fops = {
>  	.read = drm_read,
>  	.unlocked_ioctl	= drm_ioctl,
>  	.release = drm_release,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
> index f4ae203..4487999 100644
> --- a/drivers/gpu/drm/via/via_drv.c
> +++ b/drivers/gpu/drm/via/via_drv.c
> @@ -64,7 +64,6 @@ static const struct file_operations via_driver_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 3e75dfa..77d503a 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -1103,7 +1103,6 @@ static const struct file_operations vmwgfx_driver_fops
> = { .mmap = vmw_mmap,
>  	.poll = vmw_fops_poll,
>  	.read = vmw_fops_read,
> -	.fasync = drm_fasync,
>  #if defined(CONFIG_COMPAT)
>  	.compat_ioctl = drm_compat_ioctl,
>  #endif
> diff --git a/drivers/gpu/host1x/drm/drm.c b/drivers/gpu/host1x/drm/drm.c
> index e184b00..f8b708f 100644
> --- a/drivers/gpu/host1x/drm/drm.c
> +++ b/drivers/gpu/host1x/drm/drm.c
> @@ -508,7 +508,6 @@ static const struct file_operations tegra_drm_fops = {
>  	.unlocked_ioctl = drm_ioctl,
>  	.mmap = tegra_drm_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = drm_compat_ioctl,
> diff --git a/drivers/staging/imx-drm/imx-drm-core.c
> b/drivers/staging/imx-drm/imx-drm-core.c index 70f9650..f1cde28 100644
> --- a/drivers/staging/imx-drm/imx-drm-core.c
> +++ b/drivers/staging/imx-drm/imx-drm-core.c
> @@ -199,7 +199,6 @@ static const struct file_operations imx_drm_driver_fops
> = { .unlocked_ioctl = drm_ioctl,
>  	.mmap = drm_gem_cma_mmap,
>  	.poll = drm_poll,
> -	.fasync = drm_fasync,
>  	.read = drm_read,
>  	.llseek = noop_llseek,
>  };
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index d38c358..3589736 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1169,8 +1169,6 @@ struct drm_device {
> 
>  	/*@} */
> 
> -	struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
> -
>  	struct drm_agp_head *agp;	/**< AGP data */
> 
>  	struct device *dev;             /**< Device structure */
> @@ -1277,7 +1275,6 @@ extern int drm_lastclose(struct drm_device *dev);
>  extern struct mutex drm_global_mutex;
>  extern int drm_open(struct inode *inode, struct file *filp);
>  extern int drm_stub_open(struct inode *inode, struct file *filp);
> -extern int drm_fasync(int fd, struct file *filp, int on);
>  extern ssize_t drm_read(struct file *filp, char __user *buffer,
>  			size_t count, loff_t *offset);
>  extern int drm_release(struct inode *inode, struct file *filp);
-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm: don't call ->firstopen for KMS drivers
  2013-07-10 18:17   ` [PATCH] " Daniel Vetter
@ 2013-07-11  7:54     ` Laurent Pinchart
  2013-07-11 10:19       ` Daniel Vetter
  0 siblings, 1 reply; 71+ messages in thread
From: Laurent Pinchart @ 2013-07-11  7:54 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi Daniel,

On Wednesday 10 July 2013 20:17:44 Daniel Vetter wrote:
> It has way too much potential for driver writers to do stupid things
> like delayed hw setup because the load sequence is somehow racy (e.g.
> the imx driver in staging). So don't call it for modesetting drivers,
> which reduces the complexity of the drm core -> driver interface a
> notch.
> 
> v2: Don't forget to update DocBook.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  Documentation/DocBook/drm.tmpl | 2 ++
>  drivers/gpu/drm/drm_fops.c     | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 4d54ac8..0e8a5a3 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2423,6 +2423,8 @@ void (*postclose) (struct drm_device *, struct
> drm_file *);</synopsis> <para>
>          The <methodname>firstopen</methodname> method is called by the DRM
> core when an application opens a device that has no other opened file
> handle.
> +	Not that this callback is only called for legacy ums drm drivers, not
> +	for drm drivers that implement modesetting in the kernel.
>  	Similarly the <methodname>lastclose</methodname> method is called when
>  	the last application holding a file handle opened on the device closes
>  	it. Both methods are mostly used for UMS (User Mode Setting) drivers to

What about

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 7d1278e..afa8d40 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
       </abstract>
       <para>
         The <methodname>firstopen</methodname> method is called by the DRM core
-	when an application opens a device that has no other opened file handle.
-	Similarly the <methodname>lastclose</methodname> method is called when
-	the last application holding a file handle opened on the device closes
-	it. Both methods are mostly used for UMS (User Mode Setting) drivers to
-	acquire and release device resources which should be done in the
-	<methodname>load</methodname> and <methodname>unload</methodname>
-	methods for KMS drivers.
+	for legacy UMS (User Mode Setting) drivers only when an application
+	opens a device that has no other opened file handle. UMS drivers can
+	implement it to acquire device resources. KMS drivers can't use the
+	method and must acquire resources in the <methodname>load</methodname>
+	method instead.
       </para>
       <para>
-        Note that the <methodname>lastclose</methodname> method is also called
-	at module unload time or, for hot-pluggable devices, when the device is
-	unplugged. The <methodname>firstopen</methodname> and
+	Similarly the <methodname>lastclose</methodname> method is called when
+	the last application holding a file handle opened on the device closes
+	it, for both UMS and KMS drivers. Additionally, the method is also
+	called at module unload time or, for hot-pluggable devices, when the
+	device is unplugged. The <methodname>firstopen</methodname> and
 	<methodname>lastclose</methodname> calls can thus be unbalanced.
       </para>
       <para>

> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 57e3014..fcde7d4 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
>  	int i;
>  	int ret;
> 
> -	if (dev->driver->firstopen) {
> +	if (dev->driver->firstopen &&
> +	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		ret = dev->driver->firstopen(dev);
>  		if (ret != 0)
>  			return ret;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm: don't call ->firstopen for KMS drivers
  2013-07-11  7:54     ` Laurent Pinchart
@ 2013-07-11 10:19       ` Daniel Vetter
  2013-07-13 14:43         ` Daniel Vetter
  2013-07-13 14:45         ` Daniel Vetter
  0 siblings, 2 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-11 10:19 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: DRI Development

On Thu, Jul 11, 2013 at 9:54 AM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hi Daniel,
>
> On Wednesday 10 July 2013 20:17:44 Daniel Vetter wrote:
>> It has way too much potential for driver writers to do stupid things
>> like delayed hw setup because the load sequence is somehow racy (e.g.
>> the imx driver in staging). So don't call it for modesetting drivers,
>> which reduces the complexity of the drm core -> driver interface a
>> notch.
>>
>> v2: Don't forget to update DocBook.
>>
>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> ---
>>  Documentation/DocBook/drm.tmpl | 2 ++
>>  drivers/gpu/drm/drm_fops.c     | 3 ++-
>>  2 files changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
>> index 4d54ac8..0e8a5a3 100644
>> --- a/Documentation/DocBook/drm.tmpl
>> +++ b/Documentation/DocBook/drm.tmpl
>> @@ -2423,6 +2423,8 @@ void (*postclose) (struct drm_device *, struct
>> drm_file *);</synopsis> <para>
>>          The <methodname>firstopen</methodname> method is called by the DRM
>> core when an application opens a device that has no other opened file
>> handle.
>> +     Not that this callback is only called for legacy ums drm drivers, not
>> +     for drm drivers that implement modesetting in the kernel.
>>       Similarly the <methodname>lastclose</methodname> method is called when
>>       the last application holding a file handle opened on the device closes
>>       it. Both methods are mostly used for UMS (User Mode Setting) drivers to
>
> What about

So if you think we should go overboard I guess it'd be useful to
explain what KMS drivers should and shouldn't do in lastclose:
- Delayed gpu switching with vga switcheroo.
- Restoring of the fbcon, as long as the core is still a bit deficient
in getting rid of mouse cursors and stupid sprite setups when X dies
untimely and leaves dirt behind. Eventually we should be able to get
rid of this though and rely on the magic sysrq to get out of graphics
mode and restore fbcon fully.
- Nothing else, ever, especially resource cleanups.

Can you maybe add a sentence or two to your proposed update for about
this? UMS drivers tend to do a lot of nefarious stuff in lastclose, so
stressing the difference would be good.

Otherwise I like your doc update much more than mine ;-)
-Daniel

>
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 7d1278e..afa8d40 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
>        </abstract>
>        <para>
>          The <methodname>firstopen</methodname> method is called by the DRM core
> -       when an application opens a device that has no other opened file handle.
> -       Similarly the <methodname>lastclose</methodname> method is called when
> -       the last application holding a file handle opened on the device closes
> -       it. Both methods are mostly used for UMS (User Mode Setting) drivers to
> -       acquire and release device resources which should be done in the
> -       <methodname>load</methodname> and <methodname>unload</methodname>
> -       methods for KMS drivers.
> +       for legacy UMS (User Mode Setting) drivers only when an application
> +       opens a device that has no other opened file handle. UMS drivers can
> +       implement it to acquire device resources. KMS drivers can't use the
> +       method and must acquire resources in the <methodname>load</methodname>
> +       method instead.
>        </para>
>        <para>
> -        Note that the <methodname>lastclose</methodname> method is also called
> -       at module unload time or, for hot-pluggable devices, when the device is
> -       unplugged. The <methodname>firstopen</methodname> and
> +       Similarly the <methodname>lastclose</methodname> method is called when
> +       the last application holding a file handle opened on the device closes
> +       it, for both UMS and KMS drivers. Additionally, the method is also
> +       called at module unload time or, for hot-pluggable devices, when the
> +       device is unplugged. The <methodname>firstopen</methodname> and
>         <methodname>lastclose</methodname> calls can thus be unbalanced.
>        </para>
>        <para>
>
>> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
>> index 57e3014..fcde7d4 100644
>> --- a/drivers/gpu/drm/drm_fops.c
>> +++ b/drivers/gpu/drm/drm_fops.c
>> @@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
>>       int i;
>>       int ret;
>>
>> -     if (dev->driver->firstopen) {
>> +     if (dev->driver->firstopen &&
>> +         !drm_core_check_feature(dev, DRIVER_MODESET)) {
>>               ret = dev->driver->firstopen(dev);
>>               if (ret != 0)
>>                       return ret;
>
> --
> Regards,
>
> Laurent Pinchart



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

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

* Re: [PATCH 00/39] clean out drm cruft and hide it better for kms drivers
  2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
                   ` (40 preceding siblings ...)
  2013-07-10 15:51 ` [PATCH 1/2] drm: rip out dev->last_checked Daniel Vetter
@ 2013-07-11 14:09 ` Alex Deucher
  41 siblings, 0 replies; 71+ messages in thread
From: Alex Deucher @ 2013-07-11 14:09 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Wed, Jul 10, 2013 at 8:11 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Hi all,
>
> I've figured that it's again time for a bit of (late) drm spring cleanup. This
> series here consists of a pile of "rip old stuff out" patches interleaved with
> "disable old cruft for kms drivers and hide it better".
>
> Comments, flames and review highly welcome. I'd be especially happy if the arm
> guys could check whether I haven't badly broken their drivers - compile-testing
> arm is a pita, so I haven't yet done that.
>
> There's a few driver-wide patches included, but the more invasive ones (i.e.
> changing more than the drm driver vtable) are split out per-driver for easier
> merging. If no one screams my plan is to rebase this pile on top of -rc1, give
> it some more testing (check arm, ugh) and then send a pull request to Dave.
> That should reduce interference with ongoing driver work as much as possible I
> hope.
>
> My drm cruft todo list still has a pile of ideas, but I've figured I need to
> stop now for 3.12. For those interested further cleanups could include:
>
> - setversion/set_busid: All drm core version 1.1 is legacy cruft, kms drivers
>   should never run in this mode. We could clean up the setversion ioclt (and
>   move the drm core version handling into a legacy function) and set up the bus
>   id unconditionally at driver load time.
>
> - There's a few more legacy ioctls/subsystems that could be blocked out for kms
>   drivers (but the required git history digging tends to be tedious). Also I
>   think we could more aggressively move legacy cruft setup/teardown code
>   out-of-line from the main code by extracting it into drm_legacy_ functions
>   (like this series here already does for the context and dma stuff).
>
> - I think creating a drm_internal.h header for functions not exported to drivers
>   would be useful. That way we could move all the legacy functions out of drmP.h
>   (which are a lot of them), which should make it much clearer what the real drm
>   driver interface actually is.
>
> - drm_os_linux.h should just die in fire.
>
> - There's a pile of needless indirection around our agp handling, we duplicate
>   the agp core's CONFIG_AGP=n no-oping function handling in large parts, among
>   other stuff.
>
> - The drm coherent dma alloc helpers could get ripped out, at least for kms
>   drivers. For ums drivers there's some funny cases where this mapping is
>   exchanged with userspace for e.g. register access. In a least one case
>   (i810.ko) userspace even sets up that mapping, which allows it to crash the
>   kernel at will (since those maps aren't refcounted). Maybe we need to shovel
>   those interfaces into a drm_legacy.ko module to keep them around but make sure
>   that no new driver even thinks about using them.
>
> - There's also the matter of the vblank support code, imo that should be split
>   int a ums and a kms part. That'd would allow us to use struct drm_crtc * in
>   interfaces and proper locking (by grabbing crtc->mutex to exclude races with
>   dpms/modesets).
>
> If anyone wants to dig around in those areas please poke me.
>

For the series:

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> Cheers, Daniel
>
> Daniel Vetter (39):
>   drm: remove drm_modctx ioctl and use drm_noop instead
>   drm: kill dev->context_wait
>   drm: remove dev->last_switch
>   drm: kill dev->interrupt_flag and dev->dma_flag
>   drm: kill dev->ctx_start and dev->lck_start
>   drm/radoen: kill radeon_dma_ioctl_kms
>   drm: kill dev->buf_readers and dev->buf_writers
>   drm: remove redundant clears from drm_setup
>   drm/omap: kill firstopen callback
>   drm/radeon: kill firstopen callback for kms driver
>   drm/imx: kill firstopen callback
>   drm/vmwgfx: remove ->firstopen callback
>   drm: don't call ->firstopen for KMS drivers
>   drm: kill dev->driver->set_version
>   drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver
>   drm: fold in drm_sg_alloc into the ioctl
>   drm: hide legacy sg cleanup better from common code
>   drm: disallow legacy sg ioctls for modesetting drivers
>   drm: mark dma setup/teardown as legacy systems
>   drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG
>   drm: disallow legacy dma ioctls for modesetting drivers
>   drm: move drm_getsarea into drm_bufs.c
>   drm/bufs: s/drm_order/order_base_2/
>   drm/r128: s/drm_order/order_base_2/
>   drm/radeon: s/drm_order/order_base_2/
>   drm: remove drm_order
>   drm: mark context support as a legacy subsystem
>   drm/vmwgfx: remove redundant clearing of driver->dma_quiescent
>   drm: remove FASYNC support
>   drm: rip out DRIVER_FB_DMA and related code
>   drm: rip out a few unused DRIVER flags
>   drm: remove a bunch of unused #defines from drmP.h
>   drm: rip out drm_core_has_MTRR checks
>   drm: remove the dma_ioctl special-case
>   drm/memory: don't export agp helpers
>   drm: hollow-out GET_CLIENT ioctl
>   drm: no-op out GET_STATS ioctl
>   drm: fix locking in gem debugfs/procfs file
>   drm: remove procfs code, take 2
>
>  drivers/gpu/drm/Makefile                 |   2 +-
>  drivers/gpu/drm/ast/ast_drv.c            |   1 -
>  drivers/gpu/drm/cirrus/cirrus_drv.c      |   1 -
>  drivers/gpu/drm/drm_bufs.c               | 238 +++++++------------------------
>  drivers/gpu/drm/drm_context.c            |  81 ++++++++---
>  drivers/gpu/drm/drm_dma.c                |  17 ++-
>  drivers/gpu/drm/drm_drv.c                |  44 +-----
>  drivers/gpu/drm/drm_fops.c               |  66 +--------
>  drivers/gpu/drm/drm_info.c               |   4 +
>  drivers/gpu/drm/drm_ioctl.c              |  43 +-----
>  drivers/gpu/drm/drm_memory.c             |   2 -
>  drivers/gpu/drm/drm_pci.c                |  11 +-
>  drivers/gpu/drm/drm_proc.c               | 209 ---------------------------
>  drivers/gpu/drm/drm_scatter.c            |  29 ++--
>  drivers/gpu/drm/drm_stub.c               |  44 ++----
>  drivers/gpu/drm/drm_vm.c                 |   3 +-
>  drivers/gpu/drm/gma500/psb_drv.c         |   3 +-
>  drivers/gpu/drm/i810/i810_dma.c          |   1 -
>  drivers/gpu/drm/i810/i810_drv.c          |   1 -
>  drivers/gpu/drm/i915/i915_drv.c          |   1 -
>  drivers/gpu/drm/mga/mga_drv.c            |   1 -
>  drivers/gpu/drm/mgag200/mgag200_drv.c    |   1 -
>  drivers/gpu/drm/nouveau/nouveau_drm.c    |   3 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c       |   8 --
>  drivers/gpu/drm/qxl/qxl_drv.c            |   1 -
>  drivers/gpu/drm/r128/r128_cce.c          |   2 +-
>  drivers/gpu/drm/r128/r128_drv.c          |   1 -
>  drivers/gpu/drm/radeon/cik.c             |  14 +-
>  drivers/gpu/drm/radeon/evergreen.c       |   4 +-
>  drivers/gpu/drm/radeon/ni.c              |   6 +-
>  drivers/gpu/drm/radeon/r100.c            |   2 +-
>  drivers/gpu/drm/radeon/r600.c            |  14 +-
>  drivers/gpu/drm/radeon/r600_cp.c         |   6 +-
>  drivers/gpu/drm/radeon/radeon_cp.c       |   6 +-
>  drivers/gpu/drm/radeon/radeon_drv.c      |  11 +-
>  drivers/gpu/drm/radeon/radeon_kms.c      |  23 ---
>  drivers/gpu/drm/radeon/si.c              |  14 +-
>  drivers/gpu/drm/savage/savage_drv.c      |   1 -
>  drivers/gpu/drm/shmobile/shmob_drm_drv.c |   1 -
>  drivers/gpu/drm/sis/sis_drv.c            |   1 -
>  drivers/gpu/drm/tdfx/tdfx_drv.c          |   1 -
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   1 -
>  drivers/gpu/drm/udl/udl_drv.c            |   1 -
>  drivers/gpu/drm/via/via_drv.c            |   1 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  20 ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |   1 -
>  drivers/gpu/host1x/drm/drm.c             |   1 -
>  drivers/staging/imx-drm/imx-drm-core.c   |  20 +--
>  include/drm/drmP.h                       |  65 ++-------
>  49 files changed, 239 insertions(+), 793 deletions(-)
>  delete mode 100644 drivers/gpu/drm/drm_proc.c
>
> --
> 1.8.3.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] drm: don't call ->firstopen for KMS drivers
  2013-07-11 10:19       ` Daniel Vetter
@ 2013-07-13 14:43         ` Daniel Vetter
  2013-07-13 14:45         ` Daniel Vetter
  1 sibling, 0 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-13 14:43 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter, Laurent Pinchart

It has way too much potential for driver writers to do stupid things
like delayed hw setup because the load sequence is somehow racy (e.g.
the imx driver in staging). So don't call it for modesetting drivers,
which reduces the complexity of the drm core -> driver interface a
notch.

v2: Don't forget to update DocBook.

v3: Go with Laurent's slightly more elaborate proposal for the DocBook
update. Add a few words on top of his diff to elaborate a bit on what
KMS drivers should and shouldn't do in lastclose. There was already a
paragraph present talking about restoring properties, I've simply
extended that one.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl | 27 ++++++++++++++++-----------
 drivers/gpu/drm/drm_fops.c     |  3 ++-
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4d54ac8..52d5eda 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
       </abstract>
       <para>
         The <methodname>firstopen</methodname> method is called by the DRM core
-	when an application opens a device that has no other opened file handle.
-	Similarly the <methodname>lastclose</methodname> method is called when
-	the last application holding a file handle opened on the device closes
-	it. Both methods are mostly used for UMS (User Mode Setting) drivers to
-	acquire and release device resources which should be done in the
-	<methodname>load</methodname> and <methodname>unload</methodname>
-	methods for KMS drivers.
+	for legacy UMS (User Mode Setting) drivers only when an application
+	opens a device that has no other opened file handle. UMS drivers can
+	implement it to acquire device resources. KMS drivers can't use the
+	method and must acquire resources in the <methodname>load</methodname>
+	method instead.
       </para>
       <para>
-        Note that the <methodname>lastclose</methodname> method is also called
-	at module unload time or, for hot-pluggable devices, when the device is
-	unplugged. The <methodname>firstopen</methodname> and
+	Similarly the <methodname>lastclose</methodname> method is called when
+	the last application holding a file handle opened on the device closes
+	it, for both UMS and KMS drivers. Additionally, the method is also
+	called at module unload time or, for hot-pluggable devices, when the
+	device is unplugged. The <methodname>firstopen</methodname> and
 	<methodname>lastclose</methodname> calls can thus be unbalanced.
       </para>
       <para>
@@ -2462,7 +2462,12 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
       <para>
         The <methodname>lastclose</methodname> method should restore CRTC and
 	plane properties to default value, so that a subsequent open of the
-	device will not inherit state from the previous user.
+	device will not inherit state from the previous user. It can also be
+	used to execute delayed power switching state changes, e.g. in
+	conjunction with the vga-switcheroo infrastructure. Beyond that KMS
+	drivers should not do any further cleanup. Only legacy UMS drivers might
+	need to clean up device state so that the vga console or an independent
+	fbdev driver could take over.
       </para>
     </sect2>
     <sect2>
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 57e3014..fcde7d4 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
 	int i;
 	int ret;
 
-	if (dev->driver->firstopen) {
+	if (dev->driver->firstopen &&
+	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = dev->driver->firstopen(dev);
 		if (ret != 0)
 			return ret;
-- 
1.8.3.2

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

* [PATCH] drm: don't call ->firstopen for KMS drivers
  2013-07-11 10:19       ` Daniel Vetter
  2013-07-13 14:43         ` Daniel Vetter
@ 2013-07-13 14:45         ` Daniel Vetter
  2013-07-22  9:02           ` Laurent Pinchart
  1 sibling, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-13 14:45 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Laurent Pinchart

It has way too much potential for driver writers to do stupid things
like delayed hw setup because the load sequence is somehow racy (e.g.
the imx driver in staging). So don't call it for modesetting drivers,
which reduces the complexity of the drm core -> driver interface a
notch.

v2: Don't forget to update DocBook.

v3: Go with Laurent's slightly more elaborate proposal for the DocBook
update. Add a few words on top of his diff to elaborate a bit on what
KMS drivers should and shouldn't do in lastclose. There was already a
paragraph present talking about restoring properties, I've simply
extended that one.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 Documentation/DocBook/drm.tmpl | 27 ++++++++++++++++-----------
 drivers/gpu/drm/drm_fops.c     |  3 ++-
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4d54ac8..52d5eda 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
       </abstract>
       <para>
         The <methodname>firstopen</methodname> method is called by the DRM core
-	when an application opens a device that has no other opened file handle.
-	Similarly the <methodname>lastclose</methodname> method is called when
-	the last application holding a file handle opened on the device closes
-	it. Both methods are mostly used for UMS (User Mode Setting) drivers to
-	acquire and release device resources which should be done in the
-	<methodname>load</methodname> and <methodname>unload</methodname>
-	methods for KMS drivers.
+	for legacy UMS (User Mode Setting) drivers only when an application
+	opens a device that has no other opened file handle. UMS drivers can
+	implement it to acquire device resources. KMS drivers can't use the
+	method and must acquire resources in the <methodname>load</methodname>
+	method instead.
       </para>
       <para>
-        Note that the <methodname>lastclose</methodname> method is also called
-	at module unload time or, for hot-pluggable devices, when the device is
-	unplugged. The <methodname>firstopen</methodname> and
+	Similarly the <methodname>lastclose</methodname> method is called when
+	the last application holding a file handle opened on the device closes
+	it, for both UMS and KMS drivers. Additionally, the method is also
+	called at module unload time or, for hot-pluggable devices, when the
+	device is unplugged. The <methodname>firstopen</methodname> and
 	<methodname>lastclose</methodname> calls can thus be unbalanced.
       </para>
       <para>
@@ -2462,7 +2462,12 @@ void (*postclose) (struct drm_device *, struct drm_file *);</synopsis>
       <para>
         The <methodname>lastclose</methodname> method should restore CRTC and
 	plane properties to default value, so that a subsequent open of the
-	device will not inherit state from the previous user.
+	device will not inherit state from the previous user. It can also be
+	used to execute delayed power switching state changes, e.g. in
+	conjunction with the vga-switcheroo infrastructure. Beyond that KMS
+	drivers should not do any further cleanup. Only legacy UMS drivers might
+	need to clean up device state so that the vga console or an independent
+	fbdev driver could take over.
       </para>
     </sect2>
     <sect2>
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 57e3014..fcde7d4 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
 	int i;
 	int ret;
 
-	if (dev->driver->firstopen) {
+	if (dev->driver->firstopen &&
+	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
 		ret = dev->driver->firstopen(dev);
 		if (ret != 0)
 			return ret;
-- 
1.8.3.2

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

* Re: [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl
  2013-07-10 12:12 ` [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
@ 2013-07-16 12:33   ` Daniel Vetter
  2013-07-16 13:14     ` [PATCH] " Daniel Vetter
  0 siblings, 1 reply; 71+ messages in thread
From: Daniel Vetter @ 2013-07-16 12:33 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

On Wed, Jul 10, 2013 at 02:12:10PM +0200, Daniel Vetter wrote:
> We not only have debugfs files to do pretty much the equivalent of
> lsof, we also have an ioctl. Not that compared to lsof this dumps a
> wee bit more information, but we can still get at that from debugfs
> easily.
> 
> I've dug around in mesa, libdrm and ddx histories and the only users
> seem to be drm/tests/dristat.c and drm/tests/getclients.c. The later
> is a testcase for the ioctl itself since up to
> 
> commit b018fcdaa5e8b4eabb8cffda687d00004a3c4785
> Author: Eric Anholt <eric@anholt.net>
> Date:   Thu Nov 22 18:46:54 2007 +1000
> 
>     drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx
> 
> there was actually no way at all for userspace to enumerate all
> clients since the kernel just wouldn't tell it when to stop. Which
> completely broke it's only user, dristat -c.
> 
> So obviously that ioctl wasn't much use for debugging. Hence I don't
> see any point in keeping support for a tool which was pretty obviously
> never really used, and while we have good replacements in the form of
> equivalent debugfs files.
> 
> Still, to keep dristat -c from looping forever again stop it early by
> returning an unconditional -EINVAL. Also add a comment in the code
> about why.
> 
> Cc: Eric Anholt <eric@anholt.net>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

libva for the rescue (or not)! Thanks to a patch floating by on libva I've
noticed that libva's dri loader used the GET_CLIENT ioctl to

*drumroll*

check whether it's authenticated. I can't even grasp that part, but in any
case this patch here just died in it's current form :(

I'll figure out whether there's some fun way to keep the hollowed-out
ioclt without breaking existing userspace, but probably not worth the
fuzz.
-Daniel

> ---
>  drivers/gpu/drm/drm_ioctl.c | 27 ++++-----------------------
>  1 file changed, 4 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 0acf080..5159fa0 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -216,29 +216,10 @@ int drm_getmap(struct drm_device *dev, void *data,
>  int drm_getclient(struct drm_device *dev, void *data,
>  		  struct drm_file *file_priv)
>  {
> -	struct drm_client *client = data;
> -	struct drm_file *pt;
> -	int idx;
> -	int i;
> -
> -	idx = client->idx;
> -	i = 0;
> -
> -	mutex_lock(&dev->struct_mutex);
> -	list_for_each_entry(pt, &dev->filelist, lhead) {
> -		if (i++ >= idx) {
> -			client->auth = pt->authenticated;
> -			client->pid = pid_vnr(pt->pid);
> -			client->uid = from_kuid_munged(current_user_ns(), pt->uid);
> -			client->magic = pt->magic;
> -			client->iocs = pt->ioctl_count;
> -			mutex_unlock(&dev->struct_mutex);
> -
> -			return 0;
> -		}
> -	}
> -	mutex_unlock(&dev->struct_mutex);
> -
> +	/* Hollowed-out getclient ioctl to keep some dead old drm tests/tools
> +	 * not breaking completely. Userspace tools stop enumerating one they
> +	 * get -EINVAL, hence this is the return value we need to hand back for
> +	 * no clients tracked. */
>  	return -EINVAL;
>  }
>  
> -- 
> 1.8.3.2
> 

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

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

* [PATCH] drm: hollow-out GET_CLIENT ioctl
  2013-07-16 12:33   ` Daniel Vetter
@ 2013-07-16 13:14     ` Daniel Vetter
  2013-07-16 13:30       ` Chris Wilson
  2013-07-17 13:52       ` David Herrmann
  0 siblings, 2 replies; 71+ messages in thread
From: Daniel Vetter @ 2013-07-16 13:14 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, Gwenole Beauchesne

We not only have debugfs files to do pretty much the equivalent of
lsof, we also have an ioctl. Not that compared to lsof this dumps a
wee bit more information, but we can still get at that from debugfs
easily.

I've dug around in mesa, libdrm and ddx histories and the only users
seem to be drm/tests/dristat.c and drm/tests/getclients.c. The later
is a testcase for the ioctl itself since up to

commit b018fcdaa5e8b4eabb8cffda687d00004a3c4785
Author: Eric Anholt <eric@anholt.net>
Date:   Thu Nov 22 18:46:54 2007 +1000

    drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx

there was actually no way at all for userspace to enumerate all
clients since the kernel just wouldn't tell it when to stop. Which
completely broke it's only user, dristat -c.

So obviously that ioctl wasn't much use for debugging. Hence I don't
see any point in keeping support for a tool which was pretty obviously
never really used, and while we have good replacements in the form of
equivalent debugfs files.

Still, to keep dristat -c from looping forever again stop it early by
returning an unconditional -EINVAL. Also add a comment in the code
about why.

v2: Slightly less hollowed-out implementation. libva uses GET_CLIENTS
to figure out whether the fd it has is already authenticated or not.
So we need to keep that part of things working. Simplest way is to
just return one entry to keep va_drm_is_authenticated in
libva/va/drm/va_drm_auth.c working.

Cc: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_ioctl.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 0acf080..ac8ca5c 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -217,29 +217,30 @@ int drm_getclient(struct drm_device *dev, void *data,
 		  struct drm_file *file_priv)
 {
 	struct drm_client *client = data;
-	struct drm_file *pt;
-	int idx;
-	int i;
-
-	idx = client->idx;
-	i = 0;
 
-	mutex_lock(&dev->struct_mutex);
-	list_for_each_entry(pt, &dev->filelist, lhead) {
-		if (i++ >= idx) {
-			client->auth = pt->authenticated;
-			client->pid = pid_vnr(pt->pid);
-			client->uid = from_kuid_munged(current_user_ns(), pt->uid);
-			client->magic = pt->magic;
-			client->iocs = pt->ioctl_count;
-			mutex_unlock(&dev->struct_mutex);
-
-			return 0;
-		}
+	/*
+	 * Hollowed-out getclient ioctl to keep some dead old drm tests/tools
+	 * not breaking completely. Userspace tools stop enumerating one they
+	 * get -EINVAL, hence this is the return value we need to hand back for
+	 * no clients tracked.
+	 *
+	 * Unfortunately some clients (*cough* libva *cough*) use this in a fun
+	 * attempt to figure out whether they're authenticated or not. Since
+	 * that's the only thing they care about, give it to the directly
+	 * instead of walking one giant list.
+	 */
+	if (client->idx == 0) {
+		client->auth = file_priv->authenticated;
+		client->pid = pid_vnr(file_priv->pid);
+		client->uid = from_kuid_munged(current_user_ns(),
+					       file_priv->uid);
+		client->magic = 0;
+		client->iocs = 0;
+
+		return 0;
+	} else {
+		return -EINVAL;
 	}
-	mutex_unlock(&dev->struct_mutex);
-
-	return -EINVAL;
 }
 
 /**
-- 
1.8.3.2

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

* Re: [PATCH] drm: hollow-out GET_CLIENT ioctl
  2013-07-16 13:14     ` [PATCH] " Daniel Vetter
@ 2013-07-16 13:30       ` Chris Wilson
  2013-07-17 13:52       ` David Herrmann
  1 sibling, 0 replies; 71+ messages in thread
From: Chris Wilson @ 2013-07-16 13:30 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Gwenole Beauchesne, DRI Development

On Tue, Jul 16, 2013 at 03:14:15PM +0200, Daniel Vetter wrote:
> We not only have debugfs files to do pretty much the equivalent of
> lsof, we also have an ioctl. Not that compared to lsof this dumps a
> wee bit more information, but we can still get at that from debugfs
> easily.

Hmm, why are returning information about other clients to a non-root
user? Including the magic required to authorize oneself...

This ioctl has to be neutered.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

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

* Re: [PATCH] drm: hollow-out GET_CLIENT ioctl
  2013-07-16 13:14     ` [PATCH] " Daniel Vetter
  2013-07-16 13:30       ` Chris Wilson
@ 2013-07-17 13:52       ` David Herrmann
  1 sibling, 0 replies; 71+ messages in thread
From: David Herrmann @ 2013-07-17 13:52 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Gwenole Beauchesne, DRI Development

Hi

On Tue, Jul 16, 2013 at 3:14 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> We not only have debugfs files to do pretty much the equivalent of
> lsof, we also have an ioctl. Not that compared to lsof this dumps a
> wee bit more information, but we can still get at that from debugfs
> easily.
>
> I've dug around in mesa, libdrm and ddx histories and the only users
> seem to be drm/tests/dristat.c and drm/tests/getclients.c. The later
> is a testcase for the ioctl itself since up to
>
> commit b018fcdaa5e8b4eabb8cffda687d00004a3c4785
> Author: Eric Anholt <eric@anholt.net>
> Date:   Thu Nov 22 18:46:54 2007 +1000
>
>     drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx
>
> there was actually no way at all for userspace to enumerate all
> clients since the kernel just wouldn't tell it when to stop. Which
> completely broke it's only user, dristat -c.
>
> So obviously that ioctl wasn't much use for debugging. Hence I don't
> see any point in keeping support for a tool which was pretty obviously
> never really used, and while we have good replacements in the form of
> equivalent debugfs files.
>
> Still, to keep dristat -c from looping forever again stop it early by
> returning an unconditional -EINVAL. Also add a comment in the code
> about why.
>
> v2: Slightly less hollowed-out implementation. libva uses GET_CLIENTS
> to figure out whether the fd it has is already authenticated or not.
> So we need to keep that part of things working. Simplest way is to
> just return one entry to keep va_drm_is_authenticated in
> libva/va/drm/va_drm_auth.c working.
>
> Cc: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Eric Anholt <eric@anholt.net>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_ioctl.c | 43 ++++++++++++++++++++++---------------------
>  1 file changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 0acf080..ac8ca5c 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -217,29 +217,30 @@ int drm_getclient(struct drm_device *dev, void *data,
>                   struct drm_file *file_priv)
>  {
>         struct drm_client *client = data;
> -       struct drm_file *pt;
> -       int idx;
> -       int i;
> -
> -       idx = client->idx;
> -       i = 0;
>
> -       mutex_lock(&dev->struct_mutex);
> -       list_for_each_entry(pt, &dev->filelist, lhead) {
> -               if (i++ >= idx) {
> -                       client->auth = pt->authenticated;
> -                       client->pid = pid_vnr(pt->pid);
> -                       client->uid = from_kuid_munged(current_user_ns(), pt->uid);
> -                       client->magic = pt->magic;
> -                       client->iocs = pt->ioctl_count;
> -                       mutex_unlock(&dev->struct_mutex);
> -
> -                       return 0;
> -               }
> +       /*
> +        * Hollowed-out getclient ioctl to keep some dead old drm tests/tools
> +        * not breaking completely. Userspace tools stop enumerating one they
> +        * get -EINVAL, hence this is the return value we need to hand back for
> +        * no clients tracked.
> +        *
> +        * Unfortunately some clients (*cough* libva *cough*) use this in a fun
> +        * attempt to figure out whether they're authenticated or not. Since
> +        * that's the only thing they care about, give it to the directly
> +        * instead of walking one giant list.
> +        */
> +       if (client->idx == 0) {
> +               client->auth = file_priv->authenticated;
> +               client->pid = pid_vnr(file_priv->pid);
> +               client->uid = from_kuid_munged(current_user_ns(),
> +                                              file_priv->uid);
> +               client->magic = 0;
> +               client->iocs = 0;

magic = 0 is the only thing that bugs me as "0" is an invalid
magic-number for drmAuth. I hope no-one uses it. But we can fix that
if we see any regression. I cannot imagine anyone really using it.

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

> +
> +               return 0;
> +       } else {
> +               return -EINVAL;
>         }
> -       mutex_unlock(&dev->struct_mutex);
> -
> -       return -EINVAL;
>  }
>
>  /**
> --
> 1.8.3.2
>

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

* Re: [PATCH] drm: don't call ->firstopen for KMS drivers
  2013-07-13 14:45         ` Daniel Vetter
@ 2013-07-22  9:02           ` Laurent Pinchart
  0 siblings, 0 replies; 71+ messages in thread
From: Laurent Pinchart @ 2013-07-22  9:02 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi Daniel,

Thank you for the patch.

On Saturday 13 July 2013 16:45:10 Daniel Vetter wrote:
> It has way too much potential for driver writers to do stupid things
> like delayed hw setup because the load sequence is somehow racy (e.g.
> the imx driver in staging). So don't call it for modesetting drivers,
> which reduces the complexity of the drm core -> driver interface a
> notch.
> 
> v2: Don't forget to update DocBook.
> 
> v3: Go with Laurent's slightly more elaborate proposal for the DocBook
> update. Add a few words on top of his diff to elaborate a bit on what
> KMS drivers should and shouldn't do in lastclose. There was already a
> paragraph present talking about restoring properties, I've simply
> extended that one.
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

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

> ---
>  Documentation/DocBook/drm.tmpl | 27 ++++++++++++++++-----------
>  drivers/gpu/drm/drm_fops.c     |  3 ++-
>  2 files changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 4d54ac8..52d5eda 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct
> drm_file *);</synopsis> </abstract>
>        <para>
>          The <methodname>firstopen</methodname> method is called by the DRM
> core -	when an application opens a device that has no other opened file
> handle. -	Similarly the <methodname>lastclose</methodname> method is 
called
> when -	the last application holding a file handle opened on the device
> closes -	it. Both methods are mostly used for UMS (User Mode Setting)
> drivers to -	acquire and release device resources which should be done in
> the -	<methodname>load</methodname> and <methodname>unload</methodname>
> -	methods for KMS drivers.
> +	for legacy UMS (User Mode Setting) drivers only when an application
> +	opens a device that has no other opened file handle. UMS drivers can
> +	implement it to acquire device resources. KMS drivers can't use the
> +	method and must acquire resources in the <methodname>load</methodname>
> +	method instead.
>        </para>
>        <para>
> -        Note that the <methodname>lastclose</methodname> method is also
> called -	at module unload time or, for hot-pluggable devices, when the
> device is -	unplugged. The <methodname>firstopen</methodname> and
> +	Similarly the <methodname>lastclose</methodname> method is called when
> +	the last application holding a file handle opened on the device closes
> +	it, for both UMS and KMS drivers. Additionally, the method is also
> +	called at module unload time or, for hot-pluggable devices, when the
> +	device is unplugged. The <methodname>firstopen</methodname> and
>  	<methodname>lastclose</methodname> calls can thus be unbalanced.
>        </para>
>        <para>
> @@ -2462,7 +2462,12 @@ void (*postclose) (struct drm_device *, struct
> drm_file *);</synopsis> <para>
>          The <methodname>lastclose</methodname> method should restore CRTC
> and plane properties to default value, so that a subsequent open of the
> -	device will not inherit state from the previous user.
> +	device will not inherit state from the previous user. It can also be
> +	used to execute delayed power switching state changes, e.g. in
> +	conjunction with the vga-switcheroo infrastructure. Beyond that KMS
> +	drivers should not do any further cleanup. Only legacy UMS drivers might
> +	need to clean up device state so that the vga console or an independent
> +	fbdev driver could take over.
>        </para>
>      </sect2>
>      <sect2>
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 57e3014..fcde7d4 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev)
>  	int i;
>  	int ret;
> 
> -	if (dev->driver->firstopen) {
> +	if (dev->driver->firstopen &&
> +	    !drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		ret = dev->driver->firstopen(dev);
>  		if (ret != 0)
>  			return ret;
-- 
Regards,

Laurent Pinchart

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

end of thread, other threads:[~2013-07-22  9:02 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-10 12:11 [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Daniel Vetter
2013-07-10 12:11 ` [PATCH 01/39] drm: remove drm_modctx ioctl and use drm_noop instead Daniel Vetter
2013-07-10 12:11 ` [PATCH 02/39] drm: kill dev->context_wait Daniel Vetter
2013-07-10 12:11 ` [PATCH 03/39] drm: remove dev->last_switch Daniel Vetter
2013-07-10 12:11 ` [PATCH 04/39] drm: kill dev->interrupt_flag and dev->dma_flag Daniel Vetter
2013-07-10 12:11 ` [PATCH 05/39] drm: kill dev->ctx_start and dev->lck_start Daniel Vetter
2013-07-10 12:11 ` [PATCH 06/39] drm/radoen: kill radeon_dma_ioctl_kms Daniel Vetter
2013-07-10 12:11 ` [PATCH 07/39] drm: kill dev->buf_readers and dev->buf_writers Daniel Vetter
2013-07-10 12:11 ` [PATCH 08/39] drm: remove redundant clears from drm_setup Daniel Vetter
2013-07-10 13:28   ` David Herrmann
2013-07-10 15:19     ` Daniel Vetter
2013-07-10 12:11 ` [PATCH 09/39] drm/omap: kill firstopen callback Daniel Vetter
2013-07-10 12:11 ` [PATCH 10/39] drm/radeon: kill firstopen callback for kms driver Daniel Vetter
2013-07-10 12:11 ` [PATCH 11/39] drm/imx: kill firstopen callback Daniel Vetter
2013-07-10 12:11 ` [PATCH 12/39] drm/vmwgfx: remove ->firstopen callback Daniel Vetter
2013-07-10 12:11 ` [PATCH 13/39] drm: don't call ->firstopen for KMS drivers Daniel Vetter
2013-07-10 18:17   ` [PATCH] " Daniel Vetter
2013-07-11  7:54     ` Laurent Pinchart
2013-07-11 10:19       ` Daniel Vetter
2013-07-13 14:43         ` Daniel Vetter
2013-07-13 14:45         ` Daniel Vetter
2013-07-22  9:02           ` Laurent Pinchart
2013-07-10 12:11 ` [PATCH 14/39] drm: kill dev->driver->set_version Daniel Vetter
2013-07-10 12:11 ` [PATCH 15/39] drm/radeon: remove DRIVER_HAS_DMA/SG/PCI_DMA from the kms driver Daniel Vetter
2013-07-10 12:11 ` [PATCH 16/39] drm: fold in drm_sg_alloc into the ioctl Daniel Vetter
2013-07-10 12:11 ` [PATCH 17/39] drm: hide legacy sg cleanup better from common code Daniel Vetter
2013-07-10 12:11 ` [PATCH 18/39] drm: disallow legacy sg ioctls for modesetting drivers Daniel Vetter
2013-07-10 12:11 ` [PATCH 19/39] drm: mark dma setup/teardown as legacy systems Daniel Vetter
2013-07-10 12:11 ` [PATCH 20/39] drm/nouveau: drop DRIVER_PCI_DMA and DRIVER_SG Daniel Vetter
2013-07-10 12:11 ` [PATCH 21/39] drm: disallow legacy dma ioctls for modesetting drivers Daniel Vetter
2013-07-10 12:11 ` [PATCH 22/39] drm: move drm_getsarea into drm_bufs.c Daniel Vetter
2013-07-10 12:11 ` [PATCH 23/39] drm/bufs: s/drm_order/order_base_2/ Daniel Vetter
2013-07-10 12:11 ` [PATCH 24/39] drm/r128: s/drm_order/order_base_2/ Daniel Vetter
2013-07-10 12:11 ` [PATCH 25/39] drm/radeon: s/drm_order/order_base_2/ Daniel Vetter
2013-07-10 12:12 ` [PATCH 26/39] drm: remove drm_order Daniel Vetter
2013-07-10 12:12 ` [PATCH 27/39] drm: mark context support as a legacy subsystem Daniel Vetter
2013-07-10 12:12 ` [PATCH 28/39] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent Daniel Vetter
2013-07-10 12:12 ` [PATCH 29/39] drm: remove FASYNC support Daniel Vetter
2013-07-10 14:57   ` [PATCH] " Daniel Vetter
2013-07-10 15:24     ` Daniel Vetter
2013-07-10 15:25     ` Daniel Vetter
2013-07-11  0:26       ` Laurent Pinchart
2013-07-10 12:12 ` [PATCH 30/39] drm: rip out DRIVER_FB_DMA and related code Daniel Vetter
2013-07-10 12:12 ` [PATCH 31/39] drm: rip out a few unused DRIVER flags Daniel Vetter
2013-07-10 12:12 ` [PATCH 32/39] drm: remove a bunch of unused #defines from drmP.h Daniel Vetter
2013-07-10 12:12 ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Daniel Vetter
2013-07-10 13:51   ` David Herrmann
2013-07-10 15:22     ` Daniel Vetter
2013-07-10 15:41       ` David Herrmann
2013-07-10 15:59         ` Daniel Vetter
2013-07-10 16:13           ` [PATCH 1/2] " Daniel Vetter
2013-07-10 16:13             ` [PATCH 2/2] drm/docs: rip out removed driver flags documentation Daniel Vetter
2013-07-10 16:27           ` [PATCH 33/39] drm: rip out drm_core_has_MTRR checks Andy Lutomirski
2013-07-10 16:41             ` Daniel Vetter
2013-07-10 12:12 ` [PATCH 34/39] drm: remove the dma_ioctl special-case Daniel Vetter
2013-07-10 14:34   ` David Herrmann
2013-07-10 14:59     ` [PATCH] " Daniel Vetter
2013-07-10 12:12 ` [PATCH 35/39] drm/memory: don't export agp helpers Daniel Vetter
2013-07-10 12:12 ` [PATCH 36/39] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
2013-07-16 12:33   ` Daniel Vetter
2013-07-16 13:14     ` [PATCH] " Daniel Vetter
2013-07-16 13:30       ` Chris Wilson
2013-07-17 13:52       ` David Herrmann
2013-07-10 12:12 ` [PATCH 37/39] drm: no-op out GET_STATS ioctl Daniel Vetter
2013-07-10 12:12 ` [PATCH 38/39] drm: fix locking in gem debugfs/procfs file Daniel Vetter
2013-07-10 12:12 ` [PATCH 39/39] drm: remove procfs code, take 2 Daniel Vetter
2013-07-10 20:44   ` [PATCH] " Daniel Vetter
2013-07-10 15:32 ` [PATCH 00/39] clean out drm cruft and hide it better for kms drivers David Herrmann
2013-07-10 15:51 ` [PATCH 1/2] drm: rip out dev->last_checked Daniel Vetter
2013-07-10 15:51   ` [PATCH 2/2] drm: move dev data clearing from drm_setup to lastclose Daniel Vetter
2013-07-11 14:09 ` [PATCH 00/39] clean out drm cruft and hide it better for kms drivers Alex Deucher

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.