Skip to contentSkip to conversation

drm/tests: Fix endian warning

PATCH Applied José Expósito 3 participants 10 messages Jun 30, 2025 – Aug 11, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/tests: Fix endian warning

When compiling with sparse enabled, this warning is thrown:

warning: incorrect type in argument 2 (different base types)
expected restricted __le32 const [usertype] *buf got unsigned int [usertype] *[assigned] buf

Add a cast to fix it.

Fixes 453114319699 ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010()")
---
 drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -1
index 7299fa8971ce..86829e1cb7f0 100644
@@ -1033,7 +1033,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
 		NULL : &result->dst_pitch;
 
 	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
-	buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32));
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
 	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 
 	buf = dst.vaddr; /* restore original value of buf */
Signature · 1 line
2.50.0
#1 lore raw

PATCH 2/2 drm/tests: Fix drm_test_fb_xrgb8888_to_xrgb2101010() on big-endian

Fix failures on big-endian architectures on tests cases single_pixel_source_buffer, single_pixel_clip_rectangle, well_known_colors and destination_pitch.

Fixes 15bda1f8de5d ("drm/tests: Add calls to drm_fb_blit() on supported format conversion tests")
---
 drivers/gpu/drm/tests/drm_format_helper_test.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -0
index 86829e1cb7f0..981dada8f3a8 100644
@@ -1040,6 +1040,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
 	memset(buf, 0, dst_size);
 
 	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
 	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 }
 
Signature · 1 line
2.50.0
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/tests: Fix drm_test_fb_xrgb8888_to_xrgb2101010() on big-endian

Am 30.06.25 um 11:00 schrieb José Expósito:

Quoted 6 lines

Fix failures on big-endian architectures on tests cases single_pixel_source_buffer, single_pixel_clip_rectangle, well_known_colors and destination_pitch.

Fixes 15bda1f8de5d ("drm/tests: Add calls to drm_fb_blit() on supported format conversion tests")
Quoted 16 lines
---
  drivers/gpu/drm/tests/drm_format_helper_test.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -0
index 86829e1cb7f0..981dada8f3a8 100644
@@ -1040,6 +1040,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
  	memset(buf, 0, dst_size);
 
  	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
  	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
  }
 
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#3 lore raw

Re: [PATCH 2/2] drm/tests: Fix drm_test_fb_xrgb8888_to_xrgb2101010() on big-endian

Hi Thomas,

Quoted 11 lines · Thomas Zimmermann

Am 30.06.25 um 11:00 schrieb José Expósito:

Quoted 6 lines

Fix failures on big-endian architectures on tests cases single_pixel_source_buffer, single_pixel_clip_rectangle, well_known_colors and destination_pitch.

Fixes 15bda1f8de5d ("drm/tests: Add calls to drm_fb_blit() on supported format conversion tests")

Just a friendly reminder about this patches. Can I merge them? They have been in the ML for a while and it doesn't look like there are concerns.

Best wishes,
Jose

Quoted 24 lines
Quoted 14 lines
---
  drivers/gpu/drm/tests/drm_format_helper_test.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -0
index 86829e1cb7f0..981dada8f3a8 100644
@@ -1040,6 +1040,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
  	memset(buf, 0, dst_size);
  	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
  	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
  }
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
maintainer Applied
#4 lore raw

Re: [PATCH 2/2] drm/tests: Fix drm_test_fb_xrgb8888_to_xrgb2101010() on big-endian

Hi

Am 11.08.25 um 12:24 schrieb José Expósito:

Quoted 9 lines

Hi Thomas,

Quoted 6 lines · Thomas Zimmermann

Am 30.06.25 um 11:00 schrieb José Expósito:

Quoted 4 lines

Fix failures on big-endian architectures on tests cases single_pixel_source_buffer, single_pixel_clip_rectangle, well_known_colors and destination_pitch.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Fixes 15bda1f8de5d ("drm/tests: Add calls to drm_fb_blit() on supported format conversion tests")

Just a friendly reminder about this patches. Can I merge them? They have been in the ML for a while and it doesn't look like there are concerns.

Merged into drm-misc-fixes now. Sorry for the delay.

Best regards
Thomas

Quoted 27 lines

Best wishes,
Jose

Quoted 23 lines
Quoted 14 lines
---
   drivers/gpu/drm/tests/drm_format_helper_test.c | 1 +
   1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -0
index 86829e1cb7f0..981dada8f3a8 100644
@@ -1040,6 +1040,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
   	memset(buf, 0, dst_size);
   	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
   	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
   }
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
maintainer Reviewed-by on v1 1/2
#5 lore raw
In reply to José Expósito

Am 30.06.25 um 11:00 schrieb José Expósito:

Quoted 10 lines

When compiling with sparse enabled, this warning is thrown:

warning: incorrect type in argument 2 (different base types)
expected restricted __le32 const [usertype] *buf got unsigned int [usertype] *[assigned] buf

Add a cast to fix it.

Fixes 453114319699 ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010()")
Quoted 17 lines
---
  drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -1
index 7299fa8971ce..86829e1cb7f0 100644
@@ -1033,7 +1033,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
  		NULL : &result->dst_pitch;
 
  	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
