linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Ramirez Luna, Omar" <omar.ramirez@ti.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Joerg Roedel <joro@8bytes.org>, Arnd Bergmann <arnd@arndb.de>
Subject: [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping
Date: Thu, 14 Jul 2011 13:32:38 -0500	[thread overview]
Message-ID: <CAB-zwWhRQmv8euqN6jeJP=tXTQgGQ3buRJEf=4aPtTOBsh+Z2Q@mail.gmail.com> (raw)

Hi Marek,

> Add initial proof of concept implementation of DMA-mapping API for
> devices that have IOMMU support. Right now only dma_alloc_coherent,
> dma_free_coherent and dma_mmap_coherent functions are supported.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
...
> diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
> new file mode 100644
> index 0000000..c246ff3
> --- /dev/null
> +++ b/arch/arm/include/asm/dma-iommu.h
...
> +int __init arm_iommu_assign_device(struct device *dev, dma_addr_t base, dma_addr_t size);

__init causes a panic if the iommu is assigned after boot.

In OMAP3 the iommu driver controls isp and dsp address spaces, it is
loaded until any of those 2 drivers is needed.

> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index f8c6972..b6397c1 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
...
> +static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
> +           dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs)
> +{
> +       struct dma_iommu_mapping *mapping = dev->archdata.mapping;
> +       struct page **pages;
> +       void *addr = NULL;
> +       pgprot_t prot;
> +
> +       if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs))
> +               prot = pgprot_writecombine(pgprot_kernel);
> +       else
> +               prot = pgprot_dmacoherent(pgprot_kernel);
> +
> +       arm_iommu_init(dev);

I found useful to call arm_iommu_init inside arm_iommu_assign_device
instead. So, then gen_pool is created only once without the
mapping->pool check, instead of relying on the call to ...alloc_attrs,
which in my case I never use because I'm implementing
iommu_map|unmap_sg functions to see how it goes with the dma mapping.

Regards,

Omar

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2011-07-14 18:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-14 18:32 Ramirez Luna, Omar [this message]
2011-07-15  6:27 ` [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAB-zwWhRQmv8euqN6jeJP=tXTQgGQ3buRJEf=4aPtTOBsh+Z2Q@mail.gmail.com' \
    --to=omar.ramirez@ti.com \
    --cc=arnd@arndb.de \
    --cc=joro@8bytes.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).