All of lore.kernel.org
 help / color / mirror / Atom feed
* fix up nowarn confusion in the dma mapping layer
@ 2018-10-01 20:12 Christoph Hellwig
  2018-10-01 20:12 ` [PATCH 1/2] dma-mapping: translate __GFP_NOFAIL to DMA_ATTR_NO_WARN Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-01 20:12 UTC (permalink / raw)
  To: iommu; +Cc: Marek Szyprowski, Robin Murphy, linux-kernel

Hi all,

this series sorts out how we deal with the nowarn flags in the dma
mapping code.  We still support __GFP_NOWARN for the legacy APIs that
don't support passing the dma specific flags, but we generally want
every implementation to actually check DMA_ATTR_NO_WARN instead.

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

* [PATCH 1/2] dma-mapping: translate __GFP_NOFAIL to DMA_ATTR_NO_WARN
  2018-10-01 20:12 fix up nowarn confusion in the dma mapping layer Christoph Hellwig
@ 2018-10-01 20:12 ` Christoph Hellwig
  2018-10-01 20:12 ` [PATCH 2/2] dma-direct: respect DMA_ATTR_NO_WARN Christoph Hellwig
  2018-10-08  7:03 ` fix up nowarn confusion in the dma mapping layer Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-01 20:12 UTC (permalink / raw)
  To: iommu; +Cc: Marek Szyprowski, Robin Murphy, linux-kernel

This allows all dma_map_ops instances to entirely rely on
DMA_ATTR_NO_WARN going forward.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/dma-mapping.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 562af6b45f23..02ecd4679e47 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -557,9 +557,11 @@ static inline void dma_free_attrs(struct device *dev, size_t size,
 }
 
 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
-		dma_addr_t *dma_handle, gfp_t flag)
+		dma_addr_t *dma_handle, gfp_t gfp)
 {
-	return dma_alloc_attrs(dev, size, dma_handle, flag, 0);
+
+	return dma_alloc_attrs(dev, size, dma_handle, gfp,
+			(gfp & __GFP_NOWARN) ? DMA_ATTR_NO_WARN : 0);
 }
 
 static inline void dma_free_coherent(struct device *dev, size_t size,
@@ -793,8 +795,12 @@ static inline void dmam_release_declared_memory(struct device *dev)
 static inline void *dma_alloc_wc(struct device *dev, size_t size,
 				 dma_addr_t *dma_addr, gfp_t gfp)
 {
-	return dma_alloc_attrs(dev, size, dma_addr, gfp,
-			       DMA_ATTR_WRITE_COMBINE);
+	unsigned long attrs = DMA_ATTR_NO_WARN;
+
+	if (gfp & __GFP_NOWARN)
+		attrs |= DMA_ATTR_NO_WARN;
+
+	return dma_alloc_attrs(dev, size, dma_addr, gfp, attrs);
 }
 #ifndef dma_alloc_writecombine
 #define dma_alloc_writecombine dma_alloc_wc
-- 
2.19.0


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

* [PATCH 2/2] dma-direct: respect DMA_ATTR_NO_WARN
  2018-10-01 20:12 fix up nowarn confusion in the dma mapping layer Christoph Hellwig
  2018-10-01 20:12 ` [PATCH 1/2] dma-mapping: translate __GFP_NOFAIL to DMA_ATTR_NO_WARN Christoph Hellwig
@ 2018-10-01 20:12 ` Christoph Hellwig
  2018-10-08  7:03 ` fix up nowarn confusion in the dma mapping layer Christoph Hellwig
  2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-01 20:12 UTC (permalink / raw)
  To: iommu; +Cc: Marek Szyprowski, Robin Murphy, linux-kernel

Respect the DMA_ATTR_NO_WARN flags for allocations in dma-direct.

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

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 170bd322a94a..ba6f5956a291 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -107,6 +107,9 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size,
 	u64 phys_mask;
 	void *ret;
 
+	if (attrs & DMA_ATTR_NO_WARN)
+		gfp |= __GFP_NOWARN;
+
 	/* we always manually zero the memory once we are done: */
 	gfp &= ~__GFP_ZERO;
 	gfp |= __dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
-- 
2.19.0


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

* Re: fix up nowarn confusion in the dma mapping layer
  2018-10-01 20:12 fix up nowarn confusion in the dma mapping layer Christoph Hellwig
  2018-10-01 20:12 ` [PATCH 1/2] dma-mapping: translate __GFP_NOFAIL to DMA_ATTR_NO_WARN Christoph Hellwig
  2018-10-01 20:12 ` [PATCH 2/2] dma-direct: respect DMA_ATTR_NO_WARN Christoph Hellwig
@ 2018-10-08  7:03 ` Christoph Hellwig
  2018-10-09 12:55   ` Robin Murphy
  2 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-08  7:03 UTC (permalink / raw)
  To: iommu; +Cc: Robin Murphy, linux-kernel

Any comments on these rather trivial patches?

On Mon, Oct 01, 2018 at 01:12:55PM -0700, Christoph Hellwig wrote:
> Hi all,
> 
> this series sorts out how we deal with the nowarn flags in the dma
> mapping code.  We still support __GFP_NOWARN for the legacy APIs that
> don't support passing the dma specific flags, but we generally want
> every implementation to actually check DMA_ATTR_NO_WARN instead.
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
---end quoted text---

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

* Re: fix up nowarn confusion in the dma mapping layer
  2018-10-08  7:03 ` fix up nowarn confusion in the dma mapping layer Christoph Hellwig
@ 2018-10-09 12:55   ` Robin Murphy
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Murphy @ 2018-10-09 12:55 UTC (permalink / raw)
  To: Christoph Hellwig, iommu; +Cc: linux-kernel

On 08/10/18 08:03, Christoph Hellwig wrote:
> Any comments on these rather trivial patches?

Nope ;)

For both,
Acked-by: Robin Murphy <robin.murphy@arm.com>

> On Mon, Oct 01, 2018 at 01:12:55PM -0700, Christoph Hellwig wrote:
>> Hi all,
>>
>> this series sorts out how we deal with the nowarn flags in the dma
>> mapping code.  We still support __GFP_NOWARN for the legacy APIs that
>> don't support passing the dma specific flags, but we generally want
>> every implementation to actually check DMA_ATTR_NO_WARN instead.
>> _______________________________________________
>> iommu mailing list
>> iommu@lists.linux-foundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/iommu
> ---end quoted text---
> 

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

end of thread, other threads:[~2018-10-09 12:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 20:12 fix up nowarn confusion in the dma mapping layer Christoph Hellwig
2018-10-01 20:12 ` [PATCH 1/2] dma-mapping: translate __GFP_NOFAIL to DMA_ATTR_NO_WARN Christoph Hellwig
2018-10-01 20:12 ` [PATCH 2/2] dma-direct: respect DMA_ATTR_NO_WARN Christoph Hellwig
2018-10-08  7:03 ` fix up nowarn confusion in the dma mapping layer Christoph Hellwig
2018-10-09 12:55   ` Robin Murphy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.