[PATCH] drm/amdgpu: add new amdgpu_vm_bo_trace_cs() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 30, 2018 at 12:30:40AM +0800, Grodzovsky, Andrey wrote:
> When VM fault happens it helps verify a that a BO for the faulted VA wasn't omitted from the BO list for the CS.
> 

Good to know. Thanks, Andrey.

Ray

> Andrey
> 
> ________________________________________
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Huang Rui <ray.huang at amd.com>
> Sent: 29 July 2018 08:16:30
> To: Christian K?nig
> Cc: Grodzovsky, Andrey; amd-gfx at lists.freedesktop.org
> Subject: Re: [PATCH] drm/amdgpu: add new amdgpu_vm_bo_trace_cs() function
> 
> On Fri, Jul 27, 2018 at 04:57:43PM +0200, Christian K?nig wrote:
> > This allows us to trace all VM ranges which should be valid inside a CS.
> >
> > Signed-off-by: Christian K?nig <christian.koenig at amd.com>
> 
> Reviewed-by: Huang Rui <ray.huang at amd.com>
> 
> A bit curious, what kind of situation that we need trace all VM ranges
> during the command submission?
> 
> Thanks,
> Ray
> 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c    |  2 ++
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h |  5 +++++
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    | 30 ++++++++++++++++++++++++++++++
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h    |  1 +
> >  4 files changed, 38 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > index 8a49c3b97bd4..871401cd9997 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > @@ -1220,6 +1220,7 @@ static void amdgpu_cs_post_dependencies(struct amdgpu_cs_parser *p)
> >  static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
> >                           union drm_amdgpu_cs *cs)
> >  {
> > +     struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
> >       struct amdgpu_ring *ring = p->ring;
> >       struct drm_sched_entity *entity = &p->ctx->rings[ring->idx].entity;
> >       enum drm_sched_priority priority;
> > @@ -1272,6 +1273,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
> >       amdgpu_job_free_resources(job);
> >
> >       trace_amdgpu_cs_ioctl(job);
> > +     amdgpu_vm_bo_trace_cs(&fpriv->vm, &p->ticket);
> >       priority = job->base.s_priority;
> >       drm_sched_entity_push_job(&job->base, entity);
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> > index 11f262f15200..7206a0025b17 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
> > @@ -314,6 +314,11 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_mapping,
> >           TP_ARGS(mapping)
> >  );
> >
> > +DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
> > +         TP_PROTO(struct amdgpu_bo_va_mapping *mapping),
> > +         TP_ARGS(mapping)
> > +);
> > +
> >  TRACE_EVENT(amdgpu_vm_set_ptes,
> >           TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
> >                    uint32_t incr, uint64_t flags),
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > index 5d7d7900ccab..7aedf3184e36 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> > @@ -2343,6 +2343,36 @@ struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
> >       return amdgpu_vm_it_iter_first(&vm->va, addr, addr);
> >  }
> >
> > +/**
> > + * amdgpu_vm_bo_trace_cs - trace all reserved mappings
> > + *
> > + * @vm: the requested vm
> > + * @ticket: CS ticket
> > + *
> > + * Trace all mappings of BOs reserved during a command submission.
> > + */
> > +void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket)
> > +{
> > +     struct amdgpu_bo_va_mapping *mapping;
> > +
> > +     if (!trace_amdgpu_vm_bo_cs_enabled())
> > +             return;
> > +
> > +     for (mapping = amdgpu_vm_it_iter_first(&vm->va, 0, U64_MAX); mapping;
> > +          mapping = amdgpu_vm_it_iter_next(mapping, 0, U64_MAX)) {
> > +             struct amdgpu_bo *bo;
> > +
> > +             if (!mapping->bo_va || !mapping->bo_va->base.bo)
> > +                     continue;
> > +
> > +             bo = mapping->bo_va->base.bo;
> > +             if (READ_ONCE(bo->tbo.resv->lock.ctx) != ticket)
> > +                     continue;
> > +
> > +             trace_amdgpu_vm_bo_cs(mapping);
> > +     }
> > +}
> > +
> >  /**
> >   * amdgpu_vm_bo_rmv - remove a bo to a specific vm
> >   *
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> > index d416f895233d..67a15d439ac0 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
> > @@ -318,6 +318,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
> >                               uint64_t saddr, uint64_t size);
> >  struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
> >                                                        uint64_t addr);
> > +void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket);
> >  void amdgpu_vm_bo_rmv(struct amdgpu_device *adev,
> >                     struct amdgpu_bo_va *bo_va);
> >  void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size,
> > --
> > 2.14.1
> >
> > _______________________________________________
> > amd-gfx mailing list
> > amd-gfx at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux