From: sashiko-bot@kernel.org
To: "Robert Mader" <robert.mader@collabora.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v1 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22
Date: Fri, 04 Dec 2026 14:18:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-249956@kernel.org> (raw)
In-Reply-To: <20261204135131.195561-4-robert.mader@collabora.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/vkms: u16 sum overflow in vkms_color_test_inv_lut() masks
test failures
- [Medium] drm/vkms: gamma22_inv_eotf uses 4096-entry inv_pow22 LUT
instead of 370
- [Low] drm/vkms: globally export KUnit-only gamma22 LUTs via
EXPORT_SYMBOL()
--
commit 59d26d74c99ba688971258bafc7bd1586364f0e8
Author: Robert Mader <robert.mader@collabora.com>
drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22
This commit adds Gamma 2.2 EOTF and inverse EOTF 1D curve colorop support
to VKMS by defining non-uniform LUTs in vkms_luts.c, wiring them into
vkms_colorop.c and vkms_composer.c, and adding a KUnit round-trip test.
> diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
> index 409e7a7d6861f..8a1cc8e3f774e 100644
> --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c
> +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c
> @@ -151,6 +151,11 @@ static void vkms_color_srgb_inv_srgb(struct kunit *test)
> vkms_color_test_inv_lut(test, &srgb_eotf, &srgb_inv_eotf, 11, 0);
> }
>
> +static void vkms_color_gamma22_inv_gamma22(struct kunit *test)
> +{
> + vkms_color_test_inv_lut(test, &gamma22_eotf, &gamma22_inv_eotf, 304, 2);
> +}
> +
[Severity: Medium]
Can sum overflow in vkms_color_test_inv_lut() with tolerance_max set to 304?
drivers/gpu/drm/vkms/tests/vkms_color_test.c:vkms_color_test_inv_lut() {
u16 sum = 0;
u16 count = 0;
...
for (u32 i = 0; i <= 4095; i++) {
...
sum += abs((int)x - final);
count++;
}
KUNIT_EXPECT_LE(test, sum / count, tolerance_avg);
}
Because sum is a u16, it wraps modulo 65536 once the average error over
4096 samples reaches 16. A broken LUT with an average error of 16 to 18
would wrap sum / count back to 0..2 and falsely pass the average tolerance
check. Widening sum to u32 or u64 prevents the wraparound.
[ ... ]
> diff --git a/drivers/gpu/drm/vkms/vkms_luts.c b/drivers/gpu/drm/vkms/vkms_luts.c
> index 4b766ae7c1254..dcdeae68536f4 100644
> --- a/drivers/gpu/drm/vkms/vkms_luts.c
> +++ b/drivers/gpu/drm/vkms/vkms_luts.c
> @@ -706,3 +706,4947 @@ const struct vkms_color_lut srgb_inv_eotf = {
> .lut_length = ARRAY_SIZE(srgb_inv_y)
> };
> EXPORT_SYMBOL(srgb_inv_eotf);
[ ... ]
> +const struct vkms_color_lut gamma22_eotf = {
> + .x = pow22_x,
> + .y = pow22_y,
> + .lut_length = ARRAY_SIZE(pow22_y)
> +};
> +EXPORT_SYMBOL(gamma22_eotf);
[Severity: Low]
Should gamma22_eotf and gamma22_inv_eotf use EXPORT_SYMBOL_IF_KUNIT()
instead of EXPORT_SYMBOL()?
vkms_luts.o and vkms_composer.o link into vkms.o, so the only external
user is vkms_color_test.c, which already imports EXPORTED_FOR_KUNIT_TESTING.
Using EXPORT_SYMBOL_IF_KUNIT() avoids exposing these unprefixed internal
structs in the global symbol table when CONFIG_KUNIT is disabled.
[ ... ]
> +static u16 inv_pow22_x[] = {
[ ... ]
> +static_assert(ARRAY_SIZE(inv_pow22_x) == ARRAY_SIZE(inv_pow22_y),
> + "pow22_inv x and y must have the same number of entries");
> +
> +const struct vkms_color_lut gamma22_inv_eotf = {
> + .x = inv_pow22_x,
> + .y = inv_pow22_y,
> + .lut_length = ARRAY_SIZE(inv_pow22_y)
> +};
[Severity: Medium]
Were inv_pow22_x and inv_pow22_y meant to have 370 entries instead of 4096?
The commit message says the tables use the suggested sizes from
color-curve-lut.py, which recommends 370 entries for inverse pow 2.2. The
mismatch between the inv_pow22 names and the "pow22_inv" static_assert
message also suggests stale 4096-entry output was pasted here.
Embedding 4096 entries adds ~37 KiB of redundant static data to vkms.ko
(mostly repeating identical quantized values across 0xf240..0xffff),
pushes the table past a 32 KiB L1 data cache, and increases the per-channel
binary search in apply_non_uniform_lut() from 9 to 12 iterations.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204135131.195561-1-robert.mader@collabora.com?part=3
next prev parent reply other threads:[~2026-12-04 14:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 13:50 [PATCH v1 0/4] drm/vkms: Add gamma 2.2 and 2.4 1D curve colorops Robert Mader
2026-12-04 13:50 ` [PATCH v1 1/4] drm/vkms: Fix inverse lut naming scheme in script Robert Mader
2026-12-04 13:50 ` [PATCH v1 2/4] drm/vkms: Make LUT test reusable Robert Mader
2026-12-04 14:02 ` sashiko-bot
2026-12-04 13:50 ` [PATCH v1 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22 Robert Mader
2026-12-04 14:18 ` sashiko-bot [this message]
2026-12-04 13:50 ` [PATCH v1 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24 Robert Mader
2026-12-04 14:35 ` 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-249956@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robert.mader@collabora.com \
--cc=sashiko-reviews@lists.linux.dev \
/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