All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/4] dmaengine: rcar-dmac: add iommu support for slave transfers
@ 2016-01-08  8:23 Niklas Söderlund
  2016-01-08  9:28 ` Geert Uytterhoeven
  2016-01-11  2:31 ` Niklas Söderlund
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas Söderlund @ 2016-01-08  8:23 UTC (permalink / raw)
  To: linux-sh

Hi,

In this series I (try) to enable IOMMU support for rcar-dma. This
prototype works fine and is test on a lager board but it might have some
odd design choices.

What I'm most concerned about is that I could not find a good way too
keep track of mappings from different DMA channels to the same address
so that they could properly be unmapped. This issue is due to that two
channels might both try to map the same address (think rx/tx pair) and
that would make it unsafe for any one of the channels to unmap the
address without knowing if it's in use by the other.

A follow up problem to this is that if the same address is mapped from
two different channels but with different sizes and the larger size is
tried last. If such a condition should happen and the larger size is so
large that it crosses a page boundary there would be trouble.

An obvious solution to both problem would be to map address to different
iova:s in each channel and keep track of the unique mapping. That way
all the above problems would go away. The problem is I can't figure out
how to allocate a unique iova to feed to iommu_map.

Patch 4/4 is only included to show what I turn on to verify the series.
To do the verification on the lager board I simply run md5sum on
/dev/mmcblk1.


Niklas Söderlund (4):
  iommu: add function iommu_min_pgsize
  dmaengine: rcar-dmac: add iommu support for slave transfers
  ARM: dts: r8a7790: add iommus to dmac0 and dmac1
  enable ipmmu for devcies connected to ipmmu_ds

 arch/arm/boot/dts/r8a7790.dtsi      | 32 +++++++++++++++++++++++-
 arch/arm/configs/shmobile_defconfig |  3 ++-
 drivers/dma/sh/rcar-dmac.c          | 50 ++++++++++++++++++++++++++++++++++++-
 include/linux/iommu.h               | 10 ++++++++
 4 files changed, 92 insertions(+), 3 deletions(-)

--
2.6.4


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

* Re: [RFC 0/4] dmaengine: rcar-dmac: add iommu support for slave transfers
  2016-01-08  8:23 [RFC 0/4] dmaengine: rcar-dmac: add iommu support for slave transfers Niklas Söderlund
@ 2016-01-08  9:28 ` Geert Uytterhoeven
  2016-01-11  2:31 ` Niklas Söderlund
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-01-08  9:28 UTC (permalink / raw)
  To: linux-sh

Hi Niklas,

On Fri, Jan 8, 2016 at 9:23 AM, Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
> What I'm most concerned about is that I could not find a good way too
> keep track of mappings from different DMA channels to the same address
> so that they could properly be unmapped. This issue is due to that two
> channels might both try to map the same address (think rx/tx pair) and
> that would make it unsafe for any one of the channels to unmap the
> address without knowing if it's in use by the other.
>
> A follow up problem to this is that if the same address is mapped from
> two different channels but with different sizes and the larger size is
> tried last. If such a condition should happen and the larger size is so
> large that it crosses a page boundary there would be trouble.
>
> An obvious solution to both problem would be to map address to different
> iova:s in each channel and keep track of the unique mapping. That way
> all the above problems would go away. The problem is I can't figure out
> how to allocate a unique iova to feed to iommu_map.

What about
  1. Reference counting the mappings,
  2. Returning -EBUSY if the same address is already mapped with a
     different size? In the case of RX/TX pairs, the size should be the same
     (one page).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.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

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

* Re: [RFC 0/4] dmaengine: rcar-dmac: add iommu support for slave transfers
  2016-01-08  8:23 [RFC 0/4] dmaengine: rcar-dmac: add iommu support for slave transfers Niklas Söderlund
  2016-01-08  9:28 ` Geert Uytterhoeven
@ 2016-01-11  2:31 ` Niklas Söderlund
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Söderlund @ 2016-01-11  2:31 UTC (permalink / raw)
  To: linux-sh

Hi Geert,

* Geert Uytterhoeven <geert@linux-m68k.org> [2016-01-08 10:28:22 +0100]:

> Hi Niklas,
>
> On Fri, Jan 8, 2016 at 9:23 AM, Niklas Söderlund
> <niklas.soderlund@ragnatech.se> wrote:
> > What I'm most concerned about is that I could not find a good way too
> > keep track of mappings from different DMA channels to the same address
> > so that they could properly be unmapped. This issue is due to that two
> > channels might both try to map the same address (think rx/tx pair) and
> > that would make it unsafe for any one of the channels to unmap the
> > address without knowing if it's in use by the other.
> >
> > A follow up problem to this is that if the same address is mapped from
> > two different channels but with different sizes and the larger size is
> > tried last. If such a condition should happen and the larger size is so
> > large that it crosses a page boundary there would be trouble.
> >
> > An obvious solution to both problem would be to map address to different
> > iova:s in each channel and keep track of the unique mapping. That way
> > all the above problems would go away. The problem is I can't figure out
> > how to allocate a unique iova to feed to iommu_map.
>
> What about
>   1. Reference counting the mappings,
>   2. Returning -EBUSY if the same address is already mapped with a
>      different size? In the case of RX/TX pairs, the size should be the same
>      (one page).

Thanks for the pointers Geert. I did a implementation using reference
counting, it worked but got quiet messy, it was however not all a waste.
I learned that the dma-mapper api is way smarter then me and provided a
interface that solves multiple mappings of the same address.

// Niklas

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

end of thread, other threads:[~2016-01-11  2:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08  8:23 [RFC 0/4] dmaengine: rcar-dmac: add iommu support for slave transfers Niklas Söderlund
2016-01-08  9:28 ` Geert Uytterhoeven
2016-01-11  2:31 ` Niklas Söderlund

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.