]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amdgpu/dma_buf: fix page_link check
authorMatthew Auld <matthew.auld@intel.com>
Mon, 7 Apr 2025 14:18:25 +0000 (15:18 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Apr 2025 18:31:45 +0000 (14:31 -0400)
The page_link lower bits of the first sg could contain something like
SG_END, if we are mapping a single VRAM page or contiguous blob which
fits into one sg entry. Rather pull out the struct page, and use that in
our check to know if we mapped struct pages vs VRAM.

Fixes: f44ffd677fb3 ("drm/amdgpu: add support for exporting VRAM using DMA-buf v3")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.8+
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

index 9f627caedc3f6144a8b8e679ab67ee049cebbb4b..c9842a0e2a1cd45e898bb8cf2102be642889e1a1 100644 (file)
@@ -184,7 +184,7 @@ static void amdgpu_dma_buf_unmap(struct dma_buf_attachment *attach,
                                 struct sg_table *sgt,
                                 enum dma_data_direction dir)
 {
-       if (sgt->sgl->page_link) {
+       if (sg_page(sgt->sgl)) {
                dma_unmap_sgtable(attach->dev, sgt, dir, 0);
                sg_free_table(sgt);
                kfree(sgt);