From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
Date: Mon, 24 Apr 2017 17:25:53 +0300 [thread overview]
Message-ID: <1993250.7E4Rs9FdGP@avalon> (raw)
In-Reply-To: <41a6b645-188d-cc52-7eef-74be3e9af5d0@ti.com>
Hi Tomi,
On Monday 24 Apr 2017 13:44:23 Tomi Valkeinen wrote:
> On 21/04/17 00:33, 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>
> > ---
> > Changes since v1:
> >
> > - Fixed one mistakenly inverted cache coherency check
> > ---
> >
> > 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 d6d38e569fff..43b60a146edf
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> > @@ -719,16 +719,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 use shmem only with TILER. Not all SoCs have TILER (and you can
> disable TILER on the SoCs that have it).
>
> As this patch is more or less a cleanup, I'm not sure if the above
> should be part of this patch. But it makes me wonder: if we don't use
> shmem, we use dma_alloc_writecombine.
Only for OMAP_BO_SCANOUT buffers. Other buffers will still be allocated
through shmem.
> Do we still end up mapping it to the userspace as cached?
Well, in that case, we actually end up not mapping it at all if the user
requests cached mapping :-) omap_gem_mmap_obj() will return with a WARN_ON()
and omap_gem_pin() (which used to be omap_gem_get_paddr()) will return -
EINVAL.
I believe we should disallow non-contiguous buffers without a DMM at
allocation time. As for cached mapping of contiguous buffers, the dirty page
tracking implementation requires shmem at the moment. This could be fixed, but
isn't trivial. Do you see value in doing so, or should cached mappings of
contiguous buffers be disallowed for the time being ?
> I think having two different caching types for the same memory is illegal.
It used to be documented as leading to unspecified behaviour in the ARM ARM,
but I think that has been changed. If I'm not mistaken it doesn't cause any
problem in practice, at least on the TI platforms I tested back when dealing
with cache on OMAP3 :-)
> > + *
> > + * 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));
>
> Regardless of whether we support non-shmem cached buffers, isn't the
> above overly complex? Why can't we just check for OMAP_BO_CACHED? Isn't
> that the only case where the buffer is not coherent? At the moment this
> function sounds more like "is_shmem_cached_coherent".
You're right. I propose fixing that in an additional patch to avoid potential
changes to the behaviour in this one.
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-04-24 14:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
2017-04-20 21:33 ` [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
2017-04-24 10:09 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
2017-04-24 10:13 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
2017-04-24 10:16 ` Tomi Valkeinen
2017-04-24 14:08 ` Laurent Pinchart
2017-04-20 21:33 ` [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
2017-04-24 10:22 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
2017-04-24 10:24 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions Laurent Pinchart
2017-04-24 10:32 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
2017-04-24 10:44 ` Tomi Valkeinen
2017-04-24 14:25 ` Laurent Pinchart [this message]
2017-04-25 9:07 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
2017-04-27 10:48 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction Laurent Pinchart
2017-04-27 10:48 ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf Laurent Pinchart
2017-04-20 23:08 ` Chris Wilson
2017-04-21 8:49 ` Laurent Pinchart
2017-05-08 18:59 ` [PATCH v2.1 10/10] drm: omapdrm: Take GEM object reference " Laurent Pinchart
2017-05-09 8:14 ` [PATCH v2 00/10] omapdrm: GEM objects fixes 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=1993250.7E4Rs9FdGP@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.