AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Alex Hung <alex.hung@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: wayland-devel@lists.freedesktop.org, harry.wentland@amd.com,
	leo.liu@amd.com, ville.syrjala@linux.intel.com,
	pekka.paalanen@collabora.com, contact@emersion.fr,
	mwen@igalia.com, jadahl@redhat.com, sebastian.wick@redhat.com,
	shashank.sharma@amd.com, agoins@nvidia.com, joshua@froggi.es,
	mdaenzer@redhat.com, aleixpol@kde.org, xaver.hugl@gmail.com,
	victoria@system76.com, daniel@ffwll.ch, uma.shankar@intel.com,
	quic_naseer@quicinc.com, quic_cbraga@quicinc.com,
	quic_abhinavk@quicinc.com, marcan@marcan.st, Liviu.Dudau@arm.com,
	sashamcintosh@google.com, chaitanya.kumar.borah@intel.com,
	louis.chauvet@bootlin.com, mcanal@igalia.com,
	nfraprado@collabora.com, arthurgrillo@riseup.net,
	Daniel Stone <daniels@collabora.com>
Subject: Re: [PATCH V13 39/51] drm/amd/display: add 3x4 matrix colorop
Date: Fri, 19 Dec 2025 12:41:10 +0000	[thread overview]
Message-ID: <83bf2281-e604-48fd-a8ff-533ae86bc52e@ursulin.net> (raw)
In-Reply-To: <20251115000237.3561250-40-alex.hung@amd.com>


