From: Miles Chen <miles.chen@mediatek.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org,
linux-mediatek@lists.infradead.org,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules
Date: Thu, 11 Jul 2019 18:44:21 +0800 [thread overview]
Message-ID: <1562841861.9534.2.camel@mtkswgap22> (raw)
In-Reply-To: <7d14b94f-454f-d512-bc8f-589f71bc07ea@arm.com>
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
prev parent reply other threads:[~2019-07-11 10:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=1562841861.9534.2.camel@mtkswgap22 \
--to=miles.chen@mediatek.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=robin.murphy@arm.com \
--cc=wsd_upstream@mediatek.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).