All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA
@ 2015-03-27  8:33 ` James Hogan
  0 siblings, 0 replies; 2+ messages in thread
From: James Hogan @ 2015-03-27  8:33 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: James Hogan, linux-mips, stable

If there is a DMA zone (usually 24bit = 16MB I believe), but no DMA32
zone, as is the case for some 32-bit kernels, then massage_gfp_flags()
will cause DMA memory allocated for devices with a 32..63-bit
coherent_dma_mask to fall back to using __GFP_DMA, even though there may
only be 32-bits of physical address available anyway.

Correct that case to compare against a mask the size of phys_addr_t
instead of always using a 64-bit mask.

Fixes: a2e715a86c6d ("MIPS: DMA: Fix computation of DMA flags from device's coherent_dma_mask.")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 2.6.36+
---
Changes in v2:
- Add whitespace around * operator (Sergei).

This works around problems encountered on Malta with ethernet and IDE
drivers being unable to allocate any coherent memory when the entire
16MB DMA zone is taken up with static kernel data (a separate problem),
even though their coherent_dma_masks are 32-bit. This can happen when
PROVE_RCU and PROVE_LOCKING are set, especially since commit
1413c0389333 ("lockdep: Increase static allocations") was applied in
v3.16.
---
 arch/mips/mm/dma-default.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index af5f046e627e..d5096a59ff94 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -100,7 +100,7 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
 	else
 #endif
 #if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32)
-	     if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
+	     if (dev->coherent_dma_mask < DMA_BIT_MASK(sizeof(phys_addr_t) * 8))
 		dma_flag = __GFP_DMA;
 	else
 #endif
-- 
2.0.5

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

* [PATCH v2] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA
@ 2015-03-27  8:33 ` James Hogan
  0 siblings, 0 replies; 2+ messages in thread
From: James Hogan @ 2015-03-27  8:33 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: James Hogan, linux-mips, stable

If there is a DMA zone (usually 24bit = 16MB I believe), but no DMA32
zone, as is the case for some 32-bit kernels, then massage_gfp_flags()
will cause DMA memory allocated for devices with a 32..63-bit
coherent_dma_mask to fall back to using __GFP_DMA, even though there may
only be 32-bits of physical address available anyway.

Correct that case to compare against a mask the size of phys_addr_t
instead of always using a 64-bit mask.

Fixes: a2e715a86c6d ("MIPS: DMA: Fix computation of DMA flags from device's coherent_dma_mask.")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # 2.6.36+
---
Changes in v2:
- Add whitespace around * operator (Sergei).

This works around problems encountered on Malta with ethernet and IDE
drivers being unable to allocate any coherent memory when the entire
16MB DMA zone is taken up with static kernel data (a separate problem),
even though their coherent_dma_masks are 32-bit. This can happen when
PROVE_RCU and PROVE_LOCKING are set, especially since commit
1413c0389333 ("lockdep: Increase static allocations") was applied in
v3.16.
---
 arch/mips/mm/dma-default.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index af5f046e627e..d5096a59ff94 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -100,7 +100,7 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
 	else
 #endif
 #if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32)
-	     if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
+	     if (dev->coherent_dma_mask < DMA_BIT_MASK(sizeof(phys_addr_t) * 8))
 		dma_flag = __GFP_DMA;
 	else
 #endif
-- 
2.0.5

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

end of thread, other threads:[~2015-03-27  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27  8:33 [PATCH v2] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA James Hogan
2015-03-27  8:33 ` James Hogan

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.