mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
drm/amd/display: move GPU mem helpers to services
[WHAT] dm_allocate_gpu_mem() and dm_free_gpu_mem() are generic DM service helpers that wrap amdgpu_bo_create_kernel()/amdgpu_bo_free_kernel() and track allocations on adev->dm.da_list. Move them out of amdgpu_dm.c into amdgpu_dm_services.c alongside the other dm_* service callbacks. Both are already public and declared in amdgpu_dm.h; their callers in amdgpu_dm_dmub.c and amdgpu_dm_helpers.c are unaffected. No functional change. Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Fangzhi Zuo <jerry.zuo@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
0b9bd593f0
commit
66517ca0cd
|
|
@ -411,59 +411,6 @@ static void mmhub_read_system_context(struct amdgpu_device *adev, struct dc_phy_
|
|||
|
||||
}
|
||||
|
||||
void*
|
||||
dm_allocate_gpu_mem(
|
||||
struct amdgpu_device *adev,
|
||||
enum dc_gpu_mem_alloc_type type,
|
||||
size_t size,
|
||||
long long *addr)
|
||||
{
|
||||
struct dal_allocation *da;
|
||||
u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ?
|
||||
AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM;
|
||||
int ret;
|
||||
|
||||
da = kzalloc_obj(struct dal_allocation);
|
||||
if (!da)
|
||||
return NULL;
|
||||
|
||||
ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
|
||||
domain, &da->bo,
|
||||
&da->gpu_addr, &da->cpu_ptr);
|
||||
|
||||
*addr = da->gpu_addr;
|
||||
|
||||
if (ret) {
|
||||
kfree(da);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* add da to list in dm */
|
||||
list_add(&da->list, &adev->dm.da_list);
|
||||
|
||||
return da->cpu_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
dm_free_gpu_mem(
|
||||
struct amdgpu_device *adev,
|
||||
enum dc_gpu_mem_alloc_type type,
|
||||
void *pvMem)
|
||||
{
|
||||
struct dal_allocation *da;
|
||||
|
||||
/* walk the da list in DM */
|
||||
list_for_each_entry(da, &adev->dm.da_list, list) {
|
||||
if (pvMem == da->cpu_ptr) {
|
||||
amdgpu_bo_free_kernel(&da->bo, &da->gpu_addr, &da->cpu_ptr);
|
||||
list_del(&da->list);
|
||||
kfree(da);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm)
|
||||
{
|
||||
struct mod_power_init_params init_data[MAX_NUM_EDP];
|
||||
|
|
|
|||
|
|
@ -96,3 +96,56 @@ bool dm_query_extended_brightness_caps(struct dc_context *ctx,
|
|||
return true;
|
||||
}
|
||||
EXPORT_IF_KUNIT(dm_query_extended_brightness_caps);
|
||||
|
||||
void*
|
||||
dm_allocate_gpu_mem(
|
||||
struct amdgpu_device *adev,
|
||||
enum dc_gpu_mem_alloc_type type,
|
||||
size_t size,
|
||||
long long *addr)
|
||||
{
|
||||
struct dal_allocation *da;
|
||||
u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ?
|
||||
AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM;
|
||||
int ret;
|
||||
|
||||
da = kzalloc_obj(*da);
|
||||
if (!da)
|
||||
return NULL;
|
||||
|
||||
ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
|
||||
domain, &da->bo,
|
||||
&da->gpu_addr, &da->cpu_ptr);
|
||||
|
||||
*addr = da->gpu_addr;
|
||||
|
||||
if (ret) {
|
||||
kfree(da);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* add da to list in dm */
|
||||
list_add(&da->list, &adev->dm.da_list);
|
||||
|
||||
return da->cpu_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
dm_free_gpu_mem(
|
||||
struct amdgpu_device *adev,
|
||||
enum dc_gpu_mem_alloc_type type,
|
||||
void *pvMem)
|
||||
{
|
||||
struct dal_allocation *da;
|
||||
|
||||
/* walk the da list in DM */
|
||||
list_for_each_entry(da, &adev->dm.da_list, list) {
|
||||
if (pvMem == da->cpu_ptr) {
|
||||
amdgpu_bo_free_kernel(&da->bo, &da->gpu_addr, &da->cpu_ptr);
|
||||
list_del(&da->list);
|
||||
kfree(da);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user