From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Jyri Sarha <jsarha@ti.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/omap: fix tiled buffer stride calculations
Date: Thu, 18 May 2017 15:32:45 +0300 [thread overview]
Message-ID: <5891985.kG72mX4jGs@avalon> (raw)
In-Reply-To: <a534d2b3-72d8-a7a2-dc57-a956cd94d275@ti.com>
Hi Tomi,
On Thursday 18 May 2017 14:34:09 Tomi Valkeinen wrote:
> On 18/05/17 14:25, Laurent Pinchart wrote:
> > On Thursday 18 May 2017 14:14:35 Tomi Valkeinen wrote:
> >> On 18/05/17 13:59, Laurent Pinchart wrote:
> >>> On Thursday 18 May 2017 13:28:26 Tomi Valkeinen wrote:
> >>>> 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 fixes those calculations.
> >>>>
> >>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> >>>> ---
> >>>>
> >>>> 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 = PAGE_SIZE * n;
> >>>> loff_t off = mmap_offset(obj) +
> >>>> (entry->obj_pgoff << PAGE_SHIFT);
> >>>> - const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
> >>>> + const int m = 1 + (((omap_obj->width - 1) << fmt) /
> >>>> PAGE_SIZE);
> >>>
> >>> How about
> >>>
> >>> int m = round_up(omap_obj->width << fmt, PAGE_SIZE);
> >>>
> >>> 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;
> >
> > Sorry, I meant DIV_ROUND_UP, not round_up.
>
> Ah, of course. Not my day... =)
>
> From: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Date: Thu, 18 May 2017 11:51:51 +0300
> Subject: [PATCH] drm/omap: fix tiled buffer stride calculations
>
> 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 <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c
> b/drivers/gpu/drm/omapdrm/omap_gem.c index 13abf221d153..5c5c86ddd6f4
> 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 = PAGE_SIZE * n;
> loff_t off = mmap_offset(obj) +
> (entry->obj_pgoff << PAGE_SHIFT);
> - const int m = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
> + const int m = DIV_ROUND_UP(omap_obj->width << fmt, PAGE_SIZE);
>
> if (m > 1) {
> int i;
> @@ -424,7 +424,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 = 1 + ((omap_obj->width << fmt) / PAGE_SIZE);
> + const int m = DIV_ROUND_UP(omap_obj->width << fmt, PAGE_SIZE);
>
> /* We don't use vmf->pgoff since that has the fake offset: */
> pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
--
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-05-18 12:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 10:28 [PATCH] drm/omap: fix tiled buffer stride calculations Tomi Valkeinen
2017-05-18 10:59 ` Laurent Pinchart
2017-05-18 11:14 ` Tomi Valkeinen
2017-05-18 11:25 ` Laurent Pinchart
2017-05-18 11:34 ` Tomi Valkeinen
2017-05-18 12:32 ` Laurent Pinchart [this message]
2017-05-18 11:32 ` Ville Syrjälä
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=5891985.kG72mX4jGs@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jsarha@ti.com \
--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.