[PATCH v2 1/3] drm/i915/selftests: use prandom in selftest

Markus Theil posted 3 patches 10 months, 1 week ago
[PATCH v2 1/3] drm/i915/selftests: use prandom in selftest
Posted by Markus Theil 10 months, 1 week ago
This is part of a prandom cleanup, which removes
next_pseudo_random32 and replaces it with the standard PRNG.

Signed-off-by: Markus Theil <theil.markus@gmail.com>
---
 drivers/gpu/drm/i915/selftests/i915_gem.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c b/drivers/gpu/drm/i915/selftests/i915_gem.c
index 0727492576be..14efa6edd9e6 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem.c
@@ -45,13 +45,15 @@ static void trash_stolen(struct drm_i915_private *i915)
 	struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
 	const u64 slot = ggtt->error_capture.start;
 	const resource_size_t size = resource_size(&i915->dsm.stolen);
+	struct rnd_state prng;
 	unsigned long page;
-	u32 prng = 0x12345678;
 
 	/* XXX: fsck. needs some more thought... */
 	if (!i915_ggtt_has_aperture(ggtt))
 		return;
 
+	prandom_seed_state(&prng, 0x12345678);
+
 	for (page = 0; page < size; page += PAGE_SIZE) {
 		const dma_addr_t dma = i915->dsm.stolen.start + page;
 		u32 __iomem *s;
@@ -64,8 +66,7 @@ static void trash_stolen(struct drm_i915_private *i915)
 
 		s = io_mapping_map_atomic_wc(&ggtt->iomap, slot);
 		for (x = 0; x < PAGE_SIZE / sizeof(u32); x++) {
-			prng = next_pseudo_random32(prng);
-			iowrite32(prng, &s[x]);
+			iowrite32(prandom_u32_state(&prng), &s[x]);
 		}
 		io_mapping_unmap_atomic(s);
 	}
-- 
2.47.2
Re: [PATCH v2 1/3] drm/i915/selftests: use prandom in selftest
Posted by Andi Shyti 10 months ago
Hi Markus,

On Tue, Feb 11, 2025 at 07:33:30AM +0100, Markus Theil wrote:
> This is part of a prandom cleanup, which removes
> next_pseudo_random32 and replaces it with the standard PRNG.
> 
> Signed-off-by: Markus Theil <theil.markus@gmail.com>

I merged just this patch in drm-intel-gt-next.

Thanks,
Andi
Re: [PATCH v2 1/3] drm/i915/selftests: use prandom in selftest
Posted by Jason A. Donenfeld 9 months ago
Hi Andi,

On Thu, Feb 13, 2025 at 06:19:12PM +0100, Andi Shyti wrote:
> Hi Markus,
> 
> On Tue, Feb 11, 2025 at 07:33:30AM +0100, Markus Theil wrote:
> > This is part of a prandom cleanup, which removes
> > next_pseudo_random32 and replaces it with the standard PRNG.
> > 
> > Signed-off-by: Markus Theil <theil.markus@gmail.com>
> 
> I merged just this patch in drm-intel-gt-next.

This is minorly annoying for me... What am I supposed to do with patches
2 and 3? Take them through my tree for 6.16 in like half a year? Can I
just take the v1 into my tree and we can get this done with straight
forwardly? Or do you have a different suggestion for me?

Jason
Re: [PATCH v2 1/3] drm/i915/selftests: use prandom in selftest
Posted by Jani Nikula 9 months ago
On Wed, 19 Mar 2025, "Jason A. Donenfeld" <Jason@zx2c4.com> wrote:
> Hi Andi,
>
> On Thu, Feb 13, 2025 at 06:19:12PM +0100, Andi Shyti wrote:
>> Hi Markus,
>> 
>> On Tue, Feb 11, 2025 at 07:33:30AM +0100, Markus Theil wrote:
>> > This is part of a prandom cleanup, which removes
>> > next_pseudo_random32 and replaces it with the standard PRNG.
>> > 
>> > Signed-off-by: Markus Theil <theil.markus@gmail.com>
>> 
>> I merged just this patch in drm-intel-gt-next.
>
> This is minorly annoying for me... What am I supposed to do with patches
> 2 and 3? Take them through my tree for 6.16 in like half a year? Can I
> just take the v1 into my tree and we can get this done with straight
> forwardly? Or do you have a different suggestion for me?

Feel free to apply it to your tree too. It's not ideal to have two
commits for the same thing, but oh well.

Acked-by: Jani Nikula <jani.nikula@intel.com>

-- 
Jani Nikula, Intel
Re: [PATCH v2 1/3] drm/i915/selftests: use prandom in selftest
Posted by Jason A. Donenfeld 9 months ago
On Fri, Mar 21, 2025 at 02:37:15PM +0200, Jani Nikula wrote:
> On Wed, 19 Mar 2025, "Jason A. Donenfeld" <Jason@zx2c4.com> wrote:
> > Hi Andi,
> >
> > On Thu, Feb 13, 2025 at 06:19:12PM +0100, Andi Shyti wrote:
> >> Hi Markus,
> >> 
> >> On Tue, Feb 11, 2025 at 07:33:30AM +0100, Markus Theil wrote:
> >> > This is part of a prandom cleanup, which removes
> >> > next_pseudo_random32 and replaces it with the standard PRNG.
> >> > 
> >> > Signed-off-by: Markus Theil <theil.markus@gmail.com>
> >> 
> >> I merged just this patch in drm-intel-gt-next.
> >
> > This is minorly annoying for me... What am I supposed to do with patches
> > 2 and 3? Take them through my tree for 6.16 in like half a year? Can I
> > just take the v1 into my tree and we can get this done with straight
> > forwardly? Or do you have a different suggestion for me?
> 
> Feel free to apply it to your tree too. It's not ideal to have two
> commits for the same thing, but oh well.
> 
> Acked-by: Jani Nikula <jani.nikula@intel.com>

Oh that's a good idea. Thanks!

Jason