From: "Ørjan Eide" <orjan.eide@arm.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: devel@driverdev.osuosl.org, nd@arm.com,
"Todd Kjos" <tkjos@android.com>,
"Lecopzer Chen" <lecopzer.chen@mediatek.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org,
"Arve Hjønnevåg" <arve@android.com>,
john.stultz@linaro.org, anders.pedersen@arm.com,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Darren Hart (VMware)" <dvhart@infradead.org>,
"Laura Abbott" <labbott@redhat.com>,
"Martijn Coenen" <maco@android.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian Brauner" <christian@brauner.io>,
linux-media@vger.kernel.org
Subject: Re: [PATCH] staging: android: ion: Skip sync if not mapped
Date: Thu, 16 Apr 2020 18:25:54 +0200 [thread overview]
Message-ID: <20200416162554.GA34684@e123356-lin.trondheim.arm.com> (raw)
In-Reply-To: <20200416094955.GM1163@kadam>
On Thu, Apr 16, 2020 at 12:49:56PM +0300, Dan Carpenter wrote:
> On Tue, Apr 14, 2020 at 04:18:47PM +0200, Ørjan Eide wrote:
> > @@ -238,6 +242,10 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
> > struct sg_table *table,
> > enum dma_data_direction direction)
> > {
> > + struct ion_dma_buf_attachment *a = attachment->priv;
> > +
> > + a->mapped = false;
>
> Possibly a stupid question but here we're not holding a lock. Is
> concurrency an issue?
Thanks for taking a look.
Here and in ion_map_dma_buf(), where mapped is set, this should be safe.
The callers must synchronize calls to map/unmap, and ensure that they
are called in pairs.
I think there may be a potential issue between where mapped is set here,
and where it's read in ion_dma_buf_{begin,end}_cpu_access(). Coherency
issues the mapped bool won't blow up, at worst the contents of the
buffer may be invalid as cache synchronization may have been skipped.
This is still an improvement as before it would either crash or sync the
wrong page repeatedly.
The mapped state is tied to the dma_map_sg() call, so we would need take
the buffer->lock around both dma_map_sg and setting mapped to be sure
that the buffer will always have been synced.
> > +
> > dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction);
> > }
> >
> > @@ -297,6 +305,8 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
> >
> > mutex_lock(&buffer->lock);
> > list_for_each_entry(a, &buffer->attachments, list) {
> > + if (!a->mapped)
> > + continue;
> > dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents,
> > direction);
> > }
--
Ørjan
next prev parent reply other threads:[~2020-04-16 16:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 13:46 Ørjan Eide
2020-04-14 14:04 ` Greg Kroah-Hartman
2020-04-14 14:18 ` Ørjan Eide
2020-04-14 14:28 ` Greg Kroah-Hartman
2020-04-14 16:11 ` Ørjan Eide
2020-04-15 5:16 ` John Stultz
2020-04-15 4:41 ` John Stultz
2020-04-16 10:25 ` Greg Kroah-Hartman
2020-04-17 15:00 ` Daniel Vetter
2020-04-20 7:53 ` Christoph Hellwig
2020-04-20 8:22 ` Christian Brauner
2020-04-20 20:03 ` John Stultz
2020-04-21 8:05 ` Greg Kroah-Hartman
2020-07-03 7:04 ` Greg Kroah-Hartman
2020-07-08 3:43 ` John Stultz
2020-07-10 11:47 ` Greg Kroah-Hartman
2020-04-16 9:49 ` Dan Carpenter
2020-04-16 16:25 ` Ørjan Eide [this message]
2020-04-16 17:36 ` Dan Carpenter
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=20200416162554.GA34684@e123356-lin.trondheim.arm.com \
--to=orjan.eide@arm.com \
--cc=anders.pedersen@arm.com \
--cc=arnd@arndb.de \
--cc=arve@android.com \
--cc=christian@brauner.io \
--cc=dan.carpenter@oracle.com \
--cc=daniel.vetter@ffwll.ch \
--cc=devel@driverdev.osuosl.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=dvhart@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=john.stultz@linaro.org \
--cc=labbott@redhat.com \
--cc=lecopzer.chen@mediatek.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maco@android.com \
--cc=nd@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®