dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/25] drm cruft removal
@ 2013-08-08 13:41 Daniel Vetter
  2013-08-08 13:41 ` [PATCH 01/25] drm/omap: kill firstopen callback Daniel Vetter
                   ` (24 more replies)
  0 siblings, 25 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter

Hi all,

So a bunch of patches went in already, and a few of the ones here small fixups
(DocBook, compile fail for funny .configs and 1 unused variable). And slight
rebasing on top of David's drm_dev cleanup refactoring. The big change is that
the get_client ioclt isn't a complete noop now but fakes enough of the old thing
so that libva will keep on working - libva uses the get_client ioctl to figure
out whether it's authenticated or not.

Of course I've dutifully taken that libva code and pressed it into an igt
testcase to make sure we don't break anything.

r-b tags and acks for individual patches I've added, but there's the overall
review from Alex and testing from David on the series:

Tested-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Comments and review highly welcome and please consider merging for drm-next.

Note that the patch "drm/imx: kill firstopen callback" is already merged into
the staging tree, but it's probably simplest if we merge it again through
drm-next.

Thanks, Daniel

Daniel Vetter (25):
  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: 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: disallow legacy dma ioctls for modesetting drivers
  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/docs: rip out removed driver flags documentation
  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
  drm: move dev data clearing from drm_setup to lastclose

 Documentation/DocBook/drm.tmpl           |  57 +++------
 drivers/gpu/drm/Makefile                 |   2 +-
 drivers/gpu/drm/ast/ast_drv.c            |   3 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c      |   3 +-
 drivers/gpu/drm/drm_bufs.c               | 201 +++++------------------------
 drivers/gpu/drm/drm_context.c            |  73 +++++++++--
 drivers/gpu/drm/drm_dma.c                |  17 ++-
 drivers/gpu/drm/drm_drv.c                |  51 ++++----
 drivers/gpu/drm/drm_fops.c               |  71 +----------
 drivers/gpu/drm/drm_info.c               |   4 +
 drivers/gpu/drm/drm_ioctl.c              |  59 ++++-----
 drivers/gpu/drm/drm_memory.c             |   2 -
 drivers/gpu/drm/drm_pci.c                |  14 +--
 drivers/gpu/drm/drm_proc.c               | 209 -------------------------------
 drivers/gpu/drm/drm_scatter.c            |  16 ++-
 drivers/gpu/drm/drm_stub.c               |  42 ++-----
 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          |   3 +-
 drivers/gpu/drm/i915/i915_drv.c          |   3 +-
 drivers/gpu/drm/mga/mga_drv.c            |   3 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c    |   3 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c    |   1 -
 drivers/gpu/drm/omapdrm/omap_drv.c       |   8 --
 drivers/gpu/drm/qxl/qxl_drv.c            |   1 -
 drivers/gpu/drm/r128/r128_drv.c          |   3 +-
 drivers/gpu/drm/radeon/radeon_drv.c      |   8 +-
 drivers/gpu/drm/radeon/radeon_kms.c      |  13 --
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |   1 -
 drivers/gpu/drm/savage/savage_drv.c      |   3 +-
 drivers/gpu/drm/shmobile/shmob_drm_drv.c |   1 -
 drivers/gpu/drm/sis/sis_drv.c            |   3 +-
 drivers/gpu/drm/tdfx/tdfx_drv.c          |   2 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   1 -
 drivers/gpu/drm/udl/udl_drv.c            |   1 -
 drivers/gpu/drm/via/via_drv.c            |   3 +-
 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   |  21 +---
 include/drm/drmP.h                       |  52 ++------
 42 files changed, 253 insertions(+), 734 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c

-- 
1.8.3.2

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

* [PATCH 01/25] drm/omap: kill firstopen callback
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 14:04   ` Rob Clark
  2013-08-08 13:41 ` [PATCH 02/25] drm/radeon: kill firstopen callback for kms driver Daniel Vetter
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 2f9e22e..47e64f9 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -524,12 +524,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
@@ -609,7 +603,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] 40+ messages in thread

