mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 09:57:08 +03:00
gpu: nvgpu: fix MISRA 21.3 mm nvgpu allocator
MISRA rule 21.3 forbids from using calloc, malloc, realloc and free identifiers for function or macro names. This patch renames nvgpu allocator free operator to free_alloc to follow rule 21.3. Jira NVGPU-3336 Change-Id: Ie9f48d567255a3e1dca70632fbe3d36b45023f3f Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2111365 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User 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
2b165deba1
commit
778f6b2874
@@ -373,7 +373,7 @@ static void nvgpu_bitmap_print_stats(struct nvgpu_allocator *na,
|
|||||||
|
|
||||||
static const struct nvgpu_allocator_ops bitmap_ops = {
|
static const struct nvgpu_allocator_ops bitmap_ops = {
|
||||||
.alloc = nvgpu_bitmap_balloc,
|
.alloc = nvgpu_bitmap_balloc,
|
||||||
.free = nvgpu_bitmap_free,
|
.free_alloc = nvgpu_bitmap_free,
|
||||||
|
|
||||||
.alloc_fixed = nvgpu_bitmap_balloc_fixed,
|
.alloc_fixed = nvgpu_bitmap_balloc_fixed,
|
||||||
.free_fixed = nvgpu_bitmap_free_fixed,
|
.free_fixed = nvgpu_bitmap_free_fixed,
|
||||||
|
|||||||
@@ -1262,7 +1262,7 @@ static void nvgpu_buddy_print_stats(struct nvgpu_allocator *na,
|
|||||||
static const struct nvgpu_allocator_ops buddy_ops = {
|
static const struct nvgpu_allocator_ops buddy_ops = {
|
||||||
.alloc = nvgpu_buddy_balloc,
|
.alloc = nvgpu_buddy_balloc,
|
||||||
.alloc_pte = nvgpu_buddy_balloc_pte,
|
.alloc_pte = nvgpu_buddy_balloc_pte,
|
||||||
.free = nvgpu_buddy_bfree,
|
.free_alloc = nvgpu_buddy_bfree,
|
||||||
|
|
||||||
.alloc_fixed = nvgpu_balloc_fixed_buddy,
|
.alloc_fixed = nvgpu_balloc_fixed_buddy,
|
||||||
/* .free_fixed not needed. */
|
/* .free_fixed not needed. */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -147,7 +147,7 @@ static void nvgpu_lockless_print_stats(struct nvgpu_allocator *a,
|
|||||||
|
|
||||||
static const struct nvgpu_allocator_ops pool_ops = {
|
static const struct nvgpu_allocator_ops pool_ops = {
|
||||||
.alloc = nvgpu_lockless_alloc,
|
.alloc = nvgpu_lockless_alloc,
|
||||||
.free = nvgpu_lockless_free,
|
.free_alloc = nvgpu_lockless_free,
|
||||||
|
|
||||||
.base = nvgpu_lockless_alloc_base,
|
.base = nvgpu_lockless_alloc_base,
|
||||||
.length = nvgpu_lockless_alloc_length,
|
.length = nvgpu_lockless_alloc_length,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ u64 nvgpu_alloc_pte(struct nvgpu_allocator *a, u64 len, u32 page_size)
|
|||||||
|
|
||||||
void nvgpu_free(struct nvgpu_allocator *a, u64 addr)
|
void nvgpu_free(struct nvgpu_allocator *a, u64 addr)
|
||||||
{
|
{
|
||||||
a->ops->free(a, addr);
|
a->ops->free_alloc(a, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 nvgpu_alloc_fixed(struct nvgpu_allocator *a, u64 base, u64 len,
|
u64 nvgpu_alloc_fixed(struct nvgpu_allocator *a, u64 base, u64 len,
|
||||||
@@ -158,7 +158,8 @@ int nvgpu_alloc_common_init(struct nvgpu_allocator *a, struct gk20a *g,
|
|||||||
* This is the bare minimum operations required for a sensible
|
* This is the bare minimum operations required for a sensible
|
||||||
* allocator.
|
* allocator.
|
||||||
*/
|
*/
|
||||||
if (ops->alloc == NULL || ops->free == NULL || ops->fini == NULL) {
|
if (ops->alloc == NULL || ops->free_alloc == NULL ||
|
||||||
|
ops->fini == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -955,7 +955,7 @@ static void nvgpu_page_print_stats(struct nvgpu_allocator *na,
|
|||||||
|
|
||||||
static const struct nvgpu_allocator_ops page_ops = {
|
static const struct nvgpu_allocator_ops page_ops = {
|
||||||
.alloc = nvgpu_page_alloc,
|
.alloc = nvgpu_page_alloc,
|
||||||
.free = nvgpu_page_free,
|
.free_alloc = nvgpu_page_free,
|
||||||
|
|
||||||
.alloc_fixed = nvgpu_page_alloc_fixed,
|
.alloc_fixed = nvgpu_page_alloc_fixed,
|
||||||
.free_fixed = nvgpu_page_free_fixed,
|
.free_fixed = nvgpu_page_free_fixed,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct nvgpu_allocator_ops {
|
|||||||
u64 (*alloc)(struct nvgpu_allocator *allocator, u64 len);
|
u64 (*alloc)(struct nvgpu_allocator *allocator, u64 len);
|
||||||
u64 (*alloc_pte)(struct nvgpu_allocator *allocator, u64 len,
|
u64 (*alloc_pte)(struct nvgpu_allocator *allocator, u64 len,
|
||||||
u32 page_size);
|
u32 page_size);
|
||||||
void (*free)(struct nvgpu_allocator *allocator, u64 addr);
|
void (*free_alloc)(struct nvgpu_allocator *allocator, u64 addr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special interface to allocate a memory region with a specific
|
* Special interface to allocate a memory region with a specific
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ static int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
na->ops->free(na, addr1);
|
na->ops->free_alloc(na, addr1);
|
||||||
|
|
||||||
na->ops->free_fixed(na, SZ_4K, SZ_8K);
|
na->ops->free_fixed(na, SZ_4K, SZ_8K);
|
||||||
|
|
||||||
@@ -162,9 +162,9 @@ static int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
|
|||||||
}
|
}
|
||||||
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
|
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
|
||||||
|
|
||||||
na->ops->free(na, alloc3k);
|
na->ops->free_alloc(na, alloc3k);
|
||||||
|
|
||||||
na->ops->free(na, alloc3k);
|
na->ops->free_alloc(na, alloc3k);
|
||||||
|
|
||||||
alloc4k = na->ops->alloc(na, SZ_4K);
|
alloc4k = na->ops->alloc(na, SZ_4K);
|
||||||
if (alloc4k == 0) {
|
if (alloc4k == 0) {
|
||||||
@@ -221,7 +221,7 @@ static int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
|
|||||||
"freeing unaligned base didn't trigger BUG()\n");
|
"freeing unaligned base didn't trigger BUG()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
na->ops->free(na, alloc4k);
|
na->ops->free_alloc(na, alloc4k);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate 4K
|
* Allocate 4K
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ static int test_buddy_allocator_with_big_pages(struct unit_module *m,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
na->ops->free(na, addr1);
|
na->ops->free_alloc(na, addr1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* alloc_pte()
|
* alloc_pte()
|
||||||
@@ -734,11 +734,11 @@ static int test_nvgpu_buddy_allocator_basic_ops(struct unit_module *m,
|
|||||||
|
|
||||||
addr = na->ops->alloc(na, (SZ_64K >> 1));
|
addr = na->ops->alloc(na, (SZ_64K >> 1));
|
||||||
|
|
||||||
na->ops->free(na, addr);
|
na->ops->free_alloc(na, addr);
|
||||||
|
|
||||||
na->ops->free(na, addr);
|
na->ops->free_alloc(na, addr);
|
||||||
|
|
||||||
na->ops->free(na, 0ULL);
|
na->ops->free_alloc(na, 0ULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* len = 2M (requesting more than available memory)
|
* len = 2M (requesting more than available memory)
|
||||||
@@ -751,7 +751,7 @@ static int test_nvgpu_buddy_allocator_basic_ops(struct unit_module *m,
|
|||||||
|
|
||||||
addr = na->ops->alloc_pte(na, (SZ_4K << 2), SZ_1K << 1);
|
addr = na->ops->alloc_pte(na, (SZ_4K << 2), SZ_1K << 1);
|
||||||
|
|
||||||
na->ops->free(na, addr);
|
na->ops->free_alloc(na, addr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unaligned base
|
* Unaligned base
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
static bool dummy_op_called[OP_NUMBER];
|
static bool dummy_op_called[OP_NUMBER];
|
||||||
static const char *ops_str[] = {
|
static const char *ops_str[] = {
|
||||||
"alloc",
|
"alloc",
|
||||||
"free",
|
"free_alloc",
|
||||||
"alloc_pte",
|
"alloc_pte",
|
||||||
"alloc_fixed",
|
"alloc_fixed",
|
||||||
"free fixed",
|
"free fixed",
|
||||||
@@ -135,7 +135,7 @@ static void dummy_fini(struct nvgpu_allocator *allocator)
|
|||||||
|
|
||||||
static struct nvgpu_allocator_ops dummy_ops = {
|
static struct nvgpu_allocator_ops dummy_ops = {
|
||||||
.alloc = dummy_alloc,
|
.alloc = dummy_alloc,
|
||||||
.free = dummy_free,
|
.free_alloc = dummy_free,
|
||||||
.alloc_pte = dummy_alloc_pte,
|
.alloc_pte = dummy_alloc_pte,
|
||||||
.alloc_fixed = dummy_alloc_fixed,
|
.alloc_fixed = dummy_alloc_fixed,
|
||||||
.free_fixed = dummy_free_fixed,
|
.free_fixed = dummy_free_fixed,
|
||||||
@@ -271,7 +271,7 @@ static int test_nvgpu_alloc_common_init(struct unit_module *m,
|
|||||||
unit_return_fail(m,
|
unit_return_fail(m,
|
||||||
"common_init passes despite missing free(),fini()\n");
|
"common_init passes despite missing free(),fini()\n");
|
||||||
|
|
||||||
ops.free = dummy_free;
|
ops.free_alloc = dummy_free;
|
||||||
if (nvgpu_alloc_common_init(&a, NULL, "test", NULL, false, &ops) == 0)
|
if (nvgpu_alloc_common_init(&a, NULL, "test", NULL, false, &ops) == 0)
|
||||||
unit_return_fail(m,
|
unit_return_fail(m,
|
||||||
"common_init passes despite missing fini()\n");
|
"common_init passes despite missing fini()\n");
|
||||||
@@ -305,7 +305,7 @@ static int test_nvgpu_alloc_destroy(struct unit_module *m,
|
|||||||
struct nvgpu_allocator zero_a = { };
|
struct nvgpu_allocator zero_a = { };
|
||||||
struct nvgpu_allocator_ops ops = {
|
struct nvgpu_allocator_ops ops = {
|
||||||
.alloc = dummy_alloc,
|
.alloc = dummy_alloc,
|
||||||
.free = dummy_free,
|
.free_alloc = dummy_free,
|
||||||
.fini = dummy_fini,
|
.fini = dummy_fini,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ static int test_page_free(struct unit_module *m, struct gk20a *g, void *args)
|
|||||||
struct nvgpu_page_allocator *pa = page_allocator(na);
|
struct nvgpu_page_allocator *pa = page_allocator(na);
|
||||||
|
|
||||||
pa->flags |= param->flags;
|
pa->flags |= param->flags;
|
||||||
na->ops->free(na, param->ret_addr);
|
na->ops->free_alloc(na, param->ret_addr);
|
||||||
pa->flags &= ~(param->flags);
|
pa->flags &= ~(param->flags);
|
||||||
|
|
||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
@@ -430,7 +430,7 @@ static int test_page_allocator_sgt_ops(struct unit_module *m,
|
|||||||
|
|
||||||
alloc->sgt.ops->sgt_free(g, &alloc->sgt);
|
alloc->sgt.ops->sgt_free(g, &alloc->sgt);
|
||||||
|
|
||||||
na->ops->free(na, addr);
|
na->ops->free_alloc(na, addr);
|
||||||
|
|
||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -490,7 +490,7 @@ static int test_nvgpu_page_allocator_ops(struct unit_module *m,
|
|||||||
unit_return_fail(m, "reserved carveout after alloc\n");
|
unit_return_fail(m, "reserved carveout after alloc\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
na->ops->free(na, addr);
|
na->ops->free_alloc(na, addr);
|
||||||
|
|
||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user