mirror of
https://github.com/NVIDIA/open-gpu-kernel-modules.git
synced 2026-02-10 10:09:58 +00:00
560.28.03
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2015-2023 NVIDIA Corporation
|
||||
Copyright (c) 2015-2024 NVIDIA Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
@@ -898,11 +898,11 @@ NV_STATUS uvm_test_pmm_check_leak(UVM_TEST_PMM_CHECK_LEAK_PARAMS *params, struct
|
||||
return status;
|
||||
}
|
||||
|
||||
NV_STATUS __test_pmm_async_alloc_type(uvm_va_space_t *va_space,
|
||||
uvm_gpu_t *gpu,
|
||||
size_t num_chunks,
|
||||
uvm_pmm_gpu_memory_type_t mem_type,
|
||||
size_t work_iterations)
|
||||
static NV_STATUS __test_pmm_async_alloc_type(uvm_va_space_t *va_space,
|
||||
uvm_gpu_t *gpu,
|
||||
size_t num_chunks,
|
||||
uvm_pmm_gpu_memory_type_t mem_type,
|
||||
size_t work_iterations)
|
||||
{
|
||||
NV_STATUS status;
|
||||
NV_STATUS tracker_status = NV_OK;
|
||||
@@ -1199,120 +1199,6 @@ exit_unlock:
|
||||
return status;
|
||||
}
|
||||
|
||||
static NV_STATUS test_indirect_peers(uvm_gpu_t *owning_gpu, uvm_gpu_t *accessing_gpu)
|
||||
{
|
||||
uvm_pmm_gpu_t *pmm = &owning_gpu->pmm;
|
||||
size_t chunk_size = uvm_chunk_find_first_size(pmm->chunk_sizes[UVM_PMM_GPU_MEMORY_TYPE_USER]);
|
||||
uvm_gpu_chunk_t *parent_chunk = NULL;
|
||||
uvm_gpu_chunk_t **chunks = NULL;
|
||||
size_t i, num_chunks = UVM_CHUNK_SIZE_MAX / chunk_size;
|
||||
NV_STATUS tracker_status, status = NV_OK;
|
||||
uvm_mem_t *verif_mem = NULL;
|
||||
uvm_tracker_t tracker = UVM_TRACKER_INIT();
|
||||
uvm_gpu_address_t local_addr;
|
||||
uvm_gpu_address_t peer_addr;
|
||||
NvU32 init_val = 0x12345678;
|
||||
NvU32 new_val = 0xabcdc0de;
|
||||
|
||||
chunks = uvm_kvmalloc_zero(num_chunks * sizeof(chunks[0]));
|
||||
if (!chunks)
|
||||
return NV_ERR_NO_MEMORY;
|
||||
|
||||
TEST_NV_CHECK_GOTO(uvm_mem_alloc_sysmem_and_map_cpu_kernel(UVM_CHUNK_SIZE_MAX, current->mm, &verif_mem), out);
|
||||
TEST_NV_CHECK_GOTO(uvm_mem_map_gpu_kernel(verif_mem, owning_gpu), out);
|
||||
TEST_NV_CHECK_GOTO(uvm_mem_map_gpu_kernel(verif_mem, accessing_gpu), out);
|
||||
|
||||
// Allocate a root chunk then split it to test multiple mappings across
|
||||
// contiguous chunks under the same root.
|
||||
TEST_NV_CHECK_GOTO(uvm_pmm_gpu_alloc_user(pmm,
|
||||
1,
|
||||
UVM_CHUNK_SIZE_MAX,
|
||||
UVM_PMM_ALLOC_FLAGS_EVICT,
|
||||
&parent_chunk,
|
||||
NULL), out);
|
||||
|
||||
TEST_NV_CHECK_GOTO(uvm_pmm_gpu_split_chunk(pmm, parent_chunk, chunk_size, chunks), out);
|
||||
parent_chunk = NULL;
|
||||
|
||||
// Verify contiguity and multiple mappings under a root chunk
|
||||
for (i = 0; i < num_chunks; i++) {
|
||||
TEST_NV_CHECK_GOTO(uvm_pmm_gpu_indirect_peer_map(pmm, chunks[i], accessing_gpu), out);
|
||||
TEST_CHECK_GOTO(uvm_pmm_gpu_indirect_peer_addr(pmm, chunks[i], accessing_gpu) ==
|
||||
uvm_pmm_gpu_indirect_peer_addr(pmm, chunks[0], accessing_gpu) + i * chunk_size,
|
||||
out);
|
||||
}
|
||||
|
||||
// Check that accessing_gpu can read and write
|
||||
local_addr = chunk_copy_addr(owning_gpu, chunks[0]);
|
||||
peer_addr = uvm_pmm_gpu_peer_copy_address(&owning_gpu->pmm, chunks[0], accessing_gpu);
|
||||
|
||||
// Init on local GPU
|
||||
TEST_NV_CHECK_GOTO(do_memset_4(owning_gpu, local_addr, init_val, UVM_CHUNK_SIZE_MAX, &tracker), out);
|
||||
|
||||
// Read using indirect peer and verify
|
||||
TEST_NV_CHECK_GOTO(gpu_mem_check(accessing_gpu,
|
||||
verif_mem,
|
||||
peer_addr,
|
||||
UVM_CHUNK_SIZE_MAX,
|
||||
init_val,
|
||||
&tracker), out);
|
||||
|
||||
// Write from indirect peer
|
||||
TEST_NV_CHECK_GOTO(do_memset_4(accessing_gpu, peer_addr, new_val, UVM_CHUNK_SIZE_MAX, &tracker), out);
|
||||
|
||||
// Read using local gpu and verify
|
||||
TEST_NV_CHECK_GOTO(gpu_mem_check(owning_gpu, verif_mem, local_addr, UVM_CHUNK_SIZE_MAX, new_val, &tracker), out);
|
||||
|
||||
out:
|
||||
tracker_status = uvm_tracker_wait_deinit(&tracker);
|
||||
if (status == NV_OK && tracker_status != NV_OK) {
|
||||
UVM_TEST_PRINT("Tracker wait failed\n");
|
||||
status = tracker_status;
|
||||
}
|
||||
|
||||
if (parent_chunk) {
|
||||
uvm_pmm_gpu_free(pmm, parent_chunk, NULL);
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < num_chunks; i++) {
|
||||
if (chunks[i])
|
||||
uvm_pmm_gpu_free(pmm, chunks[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (verif_mem)
|
||||
uvm_mem_free(verif_mem);
|
||||
|
||||
uvm_kvfree(chunks);
|
||||
return status;
|
||||
}
|
||||
|
||||
NV_STATUS uvm_test_pmm_indirect_peers(UVM_TEST_PMM_INDIRECT_PEERS_PARAMS *params, struct file *filp)
|
||||
{
|
||||
NV_STATUS status = NV_OK;
|
||||
uvm_va_space_t *va_space = uvm_va_space_get(filp);
|
||||
uvm_gpu_t *owning_gpu, *accessing_gpu;
|
||||
bool ran_test = false;
|
||||
|
||||
uvm_va_space_down_read(va_space);
|
||||
|
||||
for_each_va_space_gpu(owning_gpu, va_space) {
|
||||
for_each_va_space_gpu_in_mask(accessing_gpu, va_space, &va_space->indirect_peers[uvm_id_value(owning_gpu->id)]) {
|
||||
ran_test = true;
|
||||
status = test_indirect_peers(owning_gpu, accessing_gpu);
|
||||
if (status != NV_OK)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ran_test)
|
||||
status = NV_WARN_NOTHING_TO_DO;
|
||||
|
||||
out:
|
||||
uvm_va_space_up_read(va_space);
|
||||
return status;
|
||||
}
|
||||
|
||||
static NV_STATUS test_chunk_with_elevated_page(uvm_gpu_t *gpu)
|
||||
{
|
||||
uvm_pmm_gpu_t *pmm = &gpu->pmm;
|
||||
|
||||
Reference in New Issue
Block a user