* [PATCH] spi: sh-msiof: Use correct device for DMA mapping with IOMMU
@ 2014-07-09 10:21 Geert Uytterhoeven
2014-07-09 21:38 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-07-09 10:21 UTC (permalink / raw)
To: Mark Brown
Cc: Laurent Pinchart, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-sh-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven
To function correctly in the presence of an IOMMU, the DMA buffers must be
mapped using the DMA channel's device instead of the MSIOF platform
device's device.
Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
drivers/spi/spi-sh-msiof.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 9922ed3a4441..4f0f1cbc92ef 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1026,12 +1026,14 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
if (!p->rx_dma_page)
goto free_tx_page;
- p->tx_dma_addr = dma_map_single(dev, p->tx_dma_page, PAGE_SIZE,
+ p->tx_dma_addr = dma_map_single(&master->dma_tx->dev->device,
+ p->tx_dma_page, PAGE_SIZE,
DMA_TO_DEVICE);
if (dma_mapping_error(dev, p->tx_dma_addr))
goto free_rx_page;
- p->rx_dma_addr = dma_map_single(dev, p->rx_dma_page, PAGE_SIZE,
+ p->rx_dma_addr = dma_map_single(&master->dma_rx->dev->device,
+ p->rx_dma_page, PAGE_SIZE,
DMA_FROM_DEVICE);
if (dma_mapping_error(dev, p->rx_dma_addr))
goto unmap_tx_page;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: sh-msiof: Use correct device for DMA mapping with IOMMU
2014-07-09 10:21 [PATCH] spi: sh-msiof: Use correct device for DMA mapping with IOMMU Geert Uytterhoeven
@ 2014-07-09 21:38 ` Laurent Pinchart
2014-07-09 21:52 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2014-07-09 21:38 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Mark Brown, linux-spi, linux-sh
Hi Geert,
Thank you for the patch.
On Wednesday 09 July 2014 12:21:17 Geert Uytterhoeven wrote:
> To function correctly in the presence of an IOMMU, the DMA buffers must be
> mapped using the DMA channel's device instead of the MSIOF platform
> device's device.
Shouldn't you also update the dma_unmap_single() calls ?
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> ---
> drivers/spi/spi-sh-msiof.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 9922ed3a4441..4f0f1cbc92ef 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -1026,12 +1026,14 @@ static int sh_msiof_request_dma(struct
> sh_msiof_spi_priv *p) if (!p->rx_dma_page)
> goto free_tx_page;
>
> - p->tx_dma_addr = dma_map_single(dev, p->tx_dma_page, PAGE_SIZE,
> + p->tx_dma_addr = dma_map_single(&master->dma_tx->dev->device,
> + p->tx_dma_page, PAGE_SIZE,
> DMA_TO_DEVICE);
> if (dma_mapping_error(dev, p->tx_dma_addr))
> goto free_rx_page;
>
> - p->rx_dma_addr = dma_map_single(dev, p->rx_dma_page, PAGE_SIZE,
> + p->rx_dma_addr = dma_map_single(&master->dma_rx->dev->device,
> + p->rx_dma_page, PAGE_SIZE,
> DMA_FROM_DEVICE);
> if (dma_mapping_error(dev, p->rx_dma_addr))
> goto unmap_tx_page;
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: sh-msiof: Use correct device for DMA mapping with IOMMU
2014-07-09 21:38 ` Laurent Pinchart
@ 2014-07-09 21:52 ` Geert Uytterhoeven
0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-07-09 21:52 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Geert Uytterhoeven, Mark Brown, linux-spi, Linux-sh list
Hi Laurent,
On Wed, Jul 9, 2014 at 11:38 PM, Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org> wrote:
> On Wednesday 09 July 2014 12:21:17 Geert Uytterhoeven wrote:
>> To function correctly in the presence of an IOMMU, the DMA buffers must be
>> mapped using the DMA channel's device instead of the MSIOF platform
>> device's device.
>
> Shouldn't you also update the dma_unmap_single() calls ?
I guess I should ;-)
Thanks, will fix...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-09 21:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-09 10:21 [PATCH] spi: sh-msiof: Use correct device for DMA mapping with IOMMU Geert Uytterhoeven
2014-07-09 21:38 ` Laurent Pinchart
2014-07-09 21:52 ` Geert Uytterhoeven
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).