[Freedreno] [PATCH v2 07/10] drm/msm/gem: Rework vma lookup and pin
Rob Clark
robdclark at gmail.com
Thu Mar 31 18:58:36 UTC 2022
On Thu, Mar 31, 2022 at 11:27 AM Dmitry Osipenko
<dmitry.osipenko at collabora.com> wrote:
>
> On 3/30/22 23:47, Rob Clark wrote:
> > From: Rob Clark <robdclark at chromium.org>
> >
> > Combines duplicate vma lookup in the get_and_pin path.
> >
> > Signed-off-by: Rob Clark <robdclark at chromium.org>
> > ---
> > drivers/gpu/drm/msm/msm_gem.c | 50 ++++++++++++++++++-----------------
> > 1 file changed, 26 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> > index deafae6feaa8..218744a490a4 100644
> > --- a/drivers/gpu/drm/msm/msm_gem.c
> > +++ b/drivers/gpu/drm/msm/msm_gem.c
> > @@ -376,39 +376,40 @@ put_iova_vmas(struct drm_gem_object *obj)
> > }
> > }
> >
> > -static int get_iova_locked(struct drm_gem_object *obj,
> > - struct msm_gem_address_space *aspace, uint64_t *iova,
> > +static struct msm_gem_vma *get_vma_locked(struct drm_gem_object *obj,
> > + struct msm_gem_address_space *aspace,
> > u64 range_start, u64 range_end)
> > {
> > struct msm_gem_vma *vma;
> > - int ret = 0;
> >
> > GEM_WARN_ON(!msm_gem_is_locked(obj));
> >
> > vma = lookup_vma(obj, aspace);
> >
> > if (!vma) {
> > + int ret;
> > +
> > vma = add_vma(obj, aspace);
> > if (IS_ERR(vma))
> > - return PTR_ERR(vma);
> > + return vma;
> >
> > ret = msm_gem_init_vma(aspace, vma, obj->size,
> > range_start, range_end);
> > if (ret) {
> You're allocation range_start -> range_end
>
>
> > del_vma(vma);
> > - return ret;
> > + return ERR_PTR(ret);
> > }
> > + } else {
> > + GEM_WARN_ON(vma->iova < range_start);
> > + GEM_WARN_ON((vma->iova + obj->size) > range_end);
>
> and then comparing range_start -> range_start + obj->size, hence you're
> assuming that range_end always equals to obj->size during the allocation.
>
> I'm not sure what is the idea here.. this looks inconsistent. I think
> you wanted to write:
>
> GEM_WARN_ON(vma->iova < range_start);
> GEM_WARN_ON(vma->iova + (vma->node.size << PAGE_SHIFT) > range_end);
>
> But is it really useful to check whether the new range is inside of the
> old range? Shouldn't it be always a error to change the IOVA range
> without reallocating vma?
There are a few cases (for allocations for GMU) where the range is
larger than the bo.. see a6xx_gmu_memory_alloc()
BR,
-R
>
> I'd expect to see:
>
> GEM_WARN_ON(vma->iova != range_start);
> GEM_WARN_ON(vma->iova + (vma->node.size << PAGE_SHIFT) != range_end);
>
> and then error out if range mismatches.
More information about the Freedreno
mailing list