* [PATCH] drm/i915/selftests: Fix compare functions provided for sorting
@ 2020-07-09 15:49 Sudeep Holla
2020-07-09 17:02 ` [Intel-gfx] " Chris Wilson
0 siblings, 1 reply; 2+ messages in thread
From: Sudeep Holla @ 2020-07-09 15:49 UTC (permalink / raw)
To: intel-gfx, dri-devel
Cc: Sudeep Holla, Andi Shyti, David Airlie, Mika Kuoppala,
Chris Wilson, Rodrigo Vivi
Both cmp_u32 and cmp_u64 are comparing the pointers instead of the value
at those pointers. This will result in incorrect/unsorted list. Fix it
by deferencing the pointers before comparison.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/gpu/drm/i915/gt/selftest_rps.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Hi,
I am not sure if I can put 2 fixes tags, but these are the ones affected.
Fixes: 4ba74e53ada3 ("drm/i915/selftests: Verify frequency scaling with RPS")
Fixes: 8757797ff9c9 ("drm/i915/selftests: Repeat the rps clock frequency measurement")
I made similar mistake and after I fixed it, just looked if there are any
similar bugs and found this.
Regards,
Sudeep
diff --git a/drivers/gpu/drm/i915/gt/selftest_rps.c b/drivers/gpu/drm/i915/gt/selftest_rps.c
index 5049c3dd08a6..c91981e75ebf 100644
--- a/drivers/gpu/drm/i915/gt/selftest_rps.c
+++ b/drivers/gpu/drm/i915/gt/selftest_rps.c
@@ -44,9 +44,9 @@ static int cmp_u64(const void *A, const void *B)
{
const u64 *a = A, *b = B;
- if (a < b)
+ if (*a < *b)
return -1;
- else if (a > b)
+ else if (*a > *b)
return 1;
else
return 0;
@@ -56,9 +56,9 @@ static int cmp_u32(const void *A, const void *B)
{
const u32 *a = A, *b = B;
- if (a < b)
+ if (*a < *b)
return -1;
- else if (a > b)
+ else if (*a > *b)
return 1;
else
return 0;
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915/selftests: Fix compare functions provided for sorting
2020-07-09 15:49 [PATCH] drm/i915/selftests: Fix compare functions provided for sorting Sudeep Holla
@ 2020-07-09 17:02 ` Chris Wilson
0 siblings, 0 replies; 2+ messages in thread
From: Chris Wilson @ 2020-07-09 17:02 UTC (permalink / raw)
To: Sudeep Holla, dri-devel, intel-gfx; +Cc: David Airlie, Sudeep Holla
Quoting Sudeep Holla (2020-07-09 16:49:31)
> Both cmp_u32 and cmp_u64 are comparing the pointers instead of the value
> at those pointers. This will result in incorrect/unsorted list. Fix it
> by deferencing the pointers before comparison.
>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/gpu/drm/i915/gt/selftest_rps.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> Hi,
>
> I am not sure if I can put 2 fixes tags, but these are the ones affected.
>
> Fixes: 4ba74e53ada3 ("drm/i915/selftests: Verify frequency scaling with RPS")
> Fixes: 8757797ff9c9 ("drm/i915/selftests: Repeat the rps clock frequency measurement")
Might as well tag the fixes, just in case anyone wants to use the tests.
> I made similar mistake and after I fixed it, just looked if there are any
> similar bugs and found this.
>
> Regards,
> Sudeep
>
> diff --git a/drivers/gpu/drm/i915/gt/selftest_rps.c b/drivers/gpu/drm/i915/gt/selftest_rps.c
> index 5049c3dd08a6..c91981e75ebf 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_rps.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_rps.c
> @@ -44,9 +44,9 @@ static int cmp_u64(const void *A, const void *B)
> {
> const u64 *a = A, *b = B;
>
> - if (a < b)
> + if (*a < *b)
> return -1;
> - else if (a > b)
> + else if (*a > *b)
> return 1;
Oh my golly gosh.
Thanks, thanks and thrice thanks.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
I better double check all my qsort-compare funcs for similar brianfarts.
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-10 7:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 15:49 [PATCH] drm/i915/selftests: Fix compare functions provided for sorting Sudeep Holla
2020-07-09 17:02 ` [Intel-gfx] " Chris Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).