dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Move struct drm_device.hose to legacy section
@ 2021-01-12  8:10 Thomas Zimmermann
  2021-01-12  8:10 ` [PATCH 1/6] drm: Inline AGP wrappers into their only callers Thomas Zimmermann
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

This patchset moves struct drm_device.hose to the section for legacy
drivers. As part of this, a number of other changes are applied in
order to protect all uses of hose by CONFIG_DRM_LEGACY.

Patches 1 to 3 move non-legacy code out put drm_memory.c and add the
remaining I/O-memory helpers to the legacy code.

Patch 4 addresses CONFIG_DRM_VM, which is only selected by legacy
drivers, so drm_vm.c can directly be compiled by CONFIG_DRM_LEGACY.

Patch 5 changes radeon to maintain its own copy of the hose field of
struct drm_device.

Patch 6 makes the hose field legacy.

The patchset has been compile-tested w/o CONFIG_DRM_LEGACY enabled.

Thomas Zimmermann (6):
  drm: Inline AGP wrappers into their only callers
  drm: Implement drm_need_swiotlb() in drm_cache.c
  drm: Build drm_memory.o only for legacy drivers
  drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY
  drm/radeon: Store PCI controller in struct radeon_device.hose
  drm: Move struct drm_device.hose to legacy section

 drivers/gpu/drm/Kconfig             |  5 ---
 drivers/gpu/drm/Makefile            |  6 ++--
 drivers/gpu/drm/drm_agpsupport.c    | 12 +++----
 drivers/gpu/drm/drm_cache.c         | 32 ++++++++++++++++++
 drivers/gpu/drm/drm_file.c          |  2 ++
 drivers/gpu/drm/drm_legacy.h        |  2 +-
 drivers/gpu/drm/drm_memory.c        | 51 -----------------------------
 drivers/gpu/drm/radeon/radeon.h     |  3 ++
 drivers/gpu/drm/radeon/radeon_drv.c |  4 ---
 drivers/gpu/drm/radeon/radeon_kms.c |  4 +++
 drivers/gpu/drm/radeon/radeon_ttm.c |  2 +-
 include/drm/drm_agpsupport.h        | 18 ----------
 include/drm/drm_device.h            |  9 ++---
 13 files changed, 57 insertions(+), 93 deletions(-)


base-commit: cd0df21e28c36de80356344ff8683be2813c6ff2
prerequisite-patch-id: c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d
--
2.29.2

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

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

* [PATCH 1/6] drm: Inline AGP wrappers into their only callers
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
@ 2021-01-12  8:10 ` Thomas Zimmermann
  2021-01-12  8:59   ` Daniel Vetter
  2021-01-12  8:10 ` [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c Thomas Zimmermann
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

The AGP wrapper functions serve no purpose.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_agpsupport.c | 12 ++++++------
 drivers/gpu/drm/drm_memory.c     | 18 ------------------
 include/drm/drm_agpsupport.h     | 18 ------------------
 3 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 4c7ad46fdd21..8b690ef306de 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -285,7 +285,7 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
 	entry = drm_agp_lookup_entry(dev, request->handle);
 	if (!entry || !entry->bound)
 		return -EINVAL;
-	ret = drm_unbind_agp(entry->memory);
+	ret = agp_unbind_memory(entry->memory);
 	if (ret == 0)
 		entry->bound = 0;
 	return ret;
@@ -326,7 +326,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
 	if (!entry || entry->bound)
 		return -EINVAL;
 	page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
-	retcode = drm_bind_agp(entry->memory, page);
+	retcode = agp_bind_memory(entry->memory, page);
 	if (retcode)
 		return retcode;
 	entry->bound = dev->agp->base + (page << PAGE_SHIFT);
@@ -369,11 +369,11 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
 	if (!entry)
 		return -EINVAL;
 	if (entry->bound)
-		drm_unbind_agp(entry->memory);
+		agp_unbind_memory(entry->memory);
 
 	list_del(&entry->head);
 
-	drm_free_agp(entry->memory, entry->pages);
+	agp_free_memory(entry->memory);
 	kfree(entry);
 	return 0;
 }
@@ -453,8 +453,8 @@ void drm_legacy_agp_clear(struct drm_device *dev)
 
 	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
 		if (entry->bound)
-			drm_unbind_agp(entry->memory);
-		drm_free_agp(entry->memory, entry->pages);
+			agp_unbind_memory(entry->memory);
+		agp_free_memory(entry->memory);
 		kfree(entry);
 	}
 	INIT_LIST_HEAD(&dev->agp->memory);
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index fbea69d6f909..f4f2bffdd5bd 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -100,24 +100,6 @@ static void *agp_remap(unsigned long offset, unsigned long size,
 	return addr;
 }
 
-/** Wrapper around agp_free_memory() */
-void drm_free_agp(struct agp_memory *handle, int pages)
-{
-	agp_free_memory(handle);
-}
-
-/** Wrapper around agp_bind_memory() */
-int drm_bind_agp(struct agp_memory *handle, unsigned int start)
-{
-	return agp_bind_memory(handle, start);
-}
-
-/** Wrapper around agp_unbind_memory() */
-int drm_unbind_agp(struct agp_memory *handle)
-{
-	return agp_unbind_memory(handle);
-}
-
 #else /*  CONFIG_AGP  */
 static inline void *agp_remap(unsigned long offset, unsigned long size,
 			      struct drm_device *dev)
diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
index 664e120b93e6..f3136750c490 100644
--- a/include/drm/drm_agpsupport.h
+++ b/include/drm/drm_agpsupport.h
@@ -28,10 +28,6 @@ struct drm_agp_head {
 
 #if IS_ENABLED(CONFIG_AGP)
 
-void drm_free_agp(struct agp_memory * handle, int pages);
-int drm_bind_agp(struct agp_memory * handle, unsigned int start);
-int drm_unbind_agp(struct agp_memory * handle);
-
 struct drm_agp_head *drm_agp_init(struct drm_device *dev);
 void drm_legacy_agp_clear(struct drm_device *dev);
 int drm_agp_acquire(struct drm_device *dev);
@@ -61,20 +57,6 @@ int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
 
 #else /* CONFIG_AGP */
 
-static inline void drm_free_agp(struct agp_memory * handle, int pages)
-{
-}
-
-static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
-{
-	return -ENODEV;
-}
-
-static inline int drm_unbind_agp(struct agp_memory * handle)
-{
-	return -ENODEV;
-}
-
 static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
 {
 	return NULL;
-- 
2.29.2

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

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

* [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
  2021-01-12  8:10 ` [PATCH 1/6] drm: Inline AGP wrappers into their only callers Thomas Zimmermann
@ 2021-01-12  8:10 ` Thomas Zimmermann
  2021-01-12  9:01   ` Daniel Vetter
  2021-01-12  8:10 ` [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers Thomas Zimmermann
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

The function is declared in drm_cache.h. I also removed the curly
braces from the for loop to adhere to kernel coding style.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_cache.c  | 32 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_memory.c | 33 ---------------------------------
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index 0fe3c496002a..49551a7fa22f 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -30,6 +30,7 @@
 
 #include <linux/export.h>
 #include <linux/highmem.h>
+#include <xen/xen.h>
 
 #include <drm/drm_cache.h>
 
@@ -176,3 +177,34 @@ drm_clflush_virt_range(void *addr, unsigned long length)
 #endif
 }
 EXPORT_SYMBOL(drm_clflush_virt_range);
+
+bool drm_need_swiotlb(int dma_bits)
+{
+	struct resource *tmp;
+	resource_size_t max_iomem = 0;
+
+	/*
+	 * Xen paravirtual hosts require swiotlb regardless of requested dma
+	 * transfer size.
+	 *
+	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
+	 *       allocator used in ttm_dma_populate() instead of
+	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
+	 *       Xen it leads to swiotlb buffer exhaustion.
+	 */
+	if (xen_pv_domain())
+		return true;
+
+	/*
+	 * Enforce dma_alloc_coherent when memory encryption is active as well
+	 * for the same reasons as for Xen paravirtual hosts.
+	 */
+	if (mem_encrypt_active())
+		return true;
+
+	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling)
+		max_iomem = max(max_iomem,  tmp->end);
+
+	return max_iomem > ((u64)1 << dma_bits);
+}
+EXPORT_SYMBOL(drm_need_swiotlb);
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index f4f2bffdd5bd..e4f20a2eb6e7 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -37,7 +37,6 @@
 #include <linux/highmem.h>
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
-#include <xen/xen.h>
 
 #include <drm/drm_agpsupport.h>
 #include <drm/drm_cache.h>
@@ -138,35 +137,3 @@ void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
 		iounmap(map->handle);
 }
 EXPORT_SYMBOL(drm_legacy_ioremapfree);
-
-bool drm_need_swiotlb(int dma_bits)
-{
-	struct resource *tmp;
-	resource_size_t max_iomem = 0;
-
-	/*
-	 * Xen paravirtual hosts require swiotlb regardless of requested dma
-	 * transfer size.
-	 *
-	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
-	 *       allocator used in ttm_dma_populate() instead of
-	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
-	 *       Xen it leads to swiotlb buffer exhaustion.
-	 */
-	if (xen_pv_domain())
-		return true;
-
-	/*
-	 * Enforce dma_alloc_coherent when memory encryption is active as well
-	 * for the same reasons as for Xen paravirtual hosts.
-	 */
-	if (mem_encrypt_active())
-		return true;
-
-	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) {
-		max_iomem = max(max_iomem,  tmp->end);
-	}
-
-	return max_iomem > ((u64)1 << dma_bits);
-}
-EXPORT_SYMBOL(drm_need_swiotlb);
-- 
2.29.2

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

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