On 15/11/2025 00:02, Alex Hung wrote:
> This adds support for a 3x4 color transformation matrix.
> 
> With this change the following IGT tests pass:
> kms_colorop --run plane-XR30-XR30-ctm_3x4_50_desat
> kms_colorop --run plane-XR30-XR30-ctm_3x4_overdrive
> kms_colorop --run plane-XR30-XR30-ctm_3x4_oversaturate
> kms_colorop --run plane-XR30-XR30-ctm_3x4_bt709_enc
> kms_colorop --run plane-XR30-XR30-ctm_3x4_bt709_dec
> 
> The color pipeline now consists of the following colorops:
> 1. 1D curve colorop
> 2. 3x4 CTM
> 3. 1D curve colorop
> 4. 1D LUT
> 5. 1D curve colorop
> 6. 1D LUT
> 
> Signed-off-by: Alex Hung <alex.hung@amd.com>
> Signed-off-by: Harry Wentland <harry.wentland@amd.com>
> Reviewed-by: Daniel Stone <daniels@collabora.com>
> Reviewed-by: Melissa Wen <mwen@igalia.com>
> ---
> v13:
>   - Remove redundant ternary null check for drm_color_ctm_3x4 blob (Coverity Scan)
> 
> V10:
>   - Change %lu to %zu for sizeof() in drm_warn (kernel test robot)
>   - Remove redundant DRM_ERROR(...)
> 
> V9:
>   - Update function names by _plane_ (Chaitanya Kumar Borah)
> 
> v8:
>   - Return -EINVAL when drm_color_ctm_3x4's size mismatches (Leo Li)
> 
> v7:
>   - Change %lu to %zu for sizeof() in drm_warn
> 
> v6:
>   - fix warnings in dbg prints
> 
>   .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 52 +++++++++++++++++++
>   .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 15 ++++++
>   2 files changed, 67 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> index b958f9c0a0c2..298f337f0eb4 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> @@ -1378,6 +1378,47 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,
>   	return __set_colorop_in_tf_1d_curve(dc_plane_state, colorop_state);
>   }
>   
> +static int
> +__set_dm_plane_colorop_3x4_matrix(struct drm_plane_state *plane_state,
> +				  struct dc_plane_state *dc_plane_state,
> +				  struct drm_colorop *colorop)
> +{
> +	struct drm_colorop *old_colorop;
> +	struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
> +	struct drm_atomic_state *state = plane_state->state;
> +	const struct drm_device *dev = colorop->dev;
> +	const struct drm_property_blob *blob;
> +	struct drm_color_ctm_3x4 *ctm = NULL;
> +	int i = 0;
> +
> +	/* 3x4 matrix */
> +	old_colorop = colorop;
> +	for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
> +		if (new_colorop_state->colorop == old_colorop &&
> +		    new_colorop_state->colorop->type == DRM_COLOROP_CTM_3X4) {
> +			colorop_state = new_colorop_state;
> +			break;
> +		}
> +	}
> +
> +	if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_CTM_3X4) {
> +		drm_dbg(dev, "3x4 matrix colorop with ID: %d\n", colorop->base.id);
> +		blob = colorop_state->data;
> +		if (blob->length == sizeof(struct drm_color_ctm_3x4)) {
> +			ctm = (struct drm_color_ctm_3x4 *) blob->data;
> +			__drm_ctm_3x4_to_dc_matrix(ctm, dc_plane_state->gamut_remap_matrix.matrix);
> +			dc_plane_state->gamut_remap_matrix.enable_remap = true;
> +			dc_plane_state->input_csc_color_matrix.enable_adjustment = false;
> +		} else {
> +			drm_warn(dev, "blob->length (%zu) isn't equal to drm_color_ctm_3x4 (%zu)\n",
> +				 blob->length, sizeof(struct drm_color_ctm_3x4));
> +			return -EINVAL;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>   static int
>   __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
>   			      struct dc_plane_state *dc_plane_state,
> @@ -1581,6 +1622,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
>   	if (ret)
>   		return ret;
>   
> +	/* 3x4 matrix */
> +	colorop = colorop->next;
> +	if (!colorop) {
> +		drm_dbg(dev, "no 3x4 matrix colorop found\n");
> +		return -EINVAL;
> +	}
> +
> +	ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop);
> +	if (ret)
> +		return ret;
> +
>   	/* 1D Curve & LUT - SHAPER TF & LUT */
>   	colorop = colorop->next;
>   	if (!colorop) {
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> index 4845f26e4a8a..f2be75b9b073 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> @@ -74,6 +74,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
>   
>   	i++;
>   
> +	/* 3x4 matrix */
> +	ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
> +	if (!ops[i]) {
> +		ret = -ENOMEM;
> +		goto cleanup;

Does this cleanup path leak the list->name allocated a few lines above, 
outside the diff? Kmemleak appears to think it can leak from somewhere 
at least:

unreferenced object 0xffff8881143c1e00 (size 32):
   comm "(udev-worker)", pid 588, jiffies 4294888494
   hex dump (first 32 bytes):
     43 6f 6c 6f 72 20 50 69 70 65 6c 69 6e 65 20 33  Color Pipeline 3
     31 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00  13..............
   backtrace (crc a75af242):
     __kmalloc_node_track_caller_noprof+0x525/0x890
     kvasprintf+0xb6/0x130
     kasprintf+0xb2/0xe0
     amdgpu_dm_initialize_default_pipeline+0x1ce/0x840 [amdgpu]
     dm_plane_init_colorops+0x19c/0x2e0 [amdgpu]
     amdgpu_dm_plane_init+0x4c4/0xf10 [amdgpu]
     initialize_plane+0xf1/0x280 [amdgpu]
     amdgpu_dm_init+0x23d0/0x7450 [amdgpu]
     dm_hw_init+0x3d/0x200 [amdgpu]
     amdgpu_device_init+0x67cd/0x9b20 [amdgpu]
     amdgpu_driver_load_kms+0x13/0xf0 [amdgpu]
     amdgpu_pci_probe+0x437/0xf30 [amdgpu]
     local_pci_probe+0xda/0x180
     pci_device_probe+0x381/0x730
     really_probe+0x1da/0x970
     __driver_probe_device+0x18c/0x3e0

Could it be a false positive, or leaking later after the success path, 
or some other path I am not sure since I am not at home in this code.

There is no error checking on list->name either, so I supppose the code 
which can touch that can handle a NULL harmlessly?

Regards,

Tvrtko

> +	}
> +
> +	ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
> +	if (ret)
> +		goto cleanup;
> +
> +	drm_colorop_set_next_property(ops[i-1], ops[i]);
> +
> +	i++;
> +
>   	/* 1D curve - SHAPER TF */
>   	ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
>   	if (!ops[i]) {


  reply	other threads:[~2025-12-19 12:41 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-15  0:01 [PATCH V13 00/51][FINAL] Color Pipeline API w/ VKMS Alex Hung
2025-11-15  0:01 ` [PATCH V13 01/51] drm: Add helper for conversion from signed-magnitude Alex Hung
2025-11-15  0:01 ` [PATCH V13 02/51] drm/vkms: Add kunit tests for VKMS LUT handling Alex Hung
2025-11-15  0:01 ` [PATCH V13 03/51] drm/doc/rfc: Describe why prescriptive color pipeline is needed Alex Hung
2025-11-15  0:01 ` [PATCH V13 04/51] drm/colorop: Introduce new drm_colorop mode object Alex Hung
2025-11-15  0:01 ` [PATCH V13 05/51] drm/colorop: Add TYPE property Alex Hung
2025-11-15  0:01 ` [PATCH V13 06/51] drm/colorop: Add 1D Curve subtype Alex Hung
2025-12-16 18:19   ` Nícolas F. R. A. Prado
2025-12-17  1:06     ` Alex Hung
2025-12-19 13:18       ` Borah, Chaitanya Kumar
2025-11-15  0:01 ` [PATCH V13 07/51] drm/colorop: Add BYPASS property Alex Hung
2025-11-15  0:01 ` [PATCH V13 08/51] drm/colorop: Add NEXT property Alex Hung
2025-11-15  0:01 ` [PATCH V13 09/51] drm/colorop: Add atomic state print for drm_colorop Alex Hung
2025-11-15  0:01 ` [PATCH V13 10/51] drm/plane: Add COLOR PIPELINE property Alex Hung
2025-11-15  0:01 ` [PATCH V13 11/51] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Alex Hung
2025-11-15  0:01 ` [PATCH V13 12/51] Documentation/gpu: document drm_colorop Alex Hung
2025-11-15  0:01 ` [PATCH V13 13/51] drm/colorop: Add destroy functions for color pipeline Alex Hung
2025-11-15  0:01 ` [PATCH V13 14/51] drm/vkms: Pass plane_cfg to plane initialization Alex Hung
2025-11-15  0:01 ` [PATCH V13 15/51] drm/vkms: Add enumerated 1D curve colorop Alex Hung
2025-12-16 18:26   ` Nícolas F. R. A. Prado
2025-12-17  1:10     ` Alex Hung
2025-11-15  0:01 ` [PATCH V13 16/51] drm/vkms: Add config for default plane pipeline Alex Hung
2025-11-15  0:01 ` [PATCH V13 17/51] drm/vkms: Add kunit tests for linear and sRGB LUTs Alex Hung
2025-11-15  0:01 ` [PATCH V13 18/51] drm/colorop: Add 3x4 CTM type Alex Hung
2025-11-15  0:01 ` [PATCH V13 19/51] drm/vkms: Use s32 for internal color pipeline precision Alex Hung
2025-11-15  0:01 ` [PATCH V13 20/51] drm/vkms: add 3x4 matrix in color pipeline Alex Hung
2025-11-15  0:01 ` [PATCH V13 21/51] drm/tests: Add a few tests around drm_fixed.h Alex Hung
2025-11-15  0:01 ` [PATCH V13 22/51] drm/vkms: Add tests for CTM handling Alex Hung
2025-11-15  0:01 ` [PATCH V13 23/51] drm/colorop: pass plane_color_pipeline client cap to atomic check Alex Hung
2025-11-15  0:01 ` [PATCH V13 24/51] drm/colorop: define a new macro for_each_new_colorop_in_state Alex Hung
2025-11-15  0:01 ` [PATCH V13 25/51] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Alex Hung
2025-11-15  0:01 ` [PATCH V13 26/51] drm/amd/display: Add bypass COLOR PIPELINE Alex Hung
2025-11-15  0:01 ` [PATCH V13 27/51] drm/amd/display: Skip color pipeline initialization for cursor plane Alex Hung
2025-11-15  0:01 ` [PATCH V13 28/51] drm/amd/display: Add support for sRGB EOTF in DEGAM block Alex Hung
2025-11-15  0:01 ` [PATCH V13 29/51] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Alex Hung
2025-11-15  0:01 ` [PATCH V13 30/51] drm/amd/display: Add support for sRGB EOTF in BLND block Alex Hung
2025-11-15  0:01 ` [PATCH V13 31/51] drm/colorop: Add PQ 125 EOTF and its inverse Alex Hung
2025-11-15  0:01 ` [PATCH V13 32/51] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Alex Hung
2025-11-15  0:01 ` [PATCH V13 33/51] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Alex Hung
2025-11-15  0:01 ` [PATCH V13 34/51] drm/amd/display: Add support for BT.709 and BT.2020 TFs Alex Hung
2025-11-15  0:02 ` [PATCH V13 35/51] drm: Add Enhanced LUT precision structure Alex Hung
2025-11-15  0:02 ` [PATCH V13 36/51] drm: Add helper to extract lut from struct drm_color_lut32 Alex Hung
2025-11-15  0:02 ` [PATCH V13 37/51] drm/colorop: Add 1D Curve Custom LUT type Alex Hung
2025-11-15  0:02 ` [PATCH V13 38/51] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Alex Hung
2025-11-15  0:02 ` [PATCH V13 39/51] drm/amd/display: add 3x4 matrix colorop Alex Hung
2025-12-19 12:41   ` Tvrtko Ursulin [this message]
2025-12-19 13:10     ` Borah, Chaitanya Kumar
2025-11-15  0:02 ` [PATCH V13 40/51] drm/colorop: Add multiplier type Alex Hung
2025-11-15  0:02 ` [PATCH V13 41/51] drm/amd/display: add multiplier colorop Alex Hung
2025-11-15  0:02 ` [PATCH V13 42/51] drm/amd/display: Swap matrix and multiplier Alex Hung
2025-11-15  0:02 ` [PATCH V13 43/51] drm/colorop: Define LUT_1D interpolation Alex Hung
2025-11-15  0:02 ` [PATCH V13 44/51] drm/colorop: allow non-bypass colorops Alex Hung
2025-11-15  0:02 ` [PATCH V13 45/51] drm/colorop: Add 3D LUT support to color pipeline Alex Hung
2025-11-15  0:02 ` [PATCH V13 46/51] drm/amd/display: add 3D LUT colorop Alex Hung
2025-11-15  0:02 ` [PATCH V13 47/51] drm/amd/display: Add AMD color pipeline doc Alex Hung
2025-11-15  0:02 ` [PATCH V13 48/51] drm/amd/display: Ensure 3D LUT for color pipeline Alex Hung
2025-11-15  0:02 ` [PATCH V13 49/51] drm/amd/display: Disable CRTC degamma when color pipeline is enabled Alex Hung
2026-02-10 10:52   ` Michel Dänzer
2025-11-15  0:02 ` [PATCH V13 50/51] drm/colorop: Add DRM_COLOROP_1D_CURVE_GAMMA22 to 1D Curve Alex Hung
2025-11-15  0:02 ` [PATCH V13 51/51] drm/amd/display: Enable support for Gamma 2.2 Alex Hung
2025-11-20 20:11 ` [PATCH V13 00/51][FINAL] Color Pipeline API w/ VKMS Harry Wentland
2025-11-21  9:13   ` Louis Chauvet
2025-11-21 13:53     ` Harry Wentland
2025-11-24 14:59       ` Alex Deucher
2025-11-25 18:43       ` Harry Wentland
2025-11-26 10:53         ` Louis Chauvet
2025-11-26 15:20           ` Harry Wentland
2025-11-26 22:39             ` Simon Ser
2025-11-26 22:47               ` Harry Wentland
2025-11-26 22:38           ` Simon Ser
2025-11-26 22:46             ` Harry Wentland
2025-11-27  8:36             ` Louis Chauvet
2025-11-21 17:50   ` Xaver Hugl
2025-11-26 11:07   ` Daniel Stone
2025-11-26 22:50     ` Harry Wentland

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=83bf2281-e604-48fd-a8ff-533ae86bc52e@ursulin.net \
    --to=tursulin@ursulin.net \
    --cc=Liviu.Dudau@arm.com \
    --cc=agoins@nvidia.com \
    --cc=aleixpol@kde.org \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arthurgrillo@riseup.net \
    --cc=chaitanya.kumar.borah@intel.com \
    --cc=contact@emersion.fr \
    --cc=daniel@ffwll.ch \
    --cc=daniels@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=jadahl@redhat.com \
    --cc=joshua@froggi.es \
    --cc=leo.liu@amd.com \
    --cc=louis.chauvet@bootlin.com \
    --cc=marcan@marcan.st \
    --cc=mcanal@igalia.com \
    --cc=mdaenzer@redhat.com \
    --cc=mwen@igalia.com \
    --cc=nfraprado@collabora.com \
    --cc=pekka.paalanen@collabora.com \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_cbraga@quicinc.com \
    --cc=quic_naseer@quicinc.com \
    --cc=sashamcintosh@google.com \
    --cc=sebastian.wick@redhat.com \
    --cc=shashank.sharma@amd.com \
    --cc=uma.shankar@intel.com \
    --cc=victoria@system76.com \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wayland-devel@lists.freedesktop.org \
    --cc=xaver.hugl@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox