* [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules
@ 2019-07-11 5:33 miles.chen
2019-07-11 8:50 ` Robin Murphy
0 siblings, 1 reply; 4+ messages in thread
From: miles.chen @ 2019-07-11 5:33 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy
Cc: Miles Chen, iommu, linux-mediatek, linux-kernel, wsd_upstream
From: Miles Chen <miles.chen@mediatek.com>
This change exports dma_alloc_from_contiguous and
dma_release_from_contiguous to modules.
Currently, we can add a reserve a memory node in dts files, make
it a CMA memory by setting compatible = "shared-dma-pool",
and setup the dev->cma_area by using of_reserved_mem_device_init_by_idx().
Export dma_alloc_from_contiguous and dma_release_from_contiguous, so we
can allocate/free from/to dev->cma_area in kernel modules.
Signed-off-by: Miles Chen <miles.chen@mediatek.com>
---
kernel/dma/contiguous.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index b2a87905846d..d5920bdedc77 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
return cma_alloc(dev_get_cma_area(dev), count, align, no_warn);
}
+EXPORT_SYMBOL_GPL(dma_alloc_from_contiguous);
/**
* dma_release_from_contiguous() - release allocated pages
@@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
{
return cma_release(dev_get_cma_area(dev), pages, count);
}
+EXPORT_SYMBOL_GPL(dma_release_from_contiguous);
/*
* Support for reserved memory regions defined in device tree
--
2.18.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules
2019-07-11 5:33 [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules miles.chen
@ 2019-07-11 8:50 ` Robin Murphy
2019-07-11 10:03 ` Christoph Hellwig
2019-07-11 10:44 ` Miles Chen
0 siblings, 2 replies; 4+ messages in thread
From: Robin Murphy @ 2019-07-11 8:50 UTC (permalink / raw)
To: miles.chen, Christoph Hellwig, Marek Szyprowski
Cc: iommu, linux-mediatek, linux-kernel, wsd_upstream
On 11/07/2019 06:33, miles.chen@mediatek.com wrote:
> From: Miles Chen <miles.chen@mediatek.com>
>
> This change exports dma_alloc_from_contiguous and
> dma_release_from_contiguous to modules.
>
> Currently, we can add a reserve a memory node in dts files, make
> it a CMA memory by setting compatible = "shared-dma-pool",
> and setup the dev->cma_area by using of_reserved_mem_device_init_by_idx().
>
> Export dma_alloc_from_contiguous and dma_release_from_contiguous, so we
> can allocate/free from/to dev->cma_area in kernel modules.
As far as I understand, this was never intended for drivers to call
directly. If a device has its own private CMA area, then regular
dma_alloc_attrs() should allocate from that automatically; if that's not
happening already, then there's a bug somewhere.
Robin.
> Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> ---
> kernel/dma/contiguous.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index b2a87905846d..d5920bdedc77 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
>
> return cma_alloc(dev_get_cma_area(dev), count, align, no_warn);
> }
> +EXPORT_SYMBOL_GPL(dma_alloc_from_contiguous);
>
> /**
> * dma_release_from_contiguous() - release allocated pages
> @@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
> {
> return cma_release(dev_get_cma_area(dev), pages, count);
> }
> +EXPORT_SYMBOL_GPL(dma_release_from_contiguous);
>
> /*
> * Support for reserved memory regions defined in device tree
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules
2019-07-11 8:50 ` Robin Murphy
@ 2019-07-11 10:03 ` Christoph Hellwig
2019-07-11 10:44 ` Miles Chen
1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2019-07-11 10:03 UTC (permalink / raw)
To: Robin Murphy
Cc: wsd_upstream, linux-kernel, iommu, miles.chen, linux-mediatek,
Christoph Hellwig
On Thu, Jul 11, 2019 at 09:50:58AM +0100, Robin Murphy wrote:
> On 11/07/2019 06:33, miles.chen@mediatek.com wrote:
>> From: Miles Chen <miles.chen@mediatek.com>
>>
>> This change exports dma_alloc_from_contiguous and
>> dma_release_from_contiguous to modules.
>>
>> Currently, we can add a reserve a memory node in dts files, make
>> it a CMA memory by setting compatible = "shared-dma-pool",
>> and setup the dev->cma_area by using of_reserved_mem_device_init_by_idx().
>>
>> Export dma_alloc_from_contiguous and dma_release_from_contiguous, so we
>> can allocate/free from/to dev->cma_area in kernel modules.
>
> As far as I understand, this was never intended for drivers to call
> directly. If a device has its own private CMA area, then regular
> dma_alloc_attrs() should allocate from that automatically; if that's not
> happening already, then there's a bug somewhere.
Agreed.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules
2019-07-11 8:50 ` Robin Murphy
2019-07-11 10:03 ` Christoph Hellwig
@ 2019-07-11 10:44 ` Miles Chen
1 sibling, 0 replies; 4+ messages in thread
From: Miles Chen @ 2019-07-11 10:44 UTC (permalink / raw)
To: Robin Murphy
Cc: wsd_upstream, linux-kernel, iommu, linux-mediatek, Christoph Hellwig
On Thu, 2019-07-11 at 09:50 +0100, Robin Murphy wrote:
> On 11/07/2019 06:33, miles.chen@mediatek.com wrote:
> > From: Miles Chen <miles.chen@mediatek.com>
> >
> > This change exports dma_alloc_from_contiguous and
> > dma_release_from_contiguous to modules.
> >
> > Currently, we can add a reserve a memory node in dts files, make
> > it a CMA memory by setting compatible = "shared-dma-pool",
> > and setup the dev->cma_area by using of_reserved_mem_device_init_by_idx().
> >
> > Export dma_alloc_from_contiguous and dma_release_from_contiguous, so we
> > can allocate/free from/to dev->cma_area in kernel modules.
>
> As far as I understand, this was never intended for drivers to call
> directly. If a device has its own private CMA area, then regular
> dma_alloc_attrs() should allocate from that automatically; if that's not
> happening already, then there's a bug somewhere.
>
> Robin.
Thanks for your comment.
After using dma_direct_ops, dma_alloc_attrs() works fine now.
Miles
>
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > kernel/dma/contiguous.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> > index b2a87905846d..d5920bdedc77 100644
> > --- a/kernel/dma/contiguous.c
> > +++ b/kernel/dma/contiguous.c
> > @@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
> >
> > return cma_alloc(dev_get_cma_area(dev), count, align, no_warn);
> > }
> > +EXPORT_SYMBOL_GPL(dma_alloc_from_contiguous);
> >
> > /**
> > * dma_release_from_contiguous() - release allocated pages
> > @@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
> > {
> > return cma_release(dev_get_cma_area(dev), pages, count);
> > }
> > +EXPORT_SYMBOL_GPL(dma_release_from_contiguous);
> >
> > /*
> > * Support for reserved memory regions defined in device tree
> >
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-11 10:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 5:33 [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules miles.chen
2019-07-11 8:50 ` Robin Murphy
2019-07-11 10:03 ` Christoph Hellwig
2019-07-11 10:44 ` Miles Chen
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).