mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Clamp the ATIF backlight curve to its 99 points
@ 2026-10-31 15:39 Hugo Sales
  2026-11-02 15:22 ` Mario Limonciello
  0 siblings, 1 reply; 4+ messages in thread
From: Hugo Sales @ 2026-10-31 15:39 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, amd-gfx
  Cc: superm1, lijo.lazar, harry.wentland, alex.hung, kees, airlied,
	simona, dri-devel, linux-kernel

amdgpu_atif_query_backlight_caps() stores the firmware's number_of_points
as data_points but copies only the 99 points that luminance_data[] holds.
number_of_points is a u8, so a firmware table that claims more makes the
custom curve code in amdgpu_dm index past the array, and
dm_query_extended_brightness_caps() copy past the end of the
data_points[] buffer it fills

Clamp the count to ATIF_QBTC_MAX_DATA_POINTS and warn, since a table
that claims more is a firmware bug

Fixes: f729e63743f0 ("drm/amd: Pass luminance data to amdgpu_dm_backlight_caps")
Signed-off-by: Hugo Sales <hugo@hsal.es>
---
The other ATIF checks log at debug level because they make the call fail
and the driver falls back to its defaults. Here the driver keeps going
with a truncated curve, so this one warns

 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 63088c072087a..4874ee864b807 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -406,7 +406,11 @@ int amdgpu_atif_query_backlight_caps(struct amdgpu_atif *atif)
 			characteristics.max_input_signal;
 	atif->backlight_caps.ac_level = characteristics.ac_level;
 	atif->backlight_caps.dc_level = characteristics.dc_level;
-	atif->backlight_caps.data_points = characteristics.number_of_points;
+	if (characteristics.number_of_points > ATIF_QBTC_MAX_DATA_POINTS)
+		pr_warn(FW_BUG "ATIF: backlight curve has %u points, using the first %u\n",
+			characteristics.number_of_points, ATIF_QBTC_MAX_DATA_POINTS);
+	atif->backlight_caps.data_points = min_t(u8, characteristics.number_of_points,
+						 ATIF_QBTC_MAX_DATA_POINTS);
 	memcpy(atif->backlight_caps.luminance_data,
 	       characteristics.data_points,
 	       sizeof(atif->backlight_caps.luminance_data));
-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: Clamp the ATIF backlight curve to its 99 points
  2026-10-31 15:39 [PATCH] drm/amdgpu: Clamp the ATIF backlight curve to its 99 points Hugo Sales
@ 2026-11-02 15:22 ` Mario Limonciello
  2026-11-02 15:37   ` Hugo Sales
  0 siblings, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2026-11-02 15:22 UTC (permalink / raw)
  To: Hugo Sales, alexander.deucher, christian.koenig, amd-gfx
  Cc: lijo.lazar, harry.wentland, alex.hung, kees, airlied, simona,
	dri-devel, linux-kernel

On 10/31/26 10:39, Hugo Sales wrote:
> amdgpu_atif_query_backlight_caps() stores the firmware's number_of_points
> as data_points but copies only the 99 points that luminance_data[] holds.
> number_of_points is a u8, so a firmware table that claims more makes the
> custom curve code in amdgpu_dm index past the array, and
> dm_query_extended_brightness_caps() copy past the end of the
> data_points[] buffer it fills
> 
> Clamp the count to ATIF_QBTC_MAX_DATA_POINTS and warn, since a table
> that claims more is a firmware bug
> 
> Fixes: f729e63743f0 ("drm/amd: Pass luminance data to amdgpu_dm_backlight_caps")
> Signed-off-by: Hugo Sales <hugo@hsal.es>
> ---
> The other ATIF checks log at debug level because they make the call fail
> and the driver falls back to its defaults. Here the driver keeps going
> with a truncated curve, so this one warns
> 
>   drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 63088c072087a..4874ee864b807 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -406,7 +406,11 @@ int amdgpu_atif_query_backlight_caps(struct amdgpu_atif *atif)
>   			characteristics.max_input_signal;
>   	atif->backlight_caps.ac_level = characteristics.ac_level;
>   	atif->backlight_caps.dc_level = characteristics.dc_level;
> -	atif->backlight_caps.data_points = characteristics.number_of_points;
> +	if (characteristics.number_of_points > ATIF_QBTC_MAX_DATA_POINTS)
> +		pr_warn(FW_BUG "ATIF: backlight curve has %u points, using the first %u\n",
> +			characteristics.number_of_points, ATIF_QBTC_MAX_DATA_POINTS);
> +	atif->backlight_caps.data_points = min_t(u8, characteristics.number_of_points,
> +						 ATIF_QBTC_MAX_DATA_POINTS);
>   	memcpy(atif->backlight_caps.luminance_data,
>   	       characteristics.data_points,
>   	       sizeof(atif->backlight_caps.luminance_data));

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

Thanks; this makes sense.  I'll get this applied to amd-staging-drm-next.

I would like to know though; did you see this in the wild?  If so I'd 
like to hear more about the system that had it and the system firmware 
on it.

What model?
What APU?
What system firmware version?
What AGESA version?

Some systems will publish this to SMBIOS and you'll see it from "dmesg | 
grep AGESA".

If it's a problem in AMD AGESA I would like to get it fixed for a future 
AGESA release.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: Clamp the ATIF backlight curve to its 99 points
  2026-11-02 15:22 ` Mario Limonciello
@ 2026-11-02 15:37   ` Hugo Sales
  2026-11-02 15:51     ` Mario Limonciello
  0 siblings, 1 reply; 4+ messages in thread
From: Hugo Sales @ 2026-11-02 15:37 UTC (permalink / raw)
  To: Mario Limonciello, alexander.deucher, christian.koenig, amd-gfx
  Cc: lijo.lazar, harry.wentland, alex.hung, kees, airlied, simona,
	dri-devel, linux-kernel

On Mon, Nov 02, 2026, Mario Limonciello wrote:
> I would like to know though; did you see this in the wild?  If so I'd
> like to hear more about the system that had it and the system firmware
> on it.

No, I haven't seen firmware do this. I found it by reading the code while
working on a series that does the intermediate calculations for the
ATIF curve at full precision, which I'll send soon

Thanks for the review,
Hugo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: Clamp the ATIF backlight curve to its 99 points
  2026-11-02 15:37   ` Hugo Sales
@ 2026-11-02 15:51     ` Mario Limonciello
  0 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2026-11-02 15:51 UTC (permalink / raw)
  To: Hugo Sales, alexander.deucher, christian.koenig, amd-gfx
  Cc: lijo.lazar, harry.wentland, alex.hung, kees, airlied, simona,
	dri-devel, linux-kernel

On 11/2/26 09:37, Hugo Sales wrote:
> On Mon, Nov 02, 2026, Mario Limonciello wrote:
>> I would like to know though; did you see this in the wild?  If so I'd
>> like to hear more about the system that had it and the system firmware
>> on it.
> 
> No, I haven't seen firmware do this. I found it by reading the code while
> working on a series that does the intermediate calculations for the
> ATIF curve at full precision, which I'll send soon
> 
> Thanks for the review,
> Hugo

Got it thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-02 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 15:39 [PATCH] drm/amdgpu: Clamp the ATIF backlight curve to its 99 points Hugo Sales
2026-11-02 15:22 ` Mario Limonciello
2026-11-02 15:37   ` Hugo Sales
2026-11-02 15:51     ` Mario Limonciello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®