On Tue,  9 Dec 2025 14:41:57 +0100
Thomas Zimmermann <[email protected]> wrote:

> Duplicate GEM-SHMEM to GEM-UMA. Convert all DRM drivers for UMA
> systems if they currently use GEM-SHMEM.
> 
> Many DRM drivers for hardware with Unified Memory Architecture (UMA)
> currently builds upon GEM-SHMEM and extends the helpers with features
> for managing the GPU MMU. This allows the GPU to access the GEM buffer
> content for its operation.
> 
> There is another, larger, set of DRM drivers that use GEM-SHMEM merely
> as buffer management with no hardware support. These drivers copy the
> buffer content to the GPU on each page flip. The GPU itself has no direct
> access. Hardware of this type is usually in servers, behind slow busses
> (SPI, USB), or provided by firmware (drivers in sysfb/).
> 
> After some discussion with Boris on the future of GEM-SHMEM, it seems
> to me that both use cases more and more diverge from each other. The
> most prominent example is the implementation of gem_prime_import,
> where both use cases use distinct approaches.
> 
> So we discussed the introduction of a GEM-UMA helper library for
> UMA-based hardware. GEM-UMA will remain flexible enough for drivers
> to extend it for their use case. GEM-SHMEM will become focused on the
> simple-hardware use case. The benefit for both libraries is that they
> will be easier to understand and maintain. GEM-SHMEM can be simplified
> signiifcantly, I think.
> 
> This RFC series introduces GEM-UMA and converts the UMA-related drivers.
> 
> Patches 1 and 2 fix issues in GEM-SHMEM, so that we don't duplicate
> errornous code.
> 
> Patch 3 copies GEM-SHMEM to GEM-UMA. Patch 4 then does soem obvious
> cleanups of unnecessary code.

Instead of copying the code as-is, I'd rather take a step back and think
about what we need and how we want to handle more complex stuff, like
reclaim. I've started working on a shrinker for panthor [1], and as part
of this series, I've added a commit implementing just enough to replace
what gem-shmem currently provides. Feels like the new GEM-UMA thing
could be designed on a composition rather than inheritance model,
where we have sub-components (backing, cpu_map, gpu_map) that can be
pulled in and re-used by the driver implementation. The common helpers
would take those sub-components instead of a plain GEM object. That
would leave the drivers free of how their internal gem_object fields are
laid out and wouldn't require overloading the ->gem_create_object()
function. It seems to be that it would better match the model you were
describing the other day.

> 
> Patches 5 to 13 update the drivers that can be converted to GEM-UMA.
> These changes are just symbol renaming. There are so far no functional
> differences between the memory managers.
> 
> A gave GEM-UMA some smoke testing by running virtgpu.

[1]https://gitlab.freedesktop.org/bbrezillon/linux/-/commits/panthor-shrinker-revisited/drivers?ref_type=heads
[2]https://gitlab.freedesktop.org/bbrezillon/linux/-/commit/4e6927fc2c60265b77a5a88013f55377bc4f4ab3

