Move struct drm_device.hose to legacy section
Subsystems (3)
Thomas Zimmermann
maintainercover Move struct drm_device.hose to legacy section
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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerPATCH 1/6 drm: Inline AGP wrappers into their only callers
The AGP wrapper functions serve no purpose.
--- 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(-)
drivers/gpu/drm/drm_agpsupport.c +6 -6
@@ -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);
drivers/gpu/drm/drm_memory.c +0 -18
@@ -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)
include/drm/drm_agpsupport.h +0 -18
@@ -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 ;
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 1/6] drm: Inline AGP wrappers into their only callers
Quoted 3 lines · Thomas Zimmermann
The AGP wrapper functions serve no purpose.
Signed-off-by Thomas Zimmermann <[email protected]>
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
Quoted 121 lines
--- 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(-)drivers/gpu/drm/drm_agpsupport.c +6
-6@@ -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);drivers/gpu/drm/drm_memory.c +0
-18@@ -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)include/drm/drm_agpsupport.h +0
-18@@ -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 ;Signature · 1 line
2.29.2
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerRe: [PATCH 1/6] drm: Inline AGP wrappers into their only callers
Hi
Am 12.01.21 um 09:59 schrieb Daniel Vetter:
Quoted 6 lines · Thomas Zimmermann
Quoted 3 lines
The AGP wrapper functions serve no purpose.
Signed-off-by Thomas Zimmermann <[email protected]>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
Quoted 126 lines
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. -DanielQuoted 121 lines
--- 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(-)drivers/gpu/drm/drm_agpsupport.c +6
-6@@ -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);drivers/gpu/drm/drm_memory.c +0
-18@@ -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)include/drm/drm_agpsupport.h +0
-18@@ -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 ;Signature · 1 line
2.29.2
Signature · 6 lines
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
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/6] drm: Inline AGP wrappers into their only callers
Quoted 5 lines · Thomas Zimmermann
Hi
Am 12.01.21 um 09:59 schrieb Daniel Vetter:
Quoted 1 line · Thomas Zimmermann
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
The AGP wrapper functions serve no purpose.
Signed-off-by Thomas Zimmermann <[email protected]>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 onCONFIG_AGPin theMakefile. So I expected this to work.
Please add that information to the commit message, with that r-b: me too. -Daniel
Quoted 139 lines
Best regards
ThomasQuoted 117 lines
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. -DanielQuoted 113 lines
--- 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(-)drivers/gpu/drm/drm_agpsupport.c +6
-6@@ -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);drivers/gpu/drm/drm_memory.c +0
-18@@ -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)include/drm/drm_agpsupport.h +0
-16@@ -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 ;Quoted 9 lines
Quoted 8 lines
include/drm/drm_agpsupport.h +0
-3-} -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
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerPATCH 2/6 drm: Implement drm_need_swiotlb() in drm_cache.c
In reply to Thomas ZimmermannThe function is declared in drm_cache.h. I also removed the curly braces from the for loop to adhere to kernel coding style.
--- drivers/gpu/drm/drm_cache.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_memory.c | 33 --------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-)
drivers/gpu/drm/drm_cache.c +32 -0
@@ -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);
drivers/gpu/drm/drm_memory.c +0 -33
@@ -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);
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c
Quoted 4 lines · Thomas Zimmermann
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 <[email protected]>
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:
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
Quoted 103 lines
--- drivers/gpu/drm/drm_cache.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_memory.c | 33 --------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-)drivers/gpu/drm/drm_cache.c +32
-0@@ -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);drivers/gpu/drm/drm_memory.c +0
-33@@ -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);Signature · 1 line
2.29.2
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerPATCH 3/6 drm: Build drm_memory.o only for legacy drivers
In reply to Thomas ZimmermannThe file contains I/O-memory functions that are only used by legacy drivers.
--- drivers/gpu/drm/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/Makefile +3 -2
@@ -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
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers
Quoted 2 lines · Thomas Zimmermann
The file contains I/O-memory functions that are only used by legacy drivers.
Yay!
Quoted 1 line
Signed-off-by Thomas Zimmermann <[email protected]>
Quoted 30 lines
--- drivers/gpu/drm/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/Makefile +3
-2@@ -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.oSignature · 1 line
2.29.2
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerPATCH 4/6 drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY
In reply to Thomas ZimmermannCONFIG_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.
--- drivers/gpu/drm/Kconfig | 5 ----- drivers/gpu/drm/Makefile | 3 +-- drivers/gpu/drm/drm_legacy.h | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/Kconfig +0 -5
@@ -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
drivers/gpu/drm/Makefile +1 -2
@@ -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
drivers/gpu/drm/drm_legacy.h +1 -1
@@ -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)
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY
Quoted 26 lines · Thomas Zimmermann
CONFIG_DRM_VMgets selected byCONFIG_DRM_LEGACY, but nothing else. So remove it and build drm_vm.o as part ofCONFIG_DRM_LEGACY.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/Kconfig | 5 ----- drivers/gpu/drm/Makefile | 3 +-- drivers/gpu/drm/drm_legacy.h | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-)drivers/gpu/drm/Kconfig +0
-4@@ -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
drivers/gpu/drm/Kconfig source "drivers/gpu/drm/xlnx/Kconfig" · line 389
Quoted 3 lines
drivers/gpu/drm/Kconfig +0
-0@@ -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.
Quoted 35 lines
drivers/gpu/drm/Kconfig +0
-1- select DRM_VM help Enable legacy DRI1 drivers. Those drivers expose unsafe and dangerous APIs to user-space, which can be used to circumvent accessdrivers/gpu/drm/Makefile +1
-2@@ -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.odrivers/gpu/drm/drm_legacy.h +1
-1@@ -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)Signature · 1 line
2.29.2
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerPATCH 5/6 drm/radeon: Store PCI controller in struct radeon_device.hose
In reply to Thomas ZimmermannMoves struct drm_device.hose into struct radeon_device. The field in struct DRM device is only for legacy drivers.
--- 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(-)
drivers/gpu/drm/radeon/radeon.h +3 -0
@@ -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;
drivers/gpu/drm/radeon/radeon_drv.c +0 -4
@@ -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 ))
drivers/gpu/drm/radeon/radeon_kms.c +4 -0
@@ -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 ;
drivers/gpu/drm/radeon/radeon_ttm.c +1 -1
@@ -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 :
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thomas Zimmermann
maintainerPATCH 6/6 drm: Move struct drm_device.hose to legacy section
In reply to Thomas ZimmermannThe 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.
--- drivers/gpu/drm/drm_file.c | 2 ++ include/drm/drm_device.h | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_file.c +2 -0
@@ -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 ;
include/drm/drm_device.h +5 -4
@@ -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;
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerI'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 <[email protected]>.
Thanks,
Christian.
Am 12.01.21 um 09:10 schrieb Thomas Zimmermann:
Quoted 41 lines
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.cand add the remaining I/O-memory helpers to the legacy code.Patch 4 addresses
CONFIG_DRM_VM, which is only selected by legacy drivers, sodrm_vm.ccan directly be compiled byCONFIG_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_LEGACYenabled.Thomas Zimmermann (6):
drm: Inline AGP wrappers into their only callers
drm: Implementdrm_need_swiotlb()indrm_cache.c
drm: Build drm_memory.o only for legacy drivers
drm: MergeCONFIG_DRM_VMintoCONFIG_DRM_LEGACYdrm/radeon: Store PCI controller in struct radeon_device.hose
drm: Move struct drm_device.hose to legacy sectiondrivers/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(-)
Quoted 5 lines
base-commit:
cd0df21e28c36de80356344ff8683be2813c6ff2
prerequisite-patch-id:c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d--
2.29.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel