linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y
@ 2017-07-09 19:33 Geert Uytterhoeven
  2017-07-10  7:55 ` Arnd Bergmann
  2017-07-10 14:56 ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2017-07-09 19:33 UTC (permalink / raw)
  To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Madalin Bucur,
	David S . Miller, Arnd Bergmann
  Cc: netdev, linux-kernel, Geert Uytterhoeven

Adding a dummy for set_dma_ops() allows to compile (sub)drivers that
don't actually use the DMA API, but propagate DMA ops configuration to a
second driver that may or may not use the DMA API.  Of course the second
driver does have to depend on HAS_DMA if it uses the DMA API.

An example is commit 5567e989198b5a8d ("fsl/fman: propagate dma_ops").

This allows to revert commit 85688d9adf685572 ("fsl/fman: add dependency
on HAS_DMA").

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 include/linux/dma-mapping.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 843ab866e0f487c2..0ab244b954418e2b 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -194,6 +194,8 @@ static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
 {
 	return &bad_dma_ops;
 }
+static inline void set_dma_ops(struct device *dev,
+			       const struct dma_map_ops *dma_ops) {}
 #endif
 
 static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
-- 
2.7.4

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

* Re: [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y
  2017-07-09 19:33 [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y Geert Uytterhoeven
@ 2017-07-10  7:55 ` Arnd Bergmann
  2017-07-10 14:56 ` Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2017-07-10  7:55 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Madalin Bucur,
	David S . Miller, Networking, Linux Kernel Mailing List

On Sun, Jul 9, 2017 at 9:33 PM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Adding a dummy for set_dma_ops() allows to compile (sub)drivers that
> don't actually use the DMA API, but propagate DMA ops configuration to a
> second driver that may or may not use the DMA API.  Of course the second
> driver does have to depend on HAS_DMA if it uses the DMA API.
>
> An example is commit 5567e989198b5a8d ("fsl/fman: propagate dma_ops").
>
> This allows to revert commit 85688d9adf685572 ("fsl/fman: add dependency
> on HAS_DMA").
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

I can't think of any correct use case for this new helper. IMO a device
driver should never set the dma_map_ops for any device, and we should
instead for the fman driver correctly.

       Arnd

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

* Re: [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y
  2017-07-09 19:33 [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y Geert Uytterhoeven
  2017-07-10  7:55 ` Arnd Bergmann
@ 2017-07-10 14:56 ` Christoph Hellwig
  2017-07-10 15:31   ` Robin Murphy
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2017-07-10 14:56 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Madalin Bucur,
	David S . Miller, Arnd Bergmann, netdev, linux-kernel

This looks reasonable to me, I'd be happy to pick it up.  Can you send
it as a series with the reverts?

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

* Re: [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y
  2017-07-10 14:56 ` Christoph Hellwig
@ 2017-07-10 15:31   ` Robin Murphy
  2017-07-11 14:02     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2017-07-10 15:31 UTC (permalink / raw)
  To: Christoph Hellwig, Geert Uytterhoeven
  Cc: Marek Szyprowski, Madalin Bucur, David S . Miller, Arnd Bergmann,
	netdev, linux-kernel

On 10/07/17 15:56, Christoph Hellwig wrote:
> This looks reasonable to me, I'd be happy to pick it up.  Can you send
> it as a series with the reverts?

The fact remains that the FSL driver is still doing the wrong thing
though - set_dma_ops(dev1, get_dma_ops(dev2)) is just a hack which
happens to work on platforms which don't keep other arch-internal DMA
info as well. I did start writing a patch somewhere to fix this thing to
actually do proper DMA configuration (originally in the context of not
abusing arch_setup_dma_ops()), but Arnd's fix is probably simpler.

I don't think it makes an awful lot of sense for code without a DMA API
dependency to be calling set_dma_ops() - AFAIU the only reason it's
available to drivers at all is for particular RDMA cases which know that
their "DMA" is actually done by CPU threads, and want to optimise for that.

Robin.

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

* Re: [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y
  2017-07-10 15:31   ` Robin Murphy
@ 2017-07-11 14:02     ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-07-11 14:02 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Christoph Hellwig, Geert Uytterhoeven, Marek Szyprowski,
	Madalin Bucur, David S . Miller, Arnd Bergmann, netdev,
	linux-kernel

On Mon, Jul 10, 2017 at 04:31:54PM +0100, Robin Murphy wrote:
> On 10/07/17 15:56, Christoph Hellwig wrote:
> > This looks reasonable to me, I'd be happy to pick it up.  Can you send
> > it as a series with the reverts?
> 
> The fact remains that the FSL driver is still doing the wrong thing
> though - set_dma_ops(dev1, get_dma_ops(dev2)) is just a hack which
> happens to work on platforms which don't keep other arch-internal DMA
> info as well. I did start writing a patch somewhere to fix this thing to
> actually do proper DMA configuration (originally in the context of not
> abusing arch_setup_dma_ops()), but Arnd's fix is probably simpler.
> 
> I don't think it makes an awful lot of sense for code without a DMA API
> dependency to be calling set_dma_ops() - AFAIU the only reason it's
> available to drivers at all is for particular RDMA cases which know that
> their "DMA" is actually done by CPU threads, and want to optimise for that.

Even that code should require the DMA API.  So yes, maybe we should
fix the code to propagate the settings by another means.

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

end of thread, other threads:[~2017-07-11 14:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-09 19:33 [PATCH/RFC] dma-mapping: Provide dummy set_dma_ops() for NO_DMA=y Geert Uytterhoeven
2017-07-10  7:55 ` Arnd Bergmann
2017-07-10 14:56 ` Christoph Hellwig
2017-07-10 15:31   ` Robin Murphy
2017-07-11 14:02     ` Christoph Hellwig

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