remove various dma_declare_coherent related exports
Subsystems (3)
Hi all,
this is a refresh of and older series that tries to ensure that drivers don't use the dma_declare_coherent function, which is intende for platform code. Unfortunately we've actually grown a user in remoteproc since then. While the maintainers havee promised to fix that up that hasn't happened so far, so for now this disabled the modular build for remoteproc until that has been solved.
PATCH 1/4 dma-mapping: remove dma_release_declared_memory
This function is entirely unused given that declared memory is generally provided by platform setup code.
--- Documentation/DMA-API.txt | 11 ----------- include/linux/dma-mapping.h | 6 ------ kernel/dma/coherent.c | 11 ----------- 3 files changed, 28 deletions(-)
Documentation/DMA-API.txt +0 -11
@@ -595,17 +595,6 @@ For reasons of efficiency, most platforms choose to track the declared region only at the granularity of a page. For smaller allocations, you should use the dma_pool() API. -:: - - void - dma_release_declared_memory(struct device *dev) - -Remove the memory region previously declared from the system. This -API performs *no* in-use checking for this region and will return -unconditionally having removed all the required structures. It is the -driver's job to ensure that no parts of this memory region are -currently in use. - Part III - Debug drivers use of the DMA-API -------------------------------------------
include/linux/dma-mapping.h +0 -6
@@ -753,7 +753,6 @@ static inline int dma_get_cache_alignment(void)#ifdef CONFIG_DMA_DECLARE_COHERENT int dma_declare_coherent_memory (struct device *dev,phys_addr_t phys_addr,dma_addr_t device_addr,size_t size); -void dma_release_declared_memory (struct device *dev);#else static inline int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
@@ -761,11 +760,6 @@ dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, {return -ENOSYS ; } - -static inline void -dma_release_declared_memory (struct device *dev) -{ -}#endif /* CONFIG_DMA_DECLARE_COHERENT */ static inline void *dmam_alloc_coherent(struct device *dev, size_t size,
kernel/dma/coherent.c +0 -11
@@ -124,17 +124,6 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, }EXPORT_SYMBOL (dma_declare_coherent_memory); -void dma_release_declared_memory (struct device *dev) -{ -struct dma_coherent_mem *mem = dev->dma_mem; - -if (!mem) -return ; -dma_release_coherent_memory (mem); - dev->dma_mem =NULL ; -} -EXPORT_SYMBOL (dma_release_declared_memory); -static void *__dma_alloc_from_coherent (struct dma_coherent_mem *mem,ssize_t size,dma_addr_t *dma_handle) {
Signature · 1 line
2.20.1
PATCH 2/4 dma-mapping: remove the dma_mmap_from_dev_coherent export
In reply to Christoph Hellwigdma_mmap_from_dev_coherent is only used by dma_map_ops instances, none of which is modular.
--- kernel/dma/coherent.c | 1 - 1 file changed, 1 deletion(-)
kernel/dma/coherent.c +0 -1
@@ -277,7 +277,6 @@ int dma_mmap_from_dev_coherent(struct device *dev, struct vm_area_struct *vma,return __dma_mmap_from_coherent (mem, vma, vaddr, size, ret); } -EXPORT_SYMBOL (dma_mmap_from_dev_coherent);int dma_mmap_from_global_coherent (struct vm_area_struct *vma,void *vaddr,size_t size,int *ret)
Signature · 1 line
2.20.1
PATCH 3/4 remoteproc: don't allow modular build
In reply to Christoph HellwigRemoteproc started using dma_declare_coherent_memory recently, which is a bad idea from drivers, and the maintainers agreed to fix that. But until that is fixed only allow building the driver built in so that we can remove the dma_declare_coherent_memory export and prevent other drivers from "accidentally" using it like remoteproc. Note that the driver would also leak the declared coherent memory on unload if it actually was built as a module at the moment.
--- drivers/remoteproc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/Kconfig +1 -1
@@ -2,7 +2,7 @@ menu "Remoteproc drivers" config REMOTEPROC - tristate "Support for Remote Processor subsystem" + bool "Support for Remote Processor subsystem" depends on HAS_DMA select CRC32 select FW_LOADER
Signature · 1 line
2.20.1
Re: [PATCH 3/4] remoteproc: don't allow modular build
Quoted 9 lines · Christoph Hellwig
Remoteproc started using
dma_declare_coherent_memoryrecently, which is a bad idea from drivers, and the maintainers agreed to fix that. But until that is fixed only allow building the driver built in so that we can remove thedma_declare_coherent_memoryexport and prevent other drivers from "accidentally" using it like remoteproc. Note that the driver would also leak the declared coherent memory on unload if it actually was built as a module at the moment.Signed-off-by Christoph Hellwig <[email protected]>
Please pick this together with the other patches.
Regards,
Bjorn
Quoted 20 lines
--- drivers/remoteproc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/Kconfig +1
-1@@ -2,7 +2,7 @@ menu "Remoteproc drivers" config REMOTEPROC - tristate "Support for Remote Processor subsystem" + bool "Support for Remote Processor subsystem" depends on HAS_DMA select CRC32 select FW_LOADERSignature · 1 line
2.20.1
Re: [PATCH 3/4] remoteproc: don't allow modular build
Quoted 3 lines · Bjorn Andersson
Reviewed-by Bjorn Andersson <[email protected]>Please pick this together with the other patches.
Thanks, I've applied the series to the dma-mapping tree for 5.4.
PATCH 4/4 dma-mapping: remove the dma_declare_coherent_memory export
In reply to Christoph Hellwigdma_declare_coherent_memory is something that the platform setup code (which pretty much means the device tree these days) need to do so that drivers can use the memory as declared by the platform. Drivers themselves have no business calling this function.
--- kernel/dma/coherent.c | 1 - 1 file changed, 1 deletion(-)
kernel/dma/coherent.c +0 -1
@@ -122,7 +122,6 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,dma_release_coherent_memory (mem);return ret; } -EXPORT_SYMBOL (dma_declare_coherent_memory);static void *__dma_alloc_from_coherent (struct dma_coherent_mem *mem,ssize_t size,dma_addr_t *dma_handle)
Signature · 1 line
2.20.1