From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniel Vetter <daniel.vetter@intel.com>, David Airlie <airlied@linux.ie>
Cc: intel-gfx@lists.freedesktop.org,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Fix comparison bug
Date: Tue, 29 Sep 2015 10:37:30 +0300 [thread overview]
Message-ID: <87vbatislh.fsf@intel.com> (raw)
In-Reply-To: <1443474531-11560-1-git-send-email-linux@rasmusvillemoes.dk>
On Tue, 29 Sep 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> ->stolen->start has type u64 aka unsigned long long; relying on the
> difference (effectively cast to int) for sorting is wrong.
>
> It wouldn't be a problem in practice if the values compared are always
> within INT_MAX of each other (so that the difference is actually
> representable in an int), but 440fd5283a87 ("drm/mm: Support 4 GiB and
> larger ranges") strongly suggests that's not the case.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index e3ec9049081f..5207e681a987 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -258,7 +258,11 @@ static int obj_rank_by_stolen(void *priv,
> struct drm_i915_gem_object *b =
> container_of(B, struct drm_i915_gem_object, obj_exec_link);
>
> - return a->stolen->start - b->stolen->start;
> + if (a->stolen->start < b->stolen->start)
> + return -1;
> + if (a->stolen->start > b->stolen->start)
> + return 1;
> + return 0;
> }
>
> static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
> --
> 2.1.3
>
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Daniel Vetter <daniel.vetter@intel.com>,
David Airlie <airlied@linux.ie>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/i915: Fix comparison bug
Date: Tue, 29 Sep 2015 10:37:30 +0300 [thread overview]
Message-ID: <87vbatislh.fsf@intel.com> (raw)
In-Reply-To: <1443474531-11560-1-git-send-email-linux@rasmusvillemoes.dk>
On Tue, 29 Sep 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> ->stolen->start has type u64 aka unsigned long long; relying on the
> difference (effectively cast to int) for sorting is wrong.
>
> It wouldn't be a problem in practice if the values compared are always
> within INT_MAX of each other (so that the difference is actually
> representable in an int), but 440fd5283a87 ("drm/mm: Support 4 GiB and
> larger ranges") strongly suggests that's not the case.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index e3ec9049081f..5207e681a987 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -258,7 +258,11 @@ static int obj_rank_by_stolen(void *priv,
> struct drm_i915_gem_object *b =
> container_of(B, struct drm_i915_gem_object, obj_exec_link);
>
> - return a->stolen->start - b->stolen->start;
> + if (a->stolen->start < b->stolen->start)
> + return -1;
> + if (a->stolen->start > b->stolen->start)
> + return 1;
> + return 0;
> }
>
> static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
> --
> 2.1.3
>
--
Jani Nikula, Intel Open Source Technology Center
next prev parent reply other threads:[~2015-09-29 7:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 21:08 [PATCH] drm/i915: Fix comparison bug Rasmus Villemoes
2015-09-29 7:37 ` Jani Nikula [this message]
2015-09-29 7:37 ` Jani Nikula
2015-09-29 7:43 ` Daniel Vetter
2015-09-29 7:43 ` [Intel-gfx] " Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2014-12-07 21:26 Rasmus Villemoes
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=87vbatislh.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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.