Skip to content

Commit 50af7ca

Browse files
trusinowiczThomas Hellström
authored andcommitted
drm/xe: Fix exporting xe buffers multiple times
The `struct ttm_resource->placement` contains TTM_PL_FLAG_* flags, but it was incorrectly tested for XE_PL_* flags. This caused xe_dma_buf_pin() to always fail when invoked for the second time. Fix this by checking the `mem_type` field instead. Fixes: 7764222 ("drm/xe: Disallow pinning dma-bufs in VRAM") Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Nirmoy Das <nirmoy.das@intel.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: intel-xe@lists.freedesktop.org Cc: <stable@vger.kernel.org> # v6.8+ Signed-off-by: Tomasz Rusinowicz <tomasz.rusinowicz@intel.com> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250218100353.2137964-1-jacek.lawrynowicz@linux.intel.com Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> (cherry picked from commit b96dabd) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent f5d4e81 commit 50af7ca

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

drivers/gpu/drm/xe/xe_bo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ static inline unsigned int xe_sg_segment_size(struct device *dev)
341341
return round_down(max / 2, PAGE_SIZE);
342342
}
343343

344-
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
345344
/**
346345
* xe_bo_is_mem_type - Whether the bo currently resides in the given
347346
* TTM memory type
@@ -356,4 +355,3 @@ static inline bool xe_bo_is_mem_type(struct xe_bo *bo, u32 mem_type)
356355
return bo->ttm.resource->mem_type == mem_type;
357356
}
358357
#endif
359-
#endif

drivers/gpu/drm/xe/xe_dma_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int xe_dma_buf_pin(struct dma_buf_attachment *attach)
5858
* 1) Avoid pinning in a placement not accessible to some importers.
5959
* 2) Pinning in VRAM requires PIN accounting which is a to-do.
6060
*/
61-
if (xe_bo_is_pinned(bo) && bo->ttm.resource->placement != XE_PL_TT) {
61+
if (xe_bo_is_pinned(bo) && !xe_bo_is_mem_type(bo, XE_PL_TT)) {
6262
drm_dbg(&xe->drm, "Can't migrate pinned bo for dma-buf pin.\n");
6363
return -EINVAL;
6464
}

0 commit comments

Comments
 (0)