mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +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
@@ -26,6 +26,7 @@
|
||||
#include <nvgpu/pmu/pmuif/ctrlboardobj.h>
|
||||
#include <nvgpu/pmu/cmd.h>
|
||||
#include <nvgpu/pmu/super_surface.h>
|
||||
#include <nvgpu/pmu/allocator.h>
|
||||
|
||||
/*
|
||||
* Inserts a previously constructed Board Object into a Board Object Group for
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <nvgpu/pmu/cmd.h>
|
||||
#include <nvgpu/pmu/msg.h>
|
||||
#include <nvgpu/pmu/fw.h>
|
||||
#include <nvgpu/pmu/allocator.h>
|
||||
|
||||
static bool pmu_validate_cmd(struct nvgpu_pmu *pmu, struct pmu_cmd *cmd,
|
||||
struct pmu_payload *payload, u32 queue_id)
|
||||
|
||||
@@ -466,47 +466,6 @@ exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
struct gk20a *gk20a_from_pmu(struct nvgpu_pmu *pmu)
|
||||
{
|
||||
return pmu->g;
|
||||
@@ -547,10 +506,3 @@ int nvgpu_pmu_lock_release(struct gk20a *g, struct nvgpu_pmu *pmu,
|
||||
|
||||
return nvgpu_pmu_mutex_release(g, &pmu->mutexes, id, token);
|
||||
}
|
||||
|
||||
void nvgpu_pmu_surface_free(struct gk20a *g, struct nvgpu_mem *mem)
|
||||
{
|
||||
nvgpu_log_fn(g, " ");
|
||||
|
||||
nvgpu_dma_free(g, mem);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -260,15 +260,6 @@ int nvgpu_pmu_destroy(struct gk20a *g);
|
||||
int nvgpu_pmu_super_surface_alloc(struct gk20a *g,
|
||||
struct nvgpu_mem *mem_surface, u32 size);
|
||||
|
||||
/* NVGPU-PMU MEM alloc */
|
||||
void nvgpu_pmu_surface_free(struct gk20a *g, struct nvgpu_mem *mem);
|
||||
void nvgpu_pmu_surface_describe(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
struct flcn_mem_desc_v0 *fb);
|
||||
int nvgpu_pmu_vidmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 size);
|
||||
int nvgpu_pmu_sysmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 size);
|
||||
|
||||
int nvgpu_early_init_pmu_sw(struct gk20a *g, struct nvgpu_pmu *pmu);
|
||||
|
||||
/* PMU reset */
|
||||
|
||||
@@ -23,13 +23,25 @@
|
||||
#ifndef NVGPU_PMU_ALLOCATOR_H
|
||||
#define NVGPU_PMU_ALLOCATOR_H
|
||||
|
||||
#include <nvgpu/types.h>
|
||||
|
||||
struct gk20a;
|
||||
struct nvgpu_pmu;
|
||||
struct nvgpu_mem;
|
||||
struct nvgpu_allocator;
|
||||
union pmu_init_msg_pmu;
|
||||
struct flcn_mem_desc_v0;
|
||||
|
||||
void nvgpu_pmu_dmem_allocator_init(struct gk20a *g,
|
||||
struct nvgpu_pmu *pmu, struct nvgpu_allocator *dmem,
|
||||
union pmu_init_msg_pmu *init);
|
||||
void nvgpu_pmu_dmem_allocator_destroy(struct nvgpu_allocator *dmem);
|
||||
|
||||
void nvgpu_pmu_surface_free(struct gk20a *g, struct nvgpu_mem *mem);
|
||||
void nvgpu_pmu_surface_describe(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
struct flcn_mem_desc_v0 *fb);
|
||||
int nvgpu_pmu_vidmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 size);
|
||||
int nvgpu_pmu_sysmem_surface_alloc(struct gk20a *g, struct nvgpu_mem *mem,
|
||||
u32 size);
|
||||
#endif /* NVGPU_PMU_ALLOCATOR_H */
|
||||
|
||||
Reference in New Issue
Block a user