dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: Re: [PATCH 6/7] drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
Date: Sun, 16 Apr 2017 00:47:46 +0300	[thread overview]
Message-ID: <51482062.AphXs1uNS7@avalon> (raw)
In-Reply-To: <30599fed-8c7c-073e-fa5c-f0f644584b0a@ti.com>

Hi Tomi,

On Friday 10 Mar 2017 14:13:08 Tomi Valkeinen wrote:
> On 10/03/17 11:39, Laurent Pinchart wrote:
> > The is_cache_coherent() function currently returns true when the mapping
> > is not cache-coherent. This isn't a bug as such as the callers interpret
> > cache-coherent as meaning that the driver has to handle the coherency
> > manually, but it is nonetheless very confusing. Fix it and add a bit
> > more documentation to explain how cached buffers are handled.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++++++-------
> >  1 file changed, 15 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c
> > b/drivers/gpu/drm/omapdrm/omap_gem.c index 945bda8e330d..59594ec0d159
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> > @@ -732,16 +732,21 @@ int omap_gem_roll(struct drm_gem_object *obj,
> > uint32_t roll)> 
> >   * Memory Management & DMA Sync
> >   */
> > 
> > -/**
> > - * shmem buffers that are mapped cached can simulate coherency via using
> > - * page faulting to keep track of dirty pages
> > +/*
> > + * shmem buffers that are mapped cached are not coherent.
> > + *
> > + * We keep track of dirty pages using page faulting to perform cache
> > management. + * When a page is mapped to the CPU in read/write mode the
> > device can't access + * it and omap_obj->dma_addrs[i] is NULL. When a
> > page is mapped to the device + * the omap_obj->dma_addrs[i] is set to the
> > DMA address, and the page is + * unmapped from the CPU.
> > 
> >   */
> >  
> >  static inline bool is_cached_coherent(struct drm_gem_object *obj)
> >  {
> >  
> >  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> > 
> > -	return (omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
> > -		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
> > +	return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
> > +		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED));
> > 
> >  }
> >  
> >  /* Sync the buffer for CPU access.. note pages should already be
> > 
> > @@ -752,7 +757,10 @@ void omap_gem_cpu_sync(struct drm_gem_object *obj,
> > int pgoff)> 
> >  	struct drm_device *dev = obj->dev;
> >  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> > 
> > -	if (is_cached_coherent(obj) && omap_obj->dma_addrs[pgoff]) {
> > +	if (!is_cached_coherent(obj))
> > +		return;
> 
> I think the ! is extra there. If the obj _is_ coherent, we can just return.

You're right, my bad. I'll fix that in v2.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-04-15 21:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10  9:39 [PATCH 0/7] omapdrm: Fix GEM objects DMA unmapping Laurent Pinchart
2017-03-10  9:39 ` [PATCH 1/7] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
2017-03-10  9:39 ` [PATCH 2/7] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
2017-03-10  9:39 ` [PATCH 3/7] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
2017-03-10  9:39 ` [PATCH 4/7] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
2017-03-10  9:39 ` [PATCH 5/7] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
2017-03-10  9:39 ` [PATCH 6/7] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
2017-03-10 12:13   ` Tomi Valkeinen
2017-04-15 21:47     ` Laurent Pinchart [this message]
2017-03-10  9:39 ` [PATCH 7/7] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
2017-03-15 11:17 ` [PATCH 0/7] omapdrm: Fix GEM objects DMA unmapping Tomi Valkeinen

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=51482062.AphXs1uNS7@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.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