gpu: nvgpu: modify alloc_as ioctl to accept mem size

- Modify NVGPU_GPU_IOCTL_ALLOC_AS and struct nvgpu_alloc_as_args to
accept start address and size of user memory. This allows configurable
address space allocation.
- Modify gk20a_as_alloc_share() and gk20a_vm_alloc_share() to receive
va_range_start and va_range_end values.
- gk20a_vm_alloc_share() initializes vm with low_hole = va_range_start,
and user vma size = (va_range_end - va_range_start).
- Modify nvgpu_as_alloc_space_args and nvgpu_as_free_space_args to
accept 64 bit number of pages.

Bug 2043269
JIRA NVGPU-5302

Change-Id: I243995adf5b7e0e84d6b36abe3b35a5ccabd7a37
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2385496
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Sami Kiminki <skiminki@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Sami Kiminki <skiminki@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2020-08-13 10:31:19 -07:00
committed by Alex Waterman
parent 8303e93a60
commit a252cc244a
10 changed files with 134 additions and 37 deletions

View File

@@ -58,24 +58,28 @@ static int global_id_count;
/* Parameters to test standard cases of allocation */
static struct test_parameters test_64k_user_managed = {
.big_page_size = SZ_64K,
.small_big_split = (SZ_1G * 56ULL),
.flags = NVGPU_AS_ALLOC_USERSPACE_MANAGED,
.expected_error = 0
};
static struct test_parameters test_0k_user_managed = {
.big_page_size = 0,
.small_big_split = 0,
.flags = NVGPU_AS_ALLOC_USERSPACE_MANAGED,
.expected_error = 0
};
static struct test_parameters test_64k_unified_va = {
.big_page_size = SZ_64K,
.small_big_split = 0,
.flags = NVGPU_AS_ALLOC_UNIFIED_VA,
.expected_error = 0
};
static struct test_parameters test_64k_unified_va_enabled = {
.big_page_size = SZ_64K,
.small_big_split = 0,
.flags = 0,
.expected_error = 0,
.unify_address_spaces_flag = true
@@ -83,12 +87,14 @@ static struct test_parameters test_64k_unified_va_enabled = {
static struct test_parameters test_einval_user_managed = {
.big_page_size = 1,
.small_big_split = (SZ_1G * 56ULL),
.flags = NVGPU_AS_ALLOC_USERSPACE_MANAGED,
.expected_error = -EINVAL
};
static struct test_parameters test_notp2_user_managed = {
.big_page_size = SZ_64K-1,
.small_big_split = (SZ_1G * 56ULL),
.flags = NVGPU_AS_ALLOC_USERSPACE_MANAGED,
.expected_error = -EINVAL
};
@@ -96,6 +102,7 @@ static struct test_parameters test_notp2_user_managed = {
/* Parameters to test corner cases and error handling */
static struct test_parameters test_64k_user_managed_as_fail = {
.big_page_size = SZ_64K,
.small_big_split = (SZ_1G * 56ULL),
.flags = 0,
.expected_error = -ENOMEM,
.special_case = SPECIAL_CASE_AS_MALLOC_FAIL
@@ -103,6 +110,7 @@ static struct test_parameters test_64k_user_managed_as_fail = {
static struct test_parameters test_64k_user_managed_vm_fail = {
.big_page_size = SZ_64K,
.small_big_split = (SZ_1G * 56ULL),
.flags = 0,
.expected_error = -ENOMEM,
.special_case = SPECIAL_CASE_VM_INIT_FAIL
@@ -110,6 +118,7 @@ static struct test_parameters test_64k_user_managed_vm_fail = {
static struct test_parameters test_64k_user_managed_busy_fail_1 = {
.big_page_size = SZ_64K,
.small_big_split = (SZ_1G * 56ULL),
.flags = 0,
.expected_error = -ENODEV,
.special_case = SPECIAL_CASE_GK20A_BUSY_ALLOC
@@ -117,6 +126,7 @@ static struct test_parameters test_64k_user_managed_busy_fail_1 = {
static struct test_parameters test_64k_user_managed_busy_fail_2 = {
.big_page_size = SZ_64K,
.small_big_split = (SZ_1G * 56ULL),
.flags = 0,
.expected_error = 0,
.special_case = SPECIAL_CASE_GK20A_BUSY_RELEASE
@@ -173,7 +183,7 @@ int test_init_mm(struct unit_module *m, struct gk20a *g, void *args)
* Before ref_init calls to gk20a_as_alloc_share should immediately
* fail.
*/
err = gk20a_as_alloc_share(g, 0, 0, NULL);
err = gk20a_as_alloc_share(g, 0, 0, 0, 0, 0, NULL);
if (err != -ENODEV) {
unit_return_fail(m, "gk20a_as_alloc_share did not fail as expected err=%d\n",
err);
@@ -213,7 +223,8 @@ int test_as_alloc_share(struct unit_module *m, struct gk20a *g, void *args)
}
err = gk20a_as_alloc_share(g, params->big_page_size,
params->flags, &out);
params->flags, (SZ_64K << 10), (1ULL << 37),
params->small_big_split, &out);
if (params->unify_address_spaces_flag) {
nvgpu_set_enabled(g, NVGPU_MM_UNIFY_ADDRESS_SPACES, false);
@@ -264,7 +275,8 @@ int test_gk20a_from_as(struct unit_module *m, struct gk20a *g, void *args)
int err;
err = gk20a_as_alloc_share(g, SZ_64K, NVGPU_AS_ALLOC_USERSPACE_MANAGED,
&out);
(SZ_64K << 10), (1ULL << 37),
nvgpu_gmmu_va_small_page_limit(), &out);
if (err != 0) {
unit_return_fail(m, "gk20a_as_alloc_share failed err=%d\n",
err);