Re: [PATCH v8 5/6] drm/panthor: Support sparse mappings

From: Boris Brezillon

Date: Wed Apr 22 2026 - 03:43:33 EST


On Tue, 21 Apr 2026 22:44:18 +0100
Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> wrote:

> >
> > Also, how about we do a
> >
> > gem = drm_gem_object_get(&vm->dummy->base)
>
> I'm afraid drm_gem_object_get() doesn't return a pointer to the same object. Other drivers work around this
> by defining their own refcnt macro like:
>
> static inline struct xe_bo *xe_bo_get(struct xe_bo *bo)
> {
> if (bo)
> drm_gem_object_get(&bo->ttm.base);
>
> return bo;
> }
>
> However, this is meant to operate on the driver-specific bo rather than a generic DRM one. We could also do this:
>
> if (!(op->flags & DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE))
> gem = drm_gem_object_lookup(file, op->bo_handle);
> else
> drm_gem_object_get(gem = &vm->dummy->base);

If it's just this single instance, let's go for:

if (!(op->flags & DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE)) {
gem = drm_gem_object_lookup(file, op->bo_handle);
} else {
gem = &vm->dummy->base;
drm_gem_object_get(gem);
}

If there are multiple places where we want to acquire a
panthor_gem_object ref, it might make sense to add those
panthor_bo_{get,put}() helpers.