* [PATCH 02/25] drm/radeon: kill firstopen callback for kms driver
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
  2013-08-08 13:41 ` [PATCH 01/25] drm/omap: kill firstopen callback Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 03/25] drm/imx: kill firstopen callback Daniel Vetter
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 fa7a7e1..3585f22 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,
@@ -390,7 +389,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 866c2b7..b46a561 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] 40+ messages in thread

* [PATCH 03/25] drm/imx: kill firstopen callback
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
  2013-08-08 13:41 ` [PATCH 01/25] drm/omap: kill firstopen callback Daniel Vetter
  2013-08-08 13:41 ` [PATCH 02/25] drm/radeon: kill firstopen callback for kms driver Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-12 22:23   ` Greg Kroah-Hartman
  2013-08-08 13:41 ` [PATCH 04/25] drm/vmwgfx: remove ->firstopen callback Daniel Vetter
                   ` (21 subsequent siblings)
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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>
---

Note that this is already in the staging tree but due to the follow-up cleanup
it's probably best to merge it again through drm-next.
-Daniel

 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 a890049..2c58533 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:
@@ -791,7 +782,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] 40+ messages in thread

* [PATCH 04/25] drm/vmwgfx: remove ->firstopen callback
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (2 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 03/25] drm/imx: kill firstopen callback Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 05/25] drm: don't call ->firstopen for KMS drivers Daniel Vetter
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 5086150..cebd847 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] 40+ messages in thread

* [PATCH 05/25] drm: don't call ->firstopen for KMS drivers
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (3 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 04/25] drm/vmwgfx: remove ->firstopen callback Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 06/25] drm: kill dev->driver->set_version Daniel Vetter
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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>
Acked-by: 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 87e22ec..c62d2d4 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2428,18 +2428,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>
@@ -2468,7 +2468,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 72acae9..10bf4f6 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] 40+ messages in thread

* [PATCH 06/25] drm: kill dev->driver->set_version
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (4 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 05/25] drm: don't call ->firstopen for KMS drivers Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 14:10   ` Rob Clark
  2013-08-08 13:41 ` [PATCH 07/25] drm: hide legacy sg cleanup better from common code Daniel Vetter
                   ` (18 subsequent siblings)
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 fba5473..7495fb2 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] 40+ messages in thread

* [PATCH 07/25] drm: hide legacy sg cleanup better from common code
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (5 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 06/25] drm: kill dev->driver->set_version Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 08/25] drm: disallow legacy sg ioctls for modesetting drivers Daniel Vetter
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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     |  6 +-----
 drivers/gpu/drm/drm_scatter.c | 10 +++++++++-
 include/drm/drmP.h            |  2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index dddd799..743b24d 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -197,11 +197,7 @@ int drm_lastclose(struct drm_device * dev)
 
 	drm_agp_clear(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;
-	}
+	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 7495fb2..bc38f99 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1567,7 +1567,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] 40+ messages in thread

* [PATCH 08/25] drm: disallow legacy sg ioctls for modesetting drivers
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (6 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 07/25] drm: hide legacy sg cleanup better from common code Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 09/25] drm: mark dma setup/teardown as legacy systems Daniel Vetter
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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] 40+ messages in thread

* [PATCH 09/25] drm: mark dma setup/teardown as legacy systems
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (7 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 08/25] drm: disallow legacy sg ioctls for modesetting drivers Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 10/25] drm: disallow legacy dma ioctls for modesetting drivers Daniel Vetter
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 743b24d..5b949a7 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -205,9 +205,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 10bf4f6..702e2a8 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 bc38f99..de19e97 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1394,8 +1394,8 @@ extern int drm_mapbufs(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
 				/* 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] 40+ messages in thread

* [PATCH 10/25] drm: disallow legacy dma ioctls for modesetting drivers
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (8 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 09/25] drm: mark dma setup/teardown as legacy systems Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 11/25] drm: mark context support as a legacy subsystem Daniel Vetter
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 bef4abf..cccc25f 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] 40+ messages in thread

* [PATCH 11/25] drm: mark context support as a legacy subsystem
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (9 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 10/25] drm: disallow legacy dma ioctls for modesetting drivers Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 12/25] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent Daniel Vetter
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 702e2a8..dd47fef 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -475,26 +475,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 d663f7d..aa0664d 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);
@@ -463,7 +457,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 de19e97..d05beac 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1333,9 +1333,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] 40+ messages in thread

* [PATCH 12/25] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (10 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 11/25] drm: mark context support as a legacy subsystem Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 13/25] drm: remove FASYNC support Daniel Vetter
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 cebd847..9c27d42 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] 40+ messages in thread

* [PATCH 13/25] drm: remove FASYNC support
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (11 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 12/25] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-13 19:26   ` David Herrmann
  2013-08-08 13:41 ` [PATCH 14/25] drm: rip out DRIVER_FB_DMA and related code Daniel Vetter
                   ` (11 subsequent siblings)
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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 c62d2d4..d51d157 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2509,7 +2509,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 a144fb0..60f1ce3 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 d35d99c..dd9c908 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 dd47fef..5679971 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -74,8 +74,6 @@ static int drm_setup(struct drm_device * dev)
 	dev->last_context = 0;
 	dev->if_version = 0;
 
-	dev->buf_async = NULL;
-
 	DRM_DEBUG("\n");
 
 	/*
@@ -373,18 +371,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 d13c2fc..99b5293 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 eac755b..ab1892eb 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 13457e3e..9411a74 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -994,7 +994,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 bd91964..b570127 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 1faa75f..b29d04b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -673,7 +673,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 47e64f9..2603d90 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -592,7 +592,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 48f2dfd..514118a 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 3585f22..3e52331 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -266,7 +266,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,
@@ -375,7 +374,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 5069d9c..c9f7fbd 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 7f2ea1a..0155518 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 14801c2..116da19 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 bb0af58..7650dc0 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 9c27d42..0dcfa6b 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 b128b90..15684bf 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 2c58533..e826086 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 d05beac..a79dcb0 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1168,8 +1168,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 */
@@ -1276,7 +1274,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] 40+ messages in thread

* [PATCH 14/25] drm: rip out DRIVER_FB_DMA and related code
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (12 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 13/25] drm: remove FASYNC support Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 15/25] drm: rip out a few unused DRIVER flags Daniel Vetter
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 a79dcb0..81de427 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -149,7 +149,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] 40+ messages in thread

* [PATCH 15/25] drm: rip out a few unused DRIVER flags
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (13 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 14/25] drm: rip out DRIVER_FB_DMA and related code Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 16/25] drm: remove a bunch of unused #defines from drmP.h Daniel Vetter
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 99b5293..1383e75 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 81de427..f526a7a9 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -147,9 +147,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] 40+ messages in thread

* [PATCH 16/25] drm: remove a bunch of unused #defines from drmP.h
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (14 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 15/25] drm: rip out a few unused DRIVER flags Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 17/25] drm: rip out drm_core_has_MTRR checks Daniel Vetter
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 f526a7a9..914055e 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -165,13 +165,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
 
 /*@}*/
@@ -260,9 +254,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] 40+ messages in thread

* [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (15 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 16/25] drm: remove a bunch of unused #defines from drmP.h Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-09 18:12   ` Andy Lutomirski
  2013-08-15 12:44   ` David Herrmann
  2013-08-08 13:41 ` [PATCH 18/25] drm/docs: rip out removed driver flags documentation Daniel Vetter
                   ` (7 subsequent siblings)
  24 siblings, 2 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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

v3: Rebase on top of David Herrmann's agp setup/cleanup changes.

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             | 14 ++++++--------
 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 -----------
 16 files changed, 24 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 60f1ce3..32e270d 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 dd9c908..138364d 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 0f54ad8..3fca2db 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -272,12 +272,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;
@@ -286,8 +285,7 @@ static int drm_pci_agp_init(struct drm_device *dev)
 static void drm_pci_agp_destroy(struct drm_device *dev)
 {
 	if (drm_core_has_AGP(dev) && dev->agp) {
-		if (drm_core_has_MTRR(dev))
-			arch_phys_wc_del(dev->agp->agp_mtrr);
+		arch_phys_wc_del(dev->agp->agp_mtrr);
 		drm_agp_clear(dev);
 		drm_agp_destroy(dev->agp);
 		dev->agp = NULL;
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 9411a74..eec47bd 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1006,7 +1006,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 b570127..fcce7b2 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 3e52331..1f93dd5 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -275,7 +275,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,
@@ -382,7 +382,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 914055e..5b9462d 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -76,7 +76,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;
 
@@ -141,7 +140,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
@@ -1219,15 +1217,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] 40+ messages in thread

* [PATCH 18/25] drm/docs: rip out removed driver flags documentation
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (16 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 17/25] drm: rip out drm_core_has_MTRR checks Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 19/25] drm: remove the dma_ioctl special-case Daniel Vetter
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 d51d157..4609cea 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] 40+ messages in thread

* [PATCH 19/25] drm: remove the dma_ioctl special-case
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (17 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 18/25] drm/docs: rip out removed driver flags documentation Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-13 18:05   ` David Herrmann
  2013-08-08 13:41 ` [PATCH 20/25] drm/memory: don't export agp helpers Daniel Vetter
                   ` (5 subsequent siblings)
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 5b949a7..83078cd 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),
 
@@ -395,9 +394,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 5b9462d..2a2a5b7 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1366,6 +1366,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] 40+ messages in thread

* [PATCH 20/25] drm/memory: don't export agp helpers
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (18 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 19/25] drm: remove the dma_ioctl special-case Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 21/25] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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] 40+ messages in thread

* [PATCH 21/25] drm: hollow-out GET_CLIENT ioctl
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (19 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 20/25] drm/memory: don't export agp helpers Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 22/25] drm: no-op out GET_STATS ioctl Daniel Vetter
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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.

This is exercised by igt/drm_get_client_auth which contains a
copypasta of the libva auth check code.

Cc: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
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] 40+ messages in thread

* [PATCH 22/25] drm: no-op out GET_STATS ioctl
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (20 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 21/25] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 15:55   ` Eric Anholt
  2013-08-08 13:41 ` [PATCH 23/25] drm: fix locking in gem debugfs/procfs file Daniel Vetter
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 ac8ca5c..cffc7c0 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -257,21 +257,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] 40+ messages in thread

* [PATCH 23/25] drm: fix locking in gem debugfs/procfs file
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (21 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 22/25] drm: no-op out GET_STATS ioctl Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 24/25] drm: remove procfs code, take 2 Daniel Vetter
  2013-08-08 13:41 ` [PATCH 25/25] drm: move dev data clearing from drm_setup to lastclose Daniel Vetter
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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] 40+ messages in thread

* [PATCH 24/25] drm: remove procfs code, take 2
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (22 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 23/25] drm: fix locking in gem debugfs/procfs file Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-08 13:41 ` [PATCH 25/25] drm: move dev data clearing from drm_setup to lastclose Daniel Vetter
  24 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter, kbuild test robot

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.

v3: fixup compilation warning for !CONFIG_DEBUG_FS, reported by
Fengguang Wu.

Cc: kbuild test robot <fengguang.wu@intel.com>
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 d943b94..55af865 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 83078cd..a845f31 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -237,13 +237,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");
@@ -266,7 +259,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 aa0664d..ea37c39 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,10 +363,11 @@ 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);
 err_mem:
+#endif
 	kfree(new_minor);
 err_idr:
 	idr_remove(&drm_minors_idr, minor_id);
@@ -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 2a2a5b7..46b3102 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;
@@ -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] 40+ messages in thread

* [PATCH 25/25] drm: move dev data clearing from drm_setup to lastclose
  2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
                   ` (23 preceding siblings ...)
  2013-08-08 13:41 ` [PATCH 24/25] drm: remove procfs code, take 2 Daniel Vetter
@ 2013-08-08 13:41 ` Daniel Vetter
  2013-08-13 18:12   ` David Herrmann
  24 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-08 13:41 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 a845f31..3b8d044 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.
@@ -209,6 +234,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] 40+ messages in thread

* Re: [PATCH 01/25] drm/omap: kill firstopen callback
  2013-08-08 13:41 ` [PATCH 01/25] drm/omap: kill firstopen callback Daniel Vetter
@ 2013-08-08 14:04   ` Rob Clark
  0 siblings, 0 replies; 40+ messages in thread
From: Rob Clark @ 2013-08-08 14:04 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Thu, Aug 8, 2013 at 9:41 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> KMS drivers really shouldn't need to do anything on firstopen, so kill
> empty callbacks.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

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

> ---
>  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 2f9e22e..47e64f9 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -524,12 +524,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
> @@ -609,7 +603,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
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 06/25] drm: kill dev->driver->set_version
  2013-08-08 13:41 ` [PATCH 06/25] drm: kill dev->driver->set_version Daniel Vetter
@ 2013-08-08 14:10   ` Rob Clark
  0 siblings, 0 replies; 40+ messages in thread
From: Rob Clark @ 2013-08-08 14:10 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Thu, Aug 8, 2013 at 9:41 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> 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>

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

