mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: mm: limit recursion depth for pd levels
The two MM functions nvgpu_set_pd_level() and nvgpu_vm_do_free_entries() are simple recursive functions for processing page descriptors (PDs) by traversing the levels in the PDs. MISRA Rule 17.2 prohibits functions calling themselves because "unless recursion is tightly controlled, it is not possible to determine before execution what the worst-case stack usage could be." So, this change limits the recursion depth of each of these functions to the maximum number of page table levels by checking the level against the MM HAL max_page_table_levels(). This also required configuring this HAL in various unit tests as they were no previously using this HAL. JIRA NVGPU-3489 Change-Id: Iadee3fa5ba9f45cd643ac6c202e9296d75d51880 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2224450 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
cf8707e2b3
commit
49a620e48a
@@ -185,8 +185,12 @@ static void nvgpu_vm_do_free_entries(struct vm_gk20a *vm,
|
||||
struct nvgpu_gmmu_pd *pd,
|
||||
u32 level)
|
||||
{
|
||||
struct gk20a *g = gk20a_from_vm(vm);
|
||||
u32 i;
|
||||
|
||||
/* This limits recursion */
|
||||
nvgpu_assert(level < g->ops.mm.gmmu.get_max_page_table_levels(g));
|
||||
|
||||
if (pd->mem != NULL) {
|
||||
nvgpu_pd_free(vm, pd);
|
||||
pd->mem = NULL;
|
||||
|
||||
Reference in New Issue
Block a user