Add xe_hw_fence_user_init which can create a struct xe_hw_fence from a user input rather than internal LRC state. Used to import user fence and export them as dma fences. Signed-off-by: Matthew Brost <matthew.brost@xxxxxxxxx> --- drivers/gpu/drm/xe/xe_hw_fence.c | 17 +++++++++++++++++ drivers/gpu/drm/xe/xe_hw_fence.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_hw_fence.c b/drivers/gpu/drm/xe/xe_hw_fence.c index 0b4f12be3692..2ea4d8bca6eb 100644 --- a/drivers/gpu/drm/xe/xe_hw_fence.c +++ b/drivers/gpu/drm/xe/xe_hw_fence.c @@ -263,3 +263,20 @@ void xe_hw_fence_init(struct dma_fence *fence, struct xe_hw_fence_ctx *ctx, trace_xe_hw_fence_create(hw_fence); } + +void xe_hw_fence_user_init(struct dma_fence *fence, struct xe_device *xe, + struct iosys_map seqno_map, u64 seqno) +{ + struct xe_hw_fence *hw_fence = + container_of(fence, typeof(*hw_fence), dma); + + hw_fence->xe = xe; + snprintf(hw_fence->name, sizeof(hw_fence->name), "user"); + hw_fence->seqno_map = seqno_map; + + INIT_LIST_HEAD(&hw_fence->irq_link); + dma_fence_init(fence, &xe_hw_fence_ops, &xe->user_fence_irq.lock, + dma_fence_context_alloc(1), seqno); + + trace_xe_hw_fence_create(hw_fence); +} diff --git a/drivers/gpu/drm/xe/xe_hw_fence.h b/drivers/gpu/drm/xe/xe_hw_fence.h index f13a1c4982c7..76571ef2ef36 100644 --- a/drivers/gpu/drm/xe/xe_hw_fence.h +++ b/drivers/gpu/drm/xe/xe_hw_fence.h @@ -30,4 +30,7 @@ void xe_hw_fence_free(struct dma_fence *fence); void xe_hw_fence_init(struct dma_fence *fence, struct xe_hw_fence_ctx *ctx, struct iosys_map seqno_map); +void xe_hw_fence_user_init(struct dma_fence *fence, struct xe_device *xe, + struct iosys_map seqno_map, u64 seqno); + #endif -- 2.34.1