From: sashiko-bot@kernel.org
To: "Robert Mader" <robert.mader@collabora.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22
Date: Fri, 04 Dec 2026 15:10:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-250064@kernel.org> (raw)
In-Reply-To: <20261204145427.221618-4-robert.mader@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: unclamped s32-to-u16 wraparound in apply_colorop()
1D curve LUTs
- [Low] drm/vkms: globally export KUnit-only gamma22 LUTs via
EXPORT_SYMBOL()
--
commit b0ad0319d06f1020df30009f35dd9bb1429d38fb
Author: Robert Mader <robert.mader@collabora.com>
drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22
This commit adds non-uniform LUTs and colorop handling for the Gamma 2.2
EOTF and its inverse, along with a KUnit round-trip test.
> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index 7a6a7875520ca..8eaad80ad4697 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -264,6 +264,19 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo
> pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
> pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
> break;
> + case DRM_COLOROP_1D_CURVE_GAMMA22:
> + pixel->r = apply_lut_to_channel_value(&gamma22_eotf, pixel->r, LUT_RED);
> + pixel->g = apply_lut_to_channel_value(&gamma22_eotf, pixel->g, LUT_GREEN);
> + pixel->b = apply_lut_to_channel_value(&gamma22_eotf, pixel->b, LUT_BLUE);
> + break;
> + case DRM_COLOROP_1D_CURVE_GAMMA22_INV:
> + pixel->r = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->r,
> + LUT_RED);
> + pixel->g = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->g,
> + LUT_GREEN);
> + pixel->b = apply_lut_to_channel_value(&gamma22_inv_eotf, pixel->b,
> + LUT_BLUE);
> + break;
[Severity: Medium]
Can passing pixel->r, pixel->g, and pixel->b directly to
apply_lut_to_channel_value() wrap out-of-range values modulo 65536?
pre_blend_color_transform() runs the pipeline in struct pixel_argb_s32 and
only clamps channels to [0, 0xffff] after all colorops finish. Because
vkms_initialize_color_pipeline() places a 1D curve stage after the 3x4 CTM
stages, out-of-range CTM outputs reach this lookup as unclamped s32 values.
Since apply_lut_to_channel_value() takes a u16 channel_value, implicit
narrowing turns -1 into 0xffff and 0x10000 into 0x0000, corrupting rendered
pixels and CRCs. Clamping to [0, 0xffff] before the lookup avoids this.
[ ... ]
> diff --git a/drivers/gpu/drm/vkms/vkms_luts.c b/drivers/gpu/drm/vkms/vkms_luts.c
> index 4b766ae7c1254..5778226fc290f 100644
> --- a/drivers/gpu/drm/vkms/vkms_luts.c
> +++ b/drivers/gpu/drm/vkms/vkms_luts.c
[ ... ]
> +const struct vkms_color_lut gamma22_eotf = {
> + .x = pow22_x,
> + .y = pow22_y,
> + .lut_length = ARRAY_SIZE(pow22_y)
> +};
> +EXPORT_SYMBOL(gamma22_eotf);
[ ... ]
> +const struct vkms_color_lut gamma22_inv_eotf = {
> + .x = pow22_inv_x,
> + .y = pow22_inv_y,
> + .lut_length = ARRAY_SIZE(pow22_inv_y)
> +};
> +EXPORT_SYMBOL(gamma22_inv_eotf);
[Severity: Low]
Should gamma22_eotf and gamma22_inv_eotf use EXPORT_SYMBOL_IF_KUNIT()
instead of EXPORT_SYMBOL()?
vkms_luts.o is linked into vkms.o with vkms_composer.o, so the only
external user is vkms_color_test.c, which already imports the
EXPORTED_FOR_KUNIT_TESTING namespace. EXPORT_SYMBOL() exports these
unprefixed names globally even without KUnit, risking symbol collisions.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204145427.221618-1-robert.mader@collabora.com?part=3
next prev parent reply other threads:[~2026-12-04 15:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:53 [PATCH v2 0/4] drm/vkms: Add gamma 2.2 and 2.4 1D curve colorops Robert Mader
2026-12-04 14:53 ` [PATCH v2 1/4] drm/vkms: Fix inverse lut naming scheme in script Robert Mader
2026-12-04 14:53 ` [PATCH v2 2/4] drm/vkms: Make LUT test reusable Robert Mader
2026-12-04 14:53 ` [PATCH v2 3/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA22 Robert Mader
2026-12-04 15:10 ` sashiko-bot [this message]
2026-12-04 14:53 ` [PATCH v2 4/4] drm/vkms: Add support for DRM_COLOROP_1D_CURVE_GAMMA24 Robert Mader
2026-12-04 15:11 ` sashiko-bot
2026-12-05 9:55 ` kernel test robot
2026-12-05 9:55 ` kernel test robot
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-250064@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 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.