[PATCH v2 2/2] drm/amd/display: Add a trace event for brightness programming

Alex Hung alex.hung at amd.com
Mon Jun 23 22:00:06 UTC 2025


Reviewed-by: Alex Hung <alex.hung at amd.com>

On 6/23/25 11:11, Mario Limonciello wrote:
> [Why]
> Brightness programming may involve a conversion of a user requested
> brightness against what was in a custom brightness curve. The values
> might not match what a user programmed.
> 
> [How]
> Add a new trace event to show specific converted brightness values.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
> ---
>   Documentation/gpu/amdgpu/debugging.rst        | 18 +++++++++++++
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  8 ++++++
>   .../amd/display/amdgpu_dm/amdgpu_dm_trace.h   | 26 +++++++++++++++++++
>   3 files changed, 52 insertions(+)
> 
> diff --git a/Documentation/gpu/amdgpu/debugging.rst b/Documentation/gpu/amdgpu/debugging.rst
> index 7cbfea0606e1..ac914d524741 100644
> --- a/Documentation/gpu/amdgpu/debugging.rst
> +++ b/Documentation/gpu/amdgpu/debugging.rst
> @@ -85,3 +85,21 @@ UMR
>   GPU debugging and diagnostics tool.  Please see the umr
>   `documentation <https://umr.readthedocs.io/en/main/>`_ for more information
>   about its capabilities.
> +
> +Debugging backlight brightness
> +==============================
> +Default backlight brightness is intended to be set via the policy advertised
> +by the firmware.  Firmware will often provide different defaults for AC or DC.
> +Furthermore, some userspace software will save backlight brightness during
> +the previous boot and attempt to restore it.
> +
> +Some firmware also has support for a feature called "Custom Backlight Curves"
> +where an input value for brightness is mapped along a linearly interpolated
> +curve of brightness values that better match display characteristics.
> +
> +In the event of problems happening with backlight, there is a trace event
> +that can be enabled at bootup to log every brightness change request.
> +This can help isolate where the problem is. To enable the trace event add
> +the following to the kernel command line:
> +
> +  tp_printk trace_event=amdgpu_dm:amdgpu_dm_brightness:mod:amdgpu trace_buf_size=1M
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 77302caaf24a..2ac5cd225781 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4860,6 +4860,14 @@ static void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
>   		reallow_idle = true;
>   	}
>   
> +	if (trace_amdgpu_dm_brightness_enabled()) {
> +		trace_amdgpu_dm_brightness(__builtin_return_address(0),
> +					   user_brightness,
> +					   brightness,
> +					   caps->aux_support,
> +					   power_supply_is_system_supplied() > 0);
> +	}
> +
>   	if (caps->aux_support) {
>   		rc = dc_link_set_backlight_level_nits(link, true, brightness,
>   						      AUX_BL_DEFAULT_TRANSITION_TIME_MS);
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
> index 4686d4b0cbad..308a36176bd2 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_trace.h
> @@ -726,6 +726,32 @@ TRACE_EVENT(dcn_optc_lock_unlock_state,
>   	    )
>   );
>   
> +TRACE_EVENT(amdgpu_dm_brightness,
> +	TP_PROTO(void *function, u32 user_brightness, u32 converted_brightness, bool aux, bool ac),
> +	TP_ARGS(function, user_brightness, converted_brightness, aux, ac),
> +	TP_STRUCT__entry(
> +		__field(void *, function)
> +		__field(u32, user_brightness)
> +		__field(u32, converted_brightness)
> +		__field(bool, aux)
> +		__field(bool, ac)
> +	),
> +	TP_fast_assign(
> +		__entry->function = function;
> +		__entry->user_brightness = user_brightness;
> +		__entry->converted_brightness = converted_brightness;
> +		__entry->aux = aux;
> +		__entry->ac = ac;
> +	),
> +	TP_printk("%ps: brightness requested=%u converted=%u aux=%s power=%s",
> +		  (void *)__entry->function,
> +		  (u32)__entry->user_brightness,
> +		  (u32)__entry->converted_brightness,
> +		  (__entry->aux) ? "true" : "false",
> +		  (__entry->ac) ? "AC" : "DC"
> +	)
> +);
> +
>   #endif /* _AMDGPU_DM_TRACE_H_ */
>   
>   #undef TRACE_INCLUDE_PATH



More information about the amd-gfx mailing list