userspace: units: replace PAGE_SIZE with NVGPU_CPU_PAGE_SIZE

Replace PAGE_SIZE with NVGPU_CPU_PAGE_SIZE, which is a nvgpu defined wrapper
over OS native page size.

Bug 200658101
Jira NVGPU-6018

Change-Id: If35e23d5df38a6b52b586911d1055e0b00b12ebe
Signed-off-by: Antony Clince Alex <aalex@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2424792
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Antony Clince Alex
2020-10-07 22:50:21 +05:30
committed by Alex Waterman
parent 223baa5883
commit 09857ecd91
6 changed files with 21 additions and 21 deletions

View File

@@ -657,12 +657,12 @@ static int stub_os_channel_alloc_usermode_buffers(struct nvgpu_channel *ch,
int err; int err;
struct gk20a *g = ch->g; struct gk20a *g = ch->g;
err = nvgpu_dma_alloc(g, PAGE_SIZE, &ch->usermode_userd); err = nvgpu_dma_alloc(g, NVGPU_CPU_PAGE_SIZE, &ch->usermode_userd);
if (err != 0) { if (err != 0) {
return err; return err;
} }
err = nvgpu_dma_alloc(g, PAGE_SIZE, &ch->usermode_gpfifo); err = nvgpu_dma_alloc(g, NVGPU_CPU_PAGE_SIZE, &ch->usermode_gpfifo);
if (err != 0) { if (err != 0) {
return err; return err;
} }
@@ -759,7 +759,7 @@ int test_channel_setup_bind(struct unit_module *m, struct gk20a *g, void *vargs)
mm.g = g; mm.g = g;
vm.mm = &mm; vm.mm = &mm;
ch->vm = &vm; ch->vm = &vm;
err = nvgpu_dma_alloc(g, PAGE_SIZE, &pdb_mem); err = nvgpu_dma_alloc(g, NVGPU_CPU_PAGE_SIZE, &pdb_mem);
unit_assert(err == 0, goto done); unit_assert(err == 0, goto done);
vm.pdb.mem = &pdb_mem; vm.pdb.mem = &pdb_mem;
@@ -1330,7 +1330,7 @@ int test_channel_deterministic_idle_unidle(struct unit_module *m,
mm.g = g; mm.g = g;
vm.mm = &mm; vm.mm = &mm;
ch->vm = &vm; ch->vm = &vm;
err = nvgpu_dma_alloc(g, PAGE_SIZE, &pdb_mem); err = nvgpu_dma_alloc(g, NVGPU_CPU_PAGE_SIZE, &pdb_mem);
unit_assert(err == 0, goto done); unit_assert(err == 0, goto done);
vm.pdb.mem = &pdb_mem; vm.pdb.mem = &pdb_mem;
@@ -1693,7 +1693,7 @@ int test_channel_semaphore_wakeup(struct unit_module *m,
mm.g = g; mm.g = g;
vm.mm = &mm; vm.mm = &mm;
ch->vm = &vm; ch->vm = &vm;
err = nvgpu_dma_alloc(g, PAGE_SIZE, &pdb_mem); err = nvgpu_dma_alloc(g, NVGPU_CPU_PAGE_SIZE, &pdb_mem);
unit_assert(err == 0, goto done); unit_assert(err == 0, goto done);
vm.pdb.mem = &pdb_mem; vm.pdb.mem = &pdb_mem;

View File

@@ -696,7 +696,7 @@ int test_tsg_release(struct unit_module *m,
} }
if (branches & F_TSG_RELEASE_MEM) { if (branches & F_TSG_RELEASE_MEM) {
nvgpu_dma_alloc(g, PAGE_SIZE, &mem); nvgpu_dma_alloc(g, NVGPU_CPU_PAGE_SIZE, &mem);
tsg->gr_ctx->mem = mem; tsg->gr_ctx->mem = mem;
} }

View File

@@ -54,41 +54,41 @@ struct pd_cache_alloc_direct_gen {
* Direct alloc testing: i.e larger than a page allocs. * Direct alloc testing: i.e larger than a page allocs.
*/ */
static struct pd_cache_alloc_direct_gen alloc_direct_1xPAGE = { static struct pd_cache_alloc_direct_gen alloc_direct_1xPAGE = {
.bytes = PAGE_SIZE, .bytes = NVGPU_CPU_PAGE_SIZE,
.nr = 1U, .nr = 1U,
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE = { static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE = {
.bytes = PAGE_SIZE, .bytes = NVGPU_CPU_PAGE_SIZE,
.nr = 1024U, .nr = 1024U,
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1x16PAGE = { static struct pd_cache_alloc_direct_gen alloc_direct_1x16PAGE = {
.bytes = 16U * PAGE_SIZE, .bytes = 16U * NVGPU_CPU_PAGE_SIZE,
.nr = 1U, .nr = 1U,
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1024x16PAGE = { static struct pd_cache_alloc_direct_gen alloc_direct_1024x16PAGE = {
.bytes = 16U * PAGE_SIZE, .bytes = 16U * NVGPU_CPU_PAGE_SIZE,
.nr = 1024U, .nr = 1024U,
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x32x24 = { static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x32x24 = {
.bytes = PAGE_SIZE, .bytes = NVGPU_CPU_PAGE_SIZE,
.nr = 1024U, .nr = 1024U,
.nr_allocs_before_free = 32U, .nr_allocs_before_free = 32U,
.nr_frees_before_alloc = 24U .nr_frees_before_alloc = 24U
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x16x4 = { static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x16x4 = {
.bytes = PAGE_SIZE, .bytes = NVGPU_CPU_PAGE_SIZE,
.nr = 1024U, .nr = 1024U,
.nr_allocs_before_free = 16U, .nr_allocs_before_free = 16U,
.nr_frees_before_alloc = 4U .nr_frees_before_alloc = 4U
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x16x15 = { static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x16x15 = {
.bytes = PAGE_SIZE, .bytes = NVGPU_CPU_PAGE_SIZE,
.nr = 1024U, .nr = 1024U,
.nr_allocs_before_free = 16U, .nr_allocs_before_free = 16U,
.nr_frees_before_alloc = 15U .nr_frees_before_alloc = 15U
}; };
static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x16x1 = { static struct pd_cache_alloc_direct_gen alloc_direct_1024xPAGE_x16x1 = {
.bytes = PAGE_SIZE, .bytes = NVGPU_CPU_PAGE_SIZE,
.nr = 1024U, .nr = 1024U,
.nr_allocs_before_free = 16U, .nr_allocs_before_free = 16U,
.nr_frees_before_alloc = 1U .nr_frees_before_alloc = 1U
@@ -404,14 +404,14 @@ int test_pd_alloc_direct_fi(struct unit_module *m, struct gk20a *g, void *args)
*/ */
nvgpu_posix_enable_fault_injection(kmem_fi, true, 0); nvgpu_posix_enable_fault_injection(kmem_fi, true, 0);
err = nvgpu_pd_alloc(&vm, &pd, PAGE_SIZE); err = nvgpu_pd_alloc(&vm, &pd, NVGPU_CPU_PAGE_SIZE);
if (err == 0) { if (err == 0) {
unit_return_fail(m, "pd_alloc() success with kmem OOM\n"); unit_return_fail(m, "pd_alloc() success with kmem OOM\n");
} }
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0); nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
nvgpu_posix_enable_fault_injection(dma_fi, true, 0); nvgpu_posix_enable_fault_injection(dma_fi, true, 0);
err = nvgpu_pd_alloc(&vm, &pd, PAGE_SIZE); err = nvgpu_pd_alloc(&vm, &pd, NVGPU_CPU_PAGE_SIZE);
if (err == 0) { if (err == 0) {
unit_return_fail(m, "pd_alloc() success with DMA OOM\n"); unit_return_fail(m, "pd_alloc() success with DMA OOM\n");
} }
@@ -558,7 +558,7 @@ int test_pd_cache_valid_alloc(struct unit_module *m, struct gk20a *g,
* This covers the VCs 1 and 2. * This covers the VCs 1 and 2.
*/ */
bytes = 256; /* 256 bytes is the min PD size. */ bytes = 256; /* 256 bytes is the min PD size. */
while (bytes <= PAGE_SIZE) { while (bytes <= NVGPU_CPU_PAGE_SIZE) {
err = nvgpu_pd_alloc(&vm, &pd, bytes); err = nvgpu_pd_alloc(&vm, &pd, bytes);
if (err) { if (err) {
@@ -722,7 +722,7 @@ int test_per_pd_size(struct unit_module *m, struct gk20a *g, void *args)
} }
pd_size = 256U; /* 256 bytes is the min PD size. */ pd_size = 256U; /* 256 bytes is the min PD size. */
while (pd_size < PAGE_SIZE) { while (pd_size < NVGPU_CPU_PAGE_SIZE) {
err = fn(m, g, &vm, pd_size); err = fn(m, g, &vm, pd_size);
if (err) { if (err) {
err = UNIT_FAIL; err = UNIT_FAIL;

View File

@@ -683,7 +683,7 @@ int test_nvgpu_mem_create_from_mem(struct unit_module *m, struct gk20a *g,
nvgpu_mem_create_from_mem(g, &dest_mem, test_mem, 0, 2); nvgpu_mem_create_from_mem(g, &dest_mem, test_mem, 0, 2);
unit_assert(dest_mem.cpu_va == test_mem->cpu_va, goto done); unit_assert(dest_mem.cpu_va == test_mem->cpu_va, goto done);
unit_assert(dest_mem.size == (2 * PAGE_SIZE), goto done); unit_assert(dest_mem.size == (2 * NVGPU_CPU_PAGE_SIZE), goto done);
unit_assert((dest_mem.mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) == true, unit_assert((dest_mem.mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) == true,
goto done); goto done);
unit_assert(dest_mem.aperture == APERTURE_SYSMEM, goto done); unit_assert(dest_mem.aperture == APERTURE_SYSMEM, goto done);

View File

@@ -439,7 +439,7 @@ int test_align_macros(struct unit_module *m,
test1 = PAGE_ALIGN_TEST_VALUE; test1 = PAGE_ALIGN_TEST_VALUE;
result = PAGE_ALIGN(test1); result = PAGE_ALIGN(test1);
if (result & (PAGE_SIZE - 1)) { if (result & (NVGPU_CPU_PAGE_SIZE - 1)) {
unit_return_fail(m, unit_return_fail(m,
"PAGE_ALIGN failure %x\n", result); "PAGE_ALIGN failure %x\n", result);
} }

View File

@@ -51,7 +51,7 @@ static int init_syncpt_mem(struct unit_module *m, struct gk20a *g)
int err; int err;
if (!nvgpu_mem_is_valid(&g->syncpt_mem)) { if (!nvgpu_mem_is_valid(&g->syncpt_mem)) {
nr_pages = U64(DIV_ROUND_UP(g->syncpt_unit_size, nr_pages = U64(DIV_ROUND_UP(g->syncpt_unit_size,
PAGE_SIZE)); NVGPU_CPU_PAGE_SIZE));
err = nvgpu_mem_create_from_phys(g, &g->syncpt_mem, err = nvgpu_mem_create_from_phys(g, &g->syncpt_mem,
g->syncpt_unit_base, nr_pages); g->syncpt_unit_base, nr_pages);
if (err != 0) { if (err != 0) {