* [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
  2021-01-12  8:10 ` [PATCH 1/6] drm: Inline AGP wrappers into their only callers Thomas Zimmermann
  2021-01-12  8:10 ` [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c Thomas Zimmermann
@ 2021-01-12  8:10 ` Thomas Zimmermann
  2021-01-12  9:02   ` Daniel Vetter
  2021-01-12  8:10 ` [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY Thomas Zimmermann
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

The file contains I/O-memory functions that are only used by legacy
drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index fefaff4c832d..ba0ecb7756c6 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -5,7 +5,7 @@
 
 drm-y       :=	drm_auth.o drm_cache.o \
 		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
-		drm_memory.o drm_drv.o \
+		drm_drv.o \
 		drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
 		drm_encoder_slave.o \
@@ -20,7 +20,8 @@ drm-y       :=	drm_auth.o drm_cache.o \
 		drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \
 		drm_managed.o drm_vblank_work.o
 
-drm-$(CONFIG_DRM_LEGACY) += drm_legacy_misc.o drm_bufs.o drm_context.o drm_dma.o drm_scatter.o drm_lock.o
+drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_legacy_misc.o drm_lock.o \
+		drm_memory.o drm_scatter.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
-- 
2.29.2

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

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

* [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2021-01-12  8:10 ` [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers Thomas Zimmermann
@ 2021-01-12  8:10 ` Thomas Zimmermann
  2021-01-12  9:04   ` Daniel Vetter
  2021-01-12  8:10 ` [PATCH 5/6] drm/radeon: Store PCI controller in struct radeon_device.hose Thomas Zimmermann
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

CONFIG_DRM_VM gets selected by CONFIG_DRM_LEGACY, but nothing else. So
remove it and build drm_vm.o as part of CONFIG_DRM_LEGACY.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/Kconfig      | 5 -----
 drivers/gpu/drm/Makefile     | 3 +--
 drivers/gpu/drm/drm_legacy.h | 2 +-
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 0973f408d75f..8bf103de1594 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -214,10 +214,6 @@ config DRM_GEM_SHMEM_HELPER
 	help
 	  Choose this if you need the GEM shmem helper functions
 
-config DRM_VM
-	bool
-	depends on DRM && MMU
-
 config DRM_SCHED
 	tristate
 	depends on DRM
@@ -391,7 +387,6 @@ source "drivers/gpu/drm/xlnx/Kconfig"
 menuconfig DRM_LEGACY
 	bool "Enable legacy drivers (DANGEROUS)"
 	depends on DRM && MMU
-	select DRM_VM
 	help
 	  Enable legacy DRI1 drivers. Those drivers expose unsafe and dangerous
 	  APIs to user-space, which can be used to circumvent access
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index ba0ecb7756c6..926adef289db 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -21,9 +21,8 @@ drm-y       :=	drm_auth.o drm_cache.o \
 		drm_managed.o drm_vblank_work.o
 
 drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_legacy_misc.o drm_lock.o \
-		drm_memory.o drm_scatter.o
+		drm_memory.o drm_scatter.o drm_vm.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
-drm-$(CONFIG_DRM_VM) += drm_vm.o
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
 drm-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_gem_shmem_helper.o
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
index 1be3ea320474..f71358f9eac9 100644
--- a/drivers/gpu/drm/drm_legacy.h
+++ b/drivers/gpu/drm/drm_legacy.h
@@ -127,7 +127,7 @@ static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
 static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
 #endif
 
-#if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
+#if IS_ENABLED(CONFIG_DRM_LEGACY)
 void drm_legacy_vma_flush(struct drm_device *d);
 #else
 static inline void drm_legacy_vma_flush(struct drm_device *d)
-- 
2.29.2

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

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

* [PATCH 5/6] drm/radeon: Store PCI controller in struct radeon_device.hose
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2021-01-12  8:10 ` [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY Thomas Zimmermann
@ 2021-01-12  8:10 ` Thomas Zimmermann
  2021-01-12  8:10 ` [PATCH 6/6] drm: Move struct drm_device.hose to legacy section Thomas Zimmermann
  2021-01-12  8:16 ` [PATCH 0/6] " Christian König
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

Moves struct drm_device.hose into struct radeon_device. The field in
struct DRM device is only for legacy drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/radeon/radeon.h     | 3 +++
 drivers/gpu/drm/radeon/radeon_drv.c | 4 ----
 drivers/gpu/drm/radeon/radeon_kms.c | 4 ++++
 drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 6bcb851d7e22..f09989bdce98 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2313,6 +2313,9 @@ struct radeon_device {
 	struct device			*dev;
 	struct drm_device		*ddev;
 	struct pci_dev			*pdev;
+#ifdef __alpha__
+	struct pci_controller		*hose;
+#endif
 	struct rw_semaphore		exclusive_lock;
 	/* ASIC */
 	union radeon_asic_config	config;
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 8193a2e9c415..efeb115ae70e 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -342,10 +342,6 @@ static int radeon_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		goto err_free;
 
-#ifdef __alpha__
-	dev->hose = pdev->sysdata;
-#endif
-
 	pci_set_drvdata(pdev, dev);
 
 	if (pci_find_capability(pdev, PCI_CAP_ID_AGP))
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 7c360d31ab6a..2479d6ab7a36 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -115,6 +115,10 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
 	}
 	dev->dev_private = (void *)rdev;
 
+#ifdef __alpha__
+	rdev->hose = pdev->sysdata;
+#endif
+
 	/* update BUS flag */
 	if (pci_find_capability(pdev, PCI_CAP_ID_AGP)) {
 		flags |= RADEON_IS_AGP;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 35b715f82ed8..e8c66d10478f 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -324,7 +324,7 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso
 		 * access, as done in ttm_bo_vm_fault().
 		 */
 		mem->bus.offset = (mem->bus.offset & 0x0ffffffffUL) +
-			rdev->ddev->hose->dense_mem_base;
+			rdev->hose->dense_mem_base;
 #endif
 		break;
 	default:
-- 
2.29.2

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

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

* [PATCH 6/6] drm: Move struct drm_device.hose to legacy section
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
                   ` (4 preceding siblings ...)
  2021-01-12  8:10 ` [PATCH 5/6] drm/radeon: Store PCI controller in struct radeon_device.hose Thomas Zimmermann
@ 2021-01-12  8:10 ` Thomas Zimmermann
  2021-01-12  8:16 ` [PATCH 0/6] " Christian König
  6 siblings, 0 replies; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  8:10 UTC (permalink / raw)
  To: daniel, airlied, maarten.lankhorst, mripard, alexander.deucher,
	christian.koenig
  Cc: Thomas Zimmermann, amd-gfx, dri-devel

The field is only relevant for legacy DRM drivers. Its only non-legacy
user in the DRM core is in drm_file.c. This code is now protected by
CONFIG_DRM_LEGACY. Radeon, the only driver that used the field, has been
changed to maintain it's own copy.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_file.c | 2 ++
 include/drm/drm_device.h   | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 80886d50d0f1..86c405d86a68 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -370,6 +370,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
 	list_add(&priv->lhead, &dev->filelist);
 	mutex_unlock(&dev->filelist_mutex);
 
+#ifdef CONFIG_DRM_LEGACY
 #ifdef __alpha__
 	/*
 	 * Default the hose
@@ -389,6 +390,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
 				dev->hose = b->sysdata;
 		}
 	}
+#endif
 #endif
 
 	return 0;
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index 939904ae88fc..d647223e8390 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -282,10 +282,6 @@ struct drm_device {
 	/** @pdev: PCI device structure */
 	struct pci_dev *pdev;
 
-#ifdef __alpha__
-	/** @hose: PCI hose, only used on ALPHA platforms. */
-	struct pci_controller *hose;
-#endif
 	/** @num_crtcs: Number of CRTCs on this device */
 	unsigned int num_crtcs;
 
@@ -328,6 +324,11 @@ struct drm_device {
 	/* List of devices per driver for stealth attach cleanup */
 	struct list_head legacy_dev_list;
 
+#ifdef __alpha__
+	/** @hose: PCI hose, only used on ALPHA platforms. */
+	struct pci_controller *hose;
+#endif
+
 	/* Context handle management - linked list of context handles */
 	struct list_head ctxlist;
 
-- 
2.29.2

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

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

* Re: [PATCH 0/6] Move struct drm_device.hose to legacy section
  2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
                   ` (5 preceding siblings ...)
  2021-01-12  8:10 ` [PATCH 6/6] drm: Move struct drm_device.hose to legacy section Thomas Zimmermann
@ 2021-01-12  8:16 ` Christian König
  6 siblings, 0 replies; 14+ messages in thread
From: Christian König @ 2021-01-12  8:16 UTC (permalink / raw)
  To: Thomas Zimmermann, daniel, airlied, maarten.lankhorst, mripard,
	alexander.deucher
  Cc: amd-gfx, dri-devel

I'm not even sure the radeon stuff still compiles/works on alpha :)

Anyway looks sane to me and the whole set is Reviewed-by: Christian 
König <christian.koenig@amd.com>.

Thanks,
Christian.

Am 12.01.21 um 09:10 schrieb Thomas Zimmermann:
> This patchset moves struct drm_device.hose to the section for legacy
> drivers. As part of this, a number of other changes are applied in
> order to protect all uses of hose by CONFIG_DRM_LEGACY.
>
> Patches 1 to 3 move non-legacy code out put drm_memory.c and add the
> remaining I/O-memory helpers to the legacy code.
>
> Patch 4 addresses CONFIG_DRM_VM, which is only selected by legacy
> drivers, so drm_vm.c can directly be compiled by CONFIG_DRM_LEGACY.
>
> Patch 5 changes radeon to maintain its own copy of the hose field of
> struct drm_device.
>
> Patch 6 makes the hose field legacy.
>
> The patchset has been compile-tested w/o CONFIG_DRM_LEGACY enabled.
>
> Thomas Zimmermann (6):
>    drm: Inline AGP wrappers into their only callers
>    drm: Implement drm_need_swiotlb() in drm_cache.c
>    drm: Build drm_memory.o only for legacy drivers
>    drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY
>    drm/radeon: Store PCI controller in struct radeon_device.hose
>    drm: Move struct drm_device.hose to legacy section
>
>   drivers/gpu/drm/Kconfig             |  5 ---
>   drivers/gpu/drm/Makefile            |  6 ++--
>   drivers/gpu/drm/drm_agpsupport.c    | 12 +++----
>   drivers/gpu/drm/drm_cache.c         | 32 ++++++++++++++++++
>   drivers/gpu/drm/drm_file.c          |  2 ++
>   drivers/gpu/drm/drm_legacy.h        |  2 +-
>   drivers/gpu/drm/drm_memory.c        | 51 -----------------------------
>   drivers/gpu/drm/radeon/radeon.h     |  3 ++
>   drivers/gpu/drm/radeon/radeon_drv.c |  4 ---
>   drivers/gpu/drm/radeon/radeon_kms.c |  4 +++
>   drivers/gpu/drm/radeon/radeon_ttm.c |  2 +-
>   include/drm/drm_agpsupport.h        | 18 ----------
>   include/drm/drm_device.h            |  9 ++---
>   13 files changed, 57 insertions(+), 93 deletions(-)
>
>
> base-commit: cd0df21e28c36de80356344ff8683be2813c6ff2
> prerequisite-patch-id: c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d
> --
> 2.29.2
>

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

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

* Re: [PATCH 1/6] drm: Inline AGP wrappers into their only callers
  2021-01-12  8:10 ` [PATCH 1/6] drm: Inline AGP wrappers into their only callers Thomas Zimmermann
@ 2021-01-12  8:59   ` Daniel Vetter
  2021-01-12  9:56     ` Thomas Zimmermann
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Vetter @ 2021-01-12  8:59 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: amd-gfx, airlied, dri-devel, alexander.deucher, christian.koenig

On Tue, Jan 12, 2021 at 09:10:30AM +0100, Thomas Zimmermann wrote:
> The AGP wrapper functions serve no purpose.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

They do, without them we fail compiling (I think at least) when agp isn't
enabled. Did you check for that? I should all work if we have the dummy
inlines for relevant agp functions in linux/agp_backend.h.
-Daniel

> ---
>  drivers/gpu/drm/drm_agpsupport.c | 12 ++++++------
>  drivers/gpu/drm/drm_memory.c     | 18 ------------------
>  include/drm/drm_agpsupport.h     | 18 ------------------
>  3 files changed, 6 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> index 4c7ad46fdd21..8b690ef306de 100644
> --- a/drivers/gpu/drm/drm_agpsupport.c
> +++ b/drivers/gpu/drm/drm_agpsupport.c
> @@ -285,7 +285,7 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
>  	entry = drm_agp_lookup_entry(dev, request->handle);
>  	if (!entry || !entry->bound)
>  		return -EINVAL;
> -	ret = drm_unbind_agp(entry->memory);
> +	ret = agp_unbind_memory(entry->memory);
>  	if (ret == 0)
>  		entry->bound = 0;
>  	return ret;
> @@ -326,7 +326,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
>  	if (!entry || entry->bound)
>  		return -EINVAL;
>  	page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
> -	retcode = drm_bind_agp(entry->memory, page);
> +	retcode = agp_bind_memory(entry->memory, page);
>  	if (retcode)
>  		return retcode;
>  	entry->bound = dev->agp->base + (page << PAGE_SHIFT);
> @@ -369,11 +369,11 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
>  	if (!entry)
>  		return -EINVAL;
>  	if (entry->bound)
> -		drm_unbind_agp(entry->memory);
> +		agp_unbind_memory(entry->memory);
>  
>  	list_del(&entry->head);
>  
> -	drm_free_agp(entry->memory, entry->pages);
> +	agp_free_memory(entry->memory);
>  	kfree(entry);
>  	return 0;
>  }
> @@ -453,8 +453,8 @@ void drm_legacy_agp_clear(struct drm_device *dev)
>  
>  	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
>  		if (entry->bound)
> -			drm_unbind_agp(entry->memory);
> -		drm_free_agp(entry->memory, entry->pages);
> +			agp_unbind_memory(entry->memory);
> +		agp_free_memory(entry->memory);
>  		kfree(entry);
>  	}
>  	INIT_LIST_HEAD(&dev->agp->memory);
> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> index fbea69d6f909..f4f2bffdd5bd 100644
> --- a/drivers/gpu/drm/drm_memory.c
> +++ b/drivers/gpu/drm/drm_memory.c
> @@ -100,24 +100,6 @@ static void *agp_remap(unsigned long offset, unsigned long size,
>  	return addr;
>  }
>  
> -/** Wrapper around agp_free_memory() */
> -void drm_free_agp(struct agp_memory *handle, int pages)
> -{
> -	agp_free_memory(handle);
> -}
> -
> -/** Wrapper around agp_bind_memory() */
> -int drm_bind_agp(struct agp_memory *handle, unsigned int start)
> -{
> -	return agp_bind_memory(handle, start);
> -}
> -
> -/** Wrapper around agp_unbind_memory() */
> -int drm_unbind_agp(struct agp_memory *handle)
> -{
> -	return agp_unbind_memory(handle);
> -}
> -
>  #else /*  CONFIG_AGP  */
>  static inline void *agp_remap(unsigned long offset, unsigned long size,
>  			      struct drm_device *dev)
> diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
> index 664e120b93e6..f3136750c490 100644
> --- a/include/drm/drm_agpsupport.h
> +++ b/include/drm/drm_agpsupport.h
> @@ -28,10 +28,6 @@ struct drm_agp_head {
>  
>  #if IS_ENABLED(CONFIG_AGP)
>  
> -void drm_free_agp(struct agp_memory * handle, int pages);
> -int drm_bind_agp(struct agp_memory * handle, unsigned int start);
> -int drm_unbind_agp(struct agp_memory * handle);
> -
>  struct drm_agp_head *drm_agp_init(struct drm_device *dev);
>  void drm_legacy_agp_clear(struct drm_device *dev);
>  int drm_agp_acquire(struct drm_device *dev);
> @@ -61,20 +57,6 @@ int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
>  
>  #else /* CONFIG_AGP */
>  
> -static inline void drm_free_agp(struct agp_memory * handle, int pages)
> -{
> -}
> -
> -static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
> -{
> -	return -ENODEV;
> -}
> -
> -static inline int drm_unbind_agp(struct agp_memory * handle)
> -{
> -	return -ENODEV;
> -}
> -
>  static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>  {
>  	return NULL;
> -- 
> 2.29.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c
  2021-01-12  8:10 ` [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c Thomas Zimmermann
@ 2021-01-12  9:01   ` Daniel Vetter
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2021-01-12  9:01 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: amd-gfx, airlied, dri-devel, alexander.deucher, christian.koenig

On Tue, Jan 12, 2021 at 09:10:31AM +0100, Thomas Zimmermann wrote:
> The function is declared in drm_cache.h. I also removed the curly
> braces from the for loop to adhere to kernel coding style.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

s/implement in/move to/ in the subject. Also would be nice to add
kerneldoc while moving (there's not kerneldoc for drm_memory) to avoid the
new warning. With that fixed:

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

It's mildly confusing, but in a way drm_cache.c is our "hack around
dma-api layering issues" pile, so fits :-) Maybe we should even make this
the official DOC: kerneldoc intro section for this file ...

Cheers, Daniel

> ---
>  drivers/gpu/drm/drm_cache.c  | 32 ++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_memory.c | 33 ---------------------------------
>  2 files changed, 32 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
> index 0fe3c496002a..49551a7fa22f 100644
> --- a/drivers/gpu/drm/drm_cache.c
> +++ b/drivers/gpu/drm/drm_cache.c
> @@ -30,6 +30,7 @@
>  
>  #include <linux/export.h>
>  #include <linux/highmem.h>
> +#include <xen/xen.h>
>  
>  #include <drm/drm_cache.h>
>  
> @@ -176,3 +177,34 @@ drm_clflush_virt_range(void *addr, unsigned long length)
>  #endif
>  }
>  EXPORT_SYMBOL(drm_clflush_virt_range);
> +
> +bool drm_need_swiotlb(int dma_bits)
> +{
> +	struct resource *tmp;
> +	resource_size_t max_iomem = 0;
> +
> +	/*
> +	 * Xen paravirtual hosts require swiotlb regardless of requested dma
> +	 * transfer size.
> +	 *
> +	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
> +	 *       allocator used in ttm_dma_populate() instead of
> +	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
> +	 *       Xen it leads to swiotlb buffer exhaustion.
> +	 */
> +	if (xen_pv_domain())
> +		return true;
> +
> +	/*
> +	 * Enforce dma_alloc_coherent when memory encryption is active as well
> +	 * for the same reasons as for Xen paravirtual hosts.
> +	 */
> +	if (mem_encrypt_active())
> +		return true;
> +
> +	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling)
> +		max_iomem = max(max_iomem,  tmp->end);
> +
> +	return max_iomem > ((u64)1 << dma_bits);
> +}
> +EXPORT_SYMBOL(drm_need_swiotlb);
> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> index f4f2bffdd5bd..e4f20a2eb6e7 100644
> --- a/drivers/gpu/drm/drm_memory.c
> +++ b/drivers/gpu/drm/drm_memory.c
> @@ -37,7 +37,6 @@
>  #include <linux/highmem.h>
>  #include <linux/pci.h>
>  #include <linux/vmalloc.h>
> -#include <xen/xen.h>
>  
>  #include <drm/drm_agpsupport.h>
>  #include <drm/drm_cache.h>
> @@ -138,35 +137,3 @@ void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
>  		iounmap(map->handle);
>  }
>  EXPORT_SYMBOL(drm_legacy_ioremapfree);
> -
> -bool drm_need_swiotlb(int dma_bits)
> -{
> -	struct resource *tmp;
> -	resource_size_t max_iomem = 0;
> -
> -	/*
> -	 * Xen paravirtual hosts require swiotlb regardless of requested dma
> -	 * transfer size.
> -	 *
> -	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
> -	 *       allocator used in ttm_dma_populate() instead of
> -	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
> -	 *       Xen it leads to swiotlb buffer exhaustion.
> -	 */
> -	if (xen_pv_domain())
> -		return true;
> -
> -	/*
> -	 * Enforce dma_alloc_coherent when memory encryption is active as well
> -	 * for the same reasons as for Xen paravirtual hosts.
> -	 */
> -	if (mem_encrypt_active())
> -		return true;
> -
> -	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) {
> -		max_iomem = max(max_iomem,  tmp->end);
> -	}
> -
> -	return max_iomem > ((u64)1 << dma_bits);
> -}
> -EXPORT_SYMBOL(drm_need_swiotlb);
> -- 
> 2.29.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers
  2021-01-12  8:10 ` [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers Thomas Zimmermann
@ 2021-01-12  9:02   ` Daniel Vetter
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2021-01-12  9:02 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: amd-gfx, airlied, dri-devel, alexander.deucher, christian.koenig

On Tue, Jan 12, 2021 at 09:10:32AM +0100, Thomas Zimmermann wrote:
> The file contains I/O-memory functions that are only used by legacy
> drivers.

Yay!

> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

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

> ---
>  drivers/gpu/drm/Makefile | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index fefaff4c832d..ba0ecb7756c6 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -5,7 +5,7 @@
>  
>  drm-y       :=	drm_auth.o drm_cache.o \
>  		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
> -		drm_memory.o drm_drv.o \
> +		drm_drv.o \
>  		drm_sysfs.o drm_hashtab.o drm_mm.o \
>  		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
>  		drm_encoder_slave.o \
> @@ -20,7 +20,8 @@ drm-y       :=	drm_auth.o drm_cache.o \
>  		drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \
>  		drm_managed.o drm_vblank_work.o
>  
> -drm-$(CONFIG_DRM_LEGACY) += drm_legacy_misc.o drm_bufs.o drm_context.o drm_dma.o drm_scatter.o drm_lock.o
> +drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_legacy_misc.o drm_lock.o \
> +		drm_memory.o drm_scatter.o
>  drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
>  drm-$(CONFIG_DRM_VM) += drm_vm.o
>  drm-$(CONFIG_COMPAT) += drm_ioc32.o
> -- 
> 2.29.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY
  2021-01-12  8:10 ` [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY Thomas Zimmermann
@ 2021-01-12  9:04   ` Daniel Vetter
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2021-01-12  9:04 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: amd-gfx, airlied, dri-devel, alexander.deucher, christian.koenig

On Tue, Jan 12, 2021 at 09:10:33AM +0100, Thomas Zimmermann wrote:
> CONFIG_DRM_VM gets selected by CONFIG_DRM_LEGACY, but nothing else. So
> remove it and build drm_vm.o as part of CONFIG_DRM_LEGACY.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  drivers/gpu/drm/Kconfig      | 5 -----
>  drivers/gpu/drm/Makefile     | 3 +--
>  drivers/gpu/drm/drm_legacy.h | 2 +-
>  3 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 0973f408d75f..8bf103de1594 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -214,10 +214,6 @@ config DRM_GEM_SHMEM_HELPER
>  	help
>  	  Choose this if you need the GEM shmem helper functions
>  
> -config DRM_VM
> -	bool
> -	depends on DRM && MMU
> -
>  config DRM_SCHED
>  	tristate
>  	depends on DRM
> @@ -391,7 +387,6 @@ source "drivers/gpu/drm/xlnx/Kconfig"
>  menuconfig DRM_LEGACY
>  	bool "Enable legacy drivers (DANGEROUS)"
>  	depends on DRM && MMU

Ah we already depend upon MMU here, so should be all good.

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

> -	select DRM_VM
>  	help
>  	  Enable legacy DRI1 drivers. Those drivers expose unsafe and dangerous
>  	  APIs to user-space, which can be used to circumvent access
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index ba0ecb7756c6..926adef289db 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -21,9 +21,8 @@ drm-y       :=	drm_auth.o drm_cache.o \
>  		drm_managed.o drm_vblank_work.o
>  
>  drm-$(CONFIG_DRM_LEGACY) += drm_bufs.o drm_context.o drm_dma.o drm_legacy_misc.o drm_lock.o \
> -		drm_memory.o drm_scatter.o
> +		drm_memory.o drm_scatter.o drm_vm.o
>  drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
> -drm-$(CONFIG_DRM_VM) += drm_vm.o
>  drm-$(CONFIG_COMPAT) += drm_ioc32.o
>  drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
>  drm-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_gem_shmem_helper.o
> diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h
> index 1be3ea320474..f71358f9eac9 100644
> --- a/drivers/gpu/drm/drm_legacy.h
> +++ b/drivers/gpu/drm/drm_legacy.h
> @@ -127,7 +127,7 @@ static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
>  static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
>  #endif
>  
> -#if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
> +#if IS_ENABLED(CONFIG_DRM_LEGACY)
>  void drm_legacy_vma_flush(struct drm_device *d);
>  #else
>  static inline void drm_legacy_vma_flush(struct drm_device *d)
> -- 
> 2.29.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/6] drm: Inline AGP wrappers into their only callers
  2021-01-12  8:59   ` Daniel Vetter
@ 2021-01-12  9:56     ` Thomas Zimmermann
  2021-01-12 14:01       ` Daniel Vetter
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Zimmermann @ 2021-01-12  9:56 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: airlied, alexander.deucher, dri-devel, amd-gfx, christian.koenig


[-- Attachment #1.1.1: Type: text/plain, Size: 5150 bytes --]

Hi

Am 12.01.21 um 09:59 schrieb Daniel Vetter:
> On Tue, Jan 12, 2021 at 09:10:30AM +0100, Thomas Zimmermann wrote:
>> The AGP wrapper functions serve no purpose.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> They do, without them we fail compiling (I think at least) when agp isn't

I thought so. But the only callers are in drm_agpsupport.c, which 
depends on CONFIG_AGP in the Makefile. So I expected this to work.

Best regards
Thomas

> enabled. Did you check for that? I should all work if we have the dummy
> inlines for relevant agp functions in linux/agp_backend.h.
> -Daniel
> 
>> ---
>>   drivers/gpu/drm/drm_agpsupport.c | 12 ++++++------
>>   drivers/gpu/drm/drm_memory.c     | 18 ------------------
>>   include/drm/drm_agpsupport.h     | 18 ------------------
>>   3 files changed, 6 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
>> index 4c7ad46fdd21..8b690ef306de 100644
>> --- a/drivers/gpu/drm/drm_agpsupport.c
>> +++ b/drivers/gpu/drm/drm_agpsupport.c
>> @@ -285,7 +285,7 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
>>   	entry = drm_agp_lookup_entry(dev, request->handle);
>>   	if (!entry || !entry->bound)
>>   		return -EINVAL;
>> -	ret = drm_unbind_agp(entry->memory);
>> +	ret = agp_unbind_memory(entry->memory);
>>   	if (ret == 0)
>>   		entry->bound = 0;
>>   	return ret;
>> @@ -326,7 +326,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
>>   	if (!entry || entry->bound)
>>   		return -EINVAL;
>>   	page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
>> -	retcode = drm_bind_agp(entry->memory, page);
>> +	retcode = agp_bind_memory(entry->memory, page);
>>   	if (retcode)
>>   		return retcode;
>>   	entry->bound = dev->agp->base + (page << PAGE_SHIFT);
>> @@ -369,11 +369,11 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
>>   	if (!entry)
>>   		return -EINVAL;
>>   	if (entry->bound)
>> -		drm_unbind_agp(entry->memory);
>> +		agp_unbind_memory(entry->memory);
>>   
>>   	list_del(&entry->head);
>>   
>> -	drm_free_agp(entry->memory, entry->pages);
>> +	agp_free_memory(entry->memory);
>>   	kfree(entry);
>>   	return 0;
>>   }
>> @@ -453,8 +453,8 @@ void drm_legacy_agp_clear(struct drm_device *dev)
>>   
>>   	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
>>   		if (entry->bound)
>> -			drm_unbind_agp(entry->memory);
>> -		drm_free_agp(entry->memory, entry->pages);
>> +			agp_unbind_memory(entry->memory);
>> +		agp_free_memory(entry->memory);
>>   		kfree(entry);
>>   	}
>>   	INIT_LIST_HEAD(&dev->agp->memory);
>> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
>> index fbea69d6f909..f4f2bffdd5bd 100644
>> --- a/drivers/gpu/drm/drm_memory.c
>> +++ b/drivers/gpu/drm/drm_memory.c
>> @@ -100,24 +100,6 @@ static void *agp_remap(unsigned long offset, unsigned long size,
>>   	return addr;
>>   }
>>   
>> -/** Wrapper around agp_free_memory() */
>> -void drm_free_agp(struct agp_memory *handle, int pages)
>> -{
>> -	agp_free_memory(handle);
>> -}
>> -
>> -/** Wrapper around agp_bind_memory() */
>> -int drm_bind_agp(struct agp_memory *handle, unsigned int start)
>> -{
>> -	return agp_bind_memory(handle, start);
>> -}
>> -
>> -/** Wrapper around agp_unbind_memory() */
>> -int drm_unbind_agp(struct agp_memory *handle)
>> -{
>> -	return agp_unbind_memory(handle);
>> -}
>> -
>>   #else /*  CONFIG_AGP  */
>>   static inline void *agp_remap(unsigned long offset, unsigned long size,
>>   			      struct drm_device *dev)
>> diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
>> index 664e120b93e6..f3136750c490 100644
>> --- a/include/drm/drm_agpsupport.h
>> +++ b/include/drm/drm_agpsupport.h
>> @@ -28,10 +28,6 @@ struct drm_agp_head {
>>   
>>   #if IS_ENABLED(CONFIG_AGP)
>>   
>> -void drm_free_agp(struct agp_memory * handle, int pages);
>> -int drm_bind_agp(struct agp_memory * handle, unsigned int start);
>> -int drm_unbind_agp(struct agp_memory * handle);
>> -
>>   struct drm_agp_head *drm_agp_init(struct drm_device *dev);
>>   void drm_legacy_agp_clear(struct drm_device *dev);
>>   int drm_agp_acquire(struct drm_device *dev);
>> @@ -61,20 +57,6 @@ int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
>>   
>>   #else /* CONFIG_AGP */
>>   
>> -static inline void drm_free_agp(struct agp_memory * handle, int pages)
>> -{
>> -}
>> -
>> -static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
>> -{
>> -	return -ENODEV;
>> -}
>> -
>> -static inline int drm_unbind_agp(struct agp_memory * handle)
>> -{
>> -	return -ENODEV;
>> -}
>> -
>>   static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>>   {
>>   	return NULL;
>> -- 
>> 2.29.2
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

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

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

* Re: [PATCH 1/6] drm: Inline AGP wrappers into their only callers
  2021-01-12  9:56     ` Thomas Zimmermann
@ 2021-01-12 14:01       ` Daniel Vetter
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2021-01-12 14:01 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: Dave Airlie, Alex Deucher, dri-devel, amd-gfx list, Christian König

On Tue, Jan 12, 2021 at 10:56 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 12.01.21 um 09:59 schrieb Daniel Vetter:
> > On Tue, Jan 12, 2021 at 09:10:30AM +0100, Thomas Zimmermann wrote:
> >> The AGP wrapper functions serve no purpose.
> >>
> >> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> >
> > They do, without them we fail compiling (I think at least) when agp isn't
>
> I thought so. But the only callers are in drm_agpsupport.c, which
> depends on CONFIG_AGP in the Makefile. So I expected this to work.

Please add that information to the commit message, with that r-b: me too.
-Daniel

>
> Best regards
> Thomas
>
> > enabled. Did you check for that? I should all work if we have the dummy
> > inlines for relevant agp functions in linux/agp_backend.h.
> > -Daniel
> >
> >> ---
> >>   drivers/gpu/drm/drm_agpsupport.c | 12 ++++++------
> >>   drivers/gpu/drm/drm_memory.c     | 18 ------------------
> >>   include/drm/drm_agpsupport.h     | 18 ------------------
> >>   3 files changed, 6 insertions(+), 42 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> >> index 4c7ad46fdd21..8b690ef306de 100644
> >> --- a/drivers/gpu/drm/drm_agpsupport.c
> >> +++ b/drivers/gpu/drm/drm_agpsupport.c
> >> @@ -285,7 +285,7 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
> >>      entry = drm_agp_lookup_entry(dev, request->handle);
> >>      if (!entry || !entry->bound)
> >>              return -EINVAL;
> >> -    ret = drm_unbind_agp(entry->memory);
> >> +    ret = agp_unbind_memory(entry->memory);
> >>      if (ret == 0)
> >>              entry->bound = 0;
> >>      return ret;
> >> @@ -326,7 +326,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
> >>      if (!entry || entry->bound)
> >>              return -EINVAL;
> >>      page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
> >> -    retcode = drm_bind_agp(entry->memory, page);
> >> +    retcode = agp_bind_memory(entry->memory, page);
> >>      if (retcode)
> >>              return retcode;
> >>      entry->bound = dev->agp->base + (page << PAGE_SHIFT);
> >> @@ -369,11 +369,11 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
> >>      if (!entry)
> >>              return -EINVAL;
> >>      if (entry->bound)
> >> -            drm_unbind_agp(entry->memory);
> >> +            agp_unbind_memory(entry->memory);
> >>
> >>      list_del(&entry->head);
> >>
> >> -    drm_free_agp(entry->memory, entry->pages);
> >> +    agp_free_memory(entry->memory);
> >>      kfree(entry);
> >>      return 0;
> >>   }
> >> @@ -453,8 +453,8 @@ void drm_legacy_agp_clear(struct drm_device *dev)
> >>
> >>      list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
> >>              if (entry->bound)
> >> -                    drm_unbind_agp(entry->memory);
> >> -            drm_free_agp(entry->memory, entry->pages);
> >> +                    agp_unbind_memory(entry->memory);
> >> +            agp_free_memory(entry->memory);
> >>              kfree(entry);
> >>      }
> >>      INIT_LIST_HEAD(&dev->agp->memory);
> >> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> >> index fbea69d6f909..f4f2bffdd5bd 100644
> >> --- a/drivers/gpu/drm/drm_memory.c
> >> +++ b/drivers/gpu/drm/drm_memory.c
> >> @@ -100,24 +100,6 @@ static void *agp_remap(unsigned long offset, unsigned long size,
> >>      return addr;
> >>   }
> >>
> >> -/** Wrapper around agp_free_memory() */
> >> -void drm_free_agp(struct agp_memory *handle, int pages)
> >> -{
> >> -    agp_free_memory(handle);
> >> -}
> >> -
> >> -/** Wrapper around agp_bind_memory() */
> >> -int drm_bind_agp(struct agp_memory *handle, unsigned int start)
> >> -{
> >> -    return agp_bind_memory(handle, start);
> >> -}
> >> -
> >> -/** Wrapper around agp_unbind_memory() */
> >> -int drm_unbind_agp(struct agp_memory *handle)
> >> -{
> >> -    return agp_unbind_memory(handle);
> >> -}
> >> -
> >>   #else /*  CONFIG_AGP  */
> >>   static inline void *agp_remap(unsigned long offset, unsigned long size,
> >>                            struct drm_device *dev)
> >> diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h
> >> index 664e120b93e6..f3136750c490 100644
> >> --- a/include/drm/drm_agpsupport.h
> >> +++ b/include/drm/drm_agpsupport.h
> >> @@ -28,10 +28,6 @@ struct drm_agp_head {
> >>
> >>   #if IS_ENABLED(CONFIG_AGP)
> >>
> >> -void drm_free_agp(struct agp_memory * handle, int pages);
> >> -int drm_bind_agp(struct agp_memory * handle, unsigned int start);
> >> -int drm_unbind_agp(struct agp_memory * handle);
> >> -
> >>   struct drm_agp_head *drm_agp_init(struct drm_device *dev);
> >>   void drm_legacy_agp_clear(struct drm_device *dev);
> >>   int drm_agp_acquire(struct drm_device *dev);
> >> @@ -61,20 +57,6 @@ int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
> >>
> >>   #else /* CONFIG_AGP */
> >>
> >> -static inline void drm_free_agp(struct agp_memory * handle, int pages)
> >> -{
> >> -}
> >> -
> >> -static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start)
> >> -{
> >> -    return -ENODEV;
> >> -}
> >> -
> >> -static inline int drm_unbind_agp(struct agp_memory * handle)
> >> -{
> >> -    return -ENODEV;
> >> -}
> >> -
> >>   static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev)
> >>   {
> >>      return NULL;
> >> --
> >> 2.29.2
> >>
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2021-01-12 14:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
2021-01-12  8:10 ` [PATCH 1/6] drm: Inline AGP wrappers into their only callers Thomas Zimmermann
2021-01-12  8:59   ` Daniel Vetter
2021-01-12  9:56     ` Thomas Zimmermann
2021-01-12 14:01       ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c Thomas Zimmermann
2021-01-12  9:01   ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers Thomas Zimmermann
2021-01-12  9:02   ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY Thomas Zimmermann
2021-01-12  9:04   ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 5/6] drm/radeon: Store PCI controller in struct radeon_device.hose Thomas Zimmermann
2021-01-12  8:10 ` [PATCH 6/6] drm: Move struct drm_device.hose to legacy section Thomas Zimmermann
2021-01-12  8:16 ` [PATCH 0/6] " Christian König

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