All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oarora Etimis" <oaroraetimis@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/7] drm/vkms: add a 3D LUT colorop
Date: Sat, 28 Nov 2026 17:34:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-238893@kernel.org> (raw)
In-Reply-To: <20261128-colorop-v1-5-dd79919f822b@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/vkms: raw 64-bit division in apply_3dlut_to_channel_value()
  breaks 32-bit build
--

commit 069bec6d031e1f99c4351f4a1c421ad40f2e771c
Author: Oarora Etimis <oaroraetimis@gmail.com>

drm/vkms: add a 3D LUT colorop

This commit adds a 17x17x17 3D LUT colorop with tetrahedral interpolation
to the VKMS plane color pipeline.

> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
> index e00d1d0b2f2d9..51ac2ae75cf0c 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -256,6 +256,115 @@ VISIBLE_IF_KUNIT u16 apply_lut32_to_channel_value(const struct drm_color_lut32 *
>  }
>  EXPORT_SYMBOL_IF_KUNIT(apply_lut32_to_channel_value);
>  
> +/*
> + * Tetrahedral interpolation of one channel in a 3D LUT. The input value of
> + * each axis selects a cell of the LUT; the fractions pick one of the six
> + * tetrahedra the cell is split into, and the four corners of that
> + * tetrahedron are weighted.
> + */
> +static u16 apply_3dlut_to_channel_value(const struct drm_color_lut32 *lut, u32 size,
> +			       enum lut_channel channel, u16 r, u16 g, u16 b)
> +{
> +	u32 max_index = size - 1;
> +	u32 r_index, g_index, b_index;
> +	u32 r_fraction, g_fraction, b_fraction;
> +	const struct drm_color_lut32 *v000;
> +	u64 position, sum;
> +	u16 v000_c, v100_c, v010_c, v001_c;
> +	u16 v110_c, v101_c, v011_c, v111_c;
> +
> +	position = (u64)r * max_index;
> +	r_index = position / U16_MAX;
> +	r_fraction = position - (u64)r_index * U16_MAX;
> +
> +	position = (u64)g * max_index;
> +	g_index = position / U16_MAX;
> +	g_fraction = position - (u64)g_index * U16_MAX;
> +
> +	position = (u64)b * max_index;
> +	b_index = position / U16_MAX;
> +	b_fraction = position - (u64)b_index * U16_MAX;

[ ... ]

> +VISIBLE_IF_KUNIT void apply_3dlut_to_pixel(struct pixel_argb_s32 *pixel,
> +					   const struct drm_color_lut32 *lut,
> +					   u32 size)
> +{
> +	u16 r = clamp_val(pixel->r, 0, 0xffff);
> +	u16 g = clamp_val(pixel->g, 0, 0xffff);
> +	u16 b = clamp_val(pixel->b, 0, 0xffff);
> +
> +	if (size < 2)
> +		return;
> +
> +	pixel->r = apply_3dlut_to_channel_value(lut, size, LUT_RED, r, g, b);
> +	pixel->g = apply_3dlut_to_channel_value(lut, size, LUT_GREEN, r, g, b);
> +	pixel->b = apply_3dlut_to_channel_value(lut, size, LUT_BLUE, r, g, b);
> +}
> +EXPORT_SYMBOL_IF_KUNIT(apply_3dlut_to_pixel);

[Severity: High]
Does dividing the u64 variable position with raw / U16_MAX break 32-bit
builds with an undefined reference to __udivdi3?

Using div_u64_rem(position, U16_MAX, &r_fraction) avoids the 64-bit
division helper, and computing the cell indices and fractions once in
apply_3dlut_to_pixel() would also avoid repeating the three divisions for
each channel of every pixel.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-colorop-v1-0-dd79919f822b@gmail.com?part=5

  reply	other threads:[~2026-11-28 17:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 17:15 [PATCH 0/7] drm/vkms: complete the plane color pipeline Oarora Etimis
2026-11-28 17:15 ` [PATCH 1/7] drm/vkms: add the colorops of a plane that is being enabled Oarora Etimis
2026-11-28 17:15 ` [PATCH 2/7] drm/vkms: free the colorop whose initialization failed Oarora Etimis
2026-11-28 17:27   ` sashiko-bot
2026-11-28 17:15 ` [PATCH 3/7] drm/vkms: use the colorop states of the state being composed Oarora Etimis
2026-11-28 17:31   ` sashiko-bot
2026-11-28 17:15 ` [PATCH 4/7] drm/vkms: add a programmable 1D LUT colorop Oarora Etimis
2026-11-28 17:25   ` sashiko-bot
2026-11-28 17:15 ` [PATCH 5/7] drm/vkms: add a 3D " Oarora Etimis
2026-11-28 17:34   ` sashiko-bot [this message]
2026-11-28 17:15 ` [PATCH 6/7] drm/vkms: add a multiplier colorop Oarora Etimis
2026-11-28 17:31   ` sashiko-bot
2026-11-28 17:15 ` [PATCH 7/7] drm/vkms: add KUnit coverage for the 3D LUT and multiplier colorops Oarora Etimis
2026-11-29 12:37 ` [PATCH 0/7] drm/vkms: complete the plane color pipeline Louis Chauvet

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-238893@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=oaroraetimis@gmail.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.