All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/20] DRM: Core Cleanups
@ 2014-08-29 10:12 David Herrmann
  2014-08-29 10:12 ` [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/ David Herrmann
                   ` (20 more replies)
  0 siblings, 21 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Hi

More cleanups of DRM core code. Diffstat says:
 72 files changed, 832 insertions(+), 1038 deletions(-)

..which is already nice, but doesn't reflect that a lot of code is now hidden
from main headers. Furthermore, with this series applied, drmP.h no longer looks
as ugly as it is now (widly unstructured). It still ain't a beauty, though:
 include/drm/drmP.h                       | 236 ++++++++-----------------------

Anyhow, highlights:
 - drop "drm_memory.h"
 - drop "drm_usb.c"
 - drop "struct drm_waitlist"
 - drop "struct drm_sigdata"
 - drop "struct drm_bus"
 - drop "drm_master->unique_size"

Two patches are driver related:
 - radeon: Patch #1, moves drm_buffer.c to radeon/
 - nouveau: Patch #17, splits drm_driver for nouveau
They're rather trivial. Everything else is DRM-core.

I've moved some legacy stuff around so it's easier to drop it once unused. If
someone disagrees with move, let me know and I'll drop the patch.

I've pushed this to the 0-day testing bots now. I'll comment on the patches in
case something shows up.

Comments welcome!
David


David Herrmann (20):
  drm/radeon: move drm_buffer to drm/radeon/
  drm: mark drm_buf and drm_map as legacy
  drm: move "struct drm_vma_entry" to drm_vm.c
  drm: move "struct drm_magic_entry" to drm_auth.c
  drm: drop unused "struct drm_waitlist"
  drm: move AGP definitions harder
  drm: replace weird conditional includes
  drm: drop __KERNEL__ protection in drmP.h
  drm: merge drm_memory.h into drm_memory.c
  drm: move __OS_HAS_AGP into drm_agpsupport.h
  drm: order includes alphabetically in drmP.h
  drm: drop DRM_DEBUG_CODE
  drm: inline "struct drm_sigdata"
  drm: move remaining includes in drmP.h to the top
  drm: simplify drm_*_set_unique()
  drm: drop unused drm_master->unique_size
  drm: add driver->set_busid() callback
  drm: Goody bye, drm_bus!
  drm: merge drm_usb into udl
  drm: move drm-lock API to drm_legacy.h

 Documentation/DocBook/drm.tmpl           |   3 +-
 drivers/gpu/drm/Kconfig                  |   6 -
 drivers/gpu/drm/Makefile                 |   5 +-
 drivers/gpu/drm/armada/armada_drv.c      |   1 +
 drivers/gpu/drm/ast/ast_drv.c            |   1 +
 drivers/gpu/drm/bochs/bochs_drv.c        |   1 +
 drivers/gpu/drm/cirrus/cirrus_drv.c      |   1 +
 drivers/gpu/drm/drm_agpsupport.c         |   1 +
 drivers/gpu/drm/drm_auth.c               |   6 +
 drivers/gpu/drm/drm_buffer.c             | 181 ------------------------
 drivers/gpu/drm/drm_bufs.c               |  89 ++++++------
 drivers/gpu/drm/drm_debugfs.c            |   2 -
 drivers/gpu/drm/drm_drv.c                |  11 +-
 drivers/gpu/drm/drm_fops.c               |  16 +--
 drivers/gpu/drm/drm_info.c               |  59 --------
 drivers/gpu/drm/drm_ioctl.c              |  27 ++--
 drivers/gpu/drm/drm_legacy.h             |  39 +++++
 drivers/gpu/drm/drm_lock.c               |  35 ++---
 drivers/gpu/drm/drm_memory.c             |  12 ++
 drivers/gpu/drm/drm_pci.c                |  41 ++----
 drivers/gpu/drm/drm_platform.c           |  38 ++---
 drivers/gpu/drm/drm_usb.c                |  88 ------------
 drivers/gpu/drm/drm_vm.c                 |  74 ++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |   1 +
 drivers/gpu/drm/gma500/psb_drv.c         |   1 +
 drivers/gpu/drm/i810/i810_dma.c          |   4 +-
 drivers/gpu/drm/i810/i810_drv.c          |   1 +
 drivers/gpu/drm/i915/i915_dma.c          |   2 +-
 drivers/gpu/drm/i915/i915_drv.c          |   1 +
 drivers/gpu/drm/mga/mga_dma.c            |  49 +++----
 drivers/gpu/drm/mga/mga_drv.c            |   1 +
 drivers/gpu/drm/mgag200/mgag200_drv.c    |   1 +
 drivers/gpu/drm/msm/msm_drv.c            |   1 +
 drivers/gpu/drm/nouveau/nouveau_drm.c    |  19 ++-
 drivers/gpu/drm/omapdrm/omap_drv.c       |   1 +
 drivers/gpu/drm/qxl/qxl_drv.c            |   1 +
 drivers/gpu/drm/r128/r128_cce.c          |   2 +-
 drivers/gpu/drm/r128/r128_drv.c          |   1 +
 drivers/gpu/drm/radeon/Makefile          |   2 +-
 drivers/gpu/drm/radeon/drm_buffer.c      | 177 +++++++++++++++++++++++
 drivers/gpu/drm/radeon/drm_buffer.h      | 148 +++++++++++++++++++
 drivers/gpu/drm/radeon/r300_cmdbuf.c     |   2 +-
 drivers/gpu/drm/radeon/r600_cp.c         |   2 +-
 drivers/gpu/drm/radeon/radeon.h          |  17 ++-
 drivers/gpu/drm/radeon/radeon_cp.c       |  22 +--
 drivers/gpu/drm/radeon/radeon_drv.c      |   2 +
 drivers/gpu/drm/radeon/radeon_ring.c     |  21 ---
 drivers/gpu/drm/radeon/radeon_state.c    |   2 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c    |   1 +
 drivers/gpu/drm/savage/savage_bci.c      |  23 +--
 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/sis/sis_mm.c             |   6 +-
 drivers/gpu/drm/tdfx/tdfx_drv.c          |   1 +
 drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   1 +
 drivers/gpu/drm/udl/Kconfig              |   3 +-
 drivers/gpu/drm/udl/udl_connector.c      |   4 +-
 drivers/gpu/drm/udl/udl_drv.c            | 102 +++++++------
 drivers/gpu/drm/udl/udl_drv.h            |   1 +
 drivers/gpu/drm/udl/udl_main.c           |   8 +-
 drivers/gpu/drm/via/via_drv.c            |   1 +
 drivers/gpu/drm/via/via_map.c            |   2 +-
 drivers/gpu/drm/via/via_mm.c             |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |   1 +
 drivers/staging/imx-drm/imx-drm-core.c   |   1 +
 include/drm/drmP.h                       | 236 ++++++++-----------------------
 include/drm/drm_agpsupport.h             |  26 +++-
 include/drm/drm_buffer.h                 | 148 -------------------
 include/drm/drm_crtc.h                   |   4 +-
 include/drm/drm_memory.h                 |  59 --------
 include/drm/drm_usb.h                    |  15 --
 72 files changed, 832 insertions(+), 1038 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_buffer.c
 delete mode 100644 drivers/gpu/drm/drm_usb.c
 create mode 100644 drivers/gpu/drm/radeon/drm_buffer.c
 create mode 100644 drivers/gpu/drm/radeon/drm_buffer.h
 delete mode 100644 include/drm/drm_buffer.h
 delete mode 100644 include/drm/drm_memory.h
 delete mode 100644 include/drm/drm_usb.h

-- 
2.1.0

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

* [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:20   ` Thierry Reding
  2014-09-08  4:08   ` Alex Deucher
  2014-08-29 10:12 ` [PATCH 02/20] drm: mark drm_buf and drm_map as legacy David Herrmann
                   ` (19 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Radeon UMS is the last user of drm_buffer. Move it out of sight so radeon
can drop it together with UMS.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/Makefile              |   2 +-
 drivers/gpu/drm/drm_buffer.c          | 181 ----------------------------------
 drivers/gpu/drm/radeon/Makefile       |   2 +-
 drivers/gpu/drm/radeon/drm_buffer.c   | 177 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/drm_buffer.h   | 148 +++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/r300_cmdbuf.c  |   2 +-
 drivers/gpu/drm/radeon/radeon_state.c |   2 +-
 include/drm/drm_buffer.h              | 148 ---------------------------
 8 files changed, 329 insertions(+), 333 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_buffer.c
 create mode 100644 drivers/gpu/drm/radeon/drm_buffer.c
 create mode 100644 drivers/gpu/drm/radeon/drm_buffer.h
 delete mode 100644 include/drm/drm_buffer.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4a55d59..9b7cb3f 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -4,7 +4,7 @@
 
 ccflags-y := -Iinclude/drm
 
-drm-y       :=	drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
+drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_context.o drm_dma.o \
 		drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_drv.o drm_vm.o \
diff --git a/drivers/gpu/drm/drm_buffer.c b/drivers/gpu/drm/drm_buffer.c
deleted file mode 100644
index 86a4a4a..0000000
--- a/drivers/gpu/drm/drm_buffer.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Pauli Nieminen.
- * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS 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.
- *
- *
- **************************************************************************/
-/*
- * Multipart buffer for coping data which is larger than the page size.
- *
- * Authors:
- * Pauli Nieminen <suokkos-at-gmail-dot-com>
- */
-
-#include <linux/export.h>
-#include <drm/drm_buffer.h>
-
-/**
- * Allocate the drm buffer object.
- *
- *   buf: Pointer to a pointer where the object is stored.
- *   size: The number of bytes to allocate.
- */
-int drm_buffer_alloc(struct drm_buffer **buf, int size)
-{
-	int nr_pages = size / PAGE_SIZE + 1;
-	int idx;
-
-	/* Allocating pointer table to end of structure makes drm_buffer
-	 * variable sized */
-	*buf = kzalloc(sizeof(struct drm_buffer) + nr_pages*sizeof(char *),
-			GFP_KERNEL);
-
-	if (*buf == NULL) {
-		DRM_ERROR("Failed to allocate drm buffer object to hold"
-				" %d bytes in %d pages.\n",
-				size, nr_pages);
-		return -ENOMEM;
-	}
-
-	(*buf)->size = size;
-
-	for (idx = 0; idx < nr_pages; ++idx) {
-
-		(*buf)->data[idx] =
-			kmalloc(min(PAGE_SIZE, size - idx * PAGE_SIZE),
-				GFP_KERNEL);
-
-
-		if ((*buf)->data[idx] == NULL) {
-			DRM_ERROR("Failed to allocate %dth page for drm"
-					" buffer with %d bytes and %d pages.\n",
-					idx + 1, size, nr_pages);
-			goto error_out;
-		}
-
-	}
-
-	return 0;
-
-error_out:
-
-	for (; idx >= 0; --idx)
-		kfree((*buf)->data[idx]);
-
-	kfree(*buf);
-	return -ENOMEM;
-}
-EXPORT_SYMBOL(drm_buffer_alloc);
-
-/**
- * Copy the user data to the begin of the buffer and reset the processing
- * iterator.
- *
- *   user_data: A pointer the data that is copied to the buffer.
- *   size: The Number of bytes to copy.
- */
-int drm_buffer_copy_from_user(struct drm_buffer *buf,
-			      void __user *user_data, int size)
-{
-	int nr_pages = size / PAGE_SIZE + 1;
-	int idx;
-
-	if (size > buf->size) {
-		DRM_ERROR("Requesting to copy %d bytes to a drm buffer with"
-				" %d bytes space\n",
-				size, buf->size);
-		return -EFAULT;
-	}
-
-	for (idx = 0; idx < nr_pages; ++idx) {
-
-		if (copy_from_user(buf->data[idx],
-			user_data + idx * PAGE_SIZE,
-			min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
-			DRM_ERROR("Failed to copy user data (%p) to drm buffer"
-					" (%p) %dth page.\n",
-					user_data, buf, idx);
-			return -EFAULT;
-
-		}
-	}
-	buf->iterator = 0;
-	return 0;
-}
-EXPORT_SYMBOL(drm_buffer_copy_from_user);
-
-/**
- * Free the drm buffer object
- */
-void drm_buffer_free(struct drm_buffer *buf)
-{
-
-	if (buf != NULL) {
-
-		int nr_pages = buf->size / PAGE_SIZE + 1;
-		int idx;
-		for (idx = 0; idx < nr_pages; ++idx)
-			kfree(buf->data[idx]);
-
-		kfree(buf);
-	}
-}
-EXPORT_SYMBOL(drm_buffer_free);
-
-/**
- * Read an object from buffer that may be split to multiple parts. If object
- * is not split function just returns the pointer to object in buffer. But in
- * case of split object data is copied to given stack object that is suplied
- * by caller.
- *
- * The processing location of the buffer is also advanced to the next byte
- * after the object.
- *
- *   objsize: The size of the objet in bytes.
- *   stack_obj: A pointer to a memory location where object can be copied.
- */
-void *drm_buffer_read_object(struct drm_buffer *buf,
-		int objsize, void *stack_obj)
-{
-	int idx = drm_buffer_index(buf);
-	int page = drm_buffer_page(buf);
-	void *obj = NULL;
-
-	if (idx + objsize <= PAGE_SIZE) {
-		obj = &buf->data[page][idx];
-	} else {
-		/* The object is split which forces copy to temporary object.*/
-		int beginsz = PAGE_SIZE - idx;
-		memcpy(stack_obj, &buf->data[page][idx], beginsz);
-
-		memcpy(stack_obj + beginsz, &buf->data[page + 1][0],
-				objsize - beginsz);
-
-		obj = stack_obj;
-	}
-
-	drm_buffer_advance(buf, objsize);
-	return obj;
-}
-EXPORT_SYMBOL(drm_buffer_read_object);
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index 357f09a..7d7aed5 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -60,7 +60,7 @@ radeon-y := radeon_drv.o
 
 # add UMS driver
 radeon-$(CONFIG_DRM_RADEON_UMS)+= radeon_cp.o radeon_state.o radeon_mem.o \
-	radeon_irq.o r300_cmdbuf.o r600_cp.o r600_blit.o
+	radeon_irq.o r300_cmdbuf.o r600_cp.o r600_blit.o drm_buffer.o
 
 # add KMS driver
 radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
diff --git a/drivers/gpu/drm/radeon/drm_buffer.c b/drivers/gpu/drm/radeon/drm_buffer.c
new file mode 100644
index 0000000..f4e0f3a
--- /dev/null
+++ b/drivers/gpu/drm/radeon/drm_buffer.c
@@ -0,0 +1,177 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Pauli Nieminen.
+ * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS 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.
+ *
+ *
+ **************************************************************************/
+/*
+ * Multipart buffer for coping data which is larger than the page size.
+ *
+ * Authors:
+ * Pauli Nieminen <suokkos-at-gmail-dot-com>
+ */
+
+#include <linux/export.h>
+#include "drm_buffer.h"
+
+/**
+ * Allocate the drm buffer object.
+ *
+ *   buf: Pointer to a pointer where the object is stored.
+ *   size: The number of bytes to allocate.
+ */
+int drm_buffer_alloc(struct drm_buffer **buf, int size)
+{
+	int nr_pages = size / PAGE_SIZE + 1;
+	int idx;
+
+	/* Allocating pointer table to end of structure makes drm_buffer
+	 * variable sized */
+	*buf = kzalloc(sizeof(struct drm_buffer) + nr_pages*sizeof(char *),
+			GFP_KERNEL);
+
+	if (*buf == NULL) {
+		DRM_ERROR("Failed to allocate drm buffer object to hold"
+				" %d bytes in %d pages.\n",
+				size, nr_pages);
+		return -ENOMEM;
+	}
+
+	(*buf)->size = size;
+
+	for (idx = 0; idx < nr_pages; ++idx) {
+
+		(*buf)->data[idx] =
+			kmalloc(min(PAGE_SIZE, size - idx * PAGE_SIZE),
+				GFP_KERNEL);
+
+
+		if ((*buf)->data[idx] == NULL) {
+			DRM_ERROR("Failed to allocate %dth page for drm"
+					" buffer with %d bytes and %d pages.\n",
+					idx + 1, size, nr_pages);
+			goto error_out;
+		}
+
+	}
+
+	return 0;
+
+error_out:
+
+	for (; idx >= 0; --idx)
+		kfree((*buf)->data[idx]);
+
+	kfree(*buf);
+	return -ENOMEM;
+}
+
+/**
+ * Copy the user data to the begin of the buffer and reset the processing
+ * iterator.
+ *
+ *   user_data: A pointer the data that is copied to the buffer.
+ *   size: The Number of bytes to copy.
+ */
+int drm_buffer_copy_from_user(struct drm_buffer *buf,
+			      void __user *user_data, int size)
+{
+	int nr_pages = size / PAGE_SIZE + 1;
+	int idx;
+
+	if (size > buf->size) {
+		DRM_ERROR("Requesting to copy %d bytes to a drm buffer with"
+				" %d bytes space\n",
+				size, buf->size);
+		return -EFAULT;
+	}
+
+	for (idx = 0; idx < nr_pages; ++idx) {
+
+		if (copy_from_user(buf->data[idx],
+			user_data + idx * PAGE_SIZE,
+			min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
+			DRM_ERROR("Failed to copy user data (%p) to drm buffer"
+					" (%p) %dth page.\n",
+					user_data, buf, idx);
+			return -EFAULT;
+
+		}
+	}
+	buf->iterator = 0;
+	return 0;
+}
+
+/**
+ * Free the drm buffer object
+ */
+void drm_buffer_free(struct drm_buffer *buf)
+{
+
+	if (buf != NULL) {
+
+		int nr_pages = buf->size / PAGE_SIZE + 1;
+		int idx;
+		for (idx = 0; idx < nr_pages; ++idx)
+			kfree(buf->data[idx]);
+
+		kfree(buf);
+	}
+}
+
+/**
+ * Read an object from buffer that may be split to multiple parts. If object
+ * is not split function just returns the pointer to object in buffer. But in
+ * case of split object data is copied to given stack object that is suplied
+ * by caller.
+ *
+ * The processing location of the buffer is also advanced to the next byte
+ * after the object.
+ *
+ *   objsize: The size of the objet in bytes.
+ *   stack_obj: A pointer to a memory location where object can be copied.
+ */
+void *drm_buffer_read_object(struct drm_buffer *buf,
+		int objsize, void *stack_obj)
+{
+	int idx = drm_buffer_index(buf);
+	int page = drm_buffer_page(buf);
+	void *obj = NULL;
+
+	if (idx + objsize <= PAGE_SIZE) {
+		obj = &buf->data[page][idx];
+	} else {
+		/* The object is split which forces copy to temporary object.*/
+		int beginsz = PAGE_SIZE - idx;
+		memcpy(stack_obj, &buf->data[page][idx], beginsz);
+
+		memcpy(stack_obj + beginsz, &buf->data[page + 1][0],
+				objsize - beginsz);
+
+		obj = stack_obj;
+	}
+
+	drm_buffer_advance(buf, objsize);
+	return obj;
+}
diff --git a/drivers/gpu/drm/radeon/drm_buffer.h b/drivers/gpu/drm/radeon/drm_buffer.h
new file mode 100644
index 0000000..c80d3a3
--- /dev/null
+++ b/drivers/gpu/drm/radeon/drm_buffer.h
@@ -0,0 +1,148 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Pauli Nieminen.
+ * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS 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.
+ *
+ *
+ **************************************************************************/
+/*
+ * Multipart buffer for coping data which is larger than the page size.
+ *
+ * Authors:
+ * Pauli Nieminen <suokkos-at-gmail-dot-com>
+ */
+
+#ifndef _DRM_BUFFER_H_
+#define _DRM_BUFFER_H_
+
+#include <drm/drmP.h>
+
+struct drm_buffer {
+	int iterator;
+	int size;
+	char *data[];
+};
+
+
+/**
+ * Return the index of page that buffer is currently pointing at.
+ */
+static inline int drm_buffer_page(struct drm_buffer *buf)
+{
+	return buf->iterator / PAGE_SIZE;
+}
+/**
+ * Return the index of the current byte in the page
+ */
+static inline int drm_buffer_index(struct drm_buffer *buf)
+{
+	return buf->iterator & (PAGE_SIZE - 1);
+}
+/**
+ * Return number of bytes that is left to process
+ */
+static inline int drm_buffer_unprocessed(struct drm_buffer *buf)
+{
+	return buf->size - buf->iterator;
+}
+
+/**
+ * Advance the buffer iterator number of bytes that is given.
+ */
+static inline void drm_buffer_advance(struct drm_buffer *buf, int bytes)
+{
+	buf->iterator += bytes;
+}
+
+/**
+ * Allocate the drm buffer object.
+ *
+ *   buf: A pointer to a pointer where the object is stored.
+ *   size: The number of bytes to allocate.
+ */
+extern int drm_buffer_alloc(struct drm_buffer **buf, int size);
+
+/**
+ * Copy the user data to the begin of the buffer and reset the processing
+ * iterator.
+ *
+ *   user_data: A pointer the data that is copied to the buffer.
+ *   size: The Number of bytes to copy.
+ */
+extern int drm_buffer_copy_from_user(struct drm_buffer *buf,
+		void __user *user_data, int size);
+
+/**
+ * Free the drm buffer object
+ */
+extern void drm_buffer_free(struct drm_buffer *buf);
+
+/**
+ * Read an object from buffer that may be split to multiple parts. If object
+ * is not split function just returns the pointer to object in buffer. But in
+ * case of split object data is copied to given stack object that is suplied
+ * by caller.
+ *
+ * The processing location of the buffer is also advanced to the next byte
+ * after the object.
+ *
+ *   objsize: The size of the objet in bytes.
+ *   stack_obj: A pointer to a memory location where object can be copied.
+ */
+extern void *drm_buffer_read_object(struct drm_buffer *buf,
+		int objsize, void *stack_obj);
+
+/**
+ * Returns the pointer to the dword which is offset number of elements from the
+ * current processing location.
+ *
+ * Caller must make sure that dword is not split in the buffer. This
+ * requirement is easily met if all the sizes of objects in buffer are
+ * multiples of dword and PAGE_SIZE is multiple dword.
+ *
+ * Call to this function doesn't change the processing location.
+ *
+ *   offset: The index of the dword relative to the internat iterator.
+ */
+static inline void *drm_buffer_pointer_to_dword(struct drm_buffer *buffer,
+		int offset)
+{
+	int iter = buffer->iterator + offset * 4;
+	return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
+}
+/**
+ * Returns the pointer to the dword which is offset number of elements from
+ * the current processing location.
+ *
+ * Call to this function doesn't change the processing location.
+ *
+ *   offset: The index of the byte relative to the internat iterator.
+ */
+static inline void *drm_buffer_pointer_to_byte(struct drm_buffer *buffer,
+		int offset)
+{
+	int iter = buffer->iterator + offset;
+	return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
+}
+
+#endif
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
index 84b1d53..9418e38 100644
--- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
+++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
@@ -34,10 +34,10 @@
  */
 
 #include <drm/drmP.h>
-#include <drm/drm_buffer.h>
 #include <drm/radeon_drm.h>
 #include "radeon_drv.h"
 #include "r300_reg.h"
+#include "drm_buffer.h"
 
 #include <asm/unaligned.h>
 
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 23bb64f..535403e 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -30,9 +30,9 @@
  */
 
 #include <drm/drmP.h>
-#include <drm/drm_buffer.h>
 #include <drm/radeon_drm.h>
 #include "radeon_drv.h"
+#include "drm_buffer.h"
 
 /* ================================================================
  * Helper functions for client state checking and fixup
diff --git a/include/drm/drm_buffer.h b/include/drm/drm_buffer.h
deleted file mode 100644
index c80d3a3..0000000
--- a/include/drm/drm_buffer.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Pauli Nieminen.
- * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS 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.
- *
- *
- **************************************************************************/
-/*
- * Multipart buffer for coping data which is larger than the page size.
- *
- * Authors:
- * Pauli Nieminen <suokkos-at-gmail-dot-com>
- */
-
-#ifndef _DRM_BUFFER_H_
-#define _DRM_BUFFER_H_
-
-#include <drm/drmP.h>
-
-struct drm_buffer {
-	int iterator;
-	int size;
-	char *data[];
-};
-
-
-/**
- * Return the index of page that buffer is currently pointing at.
- */
-static inline int drm_buffer_page(struct drm_buffer *buf)
-{
-	return buf->iterator / PAGE_SIZE;
-}
-/**
- * Return the index of the current byte in the page
- */
-static inline int drm_buffer_index(struct drm_buffer *buf)
-{
-	return buf->iterator & (PAGE_SIZE - 1);
-}
-/**
- * Return number of bytes that is left to process
- */
-static inline int drm_buffer_unprocessed(struct drm_buffer *buf)
-{
-	return buf->size - buf->iterator;
-}
-
-/**
- * Advance the buffer iterator number of bytes that is given.
- */
-static inline void drm_buffer_advance(struct drm_buffer *buf, int bytes)
-{
-	buf->iterator += bytes;
-}
-
-/**
- * Allocate the drm buffer object.
- *
- *   buf: A pointer to a pointer where the object is stored.
- *   size: The number of bytes to allocate.
- */
-extern int drm_buffer_alloc(struct drm_buffer **buf, int size);
-
-/**
- * Copy the user data to the begin of the buffer and reset the processing
- * iterator.
- *
- *   user_data: A pointer the data that is copied to the buffer.
- *   size: The Number of bytes to copy.
- */
-extern int drm_buffer_copy_from_user(struct drm_buffer *buf,
-		void __user *user_data, int size);
-
-/**
- * Free the drm buffer object
- */
-extern void drm_buffer_free(struct drm_buffer *buf);
-
-/**
- * Read an object from buffer that may be split to multiple parts. If object
- * is not split function just returns the pointer to object in buffer. But in
- * case of split object data is copied to given stack object that is suplied
- * by caller.
- *
- * The processing location of the buffer is also advanced to the next byte
- * after the object.
- *
- *   objsize: The size of the objet in bytes.
- *   stack_obj: A pointer to a memory location where object can be copied.
- */
-extern void *drm_buffer_read_object(struct drm_buffer *buf,
-		int objsize, void *stack_obj);
-
-/**
- * Returns the pointer to the dword which is offset number of elements from the
- * current processing location.
- *
- * Caller must make sure that dword is not split in the buffer. This
- * requirement is easily met if all the sizes of objects in buffer are
- * multiples of dword and PAGE_SIZE is multiple dword.
- *
- * Call to this function doesn't change the processing location.
- *
- *   offset: The index of the dword relative to the internat iterator.
- */
-static inline void *drm_buffer_pointer_to_dword(struct drm_buffer *buffer,
-		int offset)
-{
-	int iter = buffer->iterator + offset * 4;
-	return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
-}
-/**
- * Returns the pointer to the dword which is offset number of elements from
- * the current processing location.
- *
- * Call to this function doesn't change the processing location.
- *
- *   offset: The index of the byte relative to the internat iterator.
- */
-static inline void *drm_buffer_pointer_to_byte(struct drm_buffer *buffer,
-		int offset)
-{
-	int iter = buffer->iterator + offset;
-	return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
-}
-
-#endif
-- 
2.1.0

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

* [PATCH 02/20] drm: mark drm_buf and drm_map as legacy
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
  2014-08-29 10:12 ` [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/ David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:32   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 03/20] drm: move "struct drm_vma_entry" to drm_vm.c David Herrmann
                   ` (18 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Move internal declarations to drm_legacy.h and add drm_legacy_*() prefix
to all legacy functions.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_bufs.c          | 89 ++++++++++++++++++-------------------
 drivers/gpu/drm/drm_drv.c           |  4 +-
 drivers/gpu/drm/drm_ioctl.c         | 16 +++----
 drivers/gpu/drm/drm_legacy.h        | 15 +++++++
 drivers/gpu/drm/i915/i915_dma.c     |  2 +-
 drivers/gpu/drm/mga/mga_dma.c       | 49 ++++++++++----------
 drivers/gpu/drm/r128/r128_cce.c     |  2 +-
 drivers/gpu/drm/radeon/r600_cp.c    |  2 +-
 drivers/gpu/drm/radeon/radeon_cp.c  | 22 ++++-----
 drivers/gpu/drm/savage/savage_bci.c | 19 ++++----
 drivers/gpu/drm/via/via_map.c       |  2 +-
 include/drm/drmP.h                  | 41 +++++------------
 12 files changed, 131 insertions(+), 132 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 61acb8f..6f05d74 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1,18 +1,13 @@
-/**
- * \file drm_bufs.c
- * Generic buffer template
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
 /*
- * Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
+ * Legacy: Generic DRM Buffer Management
  *
  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  * All Rights Reserved.
  *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Author: Gareth Hughes <gareth@valinux.com>
+ *
  * 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
@@ -39,6 +34,7 @@
 #include <linux/export.h>
 #include <asm/shmparam.h>
 #include <drm/drmP.h>
+#include "drm_legacy.h"
 
 static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
 						  struct drm_local_map *map)
@@ -365,9 +361,9 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
 	return 0;
 }
 
-int drm_addmap(struct drm_device * dev, resource_size_t offset,
-	       unsigned int size, enum drm_map_type type,
-	       enum drm_map_flags flags, struct drm_local_map ** map_ptr)
+int drm_legacy_addmap(struct drm_device * dev, resource_size_t offset,
+		      unsigned int size, enum drm_map_type type,
+		      enum drm_map_flags flags, struct drm_local_map **map_ptr)
 {
 	struct drm_map_list *list;
 	int rc;
@@ -378,7 +374,7 @@ int drm_addmap(struct drm_device * dev, resource_size_t offset,
 	return rc;
 }
 
-EXPORT_SYMBOL(drm_addmap);
+EXPORT_SYMBOL(drm_legacy_addmap);
 
 /**
  * Ioctl to specify a range of memory that is available for mapping by a
@@ -391,8 +387,8 @@ EXPORT_SYMBOL(drm_addmap);
  * \return zero on success or a negative value on error.
  *
  */
-int drm_addmap_ioctl(struct drm_device *dev, void *data,
-		     struct drm_file *file_priv)
+int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
+			    struct drm_file *file_priv)
 {
 	struct drm_map *map = data;
 	struct drm_map_list *maplist;
@@ -429,9 +425,9 @@ int drm_addmap_ioctl(struct drm_device *dev, void *data,
  * its being used, and free any associate resource (such as MTRR's) if it's not
  * being on use.
  *
- * \sa drm_addmap
+ * \sa drm_legacy_addmap
  */
-int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
+int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
 {
 	struct drm_map_list *r_list = NULL, *list_t;
 	drm_dma_handle_t dmah;
@@ -485,19 +481,19 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
 
 	return 0;
 }
-EXPORT_SYMBOL(drm_rmmap_locked);
+EXPORT_SYMBOL(drm_legacy_rmmap_locked);
 
-int drm_rmmap(struct drm_device *dev, struct drm_local_map *map)
+int drm_legacy_rmmap(struct drm_device *dev, struct drm_local_map *map)
 {
 	int ret;
 
 	mutex_lock(&dev->struct_mutex);
-	ret = drm_rmmap_locked(dev, map);
+	ret = drm_legacy_rmmap_locked(dev, map);
 	mutex_unlock(&dev->struct_mutex);
 
 	return ret;
 }
-EXPORT_SYMBOL(drm_rmmap);
+EXPORT_SYMBOL(drm_legacy_rmmap);
 
 /* The rmmap ioctl appears to be unnecessary.  All mappings are torn down on
  * the last close of the device, and this is necessary for cleanup when things
@@ -514,8 +510,8 @@ EXPORT_SYMBOL(drm_rmmap);
  * \param arg pointer to a struct drm_map structure.
  * \return zero on success or a negative value on error.
  */
-int drm_rmmap_ioctl(struct drm_device *dev, void *data,
-		    struct drm_file *file_priv)
+int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
+			   struct drm_file *file_priv)
 {
 	struct drm_map *request = data;
 	struct drm_local_map *map = NULL;
@@ -546,7 +542,7 @@ int drm_rmmap_ioctl(struct drm_device *dev, void *data,
 		return 0;
 	}
 
-	ret = drm_rmmap_locked(dev, map);
+	ret = drm_legacy_rmmap_locked(dev, map);
 
 	mutex_unlock(&dev->struct_mutex);
 
@@ -599,7 +595,8 @@ static void drm_cleanup_buf_error(struct drm_device * dev,
  * reallocates the buffer list of the same size order to accommodate the new
  * buffers.
  */
-int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
+int drm_legacy_addbufs_agp(struct drm_device *dev,
+			   struct drm_buf_desc *request)
 {
 	struct drm_device_dma *dma = dev->dma;
 	struct drm_buf_entry *entry;
@@ -759,10 +756,11 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
 	atomic_dec(&dev->buf_alloc);
 	return 0;
 }
-EXPORT_SYMBOL(drm_addbufs_agp);
+EXPORT_SYMBOL(drm_legacy_addbufs_agp);
 #endif				/* __OS_HAS_AGP */
 
-int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
+int drm_legacy_addbufs_pci(struct drm_device *dev,
+			   struct drm_buf_desc *request)
 {
 	struct drm_device_dma *dma = dev->dma;
 	int count;
@@ -964,9 +962,10 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
 	return 0;
 
 }
-EXPORT_SYMBOL(drm_addbufs_pci);
+EXPORT_SYMBOL(drm_legacy_addbufs_pci);
 
-static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request)
+static int drm_legacy_addbufs_sg(struct drm_device *dev,
+				 struct drm_buf_desc *request)
 {
 	struct drm_device_dma *dma = dev->dma;
 	struct drm_buf_entry *entry;
@@ -1135,8 +1134,8 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
  * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
  * PCI memory respectively.
  */
-int drm_addbufs(struct drm_device *dev, void *data,
-		struct drm_file *file_priv)
+int drm_legacy_addbufs(struct drm_device *dev, void *data,
+		       struct drm_file *file_priv)
 {
 	struct drm_buf_desc *request = data;
 	int ret;
@@ -1149,15 +1148,15 @@ int drm_addbufs(struct drm_device *dev, void *data,
 
 #if __OS_HAS_AGP
 	if (request->flags & _DRM_AGP_BUFFER)
-		ret = drm_addbufs_agp(dev, request);
+		ret = drm_legacy_addbufs_agp(dev, request);
 	else
 #endif
 	if (request->flags & _DRM_SG_BUFFER)
-		ret = drm_addbufs_sg(dev, request);
+		ret = drm_legacy_addbufs_sg(dev, request);
 	else if (request->flags & _DRM_FB_BUFFER)
 		ret = -EINVAL;
 	else
-		ret = drm_addbufs_pci(dev, request);
+		ret = drm_legacy_addbufs_pci(dev, request);
 
 	return ret;
 }
@@ -1179,8 +1178,8 @@ int drm_addbufs(struct drm_device *dev, void *data,
  * lock, preventing of allocating more buffers after this call. Information
  * about each requested buffer is then copied into user space.
  */
-int drm_infobufs(struct drm_device *dev, void *data,
-		 struct drm_file *file_priv)
+int drm_legacy_infobufs(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
 {
 	struct drm_device_dma *dma = dev->dma;
 	struct drm_buf_info *request = data;
@@ -1260,8 +1259,8 @@ int drm_infobufs(struct drm_device *dev, void *data,
  *
  * \note This ioctl is deprecated and mostly never used.
  */
-int drm_markbufs(struct drm_device *dev, void *data,
-		 struct drm_file *file_priv)
+int drm_legacy_markbufs(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
 {
 	struct drm_device_dma *dma = dev->dma;
 	struct drm_buf_desc *request = data;
@@ -1307,8 +1306,8 @@ int drm_markbufs(struct drm_device *dev, void *data,
  * Calls free_buffer() for each used buffer.
  * This function is primarily used for debugging.
  */
-int drm_freebufs(struct drm_device *dev, void *data,
-		 struct drm_file *file_priv)
+int drm_legacy_freebufs(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
 {
 	struct drm_device_dma *dma = dev->dma;
 	struct drm_buf_free *request = data;
@@ -1360,8 +1359,8 @@ int drm_freebufs(struct drm_device *dev, void *data,
  * offset equal to 0, which drm_mmap() interpretes as PCI buffers and calls
  * drm_mmap_dma().
  */
-int drm_mapbufs(struct drm_device *dev, void *data,
-	        struct drm_file *file_priv)
+int drm_legacy_mapbufs(struct drm_device *dev, void *data,
+		       struct drm_file *file_priv)
 {
 	struct drm_device_dma *dma = dev->dma;
 	int retcode = 0;
@@ -1448,7 +1447,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
 	return retcode;
 }
 
-int drm_dma_ioctl(struct drm_device *dev, void *data,
+int drm_legacy_dma_ioctl(struct drm_device *dev, void *data,
 		  struct drm_file *file_priv)
 {
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
@@ -1460,7 +1459,7 @@ int drm_dma_ioctl(struct drm_device *dev, void *data,
 		return -EINVAL;
 }
 
-struct drm_local_map *drm_getsarea(struct drm_device *dev)
+struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev)
 {
 	struct drm_map_list *entry;
 
@@ -1472,4 +1471,4 @@ struct drm_local_map *drm_getsarea(struct drm_device *dev)
 	}
 	return NULL;
 }
-EXPORT_SYMBOL(drm_getsarea);
+EXPORT_SYMBOL(drm_legacy_getsarea);
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 3242e20..b1587e2 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -143,7 +143,7 @@ static void drm_master_destroy(struct kref *kref)
 
 	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) {
 		if (r_list->master == master) {
-			drm_rmmap_locked(dev, r_list->map);
+			drm_legacy_rmmap_locked(dev, r_list->map);
 			r_list = NULL;
 		}
 	}
@@ -779,7 +779,7 @@ void drm_dev_unregister(struct drm_device *dev)
 	drm_vblank_cleanup(dev);
 
 	list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
-		drm_rmmap(dev, r_list->map);
+		drm_legacy_rmmap(dev, r_list->map);
 
 	drm_minor_unregister(dev, DRM_MINOR_LEGACY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 40be746..aa1ac79 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -62,8 +62,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_legacy_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_legacy_rmmap_ioctl, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_legacy_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_legacy_getsareactx, DRM_AUTH),
@@ -87,12 +87,12 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 
 	DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-	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),
-	DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma_ioctl, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_legacy_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_legacy_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+	DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_legacy_infobufs, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_legacy_mapbufs, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_legacy_freebufs, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_legacy_dma_ioctl, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index d34f20a..912fe81 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -48,4 +48,19 @@ int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
 
+/*
+ * Generic Buffer Management
+ */
+
+#define DRM_MAP_HASH_OFFSET 0x10000000
+
+int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
+
 #endif /* __DRM_LEGACY_H__ */
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index c965698..cefacac 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -196,7 +196,7 @@ static int i915_initialize(struct drm_device *dev, drm_i915_init_t *init)
 	struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
 	int ret;
 
-	master_priv->sarea = drm_getsarea(dev);
+	master_priv->sarea = drm_legacy_getsarea(dev);
 	if (master_priv->sarea) {
 		master_priv->sarea_priv = (drm_i915_sarea_t *)
 			((u8 *)master_priv->sarea->handle + init->sarea_priv_offset);
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index c3bf059..37d80c1 100644
--- a/drivers/gpu/drm/mga/mga_dma.c
+++ b/drivers/gpu/drm/mga/mga_dma.c
@@ -502,31 +502,31 @@ static int mga_do_agp_dma_bootstrap(struct drm_device *dev,
 		return err;
 	}
 
-	/* Make drm_addbufs happy by not trying to create a mapping for less
-	 * than a page.
+	/* Make drm_legacy_addbufs happy by not trying to create a mapping for
+	 * less than a page.
 	 */
 	if (warp_size < PAGE_SIZE)
 		warp_size = PAGE_SIZE;
 
 	offset = 0;
-	err = drm_addmap(dev, offset, warp_size,
-			 _DRM_AGP, _DRM_READ_ONLY, &dev_priv->warp);
+	err = drm_legacy_addmap(dev, offset, warp_size,
+				_DRM_AGP, _DRM_READ_ONLY, &dev_priv->warp);
 	if (err) {
 		DRM_ERROR("Unable to map WARP microcode: %d\n", err);
 		return err;
 	}
 
 	offset += warp_size;
-	err = drm_addmap(dev, offset, dma_bs->primary_size,
-			 _DRM_AGP, _DRM_READ_ONLY, &dev_priv->primary);
+	err = drm_legacy_addmap(dev, offset, dma_bs->primary_size,
+				_DRM_AGP, _DRM_READ_ONLY, &dev_priv->primary);
 	if (err) {
 		DRM_ERROR("Unable to map primary DMA region: %d\n", err);
 		return err;
 	}
 
 	offset += dma_bs->primary_size;
-	err = drm_addmap(dev, offset, secondary_size,
-			 _DRM_AGP, 0, &dev->agp_buffer_map);
+	err = drm_legacy_addmap(dev, offset, secondary_size,
+				_DRM_AGP, 0, &dev->agp_buffer_map);
 	if (err) {
 		DRM_ERROR("Unable to map secondary DMA region: %d\n", err);
 		return err;
@@ -538,7 +538,7 @@ static int mga_do_agp_dma_bootstrap(struct drm_device *dev,
 	req.flags = _DRM_AGP_BUFFER;
 	req.agp_start = offset;
 
-	err = drm_addbufs_agp(dev, &req);
+	err = drm_legacy_addbufs_agp(dev, &req);
 	if (err) {
 		DRM_ERROR("Unable to add secondary DMA buffers: %d\n", err);
 		return err;
@@ -559,8 +559,8 @@ static int mga_do_agp_dma_bootstrap(struct drm_device *dev,
 	}
 
 	offset += secondary_size;
-	err = drm_addmap(dev, offset, agp_size - offset,
-			 _DRM_AGP, 0, &dev_priv->agp_textures);
+	err = drm_legacy_addmap(dev, offset, agp_size - offset,
+				_DRM_AGP, 0, &dev_priv->agp_textures);
 	if (err) {
 		DRM_ERROR("Unable to map AGP texture region %d\n", err);
 		return err;
@@ -602,7 +602,7 @@ static int mga_do_agp_dma_bootstrap(struct drm_device *dev,
  *
  * \todo
  * Determine whether the maximum address passed to drm_pci_alloc is correct.
- * The same goes for drm_addbufs_pci.
+ * The same goes for drm_legacy_addbufs_pci.
  *
  * \sa mga_do_dma_bootstrap, mga_do_agp_dma_bootstrap
  */
@@ -622,15 +622,15 @@ static int mga_do_pci_dma_bootstrap(struct drm_device *dev,
 		return -EFAULT;
 	}
 
-	/* Make drm_addbufs happy by not trying to create a mapping for less
-	 * than a page.
+	/* Make drm_legacy_addbufs happy by not trying to create a mapping for
+	 * less than a page.
 	 */
 	if (warp_size < PAGE_SIZE)
 		warp_size = PAGE_SIZE;
 
 	/* The proper alignment is 0x100 for this mapping */
-	err = drm_addmap(dev, 0, warp_size, _DRM_CONSISTENT,
-			 _DRM_READ_ONLY, &dev_priv->warp);
+	err = drm_legacy_addmap(dev, 0, warp_size, _DRM_CONSISTENT,
+				_DRM_READ_ONLY, &dev_priv->warp);
 	if (err != 0) {
 		DRM_ERROR("Unable to create mapping for WARP microcode: %d\n",
 			  err);
@@ -645,8 +645,8 @@ static int mga_do_pci_dma_bootstrap(struct drm_device *dev,
 	for (primary_size = dma_bs->primary_size; primary_size != 0;
 	     primary_size >>= 1) {
 		/* The proper alignment for this mapping is 0x04 */
-		err = drm_addmap(dev, 0, primary_size, _DRM_CONSISTENT,
-				 _DRM_READ_ONLY, &dev_priv->primary);
+		err = drm_legacy_addmap(dev, 0, primary_size, _DRM_CONSISTENT,
+					_DRM_READ_ONLY, &dev_priv->primary);
 		if (!err)
 			break;
 	}
@@ -669,7 +669,7 @@ static int mga_do_pci_dma_bootstrap(struct drm_device *dev,
 		req.count = bin_count;
 		req.size = dma_bs->secondary_bin_size;
 
-		err = drm_addbufs_pci(dev, &req);
+		err = drm_legacy_addbufs_pci(dev, &req);
 		if (!err)
 			break;
 	}
@@ -708,15 +708,16 @@ static int mga_do_dma_bootstrap(struct drm_device *dev,
 	/* The first steps are the same for both PCI and AGP based DMA.  Map
 	 * the cards MMIO registers and map a status page.
 	 */
-	err = drm_addmap(dev, dev_priv->mmio_base, dev_priv->mmio_size,
-			 _DRM_REGISTERS, _DRM_READ_ONLY, &dev_priv->mmio);
+	err = drm_legacy_addmap(dev, dev_priv->mmio_base, dev_priv->mmio_size,
+				_DRM_REGISTERS, _DRM_READ_ONLY,
+				&dev_priv->mmio);
 	if (err) {
 		DRM_ERROR("Unable to map MMIO region: %d\n", err);
 		return err;
 	}
 
-	err = drm_addmap(dev, 0, SAREA_MAX, _DRM_SHM,
-			 _DRM_READ_ONLY | _DRM_LOCKED | _DRM_KERNEL,
+	err = drm_legacy_addmap(dev, 0, SAREA_MAX, _DRM_SHM,
+				_DRM_READ_ONLY | _DRM_LOCKED | _DRM_KERNEL,
 			 &dev_priv->status);
 	if (err) {
 		DRM_ERROR("Unable to map status region: %d\n", err);
@@ -809,7 +810,7 @@ static int mga_do_init_dma(struct drm_device *dev, drm_mga_init_t *init)
 	dev_priv->texture_offset = init->texture_offset[0];
 	dev_priv->texture_size = init->texture_size[0];
 
-	dev_priv->sarea = drm_getsarea(dev);
+	dev_priv->sarea = drm_legacy_getsarea(dev);
 	if (!dev_priv->sarea) {
 		DRM_ERROR("failed to find sarea!\n");
 		return -EINVAL;
diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index 59459fe..1fae2f7 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -452,7 +452,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
 	dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch / 8) << 21) |
 					 (dev_priv->span_offset >> 5));
 
-	dev_priv->sarea = drm_getsarea(dev);
+	dev_priv->sarea = drm_legacy_getsarea(dev);
 	if (!dev_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
 		dev->dev_private = (void *)dev_priv;
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index 8c9b7e2..639d668 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -2052,7 +2052,7 @@ int r600_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
 	dev_priv->buffers_offset = init->buffers_offset;
 	dev_priv->gart_textures_offset = init->gart_textures_offset;
 
-	master_priv->sarea = drm_getsarea(dev);
+	master_priv->sarea = drm_legacy_getsarea(dev);
 	if (!master_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
 		r600_do_cleanup_cp(dev);
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index bb0d5c3..0c38801 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -1298,7 +1298,7 @@ static int radeon_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
 	dev_priv->buffers_offset = init->buffers_offset;
 	dev_priv->gart_textures_offset = init->gart_textures_offset;
 
-	master_priv->sarea = drm_getsarea(dev);
+	master_priv->sarea = drm_legacy_getsarea(dev);
 	if (!master_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
 		radeon_do_cleanup_cp(dev);
@@ -2106,9 +2106,9 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
 	else
 		dev_priv->flags |= RADEON_IS_PCI;
 
-	ret = drm_addmap(dev, pci_resource_start(dev->pdev, 2),
-			 pci_resource_len(dev->pdev, 2), _DRM_REGISTERS,
-			 _DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
+	ret = drm_legacy_addmap(dev, pci_resource_start(dev->pdev, 2),
+				pci_resource_len(dev->pdev, 2), _DRM_REGISTERS,
+				_DRM_READ_ONLY | _DRM_DRIVER, &dev_priv->mmio);
 	if (ret != 0)
 		return ret;
 
@@ -2135,8 +2135,8 @@ int radeon_master_create(struct drm_device *dev, struct drm_master *master)
 
 	/* prebuild the SAREA */
 	sareapage = max_t(unsigned long, SAREA_MAX, PAGE_SIZE);
-	ret = drm_addmap(dev, 0, sareapage, _DRM_SHM, _DRM_CONTAINS_LOCK,
-			 &master_priv->sarea);
+	ret = drm_legacy_addmap(dev, 0, sareapage, _DRM_SHM, _DRM_CONTAINS_LOCK,
+				&master_priv->sarea);
 	if (ret) {
 		DRM_ERROR("SAREA setup failed\n");
 		kfree(master_priv);
@@ -2162,7 +2162,7 @@ void radeon_master_destroy(struct drm_device *dev, struct drm_master *master)
 
 	master_priv->sarea_priv = NULL;
 	if (master_priv->sarea)
-		drm_rmmap_locked(dev, master_priv->sarea);
+		drm_legacy_rmmap_locked(dev, master_priv->sarea);
 
 	kfree(master_priv);
 
@@ -2181,9 +2181,9 @@ int radeon_driver_firstopen(struct drm_device *dev)
 	dev_priv->gart_info.table_size = RADEON_PCIGART_TABLE_SIZE;
 
 	dev_priv->fb_aper_offset = pci_resource_start(dev->pdev, 0);
-	ret = drm_addmap(dev, dev_priv->fb_aper_offset,
-			 pci_resource_len(dev->pdev, 0), _DRM_FRAME_BUFFER,
-			 _DRM_WRITE_COMBINING, &map);
+	ret = drm_legacy_addmap(dev, dev_priv->fb_aper_offset,
+				pci_resource_len(dev->pdev, 0),
+				_DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING, &map);
 	if (ret != 0)
 		return ret;
 
@@ -2196,7 +2196,7 @@ int radeon_driver_unload(struct drm_device *dev)
 
 	DRM_DEBUG("\n");
 
-	drm_rmmap(dev, dev_priv->mmio);
+	drm_legacy_rmmap(dev, dev_priv->mmio);
 
 	kfree(dev_priv);
 
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index c97cdc9..82a078c 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -556,7 +556,7 @@ int savage_driver_load(struct drm_device *dev, unsigned long chipset)
 /*
  * Initialize mappings. On Savage4 and SavageIX the alignment
  * and size of the aperture is not suitable for automatic MTRR setup
- * in drm_addmap. Therefore we add them manually before the maps are
+ * in drm_legacy_addmap. Therefore we add them manually before the maps are
  * initialized, and tear them down on last close.
  */
 int savage_driver_firstopen(struct drm_device *dev)
@@ -624,19 +624,20 @@ int savage_driver_firstopen(struct drm_device *dev)
 		/* Automatic MTRR setup will do the right thing. */
 	}
 
-	ret = drm_addmap(dev, mmio_base, SAVAGE_MMIO_SIZE, _DRM_REGISTERS,
-			 _DRM_READ_ONLY, &dev_priv->mmio);
+	ret = drm_legacy_addmap(dev, mmio_base, SAVAGE_MMIO_SIZE,
+				_DRM_REGISTERS, _DRM_READ_ONLY,
+				&dev_priv->mmio);
 	if (ret)
 		return ret;
 
-	ret = drm_addmap(dev, fb_base, fb_size, _DRM_FRAME_BUFFER,
-			 _DRM_WRITE_COMBINING, &dev_priv->fb);
+	ret = drm_legacy_addmap(dev, fb_base, fb_size, _DRM_FRAME_BUFFER,
+				_DRM_WRITE_COMBINING, &dev_priv->fb);
 	if (ret)
 		return ret;
 
-	ret = drm_addmap(dev, aperture_base, SAVAGE_APERTURE_SIZE,
-			 _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING,
-			 &dev_priv->aperture);
+	ret = drm_legacy_addmap(dev, aperture_base, SAVAGE_APERTURE_SIZE,
+				_DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING,
+				&dev_priv->aperture);
 	return ret;
 }
 
@@ -698,7 +699,7 @@ static int savage_do_init_bci(struct drm_device * dev, drm_savage_init_t * init)
 	dev_priv->texture_offset = init->texture_offset;
 	dev_priv->texture_size = init->texture_size;
 
-	dev_priv->sarea = drm_getsarea(dev);
+	dev_priv->sarea = drm_legacy_getsarea(dev);
 	if (!dev_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
 		savage_do_cleanup_bci(dev);
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index d0ab3fb..67e70e9 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -31,7 +31,7 @@ static int via_do_init_map(struct drm_device *dev, drm_via_init_t *init)
 
 	DRM_DEBUG("\n");
 
-	dev_priv->sarea = drm_getsarea(dev);
+	dev_priv->sarea = drm_legacy_getsarea(dev);
 	if (!dev_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
 		dev->dev_private = (void *)dev_priv;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 6b4fbf3..cea7911 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -153,8 +153,6 @@ 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_MAP_HASH_OFFSET 0x10000000
-
 /*@}*/
 
 /***********************************************************************/
@@ -1243,31 +1241,6 @@ extern void drm_idlelock_release(struct drm_lock_data *lock_data);
 
 extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
 
-				/* Buffer management support (drm_bufs.h) */
-extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
-extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
-extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
-		      unsigned int size, enum drm_map_type type,
-		      enum drm_map_flags flags, struct drm_local_map **map_ptr);
-extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
-			    struct drm_file *file_priv);
-extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
-extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
-extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
-			   struct drm_file *file_priv);
-extern int drm_addbufs(struct drm_device *dev, void *data,
-		       struct drm_file *file_priv);
-extern int drm_infobufs(struct drm_device *dev, void *data,
-			struct drm_file *file_priv);
-extern int drm_markbufs(struct drm_device *dev, void *data,
-			struct drm_file *file_priv);
-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);
 extern void drm_legacy_dma_takedown(struct drm_device *dev);
@@ -1354,8 +1327,6 @@ extern unsigned int drm_timestamp_monotonic;
 
 extern struct class *drm_class;
 
-extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
-
 				/* Debugfs support */
 #if defined(CONFIG_DEBUG_FS)
 extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
@@ -1466,6 +1437,18 @@ extern int drm_pci_set_unique(struct drm_device *dev,
 			      struct drm_master *master,
 			      struct drm_unique *u);
 
+				/* Legacy Support */
+
+int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
+		      unsigned int size, enum drm_map_type type,
+		      enum drm_map_flags flags, struct drm_local_map **map_p);
+int drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
+int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
+struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
+
+int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req);
+int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
+
 			       /* sysfs support (drm_sysfs.c) */
 struct drm_sysfs_class;
 extern struct class *drm_sysfs_create(struct module *owner, char *name);
-- 
2.1.0

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

* [PATCH 03/20] drm: move "struct drm_vma_entry" to drm_vm.c
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
  2014-08-29 10:12 ` [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/ David Herrmann
  2014-08-29 10:12 ` [PATCH 02/20] drm: mark drm_buf and drm_map as legacy David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:34   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 04/20] drm: move "struct drm_magic_entry" to drm_auth.c David Herrmann
                   ` (17 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Make all the drm_vma_entry handling local to drm_vm.c and hide it from
global headers. This requires to extract the inlined legacy drm_vma_entry
cleanup into a small helper and also move a weirdly placed drm_vma_info
helper into drm_vm.c.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_fops.c | 10 +-----
 drivers/gpu/drm/drm_info.c | 59 -----------------------------------
 drivers/gpu/drm/drm_vm.c   | 76 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drmP.h         |  8 ++---
 4 files changed, 79 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 6dbbb0f..12e6a1c 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -330,8 +330,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
  */
 int drm_lastclose(struct drm_device * dev)
 {
-	struct drm_vma_entry *vma, *vma_temp;
-
 	DRM_DEBUG("\n");
 
 	if (dev->driver->lastclose)
@@ -346,13 +344,7 @@ int drm_lastclose(struct drm_device * dev)
 	drm_agp_clear(dev);
 
 	drm_legacy_sg_cleanup(dev);
-
-	/* Clear vma list (only built for debugging) */
-	list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
-		list_del(&vma->head);
-		kfree(vma);
-	}
-
+	drm_legacy_vma_flush(dev);
 	drm_legacy_dma_takedown(dev);
 
 	mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index ecaf0fa..3c99f6f 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -223,62 +223,3 @@ int drm_gem_name_info(struct seq_file *m, void *data)
 
 	return 0;
 }
-
-#if DRM_DEBUG_CODE
-
-int drm_vma_info(struct seq_file *m, void *data)
-{
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct drm_device *dev = node->minor->dev;
-	struct drm_vma_entry *pt;
-	struct vm_area_struct *vma;
-	unsigned long vma_count = 0;
-#if defined(__i386__)
-	unsigned int pgprot;
-#endif
-
-	mutex_lock(&dev->struct_mutex);
-	list_for_each_entry(pt, &dev->vmalist, head)
-		vma_count++;
-
-	seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n",
-		   vma_count, high_memory,
-		   (void *)(unsigned long)virt_to_phys(high_memory));
-
-	list_for_each_entry(pt, &dev->vmalist, head) {
-		vma = pt->vma;
-		if (!vma)
-			continue;
-		seq_printf(m,
-			   "\n%5d 0x%pK-0x%pK %c%c%c%c%c%c 0x%08lx000",
-			   pt->pid,
-			   (void *)vma->vm_start, (void *)vma->vm_end,
-			   vma->vm_flags & VM_READ ? 'r' : '-',
-			   vma->vm_flags & VM_WRITE ? 'w' : '-',
-			   vma->vm_flags & VM_EXEC ? 'x' : '-',
-			   vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
-			   vma->vm_flags & VM_LOCKED ? 'l' : '-',
-			   vma->vm_flags & VM_IO ? 'i' : '-',
-			   vma->vm_pgoff);
-
-#if defined(__i386__)
-		pgprot = pgprot_val(vma->vm_page_prot);
-		seq_printf(m, " %c%c%c%c%c%c%c%c%c",
-			   pgprot & _PAGE_PRESENT ? 'p' : '-',
-			   pgprot & _PAGE_RW ? 'w' : 'r',
-			   pgprot & _PAGE_USER ? 'u' : 's',
-			   pgprot & _PAGE_PWT ? 't' : 'b',
-			   pgprot & _PAGE_PCD ? 'u' : 'c',
-			   pgprot & _PAGE_ACCESSED ? 'a' : '-',
-			   pgprot & _PAGE_DIRTY ? 'd' : '-',
-			   pgprot & _PAGE_PSE ? 'm' : 'k',
-			   pgprot & _PAGE_GLOBAL ? 'g' : 'l');
-#endif
-		seq_printf(m, "\n");
-	}
-	mutex_unlock(&dev->struct_mutex);
-	return 0;
-}
-
-#endif
-
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 24e045c..352e339 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -35,11 +35,18 @@
 
 #include <drm/drmP.h>
 #include <linux/export.h>
+#include <linux/seq_file.h>
 #if defined(__ia64__)
 #include <linux/efi.h>
 #include <linux/slab.h>
 #endif
 
+struct drm_vma_entry {
+	struct list_head head;
+	struct vm_area_struct *vma;
+	pid_t pid;
+};
+
 static void drm_vm_open(struct vm_area_struct *vma);
 static void drm_vm_close(struct vm_area_struct *vma);
 
@@ -662,3 +669,72 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
 	return ret;
 }
 EXPORT_SYMBOL(drm_mmap);
+
+void drm_legacy_vma_flush(struct drm_device *dev)
+{
+	struct drm_vma_entry *vma, *vma_temp;
+
+	/* Clear vma list (only needed for legacy drivers) */
+	list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
+		list_del(&vma->head);
+		kfree(vma);
+	}
+}
+
+#if DRM_DEBUG_CODE
+
+int drm_vma_info(struct seq_file *m, void *data)
+{
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_vma_entry *pt;
+	struct vm_area_struct *vma;
+	unsigned long vma_count = 0;
+#if defined(__i386__)
+	unsigned int pgprot;
+#endif
+
+	mutex_lock(&dev->struct_mutex);
+	list_for_each_entry(pt, &dev->vmalist, head)
+		vma_count++;
+
+	seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n",
+		   vma_count, high_memory,
+		   (void *)(unsigned long)virt_to_phys(high_memory));
+
+	list_for_each_entry(pt, &dev->vmalist, head) {
+		vma = pt->vma;
+		if (!vma)
+			continue;
+		seq_printf(m,
+			   "\n%5d 0x%pK-0x%pK %c%c%c%c%c%c 0x%08lx000",
+			   pt->pid,
+			   (void *)vma->vm_start, (void *)vma->vm_end,
+			   vma->vm_flags & VM_READ ? 'r' : '-',
+			   vma->vm_flags & VM_WRITE ? 'w' : '-',
+			   vma->vm_flags & VM_EXEC ? 'x' : '-',
+			   vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
+			   vma->vm_flags & VM_LOCKED ? 'l' : '-',
+			   vma->vm_flags & VM_IO ? 'i' : '-',
+			   vma->vm_pgoff);
+
+#if defined(__i386__)
+		pgprot = pgprot_val(vma->vm_page_prot);
+		seq_printf(m, " %c%c%c%c%c%c%c%c%c",
+			   pgprot & _PAGE_PRESENT ? 'p' : '-',
+			   pgprot & _PAGE_RW ? 'w' : 'r',
+			   pgprot & _PAGE_USER ? 'u' : 's',
+			   pgprot & _PAGE_PWT ? 't' : 'b',
+			   pgprot & _PAGE_PCD ? 'u' : 'c',
+			   pgprot & _PAGE_ACCESSED ? 'a' : '-',
+			   pgprot & _PAGE_DIRTY ? 'd' : '-',
+			   pgprot & _PAGE_PSE ? 'm' : 'k',
+			   pgprot & _PAGE_GLOBAL ? 'g' : 'l');
+#endif
+		seq_printf(m, "\n");
+	}
+	mutex_unlock(&dev->struct_mutex);
+	return 0;
+}
+
+#endif
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index cea7911..11c3575 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -296,12 +296,6 @@ struct drm_magic_entry {
 	struct drm_file *priv;
 };
 
-struct drm_vma_entry {
-	struct list_head head;
-	struct vm_area_struct *vma;
-	pid_t pid;
-};
-
 /**
  * DMA buffer.
  */
@@ -1449,6 +1443,8 @@ struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
 int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req);
 int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
 
+void drm_legacy_vma_flush(struct drm_device *d);
+
 			       /* sysfs support (drm_sysfs.c) */
 struct drm_sysfs_class;
 extern struct class *drm_sysfs_create(struct module *owner, char *name);
-- 
2.1.0

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

* [PATCH 04/20] drm: move "struct drm_magic_entry" to drm_auth.c
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (2 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 03/20] drm: move "struct drm_vma_entry" to drm_vm.c David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:39   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 05/20] drm: drop unused "struct drm_waitlist" David Herrmann
                   ` (16 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

In drm_release(), we currently call drm_remove_magic() if the drm_file
has a drm-magic attached. Therefore, once drm_master_release() is called,
the magic-list _must_ be empty.

By dropping the no-op cleanup, we can move "struct drm_magic_entry" to
drm_auth.c and avoid exposing it to all of DRM.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_auth.c | 6 ++++++
 drivers/gpu/drm/drm_drv.c  | 7 -------
 include/drm/drmP.h         | 6 ------
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 3cedae1..708a204 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -35,6 +35,12 @@
 
 #include <drm/drmP.h>
 
+struct drm_magic_entry {
+	struct list_head head;
+	struct drm_hash_item hash_item;
+	struct drm_file *priv;
+};
+
 /**
  * Find the file with the given magic number.
  *
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index b1587e2..6645669 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -133,7 +133,6 @@ EXPORT_SYMBOL(drm_master_get);
 static void drm_master_destroy(struct kref *kref)
 {
 	struct drm_master *master = container_of(kref, struct drm_master, refcount);
-	struct drm_magic_entry *pt, *next;
 	struct drm_device *dev = master->minor->dev;
 	struct drm_map_list *r_list, *list_temp;
 
@@ -154,12 +153,6 @@ static void drm_master_destroy(struct kref *kref)
 		master->unique_len = 0;
 	}
 
-	list_for_each_entry_safe(pt, next, &master->magicfree, head) {
-		list_del(&pt->head);
-		drm_ht_remove_item(&master->magiclist, &pt->hash_item);
-		kfree(pt);
-	}
-
 	drm_ht_remove(&master->magiclist);
 
 	mutex_unlock(&dev->struct_mutex);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 11c3575..0fdd813 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -290,12 +290,6 @@ struct drm_ioctl_desc {
 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)			\
 	[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
 
-struct drm_magic_entry {
-	struct list_head head;
-	struct drm_hash_item hash_item;
-	struct drm_file *priv;
-};
-
 /**
  * DMA buffer.
  */
-- 
2.1.0

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

* [PATCH 05/20] drm: drop unused "struct drm_waitlist"
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (3 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 04/20] drm: move "struct drm_magic_entry" to drm_auth.c David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:40   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 06/20] drm: move AGP definitions harder David Herrmann
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

This structure is unused, drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 include/drm/drmP.h | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0fdd813..0bf66f9 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -320,17 +320,6 @@ struct drm_buf {
 	void *dev_private;		 /**< Per-buffer private storage */
 };
 
-/** bufs is one longer than it has to be */
-struct drm_waitlist {
-	int count;			/**< Number of possible buffers */
-	struct drm_buf **bufs;		/**< List of pointers to buffers */
-	struct drm_buf **rp;			/**< Read pointer */
-	struct drm_buf **wp;			/**< Write pointer */
-	struct drm_buf **end;		/**< End pointer */
-	spinlock_t read_lock;
-	spinlock_t write_lock;
-};
-
 typedef struct drm_dma_handle {
 	dma_addr_t busaddr;
 	void *vaddr;
-- 
2.1.0

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

* [PATCH 06/20] drm: move AGP definitions harder
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (4 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 05/20] drm: drop unused "struct drm_waitlist" David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:43   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 07/20] drm: replace weird conditional includes David Herrmann
                   ` (14 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Move drm_agp_head to drm_agpsupport.h and drm_agp_mem into drm_legacy.h.
Unfortunately, drivers still heavily access drm_agp_head so we cannot
move it to drm_legacy.h. However, at least it's no longer visible in
drmP.h now (it's directly included from it, though).

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_agpsupport.c |  1 +
 drivers/gpu/drm/drm_legacy.h     | 15 +++++++++++++++
 drivers/gpu/drm/drm_memory.c     |  1 +
 drivers/gpu/drm/drm_vm.c         |  1 +
 include/drm/drmP.h               | 30 +-----------------------------
 include/drm/drm_agpsupport.h     | 13 +++++++++++++
 6 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index dde205c..4b2b4aa 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -34,6 +34,7 @@
 #include <drm/drmP.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include "drm_legacy.h"
 
 #if __OS_HAS_AGP
 
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 912fe81..d94c564 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -23,6 +23,9 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/list.h>
+
+struct agp_memory;
 struct drm_device;
 struct drm_file;
 
@@ -63,4 +66,16 @@ int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
 int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
 
+/*
+ * AGP Support
+ */
+
+struct drm_agp_mem {
+	unsigned long handle;
+	struct agp_memory *memory;
+	unsigned long bound;
+	int pages;
+	struct list_head head;
+};
+
 #endif /* __DRM_LEGACY_H__ */
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 00c67c0..7888dad 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -36,6 +36,7 @@
 #include <linux/highmem.h>
 #include <linux/export.h>
 #include <drm/drmP.h>
+#include "drm_legacy.h"
 
 #if __OS_HAS_AGP
 static void *agp_remap(unsigned long offset, unsigned long size,
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 352e339..be25174 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -40,6 +40,7 @@
 #include <linux/efi.h>
 #include <linux/slab.h>
 #endif
+#include "drm_legacy.h"
 
 struct drm_vma_entry {
 	struct list_head head;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0bf66f9..7a3c73c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -80,6 +80,7 @@ struct module;
 
 struct drm_file;
 struct drm_device;
+struct drm_agp_head;
 
 struct device_node;
 struct videomode;
@@ -440,35 +441,6 @@ struct drm_device_dma {
 };
 
 /**
- * AGP memory entry.  Stored as a doubly linked list.
- */
-struct drm_agp_mem {
-	unsigned long handle;		/**< handle */
-	struct agp_memory *memory;
-	unsigned long bound;		/**< address */
-	int pages;
-	struct list_head head;
-};
-
-/**
- * AGP data.
- *
- * \sa drm_agp_init() and drm_device::agp.
- */
-struct drm_agp_head {
-	struct agp_kern_info agp_info;		/**< AGP device information */
-	struct list_head memory;
-	unsigned long mode;		/**< AGP mode */
-	struct agp_bridge_data *bridge;
-	int enabled;			/**< whether the AGP bus as been enabled */
-	int acquired;			/**< whether the AGP device has been acquired */
-	unsigned long base;
-	int agp_mtrr;
-	int cant_use_aperture;
-	unsigned long page_mask;
-};
-
-/**
  * Scatter-gather memory.
  */
 struct drm_sg_mem {
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 86a0218..3bebeb4 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -8,6 +8,19 @@
 #include <linux/agp_backend.h>
 #include <drm/drmP.h>
 
+struct drm_agp_head {
+	struct agp_kern_info agp_info;
+	struct list_head memory;
+	unsigned long mode;
+	struct agp_bridge_data *bridge;
+	int enabled;
+	int acquired;
+	unsigned long base;
+	int agp_mtrr;
+	int cant_use_aperture;
+	unsigned long page_mask;
+};
+
 #if __OS_HAS_AGP
 
 void drm_free_agp(struct agp_memory * handle, int pages);
-- 
2.1.0

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

* [PATCH 07/20] drm: replace weird conditional includes
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (5 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 06/20] drm: move AGP definitions harder David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:45   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 08/20] drm: drop __KERNEL__ protection in drmP.h David Herrmann
                   ` (13 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

pte_wrprotect() is only used by drm_vm.c, so move the include there. Also
include it unconditionally, all architectures provide this header!

Furthermore, replace asm/current.h with sched.h, which includes
asm/current.h unconditionally. This way we get the same effect and avoid
direct asm/ includes. Furthermore, drop the weird __alpha__ protection.
It's safe to include sched.h everywhere (and the wait.h comment doesn't
apply, anyway).

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_vm.c |  1 +
 include/drm/drmP.h       | 10 +---------
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index be25174..967e570 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -40,6 +40,7 @@
 #include <linux/efi.h>
 #include <linux/slab.h>
 #endif
+#include <asm/pgtable.h>
 #include "drm_legacy.h"
 
 struct drm_vma_entry {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 7a3c73c..31fb300 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -36,12 +36,7 @@
 #define _DRM_P_H_
 
 #ifdef __KERNEL__
-#ifdef __alpha__
-/* add include of current.h so that "current" is defined
- * before static inline funcs in wait.h. Doing this so we
- * can build the DRM (part of PI DRI). 4/21/2000 S + B */
-#include <asm/current.h>
-#endif				/* __alpha__ */
+#include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/kref.h>
 #include <linux/miscdevice.h>
@@ -58,9 +53,6 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/ratelimit.h>
-#if defined(__alpha__) || defined(__powerpc__)
-#include <asm/pgtable.h>	/* For pte_wrprotect */
-#endif
 #include <asm/mman.h>
 #include <asm/uaccess.h>
 #include <linux/types.h>
-- 
2.1.0

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

* [PATCH 08/20] drm: drop __KERNEL__ protection in drmP.h
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (6 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 07/20] drm: replace weird conditional includes David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:46   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c David Herrmann
                   ` (12 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

drmP.h is internal to the kernel. No need to keep the __KERNEL__
protection.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 include/drm/drmP.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 31fb300..d3504c6 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -35,7 +35,6 @@
 #ifndef _DRM_P_H_
 #define _DRM_P_H_
 
-#ifdef __KERNEL__
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/kref.h>
@@ -1544,5 +1543,4 @@ static __inline__ bool drm_can_sleep(void)
 	return true;
 }
 
-#endif				/* __KERNEL__ */
 #endif
-- 
2.1.0

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

* [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (7 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 08/20] drm: drop __KERNEL__ protection in drmP.h David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 11:56   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h David Herrmann
                   ` (11 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

The drm_memory.h header is only used to define PAGE_AGP, which is only
used in drm_memory.c. Fold the header into drm_memory.c and drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_memory.c | 11 +++++++++
 include/drm/drmP.h           |  6 ++---
 include/drm/drm_memory.h     | 59 --------------------------------------------
 3 files changed, 13 insertions(+), 63 deletions(-)
 delete mode 100644 include/drm/drm_memory.h

diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 7888dad..62fda6a 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -39,6 +39,17 @@
 #include "drm_legacy.h"
 
 #if __OS_HAS_AGP
+
+#ifdef HAVE_PAGE_AGP
+# include <asm/agp.h>
+#else
+# ifdef __powerpc__
+#  define PAGE_AGP	__pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
+# else
+#  define PAGE_AGP	PAGE_KERNEL
+# endif
+#endif
+
 static void *agp_remap(unsigned long offset, unsigned long size,
 		       struct drm_device * dev)
 {
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d3504c6..294f7da 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -58,6 +58,8 @@
 #include <linux/agp_backend.h>
 #include <linux/workqueue.h>
 #include <linux/poll.h>
+#include <linux/highmem.h>
+#include <linux/vmalloc.h>
 #include <asm/pgalloc.h>
 #include <drm/drm.h>
 #include <drm/drm_sarea.h>
@@ -1127,10 +1129,6 @@ extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vm
 extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
 extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
 
-				/* Memory management support (drm_memory.h) */
-#include <drm/drm_memory.h>
-
-
 				/* Misc. IOCTL support (drm_ioctl.h) */
 extern int drm_irq_by_busid(struct drm_device *dev, void *data,
 			    struct drm_file *file_priv);
diff --git a/include/drm/drm_memory.h b/include/drm/drm_memory.h
deleted file mode 100644
index 4baf57a..0000000
--- a/include/drm/drm_memory.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * \file drm_memory.h
- * Memory management wrappers for DRM
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Created: Thu Feb  4 14:00:34 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/highmem.h>
-#include <linux/vmalloc.h>
-#include <drm/drmP.h>
-
-/**
- * Cut down version of drm_memory_debug.h, which used to be called
- * drm_memory.h.
- */
-
-#if __OS_HAS_AGP
-
-#ifdef HAVE_PAGE_AGP
-#include <asm/agp.h>
-#else
-# ifdef __powerpc__
-#  define PAGE_AGP	__pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
-# else
-#  define PAGE_AGP	PAGE_KERNEL
-# endif
-#endif
-
-#else				/* __OS_HAS_AGP */
-
-#endif
-- 
2.1.0

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

* [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (8 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:03   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 11/20] drm: order includes alphabetically in drmP.h David Herrmann
                   ` (10 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

With drm_memory.h gone, there is no header left that uses __OS_HAS_AGP.
Move it into drm_agpsupport.h (which is itself included from drmP.h) to
hide it harder from public eyes.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 include/drm/drmP.h           | 2 --
 include/drm/drm_agpsupport.h | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 294f7da..c6f337c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -67,8 +67,6 @@
 
 #include <linux/idr.h>
 
-#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
-
 struct module;
 
 struct drm_file;
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 3bebeb4..4f1724c 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -8,6 +8,9 @@
 #include <linux/agp_backend.h>
 #include <drm/drmP.h>
 
+#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && \
+					      defined(MODULE)))
+
 struct drm_agp_head {
 	struct agp_kern_info agp_info;
 	struct list_head memory;
-- 
2.1.0

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

* [PATCH 11/20] drm: order includes alphabetically in drmP.h
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (9 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:05   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 12/20] drm: drop DRM_DEBUG_CODE David Herrmann
                   ` (9 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

It is hardly possible to review the drmP.h includes, anymore. Order them
alphabetically, linux/ first, then asm/ and then local drm/ includes.

Since a long time ago, kernel headers have been converted to include
required headers themselves. No-one cares whether that means the compiler
has to include a header multiple times. In fact, GCC already does some
optimization regarding multiple inclusions if a sorrounding #ifndef is
present.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 include/drm/drmP.h | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c6f337c..8b3f3b7 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -35,38 +35,42 @@
 #ifndef _DRM_P_H_
 #define _DRM_P_H_
 
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/kref.h>
-#include <linux/miscdevice.h>
+#include <linux/agp_backend.h>
+#include <linux/cdev.h>
+#include <linux/dma-mapping.h>
+#include <linux/file.h>
 #include <linux/fs.h>
+#include <linux/highmem.h>
+#include <linux/idr.h>
 #include <linux/init.h>
-#include <linux/file.h>
-#include <linux/platform_device.h>
-#include <linux/pci.h>
+#include <linux/io.h>
 #include <linux/jiffies.h>
-#include <linux/dma-mapping.h>
+#include <linux/kernel.h>
+#include <linux/kref.h>
+#include <linux/miscdevice.h>
 #include <linux/mm.h>
-#include <linux/cdev.h>
 #include <linux/mutex.h>
-#include <linux/io.h>
-#include <linux/slab.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/poll.h>
 #include <linux/ratelimit.h>
-#include <asm/mman.h>
-#include <asm/uaccess.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/types.h>
-#include <linux/agp_backend.h>
-#include <linux/workqueue.h>
-#include <linux/poll.h>
-#include <linux/highmem.h>
 #include <linux/vmalloc.h>
+#include <linux/workqueue.h>
+
+#include <asm/mman.h>
 #include <asm/pgalloc.h>
+#include <asm/uaccess.h>
+
 #include <drm/drm.h>
+#include <drm/drm_hashtab.h>
+#include <drm/drm_mm.h>
+#include <drm/drm_os_linux.h>
 #include <drm/drm_sarea.h>
 #include <drm/drm_vma_manager.h>
 
-#include <linux/idr.h>
-
 struct module;
 
 struct drm_file;
@@ -77,10 +81,6 @@ struct device_node;
 struct videomode;
 struct reservation_object;
 
-#include <drm/drm_os_linux.h>
-#include <drm/drm_hashtab.h>
-#include <drm/drm_mm.h>
-
 /*
  * 4 debug categories are defined:
  *
-- 
2.1.0

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

* [PATCH 12/20] drm: drop DRM_DEBUG_CODE
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (10 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 11/20] drm: order includes alphabetically in drmP.h David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:10   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 13/20] drm: inline "struct drm_sigdata" David Herrmann
                   ` (8 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

DRM_DEBUG_CODE is currently always set, so distributions enable it. The
only reason to keep support in code is if developers wanted to disable
debug support. Sounds unlikely.

All the DRM_DEBUG() printks are still guarded by a drm_debug read. So if
its cacheline is read once, they're discarded pretty fast.. There should
hardly be any performance penalty, it's even guarded by unlikely().

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_debugfs.c        |  2 --
 drivers/gpu/drm/drm_vm.c             |  4 ----
 drivers/gpu/drm/radeon/radeon.h      | 17 ++++++++++++-----
 drivers/gpu/drm/radeon/radeon_ring.c | 21 ---------------------
 include/drm/drmP.h                   | 12 ------------
 5 files changed, 12 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 13bd429..4491dbd 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -49,9 +49,7 @@ static const struct drm_info_list drm_debugfs_list[] = {
 	{"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_DEBUGFS_ENTRIES ARRAY_SIZE(drm_debugfs_list)
 
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 967e570..4b3e9c4 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -683,8 +683,6 @@ void drm_legacy_vma_flush(struct drm_device *dev)
 	}
 }
 
-#if DRM_DEBUG_CODE
-
 int drm_vma_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -738,5 +736,3 @@ int drm_vma_info(struct seq_file *m, void *data)
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 }
-
-#endif
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 83a2461..5cfa574 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2761,18 +2761,25 @@ void radeon_atombios_fini(struct radeon_device *rdev);
 /*
  * RING helpers.
  */
-#if DRM_DEBUG_CODE == 0
+
+/**
+ * radeon_ring_write - write a value to the ring
+ *
+ * @ring: radeon_ring structure holding ring information
+ * @v: dword (dw) value to write
+ *
+ * Write a value to the requested ring buffer (all asics).
+ */
 static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
 {
+	if (ring->count_dw <= 0)
+		DRM_ERROR("radeon: writing more dwords to the ring than expected!\n");
+
 	ring->ring[ring->wptr++] = v;
 	ring->wptr &= ring->ptr_mask;
 	ring->count_dw--;
 	ring->ring_free_dw--;
 }
-#else
-/* With debugging this is just too big to inline */
-void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
-#endif
 
 /*
  * ASICs macro.
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index d656079..6f2a9bd 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -45,27 +45,6 @@
 static int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring);
 
 /**
- * radeon_ring_write - write a value to the ring
- *
- * @ring: radeon_ring structure holding ring information
- * @v: dword (dw) value to write
- *
- * Write a value to the requested ring buffer (all asics).
- */
-void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
-{
-#if DRM_DEBUG_CODE
-	if (ring->count_dw <= 0) {
-		DRM_ERROR("radeon: writing more dwords to the ring than expected!\n");
-	}
-#endif
-	ring->ring[ring->wptr++] = v;
-	ring->wptr &= ring->ptr_mask;
-	ring->count_dw--;
-	ring->ring_free_dw--;
-}
-
-/**
  * radeon_ring_supports_scratch_reg - check if the ring supports
  * writing to scratch registers
  *
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8b3f3b7..8f55875 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -140,9 +140,6 @@ int drm_err(const char *func, const char *format, ...);
 /** \name Begin the DRM... */
 /*@{*/
 
-#define DRM_DEBUG_CODE 2	  /**< Include debugging code if > 1, then
-				     also include looping detection. */
-
 #define DRM_MAGIC_HASH_ORDER  4  /**< Size of key hash table. Must be power of 2. */
 
 /*@}*/
@@ -188,7 +185,6 @@ int drm_err(const char *func, const char *format, ...);
  * \param fmt printf() like format string.
  * \param arg arguments
  */
-#if DRM_DEBUG_CODE
 #define DRM_DEBUG(fmt, args...)						\
 	do {								\
 		if (unlikely(drm_debug & DRM_UT_CORE))			\
@@ -210,12 +206,6 @@ int drm_err(const char *func, const char *format, ...);
 		if (unlikely(drm_debug & DRM_UT_PRIME))			\
 			drm_ut_debug_printk(__func__, fmt, ##args);	\
 	} while (0)
-#else
-#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
-#define DRM_DEBUG_KMS(fmt, args...)	do { } while (0)
-#define DRM_DEBUG_PRIME(fmt, args...)	do { } while (0)
-#define DRM_DEBUG(fmt, arg...)		 do { } while (0)
-#endif
 
 /*@}*/
 
@@ -1348,9 +1338,7 @@ void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
 void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
 void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf);
 
-#if DRM_DEBUG_CODE
 extern int drm_vma_info(struct seq_file *m, void *data);
-#endif
 
 				/* Scatter Gather Support (drm_scatter.h) */
 extern void drm_legacy_sg_cleanup(struct drm_device *dev);
-- 
2.1.0

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

* [PATCH 13/20] drm: inline "struct drm_sigdata"
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (11 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 12/20] drm: drop DRM_DEBUG_CODE David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:21   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 14/20] drm: move remaining includes in drmP.h to the top David Herrmann
                   ` (7 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

The sigdata structure is only used to group two fields in drm_device.
Inline it and make it an unnamed object.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_lock.c | 15 ++++++++-------
 include/drm/drmP.h         | 12 +++++-------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index e26b59e..60f1481 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -120,7 +120,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
 		sigaddset(&dev->sigmask, SIGTTOU);
 		dev->sigdata.context = lock->context;
 		dev->sigdata.lock = master->lock.hw_lock;
-		block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
+		block_all_signals(drm_notifier, dev, &dev->sigmask);
 	}
 
 	if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT))
@@ -286,26 +286,27 @@ int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
  * If the lock is not held, then let the signal proceed as usual.  If the lock
  * is held, then set the contended flag and keep the signal blocked.
  *
- * \param priv pointer to a drm_sigdata structure.
+ * \param priv pointer to a drm_device structure.
  * \return one if the signal should be delivered normally, or zero if the
  * signal should be blocked.
  */
 static int drm_notifier(void *priv)
 {
-	struct drm_sigdata *s = (struct drm_sigdata *) priv;
+	struct drm_device *dev = priv;
+	struct drm_hw_lock *lock = dev->sigdata.lock;
 	unsigned int old, new, prev;
 
 	/* Allow signal delivery if lock isn't held */
-	if (!s->lock || !_DRM_LOCK_IS_HELD(s->lock->lock)
-	    || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context)
+	if (!lock || !_DRM_LOCK_IS_HELD(lock->lock)
+	    || _DRM_LOCKING_CONTEXT(lock->lock) != dev->sigdata.context)
 		return 1;
 
 	/* Otherwise, set flag to force call to
 	   drmUnlock */
 	do {
-		old = s->lock->lock;
+		old = lock->lock;
 		new = old | _DRM_LOCK_CONT;
-		prev = cmpxchg(&s->lock->lock, old, new);
+		prev = cmpxchg(&lock->lock, old, new);
 	} while (prev != old);
 	return 0;
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8f55875..840a373 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -432,12 +432,6 @@ struct drm_sg_mem {
 	dma_addr_t *busaddr;
 };
 
-struct drm_sigdata {
-	int context;
-	struct drm_hw_lock *lock;
-};
-
-
 /**
  * Kernel side of a mapping
  */
@@ -1035,9 +1029,13 @@ struct drm_device {
 
 	struct drm_sg_mem *sg;	/**< Scatter gather memory */
 	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
-	struct drm_sigdata sigdata;	   /**< For block_all_signals */
 	sigset_t sigmask;
 
+	struct {
+		int context;
+		struct drm_hw_lock *lock;
+	} sigdata;
+
 	struct drm_local_map *agp_buffer_map;
 	unsigned int agp_buffer_token;
 
-- 
2.1.0

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

* [PATCH 14/20] drm: move remaining includes in drmP.h to the top
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (12 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 13/20] drm: inline "struct drm_sigdata" David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:26   ` Thierry Reding
  2014-08-29 10:12 ` [PATCH 15/20] drm: simplify drm_*_set_unique() David Herrmann
                   ` (6 subsequent siblings)
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Including headers somewhere else but at the top is ugly, deprecated and
was used in early days only to speed up compile-times. Those days are
over. Make headers independent and then move the inclusions to the top.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 include/drm/drmP.h           | 31 ++++++++++++-------------------
 include/drm/drm_agpsupport.h | 10 ++++++++--
 include/drm/drm_crtc.h       |  4 ++--
 3 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 840a373..a8b24fc 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1,17 +1,14 @@
-/**
- * \file drmP.h
- * Private header for Direct Rendering Manager
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
 /*
+ * Internal Header for the Direct Rendering Manager
+ *
  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  * Copyright (c) 2009-2010, Code Aurora Forum.
  * All rights reserved.
  *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Author: Gareth Hughes <gareth@valinux.com>
+ *
  * 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
@@ -64,8 +61,14 @@
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
 
-#include <drm/drm.h>
+#include <uapi/drm/drm.h>
+#include <uapi/drm/drm_mode.h>
+
+#include <drm/drm_agpsupport.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_global.h>
 #include <drm/drm_hashtab.h>
+#include <drm/drm_mem_util.h>
 #include <drm/drm_mm.h>
 #include <drm/drm_os_linux.h>
 #include <drm/drm_sarea.h>
@@ -564,8 +567,6 @@ struct drm_gem_object {
 	struct dma_buf_attachment *import_attach;
 };
 
-#include <drm/drm_crtc.h>
-
 /**
  * struct drm_master - drm master structure
  *
@@ -1228,10 +1229,6 @@ extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
 extern int drm_modeset_ctl(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv);
 
-				/* AGP/GART support (drm_agpsupport.h) */
-
-#include <drm/drm_agpsupport.h>
-
 				/* Stub support (drm_stub.h) */
 extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
 			       struct drm_file *file_priv);
@@ -1397,8 +1394,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
 		     struct vm_area_struct *vma);
 int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
 
-#include <drm/drm_global.h>
-
 static inline void
 drm_gem_object_reference(struct drm_gem_object *obj)
 {
@@ -1472,8 +1467,6 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
 {
 }
 
-#include <drm/drm_mem_util.h>
-
 struct drm_device *drm_dev_alloc(struct drm_driver *driver,
 				 struct device *parent);
 void drm_dev_ref(struct drm_device *dev);
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 4f1724c..055dc05 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -1,12 +1,16 @@
 #ifndef _DRM_AGPSUPPORT_H_
 #define _DRM_AGPSUPPORT_H_
 
+#include <linux/agp_backend.h>
 #include <linux/kernel.h>
+#include <linux/list.h>
 #include <linux/mm.h>
 #include <linux/mutex.h>
 #include <linux/types.h>
-#include <linux/agp_backend.h>
-#include <drm/drmP.h>
+#include <uapi/drm/drm.h>
+
+struct drm_device;
+struct drm_file;
 
 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && \
 					      defined(MODULE)))
@@ -61,6 +65,7 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
 int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
+
 #else /* __OS_HAS_AGP */
 
 static inline void drm_free_agp(struct agp_memory * handle, int pages)
@@ -188,6 +193,7 @@ static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
 {
 	return -ENODEV;
 }
+
 #endif /* __OS_HAS_AGP */
 
 #endif /* _DRM_AGPSUPPORT_H_ */
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 0375d75..77d9763 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,8 +31,8 @@
 #include <linux/idr.h>
 #include <linux/fb.h>
 #include <linux/hdmi.h>
-#include <drm/drm_mode.h>
-#include <drm/drm_fourcc.h>
+#include <uapi/drm/drm_mode.h>
+#include <uapi/drm/drm_fourcc.h>
 #include <drm/drm_modeset_lock.h>
 
 struct drm_device;
-- 
2.1.0

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

* [PATCH 15/20] drm: simplify drm_*_set_unique()
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (13 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 14/20] drm: move remaining includes in drmP.h to the top David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:39   ` Thierry Reding
  2014-08-29 12:58   ` Daniel Vetter
  2014-08-29 10:12 ` [PATCH 16/20] drm: drop unused drm_master->unique_size David Herrmann
                   ` (5 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Lets use kasprintf() to avoid pre-allocating the buffer. This is really
nothing to optimize for speed and the input is trusted, so kasprintf() is
just fine.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_pci.c      | 30 ++++++++----------------------
 drivers/gpu/drm/drm_platform.c | 31 ++++++++-----------------------
 2 files changed, 16 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 020cfd9..8efea6b 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -129,31 +129,17 @@ static int drm_get_pci_domain(struct drm_device *dev)
 
 static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 {
-	int len, ret;
-	master->unique_len = 40;
-	master->unique_size = master->unique_len;
-	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
-	if (master->unique == NULL)
+	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
+					drm_get_pci_domain(dev),
+					dev->pdev->bus->number,
+					PCI_SLOT(dev->pdev->devfn),
+					PCI_FUNC(dev->pdev->devfn));
+	if (!master->unique)
 		return -ENOMEM;
 
-
-	len = snprintf(master->unique, master->unique_len,
-		       "pci:%04x:%02x:%02x.%d",
-		       drm_get_pci_domain(dev),
-		       dev->pdev->bus->number,
-		       PCI_SLOT(dev->pdev->devfn),
-		       PCI_FUNC(dev->pdev->devfn));
-
-	if (len >= master->unique_len) {
-		DRM_ERROR("buffer overflow");
-		ret = -EINVAL;
-		goto err;
-	} else
-		master->unique_len = len;
-
+	master->unique_len = strlen(master->unique);
+	master->unique_size = master->unique_len + 1;
 	return 0;
-err:
-	return ret;
 }
 
 int drm_pci_set_unique(struct drm_device *dev,
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index d5b76f1..0c09ddd 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -70,35 +70,20 @@ err_free:
 
 static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
 {
-	int len, ret, id;
-
-	master->unique_len = 13 + strlen(dev->platformdev->name);
-	master->unique_size = master->unique_len;
-	master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
-
-	if (master->unique == NULL)
-		return -ENOMEM;
+	int id;
 
 	id = dev->platformdev->id;
-
-	/* if only a single instance of the platform device, id will be
-	 * set to -1.. use 0 instead to avoid a funny looking bus-id:
-	 */
-	if (id == -1)
+	if (id < 0)
 		id = 0;
 
-	len = snprintf(master->unique, master->unique_len,
-			"platform:%s:%02d", dev->platformdev->name, id);
-
-	if (len > master->unique_len) {
-		DRM_ERROR("Unique buffer overflowed\n");
-		ret = -EINVAL;
-		goto err;
-	}
+	master->unique = kasprintf(GFP_KERNEL, "platform:%s:%02d",
+						dev->platformdev->name, id);
+	if (!master->unique)
+		return -ENOMEM;
 
+	master->unique_len = strlen(master->unique);
+	master->unique_size = master->unique_len;
 	return 0;
-err:
-	return ret;
 }
 
 static struct drm_bus drm_platform_bus = {
-- 
2.1.0

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

* [PATCH 16/20] drm: drop unused drm_master->unique_size
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (14 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 15/20] drm: simplify drm_*_set_unique() David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:41   ` Thierry Reding
  2014-08-29 12:58   ` Daniel Vetter
  2014-08-29 10:12 ` [PATCH 17/20] drm: add driver->set_busid() callback David Herrmann
                   ` (4 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

This field is unused and there is really no reason to optimize
unique-allocations. Drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_ioctl.c    | 1 -
 drivers/gpu/drm/drm_pci.c      | 4 +---
 drivers/gpu/drm/drm_platform.c | 1 -
 include/drm/drmP.h             | 2 --
 4 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index aa1ac79..cb6b54a 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -189,7 +189,6 @@ drm_unset_busid(struct drm_device *dev,
 	kfree(master->unique);
 	master->unique = NULL;
 	master->unique_len = 0;
-	master->unique_size = 0;
 }
 
 /**
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 8efea6b..e266927 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -138,7 +138,6 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 		return -ENOMEM;
 
 	master->unique_len = strlen(master->unique);
-	master->unique_size = master->unique_len + 1;
 	return 0;
 }
 
@@ -149,8 +148,7 @@ int drm_pci_set_unique(struct drm_device *dev,
 	int domain, bus, slot, func, ret;
 
 	master->unique_len = u->unique_len;
-	master->unique_size = u->unique_len + 1;
-	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
+	master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
 	if (!master->unique) {
 		ret = -ENOMEM;
 		goto err;
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 0c09ddd..f197a2b 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -82,7 +82,6 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas
 		return -ENOMEM;
 
 	master->unique_len = strlen(master->unique);
-	master->unique_size = master->unique_len;
 	return 0;
 }
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a8b24fc..98b1eaf 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -574,7 +574,6 @@ struct drm_gem_object {
  * @minor: Link back to minor char device we are master for. Immutable.
  * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
  * @unique_len: Length of unique field. Protected by drm_global_mutex.
- * @unique_size: Amount allocated. Protected by drm_global_mutex.
  * @magiclist: Hash of used authentication tokens. Protected by struct_mutex.
  * @magicfree: List of used authentication tokens. Protected by struct_mutex.
  * @lock: DRI lock information.
@@ -585,7 +584,6 @@ struct drm_master {
 	struct drm_minor *minor;
 	char *unique;
 	int unique_len;
-	int unique_size;
 	struct drm_open_hash magiclist;
 	struct list_head magicfree;
 	struct drm_lock_data lock;
-- 
2.1.0

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

* [PATCH 17/20] drm: add driver->set_busid() callback
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (15 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 16/20] drm: drop unused drm_master->unique_size David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:54   ` Thierry Reding
  2014-08-29 13:01   ` Daniel Vetter
  2014-08-29 10:12 ` [PATCH 18/20] drm: Goody bye, drm_bus! David Herrmann
                   ` (3 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

One step closer to dropping all the drm_bus_* code:
Add a driver->set_busid() callback and make all drivers use the generic
helpers. Nouveau is the only driver that uses two different bus-types with
the same drm_driver. This is totally broken if both buses are available on
the same machine (unlikely, but lets be safe). Therefore, we create two
different drivers for each platform during module_init() and set the
set_busid() callback respectively.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/armada/armada_drv.c      |  1 +
 drivers/gpu/drm/ast/ast_drv.c            |  1 +
 drivers/gpu/drm/bochs/bochs_drv.c        |  1 +
 drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 +
 drivers/gpu/drm/drm_ioctl.c              |  8 +++++++-
 drivers/gpu/drm/drm_pci.c                |  3 ++-
 drivers/gpu/drm/drm_platform.c           |  3 ++-
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  1 +
 drivers/gpu/drm/gma500/psb_drv.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/msm/msm_drv.c            |  1 +
 drivers/gpu/drm/nouveau/nouveau_drm.c    | 19 +++++++++++++------
 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            |  6 ++++++
 drivers/gpu/drm/via/via_drv.c            |  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 +
 drivers/staging/imx-drm/imx-drm-core.c   |  1 +
 include/drm/drmP.h                       |  3 +++
 30 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index e2d5792..f672e6a 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -308,6 +308,7 @@ static struct drm_driver armada_drm_driver = {
 	.postclose		= NULL,
 	.lastclose		= armada_drm_lastclose,
 	.unload			= armada_drm_unload,
+	.set_busid		= drm_platform_set_busid,
 	.get_vblank_counter	= drm_vblank_count,
 	.enable_vblank		= armada_drm_enable_vblank,
 	.disable_vblank		= armada_drm_disable_vblank,
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index f19682a..9a32d9d 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -199,6 +199,7 @@ static struct drm_driver driver = {
 
 	.load = ast_driver_load,
 	.unload = ast_driver_unload,
+	.set_busid = drm_pci_set_busid,
 
 	.fops = &ast_fops,
 	.name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
index 9738e9b..98837bd 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -82,6 +82,7 @@ static struct drm_driver bochs_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
 	.load			= bochs_load,
 	.unload			= bochs_unload,
+	.set_busid		= drm_pci_set_busid,
 	.fops			= &bochs_fops,
 	.name			= "bochs-drm",
 	.desc			= "bochs dispi vga interface (qemu stdvga)",
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 919c73b..e705335 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -128,6 +128,7 @@ static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM,
 	.load = cirrus_driver_load,
 	.unload = cirrus_driver_unload,
+	.set_busid = drm_pci_set_busid,
 	.fops = &cirrus_driver_fops,
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index cb6b54a..4770bd7 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -244,7 +244,13 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
 	if (master->unique != NULL)
 		drm_unset_busid(dev, master);
 
-	if (dev->driver->bus && dev->driver->bus->set_busid) {
+	if (dev->driver->set_busid) {
+		ret = dev->driver->set_busid(dev, master);
+		if (ret) {
+			drm_unset_busid(dev, master);
+			return ret;
+		}
+	} else if (dev->driver->bus && dev->driver->bus->set_busid) {
 		ret = dev->driver->bus->set_busid(dev, master);
 		if (ret) {
 			drm_unset_busid(dev, master);
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index e266927..0400c37 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -127,7 +127,7 @@ static int drm_get_pci_domain(struct drm_device *dev)
 	return pci_domain_nr(dev->pdev->bus);
 }
 
-static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
+int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 {
 	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
 					drm_get_pci_domain(dev),
@@ -140,6 +140,7 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
 	master->unique_len = strlen(master->unique);
 	return 0;
 }
+EXPORT_SYMBOL(drm_pci_set_busid);
 
 int drm_pci_set_unique(struct drm_device *dev,
 		       struct drm_master *master,
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index f197a2b..939cd22 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -68,7 +68,7 @@ err_free:
 	return ret;
 }
 
-static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
+int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
 {
 	int id;
 
@@ -84,6 +84,7 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas
 	master->unique_len = strlen(master->unique);
 	return 0;
 }
+EXPORT_SYMBOL(drm_platform_set_busid);
 
 static struct drm_bus drm_platform_bus = {
 	.set_busid = drm_platform_set_busid,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 0d74e9b..5aae95c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -330,6 +330,7 @@ static struct drm_driver exynos_drm_driver = {
 	.preclose		= exynos_drm_preclose,
 	.lastclose		= exynos_drm_lastclose,
 	.postclose		= exynos_drm_postclose,
+	.set_busid		= drm_platform_set_busid,
 	.get_vblank_counter	= drm_vblank_count,
 	.enable_vblank		= exynos_drm_crtc_enable_vblank,
 	.disable_vblank		= exynos_drm_crtc_disable_vblank,
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index eec993f..6ec3a90 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -476,6 +476,7 @@ static struct drm_driver driver = {
 	.unload = psb_driver_unload,
 	.lastclose = psb_driver_lastclose,
 	.preclose = psb_driver_preclose,
+	.set_busid = drm_pci_set_busid,
 
 	.num_ioctls = ARRAY_SIZE(psb_ioctls),
 	.device_is_agp = psb_driver_device_is_agp,
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 441ccf8..6cb08a1 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -63,6 +63,7 @@ static struct drm_driver driver = {
 	.load = i810_driver_load,
 	.lastclose = i810_driver_lastclose,
 	.preclose = i810_driver_preclose,
+	.set_busid = drm_pci_set_busid,
 	.device_is_agp = i810_driver_device_is_agp,
 	.dma_quiescent = i810_driver_dma_quiescent,
 	.ioctls = i810_ioctls,
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index e27cdbe..fa188b4 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1572,6 +1572,7 @@ static struct drm_driver driver = {
 	.lastclose = i915_driver_lastclose,
 	.preclose = i915_driver_preclose,
 	.postclose = i915_driver_postclose,
+	.set_busid = drm_pci_set_busid,
 
 	/* Used in place of i915_pm_ops for non-DRIVER_MODESET */
 	.suspend = i915_suspend,
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 6b1a87c..cb5c71f 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -64,6 +64,7 @@ static struct drm_driver driver = {
 	.load = mga_driver_load,
 	.unload = mga_driver_unload,
 	.lastclose = mga_driver_lastclose,
+	.set_busid = drm_pci_set_busid,
 	.dma_quiescent = mga_driver_dma_quiescent,
 	.device_is_agp = mga_driver_device_is_agp,
 	.get_vblank_counter = mga_get_vblank_counter,
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 2d75d6d..9774599 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -91,6 +91,7 @@ static struct drm_driver driver = {
 	.driver_features = DRIVER_GEM | DRIVER_MODESET,
 	.load = mgag200_driver_load,
 	.unload = mgag200_driver_unload,
+	.set_busid = drm_pci_set_busid,
 	.fops = &mgag200_driver_fops,
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index b447c01..47ccdbf 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -836,6 +836,7 @@ static struct drm_driver msm_driver = {
 	.open               = msm_open,
 	.preclose           = msm_preclose,
 	.lastclose          = msm_lastclose,
+	.set_busid          = drm_platform_set_busid,
 	.irq_handler        = msm_irq,
 	.irq_preinstall     = msm_irq_preinstall,
 	.irq_postinstall    = msm_irq_postinstall,
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 250a5e8..cee1eaf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -73,7 +73,9 @@ MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1
 int nouveau_runtime_pm = -1;
 module_param_named(runpm, nouveau_runtime_pm, int, 0400);
 
-static struct drm_driver driver;
+static struct drm_driver driver_stub;
+static struct drm_driver driver_pci;
+static struct drm_driver driver_platform;
 
 static u64
 nouveau_pci_name(struct pci_dev *pdev)
@@ -322,7 +324,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 
 	pci_set_master(pdev);
 
-	ret = drm_get_pci_dev(pdev, pent, &driver);
+	ret = drm_get_pci_dev(pdev, pent, &driver_pci);
 	if (ret) {
 		nouveau_object_ref(NULL, (struct nouveau_object **)&device);
 		return ret;
@@ -855,7 +857,7 @@ nouveau_driver_fops = {
 };
 
 static struct drm_driver
-driver = {
+driver_stub = {
 	.driver_features =
 		DRIVER_USE_AGP |
 		DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
@@ -1061,7 +1063,7 @@ nouveau_platform_device_create_(struct platform_device *pdev, int size,
 	if (err)
 		return ERR_PTR(err);
 
-	drm = drm_dev_alloc(&driver, &pdev->dev);
+	drm = drm_dev_alloc(&driver_platform, &pdev->dev);
 	if (!drm) {
 		err = -ENOMEM;
 		goto err_free;
@@ -1086,6 +1088,11 @@ EXPORT_SYMBOL(nouveau_platform_device_create_);
 static int __init
 nouveau_drm_init(void)
 {
+	driver_pci = driver_stub;
+	driver_pci.set_busid = drm_pci_set_busid;
+	driver_platform = driver_stub;
+	driver_platform.set_busid = drm_platform_set_busid;
+
 	if (nouveau_modeset == -1) {
 #ifdef CONFIG_VGA_CONSOLE
 		if (vgacon_text_force())
@@ -1097,7 +1104,7 @@ nouveau_drm_init(void)
 		return 0;
 
 	nouveau_register_dsm_handler();
-	return drm_pci_init(&driver, &nouveau_drm_pci_driver);
+	return drm_pci_init(&driver_pci, &nouveau_drm_pci_driver);
 }
 
 static void __exit
@@ -1106,7 +1113,7 @@ nouveau_drm_exit(void)
 	if (!nouveau_modeset)
 		return;
 
-	drm_pci_exit(&driver, &nouveau_drm_pci_driver);
+	drm_pci_exit(&driver_pci, &nouveau_drm_pci_driver);
 	nouveau_unregister_dsm_handler();
 }
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 002b972..862ba03 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -629,6 +629,7 @@ static struct drm_driver omap_drm_driver = {
 		.lastclose = dev_lastclose,
 		.preclose = dev_preclose,
 		.postclose = dev_postclose,
+		.set_busid = drm_platform_set_busid,
 		.get_vblank_counter = drm_vblank_count,
 		.enable_vblank = omap_irq_enable_vblank,
 		.disable_vblank = omap_irq_disable_vblank,
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index a3fd920..ab9a1e3 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -216,6 +216,7 @@ static struct drm_driver qxl_driver = {
 			   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
 	.load = qxl_driver_load,
 	.unload = qxl_driver_unload,
+	.set_busid = drm_pci_set_busid,
 
 	.dumb_create = qxl_mode_dumb_create,
 	.dumb_map_offset = qxl_mode_dumb_mmap,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 5bd307c..4a59370 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -62,6 +62,7 @@ static struct drm_driver driver = {
 	.load = r128_driver_load,
 	.preclose = r128_driver_preclose,
 	.lastclose = r128_driver_lastclose,
+	.set_busid = drm_pci_set_busid,
 	.get_vblank_counter = r128_get_vblank_counter,
 	.enable_vblank = r128_enable_vblank,
 	.disable_vblank = r128_disable_vblank,
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index f1e96e0..ec7e963 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -328,6 +328,7 @@ static struct drm_driver driver_old = {
 	.preclose = radeon_driver_preclose,
 	.postclose = radeon_driver_postclose,
 	.lastclose = radeon_driver_lastclose,
+	.set_busid = drm_pci_set_busid,
 	.unload = radeon_driver_unload,
 	.suspend = radeon_suspend,
 	.resume = radeon_resume,
@@ -551,6 +552,7 @@ static struct drm_driver kms_driver = {
 	.preclose = radeon_driver_preclose_kms,
 	.postclose = radeon_driver_postclose_kms,
 	.lastclose = radeon_driver_lastclose_kms,
+	.set_busid = drm_pci_set_busid,
 	.unload = radeon_driver_unload_kms,
 	.get_vblank_counter = radeon_get_vblank_counter_kms,
 	.enable_vblank = radeon_enable_vblank_kms,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index fda64b7..672d2fc 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -158,6 +158,7 @@ static struct drm_driver rcar_du_driver = {
 	.unload			= rcar_du_unload,
 	.preclose		= rcar_du_preclose,
 	.lastclose		= rcar_du_lastclose,
+	.set_busid		= drm_platform_set_busid,
 	.get_vblank_counter	= drm_vblank_count,
 	.enable_vblank		= rcar_du_enable_vblank,
 	.disable_vblank		= rcar_du_disable_vblank,
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 3c03021..1b09d21 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -57,6 +57,7 @@ static struct drm_driver driver = {
 	.preclose = savage_reclaim_buffers,
 	.lastclose = savage_driver_lastclose,
 	.unload = savage_driver_unload,
+	.set_busid = drm_pci_set_busid,
 	.ioctls = savage_ioctls,
 	.dma_ioctl = savage_bci_buffers,
 	.fops = &savage_driver_fops,
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index ff4ba48..873d12f 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -267,6 +267,7 @@ static struct drm_driver shmob_drm_driver = {
 	.load			= shmob_drm_load,
 	.unload			= shmob_drm_unload,
 	.preclose		= shmob_drm_preclose,
+	.set_busid		= drm_platform_set_busid,
 	.irq_handler		= shmob_drm_irq,
 	.get_vblank_counter	= drm_vblank_count,
 	.enable_vblank		= shmob_drm_enable_vblank,
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 756f787..54858e6 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -108,6 +108,7 @@ static struct drm_driver driver = {
 	.open = sis_driver_open,
 	.preclose = sis_reclaim_buffers_locked,
 	.postclose = sis_driver_postclose,
+	.set_busid = drm_pci_set_busid,
 	.dma_quiescent = sis_idle,
 	.lastclose = sis_lastclose,
 	.ioctls = sis_ioctls,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 3492ca5..df533ff 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -55,6 +55,7 @@ static const struct file_operations tdfx_driver_fops = {
 };
 
 static struct drm_driver driver = {
+	.set_busid = drm_pci_set_busid,
 	.fops = &tdfx_driver_fops,
 	.name = DRIVER_NAME,
 	.desc = DRIVER_DESC,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 6be623b..aea4b766 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -502,6 +502,7 @@ static struct drm_driver tilcdc_driver = {
 	.unload             = tilcdc_unload,
 	.preclose           = tilcdc_preclose,
 	.lastclose          = tilcdc_lastclose,
+	.set_busid          = drm_platform_set_busid,
 	.irq_handler        = tilcdc_irq,
 	.irq_preinstall     = tilcdc_irq_preinstall,
 	.irq_postinstall    = tilcdc_irq_postinstall,
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 3ddd6cd..06675e5 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -34,6 +34,11 @@ MODULE_DEVICE_TABLE(usb, id_table);
 
 MODULE_LICENSE("GPL");
 
+static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m)
+{
+	return 0;
+}
+
 static int udl_usb_probe(struct usb_interface *interface,
 			 const struct usb_device_id *id)
 {
@@ -75,6 +80,7 @@ static struct drm_driver driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
 	.load = udl_driver_load,
 	.unload = udl_driver_unload,
+	.set_busid = udl_driver_set_busid,
 
 	/* gem hooks */
 	.gem_free_object = udl_gem_free_object,
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 50abc2a..c16ffa6 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -79,6 +79,7 @@ static struct drm_driver driver = {
 	.open = via_driver_open,
 	.preclose = via_reclaim_buffers_locked,
 	.postclose = via_driver_postclose,
+	.set_busid = drm_pci_set_busid,
 	.context_dtor = via_final_context,
 	.get_vblank_counter = via_get_vblank_counter,
 	.enable_vblank = via_enable_vblank,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 18b54ac..7197af1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1418,6 +1418,7 @@ static struct drm_driver driver = {
 	.open = vmw_driver_open,
 	.preclose = vmw_preclose,
 	.postclose = vmw_postclose,
+	.set_busid = drm_pci_set_busid,
 
 	.dumb_create = vmw_dumb_create,
 	.dumb_map_offset = vmw_dumb_map_offset,
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 6b22106..16392b6 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -528,6 +528,7 @@ static struct drm_driver imx_drm_driver = {
 	.unload			= imx_drm_driver_unload,
 	.lastclose		= imx_drm_driver_lastclose,
 	.preclose		= imx_drm_driver_preclose,
+	.set_busid		= drm_platform_set_busid,
 	.gem_free_object	= drm_gem_cma_free_object,
 	.gem_vm_ops		= &drm_gem_cma_vm_ops,
 	.dumb_create		= drm_gem_cma_dumb_create,
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 98b1eaf..c82f292 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -627,6 +627,7 @@ struct drm_driver {
 	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
 	int (*dma_quiescent) (struct drm_device *);
 	int (*context_dtor) (struct drm_device *dev, int context);
+	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
 
 	/**
 	 * get_vblank_counter - get raw hardware vblank counter
@@ -1498,6 +1499,7 @@ extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
 extern int drm_get_pci_dev(struct pci_dev *pdev,
 			   const struct pci_device_id *ent,
 			   struct drm_driver *driver);
+extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
 
 #define DRM_PCIE_SPEED_25 1
 #define DRM_PCIE_SPEED_50 2
@@ -1507,6 +1509,7 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
 
 /* platform section */
 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
+extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
 
 /* returns true if currently okay to sleep */
 static __inline__ bool drm_can_sleep(void)
-- 
2.1.0

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

* [PATCH 18/20] drm: Goody bye, drm_bus!
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (16 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 17/20] drm: add driver->set_busid() callback David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 12:55   ` Thierry Reding
  2014-08-29 13:02   ` Daniel Vetter
  2014-08-29 10:12 ` [PATCH 19/20] drm: merge drm_usb into udl David Herrmann
                   ` (2 subsequent siblings)
  20 siblings, 2 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

..we will not miss you..

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_ioctl.c    |  8 +-------
 drivers/gpu/drm/drm_pci.c      |  6 ------
 drivers/gpu/drm/drm_platform.c |  5 -----
 drivers/gpu/drm/drm_usb.c      | 12 ------------
 include/drm/drmP.h             |  5 -----
 5 files changed, 1 insertion(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 4770bd7..3a1349f 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -250,15 +250,9 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
 			drm_unset_busid(dev, master);
 			return ret;
 		}
-	} else if (dev->driver->bus && dev->driver->bus->set_busid) {
-		ret = dev->driver->bus->set_busid(dev, master);
-		if (ret) {
-			drm_unset_busid(dev, master);
-			return ret;
-		}
 	} else {
 		if (WARN(dev->unique == NULL,
-			 "No drm_bus.set_busid() implementation provided by "
+			 "No drm_driver.set_busid() implementation provided by "
 			 "%ps. Use drm_dev_set_unique() to set the unique "
 			 "name explicitly.", dev->driver))
 			return -EINVAL;
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 0400c37..7563130 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -254,10 +254,6 @@ void drm_pci_agp_destroy(struct drm_device *dev)
 	}
 }
 
-static struct drm_bus drm_pci_bus = {
-	.set_busid = drm_pci_set_busid,
-};
-
 /**
  * drm_get_pci_dev - Register a PCI device with the DRM subsystem
  * @pdev: PCI device
@@ -338,8 +334,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
 
 	DRM_DEBUG("\n");
 
-	driver->bus = &drm_pci_bus;
-
 	if (driver->driver_features & DRIVER_MODESET)
 		return pci_register_driver(pdriver);
 
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 939cd22..5314c9d 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -86,10 +86,6 @@ int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
 }
 EXPORT_SYMBOL(drm_platform_set_busid);
 
-static struct drm_bus drm_platform_bus = {
-	.set_busid = drm_platform_set_busid,
-};
-
 /**
  * drm_platform_init - Register a platform device with the DRM subsystem
  * @driver: DRM device driver
@@ -105,7 +101,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor
 {
 	DRM_DEBUG("\n");
 
-	driver->bus = &drm_platform_bus;
 	return drm_get_platform_dev(platform_device, driver);
 }
 EXPORT_SYMBOL(drm_platform_init);
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index f2fe94a..9c43490 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -36,16 +36,6 @@ err_free:
 }
 EXPORT_SYMBOL(drm_get_usb_dev);
 
-static int drm_usb_set_busid(struct drm_device *dev,
-			       struct drm_master *master)
-{
-	return 0;
-}
-
-static struct drm_bus drm_usb_bus = {
-	.set_busid = drm_usb_set_busid,
-};
-
 /**
  * drm_usb_init - Register matching USB devices with the DRM subsystem
  * @driver: DRM device driver
@@ -61,8 +51,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
 	int res;
 	DRM_DEBUG("\n");
 
-	driver->bus = &drm_usb_bus;
-
 	res = usb_register(udriver);
 	return res;
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c82f292..5ae388a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -605,10 +605,6 @@ struct drm_master {
 #define DRM_SCANOUTPOS_INVBL        (1 << 1)
 #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
 
-struct drm_bus {
-	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
-};
-
 /**
  * DRM driver structure. This structure represent the common code for
  * a family of cards. There will one drm_device for each card present
@@ -846,7 +842,6 @@ struct drm_driver {
 	const struct drm_ioctl_desc *ioctls;
 	int num_ioctls;
 	const struct file_operations *fops;
-	struct drm_bus *bus;
 
 	/* List of devices hanging off this driver with stealth attach. */
 	struct list_head legacy_dev_list;
-- 
2.1.0

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

* [PATCH 19/20] drm: merge drm_usb into udl
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (17 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 18/20] drm: Goody bye, drm_bus! David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 13:00   ` Thierry Reding
  2014-08-29 13:06   ` Daniel Vetter
  2014-08-29 10:12 ` [PATCH 20/20] drm: move drm-lock API to drm_legacy.h David Herrmann
  2014-08-29 13:08 ` [PATCH 00/20] DRM: Core Cleanups Daniel Vetter
  20 siblings, 2 replies; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

This merges all the remains of drm_usb into its only user, udl. We can
then drop all the drm_usb stuff, including dev->usbdev.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 Documentation/DocBook/drm.tmpl      |   3 +-
 drivers/gpu/drm/Kconfig             |   6 ---
 drivers/gpu/drm/Makefile            |   3 --
 drivers/gpu/drm/drm_usb.c           |  76 ---------------------------
 drivers/gpu/drm/udl/Kconfig         |   3 +-
 drivers/gpu/drm/udl/udl_connector.c |   4 +-
 drivers/gpu/drm/udl/udl_drv.c       | 102 +++++++++++++++++++++---------------
 drivers/gpu/drm/udl/udl_drv.h       |   1 +
 drivers/gpu/drm/udl/udl_main.c      |   8 +--
 include/drm/drmP.h                  |   1 -
 include/drm/drm_usb.h               |  15 ------
 11 files changed, 70 insertions(+), 152 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_usb.c
 delete mode 100644 include/drm/drm_usb.h

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 5c299fa..99f7ee6 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -291,10 +291,9 @@ char *date;</synopsis>
       <title>Device Registration</title>
       <para>
         A number of functions are provided to help with device registration.
-        The functions deal with PCI, USB and platform devices, respectively.
+        The functions deal with PCI and platform devices, respectively.
       </para>
 !Edrivers/gpu/drm/drm_pci.c
-!Edrivers/gpu/drm/drm_usb.c
 !Edrivers/gpu/drm/drm_platform.c
       <para>
         New drivers that no longer rely on the services provided by the
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index e3500f9..e3b4b0f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -25,12 +25,6 @@ config DRM_MIPI_DSI
 	bool
 	depends on DRM
 
-config DRM_USB
-	tristate
-	depends on DRM
-	depends on USB_SUPPORT && USB_ARCH_HAS_HCD
-	select USB
-
 config DRM_KMS_HELPER
 	tristate
 	depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 9b7cb3f..9292a76 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -22,8 +22,6 @@ drm-$(CONFIG_PCI) += ati_pcigart.o
 drm-$(CONFIG_DRM_PANEL) += drm_panel.o
 drm-$(CONFIG_OF) += drm_of.o
 
-drm-usb-y   := drm_usb.o
-
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
 		drm_plane_helper.o drm_dp_mst_topology.o
 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
@@ -36,7 +34,6 @@ CFLAGS_drm_trace_points.o := -I$(src)
 
 obj-$(CONFIG_DRM)	+= drm.o
 obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
-obj-$(CONFIG_DRM_USB)   += drm_usb.o
 obj-$(CONFIG_DRM_TTM)	+= ttm/
 obj-$(CONFIG_DRM_TDFX)	+= tdfx/
 obj-$(CONFIG_DRM_R128)	+= r128/
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
deleted file mode 100644
index 9c43490..0000000
--- a/drivers/gpu/drm/drm_usb.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#include <drm/drmP.h>
-#include <drm/drm_usb.h>
-#include <linux/usb.h>
-#include <linux/module.h>
-
-int drm_get_usb_dev(struct usb_interface *interface,
-		    const struct usb_device_id *id,
-		    struct drm_driver *driver)
-{
-	struct drm_device *dev;
-	int ret;
-
-	DRM_DEBUG("\n");
-
-	dev = drm_dev_alloc(driver, &interface->dev);
-	if (!dev)
-		return -ENOMEM;
-
-	dev->usbdev = interface_to_usbdev(interface);
-	usb_set_intfdata(interface, dev);
-
-	ret = drm_dev_register(dev, 0);
-	if (ret)
-		goto err_free;
-
-	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
-		 driver->name, driver->major, driver->minor, driver->patchlevel,
-		 driver->date, dev->primary->index);
-
-	return 0;
-
-err_free:
-	drm_dev_unref(dev);
-	return ret;
-
-}
-EXPORT_SYMBOL(drm_get_usb_dev);
-
-/**
- * drm_usb_init - Register matching USB devices with the DRM subsystem
- * @driver: DRM device driver
- * @udriver: USB device driver
- *
- * Registers one or more devices matched by a USB driver with the DRM
- * subsystem.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
-{
-	int res;
-	DRM_DEBUG("\n");
-
-	res = usb_register(udriver);
-	return res;
-}
-EXPORT_SYMBOL(drm_usb_init);
-
-/**
- * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
- * @driver: DRM device driver
- * @udriver: USB device driver
- *
- * Unregisters one or more devices matched by a USB driver from the DRM
- * subsystem.
- */
-void drm_usb_exit(struct drm_driver *driver,
-		  struct usb_driver *udriver)
-{
-	usb_deregister(udriver);
-}
-EXPORT_SYMBOL(drm_usb_exit);
-
-MODULE_AUTHOR("David Airlie");
-MODULE_DESCRIPTION("USB DRM support");
-MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/gpu/drm/udl/Kconfig b/drivers/gpu/drm/udl/Kconfig
index f025286..613ab06 100644
--- a/drivers/gpu/drm/udl/Kconfig
+++ b/drivers/gpu/drm/udl/Kconfig
@@ -1,8 +1,9 @@
 config DRM_UDL
 	tristate "DisplayLink"
 	depends on DRM
+	depends on USB_SUPPORT
 	depends on USB_ARCH_HAS_HCD
-	select DRM_USB
+	select USB
 	select FB_SYS_FILLRECT
 	select FB_SYS_COPYAREA
 	select FB_SYS_IMAGEBLIT
diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index e026a9e..0110d95 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -34,8 +34,8 @@ static u8 *udl_get_edid(struct udl_device *udl)
 		goto error;
 
 	for (i = 0; i < EDID_LENGTH; i++) {
-		ret = usb_control_msg(udl->ddev->usbdev,
-				      usb_rcvctrlpipe(udl->ddev->usbdev, 0), (0x02),
+		ret = usb_control_msg(udl->udev,
+				      usb_rcvctrlpipe(udl->udev, 0), (0x02),
 				      (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2,
 				      HZ);
 		if (ret < 1) {
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 06675e5..8607e9e 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -7,55 +7,15 @@
  */
 
 #include <linux/module.h>
-#include <drm/drm_usb.h>
+#include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include "udl_drv.h"
 
-static struct drm_driver driver;
-
-/*
- * There are many DisplayLink-based graphics products, all with unique PIDs.
- * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
- * We also require a match on SubClass (0x00) and Protocol (0x00),
- * which is compatible with all known USB 2.0 era graphics chips and firmware,
- * but allows DisplayLink to increment those for any future incompatible chips
- */
-static struct usb_device_id id_table[] = {
-	{.idVendor = 0x17e9, .bInterfaceClass = 0xff,
-	 .bInterfaceSubClass = 0x00,
-	 .bInterfaceProtocol = 0x00,
-	 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
-			USB_DEVICE_ID_MATCH_INT_CLASS |
-			USB_DEVICE_ID_MATCH_INT_SUBCLASS |
-			USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
-	{},
-};
-MODULE_DEVICE_TABLE(usb, id_table);
-
-MODULE_LICENSE("GPL");
-
 static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m)
 {
 	return 0;
 }
 
-static int udl_usb_probe(struct usb_interface *interface,
-			 const struct usb_device_id *id)
-{
-	return drm_get_usb_dev(interface, id, &driver);
-}
-
-static void udl_usb_disconnect(struct usb_interface *interface)
-{
-	struct drm_device *dev = usb_get_intfdata(interface);
-
-	drm_kms_helper_poll_disable(dev);
-	drm_connector_unplug_all(dev);
-	udl_fbdev_unplug(dev);
-	udl_drop_usb(dev);
-	drm_unplug_dev(dev);
-}
-
 static const struct vm_operations_struct udl_gem_vm_ops = {
 	.fault = udl_gem_fault,
 	.open = drm_gem_vm_open,
@@ -102,6 +62,61 @@ static struct drm_driver driver = {
 	.patchlevel = DRIVER_PATCHLEVEL,
 };
 
+static int udl_usb_probe(struct usb_interface *interface,
+			 const struct usb_device_id *id)
+{
+	struct usb_device *udev = interface_to_usbdev(interface);
+	struct drm_device *dev;
+	int r;
+
+	dev = drm_dev_alloc(&driver, &interface->dev);
+	if (!dev)
+		return -ENOMEM;
+
+	r = drm_dev_register(dev, (unsigned long)udev);
+	if (r)
+		goto err_free;
+
+	usb_set_intfdata(interface, dev);
+	DRM_INFO("Initialized udl on minor %d\n", dev->primary->index);
+
+	return 0;
+
+err_free:
+	drm_dev_unref(dev);
+	return r;
+}
+
+static void udl_usb_disconnect(struct usb_interface *interface)
+{
+	struct drm_device *dev = usb_get_intfdata(interface);
+
+	drm_kms_helper_poll_disable(dev);
+	drm_connector_unplug_all(dev);
+	udl_fbdev_unplug(dev);
+	udl_drop_usb(dev);
+	drm_unplug_dev(dev);
+}
+
+/*
+ * There are many DisplayLink-based graphics products, all with unique PIDs.
+ * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
+ * We also require a match on SubClass (0x00) and Protocol (0x00),
+ * which is compatible with all known USB 2.0 era graphics chips and firmware,
+ * but allows DisplayLink to increment those for any future incompatible chips
+ */
+static struct usb_device_id id_table[] = {
+	{.idVendor = 0x17e9, .bInterfaceClass = 0xff,
+	 .bInterfaceSubClass = 0x00,
+	 .bInterfaceProtocol = 0x00,
+	 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
+			USB_DEVICE_ID_MATCH_INT_CLASS |
+			USB_DEVICE_ID_MATCH_INT_SUBCLASS |
+			USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
+	{},
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
 static struct usb_driver udl_driver = {
 	.name = "udl",
 	.probe = udl_usb_probe,
@@ -111,13 +126,14 @@ static struct usb_driver udl_driver = {
 
 static int __init udl_init(void)
 {
-	return drm_usb_init(&driver, &udl_driver);
+	return usb_register(&udl_driver);
 }
 
 static void __exit udl_exit(void)
 {
-	drm_usb_exit(&driver, &udl_driver);
+	usb_deregister(&udl_driver);
 }
 
 module_init(udl_init);
 module_exit(udl_exit);
+MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 1fbf7b3..51e10ee 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -47,6 +47,7 @@ struct udl_fbdev;
 struct udl_device {
 	struct device *dev;
 	struct drm_device *ddev;
+	struct usb_device *udev;
 
 	int sku_pixel_limit;
 
diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
index 4279567..33dbfb2 100644
--- a/drivers/gpu/drm/udl/udl_main.c
+++ b/drivers/gpu/drm/udl/udl_main.c
@@ -202,7 +202,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
 		}
 		unode->urb = urb;
 
-		buf = usb_alloc_coherent(udl->ddev->usbdev, MAX_TRANSFER, GFP_KERNEL,
+		buf = usb_alloc_coherent(udl->udev, MAX_TRANSFER, GFP_KERNEL,
 					 &urb->transfer_dma);
 		if (!buf) {
 			kfree(unode);
@@ -211,7 +211,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
 		}
 
 		/* urb->transfer_buffer_length set to actual before submit */
-		usb_fill_bulk_urb(urb, udl->ddev->usbdev, usb_sndbulkpipe(udl->ddev->usbdev, 1),
+		usb_fill_bulk_urb(urb, udl->udev, usb_sndbulkpipe(udl->udev, 1),
 			buf, size, udl_urb_completion, unode);
 		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 
@@ -282,6 +282,7 @@ int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len)
 
 int udl_driver_load(struct drm_device *dev, unsigned long flags)
 {
+	struct usb_device *udev = (void*)flags;
 	struct udl_device *udl;
 	int ret = -ENOMEM;
 
@@ -290,10 +291,11 @@ int udl_driver_load(struct drm_device *dev, unsigned long flags)
 	if (!udl)
 		return -ENOMEM;
 
+	udl->udev = udev;
 	udl->ddev = dev;
 	dev->dev_private = udl;
 
-	if (!udl_parse_vendor_descriptor(dev, dev->usbdev)) {
+	if (!udl_parse_vendor_descriptor(dev, udl->udev)) {
 		ret = -ENODEV;
 		DRM_ERROR("firmware not recognized. Assume incompatible device\n");
 		goto err;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 5ae388a..0e73aad 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1020,7 +1020,6 @@ struct drm_device {
 #endif
 
 	struct platform_device *platformdev; /**< Platform device struture */
-	struct usb_device *usbdev;
 
 	struct drm_sg_mem *sg;	/**< Scatter gather memory */
 	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
diff --git a/include/drm/drm_usb.h b/include/drm/drm_usb.h
deleted file mode 100644
index 33506c11..0000000
--- a/include/drm/drm_usb.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef DRM_USB_H
-#define DRM_USB_H
-
-#include <drmP.h>
-
-#include <linux/usb.h>
-
-extern int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver);
-extern void drm_usb_exit(struct drm_driver *driver, struct usb_driver *udriver);
-
-int drm_get_usb_dev(struct usb_interface *interface,
-		    const struct usb_device_id *id,
-		    struct drm_driver *driver);
-
-#endif
-- 
2.1.0

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

* [PATCH 20/20] drm: move drm-lock API to drm_legacy.h
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (18 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 19/20] drm: merge drm_usb into udl David Herrmann
@ 2014-08-29 10:12 ` David Herrmann
  2014-08-29 13:02   ` Thierry Reding
  2014-08-29 13:08 ` [PATCH 00/20] DRM: Core Cleanups Daniel Vetter
  20 siblings, 1 reply; 53+ messages in thread
From: David Herrmann @ 2014-08-29 10:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter

Same as the other legacy APIs, most of this is internal, so prefix it with
drm_legacy_* and move into drm_legacy.h.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_fops.c          |  6 +++---
 drivers/gpu/drm/drm_ioctl.c         |  4 ++--
 drivers/gpu/drm/drm_legacy.h        |  9 +++++++++
 drivers/gpu/drm/drm_lock.c          | 20 +++++++++++---------
 drivers/gpu/drm/i810/i810_dma.c     |  4 ++--
 drivers/gpu/drm/savage/savage_bci.c |  4 ++--
 drivers/gpu/drm/sis/sis_mm.c        |  6 +++---
 drivers/gpu/drm/via/via_mm.c        |  6 +++---
 include/drm/drmP.h                  | 14 +++-----------
 9 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 12e6a1c..b419990 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -268,11 +268,11 @@ static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
 	struct drm_file *file_priv = filp->private_data;
 
-	if (drm_i_have_hw_lock(dev, file_priv)) {
+	if (drm_legacy_i_have_hw_lock(dev, file_priv)) {
 		DRM_DEBUG("File %p released, freeing lock for context %d\n",
 			  filp, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
-		drm_lock_free(&file_priv->master->lock,
-			      _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
+		drm_legacy_lock_free(&file_priv->master->lock,
+				     _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
 	}
 }
 
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 3a1349f..187dfaa 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -82,8 +82,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH),
-	DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_legacy_lock, DRM_AUTH),
+	DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_legacy_unlock, DRM_AUTH),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
 
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index d94c564..14e4444 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -78,4 +78,13 @@ struct drm_agp_mem {
 	struct list_head head;
 };
 
+/*
+ * Generic Userspace Locking-API
+ */
+
+int drm_legacy_i_have_hw_lock(struct drm_device *d, struct drm_file *f);
+int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
+int drm_legacy_lock_free(struct drm_lock_data *lock, unsigned int ctx);
+
 #endif /* __DRM_LEGACY_H__ */
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index 60f1481..727b032 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -52,7 +52,8 @@ static int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
  *
  * Add the current task to the lock wait queue, and attempt to take to lock.
  */
-int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
+int drm_legacy_lock(struct drm_device *dev, void *data,
+		    struct drm_file *file_priv)
 {
 	DECLARE_WAITQUEUE(entry, current);
 	struct drm_lock *lock = data;
@@ -146,7 +147,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
  *
  * Transfer and free the lock.
  */
-int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
+int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
 	struct drm_lock *lock = data;
 	struct drm_master *master = file_priv->master;
@@ -157,7 +158,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
 		return -EINVAL;
 	}
 
-	if (drm_lock_free(&master->lock, lock->context)) {
+	if (drm_legacy_lock_free(&master->lock, lock->context)) {
 		/* FIXME: Should really bail out here. */
 	}
 
@@ -250,7 +251,7 @@ static int drm_lock_transfer(struct drm_lock_data *lock_data,
  * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task
  * waiting on the lock queue.
  */
-int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
+int drm_legacy_lock_free(struct drm_lock_data *lock_data, unsigned int context)
 {
 	unsigned int old, new, prev;
 	volatile unsigned int *lock = &lock_data->hw_lock->lock;
@@ -324,7 +325,7 @@ static int drm_notifier(void *priv)
  * having to worry about starvation.
  */
 
-void drm_idlelock_take(struct drm_lock_data *lock_data)
+void drm_legacy_idlelock_take(struct drm_lock_data *lock_data)
 {
 	int ret;
 
@@ -341,9 +342,9 @@ void drm_idlelock_take(struct drm_lock_data *lock_data)
 	}
 	spin_unlock_bh(&lock_data->spinlock);
 }
-EXPORT_SYMBOL(drm_idlelock_take);
+EXPORT_SYMBOL(drm_legacy_idlelock_take);
 
-void drm_idlelock_release(struct drm_lock_data *lock_data)
+void drm_legacy_idlelock_release(struct drm_lock_data *lock_data)
 {
 	unsigned int old, prev;
 	volatile unsigned int *lock = &lock_data->hw_lock->lock;
@@ -361,9 +362,10 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
 	}
 	spin_unlock_bh(&lock_data->spinlock);
 }
-EXPORT_SYMBOL(drm_idlelock_release);
+EXPORT_SYMBOL(drm_legacy_idlelock_release);
 
-int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv)
+int drm_legacy_i_have_hw_lock(struct drm_device *dev,
+			      struct drm_file *file_priv)
 {
 	struct drm_master *master = file_priv->master;
 	return (file_priv->lock_count && master->lock.hw_lock &&
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index bae897d..c97e2ff 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -1215,9 +1215,9 @@ void i810_driver_preclose(struct drm_device *dev, struct drm_file *file_priv)
 	}
 
 	if (file_priv->master && file_priv->master->lock.hw_lock) {
-		drm_idlelock_take(&file_priv->master->lock);
+		drm_legacy_idlelock_take(&file_priv->master->lock);
 		i810_driver_reclaim_buffers(dev, file_priv);
-		drm_idlelock_release(&file_priv->master->lock);
+		drm_legacy_idlelock_release(&file_priv->master->lock);
 	} else {
 		/* master disappeared, clean up stuff anyway and hope nothing
 		 * goes wrong */
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index 82a078c..9288d30 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -1051,7 +1051,7 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
 		return;
 
 	if (file_priv->master && file_priv->master->lock.hw_lock) {
-		drm_idlelock_take(&file_priv->master->lock);
+		drm_legacy_idlelock_take(&file_priv->master->lock);
 		release_idlelock = 1;
 	}
 
@@ -1070,7 +1070,7 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
 	}
 
 	if (release_idlelock)
-		drm_idlelock_release(&file_priv->master->lock);
+		drm_legacy_idlelock_release(&file_priv->master->lock);
 }
 
 const struct drm_ioctl_desc savage_ioctls[] = {
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index 77f288e..93ad8a5 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -319,12 +319,12 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
 	if (!(file->minor->master && file->master->lock.hw_lock))
 		return;
 
-	drm_idlelock_take(&file->master->lock);
+	drm_legacy_idlelock_take(&file->master->lock);
 
 	mutex_lock(&dev->struct_mutex);
 	if (list_empty(&file_priv->obj_list)) {
 		mutex_unlock(&dev->struct_mutex);
-		drm_idlelock_release(&file->master->lock);
+		drm_legacy_idlelock_release(&file->master->lock);
 
 		return;
 	}
@@ -345,7 +345,7 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
 	}
 	mutex_unlock(&dev->struct_mutex);
 
-	drm_idlelock_release(&file->master->lock);
+	drm_legacy_idlelock_release(&file->master->lock);
 
 	return;
 }
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index d70b1e1..4f20742 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -211,12 +211,12 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
 	if (!(file->minor->master && file->master->lock.hw_lock))
 		return;
 
-	drm_idlelock_take(&file->master->lock);
+	drm_legacy_idlelock_take(&file->master->lock);
 
 	mutex_lock(&dev->struct_mutex);
 	if (list_empty(&file_priv->obj_list)) {
 		mutex_unlock(&dev->struct_mutex);
-		drm_idlelock_release(&file->master->lock);
+		drm_legacy_idlelock_release(&file->master->lock);
 
 		return;
 	}
@@ -231,7 +231,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
 	}
 	mutex_unlock(&dev->struct_mutex);
 
-	drm_idlelock_release(&file->master->lock);
+	drm_legacy_idlelock_release(&file->master->lock);
 
 	return;
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0e73aad..be1160f 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1143,22 +1143,11 @@ void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
 void drm_clflush_sg(struct sg_table *st);
 void drm_clflush_virt_range(void *addr, unsigned long length);
 
-				/* Locking IOCTL support (drm_lock.h) */
-extern int drm_lock(struct drm_device *dev, void *data,
-		    struct drm_file *file_priv);
-extern int drm_unlock(struct drm_device *dev, void *data,
-		      struct drm_file *file_priv);
-extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
-extern void drm_idlelock_take(struct drm_lock_data *lock_data);
-extern void drm_idlelock_release(struct drm_lock_data *lock_data);
-
 /*
  * These are exported to drivers so that they can implement fencing using
  * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
  */
 
-extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
-
 				/* DMA support (drm_dma.h) */
 extern int drm_legacy_dma_setup(struct drm_device *dev);
 extern void drm_legacy_dma_takedown(struct drm_device *dev);
@@ -1363,6 +1352,9 @@ int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
 
 void drm_legacy_vma_flush(struct drm_device *d);
 
+void drm_legacy_idlelock_take(struct drm_lock_data *lock);
+void drm_legacy_idlelock_release(struct drm_lock_data *lock);
+
 			       /* sysfs support (drm_sysfs.c) */
 struct drm_sysfs_class;
 extern struct class *drm_sysfs_create(struct module *owner, char *name);
-- 
2.1.0

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

* Re: [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/
  2014-08-29 10:12 ` [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/ David Herrmann
@ 2014-08-29 11:20   ` Thierry Reding
  2014-09-08  4:08   ` Alex Deucher
  1 sibling, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:20 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:27PM +0200, David Herrmann wrote:
> Radeon UMS is the last user of drm_buffer. Move it out of sight so radeon
> can drop it together with UMS.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/Makefile              |   2 +-
>  drivers/gpu/drm/drm_buffer.c          | 181 ----------------------------------
>  drivers/gpu/drm/radeon/Makefile       |   2 +-
>  drivers/gpu/drm/radeon/drm_buffer.c   | 177 +++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/radeon/drm_buffer.h   | 148 +++++++++++++++++++++++++++
>  drivers/gpu/drm/radeon/r300_cmdbuf.c  |   2 +-
>  drivers/gpu/drm/radeon/radeon_state.c |   2 +-
>  include/drm/drm_buffer.h              | 148 ---------------------------
>  8 files changed, 329 insertions(+), 333 deletions(-)
>  delete mode 100644 drivers/gpu/drm/drm_buffer.c
>  create mode 100644 drivers/gpu/drm/radeon/drm_buffer.c
>  create mode 100644 drivers/gpu/drm/radeon/drm_buffer.h
>  delete mode 100644 include/drm/drm_buffer.h

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 02/20] drm: mark drm_buf and drm_map as legacy
  2014-08-29 10:12 ` [PATCH 02/20] drm: mark drm_buf and drm_map as legacy David Herrmann
@ 2014-08-29 11:32   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:32 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:28PM +0200, David Herrmann wrote:
> Move internal declarations to drm_legacy.h and add drm_legacy_*() prefix
> to all legacy functions.

Perhaps this could give a short explanation of why they are marked as
legacy and what the plan is to get rid of them.

[...]
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
[...]
> @@ -378,7 +374,7 @@ int drm_addmap(struct drm_device * dev, resource_size_t offset,
>  	return rc;
>  }
>  
> -EXPORT_SYMBOL(drm_addmap);
> +EXPORT_SYMBOL(drm_legacy_addmap);

Nit: might as well remove the unusual blank line between the closing
brace and the EXPORT_SYMBOL while at it.

> diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
[...]
>  	offset = 0;
> -	err = drm_addmap(dev, offset, warp_size,
> -			 _DRM_AGP, _DRM_READ_ONLY, &dev_priv->warp);
> +	err = drm_legacy_addmap(dev, offset, warp_size,
> +				_DRM_AGP, _DRM_READ_ONLY, &dev_priv->warp);

The parameters are somewhat oddly wrapped here. Nothing that the patch
introduces, but perhaps low-hanging fruit while at it. There are a few
other occurrences in this file.

I found only minor whitespace nits, feel free to ignore those.

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 03/20] drm: move "struct drm_vma_entry" to drm_vm.c
  2014-08-29 10:12 ` [PATCH 03/20] drm: move "struct drm_vma_entry" to drm_vm.c David Herrmann
@ 2014-08-29 11:34   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:34 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:29PM +0200, David Herrmann wrote:
> Make all the drm_vma_entry handling local to drm_vm.c and hide it from
> global headers. This requires to extract the inlined legacy drm_vma_entry
> cleanup into a small helper and also move a weirdly placed drm_vma_info
> helper into drm_vm.c.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_fops.c | 10 +-----
>  drivers/gpu/drm/drm_info.c | 59 -----------------------------------
>  drivers/gpu/drm/drm_vm.c   | 76 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drmP.h         |  8 ++---
>  4 files changed, 79 insertions(+), 74 deletions(-)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 04/20] drm: move "struct drm_magic_entry" to drm_auth.c
  2014-08-29 10:12 ` [PATCH 04/20] drm: move "struct drm_magic_entry" to drm_auth.c David Herrmann
@ 2014-08-29 11:39   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:39 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:30PM +0200, David Herrmann wrote:
> In drm_release(), we currently call drm_remove_magic() if the drm_file
> has a drm-magic attached. Therefore, once drm_master_release() is called,
> the magic-list _must_ be empty.
> 
> By dropping the no-op cleanup, we can move "struct drm_magic_entry" to
> drm_auth.c and avoid exposing it to all of DRM.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_auth.c | 6 ++++++
>  drivers/gpu/drm/drm_drv.c  | 7 -------
>  include/drm/drmP.h         | 6 ------
>  3 files changed, 6 insertions(+), 13 deletions(-)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 05/20] drm: drop unused "struct drm_waitlist"
  2014-08-29 10:12 ` [PATCH 05/20] drm: drop unused "struct drm_waitlist" David Herrmann
@ 2014-08-29 11:40   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:40 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:31PM +0200, David Herrmann wrote:
> This structure is unused, drop it.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  include/drm/drmP.h | 11 -----------
>  1 file changed, 11 deletions(-)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 06/20] drm: move AGP definitions harder
  2014-08-29 10:12 ` [PATCH 06/20] drm: move AGP definitions harder David Herrmann
@ 2014-08-29 11:43   ` Thierry Reding
  2014-08-29 12:39     ` Daniel Vetter
  0 siblings, 1 reply; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:43 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:32PM +0200, David Herrmann wrote:
> Move drm_agp_head to drm_agpsupport.h and drm_agp_mem into drm_legacy.h.
> Unfortunately, drivers still heavily access drm_agp_head so we cannot
> move it to drm_legacy.h. However, at least it's no longer visible in
> drmP.h now (it's directly included from it, though).
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_agpsupport.c |  1 +
>  drivers/gpu/drm/drm_legacy.h     | 15 +++++++++++++++
>  drivers/gpu/drm/drm_memory.c     |  1 +
>  drivers/gpu/drm/drm_vm.c         |  1 +
>  include/drm/drmP.h               | 30 +-----------------------------
>  include/drm/drm_agpsupport.h     | 13 +++++++++++++
>  6 files changed, 32 insertions(+), 29 deletions(-)

I don't know exactly what you mean by "move harder" in the subject, but
other than that this looks good, so with a better subject this is:

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 07/20] drm: replace weird conditional includes
  2014-08-29 10:12 ` [PATCH 07/20] drm: replace weird conditional includes David Herrmann
@ 2014-08-29 11:45   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:45 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:33PM +0200, David Herrmann wrote:
> pte_wrprotect() is only used by drm_vm.c, so move the include there. Also
> include it unconditionally, all architectures provide this header!
> 
> Furthermore, replace asm/current.h with sched.h, which includes
> asm/current.h unconditionally. This way we get the same effect and avoid
> direct asm/ includes. Furthermore, drop the weird __alpha__ protection.
> It's safe to include sched.h everywhere (and the wait.h comment doesn't
> apply, anyway).
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_vm.c |  1 +
>  include/drm/drmP.h       | 10 +---------
>  2 files changed, 2 insertions(+), 9 deletions(-)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 08/20] drm: drop __KERNEL__ protection in drmP.h
  2014-08-29 10:12 ` [PATCH 08/20] drm: drop __KERNEL__ protection in drmP.h David Herrmann
@ 2014-08-29 11:46   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:46 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:34PM +0200, David Herrmann wrote:
> drmP.h is internal to the kernel. No need to keep the __KERNEL__
> protection.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  include/drm/drmP.h | 2 --
>  1 file changed, 2 deletions(-)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c
  2014-08-29 10:12 ` [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c David Herrmann
@ 2014-08-29 11:56   ` Thierry Reding
  2014-08-29 12:43     ` Daniel Vetter
  0 siblings, 1 reply; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 11:56 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:35PM +0200, David Herrmann wrote:
> The drm_memory.h header is only used to define PAGE_AGP, which is only
> used in drm_memory.c. Fold the header into drm_memory.c and drop it.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_memory.c | 11 +++++++++
>  include/drm/drmP.h           |  6 ++---
>  include/drm/drm_memory.h     | 59 --------------------------------------------
>  3 files changed, 13 insertions(+), 63 deletions(-)
>  delete mode 100644 include/drm/drm_memory.h
> 
> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> index 7888dad..62fda6a 100644
> --- a/drivers/gpu/drm/drm_memory.c
> +++ b/drivers/gpu/drm/drm_memory.c
> @@ -39,6 +39,17 @@
>  #include "drm_legacy.h"
>  
>  #if __OS_HAS_AGP
> +
> +#ifdef HAVE_PAGE_AGP
> +# include <asm/agp.h>
> +#else

This check seems to be redundant. All architectures that support AGP
provide this header.

> +# ifdef __powerpc__
> +#  define PAGE_AGP	__pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)

Is this even necessary? It seems like PowerPC always defines
HAVE_PAGE_AGP.

> +# else
> +#  define PAGE_AGP	PAGE_KERNEL
> +# endif
> +#endif

Shouldn't this simply be moved into the asm/agp.h header for each of the
architectures that has AGP?

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h
  2014-08-29 10:12 ` [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h David Herrmann
@ 2014-08-29 12:03   ` Thierry Reding
  2014-08-29 12:45     ` Daniel Vetter
  0 siblings, 1 reply; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:03 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:36PM +0200, David Herrmann wrote:
> With drm_memory.h gone, there is no header left that uses __OS_HAS_AGP.
> Move it into drm_agpsupport.h (which is itself included from drmP.h) to
> hide it harder from public eyes.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  include/drm/drmP.h           | 2 --
>  include/drm/drm_agpsupport.h | 3 +++
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 294f7da..c6f337c 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -67,8 +67,6 @@
>  
>  #include <linux/idr.h>
>  
> -#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
> -
>  struct module;
>  
>  struct drm_file;
> diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
> index 3bebeb4..4f1724c 100644
> --- a/include/drm/drm_agpsupport.h
> +++ b/include/drm/drm_agpsupport.h
> @@ -8,6 +8,9 @@
>  #include <linux/agp_backend.h>
>  #include <drm/drmP.h>
>  
> +#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && \
> +					      defined(MODULE)))

I'm not really sure what the intent was of the final defined(MODULE).
Surely the fact whether a driver is being built as a module or not does
not influence whether or not the OS supports AGP.

And if this is merely meant to make sure that drivers that are built-in
don't break to build if AGP is a module, then that should be a job for
Kconfig rather than some macro.

So I think the above could simply become:

	#define __OS_HAS_AGP IS_ENABLED(CONFIG_AGP)

And once we have that I think we could even easily get rid of the custom
__OS_HAS_AGP macro and use IS_ENABLED(CONFIG_AGP) directly.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 11/20] drm: order includes alphabetically in drmP.h
  2014-08-29 10:12 ` [PATCH 11/20] drm: order includes alphabetically in drmP.h David Herrmann
@ 2014-08-29 12:05   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:05 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:37PM +0200, David Herrmann wrote:
> It is hardly possible to review the drmP.h includes, anymore. Order them
> alphabetically, linux/ first, then asm/ and then local drm/ includes.
> 
> Since a long time ago, kernel headers have been converted to include
> required headers themselves. No-one cares whether that means the compiler
> has to include a header multiple times. In fact, GCC already does some
> optimization regarding multiple inclusions if a sorrounding #ifndef is
> present.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  include/drm/drmP.h | 46 +++++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)

This looks good, but I don't think I'm going to bother manually checking
each of those. Provided everything still complies, this is at least:

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 12/20] drm: drop DRM_DEBUG_CODE
  2014-08-29 10:12 ` [PATCH 12/20] drm: drop DRM_DEBUG_CODE David Herrmann
@ 2014-08-29 12:10   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:10 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:38PM +0200, David Herrmann wrote:
[...]
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 83a2461..5cfa574 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -2761,18 +2761,25 @@ void radeon_atombios_fini(struct radeon_device *rdev);
>  /*
>   * RING helpers.
>   */
> -#if DRM_DEBUG_CODE == 0
> +
> +/**
> + * radeon_ring_write - write a value to the ring
> + *
> + * @ring: radeon_ring structure holding ring information
> + * @v: dword (dw) value to write
> + *
> + * Write a value to the requested ring buffer (all asics).
> + */
>  static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
>  {
> +	if (ring->count_dw <= 0)
> +		DRM_ERROR("radeon: writing more dwords to the ring than expected!\n");
> +
>  	ring->ring[ring->wptr++] = v;
>  	ring->wptr &= ring->ptr_mask;
>  	ring->count_dw--;
>  	ring->ring_free_dw--;
>  }
> -#else
> -/* With debugging this is just too big to inline */
> -void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
> -#endif
>  
>  /*
>   * ASICs macro.
> diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
> index d656079..6f2a9bd 100644
> --- a/drivers/gpu/drm/radeon/radeon_ring.c
> +++ b/drivers/gpu/drm/radeon/radeon_ring.c
> @@ -45,27 +45,6 @@
>  static int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring);
>  
>  /**
> - * radeon_ring_write - write a value to the ring
> - *
> - * @ring: radeon_ring structure holding ring information
> - * @v: dword (dw) value to write
> - *
> - * Write a value to the requested ring buffer (all asics).
> - */
> -void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
> -{
> -#if DRM_DEBUG_CODE
> -	if (ring->count_dw <= 0) {
> -		DRM_ERROR("radeon: writing more dwords to the ring than expected!\n");
> -	}
> -#endif
> -	ring->ring[ring->wptr++] = v;
> -	ring->wptr &= ring->ptr_mask;
> -	ring->count_dw--;
> -	ring->ring_free_dw--;
> -}

The original was clearly never tested with DRM_DEBUG_CODE != 0. I don't
see how it could've built given that the header protects the complete
function whereas the implementation protects only part of the function.

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 13/20] drm: inline "struct drm_sigdata"
  2014-08-29 10:12 ` [PATCH 13/20] drm: inline "struct drm_sigdata" David Herrmann
@ 2014-08-29 12:21   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:21 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:39PM +0200, David Herrmann wrote:
> The sigdata structure is only used to group two fields in drm_device.
> Inline it and make it an unnamed object.

I'm not sure what unnamed object means.

> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
[...]
> @@ -1035,9 +1029,13 @@ struct drm_device {
>  
>  	struct drm_sg_mem *sg;	/**< Scatter gather memory */
>  	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
> -	struct drm_sigdata sigdata;	   /**< For block_all_signals */
>  	sigset_t sigmask;
>  
> +	struct {
> +		int context;

Your patch doesn't introduce this, but shouldn't context here be
unsigned given that it's compared to drm_hw_lock's .lock field?

I guess struct drm_lock could have that same change. I suppose it might
not be all that important since presumably the code works, but it's
still inconsistent use of types.

Anyway, if you could clarify the "unnamed object" in the commit
description, this patch:

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 14/20] drm: move remaining includes in drmP.h to the top
  2014-08-29 10:12 ` [PATCH 14/20] drm: move remaining includes in drmP.h to the top David Herrmann
@ 2014-08-29 12:26   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:26 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:40PM +0200, David Herrmann wrote:
[...]
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
[...]
> @@ -64,8 +61,14 @@
>  #include <asm/pgalloc.h>
>  #include <asm/uaccess.h>
>  
> -#include <drm/drm.h>
> +#include <uapi/drm/drm.h>
> +#include <uapi/drm/drm_mode.h>

The uapi/ prefix is not strictly necessary since include/uapi is in the
include path, but I guess it can't hurt to be explicit, so:

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 06/20] drm: move AGP definitions harder
  2014-08-29 11:43   ` Thierry Reding
@ 2014-08-29 12:39     ` Daniel Vetter
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 12:39 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 01:43:10PM +0200, Thierry Reding wrote:
> On Fri, Aug 29, 2014 at 12:12:32PM +0200, David Herrmann wrote:
> > Move drm_agp_head to drm_agpsupport.h and drm_agp_mem into drm_legacy.h.
> > Unfortunately, drivers still heavily access drm_agp_head so we cannot
> > move it to drm_legacy.h. However, at least it's no longer visible in
> > drmP.h now (it's directly included from it, though).
> > 
> > Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> > ---
> >  drivers/gpu/drm/drm_agpsupport.c |  1 +
> >  drivers/gpu/drm/drm_legacy.h     | 15 +++++++++++++++
> >  drivers/gpu/drm/drm_memory.c     |  1 +
> >  drivers/gpu/drm/drm_vm.c         |  1 +
> >  include/drm/drmP.h               | 30 +-----------------------------
> >  include/drm/drm_agpsupport.h     | 13 +++++++++++++
> >  6 files changed, 32 insertions(+), 29 deletions(-)
> 
> I don't know exactly what you mean by "move harder" in the subject, but
> other than that this looks good, so with a better subject this is:

I guess "Try to hide AGP definitions harder" would be more accurate.
-Daniel

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



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

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

* Re: [PATCH 15/20] drm: simplify drm_*_set_unique()
  2014-08-29 10:12 ` [PATCH 15/20] drm: simplify drm_*_set_unique() David Herrmann
@ 2014-08-29 12:39   ` Thierry Reding
  2014-08-29 12:58   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:39 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:41PM +0200, David Herrmann wrote:
> Lets use kasprintf() to avoid pre-allocating the buffer. This is really
> nothing to optimize for speed and the input is trusted, so kasprintf() is
> just fine.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_pci.c      | 30 ++++++++----------------------
>  drivers/gpu/drm/drm_platform.c | 31 ++++++++-----------------------
>  2 files changed, 16 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 020cfd9..8efea6b 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -129,31 +129,17 @@ static int drm_get_pci_domain(struct drm_device *dev)
>  
>  static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
>  {
> -	int len, ret;
> -	master->unique_len = 40;
> -	master->unique_size = master->unique_len;
> -	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
> -	if (master->unique == NULL)
> +	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
> +					drm_get_pci_domain(dev),
> +					dev->pdev->bus->number,
> +					PCI_SLOT(dev->pdev->devfn),
> +					PCI_FUNC(dev->pdev->devfn));

I think we've been trying to standardize on aligning parameters on
subsequent lines with the first parameter on the first line.

[...]
> +	master->unique_len = strlen(master->unique);
> +	master->unique_size = master->unique_len + 1;

[...]
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
[...]
>  static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
>  {
> -	int len, ret, id;
> -
> -	master->unique_len = 13 + strlen(dev->platformdev->name);
> -	master->unique_size = master->unique_len;
> -	master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
> -
> -	if (master->unique == NULL)
> -		return -ENOMEM;
> +	int id;
>  
>  	id = dev->platformdev->id;
> -
> -	/* if only a single instance of the platform device, id will be
> -	 * set to -1.. use 0 instead to avoid a funny looking bus-id:
> -	 */
> -	if (id == -1)
> +	if (id < 0)
>  		id = 0;

Perhaps collapse all of the above into:

	int id = (dev->platformdev->id < 0) ? 0 : dev->platformdev->id;

? Not that it matters much. I suspect we could easily remove all traces
of this particular function in a next step.

> -	len = snprintf(master->unique, master->unique_len,
> -			"platform:%s:%02d", dev->platformdev->name, id);
> -
> -	if (len > master->unique_len) {
> -		DRM_ERROR("Unique buffer overflowed\n");
> -		ret = -EINVAL;
> -		goto err;
> -	}
> +	master->unique = kasprintf(GFP_KERNEL, "platform:%s:%02d",
> +						dev->platformdev->name, id);
> +	if (!master->unique)
> +		return -ENOMEM;
>  
> +	master->unique_len = strlen(master->unique);
> +	master->unique_size = master->unique_len;

unique_size is weird. It seems to me like it should always be unique_len
+ 1. Why drm_platform_bus should be special escapes me. Also, after this
patch it seems to be completely unused, so perhaps we should just drop
it.

All of those comments can either be addressed in a separate patch (or
ignored), though, so:

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 16/20] drm: drop unused drm_master->unique_size
  2014-08-29 10:12 ` [PATCH 16/20] drm: drop unused drm_master->unique_size David Herrmann
@ 2014-08-29 12:41   ` Thierry Reding
  2014-08-29 12:58   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:41 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:42PM +0200, David Herrmann wrote:
> This field is unused and there is really no reason to optimize
> unique-allocations. Drop it.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_ioctl.c    | 1 -
>  drivers/gpu/drm/drm_pci.c      | 4 +---
>  drivers/gpu/drm/drm_platform.c | 1 -
>  include/drm/drmP.h             | 2 --
>  4 files changed, 1 insertion(+), 7 deletions(-)

Now that's what I get for not reading mails in advance. Anyway I'm
glad we agree on the uselessness of unique_size. =)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c
  2014-08-29 11:56   ` Thierry Reding
@ 2014-08-29 12:43     ` Daniel Vetter
  2014-08-29 13:26       ` Thierry Reding
  0 siblings, 1 reply; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 12:43 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 01:56:23PM +0200, Thierry Reding wrote:
> On Fri, Aug 29, 2014 at 12:12:35PM +0200, David Herrmann wrote:
> > The drm_memory.h header is only used to define PAGE_AGP, which is only
> > used in drm_memory.c. Fold the header into drm_memory.c and drop it.
> > 
> > Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> > ---
> >  drivers/gpu/drm/drm_memory.c | 11 +++++++++
> >  include/drm/drmP.h           |  6 ++---
> >  include/drm/drm_memory.h     | 59 --------------------------------------------
> >  3 files changed, 13 insertions(+), 63 deletions(-)
> >  delete mode 100644 include/drm/drm_memory.h
> > 
> > diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> > index 7888dad..62fda6a 100644
> > --- a/drivers/gpu/drm/drm_memory.c
> > +++ b/drivers/gpu/drm/drm_memory.c
> > @@ -39,6 +39,17 @@
> >  #include "drm_legacy.h"
> >  
> >  #if __OS_HAS_AGP
> > +
> > +#ifdef HAVE_PAGE_AGP
> > +# include <asm/agp.h>
> > +#else
> 
> This check seems to be redundant. All architectures that support AGP
> provide this header.
> 
> > +# ifdef __powerpc__
> > +#  define PAGE_AGP	__pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
> 
> Is this even necessary? It seems like PowerPC always defines
> HAVE_PAGE_AGP.

Iirc I've tried to untangle this before and I'm not 100% this is actually
the case on all ppc platforms. It looked like there's some crazy include
header depency stuff going on.

But given how popular drm on ppc and that the few platforms where people
actually use gpus are the saner ones (hopefully) I think we can just move
ahead with this change and fixup any compile breakage once it's reported.
If there is any.

> > +# else
> > +#  define PAGE_AGP	PAGE_KERNEL
> > +# endif
> > +#endif
> 
> Shouldn't this simply be moved into the asm/agp.h header for each of the
> architectures that has AGP?

Same comment really, I think the include mess is to hard to untangle. At
least I've failed. So with the #ifdef HAVE_PAGE_AGP dropped around the
include as Thierry suggested this is

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

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

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

* Re: [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h
  2014-08-29 12:03   ` Thierry Reding
@ 2014-08-29 12:45     ` Daniel Vetter
  0 siblings, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 12:45 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 02:03:12PM +0200, Thierry Reding wrote:
> On Fri, Aug 29, 2014 at 12:12:36PM +0200, David Herrmann wrote:
> > With drm_memory.h gone, there is no header left that uses __OS_HAS_AGP.
> > Move it into drm_agpsupport.h (which is itself included from drmP.h) to
> > hide it harder from public eyes.
> > 
> > Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> > ---
> >  include/drm/drmP.h           | 2 --
> >  include/drm/drm_agpsupport.h | 3 +++
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> > index 294f7da..c6f337c 100644
> > --- a/include/drm/drmP.h
> > +++ b/include/drm/drmP.h
> > @@ -67,8 +67,6 @@
> >  
> >  #include <linux/idr.h>
> >  
> > -#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
> > -
> >  struct module;
> >  
> >  struct drm_file;
> > diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
> > index 3bebeb4..4f1724c 100644
> > --- a/include/drm/drm_agpsupport.h
> > +++ b/include/drm/drm_agpsupport.h
> > @@ -8,6 +8,9 @@
> >  #include <linux/agp_backend.h>
> >  #include <drm/drmP.h>
> >  
> > +#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && \
> > +					      defined(MODULE)))
> 
> I'm not really sure what the intent was of the final defined(MODULE).
> Surely the fact whether a driver is being built as a module or not does
> not influence whether or not the OS supports AGP.

I think this was to make sure agp drivers are loaded before the drm
drivers. But since ages we can build the different agp drivers
indidivudally as modules, so this stopped making any sense at all.

> And if this is merely meant to make sure that drivers that are built-in
> don't break to build if AGP is a module, then that should be a job for
> Kconfig rather than some macro.
> 
> So I think the above could simply become:
> 
> 	#define __OS_HAS_AGP IS_ENABLED(CONFIG_AGP)
> 
> And once we have that I think we could even easily get rid of the custom
> __OS_HAS_AGP macro and use IS_ENABLED(CONFIG_AGP) directly.

Yeah, I think a simple IS_ENABLED(CONFIG_AGP) sould be good enough.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* Re: [PATCH 17/20] drm: add driver->set_busid() callback
  2014-08-29 10:12 ` [PATCH 17/20] drm: add driver->set_busid() callback David Herrmann
@ 2014-08-29 12:54   ` Thierry Reding
  2014-08-29 13:01   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:54 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:43PM +0200, David Herrmann wrote:
> One step closer to dropping all the drm_bus_* code:
> Add a driver->set_busid() callback and make all drivers use the generic
> helpers. Nouveau is the only driver that uses two different bus-types with
> the same drm_driver. This is totally broken if both buses are available on
> the same machine (unlikely, but lets be safe).

It's not at all unlikely. There are quite a few people using nouveau to
drive an discrete GPU over PCIe on Tegra K1.

I've also been noticing lately (and I'm not sure why I didn't see it
earlier, possibly because the relevant patches weren't in nouveau yet)
that the nouveau kernel driver crashes when running X on Tegra K1 with
nouveau (and the gk20a GPU) enabled. The reason being that the device is
wrongfully marked as drm_pci_bus.

> Therefore, we create two
> different drivers for each platform during module_init() and set the
> set_busid() callback respectively.

From what I can tell this patch should fix the above-mentioned issue, so
thanks for that. =) I do have local changes that do mostly the same
thing, but slightly less elegantly.

> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
[...]
> @@ -1086,6 +1088,11 @@ EXPORT_SYMBOL(nouveau_platform_device_create_);
>  static int __init
>  nouveau_drm_init(void)
>  {
> +	driver_pci = driver_stub;
> +	driver_pci.set_busid = drm_pci_set_busid;
> +	driver_platform = driver_stub;
> +	driver_platform.set_busid = drm_platform_set_busid;

I think at some point we may also want to remove the DRIVER_MODESET flag
here. It probably won't be that easy because DRIVER_MODESET still
implies !legacy. I thought I had submitted a patch series at some point
to fix that (and got rid of the useless /dev/dri/cardX for render-only
devices), but I don't quite remember what became of it. I seem to
remember that Daniel didn't like it, but I can't recall the reason.

> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
[...]
> @@ -1507,6 +1509,7 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
>  
>  /* platform section */
>  extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
> +extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);

One step closer to getting rid of this altogether.

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 18/20] drm: Goody bye, drm_bus!
  2014-08-29 10:12 ` [PATCH 18/20] drm: Goody bye, drm_bus! David Herrmann
@ 2014-08-29 12:55   ` Thierry Reding
  2014-08-29 13:02   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 12:55 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:44PM +0200, David Herrmann wrote:
> ..we will not miss you..
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_ioctl.c    |  8 +-------
>  drivers/gpu/drm/drm_pci.c      |  6 ------
>  drivers/gpu/drm/drm_platform.c |  5 -----
>  drivers/gpu/drm/drm_usb.c      | 12 ------------
>  include/drm/drmP.h             |  5 -----
>  5 files changed, 1 insertion(+), 35 deletions(-)

\o/

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 15/20] drm: simplify drm_*_set_unique()
  2014-08-29 10:12 ` [PATCH 15/20] drm: simplify drm_*_set_unique() David Herrmann
  2014-08-29 12:39   ` Thierry Reding
@ 2014-08-29 12:58   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 12:58 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 12:12:41PM +0200, David Herrmann wrote:
> Lets use kasprintf() to avoid pre-allocating the buffer. This is really
> nothing to optimize for speed and the input is trusted, so kasprintf() is
> just fine.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_pci.c      | 30 ++++++++----------------------
>  drivers/gpu/drm/drm_platform.c | 31 ++++++++-----------------------
>  2 files changed, 16 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 020cfd9..8efea6b 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -129,31 +129,17 @@ static int drm_get_pci_domain(struct drm_device *dev)
>  
>  static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
>  {
> -	int len, ret;
> -	master->unique_len = 40;
> -	master->unique_size = master->unique_len;
> -	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
> -	if (master->unique == NULL)
> +	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
> +					drm_get_pci_domain(dev),
> +					dev->pdev->bus->number,
> +					PCI_SLOT(dev->pdev->devfn),
> +					PCI_FUNC(dev->pdev->devfn));
> +	if (!master->unique)
>  		return -ENOMEM;
>  
> -
> -	len = snprintf(master->unique, master->unique_len,
> -		       "pci:%04x:%02x:%02x.%d",
> -		       drm_get_pci_domain(dev),
> -		       dev->pdev->bus->number,
> -		       PCI_SLOT(dev->pdev->devfn),
> -		       PCI_FUNC(dev->pdev->devfn));
> -
> -	if (len >= master->unique_len) {
> -		DRM_ERROR("buffer overflow");
> -		ret = -EINVAL;
> -		goto err;
> -	} else
> -		master->unique_len = len;
> -
> +	master->unique_len = strlen(master->unique);
> +	master->unique_size = master->unique_len + 1;
>  	return 0;
> -err:
> -	return ret;
>  }
>  
>  int drm_pci_set_unique(struct drm_device *dev,
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
> index d5b76f1..0c09ddd 100644
> --- a/drivers/gpu/drm/drm_platform.c
> +++ b/drivers/gpu/drm/drm_platform.c
> @@ -70,35 +70,20 @@ err_free:
>  
>  static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
>  {
> -	int len, ret, id;
> -
> -	master->unique_len = 13 + strlen(dev->platformdev->name);
> -	master->unique_size = master->unique_len;
> -	master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
> -
> -	if (master->unique == NULL)
> -		return -ENOMEM;
> +	int id;
>  
>  	id = dev->platformdev->id;
> -
> -	/* if only a single instance of the platform device, id will be
> -	 * set to -1.. use 0 instead to avoid a funny looking bus-id:
> -	 */
> -	if (id == -1)
> +	if (id < 0)
>  		id = 0;
>  
> -	len = snprintf(master->unique, master->unique_len,
> -			"platform:%s:%02d", dev->platformdev->name, id);
> -
> -	if (len > master->unique_len) {
> -		DRM_ERROR("Unique buffer overflowed\n");
> -		ret = -EINVAL;
> -		goto err;
> -	}
> +	master->unique = kasprintf(GFP_KERNEL, "platform:%s:%02d",
> +						dev->platformdev->name, id);
> +	if (!master->unique)
> +		return -ENOMEM;
>  
> +	master->unique_len = strlen(master->unique);
> +	master->unique_size = master->unique_len;
>  	return 0;
> -err:
> -	return ret;
>  }
>  
>  static struct drm_bus drm_platform_bus = {
> -- 
> 2.1.0
> 

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

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

* Re: [PATCH 16/20] drm: drop unused drm_master->unique_size
  2014-08-29 10:12 ` [PATCH 16/20] drm: drop unused drm_master->unique_size David Herrmann
  2014-08-29 12:41   ` Thierry Reding
@ 2014-08-29 12:58   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 12:58 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 12:12:42PM +0200, David Herrmann wrote:
> This field is unused and there is really no reason to optimize
> unique-allocations. Drop it.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_ioctl.c    | 1 -
>  drivers/gpu/drm/drm_pci.c      | 4 +---
>  drivers/gpu/drm/drm_platform.c | 1 -
>  include/drm/drmP.h             | 2 --
>  4 files changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index aa1ac79..cb6b54a 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -189,7 +189,6 @@ drm_unset_busid(struct drm_device *dev,
>  	kfree(master->unique);
>  	master->unique = NULL;
>  	master->unique_len = 0;
> -	master->unique_size = 0;
>  }
>  
>  /**
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 8efea6b..e266927 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -138,7 +138,6 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
>  		return -ENOMEM;
>  
>  	master->unique_len = strlen(master->unique);
> -	master->unique_size = master->unique_len + 1;
>  	return 0;
>  }
>  
> @@ -149,8 +148,7 @@ int drm_pci_set_unique(struct drm_device *dev,
>  	int domain, bus, slot, func, ret;
>  
>  	master->unique_len = u->unique_len;
> -	master->unique_size = u->unique_len + 1;
> -	master->unique = kmalloc(master->unique_size, GFP_KERNEL);
> +	master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
>  	if (!master->unique) {
>  		ret = -ENOMEM;
>  		goto err;
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
> index 0c09ddd..f197a2b 100644
> --- a/drivers/gpu/drm/drm_platform.c
> +++ b/drivers/gpu/drm/drm_platform.c
> @@ -82,7 +82,6 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas
>  		return -ENOMEM;
>  
>  	master->unique_len = strlen(master->unique);
> -	master->unique_size = master->unique_len;
>  	return 0;
>  }
>  
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index a8b24fc..98b1eaf 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -574,7 +574,6 @@ struct drm_gem_object {
>   * @minor: Link back to minor char device we are master for. Immutable.
>   * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
>   * @unique_len: Length of unique field. Protected by drm_global_mutex.
> - * @unique_size: Amount allocated. Protected by drm_global_mutex.
>   * @magiclist: Hash of used authentication tokens. Protected by struct_mutex.
>   * @magicfree: List of used authentication tokens. Protected by struct_mutex.
>   * @lock: DRI lock information.
> @@ -585,7 +584,6 @@ struct drm_master {
>  	struct drm_minor *minor;
>  	char *unique;
>  	int unique_len;
> -	int unique_size;
>  	struct drm_open_hash magiclist;
>  	struct list_head magicfree;
>  	struct drm_lock_data lock;
> -- 
> 2.1.0
> 

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

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

* Re: [PATCH 19/20] drm: merge drm_usb into udl
  2014-08-29 10:12 ` [PATCH 19/20] drm: merge drm_usb into udl David Herrmann
@ 2014-08-29 13:00   ` Thierry Reding
  2014-08-29 13:06   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 13:00 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:45PM +0200, David Herrmann wrote:
[...]
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
[...]
>  module_init(udl_init);
>  module_exit(udl_exit);
> +MODULE_LICENSE("GPL");

According to the header file the license is GPL v2 only, so this should
be "GPL v2".

Might also be good to add MODULE_AUTHOR and MODULE_DESCRIPTION here.

Other than that:

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 17/20] drm: add driver->set_busid() callback
  2014-08-29 10:12 ` [PATCH 17/20] drm: add driver->set_busid() callback David Herrmann
  2014-08-29 12:54   ` Thierry Reding
@ 2014-08-29 13:01   ` Daniel Vetter
  2014-08-29 13:30     ` Thierry Reding
  1 sibling, 1 reply; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 13:01 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 12:12:43PM +0200, David Herrmann wrote:
> One step closer to dropping all the drm_bus_* code:
> Add a driver->set_busid() callback and make all drivers use the generic
> helpers. Nouveau is the only driver that uses two different bus-types with
> the same drm_driver. This is totally broken if both buses are available on
> the same machine (unlikely, but lets be safe). Therefore, we create two
> different drivers for each platform during module_init() and set the
> set_busid() callback respectively.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

This has a bit a midlayer smell to it tbh, we don't really need a
set_busid callback I think. Instead there's just two cases:
- The crazy implementation for pci devices. But we already have dev->pdev,
  so the core can figure this out itself.
- Everyone else just sets a static name. For those I think we should just
  add a drm_dev_set_busid function which they can call in their
  driver-load function. Well maybe different versions for platform drivers
  and stuff.

Thanks, Daniel

> ---
>  drivers/gpu/drm/armada/armada_drv.c      |  1 +
>  drivers/gpu/drm/ast/ast_drv.c            |  1 +
>  drivers/gpu/drm/bochs/bochs_drv.c        |  1 +
>  drivers/gpu/drm/cirrus/cirrus_drv.c      |  1 +
>  drivers/gpu/drm/drm_ioctl.c              |  8 +++++++-
>  drivers/gpu/drm/drm_pci.c                |  3 ++-
>  drivers/gpu/drm/drm_platform.c           |  3 ++-
>  drivers/gpu/drm/exynos/exynos_drm_drv.c  |  1 +
>  drivers/gpu/drm/gma500/psb_drv.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/msm/msm_drv.c            |  1 +
>  drivers/gpu/drm/nouveau/nouveau_drm.c    | 19 +++++++++++++------
>  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            |  6 ++++++
>  drivers/gpu/drm/via/via_drv.c            |  1 +
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |  1 +
>  drivers/staging/imx-drm/imx-drm-core.c   |  1 +
>  include/drm/drmP.h                       |  3 +++
>  30 files changed, 58 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index e2d5792..f672e6a 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -308,6 +308,7 @@ static struct drm_driver armada_drm_driver = {
>  	.postclose		= NULL,
>  	.lastclose		= armada_drm_lastclose,
>  	.unload			= armada_drm_unload,
> +	.set_busid		= drm_platform_set_busid,
>  	.get_vblank_counter	= drm_vblank_count,
>  	.enable_vblank		= armada_drm_enable_vblank,
>  	.disable_vblank		= armada_drm_disable_vblank,
> diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
> index f19682a..9a32d9d 100644
> --- a/drivers/gpu/drm/ast/ast_drv.c
> +++ b/drivers/gpu/drm/ast/ast_drv.c
> @@ -199,6 +199,7 @@ static struct drm_driver driver = {
>  
>  	.load = ast_driver_load,
>  	.unload = ast_driver_unload,
> +	.set_busid = drm_pci_set_busid,
>  
>  	.fops = &ast_fops,
>  	.name = DRIVER_NAME,
> diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
> index 9738e9b..98837bd 100644
> --- a/drivers/gpu/drm/bochs/bochs_drv.c
> +++ b/drivers/gpu/drm/bochs/bochs_drv.c
> @@ -82,6 +82,7 @@ static struct drm_driver bochs_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
>  	.load			= bochs_load,
>  	.unload			= bochs_unload,
> +	.set_busid		= drm_pci_set_busid,
>  	.fops			= &bochs_fops,
>  	.name			= "bochs-drm",
>  	.desc			= "bochs dispi vga interface (qemu stdvga)",
> diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
> index 919c73b..e705335 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_drv.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
> @@ -128,6 +128,7 @@ static struct drm_driver driver = {
>  	.driver_features = DRIVER_MODESET | DRIVER_GEM,
>  	.load = cirrus_driver_load,
>  	.unload = cirrus_driver_unload,
> +	.set_busid = drm_pci_set_busid,
>  	.fops = &cirrus_driver_fops,
>  	.name = DRIVER_NAME,
>  	.desc = DRIVER_DESC,
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index cb6b54a..4770bd7 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -244,7 +244,13 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
>  	if (master->unique != NULL)
>  		drm_unset_busid(dev, master);
>  
> -	if (dev->driver->bus && dev->driver->bus->set_busid) {
> +	if (dev->driver->set_busid) {
> +		ret = dev->driver->set_busid(dev, master);
> +		if (ret) {
> +			drm_unset_busid(dev, master);
> +			return ret;
> +		}
> +	} else if (dev->driver->bus && dev->driver->bus->set_busid) {
>  		ret = dev->driver->bus->set_busid(dev, master);
>  		if (ret) {
>  			drm_unset_busid(dev, master);
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index e266927..0400c37 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -127,7 +127,7 @@ static int drm_get_pci_domain(struct drm_device *dev)
>  	return pci_domain_nr(dev->pdev->bus);
>  }
>  
> -static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
> +int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
>  {
>  	master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
>  					drm_get_pci_domain(dev),
> @@ -140,6 +140,7 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
>  	master->unique_len = strlen(master->unique);
>  	return 0;
>  }
> +EXPORT_SYMBOL(drm_pci_set_busid);
>  
>  int drm_pci_set_unique(struct drm_device *dev,
>  		       struct drm_master *master,
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
> index f197a2b..939cd22 100644
> --- a/drivers/gpu/drm/drm_platform.c
> +++ b/drivers/gpu/drm/drm_platform.c
> @@ -68,7 +68,7 @@ err_free:
>  	return ret;
>  }
>  
> -static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
> +int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
>  {
>  	int id;
>  
> @@ -84,6 +84,7 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas
>  	master->unique_len = strlen(master->unique);
>  	return 0;
>  }
> +EXPORT_SYMBOL(drm_platform_set_busid);
>  
>  static struct drm_bus drm_platform_bus = {
>  	.set_busid = drm_platform_set_busid,
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index 0d74e9b..5aae95c 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -330,6 +330,7 @@ static struct drm_driver exynos_drm_driver = {
>  	.preclose		= exynos_drm_preclose,
>  	.lastclose		= exynos_drm_lastclose,
>  	.postclose		= exynos_drm_postclose,
> +	.set_busid		= drm_platform_set_busid,
>  	.get_vblank_counter	= drm_vblank_count,
>  	.enable_vblank		= exynos_drm_crtc_enable_vblank,
>  	.disable_vblank		= exynos_drm_crtc_disable_vblank,
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
> index eec993f..6ec3a90 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -476,6 +476,7 @@ static struct drm_driver driver = {
>  	.unload = psb_driver_unload,
>  	.lastclose = psb_driver_lastclose,
>  	.preclose = psb_driver_preclose,
> +	.set_busid = drm_pci_set_busid,
>  
>  	.num_ioctls = ARRAY_SIZE(psb_ioctls),
>  	.device_is_agp = psb_driver_device_is_agp,
> diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
> index 441ccf8..6cb08a1 100644
> --- a/drivers/gpu/drm/i810/i810_drv.c
> +++ b/drivers/gpu/drm/i810/i810_drv.c
> @@ -63,6 +63,7 @@ static struct drm_driver driver = {
>  	.load = i810_driver_load,
>  	.lastclose = i810_driver_lastclose,
>  	.preclose = i810_driver_preclose,
> +	.set_busid = drm_pci_set_busid,
>  	.device_is_agp = i810_driver_device_is_agp,
>  	.dma_quiescent = i810_driver_dma_quiescent,
>  	.ioctls = i810_ioctls,
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index e27cdbe..fa188b4 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1572,6 +1572,7 @@ static struct drm_driver driver = {
>  	.lastclose = i915_driver_lastclose,
>  	.preclose = i915_driver_preclose,
>  	.postclose = i915_driver_postclose,
> +	.set_busid = drm_pci_set_busid,
>  
>  	/* Used in place of i915_pm_ops for non-DRIVER_MODESET */
>  	.suspend = i915_suspend,
> diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
> index 6b1a87c..cb5c71f 100644
> --- a/drivers/gpu/drm/mga/mga_drv.c
> +++ b/drivers/gpu/drm/mga/mga_drv.c
> @@ -64,6 +64,7 @@ static struct drm_driver driver = {
>  	.load = mga_driver_load,
>  	.unload = mga_driver_unload,
>  	.lastclose = mga_driver_lastclose,
> +	.set_busid = drm_pci_set_busid,
>  	.dma_quiescent = mga_driver_dma_quiescent,
>  	.device_is_agp = mga_driver_device_is_agp,
>  	.get_vblank_counter = mga_get_vblank_counter,
> diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
> index 2d75d6d..9774599 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_drv.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
> @@ -91,6 +91,7 @@ static struct drm_driver driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET,
>  	.load = mgag200_driver_load,
>  	.unload = mgag200_driver_unload,
> +	.set_busid = drm_pci_set_busid,
>  	.fops = &mgag200_driver_fops,
>  	.name = DRIVER_NAME,
>  	.desc = DRIVER_DESC,
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index b447c01..47ccdbf 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -836,6 +836,7 @@ static struct drm_driver msm_driver = {
>  	.open               = msm_open,
>  	.preclose           = msm_preclose,
>  	.lastclose          = msm_lastclose,
> +	.set_busid          = drm_platform_set_busid,
>  	.irq_handler        = msm_irq,
>  	.irq_preinstall     = msm_irq_preinstall,
>  	.irq_postinstall    = msm_irq_postinstall,
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 250a5e8..cee1eaf 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -73,7 +73,9 @@ MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1
>  int nouveau_runtime_pm = -1;
>  module_param_named(runpm, nouveau_runtime_pm, int, 0400);
>  
> -static struct drm_driver driver;
> +static struct drm_driver driver_stub;
> +static struct drm_driver driver_pci;
> +static struct drm_driver driver_platform;
>  
>  static u64
>  nouveau_pci_name(struct pci_dev *pdev)
> @@ -322,7 +324,7 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
>  
>  	pci_set_master(pdev);
>  
> -	ret = drm_get_pci_dev(pdev, pent, &driver);
> +	ret = drm_get_pci_dev(pdev, pent, &driver_pci);
>  	if (ret) {
>  		nouveau_object_ref(NULL, (struct nouveau_object **)&device);
>  		return ret;
> @@ -855,7 +857,7 @@ nouveau_driver_fops = {
>  };
>  
>  static struct drm_driver
> -driver = {
> +driver_stub = {
>  	.driver_features =
>  		DRIVER_USE_AGP |
>  		DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER,
> @@ -1061,7 +1063,7 @@ nouveau_platform_device_create_(struct platform_device *pdev, int size,
>  	if (err)
>  		return ERR_PTR(err);
>  
> -	drm = drm_dev_alloc(&driver, &pdev->dev);
> +	drm = drm_dev_alloc(&driver_platform, &pdev->dev);
>  	if (!drm) {
>  		err = -ENOMEM;
>  		goto err_free;
> @@ -1086,6 +1088,11 @@ EXPORT_SYMBOL(nouveau_platform_device_create_);
>  static int __init
>  nouveau_drm_init(void)
>  {
> +	driver_pci = driver_stub;
> +	driver_pci.set_busid = drm_pci_set_busid;
> +	driver_platform = driver_stub;
> +	driver_platform.set_busid = drm_platform_set_busid;
> +
>  	if (nouveau_modeset == -1) {
>  #ifdef CONFIG_VGA_CONSOLE
>  		if (vgacon_text_force())
> @@ -1097,7 +1104,7 @@ nouveau_drm_init(void)
>  		return 0;
>  
>  	nouveau_register_dsm_handler();
> -	return drm_pci_init(&driver, &nouveau_drm_pci_driver);
> +	return drm_pci_init(&driver_pci, &nouveau_drm_pci_driver);
>  }
>  
>  static void __exit
> @@ -1106,7 +1113,7 @@ nouveau_drm_exit(void)
>  	if (!nouveau_modeset)
>  		return;
>  
> -	drm_pci_exit(&driver, &nouveau_drm_pci_driver);
> +	drm_pci_exit(&driver_pci, &nouveau_drm_pci_driver);
>  	nouveau_unregister_dsm_handler();
>  }
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 002b972..862ba03 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -629,6 +629,7 @@ static struct drm_driver omap_drm_driver = {
>  		.lastclose = dev_lastclose,
>  		.preclose = dev_preclose,
>  		.postclose = dev_postclose,
> +		.set_busid = drm_platform_set_busid,
>  		.get_vblank_counter = drm_vblank_count,
>  		.enable_vblank = omap_irq_enable_vblank,
>  		.disable_vblank = omap_irq_disable_vblank,
> diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
> index a3fd920..ab9a1e3 100644
> --- a/drivers/gpu/drm/qxl/qxl_drv.c
> +++ b/drivers/gpu/drm/qxl/qxl_drv.c
> @@ -216,6 +216,7 @@ static struct drm_driver qxl_driver = {
>  			   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
>  	.load = qxl_driver_load,
>  	.unload = qxl_driver_unload,
> +	.set_busid = drm_pci_set_busid,
>  
>  	.dumb_create = qxl_mode_dumb_create,
>  	.dumb_map_offset = qxl_mode_dumb_mmap,
> diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
> index 5bd307c..4a59370 100644
> --- a/drivers/gpu/drm/r128/r128_drv.c
> +++ b/drivers/gpu/drm/r128/r128_drv.c
> @@ -62,6 +62,7 @@ static struct drm_driver driver = {
>  	.load = r128_driver_load,
>  	.preclose = r128_driver_preclose,
>  	.lastclose = r128_driver_lastclose,
> +	.set_busid = drm_pci_set_busid,
>  	.get_vblank_counter = r128_get_vblank_counter,
>  	.enable_vblank = r128_enable_vblank,
>  	.disable_vblank = r128_disable_vblank,
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index f1e96e0..ec7e963 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -328,6 +328,7 @@ static struct drm_driver driver_old = {
>  	.preclose = radeon_driver_preclose,
>  	.postclose = radeon_driver_postclose,
>  	.lastclose = radeon_driver_lastclose,
> +	.set_busid = drm_pci_set_busid,
>  	.unload = radeon_driver_unload,
>  	.suspend = radeon_suspend,
>  	.resume = radeon_resume,
> @@ -551,6 +552,7 @@ static struct drm_driver kms_driver = {
>  	.preclose = radeon_driver_preclose_kms,
>  	.postclose = radeon_driver_postclose_kms,
>  	.lastclose = radeon_driver_lastclose_kms,
> +	.set_busid = drm_pci_set_busid,
>  	.unload = radeon_driver_unload_kms,
>  	.get_vblank_counter = radeon_get_vblank_counter_kms,
>  	.enable_vblank = radeon_enable_vblank_kms,
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> index fda64b7..672d2fc 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -158,6 +158,7 @@ static struct drm_driver rcar_du_driver = {
>  	.unload			= rcar_du_unload,
>  	.preclose		= rcar_du_preclose,
>  	.lastclose		= rcar_du_lastclose,
> +	.set_busid		= drm_platform_set_busid,
>  	.get_vblank_counter	= drm_vblank_count,
>  	.enable_vblank		= rcar_du_enable_vblank,
>  	.disable_vblank		= rcar_du_disable_vblank,
> diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
> index 3c03021..1b09d21 100644
> --- a/drivers/gpu/drm/savage/savage_drv.c
> +++ b/drivers/gpu/drm/savage/savage_drv.c
> @@ -57,6 +57,7 @@ static struct drm_driver driver = {
>  	.preclose = savage_reclaim_buffers,
>  	.lastclose = savage_driver_lastclose,
>  	.unload = savage_driver_unload,
> +	.set_busid = drm_pci_set_busid,
>  	.ioctls = savage_ioctls,
>  	.dma_ioctl = savage_bci_buffers,
>  	.fops = &savage_driver_fops,
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> index ff4ba48..873d12f 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
> @@ -267,6 +267,7 @@ static struct drm_driver shmob_drm_driver = {
>  	.load			= shmob_drm_load,
>  	.unload			= shmob_drm_unload,
>  	.preclose		= shmob_drm_preclose,
> +	.set_busid		= drm_platform_set_busid,
>  	.irq_handler		= shmob_drm_irq,
>  	.get_vblank_counter	= drm_vblank_count,
>  	.enable_vblank		= shmob_drm_enable_vblank,
> diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
> index 756f787..54858e6 100644
> --- a/drivers/gpu/drm/sis/sis_drv.c
> +++ b/drivers/gpu/drm/sis/sis_drv.c
> @@ -108,6 +108,7 @@ static struct drm_driver driver = {
>  	.open = sis_driver_open,
>  	.preclose = sis_reclaim_buffers_locked,
>  	.postclose = sis_driver_postclose,
> +	.set_busid = drm_pci_set_busid,
>  	.dma_quiescent = sis_idle,
>  	.lastclose = sis_lastclose,
>  	.ioctls = sis_ioctls,
> diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
> index 3492ca5..df533ff 100644
> --- a/drivers/gpu/drm/tdfx/tdfx_drv.c
> +++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
> @@ -55,6 +55,7 @@ static const struct file_operations tdfx_driver_fops = {
>  };
>  
>  static struct drm_driver driver = {
> +	.set_busid = drm_pci_set_busid,
>  	.fops = &tdfx_driver_fops,
>  	.name = DRIVER_NAME,
>  	.desc = DRIVER_DESC,
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> index 6be623b..aea4b766 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
> @@ -502,6 +502,7 @@ static struct drm_driver tilcdc_driver = {
>  	.unload             = tilcdc_unload,
>  	.preclose           = tilcdc_preclose,
>  	.lastclose          = tilcdc_lastclose,
> +	.set_busid          = drm_platform_set_busid,
>  	.irq_handler        = tilcdc_irq,
>  	.irq_preinstall     = tilcdc_irq_preinstall,
>  	.irq_postinstall    = tilcdc_irq_postinstall,
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 3ddd6cd..06675e5 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -34,6 +34,11 @@ MODULE_DEVICE_TABLE(usb, id_table);
>  
>  MODULE_LICENSE("GPL");
>  
> +static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m)
> +{
> +	return 0;
> +}
> +
>  static int udl_usb_probe(struct usb_interface *interface,
>  			 const struct usb_device_id *id)
>  {
> @@ -75,6 +80,7 @@ static struct drm_driver driver = {
>  	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
>  	.load = udl_driver_load,
>  	.unload = udl_driver_unload,
> +	.set_busid = udl_driver_set_busid,
>  
>  	/* gem hooks */
>  	.gem_free_object = udl_gem_free_object,
> diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
> index 50abc2a..c16ffa6 100644
> --- a/drivers/gpu/drm/via/via_drv.c
> +++ b/drivers/gpu/drm/via/via_drv.c
> @@ -79,6 +79,7 @@ static struct drm_driver driver = {
>  	.open = via_driver_open,
>  	.preclose = via_reclaim_buffers_locked,
>  	.postclose = via_driver_postclose,
> +	.set_busid = drm_pci_set_busid,
>  	.context_dtor = via_final_context,
>  	.get_vblank_counter = via_get_vblank_counter,
>  	.enable_vblank = via_enable_vblank,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 18b54ac..7197af1 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -1418,6 +1418,7 @@ static struct drm_driver driver = {
>  	.open = vmw_driver_open,
>  	.preclose = vmw_preclose,
>  	.postclose = vmw_postclose,
> +	.set_busid = drm_pci_set_busid,
>  
>  	.dumb_create = vmw_dumb_create,
>  	.dumb_map_offset = vmw_dumb_map_offset,
> diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
> index 6b22106..16392b6 100644
> --- a/drivers/staging/imx-drm/imx-drm-core.c
> +++ b/drivers/staging/imx-drm/imx-drm-core.c
> @@ -528,6 +528,7 @@ static struct drm_driver imx_drm_driver = {
>  	.unload			= imx_drm_driver_unload,
>  	.lastclose		= imx_drm_driver_lastclose,
>  	.preclose		= imx_drm_driver_preclose,
> +	.set_busid		= drm_platform_set_busid,
>  	.gem_free_object	= drm_gem_cma_free_object,
>  	.gem_vm_ops		= &drm_gem_cma_vm_ops,
>  	.dumb_create		= drm_gem_cma_dumb_create,
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 98b1eaf..c82f292 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -627,6 +627,7 @@ struct drm_driver {
>  	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
>  	int (*dma_quiescent) (struct drm_device *);
>  	int (*context_dtor) (struct drm_device *dev, int context);
> +	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
>  
>  	/**
>  	 * get_vblank_counter - get raw hardware vblank counter
> @@ -1498,6 +1499,7 @@ extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
>  extern int drm_get_pci_dev(struct pci_dev *pdev,
>  			   const struct pci_device_id *ent,
>  			   struct drm_driver *driver);
> +extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
>  
>  #define DRM_PCIE_SPEED_25 1
>  #define DRM_PCIE_SPEED_50 2
> @@ -1507,6 +1509,7 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
>  
>  /* platform section */
>  extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
> +extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
>  
>  /* returns true if currently okay to sleep */
>  static __inline__ bool drm_can_sleep(void)
> -- 
> 2.1.0
> 

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

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

* Re: [PATCH 18/20] drm: Goody bye, drm_bus!
  2014-08-29 10:12 ` [PATCH 18/20] drm: Goody bye, drm_bus! David Herrmann
  2014-08-29 12:55   ` Thierry Reding
@ 2014-08-29 13:02   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 13:02 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 12:12:44PM +0200, David Herrmann wrote:
> ..we will not miss you..
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

Since this is independant of how we'll get rid of bus->set_busid:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>


> ---
>  drivers/gpu/drm/drm_ioctl.c    |  8 +-------
>  drivers/gpu/drm/drm_pci.c      |  6 ------
>  drivers/gpu/drm/drm_platform.c |  5 -----
>  drivers/gpu/drm/drm_usb.c      | 12 ------------
>  include/drm/drmP.h             |  5 -----
>  5 files changed, 1 insertion(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 4770bd7..3a1349f 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -250,15 +250,9 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
>  			drm_unset_busid(dev, master);
>  			return ret;
>  		}
> -	} else if (dev->driver->bus && dev->driver->bus->set_busid) {
> -		ret = dev->driver->bus->set_busid(dev, master);
> -		if (ret) {
> -			drm_unset_busid(dev, master);
> -			return ret;
> -		}
>  	} else {
>  		if (WARN(dev->unique == NULL,
> -			 "No drm_bus.set_busid() implementation provided by "
> +			 "No drm_driver.set_busid() implementation provided by "
>  			 "%ps. Use drm_dev_set_unique() to set the unique "
>  			 "name explicitly.", dev->driver))
>  			return -EINVAL;
> diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
> index 0400c37..7563130 100644
> --- a/drivers/gpu/drm/drm_pci.c
> +++ b/drivers/gpu/drm/drm_pci.c
> @@ -254,10 +254,6 @@ void drm_pci_agp_destroy(struct drm_device *dev)
>  	}
>  }
>  
> -static struct drm_bus drm_pci_bus = {
> -	.set_busid = drm_pci_set_busid,
> -};
> -
>  /**
>   * drm_get_pci_dev - Register a PCI device with the DRM subsystem
>   * @pdev: PCI device
> @@ -338,8 +334,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
>  
>  	DRM_DEBUG("\n");
>  
> -	driver->bus = &drm_pci_bus;
> -
>  	if (driver->driver_features & DRIVER_MODESET)
>  		return pci_register_driver(pdriver);
>  
> diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
> index 939cd22..5314c9d 100644
> --- a/drivers/gpu/drm/drm_platform.c
> +++ b/drivers/gpu/drm/drm_platform.c
> @@ -86,10 +86,6 @@ int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
>  }
>  EXPORT_SYMBOL(drm_platform_set_busid);
>  
> -static struct drm_bus drm_platform_bus = {
> -	.set_busid = drm_platform_set_busid,
> -};
> -
>  /**
>   * drm_platform_init - Register a platform device with the DRM subsystem
>   * @driver: DRM device driver
> @@ -105,7 +101,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor
>  {
>  	DRM_DEBUG("\n");
>  
> -	driver->bus = &drm_platform_bus;
>  	return drm_get_platform_dev(platform_device, driver);
>  }
>  EXPORT_SYMBOL(drm_platform_init);
> diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
> index f2fe94a..9c43490 100644
> --- a/drivers/gpu/drm/drm_usb.c
> +++ b/drivers/gpu/drm/drm_usb.c
> @@ -36,16 +36,6 @@ err_free:
>  }
>  EXPORT_SYMBOL(drm_get_usb_dev);
>  
> -static int drm_usb_set_busid(struct drm_device *dev,
> -			       struct drm_master *master)
> -{
> -	return 0;
> -}
> -
> -static struct drm_bus drm_usb_bus = {
> -	.set_busid = drm_usb_set_busid,
> -};
> -
>  /**
>   * drm_usb_init - Register matching USB devices with the DRM subsystem
>   * @driver: DRM device driver
> @@ -61,8 +51,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
>  	int res;
>  	DRM_DEBUG("\n");
>  
> -	driver->bus = &drm_usb_bus;
> -
>  	res = usb_register(udriver);
>  	return res;
>  }
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index c82f292..5ae388a 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -605,10 +605,6 @@ struct drm_master {
>  #define DRM_SCANOUTPOS_INVBL        (1 << 1)
>  #define DRM_SCANOUTPOS_ACCURATE     (1 << 2)
>  
> -struct drm_bus {
> -	int (*set_busid)(struct drm_device *dev, struct drm_master *master);
> -};
> -
>  /**
>   * DRM driver structure. This structure represent the common code for
>   * a family of cards. There will one drm_device for each card present
> @@ -846,7 +842,6 @@ struct drm_driver {
>  	const struct drm_ioctl_desc *ioctls;
>  	int num_ioctls;
>  	const struct file_operations *fops;
> -	struct drm_bus *bus;
>  
>  	/* List of devices hanging off this driver with stealth attach. */
>  	struct list_head legacy_dev_list;
> -- 
> 2.1.0
> 

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

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

* Re: [PATCH 20/20] drm: move drm-lock API to drm_legacy.h
  2014-08-29 10:12 ` [PATCH 20/20] drm: move drm-lock API to drm_legacy.h David Herrmann
@ 2014-08-29 13:02   ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 13:02 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 12:12:46PM +0200, David Herrmann wrote:
> Same as the other legacy APIs, most of this is internal, so prefix it with
> drm_legacy_* and move into drm_legacy.h.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/drm_fops.c          |  6 +++---
>  drivers/gpu/drm/drm_ioctl.c         |  4 ++--
>  drivers/gpu/drm/drm_legacy.h        |  9 +++++++++
>  drivers/gpu/drm/drm_lock.c          | 20 +++++++++++---------
>  drivers/gpu/drm/i810/i810_dma.c     |  4 ++--
>  drivers/gpu/drm/savage/savage_bci.c |  4 ++--
>  drivers/gpu/drm/sis/sis_mm.c        |  6 +++---
>  drivers/gpu/drm/via/via_mm.c        |  6 +++---
>  include/drm/drmP.h                  | 14 +++-----------
>  9 files changed, 38 insertions(+), 35 deletions(-)

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 19/20] drm: merge drm_usb into udl
  2014-08-29 10:12 ` [PATCH 19/20] drm: merge drm_usb into udl David Herrmann
  2014-08-29 13:00   ` Thierry Reding
@ 2014-08-29 13:06   ` Daniel Vetter
  1 sibling, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 13:06 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 12:12:45PM +0200, David Herrmann wrote:
> This merges all the remains of drm_usb into its only user, udl. We can
> then drop all the drm_usb stuff, including dev->usbdev.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

A bit of (seemingly) unecessary code movement (the probe/disconnect
functions and id table). With or without that fixed this is

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

And it looks really, really pretty ;-)

> ---
>  Documentation/DocBook/drm.tmpl      |   3 +-
>  drivers/gpu/drm/Kconfig             |   6 ---
>  drivers/gpu/drm/Makefile            |   3 --
>  drivers/gpu/drm/drm_usb.c           |  76 ---------------------------
>  drivers/gpu/drm/udl/Kconfig         |   3 +-
>  drivers/gpu/drm/udl/udl_connector.c |   4 +-
>  drivers/gpu/drm/udl/udl_drv.c       | 102 +++++++++++++++++++++---------------
>  drivers/gpu/drm/udl/udl_drv.h       |   1 +
>  drivers/gpu/drm/udl/udl_main.c      |   8 +--
>  include/drm/drmP.h                  |   1 -
>  include/drm/drm_usb.h               |  15 ------
>  11 files changed, 70 insertions(+), 152 deletions(-)
>  delete mode 100644 drivers/gpu/drm/drm_usb.c
>  delete mode 100644 include/drm/drm_usb.h
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 5c299fa..99f7ee6 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -291,10 +291,9 @@ char *date;</synopsis>
>        <title>Device Registration</title>
>        <para>
>          A number of functions are provided to help with device registration.
> -        The functions deal with PCI, USB and platform devices, respectively.
> +        The functions deal with PCI and platform devices, respectively.
>        </para>
>  !Edrivers/gpu/drm/drm_pci.c
> -!Edrivers/gpu/drm/drm_usb.c
>  !Edrivers/gpu/drm/drm_platform.c
>        <para>
>          New drivers that no longer rely on the services provided by the
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index e3500f9..e3b4b0f 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -25,12 +25,6 @@ config DRM_MIPI_DSI
>  	bool
>  	depends on DRM
>  
> -config DRM_USB
> -	tristate
> -	depends on DRM
> -	depends on USB_SUPPORT && USB_ARCH_HAS_HCD
> -	select USB
> -
>  config DRM_KMS_HELPER
>  	tristate
>  	depends on DRM
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 9b7cb3f..9292a76 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -22,8 +22,6 @@ drm-$(CONFIG_PCI) += ati_pcigart.o
>  drm-$(CONFIG_DRM_PANEL) += drm_panel.o
>  drm-$(CONFIG_OF) += drm_of.o
>  
> -drm-usb-y   := drm_usb.o
> -
>  drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
>  		drm_plane_helper.o drm_dp_mst_topology.o
>  drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
> @@ -36,7 +34,6 @@ CFLAGS_drm_trace_points.o := -I$(src)
>  
>  obj-$(CONFIG_DRM)	+= drm.o
>  obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
> -obj-$(CONFIG_DRM_USB)   += drm_usb.o
>  obj-$(CONFIG_DRM_TTM)	+= ttm/
>  obj-$(CONFIG_DRM_TDFX)	+= tdfx/
>  obj-$(CONFIG_DRM_R128)	+= r128/
> diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
> deleted file mode 100644
> index 9c43490..0000000
> --- a/drivers/gpu/drm/drm_usb.c
> +++ /dev/null
> @@ -1,76 +0,0 @@
> -#include <drm/drmP.h>
> -#include <drm/drm_usb.h>
> -#include <linux/usb.h>
> -#include <linux/module.h>
> -
> -int drm_get_usb_dev(struct usb_interface *interface,
> -		    const struct usb_device_id *id,
> -		    struct drm_driver *driver)
> -{
> -	struct drm_device *dev;
> -	int ret;
> -
> -	DRM_DEBUG("\n");
> -
> -	dev = drm_dev_alloc(driver, &interface->dev);
> -	if (!dev)
> -		return -ENOMEM;
> -
> -	dev->usbdev = interface_to_usbdev(interface);
> -	usb_set_intfdata(interface, dev);
> -
> -	ret = drm_dev_register(dev, 0);
> -	if (ret)
> -		goto err_free;
> -
> -	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
> -		 driver->name, driver->major, driver->minor, driver->patchlevel,
> -		 driver->date, dev->primary->index);
> -
> -	return 0;
> -
> -err_free:
> -	drm_dev_unref(dev);
> -	return ret;
> -
> -}
> -EXPORT_SYMBOL(drm_get_usb_dev);
> -
> -/**
> - * drm_usb_init - Register matching USB devices with the DRM subsystem
> - * @driver: DRM device driver
> - * @udriver: USB device driver
> - *
> - * Registers one or more devices matched by a USB driver with the DRM
> - * subsystem.
> - *
> - * Return: 0 on success or a negative error code on failure.
> - */
> -int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
> -{
> -	int res;
> -	DRM_DEBUG("\n");
> -
> -	res = usb_register(udriver);
> -	return res;
> -}
> -EXPORT_SYMBOL(drm_usb_init);
> -
> -/**
> - * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
> - * @driver: DRM device driver
> - * @udriver: USB device driver
> - *
> - * Unregisters one or more devices matched by a USB driver from the DRM
> - * subsystem.
> - */
> -void drm_usb_exit(struct drm_driver *driver,
> -		  struct usb_driver *udriver)
> -{
> -	usb_deregister(udriver);
> -}
> -EXPORT_SYMBOL(drm_usb_exit);
> -
> -MODULE_AUTHOR("David Airlie");
> -MODULE_DESCRIPTION("USB DRM support");
> -MODULE_LICENSE("GPL and additional rights");
> diff --git a/drivers/gpu/drm/udl/Kconfig b/drivers/gpu/drm/udl/Kconfig
> index f025286..613ab06 100644
> --- a/drivers/gpu/drm/udl/Kconfig
> +++ b/drivers/gpu/drm/udl/Kconfig
> @@ -1,8 +1,9 @@
>  config DRM_UDL
>  	tristate "DisplayLink"
>  	depends on DRM
> +	depends on USB_SUPPORT
>  	depends on USB_ARCH_HAS_HCD
> -	select DRM_USB
> +	select USB
>  	select FB_SYS_FILLRECT
>  	select FB_SYS_COPYAREA
>  	select FB_SYS_IMAGEBLIT
> diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
> index e026a9e..0110d95 100644
> --- a/drivers/gpu/drm/udl/udl_connector.c
> +++ b/drivers/gpu/drm/udl/udl_connector.c
> @@ -34,8 +34,8 @@ static u8 *udl_get_edid(struct udl_device *udl)
>  		goto error;
>  
>  	for (i = 0; i < EDID_LENGTH; i++) {
> -		ret = usb_control_msg(udl->ddev->usbdev,
> -				      usb_rcvctrlpipe(udl->ddev->usbdev, 0), (0x02),
> +		ret = usb_control_msg(udl->udev,
> +				      usb_rcvctrlpipe(udl->udev, 0), (0x02),
>  				      (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2,
>  				      HZ);
>  		if (ret < 1) {
> diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
> index 06675e5..8607e9e 100644
> --- a/drivers/gpu/drm/udl/udl_drv.c
> +++ b/drivers/gpu/drm/udl/udl_drv.c
> @@ -7,55 +7,15 @@
>   */
>  
>  #include <linux/module.h>
> -#include <drm/drm_usb.h>
> +#include <drm/drmP.h>
>  #include <drm/drm_crtc_helper.h>
>  #include "udl_drv.h"
>  
> -static struct drm_driver driver;
> -
> -/*
> - * There are many DisplayLink-based graphics products, all with unique PIDs.
> - * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
> - * We also require a match on SubClass (0x00) and Protocol (0x00),
> - * which is compatible with all known USB 2.0 era graphics chips and firmware,
> - * but allows DisplayLink to increment those for any future incompatible chips
> - */
> -static struct usb_device_id id_table[] = {
> -	{.idVendor = 0x17e9, .bInterfaceClass = 0xff,
> -	 .bInterfaceSubClass = 0x00,
> -	 .bInterfaceProtocol = 0x00,
> -	 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
> -			USB_DEVICE_ID_MATCH_INT_CLASS |
> -			USB_DEVICE_ID_MATCH_INT_SUBCLASS |
> -			USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
> -	{},
> -};
> -MODULE_DEVICE_TABLE(usb, id_table);
> -
> -MODULE_LICENSE("GPL");
> -
>  static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m)
>  {
>  	return 0;
>  }
>  
> -static int udl_usb_probe(struct usb_interface *interface,
> -			 const struct usb_device_id *id)
> -{
> -	return drm_get_usb_dev(interface, id, &driver);
> -}
> -
> -static void udl_usb_disconnect(struct usb_interface *interface)
> -{
> -	struct drm_device *dev = usb_get_intfdata(interface);
> -
> -	drm_kms_helper_poll_disable(dev);
> -	drm_connector_unplug_all(dev);
> -	udl_fbdev_unplug(dev);
> -	udl_drop_usb(dev);
> -	drm_unplug_dev(dev);
> -}
> -
>  static const struct vm_operations_struct udl_gem_vm_ops = {
>  	.fault = udl_gem_fault,
>  	.open = drm_gem_vm_open,
> @@ -102,6 +62,61 @@ static struct drm_driver driver = {
>  	.patchlevel = DRIVER_PATCHLEVEL,
>  };
>  
> +static int udl_usb_probe(struct usb_interface *interface,
> +			 const struct usb_device_id *id)
> +{
> +	struct usb_device *udev = interface_to_usbdev(interface);
> +	struct drm_device *dev;
> +	int r;
> +
> +	dev = drm_dev_alloc(&driver, &interface->dev);
> +	if (!dev)
> +		return -ENOMEM;
> +
> +	r = drm_dev_register(dev, (unsigned long)udev);
> +	if (r)
> +		goto err_free;
> +
> +	usb_set_intfdata(interface, dev);
> +	DRM_INFO("Initialized udl on minor %d\n", dev->primary->index);
> +
> +	return 0;
> +
> +err_free:
> +	drm_dev_unref(dev);
> +	return r;
> +}
> +
> +static void udl_usb_disconnect(struct usb_interface *interface)
> +{
> +	struct drm_device *dev = usb_get_intfdata(interface);
> +
> +	drm_kms_helper_poll_disable(dev);
> +	drm_connector_unplug_all(dev);
> +	udl_fbdev_unplug(dev);
> +	udl_drop_usb(dev);
> +	drm_unplug_dev(dev);
> +}
> +
> +/*
> + * There are many DisplayLink-based graphics products, all with unique PIDs.
> + * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
> + * We also require a match on SubClass (0x00) and Protocol (0x00),
> + * which is compatible with all known USB 2.0 era graphics chips and firmware,
> + * but allows DisplayLink to increment those for any future incompatible chips
> + */
> +static struct usb_device_id id_table[] = {
> +	{.idVendor = 0x17e9, .bInterfaceClass = 0xff,
> +	 .bInterfaceSubClass = 0x00,
> +	 .bInterfaceProtocol = 0x00,
> +	 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
> +			USB_DEVICE_ID_MATCH_INT_CLASS |
> +			USB_DEVICE_ID_MATCH_INT_SUBCLASS |
> +			USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(usb, id_table);
> +
>  static struct usb_driver udl_driver = {
>  	.name = "udl",
>  	.probe = udl_usb_probe,
> @@ -111,13 +126,14 @@ static struct usb_driver udl_driver = {
>  
>  static int __init udl_init(void)
>  {
> -	return drm_usb_init(&driver, &udl_driver);
> +	return usb_register(&udl_driver);
>  }
>  
>  static void __exit udl_exit(void)
>  {
> -	drm_usb_exit(&driver, &udl_driver);
> +	usb_deregister(&udl_driver);
>  }
>  
>  module_init(udl_init);
>  module_exit(udl_exit);
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
> index 1fbf7b3..51e10ee 100644
> --- a/drivers/gpu/drm/udl/udl_drv.h
> +++ b/drivers/gpu/drm/udl/udl_drv.h
> @@ -47,6 +47,7 @@ struct udl_fbdev;
>  struct udl_device {
>  	struct device *dev;
>  	struct drm_device *ddev;
> +	struct usb_device *udev;
>  
>  	int sku_pixel_limit;
>  
> diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
> index 4279567..33dbfb2 100644
> --- a/drivers/gpu/drm/udl/udl_main.c
> +++ b/drivers/gpu/drm/udl/udl_main.c
> @@ -202,7 +202,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
>  		}
>  		unode->urb = urb;
>  
> -		buf = usb_alloc_coherent(udl->ddev->usbdev, MAX_TRANSFER, GFP_KERNEL,
> +		buf = usb_alloc_coherent(udl->udev, MAX_TRANSFER, GFP_KERNEL,
>  					 &urb->transfer_dma);
>  		if (!buf) {
>  			kfree(unode);
> @@ -211,7 +211,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
>  		}
>  
>  		/* urb->transfer_buffer_length set to actual before submit */
> -		usb_fill_bulk_urb(urb, udl->ddev->usbdev, usb_sndbulkpipe(udl->ddev->usbdev, 1),
> +		usb_fill_bulk_urb(urb, udl->udev, usb_sndbulkpipe(udl->udev, 1),
>  			buf, size, udl_urb_completion, unode);
>  		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
>  
> @@ -282,6 +282,7 @@ int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len)
>  
>  int udl_driver_load(struct drm_device *dev, unsigned long flags)
>  {
> +	struct usb_device *udev = (void*)flags;
>  	struct udl_device *udl;
>  	int ret = -ENOMEM;
>  
> @@ -290,10 +291,11 @@ int udl_driver_load(struct drm_device *dev, unsigned long flags)
>  	if (!udl)
>  		return -ENOMEM;
>  
> +	udl->udev = udev;
>  	udl->ddev = dev;
>  	dev->dev_private = udl;
>  
> -	if (!udl_parse_vendor_descriptor(dev, dev->usbdev)) {
> +	if (!udl_parse_vendor_descriptor(dev, udl->udev)) {
>  		ret = -ENODEV;
>  		DRM_ERROR("firmware not recognized. Assume incompatible device\n");
>  		goto err;
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 5ae388a..0e73aad 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1020,7 +1020,6 @@ struct drm_device {
>  #endif
>  
>  	struct platform_device *platformdev; /**< Platform device struture */
> -	struct usb_device *usbdev;
>  
>  	struct drm_sg_mem *sg;	/**< Scatter gather memory */
>  	unsigned int num_crtcs;                  /**< Number of CRTCs on this device */
> diff --git a/include/drm/drm_usb.h b/include/drm/drm_usb.h
> deleted file mode 100644
> index 33506c11..0000000
> --- a/include/drm/drm_usb.h
> +++ /dev/null
> @@ -1,15 +0,0 @@
> -#ifndef DRM_USB_H
> -#define DRM_USB_H
> -
> -#include <drmP.h>
> -
> -#include <linux/usb.h>
> -
> -extern int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver);
> -extern void drm_usb_exit(struct drm_driver *driver, struct usb_driver *udriver);
> -
> -int drm_get_usb_dev(struct usb_interface *interface,
> -		    const struct usb_device_id *id,
> -		    struct drm_driver *driver);
> -
> -#endif
> -- 
> 2.1.0
> 

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

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

* Re: [PATCH 00/20] DRM: Core Cleanups
  2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
                   ` (19 preceding siblings ...)
  2014-08-29 10:12 ` [PATCH 20/20] drm: move drm-lock API to drm_legacy.h David Herrmann
@ 2014-08-29 13:08 ` Daniel Vetter
  20 siblings, 0 replies; 53+ messages in thread
From: Daniel Vetter @ 2014-08-29 13:08 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, dri-devel

On Fri, Aug 29, 2014 at 12:12:26PM +0200, David Herrmann wrote:
> Hi
> 
> More cleanups of DRM core code. Diffstat says:
>  72 files changed, 832 insertions(+), 1038 deletions(-)
> 
> ..which is already nice, but doesn't reflect that a lot of code is now hidden
> from main headers. Furthermore, with this series applied, drmP.h no longer looks
> as ugly as it is now (widly unstructured). It still ain't a beauty, though:
>  include/drm/drmP.h                       | 236 ++++++++-----------------------
> 
> Anyhow, highlights:
>  - drop "drm_memory.h"
>  - drop "drm_usb.c"
>  - drop "struct drm_waitlist"
>  - drop "struct drm_sigdata"
>  - drop "struct drm_bus"
>  - drop "drm_master->unique_size"
> 
> Two patches are driver related:
>  - radeon: Patch #1, moves drm_buffer.c to radeon/
>  - nouveau: Patch #17, splits drm_driver for nouveau
> They're rather trivial. Everything else is DRM-core.
> 
> I've moved some legacy stuff around so it's easier to drop it once unused. If
> someone disagrees with move, let me know and I'll drop the patch.
> 
> I've pushed this to the 0-day testing bots now. I'll comment on the patches in
> case something shows up.
> 
> Comments welcome!
> David
> 
> 
> David Herrmann (20):
>   drm/radeon: move drm_buffer to drm/radeon/
>   drm: mark drm_buf and drm_map as legacy
>   drm: move "struct drm_vma_entry" to drm_vm.c
>   drm: move "struct drm_magic_entry" to drm_auth.c
>   drm: drop unused "struct drm_waitlist"
>   drm: move AGP definitions harder
>   drm: replace weird conditional includes
>   drm: drop __KERNEL__ protection in drmP.h
>   drm: merge drm_memory.h into drm_memory.c
>   drm: move __OS_HAS_AGP into drm_agpsupport.h
>   drm: order includes alphabetically in drmP.h
>   drm: drop DRM_DEBUG_CODE
>   drm: inline "struct drm_sigdata"
>   drm: move remaining includes in drmP.h to the top
>   drm: simplify drm_*_set_unique()
>   drm: drop unused drm_master->unique_size
>   drm: add driver->set_busid() callback
>   drm: Goody bye, drm_bus!
>   drm: merge drm_usb into udl
>   drm: move drm-lock API to drm_legacy.h

Oh well, I've thought I'll be lazy and only review what Thierry didn't
look at yet ;-) I guess should have looked at the time-stamps.

Anyway nothing else but what Thierry spotted, so Ack on all the patches I
didn't comment on. And thanks a lot for doing this.
-Daniel

> 
>  Documentation/DocBook/drm.tmpl           |   3 +-
>  drivers/gpu/drm/Kconfig                  |   6 -
>  drivers/gpu/drm/Makefile                 |   5 +-
>  drivers/gpu/drm/armada/armada_drv.c      |   1 +
>  drivers/gpu/drm/ast/ast_drv.c            |   1 +
>  drivers/gpu/drm/bochs/bochs_drv.c        |   1 +
>  drivers/gpu/drm/cirrus/cirrus_drv.c      |   1 +
>  drivers/gpu/drm/drm_agpsupport.c         |   1 +
>  drivers/gpu/drm/drm_auth.c               |   6 +
>  drivers/gpu/drm/drm_buffer.c             | 181 ------------------------
>  drivers/gpu/drm/drm_bufs.c               |  89 ++++++------
>  drivers/gpu/drm/drm_debugfs.c            |   2 -
>  drivers/gpu/drm/drm_drv.c                |  11 +-
>  drivers/gpu/drm/drm_fops.c               |  16 +--
>  drivers/gpu/drm/drm_info.c               |  59 --------
>  drivers/gpu/drm/drm_ioctl.c              |  27 ++--
>  drivers/gpu/drm/drm_legacy.h             |  39 +++++
>  drivers/gpu/drm/drm_lock.c               |  35 ++---
>  drivers/gpu/drm/drm_memory.c             |  12 ++
>  drivers/gpu/drm/drm_pci.c                |  41 ++----
>  drivers/gpu/drm/drm_platform.c           |  38 ++---
>  drivers/gpu/drm/drm_usb.c                |  88 ------------
>  drivers/gpu/drm/drm_vm.c                 |  74 ++++++++++
>  drivers/gpu/drm/exynos/exynos_drm_drv.c  |   1 +
>  drivers/gpu/drm/gma500/psb_drv.c         |   1 +
>  drivers/gpu/drm/i810/i810_dma.c          |   4 +-
>  drivers/gpu/drm/i810/i810_drv.c          |   1 +
>  drivers/gpu/drm/i915/i915_dma.c          |   2 +-
>  drivers/gpu/drm/i915/i915_drv.c          |   1 +
>  drivers/gpu/drm/mga/mga_dma.c            |  49 +++----
>  drivers/gpu/drm/mga/mga_drv.c            |   1 +
>  drivers/gpu/drm/mgag200/mgag200_drv.c    |   1 +
>  drivers/gpu/drm/msm/msm_drv.c            |   1 +
>  drivers/gpu/drm/nouveau/nouveau_drm.c    |  19 ++-
>  drivers/gpu/drm/omapdrm/omap_drv.c       |   1 +
>  drivers/gpu/drm/qxl/qxl_drv.c            |   1 +
>  drivers/gpu/drm/r128/r128_cce.c          |   2 +-
>  drivers/gpu/drm/r128/r128_drv.c          |   1 +
>  drivers/gpu/drm/radeon/Makefile          |   2 +-
>  drivers/gpu/drm/radeon/drm_buffer.c      | 177 +++++++++++++++++++++++
>  drivers/gpu/drm/radeon/drm_buffer.h      | 148 +++++++++++++++++++
>  drivers/gpu/drm/radeon/r300_cmdbuf.c     |   2 +-
>  drivers/gpu/drm/radeon/r600_cp.c         |   2 +-
>  drivers/gpu/drm/radeon/radeon.h          |  17 ++-
>  drivers/gpu/drm/radeon/radeon_cp.c       |  22 +--
>  drivers/gpu/drm/radeon/radeon_drv.c      |   2 +
>  drivers/gpu/drm/radeon/radeon_ring.c     |  21 ---
>  drivers/gpu/drm/radeon/radeon_state.c    |   2 +-
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c    |   1 +
>  drivers/gpu/drm/savage/savage_bci.c      |  23 +--
>  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/sis/sis_mm.c             |   6 +-
>  drivers/gpu/drm/tdfx/tdfx_drv.c          |   1 +
>  drivers/gpu/drm/tilcdc/tilcdc_drv.c      |   1 +
>  drivers/gpu/drm/udl/Kconfig              |   3 +-
>  drivers/gpu/drm/udl/udl_connector.c      |   4 +-
>  drivers/gpu/drm/udl/udl_drv.c            | 102 +++++++------
>  drivers/gpu/drm/udl/udl_drv.h            |   1 +
>  drivers/gpu/drm/udl/udl_main.c           |   8 +-
>  drivers/gpu/drm/via/via_drv.c            |   1 +
>  drivers/gpu/drm/via/via_map.c            |   2 +-
>  drivers/gpu/drm/via/via_mm.c             |   6 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      |   1 +
>  drivers/staging/imx-drm/imx-drm-core.c   |   1 +
>  include/drm/drmP.h                       | 236 ++++++++-----------------------
>  include/drm/drm_agpsupport.h             |  26 +++-
>  include/drm/drm_buffer.h                 | 148 -------------------
>  include/drm/drm_crtc.h                   |   4 +-
>  include/drm/drm_memory.h                 |  59 --------
>  include/drm/drm_usb.h                    |  15 --
>  72 files changed, 832 insertions(+), 1038 deletions(-)
>  delete mode 100644 drivers/gpu/drm/drm_buffer.c
>  delete mode 100644 drivers/gpu/drm/drm_usb.c
>  create mode 100644 drivers/gpu/drm/radeon/drm_buffer.c
>  create mode 100644 drivers/gpu/drm/radeon/drm_buffer.h
>  delete mode 100644 include/drm/drm_buffer.h
>  delete mode 100644 include/drm/drm_memory.h
>  delete mode 100644 include/drm/drm_usb.h
> 
> -- 
> 2.1.0
> 

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

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

* Re: [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c
  2014-08-29 12:43     ` Daniel Vetter
@ 2014-08-29 13:26       ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 13:26 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 02:43:10PM +0200, Daniel Vetter wrote:
> On Fri, Aug 29, 2014 at 01:56:23PM +0200, Thierry Reding wrote:
> > On Fri, Aug 29, 2014 at 12:12:35PM +0200, David Herrmann wrote:
> > > The drm_memory.h header is only used to define PAGE_AGP, which is only
> > > used in drm_memory.c. Fold the header into drm_memory.c and drop it.
> > > 
> > > Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> > > ---
> > >  drivers/gpu/drm/drm_memory.c | 11 +++++++++
> > >  include/drm/drmP.h           |  6 ++---
> > >  include/drm/drm_memory.h     | 59 --------------------------------------------
> > >  3 files changed, 13 insertions(+), 63 deletions(-)
> > >  delete mode 100644 include/drm/drm_memory.h
> > > 
> > > diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> > > index 7888dad..62fda6a 100644
> > > --- a/drivers/gpu/drm/drm_memory.c
> > > +++ b/drivers/gpu/drm/drm_memory.c
> > > @@ -39,6 +39,17 @@
> > >  #include "drm_legacy.h"
> > >  
> > >  #if __OS_HAS_AGP
> > > +
> > > +#ifdef HAVE_PAGE_AGP
> > > +# include <asm/agp.h>
> > > +#else
> > 
> > This check seems to be redundant. All architectures that support AGP
> > provide this header.
> > 
> > > +# ifdef __powerpc__
> > > +#  define PAGE_AGP	__pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE)
> > 
> > Is this even necessary? It seems like PowerPC always defines
> > HAVE_PAGE_AGP.
> 
> Iirc I've tried to untangle this before and I'm not 100% this is actually
> the case on all ppc platforms. It looked like there's some crazy include
> header depency stuff going on.

Interestingly, I don't even see _PAGE_KERNEL defined on PowerPC...

> But given how popular drm on ppc and that the few platforms where people
> actually use gpus are the saner ones (hopefully) I think we can just move
> ahead with this change and fixup any compile breakage once it's reported.
> If there is any.

I'm not objecting to this change since it's merely reorganizing code.
This is just more possible future cleanup.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 17/20] drm: add driver->set_busid() callback
  2014-08-29 13:01   ` Daniel Vetter
@ 2014-08-29 13:30     ` Thierry Reding
  0 siblings, 0 replies; 53+ messages in thread
From: Thierry Reding @ 2014-08-29 13:30 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Daniel Vetter, dri-devel


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

On Fri, Aug 29, 2014 at 03:01:00PM +0200, Daniel Vetter wrote:
> On Fri, Aug 29, 2014 at 12:12:43PM +0200, David Herrmann wrote:
> > One step closer to dropping all the drm_bus_* code:
> > Add a driver->set_busid() callback and make all drivers use the generic
> > helpers. Nouveau is the only driver that uses two different bus-types with
> > the same drm_driver. This is totally broken if both buses are available on
> > the same machine (unlikely, but lets be safe). Therefore, we create two
> > different drivers for each platform during module_init() and set the
> > set_busid() callback respectively.
> > 
> > Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> 
> This has a bit a midlayer smell to it tbh, we don't really need a
> set_busid callback I think. Instead there's just two cases:
> - The crazy implementation for pci devices. But we already have dev->pdev,
>   so the core can figure this out itself.
> - Everyone else just sets a static name. For those I think we should just
>   add a drm_dev_set_busid function which they can call in their
>   driver-load function. Well maybe different versions for platform drivers
>   and stuff.

We already have drm_dev_set_unique() for exactly this purpose. I think
drivers can just be converted to use that one at a time and when no
users are left we can drop drm_*_set_busid().

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 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] 53+ messages in thread

* Re: [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/
  2014-08-29 10:12 ` [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/ David Herrmann
  2014-08-29 11:20   ` Thierry Reding
@ 2014-09-08  4:08   ` Alex Deucher
  1 sibling, 0 replies; 53+ messages in thread
From: Alex Deucher @ 2014-09-08  4:08 UTC (permalink / raw)
  To: David Herrmann; +Cc: Daniel Vetter, Maling list - DRI developers

On Fri, Aug 29, 2014 at 6:12 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Radeon UMS is the last user of drm_buffer. Move it out of sight so radeon
> can drop it together with UMS.
>
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>


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

We can probably dump radeon UMS support as well at this point.

Alex

> ---
>  drivers/gpu/drm/Makefile              |   2 +-
>  drivers/gpu/drm/drm_buffer.c          | 181 ----------------------------------
>  drivers/gpu/drm/radeon/Makefile       |   2 +-
>  drivers/gpu/drm/radeon/drm_buffer.c   | 177 +++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/radeon/drm_buffer.h   | 148 +++++++++++++++++++++++++++
>  drivers/gpu/drm/radeon/r300_cmdbuf.c  |   2 +-
>  drivers/gpu/drm/radeon/radeon_state.c |   2 +-
>  include/drm/drm_buffer.h              | 148 ---------------------------
>  8 files changed, 329 insertions(+), 333 deletions(-)
>  delete mode 100644 drivers/gpu/drm/drm_buffer.c
>  create mode 100644 drivers/gpu/drm/radeon/drm_buffer.c
>  create mode 100644 drivers/gpu/drm/radeon/drm_buffer.h
>  delete mode 100644 include/drm/drm_buffer.h
>
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 4a55d59..9b7cb3f 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -4,7 +4,7 @@
>
>  ccflags-y := -Iinclude/drm
>
> -drm-y       := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
> +drm-y       := drm_auth.o drm_bufs.o drm_cache.o \
>                 drm_context.o drm_dma.o \
>                 drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
>                 drm_lock.o drm_memory.o drm_drv.o drm_vm.o \
> diff --git a/drivers/gpu/drm/drm_buffer.c b/drivers/gpu/drm/drm_buffer.c
> deleted file mode 100644
> index 86a4a4a..0000000
> --- a/drivers/gpu/drm/drm_buffer.c
> +++ /dev/null
> @@ -1,181 +0,0 @@
> -/**************************************************************************
> - *
> - * Copyright 2010 Pauli Nieminen.
> - * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
> - * THE COPYRIGHT HOLDERS, AUTHORS 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.
> - *
> - *
> - **************************************************************************/
> -/*
> - * Multipart buffer for coping data which is larger than the page size.
> - *
> - * Authors:
> - * Pauli Nieminen <suokkos-at-gmail-dot-com>
> - */
> -
> -#include <linux/export.h>
> -#include <drm/drm_buffer.h>
> -
> -/**
> - * Allocate the drm buffer object.
> - *
> - *   buf: Pointer to a pointer where the object is stored.
> - *   size: The number of bytes to allocate.
> - */
> -int drm_buffer_alloc(struct drm_buffer **buf, int size)
> -{
> -       int nr_pages = size / PAGE_SIZE + 1;
> -       int idx;
> -
> -       /* Allocating pointer table to end of structure makes drm_buffer
> -        * variable sized */
> -       *buf = kzalloc(sizeof(struct drm_buffer) + nr_pages*sizeof(char *),
> -                       GFP_KERNEL);
> -
> -       if (*buf == NULL) {
> -               DRM_ERROR("Failed to allocate drm buffer object to hold"
> -                               " %d bytes in %d pages.\n",
> -                               size, nr_pages);
> -               return -ENOMEM;
> -       }
> -
> -       (*buf)->size = size;
> -
> -       for (idx = 0; idx < nr_pages; ++idx) {
> -
> -               (*buf)->data[idx] =
> -                       kmalloc(min(PAGE_SIZE, size - idx * PAGE_SIZE),
> -                               GFP_KERNEL);
> -
> -
> -               if ((*buf)->data[idx] == NULL) {
> -                       DRM_ERROR("Failed to allocate %dth page for drm"
> -                                       " buffer with %d bytes and %d pages.\n",
> -                                       idx + 1, size, nr_pages);
> -                       goto error_out;
> -               }
> -
> -       }
> -
> -       return 0;
> -
> -error_out:
> -
> -       for (; idx >= 0; --idx)
> -               kfree((*buf)->data[idx]);
> -
> -       kfree(*buf);
> -       return -ENOMEM;
> -}
> -EXPORT_SYMBOL(drm_buffer_alloc);
> -
> -/**
> - * Copy the user data to the begin of the buffer and reset the processing
> - * iterator.
> - *
> - *   user_data: A pointer the data that is copied to the buffer.
> - *   size: The Number of bytes to copy.
> - */
> -int drm_buffer_copy_from_user(struct drm_buffer *buf,
> -                             void __user *user_data, int size)
> -{
> -       int nr_pages = size / PAGE_SIZE + 1;
> -       int idx;
> -
> -       if (size > buf->size) {
> -               DRM_ERROR("Requesting to copy %d bytes to a drm buffer with"
> -                               " %d bytes space\n",
> -                               size, buf->size);
> -               return -EFAULT;
> -       }
> -
> -       for (idx = 0; idx < nr_pages; ++idx) {
> -
> -               if (copy_from_user(buf->data[idx],
> -                       user_data + idx * PAGE_SIZE,
> -                       min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
> -                       DRM_ERROR("Failed to copy user data (%p) to drm buffer"
> -                                       " (%p) %dth page.\n",
> -                                       user_data, buf, idx);
> -                       return -EFAULT;
> -
> -               }
> -       }
> -       buf->iterator = 0;
> -       return 0;
> -}
> -EXPORT_SYMBOL(drm_buffer_copy_from_user);
> -
> -/**
> - * Free the drm buffer object
> - */
> -void drm_buffer_free(struct drm_buffer *buf)
> -{
> -
> -       if (buf != NULL) {
> -
> -               int nr_pages = buf->size / PAGE_SIZE + 1;
> -               int idx;
> -               for (idx = 0; idx < nr_pages; ++idx)
> -                       kfree(buf->data[idx]);
> -
> -               kfree(buf);
> -       }
> -}
> -EXPORT_SYMBOL(drm_buffer_free);
> -
> -/**
> - * Read an object from buffer that may be split to multiple parts. If object
> - * is not split function just returns the pointer to object in buffer. But in
> - * case of split object data is copied to given stack object that is suplied
> - * by caller.
> - *
> - * The processing location of the buffer is also advanced to the next byte
> - * after the object.
> - *
> - *   objsize: The size of the objet in bytes.
> - *   stack_obj: A pointer to a memory location where object can be copied.
> - */
> -void *drm_buffer_read_object(struct drm_buffer *buf,
> -               int objsize, void *stack_obj)
> -{
> -       int idx = drm_buffer_index(buf);
> -       int page = drm_buffer_page(buf);
> -       void *obj = NULL;
> -
> -       if (idx + objsize <= PAGE_SIZE) {
> -               obj = &buf->data[page][idx];
> -       } else {
> -               /* The object is split which forces copy to temporary object.*/
> -               int beginsz = PAGE_SIZE - idx;
> -               memcpy(stack_obj, &buf->data[page][idx], beginsz);
> -
> -               memcpy(stack_obj + beginsz, &buf->data[page + 1][0],
> -                               objsize - beginsz);
> -
> -               obj = stack_obj;
> -       }
> -
> -       drm_buffer_advance(buf, objsize);
> -       return obj;
> -}
> -EXPORT_SYMBOL(drm_buffer_read_object);
> diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
> index 357f09a..7d7aed5 100644
> --- a/drivers/gpu/drm/radeon/Makefile
> +++ b/drivers/gpu/drm/radeon/Makefile
> @@ -60,7 +60,7 @@ radeon-y := radeon_drv.o
>
>  # add UMS driver
>  radeon-$(CONFIG_DRM_RADEON_UMS)+= radeon_cp.o radeon_state.o radeon_mem.o \
> -       radeon_irq.o r300_cmdbuf.o r600_cp.o r600_blit.o
> +       radeon_irq.o r300_cmdbuf.o r600_cp.o r600_blit.o drm_buffer.o
>
>  # add KMS driver
>  radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
> diff --git a/drivers/gpu/drm/radeon/drm_buffer.c b/drivers/gpu/drm/radeon/drm_buffer.c
> new file mode 100644
> index 0000000..f4e0f3a
> --- /dev/null
> +++ b/drivers/gpu/drm/radeon/drm_buffer.c
> @@ -0,0 +1,177 @@
> +/**************************************************************************
> + *
> + * Copyright 2010 Pauli Nieminen.
> + * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDERS, AUTHORS 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.
> + *
> + *
> + **************************************************************************/
> +/*
> + * Multipart buffer for coping data which is larger than the page size.
> + *
> + * Authors:
> + * Pauli Nieminen <suokkos-at-gmail-dot-com>
> + */
> +
> +#include <linux/export.h>
> +#include "drm_buffer.h"
> +
> +/**
> + * Allocate the drm buffer object.
> + *
> + *   buf: Pointer to a pointer where the object is stored.
> + *   size: The number of bytes to allocate.
> + */
> +int drm_buffer_alloc(struct drm_buffer **buf, int size)
> +{
> +       int nr_pages = size / PAGE_SIZE + 1;
> +       int idx;
> +
> +       /* Allocating pointer table to end of structure makes drm_buffer
> +        * variable sized */
> +       *buf = kzalloc(sizeof(struct drm_buffer) + nr_pages*sizeof(char *),
> +                       GFP_KERNEL);
> +
> +       if (*buf == NULL) {
> +               DRM_ERROR("Failed to allocate drm buffer object to hold"
> +                               " %d bytes in %d pages.\n",
> +                               size, nr_pages);
> +               return -ENOMEM;
> +       }
> +
> +       (*buf)->size = size;
> +
> +       for (idx = 0; idx < nr_pages; ++idx) {
> +
> +               (*buf)->data[idx] =
> +                       kmalloc(min(PAGE_SIZE, size - idx * PAGE_SIZE),
> +                               GFP_KERNEL);
> +
> +
> +               if ((*buf)->data[idx] == NULL) {
> +                       DRM_ERROR("Failed to allocate %dth page for drm"
> +                                       " buffer with %d bytes and %d pages.\n",
> +                                       idx + 1, size, nr_pages);
> +                       goto error_out;
> +               }
> +
> +       }
> +
> +       return 0;
> +
> +error_out:
> +
> +       for (; idx >= 0; --idx)
> +               kfree((*buf)->data[idx]);
> +
> +       kfree(*buf);
> +       return -ENOMEM;
> +}
> +
> +/**
> + * Copy the user data to the begin of the buffer and reset the processing
> + * iterator.
> + *
> + *   user_data: A pointer the data that is copied to the buffer.
> + *   size: The Number of bytes to copy.
> + */
> +int drm_buffer_copy_from_user(struct drm_buffer *buf,
> +                             void __user *user_data, int size)
> +{
> +       int nr_pages = size / PAGE_SIZE + 1;
> +       int idx;
> +
> +       if (size > buf->size) {
> +               DRM_ERROR("Requesting to copy %d bytes to a drm buffer with"
> +                               " %d bytes space\n",
> +                               size, buf->size);
> +               return -EFAULT;
> +       }
> +
> +       for (idx = 0; idx < nr_pages; ++idx) {
> +
> +               if (copy_from_user(buf->data[idx],
> +                       user_data + idx * PAGE_SIZE,
> +                       min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
> +                       DRM_ERROR("Failed to copy user data (%p) to drm buffer"
> +                                       " (%p) %dth page.\n",
> +                                       user_data, buf, idx);
> +                       return -EFAULT;
> +
> +               }
> +       }
> +       buf->iterator = 0;
> +       return 0;
> +}
> +
> +/**
> + * Free the drm buffer object
> + */
> +void drm_buffer_free(struct drm_buffer *buf)
> +{
> +
> +       if (buf != NULL) {
> +
> +               int nr_pages = buf->size / PAGE_SIZE + 1;
> +               int idx;
> +               for (idx = 0; idx < nr_pages; ++idx)
> +                       kfree(buf->data[idx]);
> +
> +               kfree(buf);
> +       }
> +}
> +
> +/**
> + * Read an object from buffer that may be split to multiple parts. If object
> + * is not split function just returns the pointer to object in buffer. But in
> + * case of split object data is copied to given stack object that is suplied
> + * by caller.
> + *
> + * The processing location of the buffer is also advanced to the next byte
> + * after the object.
> + *
> + *   objsize: The size of the objet in bytes.
> + *   stack_obj: A pointer to a memory location where object can be copied.
> + */
> +void *drm_buffer_read_object(struct drm_buffer *buf,
> +               int objsize, void *stack_obj)
> +{
> +       int idx = drm_buffer_index(buf);
> +       int page = drm_buffer_page(buf);
> +       void *obj = NULL;
> +
> +       if (idx + objsize <= PAGE_SIZE) {
> +               obj = &buf->data[page][idx];
> +       } else {
> +               /* The object is split which forces copy to temporary object.*/
> +               int beginsz = PAGE_SIZE - idx;
> +               memcpy(stack_obj, &buf->data[page][idx], beginsz);
> +
> +               memcpy(stack_obj + beginsz, &buf->data[page + 1][0],
> +                               objsize - beginsz);
> +
> +               obj = stack_obj;
> +       }
> +
> +       drm_buffer_advance(buf, objsize);
> +       return obj;
> +}
> diff --git a/drivers/gpu/drm/radeon/drm_buffer.h b/drivers/gpu/drm/radeon/drm_buffer.h
> new file mode 100644
> index 0000000..c80d3a3
> --- /dev/null
> +++ b/drivers/gpu/drm/radeon/drm_buffer.h
> @@ -0,0 +1,148 @@
> +/**************************************************************************
> + *
> + * Copyright 2010 Pauli Nieminen.
> + * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDERS, AUTHORS 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.
> + *
> + *
> + **************************************************************************/
> +/*
> + * Multipart buffer for coping data which is larger than the page size.
> + *
> + * Authors:
> + * Pauli Nieminen <suokkos-at-gmail-dot-com>
> + */
> +
> +#ifndef _DRM_BUFFER_H_
> +#define _DRM_BUFFER_H_
> +
> +#include <drm/drmP.h>
> +
> +struct drm_buffer {
> +       int iterator;
> +       int size;
> +       char *data[];
> +};
> +
> +
> +/**
> + * Return the index of page that buffer is currently pointing at.
> + */
> +static inline int drm_buffer_page(struct drm_buffer *buf)
> +{
> +       return buf->iterator / PAGE_SIZE;
> +}
> +/**
> + * Return the index of the current byte in the page
> + */
> +static inline int drm_buffer_index(struct drm_buffer *buf)
> +{
> +       return buf->iterator & (PAGE_SIZE - 1);
> +}
> +/**
> + * Return number of bytes that is left to process
> + */
> +static inline int drm_buffer_unprocessed(struct drm_buffer *buf)
> +{
> +       return buf->size - buf->iterator;
> +}
> +
> +/**
> + * Advance the buffer iterator number of bytes that is given.
> + */
> +static inline void drm_buffer_advance(struct drm_buffer *buf, int bytes)
> +{
> +       buf->iterator += bytes;
> +}
> +
> +/**
> + * Allocate the drm buffer object.
> + *
> + *   buf: A pointer to a pointer where the object is stored.
> + *   size: The number of bytes to allocate.
> + */
> +extern int drm_buffer_alloc(struct drm_buffer **buf, int size);
> +
> +/**
> + * Copy the user data to the begin of the buffer and reset the processing
> + * iterator.
> + *
> + *   user_data: A pointer the data that is copied to the buffer.
> + *   size: The Number of bytes to copy.
> + */
> +extern int drm_buffer_copy_from_user(struct drm_buffer *buf,
> +               void __user *user_data, int size);
> +
> +/**
> + * Free the drm buffer object
> + */
> +extern void drm_buffer_free(struct drm_buffer *buf);
> +
> +/**
> + * Read an object from buffer that may be split to multiple parts. If object
> + * is not split function just returns the pointer to object in buffer. But in
> + * case of split object data is copied to given stack object that is suplied
> + * by caller.
> + *
> + * The processing location of the buffer is also advanced to the next byte
> + * after the object.
> + *
> + *   objsize: The size of the objet in bytes.
> + *   stack_obj: A pointer to a memory location where object can be copied.
> + */
> +extern void *drm_buffer_read_object(struct drm_buffer *buf,
> +               int objsize, void *stack_obj);
> +
> +/**
> + * Returns the pointer to the dword which is offset number of elements from the
> + * current processing location.
> + *
> + * Caller must make sure that dword is not split in the buffer. This
> + * requirement is easily met if all the sizes of objects in buffer are
> + * multiples of dword and PAGE_SIZE is multiple dword.
> + *
> + * Call to this function doesn't change the processing location.
> + *
> + *   offset: The index of the dword relative to the internat iterator.
> + */
> +static inline void *drm_buffer_pointer_to_dword(struct drm_buffer *buffer,
> +               int offset)
> +{
> +       int iter = buffer->iterator + offset * 4;
> +       return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
> +}
> +/**
> + * Returns the pointer to the dword which is offset number of elements from
> + * the current processing location.
> + *
> + * Call to this function doesn't change the processing location.
> + *
> + *   offset: The index of the byte relative to the internat iterator.
> + */
> +static inline void *drm_buffer_pointer_to_byte(struct drm_buffer *buffer,
> +               int offset)
> +{
> +       int iter = buffer->iterator + offset;
> +       return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
> +}
> +
> +#endif
> diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
> index 84b1d53..9418e38 100644
> --- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
> +++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
> @@ -34,10 +34,10 @@
>   */
>
>  #include <drm/drmP.h>
> -#include <drm/drm_buffer.h>
>  #include <drm/radeon_drm.h>
>  #include "radeon_drv.h"
>  #include "r300_reg.h"
> +#include "drm_buffer.h"
>
>  #include <asm/unaligned.h>
>
> diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
> index 23bb64f..535403e 100644
> --- a/drivers/gpu/drm/radeon/radeon_state.c
> +++ b/drivers/gpu/drm/radeon/radeon_state.c
> @@ -30,9 +30,9 @@
>   */
>
>  #include <drm/drmP.h>
> -#include <drm/drm_buffer.h>
>  #include <drm/radeon_drm.h>
>  #include "radeon_drv.h"
> +#include "drm_buffer.h"
>
>  /* ================================================================
>   * Helper functions for client state checking and fixup
> diff --git a/include/drm/drm_buffer.h b/include/drm/drm_buffer.h
> deleted file mode 100644
> index c80d3a3..0000000
> --- a/include/drm/drm_buffer.h
> +++ /dev/null
> @@ -1,148 +0,0 @@
> -/**************************************************************************
> - *
> - * Copyright 2010 Pauli Nieminen.
> - * 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, sub license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
> - * THE COPYRIGHT HOLDERS, AUTHORS 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.
> - *
> - *
> - **************************************************************************/
> -/*
> - * Multipart buffer for coping data which is larger than the page size.
> - *
> - * Authors:
> - * Pauli Nieminen <suokkos-at-gmail-dot-com>
> - */
> -
> -#ifndef _DRM_BUFFER_H_
> -#define _DRM_BUFFER_H_
> -
> -#include <drm/drmP.h>
> -
> -struct drm_buffer {
> -       int iterator;
> -       int size;
> -       char *data[];
> -};
> -
> -
> -/**
> - * Return the index of page that buffer is currently pointing at.
> - */
> -static inline int drm_buffer_page(struct drm_buffer *buf)
> -{
> -       return buf->iterator / PAGE_SIZE;
> -}
> -/**
> - * Return the index of the current byte in the page
> - */
> -static inline int drm_buffer_index(struct drm_buffer *buf)
> -{
> -       return buf->iterator & (PAGE_SIZE - 1);
> -}
> -/**
> - * Return number of bytes that is left to process
> - */
> -static inline int drm_buffer_unprocessed(struct drm_buffer *buf)
> -{
> -       return buf->size - buf->iterator;
> -}
> -
> -/**
> - * Advance the buffer iterator number of bytes that is given.
> - */
> -static inline void drm_buffer_advance(struct drm_buffer *buf, int bytes)
> -{
> -       buf->iterator += bytes;
> -}
> -
> -/**
> - * Allocate the drm buffer object.
> - *
> - *   buf: A pointer to a pointer where the object is stored.
> - *   size: The number of bytes to allocate.
> - */
> -extern int drm_buffer_alloc(struct drm_buffer **buf, int size);
> -
> -/**
> - * Copy the user data to the begin of the buffer and reset the processing
> - * iterator.
> - *
> - *   user_data: A pointer the data that is copied to the buffer.
> - *   size: The Number of bytes to copy.
> - */
> -extern int drm_buffer_copy_from_user(struct drm_buffer *buf,
> -               void __user *user_data, int size);
> -
> -/**
> - * Free the drm buffer object
> - */
> -extern void drm_buffer_free(struct drm_buffer *buf);
> -
> -/**
> - * Read an object from buffer that may be split to multiple parts. If object
> - * is not split function just returns the pointer to object in buffer. But in
> - * case of split object data is copied to given stack object that is suplied
> - * by caller.
> - *
> - * The processing location of the buffer is also advanced to the next byte
> - * after the object.
> - *
> - *   objsize: The size of the objet in bytes.
> - *   stack_obj: A pointer to a memory location where object can be copied.
> - */
> -extern void *drm_buffer_read_object(struct drm_buffer *buf,
> -               int objsize, void *stack_obj);
> -
> -/**
> - * Returns the pointer to the dword which is offset number of elements from the
> - * current processing location.
> - *
> - * Caller must make sure that dword is not split in the buffer. This
> - * requirement is easily met if all the sizes of objects in buffer are
> - * multiples of dword and PAGE_SIZE is multiple dword.
> - *
> - * Call to this function doesn't change the processing location.
> - *
> - *   offset: The index of the dword relative to the internat iterator.
> - */
> -static inline void *drm_buffer_pointer_to_dword(struct drm_buffer *buffer,
> -               int offset)
> -{
> -       int iter = buffer->iterator + offset * 4;
> -       return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
> -}
> -/**
> - * Returns the pointer to the dword which is offset number of elements from
> - * the current processing location.
> - *
> - * Call to this function doesn't change the processing location.
> - *
> - *   offset: The index of the byte relative to the internat iterator.
> - */
> -static inline void *drm_buffer_pointer_to_byte(struct drm_buffer *buffer,
> -               int offset)
> -{
> -       int iter = buffer->iterator + offset;
> -       return &buffer->data[iter / PAGE_SIZE][iter & (PAGE_SIZE - 1)];
> -}
> -
> -#endif
> --
> 2.1.0
>

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

end of thread, other threads:[~2014-09-08  4:08 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-29 10:12 [PATCH 00/20] DRM: Core Cleanups David Herrmann
2014-08-29 10:12 ` [PATCH 01/20] drm/radeon: move drm_buffer to drm/radeon/ David Herrmann
2014-08-29 11:20   ` Thierry Reding
2014-09-08  4:08   ` Alex Deucher
2014-08-29 10:12 ` [PATCH 02/20] drm: mark drm_buf and drm_map as legacy David Herrmann
2014-08-29 11:32   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 03/20] drm: move "struct drm_vma_entry" to drm_vm.c David Herrmann
2014-08-29 11:34   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 04/20] drm: move "struct drm_magic_entry" to drm_auth.c David Herrmann
2014-08-29 11:39   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 05/20] drm: drop unused "struct drm_waitlist" David Herrmann
2014-08-29 11:40   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 06/20] drm: move AGP definitions harder David Herrmann
2014-08-29 11:43   ` Thierry Reding
2014-08-29 12:39     ` Daniel Vetter
2014-08-29 10:12 ` [PATCH 07/20] drm: replace weird conditional includes David Herrmann
2014-08-29 11:45   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 08/20] drm: drop __KERNEL__ protection in drmP.h David Herrmann
2014-08-29 11:46   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 09/20] drm: merge drm_memory.h into drm_memory.c David Herrmann
2014-08-29 11:56   ` Thierry Reding
2014-08-29 12:43     ` Daniel Vetter
2014-08-29 13:26       ` Thierry Reding
2014-08-29 10:12 ` [PATCH 10/20] drm: move __OS_HAS_AGP into drm_agpsupport.h David Herrmann
2014-08-29 12:03   ` Thierry Reding
2014-08-29 12:45     ` Daniel Vetter
2014-08-29 10:12 ` [PATCH 11/20] drm: order includes alphabetically in drmP.h David Herrmann
2014-08-29 12:05   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 12/20] drm: drop DRM_DEBUG_CODE David Herrmann
2014-08-29 12:10   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 13/20] drm: inline "struct drm_sigdata" David Herrmann
2014-08-29 12:21   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 14/20] drm: move remaining includes in drmP.h to the top David Herrmann
2014-08-29 12:26   ` Thierry Reding
2014-08-29 10:12 ` [PATCH 15/20] drm: simplify drm_*_set_unique() David Herrmann
2014-08-29 12:39   ` Thierry Reding
2014-08-29 12:58   ` Daniel Vetter
2014-08-29 10:12 ` [PATCH 16/20] drm: drop unused drm_master->unique_size David Herrmann
2014-08-29 12:41   ` Thierry Reding
2014-08-29 12:58   ` Daniel Vetter
2014-08-29 10:12 ` [PATCH 17/20] drm: add driver->set_busid() callback David Herrmann
2014-08-29 12:54   ` Thierry Reding
2014-08-29 13:01   ` Daniel Vetter
2014-08-29 13:30     ` Thierry Reding
2014-08-29 10:12 ` [PATCH 18/20] drm: Goody bye, drm_bus! David Herrmann
2014-08-29 12:55   ` Thierry Reding
2014-08-29 13:02   ` Daniel Vetter
2014-08-29 10:12 ` [PATCH 19/20] drm: merge drm_usb into udl David Herrmann
2014-08-29 13:00   ` Thierry Reding
2014-08-29 13:06   ` Daniel Vetter
2014-08-29 10:12 ` [PATCH 20/20] drm: move drm-lock API to drm_legacy.h David Herrmann
2014-08-29 13:02   ` Thierry Reding
2014-08-29 13:08 ` [PATCH 00/20] DRM: Core Cleanups Daniel Vetter

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