From: Daniel Vetter <daniel@ffwll.ch>
To: "Michel Dänzer" <michel@daenzer.net>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/mm: Fix search for smallest hole satisfying constraints
Date: Tue, 18 Mar 2014 11:01:30 +0100 [thread overview]
Message-ID: <20140318100130.GB30571@phenom.ffwll.local> (raw)
In-Reply-To: <1395104294-28066-1-git-send-email-michel@daenzer.net>
On Tue, Mar 18, 2014 at 09:58:14AM +0900, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> entry->size is the size of the node, not the size of the hole after it.
> So the code would actually find the hole which can satisfy the
> constraints and which is preceded by the smallest node, not the smallest
> hole satisfying the constraints.
>
> Reported-by: "Huang, FrankR" <FrankR.Huang@amd.com>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
But drm-next just gained my kerneldoc patch for drm_mm, so can you please
respin your patch and update the docs too? While at it ... could you
perhaps smash a bit of kerneldoc on top of enum drm_mm_search_flags, I
seem to have missed it. With that this is
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Thanks, Daniel
> ---
> drivers/gpu/drm/drm_mm.c | 33 +++++++++++++++++----------------
> 1 file changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index af93cc5..5d921e5 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -306,8 +306,8 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
> {
> struct drm_mm_node *entry;
> struct drm_mm_node *best;
> - unsigned long adj_start;
> - unsigned long adj_end;
> + unsigned long hole_start;
> + unsigned long hole_end;
> unsigned long best_size;
>
> BUG_ON(mm->scanned_blocks);
> @@ -315,7 +315,10 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
> best = NULL;
> best_size = ~0UL;
>
> - drm_mm_for_each_hole(entry, mm, adj_start, adj_end) {
> + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> + unsigned long adj_start = hole_start;
> + unsigned long adj_end = hole_end;
> +
> if (mm->color_adjust) {
> mm->color_adjust(entry, color, &adj_start, &adj_end);
> if (adj_end <= adj_start)
> @@ -328,9 +331,9 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
> if (!(flags & DRM_MM_SEARCH_BEST))
> return entry;
>
> - if (entry->size < best_size) {
> + if ((hole_end - hole_start) < best_size) {
> best = entry;
> - best_size = entry->size;
> + best_size = hole_end - hole_start;
> }
> }
>
> @@ -341,14 +344,14 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
> unsigned long size,
> unsigned alignment,
> unsigned long color,
> - unsigned long start,
> - unsigned long end,
> + unsigned long range_start,
> + unsigned long range_end,
> enum drm_mm_search_flags flags)
> {
> struct drm_mm_node *entry;
> struct drm_mm_node *best;
> - unsigned long adj_start;
> - unsigned long adj_end;
> + unsigned long hole_start;
> + unsigned long hole_end;
> unsigned long best_size;
>
> BUG_ON(mm->scanned_blocks);
> @@ -356,11 +359,9 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
> best = NULL;
> best_size = ~0UL;
>
> - drm_mm_for_each_hole(entry, mm, adj_start, adj_end) {
> - if (adj_start < start)
> - adj_start = start;
> - if (adj_end > end)
> - adj_end = end;
> + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> + unsigned long adj_start = max(hole_start, range_start);
> + unsigned long adj_end = min(hole_end, range_end);
>
> if (mm->color_adjust) {
> mm->color_adjust(entry, color, &adj_start, &adj_end);
> @@ -374,9 +375,9 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
> if (!(flags & DRM_MM_SEARCH_BEST))
> return entry;
>
> - if (entry->size < best_size) {
> + if ((hole_end - hole_start) < best_size) {
> best = entry;
> - best_size = entry->size;
> + best_size = hole_end - hole_start;
> }
> }
>
> --
> 1.9.0
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
next prev parent reply other threads:[~2014-03-18 10:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 0:58 [PATCH] drm/mm: Fix search for smallest hole satisfying constraints Michel Dänzer
2014-03-18 10:01 ` Daniel Vetter [this message]
2014-03-19 8:42 ` Michel Dänzer
2014-03-19 10:38 ` Daniel Vetter
2014-03-20 9:45 ` Michel Dänzer
2014-03-19 8:37 ` [PATCH v2] " Michel Dänzer
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=20140318100130.GB30571@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=michel@daenzer.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox