AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v12 04/12] drm/amd: add luminance property support
Date: Thu, 19 Nov 2026 23:52:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-224220@kernel.org> (raw)
In-Reply-To: <20261119-superm1-backlight-property-v12-4-89d5217d3618@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: brightness race in
  amdgpu_dm_atomic_commit_tail()
- [Low] drm/amd/display: duplicate drmm_mode_config_init() in backlight
  KUnit tests
--

commit 846a4ea0302b706193f324593664f491fbb89bfe
Author: Mario Limonciello <mario.limonciello@amd.com>

drm/amd: add luminance property support

This commit exposes the DRM LUMINANCE connector property for internal
panels when CONFIG_DRM_LUMINANCE is enabled and updates the backlight
KUnit fixtures.

> 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 56fca4e22df8d..8b5dde608266a 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
[ ... ]
> @@ -5188,6 +5189,13 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
>  		amdgpu_dm_commit_streams(state, dc_state);
>  	}
>  
> +	/*
> +	 * Apply connector luminance now that the streams are committed. Display
> +	 * Core resets the panel brightness when it enables a stream, and the
> +	 * helper reprograms LUMINANCE panels after a modeset.
> +	 */
> +	drm_atomic_helper_commit_luminance_enables(state);
> +
>  	amdgpu_dm_update_hdcp(state);
>  
>  	/* Handle connector state changes */
> @@ -5415,8 +5423,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
>  
>  	/* restore the backlight level */
>  	for (i = 0; i < dm->num_of_edps; i++) {
> -		if (dm->backlight_dev[i] &&
> -		    (dm->actual_brightness[i] != dm->brightness[i]))
> +		if ((dm->backlight_dev[i] || dm->luminance[i]) &&
> +		    dm->actual_brightness[i] != dm->brightness[i])
>  			amdgpu_dm_backlight_set_level(dm, i, dm->brightness[i]);
>  	}
>  

[Severity: Medium]
Can the unlocked retry loop at the end of amdgpu_dm_atomic_commit_tail()
race with a concurrent luminance commit and overwrite a newer brightness
level with a stale one?

Fast atomic updates on disjoint CRTCs run amdgpu_dm_atomic_commit_tail()
concurrently without taking the global dm.atomic_obj lock.  Inside
amdgpu_dm_backlight_set_level(), dm->brightness[bl_idx] is updated before
acquiring dm->dc_lock, while dm->actual_brightness[bl_idx] is updated only
after releasing dm->dc_lock:

CPU0 (eDP panel commit)           CPU1 (other CRTC commit)
amdgpu_dm_atomic_commit_tail()
  ...
  amdgpu_dm_backlight_set_level(..., B1)
    dm->brightness[0] = B1;
    mutex_lock(&dm->dc_lock);
                                  amdgpu_dm_atomic_commit_tail()
                                    /* actual_brightness[0] != B1 */
                                    val = dm->brightness[0]; /* B1 */
    ...
    mutex_unlock(&dm->dc_lock);
    dm->actual_brightness[0] = B1;

/* next luminance commit B2 on CPU0 */
amdgpu_dm_atomic_commit_tail()
  ...
  amdgpu_dm_backlight_set_level(..., B2)
    dm->brightness[0] = B2;
    ...
    dm->actual_brightness[0] = B2;
                                    amdgpu_dm_backlight_set_level(..., B1)
                                      dm->brightness[0] = B1;
                                        <-- overwrites B2 with stale B1

This leaves the panel hardware brightness and dm->brightness[0] out of
sync with connector->state->luminance.  In addition, when CPU1 runs
amdgpu_dm_backlight_set_level() after CPU0 has already finished
amdgpu_dm_commit_planes(), it re-asserts psr_event_hw_programming and
replay_event_hw_programming with no subsequent plane flip to clear them,
keeping PSR and Replay disabled until a later flip.

> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
> index 8fc1c2f997688..c33c121a19b25 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
> @@ -37,16 +37,39 @@ static const struct drm_connector_funcs dm_backlight_test_connector_funcs = {
[ ... ]
>  static void setup_test_connector(struct kunit *test,
>  				 struct dm_backlight_connector_fixture *fixture,
>  				 int bl_idx, enum signal_type signal)
>  {
> -	fixture->adev = kunit_kzalloc(test, sizeof(*fixture->adev), GFP_KERNEL);
> -	fixture->aconnector = kunit_kzalloc(test, sizeof(*fixture->aconnector), GFP_KERNEL);
> +	int ret;
> +
> +	fixture->adev = dm_kunit_alloc_adev(test);
> +	ret = drmm_mode_config_init(&fixture->adev->ddev);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
[ ... ]
> @@ -483,12 +506,17 @@ static void dm_test_register_backlight_device_success(struct kunit *test)
>  	struct dc_link *link = dm_kunit_alloc_link(test);
>  	struct drm_minor *primary;
>  	unsigned int max;
> +	int ret;
> +
> +	ret = drmm_mode_config_init(&adev->ddev);
> +	KUNIT_ASSERT_EQ(test, ret, 0);

[Severity: Low]
Does calling drmm_mode_config_init() in setup_test_connector() and
dm_test_register_backlight_device_success() reinitialize mode_config a
second time and leak the standard DRM properties?

dm_kunit_alloc_adev() allocates the DRM device through
__drm_kunit_helper_alloc_drm_device() ->
__drm_kunit_helper_alloc_drm_device_with_driver(), which already calls
drmm_mode_config_init() when DRIVER_MODESET is set.  Calling
drmm_mode_config_init() again overwrites mode_config.property_list and
mode_config.object_idr in place, leaking the standard properties allocated
by the first call and registering a second drm_mode_config_init_release
cleanup action.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-superm1-backlight-property-v12-0-89d5217d3618@amd.com?part=4

  reply	other threads:[~2026-11-19 23:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 23:27 [PATCH v12 00/12] Add support for a DRM backlight capability Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 01/12] drm: add connector LUMINANCE property Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 02/12] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 03/12] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 04/12] drm/amd: add luminance property support Mario Limonciello
2026-11-19 23:52   ` sashiko-bot [this message]
2026-11-19 23:27 ` [PATCH v12 05/12] drm/i915/display: " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 06/12] drm/bridge: add connector luminance operations Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 07/12] drm/panel: add connector luminance forwarding Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 08/12] drm/bridge_connector: add luminance support Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 09/12] drm/nouveau: add connector " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 10/12] drm/gud: " Mario Limonciello
2026-11-19 23:43   ` sashiko-bot
2026-11-19 23:27 ` [PATCH v12 11/12] drm/bridge: add PS8622 " Mario Limonciello
2026-11-19 23:27 ` [PATCH v12 12/12] drm/solomon: add SSD130x " Mario Limonciello

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=sashiko-outbox-224220@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=mario.limonciello@amd.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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