gpu: nvgpu: return 40 bit addr from nvgpu_mem_userspace_get_addr

For some of the unit tests cpu va for malloc'd buffers was going above
4gb and assert about 4gb is hit. HW supports 40 bit physical address.
Hence return 40 bit address instead of 32 bit address.

Bug 3862385

Change-Id: Ia8cc71d7e7356f2de8d0a4ba1e17f2a2cef0fe10
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2805596
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Sagar Kamble
2022-11-09 11:07:02 +05:30
committed by mobile promotions
parent ae5488c495
commit 2b69b9b264

View File

@@ -46,14 +46,12 @@
* number of bits, depending on chip).
*
* However, this does lead to some potential quirks: GPU addresses of different
* CPU virtual addresses could alias (e.g B and B + 4GB will both result in the
* same value when ANDing with 0xFFFFFFFF.
* CPU virtual addresses could alias (e.g B and B + 1024GB will both result in
* the same value when ANDing with 0xFFFFFFFFFF.
*
* If there is a buffer with an address range that crosses a 4GB boundary it'll
* If there is a buffer with an address range that crosses a 1024GB boundary it'll
* be detected here. A more sophisticated buffer to GPU virtual address approach
* could be taken, but for now this is probably sufficient. At least for one run
* through the unit test framework, the CPU malloc() address range seemed to be
* 0x555555000000 - this is a long way away from any 4GB boundary.
* could be taken, but for now this is probably sufficient.
*
* For invalid nvgpu_mems and nvgpu_mems with no cpu_va, just return NULL.
* There's little else we can do. In many cases in the unit test FW we wind up
@@ -61,8 +59,8 @@
*/
static u64 nvgpu_mem_userspace_get_addr(struct gk20a *g, struct nvgpu_mem *mem)
{
u64 hi_front = ((u64)(uintptr_t)mem->cpu_va) & ~0xffffffffUL;
u64 hi_back = ((u64)(uintptr_t)mem->cpu_va + mem->size - 1U) & ~0xffffffffUL;
u64 hi_front = ((u64)(uintptr_t)mem->cpu_va) & ~0xffffffffffUL;
u64 hi_back = ((u64)(uintptr_t)mem->cpu_va + mem->size - 1U) & ~0xffffffffffUL;
if (!nvgpu_mem_is_valid(mem) || mem->cpu_va == NULL) {
return 0x0UL;
@@ -79,7 +77,7 @@ static u64 nvgpu_mem_userspace_get_addr(struct gk20a *g, struct nvgpu_mem *mem)
nvgpu_assert(hi_front == hi_back);
return ((u64)(uintptr_t)mem->cpu_va) & 0xffffffffUL;
return ((u64)(uintptr_t)mem->cpu_va) & 0xffffffffffUL;
}
u64 nvgpu_mem_get_addr(struct gk20a *g, struct nvgpu_mem *mem)