From: <guangming.cao@mediatek.com>
To: <Brian.Starkey@arm.com>, <benjamin.gaignard@linaro.org>,
<christian.koenig@amd.com>, <dri-devel@lists.freedesktop.org>,
<john.stultz@linaro.org>, <labbott@redhat.com>,
<linaro-mm-sig@lists.linaro.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>, <lmark@codeaurora.org>,
<matthias.bgg@gmail.com>, <sumit.semwal@linaro.org>
Cc: <wsd_upstream@mediatek.com>, Guangming Cao <Guangming.Cao@mediatek.com>
Subject: [PATCH] dma-heap: Let dma heap use dma_map_attrs to map & unmap iova
Date: Wed, 21 Jul 2021 17:43:14 +0800 [thread overview]
Message-ID: <20210721094314.117413-1-guangming.cao@mediatek.com> (raw)
In-Reply-To: <20210715062405.98932-1-guangming.cao@mediatek.com>
From: Guangming Cao <Guangming.Cao@mediatek.com>
On Thu, 2021-07-15 at 14:24 +0800, guangming.cao@mediatek.com wrote:
> From: Guangming Cao <Guangming.Cao@mediatek.com>
>
> On Thu, 2021-07-08 at 18:14 +0800, guangming.cao@mediatek.com wrote:
>
> Hi Sumit, Christian, Matthias,
>
> gentle ping for this patch :)
move receviers to '--to' list.
gentle ping for this patch :)
>
> BRs!
> Guangming
>
> > From: Guangming Cao <Guangming.Cao@mediatek.com>
> >
> > For dma-heap users, they can't bypass cache sync when map/unmap
> > iova
> > with dma heap. But they can do it by adding DMA_ATTR_SKIP_CPU_SYNC
> > into dma_alloc_attrs.
> >
> > To keep alignment, at dma_heap side, also use
> > dma_buf_attachment.dma_map_attrs to do iova map & unmap.
> >
> > Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
> > ---
> > drivers/dma-buf/heaps/cma_heap.c | 6 ++++--
> > drivers/dma-buf/heaps/system_heap.c | 6 ++++--
> > 2 files changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-
> > buf/heaps/cma_heap.c
> > index 0c05b79870f9..2c9feb3bfc3e 100644
> > --- a/drivers/dma-buf/heaps/cma_heap.c
> > +++ b/drivers/dma-buf/heaps/cma_heap.c
> > @@ -99,9 +99,10 @@ static struct sg_table
> > *cma_heap_map_dma_buf(struct dma_buf_attachment *attachme
> > {
> > struct dma_heap_attachment *a = attachment->priv;
> > struct sg_table *table = &a->table;
> > + int attrs = attachment->dma_map_attrs;
> > int ret;
> >
> > - ret = dma_map_sgtable(attachment->dev, table, direction, 0);
> > + ret = dma_map_sgtable(attachment->dev, table, direction,
> > attrs);
> > if (ret)
> > return ERR_PTR(-ENOMEM);
> > a->mapped = true;
> > @@ -113,9 +114,10 @@ static void cma_heap_unmap_dma_buf(struct
> > dma_buf_attachment *attachment,
> > enum dma_data_direction direction)
> > {
> > struct dma_heap_attachment *a = attachment->priv;
> > + int attrs = attachment->dma_map_attrs;
> >
> > a->mapped = false;
> > - dma_unmap_sgtable(attachment->dev, table, direction, 0);
> > + dma_unmap_sgtable(attachment->dev, table, direction, attrs);
> > }
> >
> > static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf
> > *dmabuf,
> > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-
> > buf/heaps/system_heap.c
> > index 23a7e74ef966..fc7b1e02988e 100644
> > --- a/drivers/dma-buf/heaps/system_heap.c
> > +++ b/drivers/dma-buf/heaps/system_heap.c
> > @@ -130,9 +130,10 @@ static struct sg_table
> > *system_heap_map_dma_buf(struct dma_buf_attachment *attac
> > {
> > struct dma_heap_attachment *a = attachment->priv;
> > struct sg_table *table = a->table;
> > + int attrs = attachment->dma_map_attrs;
> > int ret;
> >
> > - ret = dma_map_sgtable(attachment->dev, table, direction, 0);
> > + ret = dma_map_sgtable(attachment->dev, table, direction,
> > attrs);
> > if (ret)
> > return ERR_PTR(ret);
> >
> > @@ -145,9 +146,10 @@ static void system_heap_unmap_dma_buf(struct
> > dma_buf_attachment *attachment,
> > enum dma_data_direction
> > direction)
> > {
> > struct dma_heap_attachment *a = attachment->priv;
> > + int attrs = attachment->dma_map_attrs;
> >
> > a->mapped = false;
> > - dma_unmap_sgtable(attachment->dev, table, direction, 0);
> > + dma_unmap_sgtable(attachment->dev, table, direction, attrs);
> > }
> >
> > static int system_heap_dma_buf_begin_cpu_access(struct dma_buf
> > *dmabuf,
> > --
> > 2.17.1
> >
next prev parent reply other threads:[~2021-07-21 10:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 10:14 [PATCH] dma-heap: Let dma heap use dma_map_attrs to map & unmap iova guangming.cao
2021-07-15 6:24 ` guangming.cao
2021-07-21 9:43 ` guangming.cao [this message]
2021-08-10 2:02 ` [PATCH] dma_heap: enable map_attrs when (un)map_attachment guangming.cao
2021-08-10 9:26 ` kernel test robot
2021-08-10 9:56 ` kernel test robot
2021-08-10 9:56 ` kernel test robot
2021-08-26 6:42 ` [PATCH] dma-buf: Add support for mapping buffers with DMA attributes guangming.cao
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=20210721094314.117413-1-guangming.cao@mediatek.com \
--to=guangming.cao@mediatek.com \
--cc=Brian.Starkey@arm.com \
--cc=benjamin.gaignard@linaro.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=john.stultz@linaro.org \
--cc=labbott@redhat.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lmark@codeaurora.org \
--cc=matthias.bgg@gmail.com \
--cc=sumit.semwal@linaro.org \
--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).