> ---
>  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 fba5473..7495fb2 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
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 22/25] drm: no-op out GET_STATS ioctl
  2013-08-08 13:41 ` [PATCH 22/25] drm: no-op out GET_STATS ioctl Daniel Vetter
@ 2013-08-08 15:55   ` Eric Anholt
  2013-08-09  9:05     ` Daniel Vetter
  0 siblings, 1 reply; 40+ messages in thread
From: Eric Anholt @ 2013-08-08 15:55 UTC (permalink / raw)
  To: DRI Development; +Cc: Daniel Vetter


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

Daniel Vetter <daniel.vetter@ffwll.ch> writes:

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

I'm happy to see these two die.  Even back in the day we didn't use
them.

This has been quite a trip down memory lane.

Patch 9 typo: s/functinal/functional/
Patch 25 typo: s/loose/lose/

Patches 2, 6-11, 19, 21, 22, 24, 25 are:

Reviewed-by: Eric Anholt <eric@anholt.net>

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

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

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

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

* Re: [PATCH 22/25] drm: no-op out GET_STATS ioctl
  2013-08-08 15:55   ` Eric Anholt
@ 2013-08-09  9:05     ` Daniel Vetter
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel Vetter @ 2013-08-09  9:05 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Daniel Vetter, DRI Development

On Thu, Aug 08, 2013 at 05:55:45PM +0200, Eric Anholt wrote:
> Daniel Vetter <daniel.vetter@ffwll.ch> writes:
> 
> > 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.
> 
> I'm happy to see these two die.  Even back in the day we didn't use
> them.
> 
> This has been quite a trip down memory lane.
> 
> Patch 9 typo: s/functinal/functional/
> Patch 25 typo: s/loose/lose/

Fixed.

> Patches 2, 6-11, 19, 21, 22, 24, 25 are:
> 
> Reviewed-by: Eric Anholt <eric@anholt.net>

Thanks for the review. I've pushed a fixed branch with r-b tags to

http://cgit.freedesktop.org/~danvet/drm/log/?h=drm-cleanups

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

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

* Re: [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-08 13:41 ` [PATCH 17/25] drm: rip out drm_core_has_MTRR checks Daniel Vetter
@ 2013-08-09 18:12   ` Andy Lutomirski
  2013-08-09 18:36     ` Daniel Vetter
  2013-08-15 12:44   ` David Herrmann
  1 sibling, 1 reply; 40+ messages in thread
From: Andy Lutomirski @ 2013-08-09 18:12 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Thu, Aug 8, 2013 at 6:41 AM, 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.

If any of the new arch_phys_wc_add calls are reachable and if the
driver calls arch_phys_wc_add itself, then the lack of refcounting on
non-PAT systems may cause a problem.  (I don't understand the drm
stuff well enough to know whether that can actually happen.)

--Andy

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

* Re: [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-09 18:12   ` Andy Lutomirski
@ 2013-08-09 18:36     ` Daniel Vetter
  2013-08-09 18:39       ` Andy Lutomirski
  0 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-09 18:36 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: DRI Development

On Fri, Aug 9, 2013 at 8:12 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Thu, Aug 8, 2013 at 6:41 AM, 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.
>
> If any of the new arch_phys_wc_add calls are reachable and if the
> driver calls arch_phys_wc_add itself, then the lack of refcounting on
> non-PAT systems may cause a problem.  (I don't understand the drm
> stuff well enough to know whether that can actually happen.)

This is only about compile-time options really. Somehow drm had the
idea to use these check functions instead of #ifdef plus dummy static
inline noop functions. David Herrmann just did the same patch for the
agp stuff. So refcounting is of no concern here.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-09 18:36     ` Daniel Vetter
@ 2013-08-09 18:39       ` Andy Lutomirski
  2013-08-09 18:47         ` Daniel Vetter
  0 siblings, 1 reply; 40+ messages in thread
From: Andy Lutomirski @ 2013-08-09 18:39 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Fri, Aug 9, 2013 at 11:36 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> On Fri, Aug 9, 2013 at 8:12 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> On Thu, Aug 8, 2013 at 6:41 AM, 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.
>>
>> If any of the new arch_phys_wc_add calls are reachable and if the
>> driver calls arch_phys_wc_add itself, then the lack of refcounting on
>> non-PAT systems may cause a problem.  (I don't understand the drm
>> stuff well enough to know whether that can actually happen.)
>
> This is only about compile-time options really. Somehow drm had the
> idea to use these check functions instead of #ifdef plus dummy static
> inline noop functions. David Herrmann just did the same patch for the
> agp stuff. So refcounting is of no concern here.

I feel like I'm missing something obvious here.  On nouveau, prior to
this patch, the drm maps code would not touch mtrrs.  Now it will.
Nouveau already calls arch_phys_wc_add, so if that maps code is
reached on the same resource, then there could be refcounting issues.

--Andy

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



-- 
Andy Lutomirski
AMA Capital Management, LLC

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

* Re: [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-09 18:39       ` Andy Lutomirski
@ 2013-08-09 18:47         ` Daniel Vetter
  2013-08-09 18:48           ` Andy Lutomirski
  0 siblings, 1 reply; 40+ messages in thread
