mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: move sys/vid alloc functions to allocator unit
currently sys/vid surface alloc/free as part of pmu.c which adds circular dependency between different units within PMU, so moved to allocator unit as these functions perform memory allocation/free from sys/vid mem. JIRA NVGPU-1972 Change-Id: Ib7fc60ba74b56ea59f92f5d553dec7c83b0c72f2 Signed-off-by: Mahantesh Kumbar <mkumbar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2094838 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
b65485c5b4
commit
678cfdc608
@@ -25,6 +25,7 @@
|
||||
#include <nvgpu/gk20a.h>
|
||||
#include <nvgpu/pmu.h>
|
||||
#include <nvgpu/pmu/fw.h>
|
||||
#include <nvgpu/dma.h>
|
||||
|
||||
void nvgpu_pmu_dmem_allocator_init(struct gk20a *g,
|
||||
struct nvgpu_pmu *pmu, struct nvgpu_allocator *dmem,
|
||||
@@ -54,3 +55,51 @@ void nvgpu_pmu_dmem_allocator_destroy(struct nvgpu_allocator *dmem)
|
||||
nvgpu_alloc_destroy(dmem);
|
||||
}
|
||||
}
|
||||
|
||||
void nvgpu_pmu_surface_free(struct gk20a *g, struct nvgpu_mem *mem)
|
||||
{
|
||||
if (nvgpu_mem_is_valid(mem)) {
|
||||
nvgpu_dma_free(g, mem);
|
||||
}
|
||||
}
|
||||
|
||||
void nvgpu_pmu_surface_describe(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
struct flcn_mem_desc_v0 *fb)
|
||||
{
|
||||
fb->address.lo = u64_lo32(mem->gpu_va);
|
||||
fb->address.hi = u64_hi32(mem->gpu_va);
|
||||
fb->params = ((u32)mem->size & 0xFFFFFFU);
|
||||
fb->params |= (GK20A_PMU_DMAIDX_VIRT << 24U);
|
||||
}
|
||||
|
||||
int nvgpu_pmu_vidmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 size)
|
||||
{
|
||||
struct mm_gk20a *mm = &g->mm;
|
||||
struct vm_gk20a *vm = mm->pmu.vm;
|
||||
int err;
|
||||
|
||||
err = nvgpu_dma_alloc_map_vid(vm, size, mem);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "memory allocation failed");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nvgpu_pmu_sysmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 size)
|
||||
{
|
||||
struct mm_gk20a *mm = &g->mm;
|
||||
struct vm_gk20a *vm = mm->pmu.vm;
|
||||
int err;
|
||||
|
||||
err = nvgpu_dma_alloc_map_sys(vm, size, mem);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "failed to allocate memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user