public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/gpuvm: Add support for single-page-filled mappings
@ 2025-02-02 13:34 Asahi Lina
  2025-02-02 13:34 ` [PATCH 1/4] drm/gpuvm: Add a flags argument to drm_gpuvm_sm_map[_*] Asahi Lina
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Asahi Lina @ 2025-02-02 13:34 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Frank Binns, Matt Coster, Karol Herbst, Lyude Paul,
	Danilo Krummrich, Boris Brezillon, Steven Price, Liviu Dudau,
	Lucas De Marchi, Thomas Hellström, Rodrigo Vivi
  Cc: dri-devel, linux-kernel, nouveau, intel-xe, asahi, Asahi Lina

Some hardware requires dummy page mappings to efficiently implement
Vulkan sparse features. These mappings consist of the same physical
memory page, repeated for a large range of address space (e.g. 16GiB).

Add support for this to drm_gpuvm. Currently, drm_gpuvm expects BO
ranges to correspond 1:1 to virtual memory ranges that are mapped, and
does math on the BO offset accordingly. To make single page mappings
work, we need a way to turn off that math, keeping the BO offset always
constant and pointing to the same page (typically BO offset 0).

To make this work, we need to handle all the corner cases when these
mappings intersect with regular mappings. The rules are simply to never
mix or merge a "regular" mapping with a single page mapping.

drm_gpuvm has support for a flags field in drm_gpuva objects. This is
normally managed by drivers directly. We can introduce a
DRM_GPUVA_SINGLE_PAGE flag to handle this. However, to make it work,
sm_map and friends need to know ahead of time whether the new mapping is
a single page mapping or not. Therefore, we need to add an argument to
these functions so drivers can provide the flags to be filled into
drm_gpuva.flags.

These changes should not affect any existing drivers that use drm_gpuvm
other than the API change:

- imagination: Does not use flags at all
- nouveau: Only uses drm_gpuva_invalidate(), which is only called on
  existing drm_gpuva objects (after the map steps)
- panthor: Does not use flags at all
- xe: Does not use drm_gpuva_init_from_op() or
  drm_gpuva_remap()/drm_gpuva_map() (which call it). This means that the
flags field of the gpuva object is managed by the driver only, so these
changes cannot clobber it.

Note that the way this is implemented, drm_gpuvm does not need to know
the GPU page size. It only has to never do math on the BO offset to meet
the requirements.

I suspect that after this change there could be some cleanup possible in
the xe driver (which right now passes flags around in various
driver-specific ways from the map step through to drm_gpuva objects),
but I'll leave that to the Xe folks.

Signed-off-by: Asahi Lina <lina@asahilina.net>
---
Asahi Lina (4):
      drm/gpuvm: Add a flags argument to drm_gpuvm_sm_map[_*]
      drm/gpuvm: Plumb through flags into drm_gpuva_op_map
      drm/gpuvm: Add DRM_GPUVA_SINGLE_PAGE flag and logic
      drm/gpuvm: Plumb through flags into drm_gpuva_init

 drivers/gpu/drm/drm_gpuvm.c            | 72 ++++++++++++++++++++++++++--------
 drivers/gpu/drm/imagination/pvr_vm.c   |  3 +-
 drivers/gpu/drm/nouveau/nouveau_uvmm.c |  3 +-
 drivers/gpu/drm/panthor/panthor_mmu.c  |  3 +-
 drivers/gpu/drm/xe/xe_vm.c             |  3 +-
 include/drm/drm_gpuvm.h                | 26 +++++++++---
 6 files changed, 84 insertions(+), 26 deletions(-)
---
base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
change-id: 20250202-gpuvm-single-page-253346a74677

Cheers,
~~ Lina


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-02-03 17:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-02 13:34 [PATCH 0/4] drm/gpuvm: Add support for single-page-filled mappings Asahi Lina
2025-02-02 13:34 ` [PATCH 1/4] drm/gpuvm: Add a flags argument to drm_gpuvm_sm_map[_*] Asahi Lina
2025-02-02 13:34 ` [PATCH 2/4] drm/gpuvm: Plumb through flags into drm_gpuva_op_map Asahi Lina
2025-02-02 13:34 ` [PATCH 3/4] drm/gpuvm: Add DRM_GPUVA_SINGLE_PAGE flag and logic Asahi Lina
2025-02-02 13:34 ` [PATCH 4/4] drm/gpuvm: Plumb through flags into drm_gpuva_init Asahi Lina
2025-02-02 18:53 ` [PATCH 0/4] drm/gpuvm: Add support for single-page-filled mappings Danilo Krummrich
2025-02-02 23:56   ` Asahi Lina
2025-02-03  9:21   ` Boris Brezillon
2025-02-03 11:23     ` Liviu Dudau
2025-02-03 12:12       ` Boris Brezillon
2025-02-03 12:17         ` Matthew Auld
2025-02-03 13:46     ` Asahi Lina
2025-02-03 17:13       ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox