On Mon, 3 Nov 2025 21:00:58 +0000
Akash Goel <[email protected]> wrote:

> On 10/31/25 15:48, Boris Brezillon wrote:
> > There's no reason for panthor_vm_[un]map_pages() to fail unless the
> > drm_gpuvm state and the page table are out of sync, so let's reflect that
> > by making panthor_vm_unmap_pages() a void function and adding
> > WARN_ON()s in various places. We also try to recover from those
> > unexpected mismatch by checking for already unmapped ranges and skipping
> > them. But there's only so much we can do to try and cope with such
> > SW bugs, so when we see a mismatch, we flag the VM unusable and disable
> > the AS to avoid further GPU accesses to the memory.
> >
> > It could be that the as_disable() call fails because the MMU unit is
> > stuck, in which case the whole GPU is frozen, and only a GPU reset can
> > unblock things. Ater the reset, the VM will be seen as unusable and
> > any attempt to re-use it will fail, so we should be covered for any
> > use-after-unmap issues.
> >
> > Signed-off-by: Boris Brezillon <[email protected]>
> > ---
> >   drivers/gpu/drm/panthor/panthor_mmu.c | 82 ++++++++++++++++++---------
> >   1 file changed, 55 insertions(+), 27 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c 
> > b/drivers/gpu/drm/panthor/panthor_mmu.c
> > index ea886c8ac97f..a4f3ed04b5cc 100644
> > --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> > @@ -846,12 +846,32 @@ static size_t get_pgsize(u64 addr, size_t size, 
> > size_t *count)
> >       return SZ_2M;
> >   }
> >
> > -static int panthor_vm_unmap_pages(struct panthor_vm *vm, u64 iova, u64 
> > size)
> > +static void panthor_vm_declare_unusable(struct panthor_vm *vm)
> > +{
> > +     struct panthor_device *ptdev = vm->ptdev;
> > +     int cookie;
> > +
> > +     if (vm->unusable)
> > +             return;
> > +
> > +     vm->unusable = true;
> > +     mutex_unlock(&ptdev->mmu->as.slots_lock);  
> 
> Please fix this. Need to call mutex_lock.

Oops. Will fix.

> 
> 
> > +     if (vm->as.id >= 0 && drm_dev_enter(&ptdev->base, &cookie)) {
> > +             panthor_mmu_as_disable(ptdev, vm->as.id);
> > +             drm_dev_exit(cookie);
> > +     }
> > +     mutex_unlock(&ptdev->mmu->as.slots_lock);
> > +}
> > +
> > +static void panthor_vm_unmap_pages(struct panthor_vm *vm, u64 iova, u64 
> > size)  
> 
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.

Reply via email to