From: Laura Abbott <labbott@redhat.com>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Beata Michalska <Beata.Michalska@arm.com>,
Matt Szczesiak <matt.szczesiak@arm.com>,
Anders Pedersen <Anders.Pedersen@arm.com>,
John Reitan <John.Reitan@arm.com>,
Liam Mark <lmark@codeaurora.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Todd Kjos <tkjos@android.com>, Martijn Coenen <maco@android.com>,
dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] staging: ion: Rework ion_map_dma_buf() to minimize re-mapping
Date: Sun, 21 Oct 2018 02:13:39 -0700 [thread overview]
Message-ID: <e936704c-9bb5-8da8-3d30-e7c9a12a3b07@redhat.com> (raw)
In-Reply-To: <CALAqxLUd-L+dj=GD5F=PkP5o-FokMCeYHWRJZs24R9-Grbf=PA@mail.gmail.com>
On 10/17/2018 07:53 PM, John Stultz wrote:
> On Fri, Oct 12, 2018 at 10:51 AM, Laura Abbott <labbott@redhat.com> wrote:
>>
>> I suspect most of the cost of the dma_map/dma_unmap is from the
>> cache flushing and not the actual mapping operations. If this
>> is the case, another option might be to figure out how to
>> incorporate dma_attrs so drivers can use DMA_ATTR_SKIP_CPU_SYNC
>> to decide when they actually want to sync.
>
> So just to confirm on this point, I basically tested the following
> change (whitespace corrupt, sorry):
>
> diff --git a/drivers/staging/android/ion/ion.c
> b/drivers/staging/android/ion/ion.c
> index 24cb666..e76b0e2 100644
> --- a/drivers/staging/android/ion/ion.c
> +++ b/drivers/staging/android/ion/ion.c
> @@ -273,8 +273,8 @@ static struct sg_table *ion_map_dma_buf(struct
> dma_buf_attachment *attachment,
>
> table = a->table;
>
> - if (!dma_map_sg(attachment->dev, table->sgl, table->nents,
> - direction))
> + if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents,
> + direction, DMA_ATTR_SKIP_CPU_SYNC))
> return ERR_PTR(-ENOMEM);
>
> return table;
> @@ -284,7 +284,7 @@ static void ion_unmap_dma_buf(struct
> dma_buf_attachment *attachment,
> struct sg_table *table,
> enum dma_data_direction direction)
> {
> - dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
> + dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents,
> direction, DMA_ATTR_SKIP_CPU_SYNC);
> }
>
> static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
>
>
> And indeed, that performed similarly to the pre 4.12 ION code (and it
> also had some of the same image caching error garbage we've seen w/
> 4.9 era kernels, which my earlier patch didn't have).
>
> So yes, it seems having some way to conditionally skip cpu sync would
> be good. Though I'm not sure what sort of interface to using this you
> might have in mind?
>
I hadn't quite gotten anything fully formed but I think solving this
will require changes at the dma-buf layer. One idea I had was allowing
dma_attrs to be set per attachment, the other was extending the
dma_buf_map_attachment to take an attrs argument. I'm at OSSEU this
week but I didn't want to forget about this. I'll see if I can turn
this into a more coherent proposal unless you get to it first.
Thanks,
Laura
> thanks
> -john
>
prev parent reply other threads:[~2018-10-21 9:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 23:33 John Stultz
2018-10-12 17:51 ` Laura Abbott
2018-10-14 6:01 ` Liam Mark
2018-10-15 16:31 ` John Stultz
2018-10-15 16:29 ` John Stultz
2018-10-18 2:53 ` John Stultz
2018-10-21 9:13 ` Laura Abbott [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=e936704c-9bb5-8da8-3d30-e7c9a12a3b07@redhat.com \
--to=labbott@redhat.com \
--cc=Anders.Pedersen@arm.com \
--cc=Beata.Michalska@arm.com \
--cc=John.Reitan@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lmark@codeaurora.org \
--cc=maco@android.com \
--cc=matt.szczesiak@arm.com \
--cc=sumit.semwal@linaro.org \
--cc=tkjos@android.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
all inboxes | Powered by JetHome®