-	buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32));
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
  	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 
  	buf = dst.vaddr; /* restore original value of buf */
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#6 lore raw
In reply to José Expósito
Quoted 19 lines · José Expósito

When compiling with sparse enabled, this warning is thrown:

warning: incorrect type in argument 2 (different base types)
expected restricted __le32 const [usertype] *buf got unsigned int [usertype] *[assigned] buf

Add a cast to fix it.

Fixes 453114319699 ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010()")
---
 drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +0 -0
index 7299fa8971ce..86829e1cb7f0 100644

drivers/gpu/drm/tests/drm_format_helper_test.c static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) · line 1039

Quoted 8 lines
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -1
@@ -1033,7 +1033,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
 		NULL : &result->dst_pitch;
 
 	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
-	buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32));
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
 	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 
 	buf = dst.vaddr; /* restore original value of buf */

It might be cleaner to use two separate variables instead of using "buf" as both little endian and host byte order. (Same for patch 2)

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#7 lore raw

Hey Michel,

Thanks for looking into this.

Quoted 22 lines · Michel Dänzer
Quoted 21 lines · José Expósito

When compiling with sparse enabled, this warning is thrown:

warning: incorrect type in argument 2 (different base types)
expected restricted __le32 const [usertype] *buf got unsigned int [usertype] *[assigned] buf

Add a cast to fix it.

Fixes 453114319699 ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010()")
---
 drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +0 -0
index 7299fa8971ce..86829e1cb7f0 100644
@@ -1033,7 +1033,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
 		NULL : &result->dst_pitch;
 
Quoted 8 lines

drivers/gpu/drm/tests/drm_format_helper_test.c static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) · line 1039

Quoted 6 lines
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -1
 	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
-	buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32));
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
 	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 
 	buf = dst.vaddr; /* restore original value of buf */

It might be cleaner to use two separate variables instead of using "buf" as both little endian and host byte order. (Same for patch 2)

Yes, however, the same pattern is repeated 10 times in this file.

What do you think about fixing it in a follow up? I don't think it should block fixing the KUnit tests.

Jose

Quoted 4 lines
Signature · 3 lines
-- 
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#8 lore raw
Quoted 32 lines · José Expósito

Hey Michel,

Thanks for looking into this.

Quoted 27 lines · Michel Dänzer
Quoted 26 lines · José Expósito

When compiling with sparse enabled, this warning is thrown:

warning: incorrect type in argument 2 (different base types)
expected restricted __le32 const [usertype] *buf got unsigned int [usertype] *[assigned] buf

Add a cast to fix it.

Fixes 453114319699 ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010()")
---
 drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -1
index 7299fa8971ce..86829e1cb7f0 100644
@@ -1033,7 +1033,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
 		NULL : &result->dst_pitch;
 
 	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
-	buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32));
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
 	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 
Quoted 8 lines
Quoted 3 lines

drivers/gpu/drm/tests/drm_format_helper_test.c static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) · line 1039

Quoted 1 line
drivers/gpu/drm/tests/drm_format_helper_test.c +0 -0
 	buf = dst.vaddr; /* restore original value of buf */

It might be cleaner to use two separate variables instead of using "buf" as both little endian and host byte order. (Same for patch 2)

Yes, however, the same pattern is repeated 10 times in this file.

What do you think about fixing it in a follow up? I don't think it should block fixing the KUnit tests.

Ah, yes, makes sense to do it separately then.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#9 lore raw
In reply to José Expósito

Hi

Am 01.07.25 um 18:45 schrieb José Expósito:

Quoted 32 lines

Hey Michel,

Thanks for looking into this.

Quoted 27 lines · Michel Dänzer
Quoted 26 lines · José Expósito

When compiling with sparse enabled, this warning is thrown:

warning: incorrect type in argument 2 (different base types)
expected restricted __le32 const [usertype] *buf got unsigned int [usertype] *[assigned] buf

Add a cast to fix it.

Fixes 453114319699 ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010()")
---
  drivers/gpu/drm/tests/drm_format_helper_test.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tests/drm_format_helper_test.c +1 -1
index 7299fa8971ce..86829e1cb7f0 100644
@@ -1033,7 +1033,7 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test)
  		NULL : &result->dst_pitch;
 
  	drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, &params->clip, &fmtcnv_state);
-	buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32));
+	buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32));
  	KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size);
 
Quoted 6 lines
Quoted 2 lines

drivers/gpu/drm/tests/drm_format_helper_test.c static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) · line 1039

Quoted 1 line
drivers/gpu/drm/tests/drm_format_helper_test.c +0 -0
  	buf = dst.vaddr; /* restore original value of buf */

It might be cleaner to use two separate variables instead of using "buf" as both little endian and host byte order. (Same for patch 2)

Yes, however, the same pattern is repeated 10 times in this file.

What do you think about fixing it in a follow up? I don't think it should block fixing the KUnit tests.

Before doing this, you should consider storing the test data in little-endian. That would save all the endianess conversion in the code.

Best regards
Thomas

Quoted 6 lines

Jose

Quoted 3 lines
Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)