All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sidharth Saha" <ssaha2000@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/5] drm/vkms: Add KUnit test for RGB565 writeback conversion
Date: Tue, 17 Nov 2026 01:33:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-218047@kernel.org> (raw)
In-Reply-To: <20261116-rgb565-test-v1-1-27f49c1aa694@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/vkms: non-routable noreply email in Signed-off-by trailer
- [Medium] drm/vkms: missing sentinel in vkms_format_test_cases causes
  OOB read
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Medium] drm/vkms: CPU stalls due to 64-bit division in
  argb_u16_to_RGB565() [1]
--

commit 7e8259d89165f4b4d4681ffd3d36be55b127f91e
Author: Sidharth Saha <ssaha2000@gmail.com>

> drm/vkms: Add KUnit test for RGB565 writeback conversion
>
> argb_u16_to_RGB565() reduces each 16-bit channel to 5 or 6 bits. Its
> rounding was fixed in commit ab87f558dcfb ("drm/vkms: Fix RGB565 pixel
> conversion"), lost again in commit cc4fd2934d41 ("drm/vkms: Isolate
> writeback pixel conversion functions"), and restored by "drm/vkms: make
> argb_u16_to_RGB565 round resulting values". Add a KUnit test so it can't
> silently regress again.
>
> The test checks hand-computed values for zero, maximum, the 0x8000
> midpoint, inputs on either side of the first rounding step, and distinct
> per-channel values to catch channel placement errors.
>
> Make argb_u16_to_RGB565() visible to KUnit so the test can call it.
>
> Signed-off-by: Sidharth Saha <40047656+Sidharth-Saha@users.noreply.github.com>

[Severity: High]
The Signed-off-by trailer uses a non-routable GitHub noreply email address
that does not match the commit Author address (<ssaha2000@gmail.com>).

> diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c
> index bbb1ad18c99ff..a8ef93b9c806c 100644
> --- a/drivers/gpu/drm/vkms/tests/vkms_format_test.c
> +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c

[ ... ]

> @@ -265,9 +265,45 @@ KUNIT_ARRAY_PARAM(yuv_u16_to_argb_u16, yuv_u16_to_argb_u16_cases,
>  static struct kunit_case vkms_format_test_cases[] = {
>  	KUNIT_CASE_PARAM(vkms_format_test_yuv_u16_to_argb_u16, yuv_u16_to_argb_u16_gen_params),
> -	{}
> +	KUNIT_CASE_PARAM(vkms_format_test_argb_u16_to_RGB565, rgb565_gen_params),
>  };

[Severity: Medium]
Does removing the trailing {} sentinel from vkms_format_test_cases[] cause
an out-of-bounds read when KUnit iterates over the suite?

kunit_suite_for_each_test_case() walks suite->test_cases until it sees a
NULL run_case pointer, so running or enumerating the vkms-format suite will
read past the end of the array and treat adjacent memory as a test case.
Note that a later patch in this series, commit "drm/vkms: Add KUnit tests
for RGB565 and BGR565 read conversion", restores the trailing {} entry.

> diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
> index b0078d6efb908..c5ee2d6a920f6 100644
> --- a/drivers/gpu/drm/vkms/vkms_formats.c
> +++ b/drivers/gpu/drm/vkms/vkms_formats.c
> @@ -685,7 +685,7 @@ static void argb_u16_to_channels(u16 *out_r, u16 *out_g, u16 *out_b, u16 *out_a,
>  		*out_a = u16_to_channel(a_size, in_pixel->a);
>  }
>  
> -static void argb_u16_to_RGB565(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel)
> +VISIBLE_IF_KUNIT void argb_u16_to_RGB565(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel)
>  {
>  	__le16 *pixel = (__le16 *)out_pixel;
>  	u16 r, g, b;
> @@ -694,6 +694,7 @@ static void argb_u16_to_RGB565(u8 *out_pixel, const struct pixel_argb_u16 *in_pi
>  
>  	*pixel = cpu_to_le16(r << 11 | g << 5 | b);
>  }
> +EXPORT_SYMBOL_IF_KUNIT(argb_u16_to_RGB565);

[Severity: Medium]
This problem wasn't introduced by this patch, but argb_u16_to_RGB565() (via
argb_u16_to_channels() -> u16_to_channel()) and argb_u16_from_RGB565()
perform 64-bit fixed-point divisions with drm_fixp_div() on every channel
of every pixel [1]:

drivers/gpu/drm/vkms/vkms_formats.c:u16_to_channel() {
	s64 fp_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp((1 << size) - 1));
	s64 fp_channel = drm_int2fixp(in);

	return drm_fixp2int_round(drm_fixp_div(fp_channel, fp_ratio));
}

When vkms_writeback_row() or plane reading converts an entire framebuffer,
running software-emulated 64-bit divisions per pixel causes severe CPU
stalls and rendering performance degradation on 32-bit architectures.

[1] https://sashiko.dev/#/bug/linux-7999e4a9-b93f-4927-aea8-f7c41dab6826

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-rgb565-test-v1-0-27f49c1aa694@gmail.com?part=1

  reply	other threads:[~2026-11-17  1:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  1:21 [PATCH 0/5] drm/vkms: Add KUnit tests for packed RGB format conversions Sidharth Saha
2026-11-17  1:21 ` Sidharth Saha via B4 Relay
2026-11-17  1:21 ` [PATCH 1/5] drm/vkms: Add KUnit test for RGB565 writeback conversion Sidharth Saha
2026-11-17  1:21   ` Sidharth Saha via B4 Relay
2026-11-17  1:33   ` sashiko-bot [this message]
2026-11-17  1:21 ` [PATCH 2/5] drm/vkms: Add KUnit test for BGR565 " Sidharth Saha
2026-11-17  1:21   ` Sidharth Saha via B4 Relay
2026-11-17  1:32   ` sashiko-bot
2026-11-17  1:21 ` [PATCH 3/5] drm/vkms: Add KUnit tests for RGB332 and BGR233 read conversion Sidharth Saha
2026-11-17  1:21   ` Sidharth Saha via B4 Relay
2026-11-17  1:31   ` sashiko-bot
2026-11-17  1:21 ` [PATCH 4/5] drm/vkms: Add KUnit tests for RGB332 and BGR233 writeback conversion Sidharth Saha
2026-11-17  1:21   ` Sidharth Saha via B4 Relay
2026-11-17  1:31   ` sashiko-bot
2026-11-17  1:21 ` [PATCH 5/5] drm/vkms: Add KUnit tests for RGB565 and BGR565 read conversion Sidharth Saha
2026-11-17  1:21   ` Sidharth Saha via B4 Relay
2026-11-17  1:29   ` sashiko-bot

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=sashiko-outbox-218047@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ssaha2000@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.