2022-07-26 23:33:17

by José Expósito

[permalink] [raw]
Subject: [PATCH v3 0/4] KUnit tests for RGB565 conversion

Hello everyone,

This series is a follow up of the XRGB8888 to RGB332 conversion KUnit
tests.

As I mentioned in v2 [1] I suspected that the inconsistency handling
the endian might need to be fixed.
Fortunately, Geert Uytterhoeven fixed it in commit 4d9db10576ff
("drm/format-helper: Fix endianness in drm_fb_*_to_*() conversion
helpers"), so I updated the tests to reflect his change.

Changes since v1:

- Fix a bug reported by David Gow in the XRGB8888 to RGB332 tests
- Simplify the test structure as suggested by David Gow
- Add Tested-by Tales L. Aparecida and Acked-by Thomas Zimmermann
- Fix link in the last patch (Thomas Zimmermann)

Changes since v2:

- Test endian as fixed in commit 4d9db10576ff ("drm/format-helper: Fix
endianness in drm_fb_*_to_*() conversion helpers")
- Fix Sparse warning reported by David Gow
- Add Reviewed-by David Gow

[1] https://lore.kernel.org/dri-devel/[email protected]/

José Expósito (4):
drm/format-helper: Fix test on big endian architectures
drm/format-helper: Rename test cases to make them more generic
drm/format-helper: Support multiple target formats results
drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb565()

.../gpu/drm/tests/drm_format_helper_test.c | 169 ++++++++++++++----
1 file changed, 139 insertions(+), 30 deletions(-)

--
2.25.1


2022-07-26 23:42:00

by José Expósito

[permalink] [raw]
Subject: [PATCH v3 1/4] drm/format-helper: Fix test on big endian architectures

The tests fail on big endian architectures, like PowerPC:

$ ./tools/testing/kunit/kunit.py run \
--kunitconfig=drivers/gpu/drm/tests \
--arch=powerpc --cross_compile=powerpc64-linux-gnu-

Transform the XRGB8888 buffer from little endian to the CPU endian
before calling the conversion function to avoid this error.

Fixes: 8f456104915f ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332()")
Reported-by: David Gow <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: José Expósito <[email protected]>
---
.../gpu/drm/tests/drm_format_helper_test.c | 23 +++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c
index 98583bf56044..eefaba3aaea2 100644
--- a/drivers/gpu/drm/tests/drm_format_helper_test.c
+++ b/drivers/gpu/drm/tests/drm_format_helper_test.c
@@ -111,6 +111,21 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch,
return dst_pitch * drm_rect_height(clip);
}

+static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size)
+{
+ u32 *dst = NULL;
+ int n;
+
+ dst = kunit_kzalloc(test, sizeof(*dst) * buf_size, GFP_KERNEL);
+ if (!dst)
+ return NULL;
+
+ for (n = 0; n < buf_size; n++)
+ dst[n] = le32_to_cpu((__force __le32)buf[n]);
+
+ return dst;
+}
+
static void xrgb8888_to_rgb332_case_desc(struct xrgb8888_to_rgb332_case *t,
char *desc)
{
@@ -125,6 +140,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test)
const struct xrgb8888_to_rgb332_case *params = test->param_value;
size_t dst_size;
__u8 *dst = NULL;
+ __u32 *src = NULL;

struct drm_framebuffer fb = {
.format = drm_format_info(DRM_FORMAT_XRGB8888),
@@ -138,8 +154,11 @@ static void xrgb8888_to_rgb332_test(struct kunit *test)
dst = kunit_kzalloc(test, dst_size, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst);

- drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, params->xrgb8888,
- &fb, &params->clip);
+ src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src);
+
+ drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, src, &fb,
+ &params->clip);
KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0);
}

--
2.25.1

2022-07-28 18:22:44

by José Expósito

[permalink] [raw]
Subject: Re: [PATCH v3 0/4] KUnit tests for RGB565 conversion

On Wed, Jul 27, 2022 at 01:09:12AM +0200, Jos? Exp?sito wrote:
> Hello everyone,
>
> This series is a follow up of the XRGB8888 to RGB332 conversion KUnit
> tests.
>
> As I mentioned in v2 [1] I suspected that the inconsistency handling
> the endian might need to be fixed.
> Fortunately, Geert Uytterhoeven fixed it in commit 4d9db10576ff
> ("drm/format-helper: Fix endianness in drm_fb_*_to_*() conversion
> helpers"), so I updated the tests to reflect his change.
>
> Changes since v1:
>
> - Fix a bug reported by David Gow in the XRGB8888 to RGB332 tests
> - Simplify the test structure as suggested by David Gow
> - Add Tested-by Tales L. Aparecida and Acked-by Thomas Zimmermann
> - Fix link in the last patch (Thomas Zimmermann)
>
> Changes since v2:
>
> - Test endian as fixed in commit 4d9db10576ff ("drm/format-helper: Fix
> endianness in drm_fb_*_to_*() conversion helpers")
> - Fix Sparse warning reported by David Gow
> - Add Reviewed-by David Gow
>
> [1] https://lore.kernel.org/dri-devel/[email protected]/
>
> Jos? Exp?sito (4):
> drm/format-helper: Fix test on big endian architectures
> drm/format-helper: Rename test cases to make them more generic
> drm/format-helper: Support multiple target formats results
> drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb565()
>
> .../gpu/drm/tests/drm_format_helper_test.c | 169 ++++++++++++++----
> 1 file changed, 139 insertions(+), 30 deletions(-)
>
> --
> 2.25.1
>

As suggested by Thomas [1] I pushed the series to drm-misc-next.

I've found some conflicts in drm-tip in unreleated files I'm trying to
figure out on IRC though :(

Jose

[1] https://lore.kernel.org/dri-devel/[email protected]/