IOMMU Archive on lore.kernel.org
 help / color / Atom feed
* remove various dma_declare_coherent related exports
@ 2019-09-02 20:07 Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 1/4] dma-mapping: remove dma_release_declared_memory Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Christoph Hellwig @ 2019-09-02 20:07 UTC (permalink / raw)
  To: iommu, Loic Pallardy, Bjorn Andersson
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel

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.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 1/4] dma-mapping: remove dma_release_declared_memory
  2019-09-02 20:07 remove various dma_declare_coherent related exports Christoph Hellwig
@ 2019-09-02 20:07 ` Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 2/4] dma-mapping: remove the dma_mmap_from_dev_coherent export Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2019-09-02 20:07 UTC (permalink / raw)
  To: iommu, Loic Pallardy, Bjorn Andersson
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel

This function is entirely unused given that declared memory is
generally provided by platform setup code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/DMA-API.txt   | 11 -----------
 include/linux/dma-mapping.h |  6 ------
 kernel/dma/coherent.c       | 11 -----------
 3 files changed, 28 deletions(-)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index e47c63bd4887..c0865ca664b8 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -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
 -------------------------------------------
 
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 48ebe8295987..165cd61f1c6e 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -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,
diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index 29fd6590dc1e..7271cda86a37 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -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)
 {
-- 
2.20.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 2/4] dma-mapping: remove the dma_mmap_from_dev_coherent export
  2019-09-02 20:07 remove various dma_declare_coherent related exports Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 1/4] dma-mapping: remove dma_release_declared_memory Christoph Hellwig
@ 2019-09-02 20:07 ` Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 3/4] remoteproc: don't allow modular build Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 4/4] dma-mapping: remove the dma_declare_coherent_memory export Christoph Hellwig
  3 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2019-09-02 20:07 UTC (permalink / raw)
  To: iommu, Loic Pallardy, Bjorn Andersson
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel

dma_mmap_from_dev_coherent is only used by dma_map_ops instances,
none of which is modular.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 kernel/dma/coherent.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index 7271cda86a37..7cafe1affdc9 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -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)
-- 
2.20.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 3/4] remoteproc: don't allow modular build
  2019-09-02 20:07 remove various dma_declare_coherent related exports Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 1/4] dma-mapping: remove dma_release_declared_memory Christoph Hellwig
  2019-09-02 20:07 ` [PATCH 2/4] dma-mapping: remove the dma_mmap_from_dev_coherent export Christoph Hellwig
@ 2019-09-02 20:07 ` Christoph Hellwig
  2019-09-03 21:07   ` Bjorn Andersson
  2019-09-02 20:07 ` [PATCH 4/4] dma-mapping: remove the dma_declare_coherent_memory export Christoph Hellwig
  3 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2019-09-02 20:07 UTC (permalink / raw)
  To: iommu, Loic Pallardy, Bjorn Andersson
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/remoteproc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 28ed306982f7..94afdde4bc9f 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -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
-- 
2.20.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 4/4] dma-mapping: remove the dma_declare_coherent_memory export
  2019-09-02 20:07 remove various dma_declare_coherent related exports Christoph Hellwig
                   ` (2 preceding siblings ...)
  2019-09-02 20:07 ` [PATCH 3/4] remoteproc: don't allow modular build Christoph Hellwig
@ 2019-09-02 20:07 ` Christoph Hellwig
  3 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2019-09-02 20:07 UTC (permalink / raw)
  To: iommu, Loic Pallardy, Bjorn Andersson
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 kernel/dma/coherent.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index 7cafe1affdc9..545e3869b0e3 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -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)
-- 
2.20.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 3/4] remoteproc: don't allow modular build
  2019-09-02 20:07 ` [PATCH 3/4] remoteproc: don't allow modular build Christoph Hellwig
@ 2019-09-03 21:07   ` Bjorn Andersson
  2019-09-04  9:05     ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Andersson @ 2019-09-03 21:07 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ohad Ben-Cohen, iommu, linux-remoteproc, linux-kernel, Loic Pallardy

On Mon 02 Sep 13:07 PDT 2019, Christoph Hellwig wrote:

> Remoteproc 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Please pick this together with the other patches.

Regards,
Bjorn

> ---
>  drivers/remoteproc/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 28ed306982f7..94afdde4bc9f 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -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
> -- 
> 2.20.1
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 3/4] remoteproc: don't allow modular build
  2019-09-03 21:07   ` Bjorn Andersson
@ 2019-09-04  9:05     ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2019-09-04  9:05 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Ohad Ben-Cohen, Loic Pallardy, linux-remoteproc, linux-kernel,
	iommu, Christoph Hellwig

On Tue, Sep 03, 2019 at 02:07:39PM -0700, Bjorn Andersson wrote:
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> 
> Please pick this together with the other patches.

Thanks, I've applied the series to the dma-mapping tree for 5.4.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-02 20:07 remove various dma_declare_coherent related exports Christoph Hellwig
2019-09-02 20:07 ` [PATCH 1/4] dma-mapping: remove dma_release_declared_memory Christoph Hellwig
2019-09-02 20:07 ` [PATCH 2/4] dma-mapping: remove the dma_mmap_from_dev_coherent export Christoph Hellwig
2019-09-02 20:07 ` [PATCH 3/4] remoteproc: don't allow modular build Christoph Hellwig
2019-09-03 21:07   ` Bjorn Andersson
2019-09-04  9:05     ` Christoph Hellwig
2019-09-02 20:07 ` [PATCH 4/4] dma-mapping: remove the dma_declare_coherent_memory export Christoph Hellwig

IOMMU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iommu/0 linux-iommu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iommu linux-iommu/ https://lore.kernel.org/linux-iommu \
		iommu@lists.linux-foundation.org iommu@archiver.kernel.org
	public-inbox-index linux-iommu


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linux-foundation.lists.iommu


AGPL code for this site: git clone https://public-inbox.org/ public-inbox