drm/atomic: track individual colorop updates
Subsystems (5)
v9 cover drm/atomic: track individual colorop updates
This version is just a rebase on top of drm-misc-fixes instead of drm-misc-next. The entire set of fixes targets issues in commits that are in the kernel v6.18, but the second patch conflicts with:
- 8e135a47d35 ("drm/colorop: Rename __drm_colorop_state_reset()")
- 5164f7e7ff8 ("drm: Rename struct drm_atomic_state to drm_atomic_commit")
- 0c44d8dc6df ("drm/atomic: prefer drm_printf_indent() over inline \t")
This series is a partial of [1], only with patches related to individual colorop update tracking. I.e., I'm detaching from here fixes regarding attempts of changing colorops that are not part of an active color pipeline, or in the transition between active and inactive color pipelines.
This series focus on tracking updates for each individual color operation, allowing the driver to react accordingly. This new version just adds r-b and Fixes tag accordingly. During the Display Next Hackfest we also agree that it should be applied to drm-misc-fixes and it can be backported by AMD after.
- Patches 1 and 2 make lut1d_interpolation and lut3d_interpolation colorops correctly behave as mutable, handling their changes via drm_colorop_state.
- Patches 3 and 4 track colorop updates of a given plane color pipeline by setting plane color_mgmt_changed flag, similar to what is done for tracking CRTC color mgmt property changes with CRTC color_mgmt_changed flag. The flag also tracks when a different color pipeline is set to a given plane, but doesn't consider as a change when the same color pipeline value is set to the plane COLOR_PIPELINE prop. That way, the driver can react accordingly and update their color blocks. As interpolation properties become mutable, they are also tracked here.
It also fixes shaper/3D LUT updates when changing night mode settings on gamescope with a custom branch that supports COLOR_PIPELINE:
- https://github.com/ValveSoftware/gamescope/pull/2113
v1: https://lore.kernel.org/dri-devel/[email protected]/
Changes:
- include linux types for function's bool return type (kernel bot on MSM driver)
- add Harry's r-b tags
v2: https://lore.kernel.org/dri-devel/[email protected]/
Changes:
- [NEW] two patches to only consider colorop updates from active color pipelines (Chaitanya)
- [NEW] make lut interpolation properties mutable + Alex H patch for kernel docs
- track lut(1/3)d_interpolation updates (Chaitanya)
- rebase changes according to new patches
v3: https://lore.kernel.org/dri-devel/[email protected]/
Changes: rebase on drm-misc-next
v4: https://lore.kernel.org/dri-devel/[email protected]/
Changes: fix kernel doc (kernel bot)
v5: https://lore.kernel.org/dri-devel/[email protected]/
Changes:
- rebase on drm-misc-next
- fix kernel-doc and correctly reword (atomic) state to plane_state (Chaitanya)
- reject inactive colorop updates in atomic check time, instead of during property's setup, to avoid ordering dependency as pointed out by Chaitanya
- use |= replaced for consistency (Chaitanya)
- add Chaitanya's r-b tags to patches 1,3-5
[1] v6: https://lore.kernel.org/dri-devel/[email protected]/
Changes:
- detach patches that implement individual tracking from those related to inactive colorop updates.
v7: https://lore.kernel.org/dri-devel/[email protected]/
Changes:
- add Fixes and r-b tags
v8: https://lore.kernel.org/dri-devel/[email protected]/
Changes:
- moving from drm-misc-next to drm-misc-fixes
Alex Hung (1):
drm/colorop: Remove read-only comments from interpolation fields
Melissa Wen (3):
drm/colorop: make lut(1/3)d_interpolation props correctly behave as
mutable
drm/atomic: track individual colorop updates drm/amd/display: use plane color_mgmt_changed to track colorop changes
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +- drivers/gpu/drm/drm_atomic.c | 4 +- drivers/gpu/drm/drm_atomic_uapi.c | 68 +++++++++++++++---- drivers/gpu/drm/drm_colorop.c | 16 ++++- include/drm/drm_atomic_uapi.h | 4 +- include/drm/drm_colorop.h | 34 +++++----- 6 files changed, 93 insertions(+), 39 deletions(-)
Signature · 1 line
2.53.0
PATCH v9 1/4 drm/colorop: Remove read-only comments from interpolation fields
From: Alex Hung <[email protected]>
The lut1d_interpolation and lut3d_interpolation fields and their associated properties were marked as read-only, but userspace can set them via drm_atomic_colorop_set_property().
--- include/drm/drm_colorop.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
include/drm/drm_colorop.h +2 -4
@@ -309,7 +309,6 @@ struct drm_colorop {/** * @lut1d_interpolation: * -* Read-only * Interpolation for DRM_COLOROP_1D_LUT */ enum drm_colorop_lut1d_interpolation_type lut1d_interpolation;
@@ -317,7 +316,6 @@ struct drm_colorop {/** * @lut3d_interpolation: * -* Read-only * Interpolation for DRM_COLOROP_3D_LUT */ enum drm_colorop_lut3d_interpolation_type lut3d_interpolation;
@@ -325,7 +323,7 @@ struct drm_colorop {/** * @lut1d_interpolation_property: * -* Read-only property for DRM_COLOROP_1D_LUT interpolation +* Property for DRM_COLOROP_1D_LUT interpolation */ struct drm_property *lut1d_interpolation_property;
@@ -353,7 +351,7 @@ struct drm_colorop {/** * @lut3d_interpolation_property: * -* Read-only property for DRM_COLOROP_3D_LUT interpolation +* Property for DRM_COLOROP_3D_LUT interpolation */ struct drm_property *lut3d_interpolation_property;
Signature · 1 line
2.53.0
PATCH v9 2/4 drm/colorop: make lut(1/3)d_interpolation props correctly behave as mutable
In reply to Melissa WenAs interpolation props are actually mutable props, any changes should be handled by drm_colorop_state. Move their enum and make it correctly behaves as mutable.
--- drivers/gpu/drm/drm_atomic.c | 4 ++-- drivers/gpu/drm/drm_atomic_uapi.c | 8 ++++---- drivers/gpu/drm/drm_colorop.c | 16 ++++++++++++++-- include/drm/drm_colorop.h | 28 ++++++++++++++-------------- 4 files changed, 34 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_atomic.c +2 -2
@@ -830,7 +830,7 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,case DRM_COLOROP_1D_LUT :drm_printf (p,"\tsize=%d\n" , colorop->size);drm_printf (p,"\tinterpolation=%s\n" , -drm_get_colorop_lut1d_interpolation_name (colorop->lut1d_interpolation)); +drm_get_colorop_lut1d_interpolation_name (state->lut1d_interpolation));drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 );break ;case DRM_COLOROP_CTM_3X4 :
@@ -842,7 +842,7 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,case DRM_COLOROP_3D_LUT :drm_printf (p,"\tsize=%d\n" , colorop->size);drm_printf (p,"\tinterpolation=%s\n" , -drm_get_colorop_lut3d_interpolation_name (colorop->lut3d_interpolation)); +drm_get_colorop_lut3d_interpolation_name (state->lut3d_interpolation));drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 );break ;default :
drivers/gpu/drm/drm_atomic_uapi.c +4 -4
@@ -751,13 +751,13 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,if (property == colorop->bypass_property) { state->bypass = val; }else if (property == colorop->lut1d_interpolation_property) { - colorop->lut1d_interpolation = val; + state->lut1d_interpolation = val; }else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; }else if (property == colorop->multiplier_property) { state->multiplier = val; }else if (property == colorop->lut3d_interpolation_property) { - colorop->lut3d_interpolation = val; + state->lut3d_interpolation = val; }else if (property == colorop->data_property) {return drm_atomic_color_set_data_property (colorop, state, property, val);
@@ -782,7 +782,7 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,else if (property == colorop->bypass_property) *val = state->bypass;else if (property == colorop->lut1d_interpolation_property) - *val = colorop->lut1d_interpolation; + *val = state->lut1d_interpolation;else if (property == colorop->curve_1d_type_property) *val = state->curve_1d_type;else if (property == colorop->multiplier_property)
@@ -790,7 +790,7 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,else if (property == colorop->size_property) *val = colorop->size;else if (property == colorop->lut3d_interpolation_property) - *val = colorop->lut3d_interpolation; + *val = state->lut3d_interpolation;else if (property == colorop->data_property) *val = (state->data) ? state->data->base.id :0 ;else
drivers/gpu/drm/drm_colorop.c +14 -2
@@ -342,7 +342,6 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color colorop->lut1d_interpolation_property = prop;drm_object_attach_property (&colorop->base, prop, interpolation); - colorop->lut1d_interpolation = interpolation;/* data */ ret =drm_colorop_create_data_prop (dev, colorop);
@@ -442,7 +441,6 @@ int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *col colorop->lut3d_interpolation_property = prop;drm_object_attach_property (&colorop->base, prop, interpolation); - colorop->lut3d_interpolation = interpolation;/* data */ ret =drm_colorop_create_data_prop (dev, colorop);
@@ -521,6 +519,20 @@ static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, &val); colorop_state->curve_1d_type = val; } + +if (colorop->lut1d_interpolation_property) { +if (!drm_object_property_get_default_value (&colorop->base, + colorop->lut1d_interpolation_property, + &val)) + colorop_state->lut1d_interpolation = val; + } + +if (colorop->lut3d_interpolation_property) { +if (!drm_object_property_get_default_value (&colorop->base, + colorop->lut3d_interpolation_property, + &val)) + colorop_state->lut3d_interpolation = val; + } }/**
include/drm/drm_colorop.h +14 -14
@@ -183,6 +183,20 @@ struct drm_colorop_state {*/ struct drm_property_blob *data; +/** +* @lut1d_interpolation: +* +* Interpolation for DRM_COLOROP_1D_LUT +*/ +enum drm_colorop_lut1d_interpolation_type lut1d_interpolation; + +/** +* @lut3d_interpolation: +* +* Interpolation for DRM_COLOROP_3D_LUT +*/ +enum drm_colorop_lut3d_interpolation_type lut3d_interpolation; +/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; };
@@ -306,20 +320,6 @@ struct drm_colorop {*/ uint32_t size; -/** -* @lut1d_interpolation: -* -* Interpolation for DRM_COLOROP_1D_LUT -*/ -enum drm_colorop_lut1d_interpolation_type lut1d_interpolation; - -/** -* @lut3d_interpolation: -* -* Interpolation for DRM_COLOROP_3D_LUT -*/ -enum drm_colorop_lut3d_interpolation_type lut3d_interpolation; -/** * @lut1d_interpolation_property: *
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v9 2/4] drm/colorop: make lut(1/3)d_interpolation props correctly behave as mutable
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The function drm_colorop_atomic_destroy_state frees the drm_colorop_state struct without releasing the reference to the state->data blob, leading to a memory leak of drm_property_blob objects.
- [High] __drm_atomic_helper_colorop_duplicate_state unconditionally resets bypass = true, destroying user state.
--
commit af8aea1831e57bd16ec95c73773d4e52e3faa54a
Author: Melissa Wen <[email protected]>
Subject: drm/colorop: make lut(1/3)d_interpolation props correctly behave as mutable
This commit moves the interpolation properties into drm_colorop_state so they can correctly behave as mutable properties. It updates the getters, setters, and state printing to use the state objects instead of the base colorop.
Quoted 4 lines
drivers/gpu/drm/drm_colorop.c +0
-0
[ ... ]
Quoted 9 lines
drivers/gpu/drm/drm_colorop.c +5
-0@@ -488,6 +486,20 @@ static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, &val); colorop_state->curve_1d_type = val; } + +if (colorop->lut1d_interpolation_property) { +if (!drm_object_property_get_default_value (&colorop->base, + colorop->lut1d_interpolation_property, + &val))
drivers/gpu/drm/drm_colorop.c static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state, · line 503
Quoted 10 lines
drivers/gpu/drm/drm_colorop.c +9
-0+ colorop_state->lut1d_interpolation = val; + } + +if (colorop->lut3d_interpolation_property) { +if (!drm_object_property_get_default_value (&colorop->base, + colorop->lut3d_interpolation_property, + &val)) + colorop_state->lut3d_interpolation = val; + } }
[Severity: High]
This isn't a bug introduced by this patch, but does drm_colorop_atomic_destroy_state() leak the state->data blob reference?
During atomic state duplication, a reference is taken on the data blob:
static void __drm_atomic_helper_colorop_duplicate_state(...)
{
...
if (state->data)
drm_property_blob_get(state->data);
...
}However, the destruction function frees the state without dropping this reference:
void drm_colorop_atomic_destroy_state(...)
{
kfree(state);
}Could this leak system memory on every atomic commit that includes the colorop? Is it possible this also happens in drm_colorop_reset() when it calls kfree() on colorop->state?
[Severity: High]
This is also a pre-existing issue, but does __drm_atomic_helper_colorop_duplicate_state() corrupt the user state by forcing bypass to true?
static void __drm_atomic_helper_colorop_duplicate_state(...)
{
memcpy(state, colorop->state, sizeof(*state));
...
state->bypass = true;
}If userspace configures a color pipeline with bypass = false, will a subsequent unrelated atomic commit (like moving a cursor or doing a pageflip) that duplicates the colorop state inadvertently reset bypass back to true?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v9 3/4 drm/atomic: track individual colorop updates
In reply to Melissa WenAs we do for CRTC color mgmt properties, use color_mgmt_changed flag to track any value changes in the color pipeline of a given plane, so that drivers can update color blocks as soon as plane color pipeline or individual colorop values change. Since we're here, only announce and track changes to plane COLOR_PIPELINE prop if its value is actually changing.
--- drivers/gpu/drm/drm_atomic_uapi.c | 64 ++++++++++++++++++++++++------- include/drm/drm_atomic_uapi.h | 4 +- 2 files changed, 54 insertions(+), 14 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +51 -13
@@ -265,13 +265,19 @@ EXPORT_SYMBOL(drm_atomic_set_fb_for_plane);* * Helper function to select the color pipeline on a plane by setting * it to the first drm_colorop element of the pipeline. +* +* Return: true if plane color pipeline value changed, false otherwise. */ -void +bool drm_atomic_set_colorop_for_plane (struct drm_plane_state *plane_state,struct drm_colorop *colorop) {struct drm_plane *plane = plane_state->plane; +/* Color pipeline didn't change */ +if (plane_state->color_pipeline == colorop) +return false; +if (colorop) drm_dbg_atomic(plane->dev, "Set [COLOROP:%d] for [PLANE:%d:%s] state %p\n",
@@ -283,6 +289,8 @@ drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state, plane->base.id, plane->name, plane_state); plane_state->color_pipeline = colorop; + +return true; }EXPORT_SYMBOL (drm_atomic_set_colorop_for_plane);
@@ -604,7 +612,7 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,if (val && !colorop)return -EACCES ; -drm_atomic_set_colorop_for_plane (state, colorop); + state->color_mgmt_changed |=drm_atomic_set_colorop_for_plane (state, colorop); }else if (property == config->prop_fb_damage_clips) { ret = drm_property_replace_blob_from_id(dev, &state->fb_damage_clips,
@@ -713,11 +721,11 @@ drm_atomic_plane_get_property(struct drm_plane *plane,static int drm_atomic_color_set_data_property (struct drm_colorop *colorop,struct drm_colorop_state *state,struct drm_property *property, -uint64_t val) +uint64_t val, +bool *replaced) {ssize_t elem_size =-1 ;ssize_t size =-1 ; -bool replaced = false;switch (colorop->type) {case DRM_COLOROP_1D_LUT :
@@ -739,28 +747,45 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop, &state->data, val,-1 , size, elem_size, - &replaced); + replaced); }static int drm_atomic_colorop_set_property (struct drm_colorop *colorop,struct drm_colorop_state *state,struct drm_file *file_priv,struct drm_property *property, -uint64_t val) +uint64_t val, +bool *replaced) {if (property == colorop->bypass_property) { - state->bypass = val; +if (state->bypass != val) { + state->bypass = val; + *replaced = true; + } }else if (property == colorop->lut1d_interpolation_property) { - state->lut1d_interpolation = val; +if (state->lut1d_interpolation != val) { + state->lut1d_interpolation = val; + *replaced = true; + } }else if (property == colorop->curve_1d_type_property) { - state->curve_1d_type = val; +if (state->curve_1d_type != val) { + state->curve_1d_type = val; + *replaced = true; + } }else if (property == colorop->multiplier_property) { - state->multiplier = val; +if (state->multiplier != val) { + state->multiplier = val; + *replaced = true; + } }else if (property == colorop->lut3d_interpolation_property) { - state->lut3d_interpolation = val; +if (state->lut3d_interpolation != val) { + state->lut3d_interpolation = val; + *replaced = true; + } }else if (property == colorop->data_property) {return drm_atomic_color_set_data_property (colorop, state, - property, val); + property, val, + replaced); }else { drm_dbg_atomic(colorop->dev, "[COLOROP:%d:%d] unknown property [PROP:%d:%s]\n",
@@ -1275,8 +1300,10 @@ int drm_atomic_set_property(struct drm_atomic_state *state,break ; }case DRM_MODE_OBJECT_COLOROP : { +struct drm_plane_state *plane_state;struct drm_colorop *colorop =obj_to_colorop (obj);struct drm_colorop_state *colorop_state; +bool replaced = false; colorop_state =drm_atomic_get_colorop_state (state, colorop);if (IS_ERR (colorop_state)) {
@@ -1285,7 +1312,18 @@ int drm_atomic_set_property(struct drm_atomic_state *state, } ret =drm_atomic_colorop_set_property (colorop, colorop_state, - file_priv, prop, prop_value); + file_priv, prop, prop_value, + &replaced); +if (ret || !replaced) +break ; + + plane_state =drm_atomic_get_plane_state (state, colorop->plane); +if (IS_ERR (plane_state)) { + ret =PTR_ERR (plane_state); +break ; + } + plane_state->color_mgmt_changed |= replaced; +break ; }default :
include/drm/drm_atomic_uapi.h +3 -1
@@ -29,6 +29,8 @@#ifndef DRM_ATOMIC_UAPI_H_ #define DRM_ATOMIC_UAPI_H_ +#include <linux/types.h> +struct drm_crtc_state ;struct drm_display_mode ;struct drm_property_blob ;
@@ -50,7 +52,7 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state, struct drm_crtc *crtc);void drm_atomic_set_fb_for_plane (struct drm_plane_state *plane_state,struct drm_framebuffer *fb); -void drm_atomic_set_colorop_for_plane (struct drm_plane_state *plane_state, +bool drm_atomic_set_colorop_for_plane (struct drm_plane_state *plane_state,struct drm_colorop *colorop); int __must_check drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing async_flip validation for DRM_MODE_OBJECT_COLOROP allows colorop properties to be modified during async page flips, resulting in silently discarded updates.
- [High] Leaked drm_property_blob references in colorop state destruction.
--
commit e431074495b7fd11806af7e6be2bb0ec2ea72838
Author: Melissa Wen <[email protected]>
drm/atomic: track individual colorop updates
As we do for CRTC color mgmt properties, this commit uses the color_mgmt_changed flag to track value changes in the color pipeline of a given plane. This allows drivers to update color blocks as soon as plane color pipeline or individual colorop values change.
Quoted 4 lines
drivers/gpu/drm/drm_atomic_uapi.c +0
-0
[ ... ]
drivers/gpu/drm/drm_atomic_uapi.c int drm_atomic_set_property(struct drm_atomic_state *state, · line 1300
Quoted 6 lines
drivers/gpu/drm/drm_atomic_uapi.c +1
-0@@ -1271,8 +1296,10 @@ int drm_atomic_set_property(struct drm_atomic_state *state,break ; }case DRM_MODE_OBJECT_COLOROP : { +struct drm_plane_state *plane_state;struct drm_colorop *colorop =obj_to_colorop (obj);
[Severity: High]
This isn't a bug introduced by this patch, but does this block lack validation for async_flip?
Unlike the blocks for planes, CRTCs, and connectors, there is no check for async_flip here. If userspace submits an atomic commit with DRM_MODE_PAGE_FLIP_ASYNC that modifies colorop properties, the ioctl succeeds and modifies colorop_state inside the transaction.
However, drm_atomic_helper_async_commit() completely ignores colorops and does not swap state->colorops. Could this lead to the updated state being silently discarded and never applied to hardware, causing state divergence between userspace expectations and kernel state?
drivers/gpu/drm/drm_atomic_uapi.c int drm_atomic_set_property(struct drm_atomic_state *state, · line 1309
Quoted 5 lines
drivers/gpu/drm/drm_atomic_uapi.c +1
-0struct drm_colorop_state *colorop_state; +bool replaced = false; colorop_state =drm_atomic_get_colorop_state (state, colorop);if (IS_ERR (colorop_state)) {
[Severity: High]
This is a pre-existing issue, but is there a leaked drm_property_blob reference in colorop state destruction?
Looking at drm_colorop_atomic_destroy_state() indrivers/gpu/drm/drm_colorop.c:
void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop,
struct drm_colorop_state *state)
{
kfree(state);
}When an atomic state is committed or aborted, the atomic framework frees the associated state objects by calling their respective destroy functions. This function simply calls kfree(state) without dropping the reference to the data blob (state->data) via drm_property_blob_put().
Because drm_atomic_helper_colorop_duplicate_state() explicitly increments the blob's reference count, and property setting acquires new blob references, could failing to release the blob reference during state teardown lead to an unbounded memory leak for every atomic update touching the color pipeline?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v9 4/4 drm/amd/display: use plane color_mgmt_changed to track colorop changes
In reply to Melissa WenEnsure the driver tracks changes in any colorop property of a plane color pipeline by using the same mechanism of CRTC color management and update plane color blocks when any colorop property changes. It fixes an issue observed on gamescope settings for night mode which is done via shaper/3D-LUT updates.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -1
@@ -10067,7 +10067,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,continue ; bundle->surface_updates[planes_count].surface = dc_plane; -if (new_pcrtc_state->color_mgmt_changed) { +if (new_pcrtc_state->color_mgmt_changed || new_plane_state->color_mgmt_changed) { bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction; bundle->surface_updates[planes_count].in_transfer_func = &dc_plane->in_transfer_func; bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix;
@@ -11808,6 +11808,10 @@ static bool should_reset_plane(struct drm_atomic_state *state,if (new_crtc_state->color_mgmt_changed)return true; +/* Plane color pipeline or its colorop changes. */ +if (new_plane_state->color_mgmt_changed) +return true; +/* * On zpos change, planes need to be reordered by removing and re-adding * them one by one to the dc state, in order of descending zpos.
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v9 4/4] drm/amd/display: use plane color_mgmt_changed to track colorop changes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The logic in `should_reset_plane` fails to trigger a reset for all planes on a CRTC when another…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The logic in should_reset_plane fails to trigger a reset for all planes on a CRTC when another plane's color management changes via the new DRM Color Pipeline API, leading to plane z-order corruption. --
commit 52aefc9e9f5291e7e9724eb87eff29b790339396
Author: Melissa Wen <[email protected]>
drm/amd/display: use plane color_mgmt_changed to track colorop changes
Ensure the driver tracks changes in any colorop property of a plane color pipeline by using the same mechanism of CRTC color management and update plane color blocks when any colorop property changes.
Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0
[ ... ]
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool should_reset_plane(struct drm_atomic_state *state, · line 12216
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-0@@ -12208,6 +12208,10 @@ static bool should_reset_plane(struct drm_atomic_state *state,if (new_crtc_state->color_mgmt_changed)return true; +/* Plane color pipeline or its colorop changes. */ +if (new_plane_state->color_mgmt_changed) +return true; +/* * On zpos change, planes need to be reordered by removing and re-adding
[Severity: High]
Does this code need to check color_mgmt_changed for other planes on the CRTC as well?
Looking further down in should_reset_plane(), there is a loop over other planes that checks legacy AMD color properties, but it misses checking new_other_state->color_mgmt_changed:
for_each_oldnew_plane_in_state(state, other, old_other_state, new_other_state, i) {
...
/* HDR/Transfer Function changes. */
if (dm_old_other_state->degamma_tf != dm_new_other_state->degamma_tf ||
...If Plane A has color_mgmt_changed == true, should_reset_plane() correctly returns true and Plane A gets reset.
However, when should_reset_plane() is evaluated for Plane B on the same CRTC, it iterates over the other planes (including Plane A). Since the loop does not check Plane A's color_mgmt_changed state, it could return false for Plane B.
Could this cause only some planes on the CRTC to be removed and re-added, resulting in a scrambled hardware z-order or pipeline acquisition errors?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Patchwork
CI✗ Fi.CI.BUILD: failure for drm/atomic: track individual colorop updates
In reply to Melissa Wen== Series Details ==
== Series Details ==
Series: drm/atomic: track individual colorop updates
URL : https://patchwork.freedesktop.org/series/168172/
State : failure
== Summary ==
Error: patch https://patchwork.freedesktop.org/api/1.0/series/168172/revisions/1/mbox/ not applied
Applying: drm/colorop: Remove read-only comments from interpolation fields
Applying: drm/colorop: make lut(1/3)d_interpolation props correctly behave as mutable
error: sha1 information is lacking or useless (include/drm/drm_colorop.h).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 drm/colorop: make lut(1/3)d_interpolation props correctly behave as mutable When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced