Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 10/14] drm/amd/display: Update KUnit backlight tests for luminance property and fixtures
Date: Tue, 08 Sep 2026 04:54:23 +0000	[thread overview]
Message-ID: <20260908045423.7B4491F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908044035.62093-11-mario.limonciello@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Mock connectors bypass standard DRM initialization, leading to missing cleanup and leaving dangling pointers on the global `drm_backlight_list`.
- [Medium] Double initialization of `mode_config` via `drmm_mode_config_init()` overwrites lists, leaks DRM standard properties, and double-registers cleanup actions.
--

commit a56dca4aad815c6c0a1a6a861da4fc03fba94e83
Author: Mario Limonciello (AMD) <superm1@kernel.org>

    drm/amd/display: Update KUnit backlight tests for luminance property and fixtures

    Initialize backlight connector state and display manager dc_lock in
    KUnit connector and adev allocators, and update property count
    expectations in tests to account for the newly attached LUMINANCE property.

> 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 e03173d4e5bd8..c5f65e9a90ca8 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
> @@ -52,6 +52,7 @@ static void setup_test_connector(struct kunit *test,
>  	fixture->aconnector->dc_link = fixture->link;
>  	fixture->aconnector->base.dev = &fixture->adev->ddev;
>  	fixture->link->connector_signal = signal;
> +	drm_backlight_connector_init(&fixture->aconnector->base);
>  }

[Severity: High]
Does this bypass standard DRM initialization? By manually initializing the
backlight fields here (and in dm_kunit_alloc_connector()) without registering
a standard DRM lifecycle cleanup action, the mock connector avoids
drm_connector_cleanup(). 

When tests like dm_test_register_backlight_device_success() later call
amdgpu_dm_register_backlight_device() and link it into drm_backlight_list, does
the lack of cleanup leave a dangling pointer on the global list after the KUnit
test finishes and frees the mock connector?

[ ... ]
> @@ -483,12 +484,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: Medium]
Is this call to drmm_mode_config_init() redundant and potentially harmful?

The DRM device adev is allocated via dm_kunit_alloc_adev(), which uses
__drm_kunit_helper_alloc_drm_device() with DRIVER_MODESET. This implies
the mode config is already initialized. Calling it again zeroes out lists
like property_list (using INIT_LIST_HEAD) without freeing previously
allocated standard properties, which leads to a memory leak. 

Furthermore, does it register a duplicate drm_mode_config_init_release action,
leading to double teardown attempts on the same structures?

A similarly problematic duplicate call also appears to be present in
dm_test_setup_backlight_device_attaches_abm_property().

[ ... ]
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
> index aad122c7229f5..ed5045c948fe9 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
[ ... ]
> @@ -172,6 +177,7 @@ struct amdgpu_dm_connector *dm_kunit_alloc_connector(struct kunit *test,
>  	if (adev)
>  		aconnector->base.dev = &adev->ddev;
>  	aconnector->dc_link = link;
> +	drm_backlight_connector_init(&aconnector->base);
>  
>  	return aconnector;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908044035.62093-1-mario.limonciello@amd.com?part=10

  reply	other threads:[~2026-09-08  4:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  4:40 [PATCH v8 00/14] Add support for a DRM backlight capability Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 01/14] Revert "backlight: Remove notifier" Mario Limonciello
2026-09-08  4:51   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 02/14] backlight: add kernel-internal backlight API Mario Limonciello
2026-09-08  4:52   ` sashiko-bot
2026-09-08 15:45   ` Jani Nikula
2026-09-08 16:00     ` Mario Limonciello
2026-09-08 16:33       ` Jani Nikula
2026-09-08  4:40 ` [PATCH v8 03/14] drm/property: add a per-connector luminance flag Mario Limonciello
2026-09-08  4:54   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 04/14] drm: add connector backlight (LUMINANCE) infrastructure Mario Limonciello
2026-09-08  4:54   ` sashiko-bot
2026-09-08 15:48   ` Jani Nikula
2026-09-08  4:40 ` [PATCH v8 05/14] drm: add DRM_CLIENT_CAP_LUMINANCE Mario Limonciello
2026-09-08  4:55   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 06/14] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 07/14] drm/amd: Indicate driver supports luminance Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 08/14] drm/amd/display: use drm backlight Mario Limonciello
2026-09-08  4:57   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 09/14] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper Mario Limonciello
2026-09-08  4:51   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 10/14] drm/amd/display: Update KUnit backlight tests for luminance property and fixtures Mario Limonciello
2026-09-08  4:54   ` sashiko-bot [this message]
2026-09-08  4:40 ` [PATCH v8 11/14] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 12/14] drm/xe: Indicate support for luminance on the connector Mario Limonciello
2026-09-08  4:57   ` sashiko-bot
2026-09-08  4:40 ` [PATCH v8 13/14] drm/i915: " Mario Limonciello
2026-09-08  4:40 ` [PATCH v8 14/14] drm/i915/display: use drm backlight Mario Limonciello
2026-09-08  5:03   ` sashiko-bot
2026-09-08  9:32 ` ✓ i915.CI.BAT: success for Add support for a DRM backlight capability (rev3) Patchwork
2026-09-08 18:45 ` ✗ i915.CI.Full: failure " Patchwork

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=20260908045423.7B4491F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.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