From: Tomi Valkeinen Subject: Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Date: Mon, 24 Apr 2017 13:44:23 +0300 Message-ID: <41a6b645-188d-cc52-7eef-74be3e9af5d0@ti.com> References: <20170420213359.31300-1-laurent.pinchart@ideasonboard.com> <20170420213359.31300-8-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1897869860==" Return-path: Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B44B89D84 for ; Mon, 24 Apr 2017 10:44:28 +0000 (UTC) In-Reply-To: <20170420213359.31300-8-laurent.pinchart@ideasonboard.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Laurent Pinchart , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1897869860== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kxlf8kOu3WnxnAV5RLHsRoA6JFdDXcVr6" --kxlf8kOu3WnxnAV5RLHsRoA6JFdDXcVr6 Content-Type: multipart/mixed; boundary="K0XajGgd6xH3GKOmI2UIGaOdBhCCRn1XS"; protected-headers="v1" From: Tomi Valkeinen To: Laurent Pinchart , dri-devel@lists.freedesktop.org Message-ID: <41a6b645-188d-cc52-7eef-74be3e9af5d0@ti.com> Subject: Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' References: <20170420213359.31300-1-laurent.pinchart@ideasonboard.com> <20170420213359.31300-8-laurent.pinchart@ideasonboard.com> In-Reply-To: <20170420213359.31300-8-laurent.pinchart@ideasonboard.com> --K0XajGgd6xH3GKOmI2UIGaOdBhCCRn1XS Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 21/04/17 00:33, Laurent Pinchart wrote: > The is_cache_coherent() function currently returns true when the mappin= g > is not cache-coherent. This isn't a bug as such as the callers interpre= t > 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. >=20 > Signed-off-by: Laurent Pinchart > --- > Changes since v1: >=20 > - Fixed one mistakenly inverted cache coherency check > --- > drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++++++------- > 1 file changed, 15 insertions(+), 7 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapd= rm/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, uin= t32_t roll) > * Memory Management & DMA Sync > */ > =20 > -/** > - * shmem buffers that are mapped cached can simulate coherency via usi= ng > - * 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. Do we still end up mapping it to the userspace as cached? I think having two different caching types for the same memory is illegal. > + * > + * We keep track of dirty pages using page faulting to perform cache m= anagement. > + * 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 =3D to_omap_bo(obj); > =20 > - return (omap_obj->flags & OMAP_BO_MEM_SHMEM) && > - ((omap_obj->flags & OMAP_BO_CACHE_MASK) =3D=3D OMAP_BO_CACHED); > + return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) && > + ((omap_obj->flags & OMAP_BO_CACHE_MASK) =3D=3D 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". Tomi --K0XajGgd6xH3GKOmI2UIGaOdBhCCRn1XS-- --kxlf8kOu3WnxnAV5RLHsRoA6JFdDXcVr6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJY/dcHAAoJEPo9qoy8lh71ExUP/RLgmXuNQKZ+77FCiKdSEjpa itkQkp5V82xatiniIbKbbaw5AqKntq278bCE3zU2o725BVlMZDaY01qo55thKRB/ FtnbXle3a26jP652fDxZnvpjqiW+QNtu28M2oWXEvFINV0fTQo9W7lys8V2n39wP hmfkTfTAr30Mh0Tqcf0/Ggfxh+fTU2H7XRDaIVryxMgR7Fzw1kiM1nOiYFlxjIAp 8Vr9psPeClG7L8Xc4hXS/Ysi7LTRqEZZRI0J4A5L7GCxYVoKdee09MCjM6/ooLO/ UM51WODObPCqz/jpIhRnhYknwBudwV+7m0L3qOU71iTQGBYbcBZD4zJAlj+bC+68 rzhqiKawBDWiOQ/fHpCnuYHpi0KnET1UuiJm2y3tvRj525twSTGDGYgw96fwWdcQ a/rCrldR1E2QQiaNSBCag0TfKY7yFsmduSCXNazGA61hdx8rqrmZEFRgtnVACGnP Ef++nSlaN7nfrWINJk5j7gHh0nIpQ1GNEbOv8Gd8WVjhUHBYdQfucmQ7nJ9i4EAa pHRwE0cMSBiUo9W16+6F0wW1mgKwDQV6JYpCDbJbj/9BJ278pR9HzxVOQLoN75A3 QpAHgjqOJGAOGATomL9wNNIK0mwLXNvQyPGRhpXX31CL5OKhTpKQesuz8r0X/57S Kq1/ZKwYxazvKEPST4PB =FZ72 -----END PGP SIGNATURE----- --kxlf8kOu3WnxnAV5RLHsRoA6JFdDXcVr6-- --===============1897869860== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1897869860==--