> 
> Thomas Zimmermann (13):
>   drm/gem-shmem: Fix typos in documentation
>   drm/gem-shmem: Fix the MODULE_LICENSE() string
>   drm: Add GEM-UMA helpers for memory management
>   drm/gem-uma: Remove unused interfaces
>   drm/imagination: Use GEM-UMA helpers for memory management
>   drm/lima: Use GEM-UMA helpers for memory management
>   drm/panfrost: Use GEM-UMA helpers for memory management
>   drm/panthor: Use GEM-UMA helpers for memory management
>   drm/v3d: Use GEM-UMA helpers for memory management
>   drm/virtgpu: Use GEM-UMA helpers for memory management
>   accel/amdxdna: Use GEM-UMA helpers for memory management
>   accel/ivpu: Use GEM-UMA helpers for memory management
>   accel/rocket: Use GEM-UMA helpers for memory management
> 
>  Documentation/gpu/drm-mm.rst                  |  12 +
>  drivers/accel/amdxdna/Kconfig                 |   2 +-
>  drivers/accel/amdxdna/aie2_ctx.c              |   1 -
>  drivers/accel/amdxdna/aie2_message.c          |   1 -
>  drivers/accel/amdxdna/aie2_pci.c              |   1 -
>  drivers/accel/amdxdna/aie2_psp.c              |   1 -
>  drivers/accel/amdxdna/aie2_smu.c              |   1 -
>  drivers/accel/amdxdna/amdxdna_ctx.c           |   7 +-
>  drivers/accel/amdxdna/amdxdna_gem.c           |  49 +-
>  drivers/accel/amdxdna/amdxdna_gem.h           |   5 +-
>  .../accel/amdxdna/amdxdna_mailbox_helper.c    |   1 -
>  drivers/accel/amdxdna/amdxdna_pci_drv.c       |   1 -
>  drivers/accel/amdxdna/amdxdna_sysfs.c         |   1 -
>  drivers/accel/ivpu/Kconfig                    |   2 +-
>  drivers/accel/ivpu/ivpu_gem.c                 |  36 +-
>  drivers/accel/ivpu/ivpu_gem.h                 |   4 +-
>  drivers/accel/rocket/Kconfig                  |   2 +-
>  drivers/accel/rocket/rocket_gem.c             |  46 +-
>  drivers/accel/rocket/rocket_gem.h             |   6 +-
>  drivers/gpu/drm/Kconfig                       |   9 +
>  drivers/gpu/drm/Kconfig.debug                 |   1 +
>  drivers/gpu/drm/Makefile                      |   4 +
>  drivers/gpu/drm/drm_fbdev_uma.c               | 203 +++++
>  drivers/gpu/drm/drm_gem_shmem_helper.c        |   5 +-
>  drivers/gpu/drm/drm_gem_uma_helper.c          | 787 ++++++++++++++++++
>  drivers/gpu/drm/imagination/Kconfig           |   4 +-
>  drivers/gpu/drm/imagination/pvr_drv.c         |   2 +-
>  drivers/gpu/drm/imagination/pvr_free_list.c   |   2 +-
>  drivers/gpu/drm/imagination/pvr_gem.c         |  74 +-
>  drivers/gpu/drm/imagination/pvr_gem.h         |  12 +-
>  drivers/gpu/drm/lima/Kconfig                  |   4 +-
>  drivers/gpu/drm/lima/lima_drv.c               |   2 +-
>  drivers/gpu/drm/lima/lima_gem.c               |  30 +-
>  drivers/gpu/drm/lima/lima_gem.h               |   6 +-
>  drivers/gpu/drm/panfrost/Kconfig              |   2 +-
>  drivers/gpu/drm/panfrost/panfrost_drv.c       |   2 +-
>  drivers/gpu/drm/panfrost/panfrost_gem.c       |  30 +-
>  drivers/gpu/drm/panfrost/panfrost_gem.h       |   6 +-
>  .../gpu/drm/panfrost/panfrost_gem_shrinker.c  |  30 +-
>  drivers/gpu/drm/panfrost/panfrost_mmu.c       |   8 +-
>  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |   6 +-
>  drivers/gpu/drm/panthor/Kconfig               |   2 +-
>  drivers/gpu/drm/panthor/panthor_drv.c         |   2 +-
>  drivers/gpu/drm/panthor/panthor_fw.c          |   4 +-
>  drivers/gpu/drm/panthor/panthor_gem.c         |  40 +-
>  drivers/gpu/drm/panthor/panthor_gem.h         |   8 +-
>  drivers/gpu/drm/panthor/panthor_mmu.c         |  10 +-
>  drivers/gpu/drm/panthor/panthor_sched.c       |   1 -
>  drivers/gpu/drm/tests/Makefile                |   1 +
>  drivers/gpu/drm/tests/drm_gem_uma_test.c      | 385 +++++++++
>  drivers/gpu/drm/v3d/Kconfig                   |   2 +-
>  drivers/gpu/drm/v3d/v3d_bo.c                  |  45 +-
>  drivers/gpu/drm/v3d/v3d_drv.h                 |   4 +-
>  drivers/gpu/drm/v3d/v3d_mmu.c                 |   9 +-
>  drivers/gpu/drm/virtio/Kconfig                |   4 +-
>  drivers/gpu/drm/virtio/virtgpu_drv.c          |   4 +-
>  drivers/gpu/drm/virtio/virtgpu_drv.h          |  12 +-
>  drivers/gpu/drm/virtio/virtgpu_object.c       |  64 +-
>  drivers/gpu/drm/virtio/virtgpu_plane.c        |   6 +-
>  drivers/gpu/drm/virtio/virtgpu_vq.c           |   6 +-
>  include/drm/drm_fbdev_uma.h                   |  20 +
>  include/drm/drm_gem_uma_helper.h              | 293 +++++++
>  62 files changed, 2018 insertions(+), 312 deletions(-)
>  create mode 100644 drivers/gpu/drm/drm_fbdev_uma.c
>  create mode 100644 drivers/gpu/drm/drm_gem_uma_helper.c
>  create mode 100644 drivers/gpu/drm/tests/drm_gem_uma_test.c
>  create mode 100644 include/drm/drm_fbdev_uma.h
>  create mode 100644 include/drm/drm_gem_uma_helper.h
> 
> 
> base-commit: 0a21e96e0b6840d2a4e0b45a957679eeddeb4362
> prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
> prerequisite-patch-id: a5a973e527c88a5b47053d7a72aefe0b550197cb
> prerequisite-patch-id: 719d09751d38f5da743beed6266585ee063e1e29
> prerequisite-patch-id: 0bbc85bc6b528c32592e07f4ceafa51795c4cad9
> prerequisite-patch-id: c856d9c8a026e3244c44ec829e426e0ad4a685ab
> prerequisite-patch-id: 13441c9ed3062ae1448a53086559dfcbbd578177
> prerequisite-patch-id: 951c039657c1f58e4b6e36bc01c7a1c69ed59767
> prerequisite-patch-id: 4370b8b803ca439666fb9d2beb862f6e78347ce3
> prerequisite-patch-id: ebbaad226ed599f7aad4784fb3f4aaebe34cb110
> prerequisite-patch-id: cb907c3e3e14de7f4d13b429f3a2a88621a8a9fe
> prerequisite-patch-id: 0e243b426742122b239af59e36d742da5795a8b1
> prerequisite-patch-id: 120f97fa1af9891375a0dcf52c51c1907b01fe6a

Reply via email to