gpu: nvgpu: mm: fix MISRA 17.2 violation

MISRA rule 17.2 prohibits functions calling themselves (recursion).
Remove recursion in the function buddy_coalesce().

JIRA NVGPU-3337

Change-Id: I03ec9751688f79b4bf704f5be1c43fce6e0dbaf5
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2109647
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Philip Elcan
2019-05-01 17:22:48 -04:00
committed by mobile promotions
parent 9f7b712e3a
commit c6531d8b78

View File

@@ -367,38 +367,33 @@ static void balloc_coalesce(struct nvgpu_buddy_allocator *a,
{
struct nvgpu_buddy *parent;
if (buddy_is_alloced(b) || buddy_is_split(b)) {
return;
while (!buddy_is_alloced(b) && !buddy_is_split(b)) {
/*
* If both our buddy and I are both not allocated and not split
* then we can coalesce ourselves.
*/
if (b->buddy == NULL) {
return;
}
if (buddy_is_alloced(b->buddy) || buddy_is_split(b->buddy)) {
return;
}
parent = b->parent;
balloc_blist_rem(a, b);
balloc_blist_rem(a, b->buddy);
buddy_clr_split(parent);
a->buddy_list_split[parent->order]--;
balloc_blist_add(a, parent);
/* Clean up the remains. */
nvgpu_kmem_cache_free(a->buddy_cache, b->buddy);
nvgpu_kmem_cache_free(a->buddy_cache, b);
b = parent;
}
/*
* If both our buddy and I are both not allocated and not split then
* we can coalesce ourselves.
*/
if (b->buddy == NULL) {
return;
}
if (buddy_is_alloced(b->buddy) || buddy_is_split(b->buddy)) {
return;
}
parent = b->parent;
balloc_blist_rem(a, b);
balloc_blist_rem(a, b->buddy);
buddy_clr_split(parent);
a->buddy_list_split[parent->order]--;
balloc_blist_add(a, parent);
/*
* Recursively coalesce as far as we can go.
*/
balloc_coalesce(a, parent);
/* Clean up the remains. */
nvgpu_kmem_cache_free(a->buddy_cache, b->buddy);
nvgpu_kmem_cache_free(a->buddy_cache, b);
}
/*