<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2024-04-23 09:32, Christian König
wrote:<br>
</div>
<blockquote type="cite" cite="mid:a7779c0e-124e-4fee-b884-b0cc7075554d@amd.com">Am
23.04.24 um 15:04 schrieb Philip Yang:
<br>
<blockquote type="cite">To test RDMA using dummy driver on the
system without NIC/RDMA
<br>
device, the get/put dma pages pass in null device pointer, skip
the
<br>
dma map/unmap resource and sg table to avoid null pointer
access.
<br>
</blockquote>
<br>
Well just to make it clear this patch is really a no-go for
upstreaming.
<br>
<br>
The RDMA code isn't upstream as far as I know and doing this here
is really not a good idea even internally.
<br>
</blockquote>
<p>Right, this change is not needed and not related to upstream,
just to minimize the difference with upstream.</p>
<p>I will not upstream this patch.</p>
<p>Regards,</p>
<p>Philip<br>
</p>
<blockquote type="cite" cite="mid:a7779c0e-124e-4fee-b884-b0cc7075554d@amd.com">
<br>
Regards,
<br>
Christian.
<br>
<br>
<blockquote type="cite">
<br>
Signed-off-by: Philip Yang <a class="moz-txt-link-rfc2396E" href="mailto:Philip.Yang@amd.com"><Philip.Yang@amd.com></a>
<br>
---
<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 33
+++++++++++---------
<br>
1 file changed, 19 insertions(+), 14 deletions(-)
<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
<br>
index 6c7133bf51d8..101a85263b53 100644
<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
<br>
@@ -698,12 +698,15 @@ int amdgpu_vram_mgr_alloc_sgt(struct
amdgpu_device *adev,
<br>
unsigned long size = min(cursor.size,
MAX_SG_SEGMENT_SIZE);
<br>
dma_addr_t addr;
<br>
- addr = dma_map_resource(dev, phys, size, dir,
<br>
- DMA_ATTR_SKIP_CPU_SYNC);
<br>
- r = dma_mapping_error(dev, addr);
<br>
- if (r)
<br>
- goto error_unmap;
<br>
-
<br>
+ if (dev) {
<br>
+ addr = dma_map_resource(dev, phys, size, dir,
<br>
+ DMA_ATTR_SKIP_CPU_SYNC);
<br>
+ r = dma_mapping_error(dev, addr);
<br>
+ if (r)
<br>
+ goto error_unmap;
<br>
+ } else {
<br>
+ addr = phys;
<br>
+ }
<br>
sg_set_page(sg, NULL, size, 0);
<br>
sg_dma_address(sg) = addr;
<br>
sg_dma_len(sg) = size;
<br>
@@ -717,10 +720,10 @@ int amdgpu_vram_mgr_alloc_sgt(struct
amdgpu_device *adev,
<br>
for_each_sgtable_sg((*sgt), sg, i) {
<br>
if (!sg->length)
<br>
continue;
<br>
-
<br>
- dma_unmap_resource(dev, sg->dma_address,
<br>
- sg->length, dir,
<br>
- DMA_ATTR_SKIP_CPU_SYNC);
<br>
+ if (dev)
<br>
+ dma_unmap_resource(dev, sg->dma_address,
<br>
+ sg->length, dir,
<br>
+ DMA_ATTR_SKIP_CPU_SYNC);
<br>
}
<br>
sg_free_table(*sgt);
<br>
@@ -745,10 +748,12 @@ void amdgpu_vram_mgr_free_sgt(struct
device *dev,
<br>
struct scatterlist *sg;
<br>
int i;
<br>
- for_each_sgtable_sg(sgt, sg, i)
<br>
- dma_unmap_resource(dev, sg->dma_address,
<br>
- sg->length, dir,
<br>
- DMA_ATTR_SKIP_CPU_SYNC);
<br>
+ if (dev) {
<br>
+ for_each_sgtable_sg(sgt, sg, i)
<br>
+ dma_unmap_resource(dev, sg->dma_address,
<br>
+ sg->length, dir,
<br>
+ DMA_ATTR_SKIP_CPU_SYNC);
<br>
+ }
<br>
sg_free_table(sgt);
<br>
kfree(sgt);
<br>
}
<br>
</blockquote>
<br>
</blockquote>
</body>
</html>