On 5/20/26 12:16, Thomas Hellström wrote: > Drivers were accessing this drm_exec member directly. > While that may seem harmless, it will require action if > the drm_exec utility is made a subclass of a dma-resv transaction > utility as outlined in the cover-letter. > > Provide an accessor, drm_exec_ticket() to avoid that. > > v2: > - Fix amdgpu compile error (Intel CI) > - Update the commit message. > > Signed-off-by: Thomas Hellström <[email protected]>
Reviewed-by: Christian König <[email protected]> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++--- > drivers/gpu/drm/xe/xe_validation.c | 4 ++-- > include/drm/drm_exec.h | 11 +++++++++++ > 4 files changed, 18 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > index 72a5a29e63f6..d54794e5b18b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c > @@ -2999,7 +2999,7 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, > struct dma_fence __rcu * > /* Validate PDs, PTs and evicted DMABuf imports last. Otherwise BO > * validations above would invalidate DMABuf imports again. > */ > - ret = process_validate_vms(process_info, &exec.ticket); > + ret = process_validate_vms(process_info, drm_exec_ticket(&exec)); > if (ret) { > pr_debug("Validating VMs failed, ret: %d\n", ret); > goto validate_map_fail; > @@ -3040,7 +3040,7 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, > struct dma_fence __rcu * > goto validate_map_fail; > } > > - ret = amdgpu_vm_handle_moved(adev, peer_vm, &exec.ticket); > + ret = amdgpu_vm_handle_moved(adev, peer_vm, > drm_exec_ticket(&exec)); > if (ret) { > dev_dbg(adev->dev, > "Memory eviction: handle moved failed, pid %8d. > Try again.\n", > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > index 97a851ae7bd8..6ada57abce9d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > @@ -1157,7 +1157,7 @@ static int amdgpu_cs_vm_handling(struct > amdgpu_cs_parser *p) > return r; > } > > - r = amdgpu_vm_handle_moved(adev, vm, &p->exec.ticket); > + r = amdgpu_vm_handle_moved(adev, vm, drm_exec_ticket(&p->exec)); > if (r) > return r; > > @@ -1359,7 +1359,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, > cs->out.handle = seq; > leader->uf_sequence = seq; > > - amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->exec.ticket); > + amdgpu_vm_bo_trace_cs(&fpriv->vm, drm_exec_ticket(&p->exec)); > for (i = 0; i < p->gang_size; ++i) { > amdgpu_job_free_resources(p->jobs[i]); > trace_amdgpu_cs_ioctl(p->jobs[i]); > @@ -1794,7 +1794,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser > *parser, > *map = mapping; > > /* Double check that the BO is reserved by this CS */ > - if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket) > + if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != > drm_exec_ticket(&parser->exec)) > return -EINVAL; > > /* Make sure VRAM is allocated contigiously */ > diff --git a/drivers/gpu/drm/xe/xe_validation.c > b/drivers/gpu/drm/xe/xe_validation.c > index a611438eaafe..8dff4d0ec895 100644 > --- a/drivers/gpu/drm/xe/xe_validation.c > +++ b/drivers/gpu/drm/xe/xe_validation.c > @@ -156,7 +156,7 @@ int xe_validation_ctx_init(struct xe_validation_ctx *ctx, > struct xe_validation_d > > #ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH > /* > - * This abuses both drm_exec and ww_mutex internals and should be > + * This abuses ww_mutex internals and should be > * replaced by checking for -EDEADLK when we can make TTM > * stop converting -EDEADLK to -ENOMEM. > * An alternative is to not have exhaustive eviction with > @@ -164,7 +164,7 @@ int xe_validation_ctx_init(struct xe_validation_ctx *ctx, > struct xe_validation_d > */ > static bool xe_validation_contention_injected(struct drm_exec *exec) > { > - return !!exec->ticket.contending_lock; > + return !!drm_exec_ticket(exec)->contending_lock; > } > > #else > diff --git a/include/drm/drm_exec.h b/include/drm/drm_exec.h > index 99c7e1bb3c5b..8725ba92ff91 100644 > --- a/include/drm/drm_exec.h > +++ b/include/drm/drm_exec.h > @@ -161,6 +161,17 @@ static inline bool drm_exec_is_contended(struct drm_exec > *exec) > goto *__drm_exec_retry_ptr; \ > } while (0) > > +/** > + * drm_exec_ticket - return the ww_acquire_ctx for this exec context > + * @exec: drm_exec object > + * > + * Return: Pointer to the ww_acquire_ctx embedded in @exec. > + */ > +static inline struct ww_acquire_ctx *drm_exec_ticket(struct drm_exec *exec) > +{ > + return &exec->ticket; > +} > + > void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr); > void drm_exec_fini(struct drm_exec *exec); > bool drm_exec_cleanup(struct drm_exec *exec);
