2018-07-11 15:06:19

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function

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 <[email protected]>
---
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



2018-07-11 14:58:05

by Thomas Bogendoerfer

[permalink] [raw]
Subject: [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices

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

Signed-off-by: Thomas Bogendoerfer <[email protected]>
---
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


2018-07-11 18:42:16

by Paul Burton

[permalink] [raw]
Subject: Re: [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function

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 <[email protected]>
> ---
> 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

2018-07-11 22:35:44

by Paul Burton

[permalink] [raw]
Subject: Re: [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices

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

2018-07-12 02:53:12

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH 1/2] mips: Fix mips_dma_map_sg by using correct dma mapping function

On Wed, 11 Jul 2018 09:03:42 -0700
Paul Burton <[email protected]> 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.

2018-07-12 02:54:13

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH 2/2] mips/jazz: provide dma_mask/coherent_dma_mask for platform devices

On Wed, 11 Jul 2018 09:15:56 -0700
Paul Burton <[email protected]> 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.