From: Maxime Ripard <mripard@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org,
"Maxime Ripard" <mripard@kernel.org>,
"Harry Wentland" <harry.wentland@amd.com>,
"Leo Li" <sunpeng.li@amd.com>,
"Rodrigo Siqueira" <siqueira@igalia.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
amd-gfx@lists.freedesktop.org
Subject: [PATCH v2 08/16] drm/amdgpu: Switch private_obj initialization to atomic_create_state
Date: Tue, 14 Oct 2025 11:31:52 +0200 [thread overview]
Message-ID: <20251014-drm-private-obj-reset-v2-8-6dd60e985e9d@kernel.org> (raw)
In-Reply-To: <20251014-drm-private-obj-reset-v2-0-6dd60e985e9d@kernel.org>
The amdgpu driver relies on a drm_private_obj, that is initialized by
allocating and initializing a state, and then passing it to
drm_private_obj_init.
Since we're gradually moving away from that pattern to the more
established one relying on a atomic_create_state implementation, let's
migrate this instance to the new pattern.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <siqueira@igalia.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 52 ++++++++++++-----------
1 file changed, 28 insertions(+), 24 deletions(-)
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 62defeccbb5ca09c89523fc4112d2085bbdbb0a9..239b3f58694919b7dbb8836f8859788b50288ffa 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4675,18 +4675,41 @@ static void dm_atomic_destroy_state(struct drm_private_obj *obj,
dc_state_release(dm_state->context);
kfree(dm_state);
}
+static struct drm_private_state *
+dm_atomic_create_state(struct drm_private_obj *obj)
+{
+ struct amdgpu_device *adev = drm_to_adev(obj->dev);
+ struct dm_atomic_state *dm_state;
+ struct dc_state *context;
+
+ dm_state = kzalloc(sizeof(*dm_state), GFP_KERNEL);
+ if (!dm_state)
+ return ERR_PTR(-ENOMEM);
+
+ context = dc_state_create_current_copy(adev->dm.dc);
+ if (!context) {
+ kfree(dm_state);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ __drm_atomic_helper_private_obj_create_state(obj, &dm_state->base);
+ dm_state->context = context;
+
+ return &dm_state->base;
+}
+
static struct drm_private_state_funcs dm_atomic_state_funcs = {
+ .atomic_create_state = dm_atomic_create_state,
.atomic_duplicate_state = dm_atomic_duplicate_state,
.atomic_destroy_state = dm_atomic_destroy_state,
};
static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
{
- struct dm_atomic_state *state;
int r;
adev->mode_info.mode_config_initialized = true;
adev_to_drm(adev)->mode_config.funcs = (void *)&amdgpu_dm_mode_funcs;
@@ -4702,46 +4725,27 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
else
adev_to_drm(adev)->mode_config.prefer_shadow = 1;
/* indicates support for immediate flip */
adev_to_drm(adev)->mode_config.async_page_flip = true;
- state = kzalloc(sizeof(*state), GFP_KERNEL);
- if (!state)
- return -ENOMEM;
-
- state->context = dc_state_create_current_copy(adev->dm.dc);
- if (!state->context) {
- kfree(state);
- return -ENOMEM;
- }
-
drm_atomic_private_obj_init(adev_to_drm(adev),
&adev->dm.atomic_obj,
- &state->base,
+ NULL,
&dm_atomic_state_funcs);
r = amdgpu_display_modeset_create_props(adev);
- if (r) {
- dc_state_release(state->context);
- kfree(state);
+ if (r)
return r;
- }
#ifdef AMD_PRIVATE_COLOR
- if (amdgpu_dm_create_color_properties(adev)) {
- dc_state_release(state->context);
- kfree(state);
+ if (amdgpu_dm_create_color_properties(adev))
return -ENOMEM;
- }
#endif
r = amdgpu_dm_audio_init(adev);
- if (r) {
- dc_state_release(state->context);
- kfree(state);
+ if (r)
return r;
- }
return 0;
}
#define AMDGPU_DM_DEFAULT_MIN_BACKLIGHT 12
--
2.51.0
next prev parent reply other threads:[~2025-10-14 12:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 9:31 [PATCH v2 00/16] drm/atomic: Allocate drm_private_state through a callback Maxime Ripard
2025-10-14 9:31 ` Maxime Ripard [this message]
2025-10-14 9:32 ` [PATCH v2 16/16] drm/atomic: Remove state argument to drm_atomic_private_obj_init Maxime Ripard
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=20251014-drm-private-obj-reset-v2-8-6dd60e985e9d@kernel.org \
--to=mripard@kernel.org \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@amd.com \
--cc=tzimmermann@suse.de \
/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