[PATCH] drm/xe: Have LRC hold VM reference
Niranjana Vishwanathapura
niranjana.vishwanathapura at intel.com
Thu May 22 18:08:12 UTC 2025
On Thu, May 22, 2025 at 11:02:47AM -0700, Summers, Stuart wrote:
>On Wed, 2025-05-21 at 18:22 -0700, Niranjana Vishwanathapura wrote:
>> LRC's BO uses VM's dma_resv object. Have LRC hold
>> VM reference.
>>
>> Signed-off-by: Niranjana Vishwanathapura
>> <niranjana.vishwanathapura at intel.com>
>
>This covers the case where the VM is closed out from under the LRC and
>the LRC BO tries to access the now unreferenced object, so:
>Reviewed-by: Stuart Summers <stuart.summers at intel.com>
>
Thanks.
>But longer term it would be nice to decouple this in a way that allows
>these two to be referenced/dereferenced independently.
>
They can be referenced/dereference independently now also.
But LRC has a dependency on VM here. So, it should hold VM reference.
Earlier LRC and exec_queue were tied together and exec_queue was
ensuring VM reference is held. But now LRC is decoupled from exec_queue.
So, now LRC must ensure VM reference is held.
Niranjana
>Thanks,
>Stuart
>
>> ---
>> drivers/gpu/drm/xe/xe_lrc.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_lrc.c
>> b/drivers/gpu/drm/xe/xe_lrc.c
>> index 61a2e87990a9..efdf4ef35b35 100644
>> --- a/drivers/gpu/drm/xe/xe_lrc.c
>> +++ b/drivers/gpu/drm/xe/xe_lrc.c
>> @@ -908,12 +908,17 @@ static void xe_lrc_set_ppgtt(struct xe_lrc
>> *lrc, struct xe_vm *vm)
>>
>> static void xe_lrc_finish(struct xe_lrc *lrc)
>> {
>> + struct xe_vm *vm = lrc->bo->vm;
>> +
>> xe_hw_fence_ctx_finish(&lrc->fence_ctx);
>> xe_bo_lock(lrc->bo, false);
>> xe_bo_unpin(lrc->bo);
>> xe_bo_unlock(lrc->bo);
>> xe_bo_put(lrc->bo);
>> xe_bo_unpin_map_no_vm(lrc->bb_per_ctx_bo);
>> +
>> + if (vm)
>> + xe_vm_put(vm);
>> }
>>
>> /*
>> @@ -1013,6 +1018,10 @@ static int xe_lrc_init(struct xe_lrc *lrc,
>> struct xe_hw_engine *hwe,
>> if (IS_ERR(lrc->bo))
>> return PTR_ERR(lrc->bo);
>>
>> + /* The lrc->bo uses VM's dma_resv object, take VM reference
>> */
>> + if (vm)
>> + xe_vm_get(vm);
>> +
>> lrc->bb_per_ctx_bo = xe_bo_create_pin_map(xe, tile, NULL,
>> SZ_4K,
>> ttm_bo_type_kernel,
>> bo_flags);
>
More information about the Intel-xe
mailing list