FAILED: patch "[PATCH] drm/amd/display: Scale custom brightness curve from full" failed to apply to 6.18-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 6fd83a1c2cdea48c396f600795217fbdfb8124f6
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090900-lip-ribbon-1726@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6fd83a1c2cdea48c396f600795217fbdfb8124f6 Mon Sep 17 00:00:00 2001
From: Akhmed Zhitaev <[email protected]>
Date: Thu, 13 Aug 2026 22:09:59 +0500
Subject: [PATCH] drm/amd/display: Scale custom brightness curve from full
range
Custom brightness curves use an 8-bit input signal. After exporting the full PWM range to userspace, the curve normalizer still divides requests by the physical PWM span. On panels with a nonzero minimum PWM level, this can produce a curve input greater than 255 and send an invalid backlight level to DC.
Scale the userspace [0..max] range to the curve's [0..255] range instead. This retains the full advertised range and keeps the reverse readback conversion unchanged.
(Move to amdgpu_dm_backlight.c)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c +4 -4
@@ -106,10 +106,10 @@ int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps, }EXPORT_IF_KUNIT (get_brightness_range); -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */ -static inline u32 scale_input_to_fw (int min,int max,u64 input) +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */ +static inline u32 scale_input_to_fw (int max,u64 input) { -return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max - min); +return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max); }/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
@@ -123,7 +123,7 @@ void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps, unsigned int min, unsigned int max, uint32_t *user_brightness) { - u32 brightness = scale_input_to_fw(min, max, *user_brightness); + u32 brightness = scale_input_to_fw(max, *user_brightness);u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;int left, right;
cover drm/amd/display: Fix full-range custom brightness handling
This series backports the two changes required to make full-range backlight handling safe on 6.18.y.
Patch 1 restores the userspace [0..max] brightness range. Patch 2 fixes custom brightness curve normalization for that range.
These patches must be applied together:
- patch 1 without patch 2 can reproduce the existing high-brightness regression on panels with a non-zero minimum PWM level;
- patch 2 without patch 1 does not match the current 6.18.y userspace ABI.
The larger power-module refactor is not required for the brightness arithmetic itself.
Validation:
- make olddefconfig
- CONFIG_DRM_AMDGPU=y
- CONFIG_DRM_AMD_DC=y
- make -j$(nproc) drivers/gpu/drm/amd/amdgpu/
- git diff --check
Akhmed Zhitaev (1):
drm/amd/display: Scale custom brightness curve from full range
Mario Limonciello (1):
drm/amd/display: Fix backlight max_brightness to match exported range
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/2 drm/amd/display: Fix backlight max_brightness to match exported range
From: Mario Limonciello <[email protected]>
[ Upstream commit bd9e2b5b0473c75abc0f4134dfe79ecbfb16610d ]
[Why]
FWTS autobrightness fails on eDP panels because actual_brightness can read higher than the advertised max_brightness (e.g. 63576 vs 62451).
The conversion helpers expose the firmware PWM range to userspace as [0..max]. But max_brightness is advertised as (max - min), which is smaller. So reading the level can return a value above max_brightness.
This regressed in commit 4b61b8a39051 ("drm/amd/display: Add debugging message for brightness caps"), which changed max_brightness to (max - min) and undid commit 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace").
[How]
Advertise max_brightness as max, and scale the initial AC/DC brightness against max too. Update the KUnit expectations to match.
[ Backport note: In 6.18.y the backlight property setup still lives in
amdgpu_dm.c, so apply the same property changes there. The upstream KUnit file was introduced by a later refactoring and is not present. ]
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -3
@@ -5222,11 +5222,11 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector) caps = &dm->backlight_caps[aconnector->bl_idx];if (get_brightness_range (caps, &min, &max)) {if (power_supply_is_system_supplied () >0 ) - props.brightness =DIV_ROUND_CLOSEST ((max - min) * caps->ac_level,100 ); + props.brightness =DIV_ROUND_CLOSEST (max * caps->ac_level,100 );else - props.brightness =DIV_ROUND_CLOSEST ((max - min) * caps->dc_level,100 ); + props.brightness =DIV_ROUND_CLOSEST (max * caps->dc_level,100 );/* min is zero, so max needs to be adjusted */ - props.max_brightness = max - min; + props.max_brightness = max;drm_dbg (drm,"Backlight caps: min: %d, max: %d, ac %d, dc %d\n" , min, max, caps->ac_level, caps->dc_level); }else
Signature · 1 line
2.55.0
PATCH 2/2 drm/amd/display: Scale custom brightness curve from full range
In reply to Akhmed Zhitaev[ Upstream commit 6fd83a1c2cdea48c396f600795217fbdfb8124f6 ]
Custom brightness curves use an 8-bit input signal. After exporting the full PWM range to userspace, the curve normalizer still divides requests by the physical PWM span. On panels with a nonzero minimum PWM level, this can produce a curve input greater than 255 and send an invalid backlight level to DC.
Scale the userspace [0..max] range to the curve's [0..255] range instead. This retains the full advertised range and keeps the reverse readback conversion unchanged.
[ Backport note: In 6.18.y the brightness helpers still live in
amdgpu_dm.c, while upstream changes the later amdgpu_dm_backlight.c. Apply the same semantic change at the old location; the logic is otherwise unchanged. ]
(Move to amdgpu_dm_backlight.c)
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -4
@@ -4952,10 +4952,10 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,return 1 ; } -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */ -static inline u32 scale_input_to_fw (int min,int max,u64 input) +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */ +static inline u32 scale_input_to_fw (int max,u64 input) { -return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max - min); +return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max); }/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
@@ -4968,7 +4968,7 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap unsigned int min, unsigned int max, uint32_t *user_brightness) { - u32 brightness = scale_input_to_fw(min, max, *user_brightness); + u32 brightness = scale_input_to_fw(max, *user_brightness);u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;int left, right;
Signature · 1 line
2.55.0
Re: [PATCH 6.18.y 0/2] drm/amd/display: Fix full-range custom brightness handling
In reply to Akhmed ZhitaevQuoted 5 lines
This series backports the two changes required to make full-range backlight handling safe on 6.18.y.
Patch 1 restores the userspace [0..max] brightness range. Patch 2 fixes custom brightness curve normalization for that range.
Queued the series for 6.18, thanks.
Signature · 2 lines
Thanks, Sasha