linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* tip/x86/dma fix for arc and s390 (at least)
@ 2018-03-28 13:35 Christoph Hellwig
  2018-03-28 13:35 ` [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-03-28 13:35 UTC (permalink / raw)
  To: x86; +Cc: Evgeniy Didin, Sebastian Ott, iommu, linux-kernel

Hi all,

this restores previous __GFP_ZERO passthrough behavior for now as arc and
s390 rely on it.  Needs more work to sort out the API mess in the long run.

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

* [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs
  2018-03-28 13:35 tip/x86/dma fix for arc and s390 (at least) Christoph Hellwig
@ 2018-03-28 13:35 ` Christoph Hellwig
  2018-03-28 15:12   ` Evgeniy Didin
  2018-03-28 15:40   ` [tip:x86/dma] dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs tip-bot for Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-03-28 13:35 UTC (permalink / raw)
  To: x86; +Cc: Evgeniy Didin, Sebastian Ott, iommu, linux-kernel

Revert the clearing of __GFP_ZERO in dma_alloc_attrs and move it to
dma_direct_alloc for now.  While most common architectures always zero dma
cohereny allocations (and x86 did so since day one) this is not documented
and at least arc and s390 do not zero without the explicit __GFP_ZERO
argument.

Fixes: 57bf5a8963f8 ("dma-mapping: clear harmful GFP_* flags in common code")
Reported-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/dma-mapping.h | 8 ++------
 lib/dma-direct.c            | 3 +++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eb9eab4ecd6d..12fedcba9a9a 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -518,12 +518,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
 	if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
 		return cpu_addr;
 
-	/*
-	 * Let the implementation decide on the zone to allocate from, and
-	 * decide on the way of zeroing the memory given that the memory
-	 * returned should always be zeroed.
-	 */
-	flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO);
+	/* let the implementation decide on the zone to allocate from: */
+	flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
 
 	if (!arch_dma_alloc_attrs(&dev, &flag))
 		return NULL;
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index 1277d293d4da..c0bba30fef0a 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -59,6 +59,9 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
 	struct page *page = NULL;
 	void *ret;
 
+	/* we always manually zero the memory once we are done: */
+	gfp &= ~__GFP_ZERO;
+
 	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
 	if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
 		gfp |= GFP_DMA;
-- 
2.14.2

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

* Re: [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs
  2018-03-28 13:35 ` [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs Christoph Hellwig
@ 2018-03-28 15:12   ` Evgeniy Didin
  2018-04-09 10:52     ` dma-mapping: clear harmful GFP_* flags in common code Alexey Brodkin
  2018-03-28 15:40   ` [tip:x86/dma] dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs tip-bot for Christoph Hellwig
  1 sibling, 1 reply; 5+ messages in thread
From: Evgeniy Didin @ 2018-03-28 15:12 UTC (permalink / raw)
  To: hch, x86
  Cc: linux-kernel, sebott, linux-arch, iommu, Evgeniy.Didin, linux-snps-arc

Adding linux-snps and linux-arch mailing lists.

> Revert the clearing of __GFP_ZERO in dma_alloc_attrs and move it to
> dma_direct_alloc for now.  While most common architectures always zero dma
> cohereny allocations (and x86 did so since day one) this is not documented
> and at least arc and s390 do not zero without the explicit __GFP_ZERO
> argument.
This patch fixed Ethernet issues on ARC HSDK.
https://www.spinics.net/lists/kernel/msg2762054.html

Tested-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
> Fixes: 57bf5a8963f8 ("dma-mapping: clear harmful GFP_* flags in common code")
> Reported-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
> Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/dma-mapping.h | 8 ++------
>  lib/dma-direct.c            | 3 +++
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index eb9eab4ecd6d..12fedcba9a9a 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -518,12 +518,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
>  	if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
>  		return cpu_addr;
>  
> -	/*
> -	 * Let the implementation decide on the zone to allocate from, and
> -	 * decide on the way of zeroing the memory given that the memory
> -	 * returned should always be zeroed.
> -	 */
> -	flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO);
> +	/* let the implementation decide on the zone to allocate from: */
> +	flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
> 
>  	if (!arch_dma_alloc_attrs(&dev, &flag))
>  		return NULL;
> diff --git a/lib/dma-direct.c b/lib/dma-direct.c
> index 1277d293d4da..c0bba30fef0a 100644
> --- a/lib/dma-direct.c
> +++ b/lib/dma-direct.c
> @@ -59,6 +59,9 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
>  	struct page *page = NULL;
>  	void *ret;
>  
> +	/* we always manually zero the memory once we are done: */
> +	gfp &= ~__GFP_ZERO;
> +
>  	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
>  	if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
>  		gfp |= GFP_DMA;

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

