Skip to content

Commit

Permalink
drm/i915/selftests: Use mul_u32_u32() for 32b x 32b -> 64b result
Browse files Browse the repository at this point in the history
As realised by commit 9e3d622 ("math64, timers: Fix 32bit
mul_u64_u32_shr() and friends"), GCC does not always generate ideal code
for performing a 32b x 32b multiply returning a 64b result (i.e. where
we idiomatically use u64 result = (u64)x * (u32)x).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20170913105154.2910-2-chris@chris-wilson.co.uk
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
  • Loading branch information
Chris Wilson committed Sep 13, 2017
1 parent 3123698 commit 7ce5b68
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/selftests/i915_gem_timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int igt_sync(void *arg)

static unsigned int random_engine(struct rnd_state *rnd)
{
return ((u64)prandom_u32_state(rnd) * I915_NUM_ENGINES) >> 32;
return i915_prandom_u32_max_state(I915_NUM_ENGINES, rnd);
}

static int bench_sync(void *arg)
Expand Down
5 changes: 0 additions & 5 deletions drivers/gpu/drm/i915/selftests/i915_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ u64 i915_prandom_u64_state(struct rnd_state *rnd)
return x;
}

static inline u32 i915_prandom_u32_max_state(u32 ep_ro, struct rnd_state *state)
{
return upper_32_bits((u64)prandom_u32_state(state) * ep_ro);
}

void i915_random_reorder(unsigned int *order, unsigned int count,
struct rnd_state *state)
{
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/selftests/i915_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@

u64 i915_prandom_u64_state(struct rnd_state *rnd);

static inline u32 i915_prandom_u32_max_state(u32 ep_ro, struct rnd_state *state)
{
return upper_32_bits(mul_u32_u32(prandom_u32_state(state), ep_ro));
}

unsigned int *i915_random_order(unsigned int count,
struct rnd_state *state);
void i915_random_reorder(unsigned int *order,
Expand Down

0 comments on commit 7ce5b68

Please sign in to comment.