* [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping
@ 2011-07-14 18:32 ` Ramirez Luna, Omar
0 siblings, 0 replies; 4+ messages in thread
From: Ramirez Luna, Omar @ 2011-07-14 18:32 UTC (permalink / raw)
To: Marek Szyprowski
Cc: linux-arm-kernel, linaro-mm-sig, linux-mm, Kyungmin Park,
Russell King - ARM Linux, Joerg Roedel, Arnd Bergmann
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping
@ 2011-07-14 18:32 ` Ramirez Luna, Omar
0 siblings, 0 replies; 4+ messages in thread
From: Ramirez Luna, Omar @ 2011-07-14 18:32 UTC (permalink / raw)
To: linux-arm-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping
2011-07-14 18:32 ` Ramirez Luna, Omar
@ 2011-07-15 6:27 ` Marek Szyprowski
-1 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2011-07-15 6:27 UTC (permalink / raw)
To: 'Ramirez Luna, Omar'
Cc: linux-arm-kernel, linaro-mm-sig, linux-mm,
'Kyungmin Park', 'Russell King - ARM Linux',
'Joerg Roedel', 'Arnd Bergmann'
Hello,
On Thursday, July 14, 2011 8:33 PM Ramirez Luna, Omar wrote:
> > 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.
Well, ok. This was just a proof-of-concept/rfc patch, so it was designed only
for our particular case.
> > 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.
Right, this is still on my todo list, but I wanted to focus on cleanup
of dma mapping framework and cma first.
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
--
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping
@ 2011-07-15 6:27 ` Marek Szyprowski
0 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2011-07-15 6:27 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
On Thursday, July 14, 2011 8:33 PM Ramirez Luna, Omar wrote:
> > 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.
Well, ok. This was just a proof-of-concept/rfc patch, so it was designed only
for our particular case.
> > 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.
Right, this is still on my todo list, but I wanted to focus on cleanup
of dma mapping framework and cma first.
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-15 6:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-14 18:32 [Linaro-mm-sig] [RFC 2/2] ARM: initial proof-of-concept IOMMU mapper for DMA-mapping Ramirez Luna, Omar
2011-07-14 18:32 ` Ramirez Luna, Omar
2011-07-15 6:27 ` Marek Szyprowski
2011-07-15 6:27 ` Marek Szyprowski
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.