All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Akash Goel <akash.goel@arm.com>
Cc: "Steven Price" <steven.price@arm.com>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>,
	dri-devel@lists.freedesktop.org,
	"Lars-Ivar Hesselberg Simonsen" <lars-ivar.simonsen@arm.com>,
	kernel@collabora.com
Subject: Re: [PATCH v1 3/4] drm/panthor: Make panthor_vm_[un]map_pages() more robust
Date: Tue, 4 Nov 2025 08:43:32 +0100	[thread overview]
Message-ID: <20251104084332.3838c081@fedora> (raw)
In-Reply-To: <dedbbff4-0c06-4d6d-b3dd-73cdc592a98e@arm.com>

On Mon, 3 Nov 2025 21:00:58 +0000
Akash Goel <akash.goel@arm.com> 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 <boris.brezillon@collabora.com>
> > ---
> >   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	other threads:[~2025-11-04  7:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 15:48 [PATCH v1 0/4] drm/panthor: Misc fixes Boris Brezillon
2025-10-31 15:48 ` [PATCH v1 1/4] drm/panthor: Fix UAF on kernel BO VA nodes Boris Brezillon
2025-11-03 11:10   ` Liviu Dudau
2025-11-03 14:34   ` Liviu Dudau
2025-10-31 15:48 ` [PATCH v1 2/4] drm/panthor: Add support for atomic page table updates Boris Brezillon
2025-11-07 16:26   ` Steven Price
2025-11-07 17:14     ` Boris Brezillon
2025-10-31 15:48 ` [PATCH v1 3/4] drm/panthor: Make panthor_vm_[un]map_pages() more robust Boris Brezillon
2025-11-03 21:00   ` Akash Goel
2025-11-04  7:43     ` Boris Brezillon [this message]
2025-10-31 15:48 ` [PATCH v1 4/4] drm/panthor: Relax check in panthor_sched_pre_reset() Boris Brezillon
2025-11-07 16:40   ` Steven Price
2025-11-12 12:47     ` Boris Brezillon
2025-11-17  9:49       ` Steven Price
2025-11-17 10:26         ` Boris Brezillon
2025-11-17 11:07           ` Steven Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251104084332.3838c081@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=akash.goel@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=lars-ivar.simonsen@arm.com \
    --cc=liviu.dudau@arm.com \
    --cc=steven.price@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.