LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function
@ 2018-07-11 11:38 Thomas Bogendoerfer
  2018-07-11 11:38 ` [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices Thomas Bogendoerfer
  2018-07-11 16:03 ` [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Paul Burton
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Bogendoerfer @ 2018-07-11 11:38 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips, linux-kernel

sg list elements could cover more than one page of data. Therefore
using plat_map_dma_mem_page() doesn't work for platforms, which have
IOMMU functionality hidden behind plat_map_dma_XXX functions.

Fixes: e36863a550da ("MIPS: HIGHMEM DMA on noncoherent MIPS32 processors")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 arch/mips/mm/dma-default.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index f9fef0028ca2..2718185a3d38 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -288,8 +288,8 @@ static int mips_dma_map_sg(struct device *dev, struct scatterlist *sglist,
 #ifdef CONFIG_NEED_SG_DMA_LENGTH
 		sg->dma_length = sg->length;
 #endif
-		sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) +
-				  sg->offset;
+		sg->dma_address = plat_map_dma_mem(dev, sg_virt(sg),
+						   sg->length);
 	}
 
 	return nents;
-- 
2.13.7


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

* [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices
  2018-07-11 11:38 [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Thomas Bogendoerfer
@ 2018-07-11 11:38 ` Thomas Bogendoerfer
  2018-07-11 16:15   ` Paul Burton
  2018-07-11 16:03 ` [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Paul Burton
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Bogendoerfer @ 2018-07-11 11:38 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan, linux-mips, linux-kernel

platform devices for sonic and esp didn't have dma_masks.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 arch/mips/jazz/setup.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c
index 448fd41792e4..1b5e121c3f0d 100644
--- a/arch/mips/jazz/setup.c
+++ b/arch/mips/jazz/setup.c
@@ -16,6 +16,7 @@
 #include <linux/screen_info.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/jazz.h>
 #include <asm/jazzdma.h>
@@ -136,10 +137,16 @@ static struct resource jazz_esp_rsrc[] = {
 	}
 };
 
+static u64 jazz_esp_dma_mask = DMA_BIT_MASK(32);
+
 static struct platform_device jazz_esp_pdev = {
 	.name		= "jazz_esp",
 	.num_resources	= ARRAY_SIZE(jazz_esp_rsrc),
-	.resource	= jazz_esp_rsrc
+	.resource	= jazz_esp_rsrc,
+	.dev = {
+		.dma_mask	   = &jazz_esp_dma_mask,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+	}
 };
 
 static struct resource jazz_sonic_rsrc[] = {
@@ -155,10 +162,16 @@ static struct resource jazz_sonic_rsrc[] = {
 	}
 };
 
+static u64 jazz_sonic_dma_mask = DMA_BIT_MASK(32);
+
 static struct platform_device jazz_sonic_pdev = {
 	.name		= "jazzsonic",
 	.num_resources	= ARRAY_SIZE(jazz_sonic_rsrc),
-	.resource	= jazz_sonic_rsrc
+	.resource	= jazz_sonic_rsrc,
+	.dev = {
+		.dma_mask	   = &jazz_sonic_dma_mask,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+	}
 };
 
 static struct resource jazz_cmos_rsrc[] = {
-- 
2.13.7


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

* Re: [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function
  2018-07-11 11:38 [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Thomas Bogendoerfer
  2018-07-11 11:38 ` [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices Thomas Bogendoerfer
@ 2018-07-11 16:03 ` Paul Burton
  2018-07-11 20:50   ` Thomas Bogendoerfer
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Burton @ 2018-07-11 16:03 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

Hi Thomas,

On Wed, Jul 11, 2018 at 01:38:51PM +0200, Thomas Bogendoerfer wrote:
> sg list elements could cover more than one page of data. Therefore
> using plat_map_dma_mem_page() doesn't work for platforms, which have
> IOMMU functionality hidden behind plat_map_dma_XXX functions.
> 
> Fixes: e36863a550da ("MIPS: HIGHMEM DMA on noncoherent MIPS32 processors")
> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
>  arch/mips/mm/dma-default.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
> index f9fef0028ca2..2718185a3d38 100644
> --- a/arch/mips/mm/dma-default.c
> +++ b/arch/mips/mm/dma-default.c
> @@ -288,8 +288,8 @@ static int mips_dma_map_sg(struct device *dev, struct scatterlist *sglist,
>  #ifdef CONFIG_NEED_SG_DMA_LENGTH
>  		sg->dma_length = sg->length;
>  #endif
> -		sg->dma_address = plat_map_dma_mem_page(dev, sg_page(sg)) +
> -				  sg->offset;
> +		sg->dma_address = plat_map_dma_mem(dev, sg_virt(sg),
> +						   sg->length);
>  	}
>  
>  	return nents;

This doesn't apply after Christoph's massive MIPS DMA cleanup which can
be found in mips-next (or linux-next). After this work we end up using
the generic dma_direct_map_sg() on most systems, and the code above has
been removed.

Thanks,
    Paul

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

* Re: [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices
  2018-07-11 11:38 ` [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices Thomas Bogendoerfer
@ 2018-07-11 16:15   ` Paul Burton
  2018-07-11 20:52     ` Thomas Bogendoerfer
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Burton @ 2018-07-11 16:15 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

Hi Thomas,

On Wed, Jul 11, 2018 at 01:38:52PM +0200, Thomas Bogendoerfer wrote:
> platform devices for sonic and esp didn't have dma_masks.

That's a very brief commit message :)

Could you add a description of why this is a problem & what was broken
as a result of it?

If this is a problem you've encountered it'd also be useful to mention
which functionality you tested on which machine to discover the problem
& verify the fix.

Thanks,
    Paul

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

* Re: [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function
  2018-07-11 16:03 ` [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Paul Burton
@ 2018-07-11 20:50   ` Thomas Bogendoerfer
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Bogendoerfer @ 2018-07-11 20:50 UTC (permalink / raw)
  To: Paul Burton; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

On Wed, 11 Jul 2018 09:03:42 -0700
Paul Burton <paul.burton@mips.com> wrote:

> This doesn't apply after Christoph's massive MIPS DMA cleanup which can
> be found in mips-next (or linux-next). After this work we end up using
> the generic dma_direct_map_sg() on most systems, and the code above has
> been removed.

Christoph's cleanup also fixes the issue. I thought sending it as a fix for
4.17 would be appropriate, but no problem with dropping it.

Thomas.

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

* Re: [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices
  2018-07-11 16:15   ` Paul Burton
@ 2018-07-11 20:52     ` Thomas Bogendoerfer
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Bogendoerfer @ 2018-07-11 20:52 UTC (permalink / raw)
  To: Paul Burton; +Cc: Ralf Baechle, James Hogan, linux-mips, linux-kernel

On Wed, 11 Jul 2018 09:15:56 -0700
Paul Burton <paul.burton@mips.com> wrote:

> On Wed, Jul 11, 2018 at 01:38:52PM +0200, Thomas Bogendoerfer wrote:
> > platform devices for sonic and esp didn't have dma_masks.
> 
> That's a very brief commit message :)

I thought it's obvious, that now every dma mapping operation triggers a WARN_ON, if
dma masks are missing. But no problem to respin with a more information added.

Thomas.

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-11 11:38 [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Thomas Bogendoerfer
2018-07-11 11:38 ` [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices Thomas Bogendoerfer
2018-07-11 16:15   ` Paul Burton
2018-07-11 20:52     ` Thomas Bogendoerfer
2018-07-11 16:03 ` [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function Paul Burton
2018-07-11 20:50   ` Thomas Bogendoerfer

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

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


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


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