mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 18:16:01 +03:00
gpu: nvgpu: vm: plausibility check for nvgpu_vm_bind_channel
Ensure that the channel pointer passed to nvgpu_vm_bind_channel is not NULL. Update unit test accordingly. JIRA NVGPU-4947. Change-Id: I3f987ee9042066df83cc6101b20b4add3661fae8 Signed-off-by: Nicolas Benech <nbenech@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2291034 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@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:
committed by
Alex Waterman
parent
16b80d2c5c
commit
e8c02f121b
@@ -148,6 +148,10 @@ int vm_aspace_id(struct vm_gk20a *vm)
|
||||
|
||||
int nvgpu_vm_bind_channel(struct vm_gk20a *vm, struct nvgpu_channel *ch)
|
||||
{
|
||||
if (ch == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
nvgpu_log_fn(ch->g, " ");
|
||||
|
||||
nvgpu_vm_get(vm);
|
||||
|
||||
@@ -821,6 +821,15 @@ int test_vm_bind(struct unit_module *m, struct gk20a *g, void *__args)
|
||||
|
||||
vm = create_test_vm(m, g);
|
||||
|
||||
/* Error testing */
|
||||
g->ops.mm.vm_bind_channel(vm, NULL);
|
||||
if (channel->vm == vm) {
|
||||
ret = UNIT_FAIL;
|
||||
unit_err(m, "nvgpu_vm_bind_channel did not fail as expected.\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Succesfull call */
|
||||
g->ops.mm.vm_bind_channel(vm, channel);
|
||||
|
||||
if (channel->vm != vm) {
|
||||
@@ -831,6 +840,7 @@ int test_vm_bind(struct unit_module *m, struct gk20a *g, void *__args)
|
||||
|
||||
ret = UNIT_SUCCESS;
|
||||
exit:
|
||||
g->fifo.channel = NULL;
|
||||
free(channel);
|
||||
nvgpu_vm_put(vm);
|
||||
return ret;
|
||||
|
||||
@@ -286,7 +286,7 @@ int test_nvgpu_vm_alloc_va(struct unit_module *m, struct gk20a *g,
|
||||
*
|
||||
* Description: This test targets the nvgpu_vm_bind_channel API.
|
||||
*
|
||||
* Test Type: Feature
|
||||
* Test Type: Feature, Error injection
|
||||
*
|
||||
* Targets: gops_mm.vm_bind_channel, nvgpu_vm_bind_channel
|
||||
*
|
||||
@@ -299,6 +299,8 @@ int test_nvgpu_vm_alloc_va(struct unit_module *m, struct gk20a *g,
|
||||
* - Address space size = 128GB
|
||||
* - Kernel reserved space size = 4GB
|
||||
* - Create an empty nvgpu_channel instance.
|
||||
* - Call the nvgpu_vm_bind_channel with a NULL channel pointer and ensure it
|
||||
* failed.
|
||||
* - Call the nvgpu_vm_bind_channel API with the empty channel instance.
|
||||
* - Ensure that after the call, the VM pointer in the nvgpu_channel structure
|
||||
* points to the VM in use in the test.
|
||||
|
||||
Reference in New Issue
Block a user