Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: Switch private_obj initialization to atomic_create_state

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.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://patch.msgid.link/20260224-drm-private-obj-reset-v5-1-5a72f8ec9934@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+28 -24
+28 -24
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 4844 4844 kfree(dm_state); 4845 4845 } 4846 4846 4847 + static struct drm_private_state * 4848 + dm_atomic_create_state(struct drm_private_obj *obj) 4849 + { 4850 + struct amdgpu_device *adev = drm_to_adev(obj->dev); 4851 + struct dm_atomic_state *dm_state; 4852 + struct dc_state *context; 4853 + 4854 + dm_state = kzalloc_obj(*dm_state); 4855 + if (!dm_state) 4856 + return ERR_PTR(-ENOMEM); 4857 + 4858 + context = dc_state_create_current_copy(adev->dm.dc); 4859 + if (!context) { 4860 + kfree(dm_state); 4861 + return ERR_PTR(-ENOMEM); 4862 + } 4863 + 4864 + __drm_atomic_helper_private_obj_create_state(obj, &dm_state->base); 4865 + dm_state->context = context; 4866 + 4867 + return &dm_state->base; 4868 + } 4869 + 4847 4870 static struct drm_private_state_funcs dm_atomic_state_funcs = { 4871 + .atomic_create_state = dm_atomic_create_state, 4848 4872 .atomic_duplicate_state = dm_atomic_duplicate_state, 4849 4873 .atomic_destroy_state = dm_atomic_destroy_state, 4850 4874 }; 4851 4875 4852 4876 static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) 4853 4877 { 4854 - struct dm_atomic_state *state; 4855 4878 int r; 4856 4879 4857 4880 adev->mode_info.mode_config_initialized = true; ··· 4894 4871 /* indicates support for immediate flip */ 4895 4872 adev_to_drm(adev)->mode_config.async_page_flip = true; 4896 4873 4897 - state = kzalloc_obj(*state); 4898 - if (!state) 4899 - return -ENOMEM; 4900 - 4901 - state->context = dc_state_create_current_copy(adev->dm.dc); 4902 - if (!state->context) { 4903 - kfree(state); 4904 - return -ENOMEM; 4905 - } 4906 - 4907 4874 drm_atomic_private_obj_init(adev_to_drm(adev), 4908 4875 &adev->dm.atomic_obj, 4909 - &state->base, 4876 + NULL, 4910 4877 &dm_atomic_state_funcs); 4911 4878 4912 4879 r = amdgpu_display_modeset_create_props(adev); 4913 - if (r) { 4914 - dc_state_release(state->context); 4915 - kfree(state); 4880 + if (r) 4916 4881 return r; 4917 - } 4918 4882 4919 4883 #ifdef AMD_PRIVATE_COLOR 4920 - if (amdgpu_dm_create_color_properties(adev)) { 4921 - dc_state_release(state->context); 4922 - kfree(state); 4884 + if (amdgpu_dm_create_color_properties(adev)) 4923 4885 return -ENOMEM; 4924 - } 4925 4886 #endif 4926 4887 4927 4888 r = amdgpu_dm_audio_init(adev); 4928 - if (r) { 4929 - dc_state_release(state->context); 4930 - kfree(state); 4889 + if (r) 4931 4890 return r; 4932 - } 4933 4891 4934 4892 return 0; 4935 4893 }