Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1234489 > unrolled thread
| Started by | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| First post | 2015-09-28 23:20 +0200 |
| Last post | 2015-09-29 09:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] drm/i915: Fix comparison bug Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-28 23:20 +0200
Re: [PATCH] drm/i915: Fix comparison bug Jani Nikula <jani.nikula@linux.intel.com> - 2015-09-29 09:40 +0200
Re: [Intel-gfx] [PATCH] drm/i915: Fix comparison bug Daniel Vetter <daniel@ffwll.ch> - 2015-09-29 09:50 +0200
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-09-28 23:20 +0200 |
| Subject | [PATCH] drm/i915: Fix comparison bug |
| Message-ID | <qdO05-2Tc-61@gated-at.bofh.it> |
->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>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Jani Nikula <jani.nikula@linux.intel.com> |
|---|---|
| Date | 2015-09-29 09:40 +0200 |
| Message-ID | <qdXG1-8il-5@gated-at.bofh.it> |
| In reply to | #1234489 |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2015-09-29 09:50 +0200 |
| Subject | Re: [Intel-gfx] [PATCH] drm/i915: Fix comparison bug |
| Message-ID | <qdXPJ-8tJ-21@gated-at.bofh.it> |
| In reply to | #1234777 |
On Tue, Sep 29, 2015 at 10:37:30AM +0300, Jani Nikula wrote:
> 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>
drm_mm is the shared gpu memmory manager, but stolen itself can only go to
about 1.5G currently. So safe, but I merged your patch anyway with a small
note added for 4.4.
Thanks, Daniel
>
>
> > ---
> > 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
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web