From: Daniel Vetter @ 2013-08-09 18:47 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: DRI Development

On Fri, Aug 9, 2013 at 8:39 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Fri, Aug 9, 2013 at 11:36 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>> On Fri, Aug 9, 2013 at 8:12 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>>> On Thu, Aug 8, 2013 at 6:41 AM, 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.
>>>
>>> If any of the new arch_phys_wc_add calls are reachable and if the
>>> driver calls arch_phys_wc_add itself, then the lack of refcounting on
>>> non-PAT systems may cause a problem.  (I don't understand the drm
>>> stuff well enough to know whether that can actually happen.)
>>
>> This is only about compile-time options really. Somehow drm had the
>> idea to use these check functions instead of #ifdef plus dummy static
>> inline noop functions. David Herrmann just did the same patch for the
>> agp stuff. So refcounting is of no concern here.
>
> I feel like I'm missing something obvious here.  On nouveau, prior to
> this patch, the drm maps code would not touch mtrrs.  Now it will.
> Nouveau already calls arch_phys_wc_add, so if that maps code is
> reached on the same resource, then there could be refcounting issues.

Oh that kind of confusion. The maps code here is for old userspace
drivers, I have some patches in the queue that will disable it
properly for kms drivers. So it should never happen that both the kms
driver and the maps code in the drm core set up a mtrr mapping. And if
it happens someone is doing something really nasty, and that hole will
soon be plugged.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-09 18:47         ` Daniel Vetter
@ 2013-08-09 18:48           ` Andy Lutomirski
  0 siblings, 0 replies; 40+ messages in thread
From: Andy Lutomirski @ 2013-08-09 18:48 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Fri, Aug 9, 2013 at 11:47 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> On Fri, Aug 9, 2013 at 8:39 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> On Fri, Aug 9, 2013 at 11:36 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>>> On Fri, Aug 9, 2013 at 8:12 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>>>> On Thu, Aug 8, 2013 at 6:41 AM, 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.
>>>>
>>>> If any of the new arch_phys_wc_add calls are reachable and if the
>>>> driver calls arch_phys_wc_add itself, then the lack of refcounting on
>>>> non-PAT systems may cause a problem.  (I don't understand the drm
>>>> stuff well enough to know whether that can actually happen.)
>>>
>>> This is only about compile-time options really. Somehow drm had the
>>> idea to use these check functions instead of #ifdef plus dummy static
>>> inline noop functions. David Herrmann just did the same patch for the
>>> agp stuff. So refcounting is of no concern here.
>>
>> I feel like I'm missing something obvious here.  On nouveau, prior to
>> this patch, the drm maps code would not touch mtrrs.  Now it will.
>> Nouveau already calls arch_phys_wc_add, so if that maps code is
>> reached on the same resource, then there could be refcounting issues.
>
> Oh that kind of confusion. The maps code here is for old userspace
> drivers, I have some patches in the queue that will disable it
> properly for kms drivers. So it should never happen that both the kms
> driver and the maps code in the drm core set up a mtrr mapping. And if
> it happens someone is doing something really nasty, and that hole will
> soon be plugged.

In that case, I'm convinced.  In case you care:

Acked-by: Andy Lutomirski <luto@amacapital.net>

--Andy

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



-- 
Andy Lutomirski
AMA Capital Management, LLC

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

* Re: [PATCH 03/25] drm/imx: kill firstopen callback
  2013-08-08 13:41 ` [PATCH 03/25] drm/imx: kill firstopen callback Daniel Vetter
@ 2013-08-12 22:23   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 40+ messages in thread
From: Greg Kroah-Hartman @ 2013-08-12 22:23 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

On Thu, Aug 08, 2013 at 03:41:13PM +0200, Daniel Vetter wrote:
> 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>
> ---
> 
> Note that this is already in the staging tree but due to the follow-up cleanup
> it's probably best to merge it again through drm-next.
> -Daniel

That's fine with me:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 19/25] drm: remove the dma_ioctl special-case
  2013-08-08 13:41 ` [PATCH 19/25] drm: remove the dma_ioctl special-case Daniel Vetter
@ 2013-08-13 18:05   ` David Herrmann
  0 siblings, 0 replies; 40+ messages in thread
From: David Herrmann @ 2013-08-13 18:05 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi

On Thu, Aug 8, 2013 at 3:41 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.
>
> 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>

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

Regards
David

> ---
>  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 5b949a7..83078cd 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),
>
> @@ -395,9 +394,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 5b9462d..2a2a5b7 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1366,6 +1366,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	[flat|nested] 40+ messages in thread

* Re: [PATCH 25/25] drm: move dev data clearing from drm_setup to lastclose
  2013-08-08 13:41 ` [PATCH 25/25] drm: move dev data clearing from drm_setup to lastclose Daniel Vetter
@ 2013-08-13 18:12   ` David Herrmann
  0 siblings, 0 replies; 40+ messages in thread
From: David Herrmann @ 2013-08-13 18:12 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development

Hi

On Thu, Aug 8, 2013 at 3:41 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> 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>

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

Regards
David

> ---
>  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 a845f31..3b8d044 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.
> @@ -209,6 +234,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	[flat|nested] 40+ messages in thread

* Re: [PATCH 13/25] drm: remove FASYNC support
  2013-08-08 13:41 ` [PATCH 13/25] drm: remove FASYNC support Daniel Vetter
@ 2013-08-13 19:26   ` David Herrmann
  0 siblings, 0 replies; 40+ messages in thread
From: David Herrmann @ 2013-08-13 19:26 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Laurent Pinchart, DRI Development

Hi

On Thu, Aug 8, 2013 at 3:41 PM, Daniel Vetter <daniel.vetter@ffwll.ch> 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>
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Looks good now. It reminds me that I should resend the O_NONBLOCK
implementation of drm_read() which would properly replace any SIGIO
uses...

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

Regards
David

> ---
>  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 c62d2d4..d51d157 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2509,7 +2509,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 a144fb0..60f1ce3 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 d35d99c..dd9c908 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 dd47fef..5679971 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -74,8 +74,6 @@ static int drm_setup(struct drm_device * dev)
>         dev->last_context = 0;
>         dev->if_version = 0;
>
> -       dev->buf_async = NULL;
> -
>         DRM_DEBUG("\n");
>
>         /*
> @@ -373,18 +371,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 d13c2fc..99b5293 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 eac755b..ab1892eb 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 13457e3e..9411a74 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -994,7 +994,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 bd91964..b570127 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 1faa75f..b29d04b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -673,7 +673,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 47e64f9..2603d90 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -592,7 +592,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 48f2dfd..514118a 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 3585f22..3e52331 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -266,7 +266,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,
> @@ -375,7 +374,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 5069d9c..c9f7fbd 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 7f2ea1a..0155518 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 14801c2..116da19 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 bb0af58..7650dc0 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 9c27d42..0dcfa6b 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 b128b90..15684bf 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 2c58533..e826086 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 d05beac..a79dcb0 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1168,8 +1168,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 */
> @@ -1276,7 +1274,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
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 17/25] drm: rip out drm_core_has_MTRR checks
  2013-08-08 13:41 ` [PATCH 17/25] drm: rip out drm_core_has_MTRR checks Daniel Vetter
  2013-08-09 18:12   ` Andy Lutomirski
@ 2013-08-15 12:44   ` David Herrmann
  1 sibling, 0 replies; 40+ messages in thread
From: David Herrmann @ 2013-08-15 12:44 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: DRI Development, Andy Lutomirski

Hi

On Thu, Aug 8, 2013 at 3:41 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.
>
> 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
>
> v3: Rebase on top of David Herrmann's agp setup/cleanup changes.
>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

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

Regards
David

