From: "José Expósito" <jose.exposito89@gmail.com>
To: javierm@redhat.com
Cc: davidgow@google.com, dlatypov@google.com, tzimmermann@suse.de,
mripard@kernel.org, daniel@ffwll.ch, airlied@linux.ie,
maarten.lankhorst@linux.intel.com, jani.nikula@linux.intel.com,
maira.canal@usp.br, isabbasso@riseup.net,
magalilemes00@gmail.com, tales.aparecida@gmail.com,
dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com,
linux-kernel@vger.kernel.org,
"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH v2 1/4] drm/format-helper: Fix test on big endian architectures
Date: Sat, 9 Jul 2022 13:58:34 +0200 [thread overview]
Message-ID: <20220709115837.560877-2-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220709115837.560877-1-jose.exposito89@gmail.com>
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 <davidgow@google.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
.../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..4d074c2e48bf 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, buf_size, GFP_KERNEL);
+ if (!dst)
+ return NULL;
+
+ for (n = 0; n < buf_size; n++)
+ dst[n] = le32_to_cpu(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, ¶ms->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,
+ ¶ms->clip);
KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0);
}
--
2.25.1
next prev parent reply other threads:[~2022-07-09 11:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-09 11:58 [PATCH v2 0/4] KUnit tests for RGB565 conversion José Expósito
2022-07-09 11:58 ` José Expósito [this message]
2022-07-16 9:32 ` [PATCH v2 1/4] drm/format-helper: Fix test on big endian architectures David Gow
2022-07-09 11:58 ` [PATCH v2 2/4] drm/format-helper: Rename test cases to make them more generic José Expósito
2022-07-16 9:32 ` David Gow
2022-07-09 11:58 ` [PATCH v2 3/4] drm/format-helper: Support multiple target formats results José Expósito
2022-07-16 9:32 ` David Gow
2022-07-09 11:58 ` [PATCH v2 4/4] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb565() José Expósito
2022-07-16 9:32 ` David Gow
2022-07-17 16:55 ` José Expósito
2022-07-17 17:00 ` José Expósito
2022-08-10 16:31 ` Daniel Vetter
2022-08-10 16:45 ` Daniel Latypov
2022-08-10 16:41 ` Daniel Latypov
2022-08-13 10:36 ` José Expósito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220709115837.560877-2-jose.exposito89@gmail.com \
--to=jose.exposito89@gmail.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=davidgow@google.com \
--cc=dlatypov@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=isabbasso@riseup.net \
--cc=jani.nikula@linux.intel.com \
--cc=javierm@redhat.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=magalilemes00@gmail.com \
--cc=maira.canal@usp.br \
--cc=mripard@kernel.org \
--cc=tales.aparecida@gmail.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®