From: Philip Yang <Philip.Yang@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <Felix.Kuehling@amd.com>, <christian.koenig@amd.com>,
<Arunpravin.PaneerSelvam@amd.com>,
Philip Yang <Philip.Yang@amd.com>
Subject: [PATCH v2 5/6] drm/amdgpu: Skip dma map resource for null RDMA device
Date: Thu, 18 Apr 2024 09:58:02 -0400 [thread overview]
Message-ID: <20240418135803.17365-6-Philip.Yang@amd.com> (raw)
In-Reply-To: <20240418135803.17365-1-Philip.Yang@amd.com>
To test RDMA using dummy driver on the system without NIC/RDMA
device, the get/put dma pages pass in null device pointer, skip the
dma map/unmap resource to avoid null pointer access.
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 33 +++++++++++---------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 2f2ae7177771..4c512a372ec7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -703,12 +703,15 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
size_t size = cursor.size;
dma_addr_t addr;
- addr = dma_map_resource(dev, phys, size, dir,
- DMA_ATTR_SKIP_CPU_SYNC);
- r = dma_mapping_error(dev, addr);
- if (r)
- goto error_unmap;
-
+ if (dev) {
+ addr = dma_map_resource(dev, phys, size, dir,
+ DMA_ATTR_SKIP_CPU_SYNC);
+ r = dma_mapping_error(dev, addr);
+ if (r)
+ goto error_unmap;
+ } else {
+ addr = phys;
+ }
sg_set_page(sg, NULL, size, 0);
sg_dma_address(sg) = addr;
sg_dma_len(sg) = size;
@@ -722,10 +725,10 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
for_each_sgtable_sg((*sgt), sg, i) {
if (!sg->length)
continue;
-
- dma_unmap_resource(dev, sg->dma_address,
- sg->length, dir,
- DMA_ATTR_SKIP_CPU_SYNC);
+ if (dev)
+ dma_unmap_resource(dev, sg->dma_address,
+ sg->length, dir,
+ DMA_ATTR_SKIP_CPU_SYNC);
}
sg_free_table(*sgt);
@@ -750,10 +753,12 @@ void amdgpu_vram_mgr_free_sgt(struct device *dev,
struct scatterlist *sg;
int i;
- for_each_sgtable_sg(sgt, sg, i)
- dma_unmap_resource(dev, sg->dma_address,
- sg->length, dir,
- DMA_ATTR_SKIP_CPU_SYNC);
+ if (dev) {
+ for_each_sgtable_sg(sgt, sg, i)
+ dma_unmap_resource(dev, sg->dma_address,
+ sg->length, dir,
+ DMA_ATTR_SKIP_CPU_SYNC);
+ }
sg_free_table(sgt);
kfree(sgt);
}
--
2.43.2
next prev parent reply other threads:[~2024-04-18 13:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 13:57 [PATCH v2 0/6] Best effort contiguous VRAM allocation Philip Yang
2024-04-18 13:57 ` [PATCH v2 1/6] drm/amdgpu: Support " Philip Yang
2024-04-18 14:37 ` Christian König
2024-04-18 20:50 ` Philip Yang
2024-04-18 13:57 ` [PATCH v2 2/6] drm/amdgpu: Evict BOs from same process for contiguous allocation Philip Yang
2024-04-18 13:58 ` [PATCH v2 3/6] drm/amdkfd: Evict BO itself " Philip Yang
2024-04-18 13:58 ` [PATCH v2 4/6] drm/amdkfd: Increase KFD bo restore wait time Philip Yang
2024-04-18 13:58 ` Philip Yang [this message]
2024-04-18 13:58 ` [PATCH v2 6/6] drm/amdkfd: Bump kfd version for contiguous VRAM allocation Philip Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240418135803.17365-6-Philip.Yang@amd.com \
--to=philip.yang@amd.com \
--cc=Arunpravin.PaneerSelvam@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.