> ---
>  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             | 14 ++++++--------
>  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 -----------
>  16 files changed, 24 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index 60f1ce3..32e270d 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 dd9c908..138364d 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 0f54ad8..3fca2db 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -272,12 +272,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;
> @@ -286,8 +285,7 @@ static int drm_pci_agp_init(struct drm_device *dev)
>  static void drm_pci_agp_destroy(struct drm_device *dev)
>  {
>         if (drm_core_has_AGP(dev) && dev->agp) {
> -               if (drm_core_has_MTRR(dev))
> -                       arch_phys_wc_del(dev->agp->agp_mtrr);
> +               arch_phys_wc_del(dev->agp->agp_mtrr);
>                 drm_agp_clear(dev);
>                 drm_agp_destroy(dev->agp);
>                 dev->agp = NULL;
> 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 9411a74..eec47bd 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1006,7 +1006,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 b570127..fcce7b2 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 3e52331..1f93dd5 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -275,7 +275,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,
> @@ -382,7 +382,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 914055e..5b9462d 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -76,7 +76,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;
>
> @@ -141,7 +140,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
> @@ -1219,15 +1217,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	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2013-08-15 12:44 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-08 13:41 [PATCH 00/25] drm cruft removal Daniel Vetter
2013-08-08 13:41 ` [PATCH 01/25] drm/omap: kill firstopen callback Daniel Vetter
2013-08-08 14:04   ` Rob Clark
2013-08-08 13:41 ` [PATCH 02/25] drm/radeon: kill firstopen callback for kms driver Daniel Vetter
2013-08-08 13:41 ` [PATCH 03/25] drm/imx: kill firstopen callback Daniel Vetter
2013-08-12 22:23   ` Greg Kroah-Hartman
2013-08-08 13:41 ` [PATCH 04/25] drm/vmwgfx: remove ->firstopen callback Daniel Vetter
2013-08-08 13:41 ` [PATCH 05/25] drm: don't call ->firstopen for KMS drivers Daniel Vetter
2013-08-08 13:41 ` [PATCH 06/25] drm: kill dev->driver->set_version Daniel Vetter
2013-08-08 14:10   ` Rob Clark
2013-08-08 13:41 ` [PATCH 07/25] drm: hide legacy sg cleanup better from common code Daniel Vetter
2013-08-08 13:41 ` [PATCH 08/25] drm: disallow legacy sg ioctls for modesetting drivers Daniel Vetter
2013-08-08 13:41 ` [PATCH 09/25] drm: mark dma setup/teardown as legacy systems Daniel Vetter
2013-08-08 13:41 ` [PATCH 10/25] drm: disallow legacy dma ioctls for modesetting drivers Daniel Vetter
2013-08-08 13:41 ` [PATCH 11/25] drm: mark context support as a legacy subsystem Daniel Vetter
2013-08-08 13:41 ` [PATCH 12/25] drm/vmwgfx: remove redundant clearing of driver->dma_quiescent Daniel Vetter
2013-08-08 13:41 ` [PATCH 13/25] drm: remove FASYNC support Daniel Vetter
2013-08-13 19:26   ` David Herrmann
2013-08-08 13:41 ` [PATCH 14/25] drm: rip out DRIVER_FB_DMA and related code Daniel Vetter
2013-08-08 13:41 ` [PATCH 15/25] drm: rip out a few unused DRIVER flags Daniel Vetter
2013-08-08 13:41 ` [PATCH 16/25] drm: remove a bunch of unused #defines from drmP.h Daniel Vetter
2013-08-08 13:41 ` [PATCH 17/25] drm: rip out drm_core_has_MTRR checks Daniel Vetter
2013-08-09 18:12   ` Andy Lutomirski
2013-08-09 18:36     ` Daniel Vetter
2013-08-09 18:39       ` Andy Lutomirski
2013-08-09 18:47         ` Daniel Vetter
2013-08-09 18:48           ` Andy Lutomirski
2013-08-15 12:44   ` David Herrmann
2013-08-08 13:41 ` [PATCH 18/25] drm/docs: rip out removed driver flags documentation Daniel Vetter
2013-08-08 13:41 ` [PATCH 19/25] drm: remove the dma_ioctl special-case Daniel Vetter
2013-08-13 18:05   ` David Herrmann
2013-08-08 13:41 ` [PATCH 20/25] drm/memory: don't export agp helpers Daniel Vetter
2013-08-08 13:41 ` [PATCH 21/25] drm: hollow-out GET_CLIENT ioctl Daniel Vetter
2013-08-08 13:41 ` [PATCH 22/25] drm: no-op out GET_STATS ioctl Daniel Vetter
2013-08-08 15:55   ` Eric Anholt
2013-08-09  9:05     ` Daniel Vetter
2013-08-08 13:41 ` [PATCH 23/25] drm: fix locking in gem debugfs/procfs file Daniel Vetter
2013-08-08 13:41 ` [PATCH 24/25] drm: remove procfs code, take 2 Daniel Vetter
2013-08-08 13:41 ` [PATCH 25/25] drm: move dev data clearing from drm_setup to lastclose Daniel Vetter
2013-08-13 18:12   ` David Herrmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).