mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	kernel@collabora.com, Liviu Dudau <liviu.dudau@arm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	Alice Ryhl <aliceryhl@google.com>
Subject: Re: [PATCH v11 5/6] drm/panthor: Support sparse mappings
Date: Wed, 20 May 2026 08:16:08 +0200	[thread overview]
Message-ID: <20260520081608.0122a1d4@fedora> (raw)
In-Reply-To: <agy06w1k_rbiZTFN@sobremesa>

On Tue, 19 May 2026 20:15:34 +0100
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:

> Hi Steven,
> 
> On 13.05.2026 16:46, Steven Price wrote:
> > On 07/05/2026 22:49, Adrián Larumbe wrote:  
> > > Allow UM to bind sparsely populated memory regions by cyclically mapping
> > > virtual ranges over a kernel-allocated dummy BO. This alternative is
> > > preferable to the old method of handling sparseness in the UMD, because it
> > > relied on the creation of a buffer object to the same end, despite the fact
> > > Vulkan sparse resources don't need to be backed by a driver BO.
> > >
> > > The choice of backing sparsely-bound regions with a Panthor BO was made so
> > > as to profit from the existing shrinker reclaim code. That way no special
> > > treatment must be given to the dummy sparse BOs when reclaiming memory, as
> > > would be the case if we had chosen a raw kernel page implementation.  
> >
> > Do you need to fix up the remap_evicted_vma() path though? At the moment
> > that will go through panthor_vm_map_pages() without doing the
> > panthor_fix_sparse_map_offset() dance. Also I suspect it won't map the
> > whole region (just the first 2MB in the sgtable).  
> 
> You're right, we need to account for the case in which the VMA is of the sparse kind
> and backed by the dummy BO. I suggest something as follows:
> 
> ``` diff
>  		ret = panthor_vm_lock_region(vm, evicted_vma->base.va.addr,
>  					     evicted_vma->base.va.range);
>  		if (!ret) {
> -			ret = panthor_vm_map_pages(vm, evicted_vma->base.va.addr,
> -						   flags_to_prot(evicted_vma->flags),
> -						   bo->dmap.sgt,
> -						   evicted_vma->base.gem.offset,
> -						   evicted_vma->base.va.range);
> +			struct drm_gpuva_op_map map_op = {
> +				.va.addr = evicted_vma->base.va.addr,
> +				.va.range = evicted_vma->base.va.range,
> +				.gem.obj = &bo->base,
> +				.gem.offset = evicted_vma->base.gem.offset,
> +			};
> +			if (evicted_vma->flags & DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE)
> +				drm_WARN_ON(&vm->ptdev->base, map_op.gem.offset !=
> +					    (map_op.va.addr & (SZ_2M - 1)));
> +
> +			ret = panthor_vm_exec_map_op(vm, evicted_vma->flags, &map_op);
>  			if (!ret)
>  				evicted_vma->evicted = false;
> ```
> 
> However, it seems to me there's no need for panthor_fix_sparse_map_offset() in this code path,
> because a VMA should always have the right gem offset even after eviction. This holds true in
> the event of an sm_remap of a VMA that had already been evicted.

Yep, I think you're right.

> 
> This led me to think doing a WARN_ON test on the offset is the right way to go.

A WARN_ON[_ONCE]() would do, yes.

  reply	other threads:[~2026-05-20  6:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 21:49 [PATCH v11 0/6] Support sparse mappings in Panthor Adrián Larumbe
2026-05-07 21:49 ` [PATCH v11 1/6] drm/panthor: Expose GPU page sizes to UM Adrián Larumbe
2026-05-07 21:49 ` [PATCH v11 2/6] drm/panthor: Pass vm_bind_op to vm_prepare_map_op_ctx Adrián Larumbe
2026-05-07 21:49 ` [PATCH v11 3/6] drm/panthor: Delete spurious whitespace from uAPI header Adrián Larumbe
2026-05-07 21:49 ` [PATCH v11 4/6] drm/panthor: Remove unused operation context field Adrián Larumbe
2026-05-07 21:49 ` [PATCH v11 5/6] drm/panthor: Support sparse mappings Adrián Larumbe
2026-05-13 15:46   ` Steven Price
2026-05-13 16:16     ` Boris Brezillon
2026-05-19 19:15     ` Adrián Larumbe
2026-05-20  6:16       ` Boris Brezillon [this message]
2026-05-07 21:49 ` [PATCH v11 6/6] drm/panthor: Bump the driver version to 1.9 Adrián Larumbe

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=20260520081608.0122a1d4@fedora \
    --to=boris.brezillon@collabora.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome