From: Tomi Valkeinen Subject: Re: [PATCH] drm/omap: fix tiled buffer stride calculations Date: Thu, 18 May 2017 14:14:35 +0300 Message-ID: <7c0b4d6f-c5f8-718a-36c3-7aea832cccf2@ti.com> References: <1495103306-7041-1-git-send-email-tomi.valkeinen@ti.com> <1779275.QoS2HsWmdB@avalon> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0862973132==" Return-path: Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFE2889B27 for ; Thu, 18 May 2017 11:14:40 +0000 (UTC) In-Reply-To: <1779275.QoS2HsWmdB@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: Jyri Sarha , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0862973132== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ce96T0GW0E5j6mePWxmxLqUTtUjdApasg" --ce96T0GW0E5j6mePWxmxLqUTtUjdApasg Content-Type: multipart/mixed; boundary="v9xnN67EtuKHjdmCJMps3XUnif06SNeEN"; protected-headers="v1" From: Tomi Valkeinen To: Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, Jyri Sarha Message-ID: <7c0b4d6f-c5f8-718a-36c3-7aea832cccf2@ti.com> Subject: Re: [PATCH] drm/omap: fix tiled buffer stride calculations References: <1495103306-7041-1-git-send-email-tomi.valkeinen@ti.com> <1779275.QoS2HsWmdB@avalon> In-Reply-To: <1779275.QoS2HsWmdB@avalon> --v9xnN67EtuKHjdmCJMps3XUnif06SNeEN Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 18/05/17 13:59, Laurent Pinchart wrote: > Hi Tomi, >=20 > Thank you for the patch. >=20 > On Thursday 18 May 2017 13:28:26 Tomi Valkeinen wrote: >> omap_gem uses page alignment for buffer stride. The related calculatio= ns >> are a bit off, though, as byte stride of 4096 gets aligned to 8192, >> instead of 4096. This patch fixes those calculations. >> >> Signed-off-by: Tomi Valkeinen >> --- >> drivers/gpu/drm/omapdrm/omap_gem.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c >> b/drivers/gpu/drm/omapdrm/omap_gem.c index 13abf221d153..4c41000ff4c4 >> 100644 >> --- a/drivers/gpu/drm/omapdrm/omap_gem.c >> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c >> @@ -182,7 +182,7 @@ static void evict_entry(struct drm_gem_object *obj= , >> size_t size =3D PAGE_SIZE * n; >> loff_t off =3D mmap_offset(obj) + >> (entry->obj_pgoff << PAGE_SHIFT); >> - const int m =3D 1 + ((omap_obj->width << fmt) / PAGE_SIZE); >> + const int m =3D 1 + (((omap_obj->width - 1) << fmt) / PAGE_SIZE); >=20 > How about=20 >=20 > int m =3D round_up(omap_obj->width << fmt, PAGE_SIZE); >=20 > instead of open-coding it ? I find that a bit easier to understand. That should be: round_up(omap_obj->width << fmt, PAGE_SIZE) / PAGE_SIZE; Yes, I think that's more understandable. > By the way, shifting left by fmt should be fine for TILFMT_8BIT, TILFMT= _16BIT=20 > and TILFMT_32BIT that evaluate to 0, 1 and 2 respectively, but how does= it=20 > work with TILFMT_PAGE ? fmt is computed by gem2fmt() in call cases, whi= ch=20 > returns TILFMT_PAGE in the default case (no tiled flag set). Can this h= appen=20 > in practice ? These functions are only called for 2D buffers. I do find shifting by 'enum tiler_fmt' quite ugly, though... Tomi --v9xnN67EtuKHjdmCJMps3XUnif06SNeEN-- --ce96T0GW0E5j6mePWxmxLqUTtUjdApasg 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 iQIcBAEBCAAGBQJZHYIbAAoJEPo9qoy8lh71Bo8P/jQBaCVJz9ohNaKxOReCVJrL 3NnIZbL5Mi5mrTEM5YJEiwwfV+uZ/Ex+2QHMBaD5bBIyZgL1v/EkA2D5F3fZFCy8 hc69EuvytTWhLllSgAIF1bbCgWuuV/PsYx/peaQ95/4/Mzp0uAiJcy+16j5rpA2H rzsDWqQelXdJxhJ0ISkjMahq23G66GlYCIEcgcmIANbP9xgeBeUhl1PTXTM90lk3 gF1QQuHTBHCnmG3wMgtQaGSZzizih7vOEKqpb1E3/jgVpPs3RAKVhSVi1OUFoRa4 fnU5wjhUv2Q7tBhnnntYsRytdMzAOcLpsCE0vnNGyUILsbtN0UZulZuC9IRFxvjQ o4/yDkXTqT2fa2Ol52Bjdz0uJqL1tyIx8YuMmkxeauBVCJxTqizOSHzJcRgDva2S M3HcXnqJTwMkk+Yq9g0ekMXTvuOkFLbqy3GjhEdeAu9YNKi5PZF5D25qIqk7zvKp DPiE4qYBGr7IyZfJziW2MLbrlemecbGi21Z0Ec5bGxAwKqYPoZJ6r1pHgHU/A20+ 1fOtEJkKA0E+WxKPyr4C32UDcxvNWLEwxN7cwZVljEQ/lzQAhdIpm764URwfB/1v dxWkXHV21XeI8VdMxhKyYMOpKvxOxGhaj7Ht6XZLknhzkbMMiDaKcAD5s5TAPcHP RJh0kqVcP78pk/di1o8i =j2D8 -----END PGP SIGNATURE----- --ce96T0GW0E5j6mePWxmxLqUTtUjdApasg-- --===============0862973132== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0862973132==--