On pe, 2016-12-16 at 07:46 +0000, Chris Wilson wrote: > When testing, we want a random but yet reproducible order in which to > process elements. Here we create an array which is a random (using the > Tausworthe PRNG) permutation of the order in which to execute. > > v2: Tidier code by David Herrmann > > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> > Cc: David Herrmann <dh.herrmann@xxxxxxxxx> <SNIP> > @@ -0,0 +1,41 @@ > +#include <linux/bitops.h> > +#include <linux/kernel.h> > +#include <linux/random.h> > +#include <linux/slab.h> > +#include <linux/types.h> > + > +#include "drm_random.h" > + > +static inline u32 prandom_u32_max_state(u32 ep_ro, struct rnd_state *state) > +{ > + return upper_32_bits((u64)prandom_u32_state(state) * ep_ro); > +} > + To be submitted upstream. If you prefix the function here, there won't be a conflict when the upstream part gets merged. > +++ b/drivers/gpu/drm/lib/drm_random.h > @@ -0,0 +1,21 @@ > +#ifndef __DRM_RANDOM_H__ > +#define __DRM_RANDOM_H > + > +#include <linux/random.h> > + > +#define RND_STATE_INITIALIZER(seed__) ({ \ > + struct rnd_state state__; \ > + prandom_seed_state(&state__, (seed__)); \ > + state__; \ > +}) > + > +#define RND_STATE(name__, seed__) \ > + struct rnd_state name__ = RND_STATE_INITIALIZER(seed__) For upstream submission too. Same comment as above. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> Regards, Joonas -- Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx