From: Tomi Valkeinen Subject: Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Date: Tue, 25 Apr 2017 12:07:54 +0300 Message-ID: <7b0bca46-9791-ed4d-a4fd-6debd1ff9a60@ti.com> References: <20170420213359.31300-1-laurent.pinchart@ideasonboard.com> <20170420213359.31300-8-laurent.pinchart@ideasonboard.com> <41a6b645-188d-cc52-7eef-74be3e9af5d0@ti.com> <1993250.7E4Rs9FdGP@avalon> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1619151215==" Return-path: Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 633806E2F7 for ; Tue, 25 Apr 2017 09:08:24 +0000 (UTC) In-Reply-To: <1993250.7E4Rs9FdGP@avalon> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Laurent Pinchart Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1619151215== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TX6oEDxjpopam5NpOc1aWVDGBU8pBIEov" --TX6oEDxjpopam5NpOc1aWVDGBU8pBIEov Content-Type: multipart/mixed; boundary="15RqsjCMpmlrwBg9pGr2dWdvSD8d1EQwv"; protected-headers="v1" From: Tomi Valkeinen To: Laurent Pinchart Cc: dri-devel@lists.freedesktop.org Message-ID: <7b0bca46-9791-ed4d-a4fd-6debd1ff9a60@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> <41a6b645-188d-cc52-7eef-74be3e9af5d0@ti.com> <1993250.7E4Rs9FdGP@avalon> In-Reply-To: <1993250.7E4Rs9FdGP@avalon> --15RqsjCMpmlrwBg9pGr2dWdvSD8d1EQwv Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 24/04/17 17:25, Laurent Pinchart wrote: > Hi Tomi, >=20 > 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 mapp= ing >>> is not cache-coherent. This isn't a bug as such as the callers interp= ret >>> 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 >>> --- >>> 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)>=20 >>> * Memory Management & DMA Sync >>> */ >>> >>> -/** >>> - * shmem buffers that are mapped cached can simulate coherency via u= sing >>> - * 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. >=20 > Only for OMAP_BO_SCANOUT buffers. Other buffers will still be allocated= =20 > through shmem. Right... I hope nobody allocates those. omapdrm should be used for dss buffers, which means scanout... >> Do we still end up mapping it to the userspace as cached? >=20 > Well, in that case, we actually end up not mapping it at all if the use= r=20 > requests cached mapping :-) omap_gem_mmap_obj() will return with a WARN= _ON()=20 > and omap_gem_pin() (which used to be omap_gem_get_paddr()) will return = - > EINVAL. >=20 > I believe we should disallow non-contiguous buffers without a DMM at=20 > allocation time. As for cached mapping of contiguous buffers, the dirty= page=20 > tracking implementation requires shmem at the moment. This could be fix= ed, but=20 > isn't trivial. Do you see value in doing so, or should cached mappings = of=20 > contiguous buffers be disallowed for the time being ? I think the answer depends on whether cached buffers are usable (performance-wise). If not, we should drop cached buffer support totally. If yes, then we should support them for contiguous buffers too. >>> static inline bool is_cached_coherent(struct drm_gem_object *obj) >>> { >>> struct omap_gem_object *omap_obj =3D to_omap_bo(obj); >>> >>> - 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 thi= s >> function sounds more like "is_shmem_cached_coherent". >=20 > You're right. I propose fixing that in an additional patch to avoid pot= ential=20 > changes to the behaviour in this one. Sounds good. Tomi --15RqsjCMpmlrwBg9pGr2dWdvSD8d1EQwv-- --TX6oEDxjpopam5NpOc1aWVDGBU8pBIEov 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/xHqAAoJEPo9qoy8lh71j8QP/2scfZXPN2hnV6O0cidHX4Fk EMnkipMwYaL8GUdFzRIRgd34J6dFigyx+c6Ch1Oe1ZJSIgQJCkALGBYuhVqba+3+ i/7RkVgTmrBLVxl48ddHr79++77htG8BwTxmoNLjveMvCTY+EMzRE/qeaEV6lZ6v ESLZv3pd1B4kaTNGGX15B7zQ3bLjK8ZnZW33HVGM99fG3auLqEzycNjKq2OJ5wbv pJ1ZrRLq3qTdT7IioLY7hTvII3isK8FxTKtDBPB+Lj9fIsls1KXKhj7BRrJYogRb H4WGdrbJbxSLqF4l/B2AAT/HikPsIVYB1YLp8PXF1t+6uBtZYcXfiYKuToIXS4wc fLwNGTJNlc6cd1ce3CmZBbQWlJLMXfKNkaqZhJhoB9XSy8t/dp61hbYj/Yie0f1A eGI0vaNB6BKcF1jC47lnczWlNmHOPfv4zaNaFq5ZMm4XLhCmmHhHfjC2tVqW3OZ7 eQtAbv4rI2DlMXEkrojGt/J491XqP4Y72NDXaqr/PDJNLSElQgtpSpQsB5F7/C/3 em4a5m7532O1kEOyQYbdPAipEdOk/n5TEXmBWJKFWy4BzxMFryeYeui6PwQfzEBY 1gpwUP314YQ78E17bzf00YdobnePD5izCP6qgvWOp0t2C9lyz3GsJyQ6N4LMeLGJ 4UUnGv+5SfhmMrpfSwZN =QnIG -----END PGP SIGNATURE----- --TX6oEDxjpopam5NpOc1aWVDGBU8pBIEov-- --===============1619151215== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1619151215==--