From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-cys01nam02on0094.outbound.protection.outlook.com ([104.47.37.94]:64207 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935246AbeCSQNe (ORCPT ); Mon, 19 Mar 2018 12:13:34 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Tomi Valkeinen , Sasha Levin Subject: [PATCH AUTOSEL for 3.18 066/102] drm/omap: fix tiled buffer stride calculations Date: Mon, 19 Mar 2018 16:12:51 +0000 Message-ID: <20180319161117.17833-66-alexander.levin@microsoft.com> References: <20180319161117.17833-1-alexander.levin@microsoft.com> In-Reply-To: <20180319161117.17833-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Tomi Valkeinen [ Upstream commit cc8dd7661ccc2d8dc88921da8e6cc7c2fcdb0341 ] omap_gem uses page alignment for buffer stride. The related calculations are a bit off, though, as byte stride of 4096 gets aligned to 8192, instead of 4096. This patch changes the code to use DIV_ROUND_UP(), which fixes those calculations and makes them more readable. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Signed-off-by: Sasha Levin --- 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/o= map_gem.c index e4849413ee80..4f745c11d955 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -158,7 +158,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 DIV_ROUND_UP(omap_obj->width << fmt, PAGE_SIZE); =20 if (m > 1) { int i; @@ -415,7 +415,7 @@ static int fault_2d(struct drm_gem_object *obj, * into account in some of the math, so figure out virtual stride * in pages */ - const int m =3D 1 + ((omap_obj->width << fmt) / PAGE_SIZE); + const int m =3D DIV_ROUND_UP(omap_obj->width << fmt, PAGE_SIZE); =20 /* We don't use vmf->pgoff since that has the fake offset: */ pgoff =3D ((unsigned long)vmf->virtual_address - --=20 2.14.1