* [tip:x86/dma] dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs
  2018-03-28 13:35 ` [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs Christoph Hellwig
  2018-03-28 15:12   ` Evgeniy Didin
@ 2018-03-28 15:40   ` tip-bot for Christoph Hellwig
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Christoph Hellwig @ 2018-03-28 15:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: sebott, tglx, hch, mingo, Evgeniy.Didin, linux-kernel, hpa

Commit-ID:  e89f5b37015309a8bdf0b21d08007580b92f92a4
Gitweb:     https://git.kernel.org/tip/e89f5b37015309a8bdf0b21d08007580b92f92a4
Author:     Christoph Hellwig <hch@lst.de>
AuthorDate: Wed, 28 Mar 2018 15:35:35 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 28 Mar 2018 17:34:23 +0200

dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs

Revert the clearing of __GFP_ZERO in dma_alloc_attrs and move it to
dma_direct_alloc for now.  While most common architectures always zero dma
cohereny allocations (and x86 did so since day one) this is not documented
and at least arc and s390 do not zero without the explicit __GFP_ZERO
argument.

Fixes: 57bf5a8963f8 ("dma-mapping: clear harmful GFP_* flags in common code")
Reported-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Evgeniy Didin <Evgeniy.Didin@synopsys.com>
Cc: iommu@lists.linux-foundation.org
Link: https://lkml.kernel.org/r/20180328133535.17302-2-hch@lst.de

---
 include/linux/dma-mapping.h | 8 ++------
 lib/dma-direct.c            | 3 +++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eb9eab4ecd6d..12fedcba9a9a 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -518,12 +518,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size,
 	if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr))
 		return cpu_addr;
 
-	/*
-	 * Let the implementation decide on the zone to allocate from, and
-	 * decide on the way of zeroing the memory given that the memory
-	 * returned should always be zeroed.
-	 */
-	flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO);
+	/* let the implementation decide on the zone to allocate from: */
+	flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
 
 	if (!arch_dma_alloc_attrs(&dev, &flag))
 		return NULL;
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index 1277d293d4da..c0bba30fef0a 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -59,6 +59,9 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
 	struct page *page = NULL;
 	void *ret;
 
+	/* we always manually zero the memory once we are done: */
+	gfp &= ~__GFP_ZERO;
+
 	/* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */
 	if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS))
 		gfp |= GFP_DMA;

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

* dma-mapping: clear harmful GFP_* flags in common code
  2018-03-28 15:12   ` Evgeniy Didin
@ 2018-04-09 10:52     ` Alexey Brodkin
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Brodkin @ 2018-04-09 10:52 UTC (permalink / raw)
  To: stable; +Cc: hch, linux-arch, sebott, x86, linux-kernel, iommu, linux-snps-arc

Hello,

May we have
e89f5b370153 ("dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs")
back-ported to 4.16 kernel as it fixes:

57bf5a8 ("dma-mapping: clear harmful GFP_* flags in common code").

For more info about introduced problem see this thread:
http://lists.infradead.org/pipermail/linux-snps-arc/2018-March/003652.html

-Alexey

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 13:35 tip/x86/dma fix for arc and s390 (at least) Christoph Hellwig
2018-03-28 13:35 ` [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs Christoph Hellwig
2018-03-28 15:12   ` Evgeniy Didin
2018-04-09 10:52     ` dma-mapping: clear harmful GFP_* flags in common code Alexey Brodkin
2018-03-28 15:40   ` [tip:x86/dma] dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs tip-bot for 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).