Skip to contentSkip to conversation

drm: Introduce GEM-UMA memory management

RFC PATCH In review Thomas Zimmermann 3 participants 26 messages Dec 9, 2025 – Dec 11, 2025

Subsystems (14)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm: Introduce GEM-UMA memory management

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.

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.

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

Signature · 1 line
2.52.0
author maintainer
#1 lore raw

PATCH 1/13 drm/gem-shmem: Fix typos in documentation

Fix the compile-time warnings

Warning: drm_gem_shmem_helper.c:104 function parameter 'shmem' not described in 'drm_gem_shmem_init'
Warning: drm_gem_shmem_helper.c:104 function parameter 'size' not described in 'drm_gem_shmem_init'

---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -1
index dc94a27710e5..f4e77f75ec81 100644
@@ -96,7 +96,8 @@ static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_obj
 /**
  * drm_gem_shmem_init - Initialize an allocated object.
  * @dev: DRM device
- * @obj: The allocated shmem GEM object.
+ * @shmem: The allocated shmem GEM object.
+ * @size: Buffer size in bytes
  *
  * Returns:
  * 0 on success, or a negative error code on failure.
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 1/13
#2 lore raw

Re: [PATCH 01/13] drm/gem-shmem: Fix typos in documentation

Quoted 6 lines · On Tue, 9 Dec 2025 14:41:58 +0100 Thomas Zimmermann <[email protected]>…

Fix the compile-time warnings

Warning: drm_gem_shmem_helper.c:104 function parameter 'shmem' not described in 'drm_gem_shmem_init'
Warning: drm_gem_shmem_helper.c:104 function parameter 'size' not described in 'drm_gem_shmem_init'

Quoted 18 lines
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -1
index dc94a27710e5..f4e77f75ec81 100644
@@ -96,7 +96,8 @@ static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_obj
 /**
  * drm_gem_shmem_init - Initialize an allocated object.
  * @dev: DRM device
- * @obj: The allocated shmem GEM object.
+ * @shmem: The allocated shmem GEM object.
+ * @size: Buffer size in bytes
  *
  * Returns:
  * 0 on success, or a negative error code on failure.
author maintainer
#3 lore raw

Re: [PATCH 01/13] drm/gem-shmem: Fix typos in documentation

In reply to Thomas Zimmermann

Am 09.12.25 um 14:41 schrieb Thomas Zimmermann:

Quoted 6 lines

Fix the compile-time warnings

Warning: drm_gem_shmem_helper.c:104 function parameter 'shmem' not described in 'drm_gem_shmem_init'
Warning: drm_gem_shmem_helper.c:104 function parameter 'size' not described in 'drm_gem_shmem_init'

Fixes e3f4bdaf2c5b ("drm/gem/shmem: Extract drm_gem_shmem_init() from drm_gem_shmem_create()")
Quoted 18 lines
---
  drivers/gpu/drm/drm_gem_shmem_helper.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +2 -1
index dc94a27710e5..f4e77f75ec81 100644
@@ -96,7 +96,8 @@ static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_obj
  /**
   * drm_gem_shmem_init - Initialize an allocated object.
   * @dev: DRM device
- * @obj: The allocated shmem GEM object.
+ * @shmem: The allocated shmem GEM object.
+ * @size: Buffer size in bytes
   *
   * Returns:
   * 0 on success, or a negative error code on failure.
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
author maintainer
#4 lore raw

PATCH 2/13 drm/gem-shmem: Fix the MODULE_LICENSE() string

In reply to Thomas Zimmermann

Replace the bogus "GPL v2" with "GPL" as MODULE_LICNSE() string. The value does not declare the module's exact license, but only lets the module loader test whether the module is Free Software or not.

See commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity") in the details of the issue. The fix is to use "GPL" for all modules under any variant of the GPL.

---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -1
index f4e77f75ec81..2a67da98da25 100644
@@ -896,4 +896,4 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_no_map);
 
 MODULE_DESCRIPTION("DRM SHMEM memory-management helpers");
 MODULE_IMPORT_NS("DMA_BUF");
-MODULE_LICENSE("GPL v2");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 2/13
#5 lore raw

Re: [PATCH 02/13] drm/gem-shmem: Fix the MODULE_LICENSE() string

Quoted 9 lines · On Tue, 9 Dec 2025 14:41:59 +0100 Thomas Zimmermann <[email protected]>…

Replace the bogus "GPL v2" with "GPL" as MODULE_LICNSE() string. The value does not declare the module's exact license, but only lets the module loader test whether the module is Free Software or not.

See commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity") in the details of the issue. The fix is to use "GPL" for all modules under any variant of the GPL.

Quoted 14 lines
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -1
index f4e77f75ec81..2a67da98da25 100644
@@ -896,4 +896,4 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_no_map);
 
 MODULE_DESCRIPTION("DRM SHMEM memory-management helpers");
 MODULE_IMPORT_NS("DMA_BUF");
-MODULE_LICENSE("GPL v2");
+MODULE_LICENSE("GPL");
author maintainer
#6 lore raw

Re: [PATCH 02/13] drm/gem-shmem: Fix the MODULE_LICENSE() string

In reply to Thomas Zimmermann

Am 09.12.25 um 14:41 schrieb Thomas Zimmermann:

Quoted 9 lines

Replace the bogus "GPL v2" with "GPL" as MODULE_LICNSE() string. The value does not declare the module's exact license, but only lets the module loader test whether the module is Free Software or not.

See commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity") in the details of the issue. The fix is to use "GPL" for all modules under any variant of the GPL.

Fixes 4b2b5e142ff4 ("drm: Move GEM memory managers into modules")
Quoted 14 lines
---
  drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +1 -1
index f4e77f75ec81..2a67da98da25 100644
@@ -896,4 +896,4 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_no_map);
 
  MODULE_DESCRIPTION("DRM SHMEM memory-management helpers");
  MODULE_IMPORT_NS("DMA_BUF");
-MODULE_LICENSE("GPL v2");
+MODULE_LICENSE("GPL");
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
author maintainer
#7 lore raw

PATCH 3/13 drm: Add GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Duplicate the existing GEM-SHMEM helpers to GEM-UMA; including fbdev emulation and tests.

The new GEM-UMA helpers provide memory management for DRM drivers with Unified Memory Architecture (UMA) hardware. Here, the CPU and GPU share use of the system memory. DRM drivers for such hardware currently often build upon GEM-SHMEM and extend it with additional GTT/MMU functionality for the graphics chipset.

GEM-SHMEM also serves the different use case of holding the graphics buffers entirely in system memory and copying their content on pageflips. This conflicts with the UMA use case and complicates GEM-SHMEM. The most prominent example is PRIME buffer import, where GEM-SHMEM currently has to provide two distinct implementations.

By having a separate GEM memory manager for UMA, both implementations, SHMEM and UMA, can evolve in different directions with each focusng on their specific use case.

---
 Documentation/gpu/drm-mm.rst             |  12 +
 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_uma_helper.c     | 898 +++++++++++++++++++++++
 drivers/gpu/drm/tests/Makefile           |   1 +
 drivers/gpu/drm/tests/drm_gem_uma_test.c | 385 ++++++++++
 include/drm/drm_fbdev_uma.h              |  20 +
 include/drm/drm_gem_uma_helper.h         | 309 ++++++++
 10 files changed, 1842 insertions(+)
 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
Documentation/gpu/drm-mm.rst +12 -0
index d55751cad67c..225d9d760227 100644
@@ -379,6 +379,18 @@ GEM SHMEM Helper Function Reference
 .. kernel-doc:: drivers/gpu/drm/drm_gem_shmem_helper.c
    :export:
 
+GEM UMA Helper Function Reference
+-----------------------------------
+
+.. kernel-doc:: drivers/gpu/drm/drm_gem_uma_helper.c
+   :doc: overview
+
+.. kernel-doc:: include/drm/drm_gem_uma_helper.h
+   :internal:
+
+.. kernel-doc:: drivers/gpu/drm/drm_gem_uma_helper.c
+   :export:
+
 GEM VRAM Helper Functions Reference
 -----------------------------------
 
drivers/gpu/drm/Kconfig +9 -0
index 7e6bc0b3a589..a35fbd9feccb 100644
@@ -257,6 +257,15 @@ config DRM_GEM_SHMEM_HELPER
 	help
 	  Choose this if you need the GEM shmem helper functions
 
+config DRM_GEM_UMA_HELPER
+	tristate
+	depends on DRM && MMU
+	select DRM_KMS_HELPER if DRM_FBDEV_EMULATION
+	select FB_CORE if DRM_FBDEV_EMULATION
+	select FB_SYSMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION
+	help
+	  Choose this if you need the GEM UMA helper functions
+
 config DRM_SUBALLOC_HELPER
 	tristate
 	depends on DRM
drivers/gpu/drm/Kconfig.debug +1 -0
index 05dc43c0b8c5..ec791826fca8 100644
@@ -68,6 +68,7 @@ config DRM_KUNIT_TEST
 	select DRM_EXEC
 	select DRM_EXPORT_FOR_TESTS if m
 	select DRM_GEM_SHMEM_HELPER
+	select DRM_GEM_UMA_HELPER
 	select DRM_KUNIT_TEST_HELPERS
 	select DRM_LIB_RANDOM
 	select DRM_SYSFB_HELPER
drivers/gpu/drm/Makefile +4 -0
index 33ff76ae52b2..c227523aa693 100644
@@ -125,6 +125,10 @@ obj-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_shmem_helper.o
 drm_suballoc_helper-y := drm_suballoc.o
 obj-$(CONFIG_DRM_SUBALLOC_HELPER) += drm_suballoc_helper.o
 
+drm_uma_helper-y := drm_gem_uma_helper.o
+drm_uma_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fbdev_uma.o
+obj-$(CONFIG_DRM_GEM_UMA_HELPER) += drm_uma_helper.o
+
 drm_vram_helper-y := drm_gem_vram_helper.o
 obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o
 
drivers/gpu/drm/drm_fbdev_uma.c new file +203 -0

203 lines not on this page · raw message

drivers/gpu/drm/drm_gem_uma_helper.c new file +898 -0

898 lines not on this page · raw message

drivers/gpu/drm/tests/Makefile +1 -0
index c0e952293ad0..801f1c00e3c1 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
 	drm_format_test.o \
 	drm_framebuffer_test.o \
 	drm_gem_shmem_test.o \
+	drm_gem_uma_test.o \
 	drm_hdmi_state_helper_test.o \
 	drm_managed_test.o \
 	drm_mm_test.o \
drivers/gpu/drm/tests/drm_gem_uma_test.c new file +385 -0

385 lines not on this page · raw message

include/drm/drm_fbdev_uma.h new file +20 -0
new file mode 100644
index 000000000000..2dd5d47795ea
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef DRM_FBDEV_UMA_H
+#define DRM_FBDEV_UMA_H
+
+struct drm_fb_helper;
+struct drm_fb_helper_surface_size;
+
+#ifdef CONFIG_DRM_FBDEV_EMULATION
+int drm_fbdev_uma_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
+				     struct drm_fb_helper_surface_size *sizes);
+
+#define DRM_FBDEV_UMA_DRIVER_OPS \
+	.fbdev_probe = drm_fbdev_uma_driver_fbdev_probe
+#else
+#define DRM_FBDEV_UMA_DRIVER_OPS \
+	.fbdev_probe = NULL
+#endif
+
+#endif
include/drm/drm_gem_uma_helper.h new file +309 -0

309 lines not on this page · raw message

Signature · 1 line
2.52.0
author maintainer
#8 lore raw

PATCH 4/13 drm/gem-uma: Remove unused interfaces

In reply to Thomas Zimmermann

Copying from GEM-SHMEM duplicated a number of interfaces that are not required. Remove them.

---
 drivers/gpu/drm/drm_gem_uma_helper.c | 111 ---------------------------
 include/drm/drm_gem_uma_helper.h     |  16 ----
 2 files changed, 127 deletions(-)
drivers/gpu/drm/drm_gem_uma_helper.c +0 -111
index d617cfd981e1..2b88e21b1db9 100644
@@ -18,7 +18,6 @@
 #include <drm/drm.h>
 #include <drm/drm_device.h>
 #include <drm/drm_drv.h>
-#include <drm/drm_dumb_buffers.h>
 #include <drm/drm_gem_uma_helper.h>
 #include <drm/drm_prime.h>
 #include <drm/drm_print.h>
@@ -466,29 +465,6 @@ void drm_gem_uma_vunmap_locked(struct drm_gem_uma_object *uma, struct iosys_map
 }
 EXPORT_SYMBOL_GPL(drm_gem_uma_vunmap_locked);
 
-static int
-drm_gem_uma_create_with_handle(struct drm_file *file_priv,
-			       struct drm_device *dev, size_t size,
-			       uint32_t *handle)
-{
-	struct drm_gem_uma_object *uma;
-	int ret;
-
-	uma = drm_gem_uma_create(dev, size);
-	if (IS_ERR(uma))
-		return PTR_ERR(uma);
-
-	/*
-	 * Allocate an id of idr table where the obj is registered
-	 * and handle has the id what user can see.
-	 */
-	ret = drm_gem_handle_create(file_priv, &uma->base, handle);
-	/* drop reference from allocate - handle holds it now. */
-	drm_gem_object_put(&uma->base);
-
-	return ret;
-}
-
 /* Update madvise status, returns true if not purged, else
  * false or -errno.
  */
@@ -537,36 +513,6 @@ void drm_gem_uma_purge_locked(struct drm_gem_uma_object *uma)
 }
 EXPORT_SYMBOL_GPL(drm_gem_uma_purge_locked);
 
-/**
- * drm_gem_uma_dumb_create - Create a dumb UMA buffer object
- * @file: DRM file structure to create the dumb buffer for
- * @dev: DRM device
- * @args: IOCTL data
- *
- * This function computes the pitch of the dumb buffer and rounds it up to an
- * integer number of bytes per pixel. Drivers for hardware that doesn't have
- * any additional restrictions on the pitch can directly use this function as
- * their &drm_driver.dumb_create callback.
- *
- * For hardware with additional restrictions, drivers can adjust the fields
- * set up by userspace before calling into this function.
- *
- * Returns:
- * 0 on success or a negative error code on failure.
- */
-int drm_gem_uma_dumb_create(struct drm_file *file, struct drm_device *dev,
-			    struct drm_mode_create_dumb *args)
-{
-	int ret;
-
-	ret = drm_mode_size_dumb(dev, args, SZ_8, 0);
-	if (ret)
-		return ret;
-
-	return drm_gem_uma_create_with_handle(file, dev, args->size, &args->handle);
-}
-EXPORT_SYMBOL_GPL(drm_gem_uma_dumb_create);
-
 static vm_fault_t drm_gem_uma_fault(struct vm_fault *vmf)
 {
 	struct vm_area_struct *vma = vmf->vma;
@@ -836,63 +782,6 @@ drm_gem_uma_prime_import_sg_table(struct drm_device *dev,
 }
 EXPORT_SYMBOL_GPL(drm_gem_uma_prime_import_sg_table);
 
-/**
- * drm_gem_uma_prime_import_no_map - Import dmabuf without mapping its sg_table
- * @dev: Device to import into
- * @dma_buf: dma-buf object to import
- *
- * Drivers that use the GEM UMA helpers but also wants to import dmabuf without
- * mapping its sg_table can use this as their &drm_driver.gem_prime_import
- * implementation.
- */
-struct drm_gem_object *drm_gem_uma_prime_import_no_map(struct drm_device *dev,
-						       struct dma_buf *dma_buf)
-{
-	struct dma_buf_attachment *attach;
-	struct drm_gem_uma_object *uma;
-	struct drm_gem_object *obj;
-	size_t size;
-	int ret;
-
-	if (drm_gem_is_prime_exported_dma_buf(dev, dma_buf)) {
-		/*
-		 * Importing dmabuf exported from our own gem increases
-		 * refcount on gem itself instead of f_count of dmabuf.
-		 */
-		obj = dma_buf->priv;
-		drm_gem_object_get(obj);
-		return obj;
-	}
-
-	attach = dma_buf_attach(dma_buf, dev->dev);
-	if (IS_ERR(attach))
-		return ERR_CAST(attach);
-
-	get_dma_buf(dma_buf);
-
-	size = PAGE_ALIGN(attach->dmabuf->size);
-
-	uma = __drm_gem_uma_create(dev, size, true, NULL);
-	if (IS_ERR(uma)) {
-		ret = PTR_ERR(uma);
-		goto fail_detach;
-	}
-
-	drm_dbg_prime(dev, "size = %zu\n", size);
-
-	uma->base.import_attach = attach;
-	uma->base.resv = dma_buf->resv;
-
-	return &uma->base;
-
-fail_detach:
-	dma_buf_detach(dma_buf, attach);
-	dma_buf_put(dma_buf);
-
-	return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(drm_gem_uma_prime_import_no_map);
-
 MODULE_DESCRIPTION("DRM UMA memory-management helpers");
 MODULE_IMPORT_NS("DMA_BUF");
 MODULE_LICENSE("GPL");
include/drm/drm_gem_uma_helper.h +0 -16
index e7722c625fab..3d6de27efe79 100644
@@ -13,7 +13,6 @@
 #include <drm/drm_prime.h>
 
 struct dma_buf_attachment;
-struct drm_mode_create_dumb;
 struct drm_printer;
 struct sg_table;
 
@@ -290,20 +289,5 @@ struct drm_gem_object *
 drm_gem_uma_prime_import_sg_table(struct drm_device *dev,
 				  struct dma_buf_attachment *attach,
 				  struct sg_table *sgt);
-int drm_gem_uma_dumb_create(struct drm_file *file, struct drm_device *dev,
-			    struct drm_mode_create_dumb *args);
-struct drm_gem_object *drm_gem_uma_prime_import_no_map(struct drm_device *dev,
-						       struct dma_buf *buf);
-
-/**
- * DRM_GEM_UMA_DRIVER_OPS - Default GEM UMA operations
- *
- * This macro provides a shortcut for setting the GEM UMA operations
- * in the &drm_driver structure. Drivers that do not require an s/g table
- * for imported buffers should use this.
- */
-#define DRM_GEM_UMA_DRIVER_OPS \
-	.gem_prime_import       = drm_gem_uma_prime_import_no_map, \
-	.dumb_create            = drm_gem_uma_dumb_create
 
 #endif /* __DRM_GEM_UMA_HELPER_H__ */
Signature · 1 line
2.52.0
author maintainer
#9 lore raw

PATCH 5/13 drm/imagination: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert imagination from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as imagination.

---
 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 ++--
 5 files changed, 47 insertions(+), 47 deletions(-)
drivers/gpu/drm/imagination/Kconfig +2 -2
index 0482bfcefdde..ee796c9cfdf2 100644
@@ -9,9 +9,9 @@ config DRM_POWERVR
 	depends on PM
 	depends on POWER_SEQUENCING || !POWER_SEQUENCING
 	select DRM_EXEC
-	select DRM_GEM_SHMEM_HELPER
-	select DRM_SCHED
+	select DRM_GEM_UMA_HELPER
 	select DRM_GPUVM
+	select DRM_SCHED
 	select FW_LOADER
 	help
 	  Choose this option if you have a system that has an Imagination
drivers/gpu/drm/imagination/pvr_drv.c +1 -1
index 916b40ced7eb..61bcbbef208c 100644
@@ -1392,7 +1392,7 @@ static struct drm_driver pvr_drm_driver = {
 	.minor = PVR_DRIVER_MINOR,
 	.patchlevel = PVR_DRIVER_PATCHLEVEL,
 
-	.gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table,
+	.gem_prime_import_sg_table = drm_gem_uma_prime_import_sg_table,
 	.gem_create_object = pvr_gem_create_object,
 };
 
drivers/gpu/drm/imagination/pvr_free_list.c +1 -1
index 5228e214491c..5b43f7ca2a6c 100644
@@ -281,7 +281,7 @@ pvr_free_list_insert_node_locked(struct pvr_free_list_node *free_list_node)
 	offset = (start_page * FREE_LIST_ENTRY_SIZE) &
 		  ~((u64)ROGUE_BIF_PM_FREELIST_BASE_ADDR_ALIGNSIZE - 1);
 
-	sgt = drm_gem_shmem_get_pages_sgt(&free_list_node->mem_obj->base);
+	sgt = drm_gem_uma_get_pages_sgt(&free_list_node->mem_obj->base);
 	if (WARN_ON(IS_ERR(sgt)))
 		return PTR_ERR(sgt);
 
drivers/gpu/drm/imagination/pvr_gem.c +37 -37

163 lines not on this page · raw message

drivers/gpu/drm/imagination/pvr_gem.h +6 -6
index c99f30cc6208..59223876b3f7 100644
@@ -10,7 +10,7 @@
 #include <uapi/drm/pvr_drm.h>
 
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/drm_mm.h>
 
 #include <linux/bitfield.h>
@@ -82,12 +82,12 @@ struct pvr_file;
  */
 struct pvr_gem_object {
 	/**
-	 * @base: The underlying &struct drm_gem_shmem_object.
+	 * @base: The underlying &struct drm_gem_uma_object.
 	 *
 	 * Do not access this member directly, instead call
 	 * shem_gem_from_pvr_gem().
 	 */
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 
 	/**
 	 * @flags: Options set at creation-time. Some of these options apply to
@@ -111,9 +111,9 @@ struct pvr_gem_object {
 static_assert(offsetof(struct pvr_gem_object, base) == 0,
 	      "offsetof(struct pvr_gem_object, base) not zero");
 
-#define shmem_gem_from_pvr_gem(pvr_obj) (&(pvr_obj)->base)
+#define uma_gem_from_pvr_gem(pvr_obj) (&(pvr_obj)->base)
 
-#define shmem_gem_to_pvr_gem(shmem_obj) container_of_const(shmem_obj, struct pvr_gem_object, base)
+#define uma_gem_to_pvr_gem(uma_obj) container_of_const(uma_obj, struct pvr_gem_object, base)
 
 #define gem_from_pvr_gem(pvr_obj) (&(pvr_obj)->base.base)
 
@@ -134,7 +134,7 @@ struct pvr_gem_object *pvr_gem_object_from_handle(struct pvr_file *pvr_file,
 static __always_inline struct sg_table *
 pvr_gem_object_get_pages_sgt(struct pvr_gem_object *pvr_obj)
 {
-	return drm_gem_shmem_get_pages_sgt(shmem_gem_from_pvr_gem(pvr_obj));
+	return drm_gem_uma_get_pages_sgt(uma_gem_from_pvr_gem(pvr_obj));
 }
 
 void *pvr_gem_object_vmap(struct pvr_gem_object *pvr_obj);
Signature · 1 line
2.52.0
author maintainer
#10 lore raw

PATCH 6/13 drm/lima: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert lima from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as lima.

---
 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 +++---
 4 files changed, 21 insertions(+), 21 deletions(-)
drivers/gpu/drm/lima/Kconfig +2 -2
index fa1d4f5df31e..ad854acef58d 100644
@@ -8,9 +8,9 @@ config DRM_LIMA
        depends on MMU
        depends on COMMON_CLK
        depends on OF
+       select DEVFREQ_GOV_SIMPLE_ONDEMAND
+       select DRM_GEM_UMA_HELPER
        select DRM_SCHED
-       select DRM_GEM_SHMEM_HELPER
        select PM_DEVFREQ
-       select DEVFREQ_GOV_SIMPLE_ONDEMAND
        help
 	 DRM driver for ARM Mali 400/450 GPUs.
drivers/gpu/drm/lima/lima_drv.c +1 -1
index 65210ab081bb..9d57d2e002f9 100644
@@ -276,7 +276,7 @@ static const struct drm_driver lima_drm_driver = {
 	.patchlevel         = 0,
 
 	.gem_create_object  = lima_gem_create_object,
-	.gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table,
+	.gem_prime_import_sg_table = drm_gem_uma_prime_import_sg_table,
 };
 
 struct lima_block_reader {
drivers/gpu/drm/lima/lima_gem.c +15 -15
index 9722b847a539..d6f00dde22ac 100644
@@ -110,16 +110,16 @@ int lima_gem_create_handle(struct drm_device *dev, struct drm_file *file,
 {
 	int err;
 	gfp_t mask;
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	struct drm_gem_object *obj;
 	struct lima_bo *bo;
 	bool is_heap = flags & LIMA_BO_FLAG_HEAP;
 
-	shmem = drm_gem_shmem_create(dev, size);
-	if (IS_ERR(shmem))
-		return PTR_ERR(shmem);
+	uma = drm_gem_uma_create(dev, size);
+	if (IS_ERR(uma))
+		return PTR_ERR(uma);
 
-	obj = &shmem->base;
+	obj = &uma->base;
 
 	/* Mali Utgard GPU can only support 32bit address space */
 	mask = mapping_gfp_mask(obj->filp->f_mapping);
@@ -133,7 +133,7 @@ int lima_gem_create_handle(struct drm_device *dev, struct drm_file *file,
 		if (err)
 			goto out;
 	} else {
-		struct sg_table *sgt = drm_gem_shmem_get_pages_sgt(shmem);
+		struct sg_table *sgt = drm_gem_uma_get_pages_sgt(uma);
 
 		if (IS_ERR(sgt)) {
 			err = PTR_ERR(sgt);
@@ -157,7 +157,7 @@ static void lima_gem_free_object(struct drm_gem_object *obj)
 	if (!list_empty(&bo->va))
 		dev_err(obj->dev->dev, "lima gem free bo still has va\n");
 
-	drm_gem_shmem_free(&bo->base);
+	drm_gem_uma_free(&bo->base);
 }
 
 static int lima_gem_object_open(struct drm_gem_object *obj, struct drm_file *file)
@@ -185,7 +185,7 @@ static int lima_gem_pin(struct drm_gem_object *obj)
 	if (bo->heap_size)
 		return -EINVAL;
 
-	return drm_gem_shmem_pin_locked(&bo->base);
+	return drm_gem_uma_pin_locked(&bo->base);
 }
 
 static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
@@ -195,7 +195,7 @@ static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
 	if (bo->heap_size)
 		return -EINVAL;
 
-	return drm_gem_shmem_vmap_locked(&bo->base, map);
+	return drm_gem_uma_vmap_locked(&bo->base, map);
 }
 
 static int lima_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
@@ -205,21 +205,21 @@ static int lima_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 	if (bo->heap_size)
 		return -EINVAL;
 
-	return drm_gem_shmem_mmap(&bo->base, vma);
+	return drm_gem_uma_mmap(&bo->base, vma);
 }
 
 static const struct drm_gem_object_funcs lima_gem_funcs = {
 	.free = lima_gem_free_object,
 	.open = lima_gem_object_open,
 	.close = lima_gem_object_close,
-	.print_info = drm_gem_shmem_object_print_info,
+	.print_info = drm_gem_uma_object_print_info,
 	.pin = lima_gem_pin,
-	.unpin = drm_gem_shmem_object_unpin,
-	.get_sg_table = drm_gem_shmem_object_get_sg_table,
+	.unpin = drm_gem_uma_object_unpin,
+	.get_sg_table = drm_gem_uma_object_get_sg_table,
 	.vmap = lima_gem_vmap,
-	.vunmap = drm_gem_shmem_object_vunmap,
+	.vunmap = drm_gem_uma_object_vunmap,
 	.mmap = lima_gem_mmap,
-	.vm_ops = &drm_gem_shmem_vm_ops,
+	.vm_ops = &drm_gem_uma_vm_ops,
 };
 
 struct drm_gem_object *lima_gem_create_object(struct drm_device *dev, size_t size)
drivers/gpu/drm/lima/lima_gem.h +3 -3
index ccea06142f4b..6ad19fda3480 100644
@@ -4,13 +4,13 @@
 #ifndef __LIMA_GEM_H__
 #define __LIMA_GEM_H__
 
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 
 struct lima_submit;
 struct lima_vm;
 
 struct lima_bo {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 
 	struct mutex lock;
 	struct list_head va;
@@ -21,7 +21,7 @@ struct lima_bo {
 static inline struct lima_bo *
 to_lima_bo(struct drm_gem_object *obj)
 {
-	return container_of(to_drm_gem_shmem_obj(obj), struct lima_bo, base);
+	return container_of(to_drm_gem_uma_obj(obj), struct lima_bo, base);
 }
 
 static inline size_t lima_bo_size(struct lima_bo *bo)
Signature · 1 line
2.52.0
author maintainer
#11 lore raw

PATCH 7/13 drm/panfrost: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert panfrost from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as panfrost.

---
 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 ++--
 7 files changed, 42 insertions(+), 42 deletions(-)
drivers/gpu/drm/panfrost/Kconfig +1 -1
index e6403a9d66ad..3e44858df0f3 100644
@@ -6,10 +6,10 @@ config DRM_PANFROST
 	depends on ARM || ARM64 || COMPILE_TEST
 	depends on !GENERIC_ATOMIC64    # for IOMMU_IO_PGTABLE_LPAE
 	depends on MMU
+	select DRM_GEM_UMA_HELPER
 	select DRM_SCHED
 	select IOMMU_SUPPORT
 	select IOMMU_IO_PGTABLE_LPAE
-	select DRM_GEM_SHMEM_HELPER
 	select PM_DEVFREQ
 	select DEVFREQ_GOV_SIMPLE_ONDEMAND
 	select WANT_DEV_COREDUMP
drivers/gpu/drm/panfrost/panfrost_drv.c +1 -1
index 7d8c7c337606..fe38aa354bcc 100644
@@ -499,7 +499,7 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data,
 		}
 	}
 
-	args->retained = drm_gem_shmem_madvise_locked(&bo->base, args->madv);
+	args->retained = drm_gem_uma_madvise_locked(&bo->base, args->madv);
 
 	if (args->retained) {
 		if (args->madv == PANFROST_MADV_DONTNEED)
drivers/gpu/drm/panfrost/panfrost_gem.c +15 -15
index 8041b65c6609..17a5218c9aee 100644
@@ -85,7 +85,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj)
 		kvfree(bo->sgts);
 	}
 
-	drm_gem_shmem_free(&bo->base);
+	drm_gem_uma_free(&bo->base);
 }
 
 struct panfrost_gem_mapping *
@@ -228,7 +228,7 @@ static int panfrost_gem_pin(struct drm_gem_object *obj)
 	if (bo->is_heap)
 		return -EINVAL;
 
-	return drm_gem_shmem_pin_locked(&bo->base);
+	return drm_gem_uma_pin_locked(&bo->base);
 }
 
 static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj)
@@ -263,16 +263,16 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = {
 	.free = panfrost_gem_free_object,
 	.open = panfrost_gem_open,
 	.close = panfrost_gem_close,
-	.print_info = drm_gem_shmem_object_print_info,
+	.print_info = drm_gem_uma_object_print_info,
 	.pin = panfrost_gem_pin,
-	.unpin = drm_gem_shmem_object_unpin,
-	.get_sg_table = drm_gem_shmem_object_get_sg_table,
-	.vmap = drm_gem_shmem_object_vmap,
-	.vunmap = drm_gem_shmem_object_vunmap,
-	.mmap = drm_gem_shmem_object_mmap,
+	.unpin = drm_gem_uma_object_unpin,
+	.get_sg_table = drm_gem_uma_object_get_sg_table,
+	.vmap = drm_gem_uma_object_vmap,
+	.vunmap = drm_gem_uma_object_vunmap,
+	.mmap = drm_gem_uma_object_mmap,
 	.status = panfrost_gem_status,
 	.rss = panfrost_gem_rss,
-	.vm_ops = &drm_gem_shmem_vm_ops,
+	.vm_ops = &drm_gem_uma_vm_ops,
 };
 
 /**
@@ -306,18 +306,18 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t
 struct panfrost_gem_object *
 panfrost_gem_create(struct drm_device *dev, size_t size, u32 flags)
 {
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	struct panfrost_gem_object *bo;
 
 	/* Round up heap allocations to 2MB to keep fault handling simple */
 	if (flags & PANFROST_BO_HEAP)
 		size = roundup(size, SZ_2M);
 
-	shmem = drm_gem_shmem_create(dev, size);
-	if (IS_ERR(shmem))
-		return ERR_CAST(shmem);
+	uma = drm_gem_uma_create(dev, size);
+	if (IS_ERR(uma))
+		return ERR_CAST(uma);
 
-	bo = to_panfrost_bo(&shmem->base);
+	bo = to_panfrost_bo(&uma->base);
 	bo->noexec = !!(flags & PANFROST_BO_NOEXEC);
 	bo->is_heap = !!(flags & PANFROST_BO_HEAP);
 
@@ -332,7 +332,7 @@ panfrost_gem_prime_import_sg_table(struct drm_device *dev,
 	struct drm_gem_object *obj;
 	struct panfrost_gem_object *bo;
 
-	obj = drm_gem_shmem_prime_import_sg_table(dev, attach, sgt);
+	obj = drm_gem_uma_prime_import_sg_table(dev, attach, sgt);
 	if (IS_ERR(obj))
 		return ERR_CAST(obj);
 
drivers/gpu/drm/panfrost/panfrost_gem.h +3 -3
index 8de3e76f2717..01a796a54340 100644
@@ -4,7 +4,7 @@
 #ifndef __PANFROST_GEM_H__
 #define __PANFROST_GEM_H__
 
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/drm_mm.h>
 
 struct panfrost_mmu;
@@ -50,7 +50,7 @@ struct panfrost_gem_debugfs {
 };
 
 struct panfrost_gem_object {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 	struct sg_table *sgts;
 
 	/*
@@ -115,7 +115,7 @@ struct panfrost_gem_mapping {
 static inline
 struct  panfrost_gem_object *to_panfrost_bo(struct drm_gem_object *obj)
 {
-	return container_of(to_drm_gem_shmem_obj(obj), struct panfrost_gem_object, base);
+	return container_of(to_drm_gem_uma_obj(obj), struct panfrost_gem_object, base);
 }
 
 static inline struct panfrost_gem_mapping *
drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c +15 -15
index 2fe967a90bcb..b55accfcbe0d 100644
@@ -9,7 +9,7 @@
 #include <linux/list.h>
 
 #include <drm/drm_device.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 
 #include "panfrost_device.h"
 #include "panfrost_gem.h"
@@ -19,15 +19,15 @@ static unsigned long
 panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc)
 {
 	struct panfrost_device *pfdev = shrinker->private_data;
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	unsigned long count = 0;
 
 	if (!mutex_trylock(&pfdev->shrinker_lock))
 		return 0;
 
-	list_for_each_entry(shmem, &pfdev->shrinker_list, madv_list) {
-		if (drm_gem_shmem_is_purgeable(shmem))
-			count += shmem->base.size >> PAGE_SHIFT;
+	list_for_each_entry(uma, &pfdev->shrinker_list, madv_list) {
+		if (drm_gem_uma_is_purgeable(uma))
+			count += uma->base.size >> PAGE_SHIFT;
 	}
 
 	mutex_unlock(&pfdev->shrinker_lock);
@@ -37,7 +37,7 @@ panfrost_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc
 
 static bool panfrost_gem_purge(struct drm_gem_object *obj)
 {
-	struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
+	struct drm_gem_uma_object *uma = to_drm_gem_uma_obj(obj);
 	struct panfrost_gem_object *bo = to_panfrost_bo(obj);
 	bool ret = false;
 
@@ -47,14 +47,14 @@ static bool panfrost_gem_purge(struct drm_gem_object *obj)
 	if (!mutex_trylock(&bo->mappings.lock))
 		return false;
 
-	if (!dma_resv_trylock(shmem->base.resv))
+	if (!dma_resv_trylock(uma->base.resv))
 		goto unlock_mappings;
 
 	panfrost_gem_teardown_mappings_locked(bo);
-	drm_gem_shmem_purge_locked(&bo->base);
+	drm_gem_uma_purge_locked(&bo->base);
 	ret = true;
 
-	dma_resv_unlock(shmem->base.resv);
+	dma_resv_unlock(uma->base.resv);
 
 unlock_mappings:
 	mutex_unlock(&bo->mappings.lock);
@@ -65,19 +65,19 @@ static unsigned long
 panfrost_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc)
 {
 	struct panfrost_device *pfdev = shrinker->private_data;
-	struct drm_gem_shmem_object *shmem, *tmp;
+	struct drm_gem_uma_object *uma, *tmp;
 	unsigned long freed = 0;
 
 	if (!mutex_trylock(&pfdev->shrinker_lock))
 		return SHRINK_STOP;
 
-	list_for_each_entry_safe(shmem, tmp, &pfdev->shrinker_list, madv_list) {
+	list_for_each_entry_safe(uma, tmp, &pfdev->shrinker_list, madv_list) {
 		if (freed >= sc->nr_to_scan)
 			break;
-		if (drm_gem_shmem_is_purgeable(shmem) &&
-		    panfrost_gem_purge(&shmem->base)) {
-			freed += shmem->base.size >> PAGE_SHIFT;
-			list_del_init(&shmem->madv_list);
+		if (drm_gem_uma_is_purgeable(uma) &&
+		    panfrost_gem_purge(&uma->base)) {
+			freed += uma->base.size >> PAGE_SHIFT;
+			list_del_init(&uma->madv_list);
 		}
 	}
 
drivers/gpu/drm/panfrost/panfrost_mmu.c +4 -4
index 8f3b7a7b6ad0..a19bf238ba21 100644
@@ -461,8 +461,8 @@ static int mmu_map_sg(struct panfrost_device *pfdev, struct panfrost_mmu *mmu,
 int panfrost_mmu_map(struct panfrost_gem_mapping *mapping)
 {
 	struct panfrost_gem_object *bo = mapping->obj;
-	struct drm_gem_shmem_object *shmem = &bo->base;
-	struct drm_gem_object *obj = &shmem->base;
+	struct drm_gem_uma_object *uma = &bo->base;
+	struct drm_gem_object *obj = &uma->base;
 	struct panfrost_device *pfdev = to_panfrost_device(obj->dev);
 	struct sg_table *sgt;
 	int prot = IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE;
@@ -474,7 +474,7 @@ int panfrost_mmu_map(struct panfrost_gem_mapping *mapping)
 	if (bo->noexec)
 		prot |= IOMMU_NOEXEC;
 
-	sgt = drm_gem_shmem_get_pages_sgt(shmem);
+	sgt = drm_gem_uma_get_pages_sgt(uma);
 	if (WARN_ON(IS_ERR(sgt)))
 		return PTR_ERR(sgt);
 
@@ -488,7 +488,7 @@ int panfrost_mmu_map(struct panfrost_gem_mapping *mapping)
 	return 0;
 
 err_put_pages:
-	drm_gem_shmem_put_pages_locked(shmem);
+	drm_gem_uma_put_pages_locked(uma);
 	return ret;
 }
 
drivers/gpu/drm/panfrost/panfrost_perfcnt.c +3 -3
index 7020c0192e18..874c23c7c024 100644
@@ -9,7 +9,7 @@
 #include <linux/uaccess.h>
 
 #include <drm/drm_file.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/panfrost_drm.h>
 
 #include "panfrost_device.h"
@@ -75,7 +75,7 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
 	struct panfrost_file_priv *user = file_priv->driver_priv;
 	struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
 	struct iosys_map map;
-	struct drm_gem_shmem_object *bo;
+	struct drm_gem_uma_object *bo;
 	u32 cfg, as;
 	int ret;
 
@@ -88,7 +88,7 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
 	if (ret < 0)
 		goto err_put_pm;
 
-	bo = drm_gem_shmem_create(&pfdev->base, perfcnt->bosize);
+	bo = drm_gem_uma_create(&pfdev->base, perfcnt->bosize);
 	if (IS_ERR(bo)) {
 		ret = PTR_ERR(bo);
 		goto err_put_pm;
Signature · 1 line
2.52.0
author maintainer
#12 lore raw

PATCH 8/13 drm/panthor: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert panthor from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as panthor.

---
 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 -
 7 files changed, 33 insertions(+), 34 deletions(-)
drivers/gpu/drm/panthor/Kconfig +1 -1
index 55b40ad07f3b..dc87abc79917 100644
@@ -8,7 +8,7 @@ config DRM_PANTHOR
 	depends on MMU
 	select DEVFREQ_GOV_SIMPLE_ONDEMAND
 	select DRM_EXEC
-	select DRM_GEM_SHMEM_HELPER
+	select DRM_GEM_UMA_HELPER
 	select DRM_GPUVM
 	select DRM_SCHED
 	select IOMMU_IO_PGTABLE_LPAE
drivers/gpu/drm/panthor/panthor_drv.c +1 -1
index d1d4c50da5bf..43d8791e1a47 100644
@@ -1620,7 +1620,7 @@ static const struct drm_driver panthor_drm_driver = {
 	.minor = 5,
 
 	.gem_create_object = panthor_gem_create_object,
-	.gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table,
+	.gem_prime_import_sg_table = drm_gem_uma_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
 	.debugfs_init = panthor_debugfs_init,
 #endif
drivers/gpu/drm/panthor/panthor_fw.c +2 -2
index 38d87ab92eda..81cc6e2eee23 100644
@@ -620,7 +620,7 @@ static int panthor_fw_load_section_entry(struct panthor_device *ptdev,
 		panthor_fw_init_section_mem(ptdev, section);
 
 		bo = to_panthor_bo(section->mem->obj);
-		sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
+		sgt = drm_gem_uma_get_pages_sgt(&bo->base);
 		if (IS_ERR(sgt))
 			return PTR_ERR(sgt);
 
@@ -684,7 +684,7 @@ panthor_reload_fw_sections(struct panthor_device *ptdev, bool full_reload)
 			continue;
 
 		panthor_fw_init_section_mem(ptdev, section);
-		sgt = drm_gem_shmem_get_pages_sgt(&to_panthor_bo(section->mem->obj)->base);
+		sgt = drm_gem_uma_get_pages_sgt(&to_panthor_bo(section->mem->obj)->base);
 		if (!drm_WARN_ON(&ptdev->base, IS_ERR_OR_NULL(sgt)))
 			dma_sync_sgtable_for_device(ptdev->base.dev, sgt, DMA_TO_DEVICE);
 	}
drivers/gpu/drm/panthor/panthor_gem.c +20 -20
index 2c12c1c58e2b..68bc36fa70df 100644
@@ -75,7 +75,7 @@ static void panthor_gem_free_object(struct drm_gem_object *obj)
 	mutex_destroy(&bo->label.lock);
 
 	drm_gem_free_mmap_offset(&bo->base.base);
-	drm_gem_shmem_free(&bo->base);
+	drm_gem_uma_free(&bo->base);
 	drm_gem_object_put(vm_root_gem);
 }
 
@@ -123,7 +123,7 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
 			 size_t size, u32 bo_flags, u32 vm_map_flags,
 			 u64 gpu_va, const char *name)
 {
-	struct drm_gem_shmem_object *obj;
+	struct drm_gem_uma_object *obj;
 	struct panthor_kernel_bo *kbo;
 	struct panthor_gem_object *bo;
 	u32 debug_flags = PANTHOR_DEBUGFS_GEM_USAGE_FLAG_KERNEL;
@@ -136,7 +136,7 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
 	if (!kbo)
 		return ERR_PTR(-ENOMEM);
 
-	obj = drm_gem_shmem_create(&ptdev->base, size);
+	obj = drm_gem_uma_create(&ptdev->base, size);
 	if (IS_ERR(obj)) {
 		ret = PTR_ERR(obj);
 		goto err_free_bo;
@@ -207,16 +207,16 @@ static enum drm_gem_object_status panthor_gem_status(struct drm_gem_object *obj)
 
 static const struct drm_gem_object_funcs panthor_gem_funcs = {
 	.free = panthor_gem_free_object,
-	.print_info = drm_gem_shmem_object_print_info,
-	.pin = drm_gem_shmem_object_pin,
-	.unpin = drm_gem_shmem_object_unpin,
-	.get_sg_table = drm_gem_shmem_object_get_sg_table,
-	.vmap = drm_gem_shmem_object_vmap,
-	.vunmap = drm_gem_shmem_object_vunmap,
-	.mmap = drm_gem_shmem_object_mmap,
+	.print_info = drm_gem_uma_object_print_info,
+	.pin = drm_gem_uma_object_pin,
+	.unpin = drm_gem_uma_object_unpin,
+	.get_sg_table = drm_gem_uma_object_get_sg_table,
+	.vmap = drm_gem_uma_object_vmap,
+	.vunmap = drm_gem_uma_object_vunmap,
+	.mmap = drm_gem_uma_object_mmap,
 	.status = panthor_gem_status,
 	.export = panthor_gem_prime_export,
-	.vm_ops = &drm_gem_shmem_vm_ops,
+	.vm_ops = &drm_gem_uma_vm_ops,
 };
 
 /**
@@ -263,14 +263,14 @@ panthor_gem_create_with_handle(struct drm_file *file,
 			       u64 *size, u32 flags, u32 *handle)
 {
 	int ret;
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	struct panthor_gem_object *bo;
 
-	shmem = drm_gem_shmem_create(ddev, *size);
-	if (IS_ERR(shmem))
-		return PTR_ERR(shmem);
+	uma = drm_gem_uma_create(ddev, *size);
+	if (IS_ERR(uma))
+		return PTR_ERR(uma);
 
-	bo = to_panthor_bo(&shmem->base);
+	bo = to_panthor_bo(&uma->base);
 	bo->flags = flags;
 
 	if (exclusive_vm) {
@@ -288,10 +288,10 @@ panthor_gem_create_with_handle(struct drm_file *file,
 	 * FIXME: Ideally this should be done when pages are allocated, not at
 	 * BO creation time.
 	 */
-	if (shmem->map_wc) {
+	if (uma->map_wc) {
 		struct sg_table *sgt;
 
-		sgt = drm_gem_shmem_get_pages_sgt(shmem);
+		sgt = drm_gem_uma_get_pages_sgt(uma);
 		if (IS_ERR(sgt)) {
 			ret = PTR_ERR(sgt);
 			goto out_put_gem;
@@ -302,13 +302,13 @@ panthor_gem_create_with_handle(struct drm_file *file,
 	 * Allocate an id of idr table where the obj is registered
 	 * and handle has the id what user can see.
 	 */
-	ret = drm_gem_handle_create(file, &shmem->base, handle);
+	ret = drm_gem_handle_create(file, &uma->base, handle);
 	if (!ret)
 		*size = bo->base.base.size;
 
 out_put_gem:
 	/* drop reference from allocate - handle holds it now. */
-	drm_gem_object_put(&shmem->base);
+	drm_gem_object_put(&uma->base);
 
 	return ret;
 }
drivers/gpu/drm/panthor/panthor_gem.h +4 -4
index 80c6e24112d0..032b14a32b28 100644
@@ -5,7 +5,7 @@
 #ifndef __PANTHOR_GEM_H__
 #define __PANTHOR_GEM_H__
 
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/drm_mm.h>
 
 #include <linux/iosys-map.h>
@@ -64,8 +64,8 @@ struct panthor_gem_debugfs {
  * struct panthor_gem_object - Driver specific GEM object.
  */
 struct panthor_gem_object {
-	/** @base: Inherit from drm_gem_shmem_object. */
-	struct drm_gem_shmem_object base;
+	/** @base: Inherit from drm_gem_uma_object. */
+	struct drm_gem_uma_object base;
 
 	/**
 	 * @exclusive_vm_root_gem: Root GEM of the exclusive VM this GEM object
@@ -133,7 +133,7 @@ struct panthor_kernel_bo {
 static inline
 struct panthor_gem_object *to_panthor_bo(struct drm_gem_object *obj)
 {
-	return container_of(to_drm_gem_shmem_obj(obj), struct panthor_gem_object, base);
+	return container_of(to_drm_gem_uma_obj(obj), struct panthor_gem_object, base);
 }
 
 struct drm_gem_object *panthor_gem_create_object(struct drm_device *ddev, size_t size);
drivers/gpu/drm/panthor/panthor_mmu.c +5 -5
index 478ea98db95c..f51619cea679 100644
@@ -1073,7 +1073,7 @@ static void panthor_vm_bo_free(struct drm_gpuvm_bo *vm_bo)
 	struct panthor_gem_object *bo = to_panthor_bo(vm_bo->obj);
 
 	if (!drm_gem_is_imported(&bo->base.base))
-		drm_gem_shmem_unpin(&bo->base);
+		drm_gem_uma_unpin(&bo->base);
 	kfree(vm_bo);
 }
 
@@ -1218,15 +1218,15 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
 		 * once we have successfully called drm_gpuvm_bo_create(),
 		 * GPUVM will take care of dropping the pin for us.
 		 */
-		ret = drm_gem_shmem_pin(&bo->base);
+		ret = drm_gem_uma_pin(&bo->base);
 		if (ret)
 			goto err_cleanup;
 	}
 
-	sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
+	sgt = drm_gem_uma_get_pages_sgt(&bo->base);
 	if (IS_ERR(sgt)) {
 		if (!drm_gem_is_imported(&bo->base.base))
-			drm_gem_shmem_unpin(&bo->base);
+			drm_gem_uma_unpin(&bo->base);
 
 		ret = PTR_ERR(sgt);
 		goto err_cleanup;
@@ -1237,7 +1237,7 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
 	preallocated_vm_bo = drm_gpuvm_bo_create(&vm->base, &bo->base.base);
 	if (!preallocated_vm_bo) {
 		if (!drm_gem_is_imported(&bo->base.base))
-			drm_gem_shmem_unpin(&bo->base);
+			drm_gem_uma_unpin(&bo->base);
 
 		ret = -ENOMEM;
 		goto err_cleanup;
drivers/gpu/drm/panthor/panthor_sched.c +0 -1
index e74ca071159d..d8a3f6aa9aaa 100644
@@ -3,7 +3,6 @@
 
 #include <drm/drm_drv.h>
 #include <drm/drm_exec.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_managed.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
Signature · 1 line
2.52.0
author maintainer
#13 lore raw

PATCH 9/13 drm/v3d: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert v3d from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as v3d.

---
 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 ++++---
 4 files changed, 29 insertions(+), 31 deletions(-)
drivers/gpu/drm/v3d/Kconfig +1 -1
index ce62c5908e1d..4345cb0f4dd6 100644
@@ -5,8 +5,8 @@ config DRM_V3D
 	depends on DRM
 	depends on COMMON_CLK
 	depends on MMU
+	select DRM_GEM_UMA_HELPER
 	select DRM_SCHED
-	select DRM_GEM_SHMEM_HELPER
 	help
 	  Choose this option if you have a system that has a Broadcom
 	  V3D 3.x or newer GPUs. SoCs supported include the BCM2711,
drivers/gpu/drm/v3d/v3d_bo.c +22 -23

104 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_drv.h +2 -2
index 1884686985b8..3843d10fbd72 100644
@@ -8,7 +8,7 @@
 
 #include <drm/drm_encoder.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/gpu_scheduler.h>
 
 #include "v3d_performance_counters.h"
@@ -243,7 +243,7 @@ struct v3d_file_priv {
 };
 
 struct v3d_bo {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 
 	struct drm_mm_node node;
 
drivers/gpu/drm/v3d/v3d_mmu.c +4 -5
index a25d25a8ae61..a634ac3eaaf6 100644
@@ -82,13 +82,13 @@ int v3d_mmu_set_page_table(struct v3d_dev *v3d)
 
 void v3d_mmu_insert_ptes(struct v3d_bo *bo)
 {
-	struct drm_gem_shmem_object *shmem_obj = &bo->base;
-	struct v3d_dev *v3d = to_v3d_dev(shmem_obj->base.dev);
+	struct drm_gem_uma_object *uma_obj = &bo->base;
+	struct v3d_dev *v3d = to_v3d_dev(uma_obj->base.dev);
 	u32 page = bo->node.start;
 	struct scatterlist *sgl;
 	unsigned int count;
 
-	for_each_sgtable_dma_sg(shmem_obj->sgt, sgl, count) {
+	for_each_sgtable_dma_sg(uma_obj->sgt, sgl, count) {
 		dma_addr_t dma_addr = sg_dma_address(sgl);
 		u32 pfn = dma_addr >> V3D_MMU_PAGE_SHIFT;
 		unsigned int len = sg_dma_len(sgl);
@@ -121,8 +121,7 @@ void v3d_mmu_insert_ptes(struct v3d_bo *bo)
 		}
 	}
 
-	WARN_ON_ONCE(page - bo->node.start !=
-		     shmem_obj->base.size >> V3D_MMU_PAGE_SHIFT);
+	WARN_ON_ONCE(page - bo->node.start != uma_obj->base.size >> V3D_MMU_PAGE_SHIFT);
 
 	if (v3d_mmu_flush_all(v3d))
 		dev_err(v3d->drm.dev, "MMU flush timeout\n");
Signature · 1 line
2.52.0
author maintainer
#14 lore raw

PATCH 10/13 drm/virtgpu: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert virtgpu from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as virtgpu.

---
 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 +--
 6 files changed, 48 insertions(+), 48 deletions(-)
drivers/gpu/drm/virtio/Kconfig +2 -2
index fc884fb57b7e..eee61fce17fc 100644
@@ -2,10 +2,10 @@
 config DRM_VIRTIO_GPU
 	tristate "Virtio GPU driver"
 	depends on DRM && VIRTIO_MENU && MMU
-	select VIRTIO
 	select DRM_CLIENT_SELECTION
+	select DRM_GEM_UMA_HELPER
 	select DRM_KMS_HELPER
-	select DRM_GEM_SHMEM_HELPER
+	select VIRTIO
 	select VIRTIO_DMA_SHARED_BUFFER
 	help
 	   This is the virtual GPU driver for virtio.  It can be used with
drivers/gpu/drm/virtio/virtgpu_drv.c +2 -2
index a5ce96fb8a1d..8dbaa021f90f 100644
@@ -37,7 +37,7 @@
 #include <drm/drm.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_drv.h>
-#include <drm/drm_fbdev_shmem.h>
+#include <drm/drm_fbdev_uma.h>
 #include <drm/drm_file.h>
 #include <drm/drm_print.h>
 
@@ -234,7 +234,7 @@ static const struct drm_driver driver = {
 
 	.dumb_create = virtio_gpu_mode_dumb_create,
 
-	DRM_FBDEV_SHMEM_DRIVER_OPS,
+	DRM_FBDEV_UMA_DRIVER_OPS,
 
 #if defined(CONFIG_DEBUG_FS)
 	.debugfs_init = virtio_gpu_debugfs_init,
drivers/gpu/drm/virtio/virtgpu_drv.h +6 -6
index f17660a71a3e..d7a2293cc794 100644
@@ -38,7 +38,7 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_framebuffer.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/virtgpu_drm.h>
@@ -87,7 +87,7 @@ struct virtio_gpu_object_params {
 };
 
 struct virtio_gpu_object {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 	struct sg_table *sgt;
 	uint32_t hw_res_handle;
 	bool dumb;
@@ -102,7 +102,7 @@ struct virtio_gpu_object {
 #define gem_to_virtio_gpu_obj(gobj) \
 	container_of((gobj), struct virtio_gpu_object, base.base)
 
-struct virtio_gpu_object_shmem {
+struct virtio_gpu_object_uma {
 	struct virtio_gpu_object base;
 };
 
@@ -113,8 +113,8 @@ struct virtio_gpu_object_vram {
 	struct drm_mm_node vram_node;
 };
 
-#define to_virtio_gpu_shmem(virtio_gpu_object) \
-	container_of((virtio_gpu_object), struct virtio_gpu_object_shmem, base)
+#define to_virtio_gpu_uma(virtio_gpu_object) \
+	container_of((virtio_gpu_object), struct virtio_gpu_object_uma, base)
 
 #define to_virtio_gpu_vram(virtio_gpu_object) \
 	container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base)
@@ -474,7 +474,7 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
 			     struct virtio_gpu_object **bo_ptr,
 			     struct virtio_gpu_fence *fence);
 
-bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo);
+bool virtio_gpu_is_uma(struct virtio_gpu_object *bo);
 
 int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
 			       uint32_t *resid);
drivers/gpu/drm/virtio/virtgpu_object.c +32 -32

122 lines not on this page · raw message

drivers/gpu/drm/virtio/virtgpu_plane.c +3 -3
index a7863f8ee4ee..a80027e02612 100644
@@ -515,12 +515,12 @@ static int virtio_drm_get_scanout_buffer(struct drm_plane *plane,
 	if (bo->base.vaddr) {
 		iosys_map_set_vaddr(&sb->map[0], bo->base.vaddr);
 	} else {
-		struct drm_gem_shmem_object *shmem = &bo->base;
+		struct drm_gem_uma_object *uma = &bo->base;
 
-		if (!shmem->pages)
+		if (!uma->pages)
 			return -ENODEV;
 		/* map scanout buffer later */
-		sb->pages = shmem->pages;
+		sb->pages = uma->pages;
 	}
 
 	sb->format = plane->state->fb->format;
drivers/gpu/drm/virtio/virtgpu_vq.c +3 -3
index 0c194b4e9488..9c6607239629 100644
@@ -726,7 +726,7 @@ int virtio_gpu_panic_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
 	struct virtio_gpu_vbuffer *vbuf;
 	bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
 
-	if (virtio_gpu_is_shmem(bo) && use_dma_api)
+	if (virtio_gpu_is_uma(bo) && use_dma_api)
 		dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
 					    bo->base.sgt, DMA_TO_DEVICE);
 
@@ -757,7 +757,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
 	struct virtio_gpu_vbuffer *vbuf;
 	bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
 
-	if (virtio_gpu_is_shmem(bo) && use_dma_api)
+	if (virtio_gpu_is_uma(bo) && use_dma_api)
 		dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
 					    bo->base.sgt, DMA_TO_DEVICE);
 
@@ -1195,7 +1195,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
 	struct virtio_gpu_vbuffer *vbuf;
 	bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
 
-	if (virtio_gpu_is_shmem(bo) && use_dma_api)
+	if (virtio_gpu_is_uma(bo) && use_dma_api)
 		dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
 					    bo->base.sgt, DMA_TO_DEVICE);
 
Signature · 1 line
2.52.0
author maintainer
#15 lore raw

PATCH 11/13 accel/amdxdna: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert amdxdna from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as amdxdna.

---
 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 -
 12 files changed, 32 insertions(+), 39 deletions(-)
drivers/accel/amdxdna/Kconfig +1 -1
index f39d7a87296c..a417b18b401f 100644
@@ -6,8 +6,8 @@ config DRM_ACCEL_AMDXDNA
 	depends on DRM_ACCEL
 	depends on PCI && HAS_IOMEM
 	depends on X86_64
+	select DRM_GEM_UMA_HELPER
 	select DRM_SCHED
-	select DRM_GEM_SHMEM_HELPER
 	select FW_LOADER
 	select HMM_MIRROR
 	help
drivers/accel/amdxdna/aie2_ctx.c +0 -1
index 42d876a427c5..7e82496495d3 100644
@@ -6,7 +6,6 @@
 #include <drm/amdxdna_accel.h>
 #include <drm/drm_device.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_print.h>
 #include <drm/drm_syncobj.h>
 #include <linux/hmm.h>
drivers/accel/amdxdna/aie2_message.c +0 -1
index d493bb1c3360..2f639c22ebf1 100644
@@ -7,7 +7,6 @@
 #include <drm/drm_cache.h>
 #include <drm/drm_device.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
 #include <linux/bitfield.h>
drivers/accel/amdxdna/aie2_pci.c +0 -1
index ceef1c502e9e..498a23a070c9 100644
@@ -6,7 +6,6 @@
 #include <drm/amdxdna_accel.h>
 #include <drm/drm_device.h>
 #include <drm/drm_drv.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_managed.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
drivers/accel/amdxdna/aie2_psp.c +0 -1
index f28a060a8810..81145210abf3 100644
@@ -4,7 +4,6 @@
  */
 
 #include <drm/drm_device.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_managed.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
drivers/accel/amdxdna/aie2_smu.c +0 -1
index bd94ee96c2bc..a16942aa10a1 100644
@@ -4,7 +4,6 @@
  */
 
 #include <drm/drm_device.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
 #include <linux/iopoll.h>
drivers/accel/amdxdna/amdxdna_ctx.c +3 -4
index d17aef89a0ad..1c02a97b1865 100644
@@ -8,7 +8,6 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_file.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
 #include <linux/xarray.h>
@@ -387,7 +386,7 @@ amdxdna_arg_bos_lookup(struct amdxdna_client *client,
 		gobj = drm_gem_object_lookup(client->filp, bo_hdls[i]);
 		if (!gobj) {
 			ret = -ENOENT;
-			goto put_shmem_bo;
+			goto put_bos;
 		}
 		abo = to_xdna_obj(gobj);
 
@@ -402,7 +401,7 @@ amdxdna_arg_bos_lookup(struct amdxdna_client *client,
 		if (ret) {
 			mutex_unlock(&abo->lock);
 			drm_gem_object_put(gobj);
-			goto put_shmem_bo;
+			goto put_bos;
 		}
 		abo->pinned = true;
 		mutex_unlock(&abo->lock);
@@ -412,7 +411,7 @@ amdxdna_arg_bos_lookup(struct amdxdna_client *client,
 
 	return 0;
 
-put_shmem_bo:
+put_bos:
 	amdxdna_arg_bos_put(job);
 	return ret;
 }
drivers/accel/amdxdna/amdxdna_gem.c +24 -25

123 lines not on this page · raw message

drivers/accel/amdxdna/amdxdna_gem.h +4 -1
index f79fc7f3c93b..74c78c86125e 100644
@@ -7,6 +7,9 @@
 #define _AMDXDNA_GEM_H_
 
 #include <linux/hmm.h>
+
+#include <drm/drm_gem_uma_helper.h>
+
 #include "amdxdna_pci_drv.h"
 
 struct amdxdna_umap {
@@ -33,7 +36,7 @@ struct amdxdna_mem {
 };
 
 struct amdxdna_gem_obj {
-	struct drm_gem_shmem_object	base;
+	struct drm_gem_uma_object	base;
 	struct amdxdna_client		*client;
 	u8				type;
 	bool				pinned;
drivers/accel/amdxdna/amdxdna_mailbox_helper.c +0 -1
index 6d0c24513476..63c3b82ff1b0 100644
@@ -7,7 +7,6 @@
 #include <drm/drm_device.h>
 #include <drm/drm_print.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/gpu_scheduler.h>
 #include <linux/completion.h>
 
drivers/accel/amdxdna/amdxdna_pci_drv.c +0 -1
index 1973ab67721b..ae069b8805c7 100644
@@ -7,7 +7,6 @@
 #include <drm/drm_accel.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_ioctl.h>
 #include <drm/drm_managed.h>
 #include <drm/gpu_scheduler.h>
drivers/accel/amdxdna/amdxdna_sysfs.c +0 -1
index f27e4ee960a0..d7fcb9c9b7b5 100644
@@ -5,7 +5,6 @@
 
 #include <drm/amdxdna_accel.h>
 #include <drm/drm_device.h>
-#include <drm/drm_gem_shmem_helper.h>
 #include <drm/drm_print.h>
 #include <drm/gpu_scheduler.h>
 #include <linux/types.h>
Signature · 1 line
2.52.0
author maintainer
#16 lore raw

PATCH 12/13 accel/ivpu: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert ivpu from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as ivpu.

---
 drivers/accel/ivpu/Kconfig    |  2 +-
 drivers/accel/ivpu/ivpu_gem.c | 36 +++++++++++++++++------------------
 drivers/accel/ivpu/ivpu_gem.h |  4 ++--
 3 files changed, 21 insertions(+), 21 deletions(-)
drivers/accel/ivpu/Kconfig +1 -1
index 9e055b5ce03d..49ca139a9d31 100644
@@ -5,8 +5,8 @@ config DRM_ACCEL_IVPU
 	depends on DRM_ACCEL
 	depends on X86_64 && !UML
 	depends on PCI && PCI_MSI
+	select DRM_GEM_UMA_HELPER
 	select FW_LOADER
-	select DRM_GEM_SHMEM_HELPER
 	select GENERIC_ALLOCATOR
 	select WANT_DEV_COREDUMP
 	help
drivers/accel/ivpu/ivpu_gem.c +18 -18
index ece68f570b7e..7f4aeb482efb 100644
@@ -84,7 +84,7 @@ int __must_check ivpu_bo_bind(struct ivpu_bo *bo)
 	if (bo->base.base.import_attach)
 		sgt = ivpu_bo_map_attachment(vdev, bo);
 	else
-		sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
+		sgt = drm_gem_uma_get_pages_sgt(&bo->base);
 	if (IS_ERR(sgt)) {
 		ret = PTR_ERR(sgt);
 		ivpu_err(vdev, "Failed to map BO in IOMMU: %d\n", ret);
@@ -223,7 +223,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
 
 	get_dma_buf(dma_buf);
 
-	obj = drm_gem_shmem_prime_import_sg_table(dev, attach, NULL);
+	obj = drm_gem_uma_prime_import_sg_table(dev, attach, NULL);
 	if (IS_ERR(obj)) {
 		ret = PTR_ERR(obj);
 		goto fail_detach;
@@ -251,7 +251,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
 
 static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 flags)
 {
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	struct ivpu_bo *bo;
 
 	switch (flags & DRM_IVPU_BO_CACHE_MASK) {
@@ -262,11 +262,11 @@ static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 fla
 		return ERR_PTR(-EINVAL);
 	}
 
-	shmem = drm_gem_shmem_create(&vdev->drm, size);
-	if (IS_ERR(shmem))
-		return ERR_CAST(shmem);
+	uma = drm_gem_uma_create(&vdev->drm, size);
+	if (IS_ERR(uma))
+		return ERR_CAST(uma);
 
-	bo = to_ivpu_bo(&shmem->base);
+	bo = to_ivpu_bo(&uma->base);
 	bo->base.map_wc = flags & DRM_IVPU_BO_WC;
 	bo->flags = flags;
 
@@ -330,7 +330,7 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
 
 	drm_WARN_ON(obj->dev, refcount_read(&bo->base.pages_use_count) > 1);
 	drm_WARN_ON(obj->dev, bo->base.base.vma_node.vm_files.rb_node);
-	drm_gem_shmem_free(&bo->base);
+	drm_gem_uma_free(&bo->base);
 }
 
 static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
@@ -347,15 +347,15 @@ static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
 static const struct drm_gem_object_funcs ivpu_gem_funcs = {
 	.free = ivpu_gem_bo_free,
 	.open = ivpu_gem_bo_open,
-	.print_info = drm_gem_shmem_object_print_info,
-	.pin = drm_gem_shmem_object_pin,
-	.unpin = drm_gem_shmem_object_unpin,
-	.get_sg_table = drm_gem_shmem_object_get_sg_table,
-	.vmap = drm_gem_shmem_object_vmap,
-	.vunmap = drm_gem_shmem_object_vunmap,
-	.mmap = drm_gem_shmem_object_mmap,
+	.print_info = drm_gem_uma_object_print_info,
+	.pin = drm_gem_uma_object_pin,
+	.unpin = drm_gem_uma_object_unpin,
+	.get_sg_table = drm_gem_uma_object_get_sg_table,
+	.vmap = drm_gem_uma_object_vmap,
+	.vunmap = drm_gem_uma_object_vunmap,
+	.mmap = drm_gem_uma_object_mmap,
 	.status = ivpu_gem_status,
-	.vm_ops = &drm_gem_shmem_vm_ops,
+	.vm_ops = &drm_gem_uma_vm_ops,
 };
 
 int ivpu_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
@@ -435,7 +435,7 @@ ivpu_bo_create(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx,
 
 	if (flags & DRM_IVPU_BO_MAPPABLE) {
 		ivpu_bo_lock(bo);
-		ret = drm_gem_shmem_vmap_locked(&bo->base, &map);
+		ret = drm_gem_uma_vmap_locked(&bo->base, &map);
 		ivpu_bo_unlock(bo);
 
 		if (ret)
@@ -475,7 +475,7 @@ void ivpu_bo_free(struct ivpu_bo *bo)
 
 	if (bo->flags & DRM_IVPU_BO_MAPPABLE) {
 		ivpu_bo_lock(bo);
-		drm_gem_shmem_vunmap_locked(&bo->base, &map);
+		drm_gem_uma_vunmap_locked(&bo->base, &map);
 		ivpu_bo_unlock(bo);
 	}
 
drivers/accel/ivpu/ivpu_gem.h +2 -2
index 0c3350f22b55..3e5d1a64deab 100644
@@ -6,13 +6,13 @@
 #define __IVPU_GEM_H__
 
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 #include <drm/drm_mm.h>
 
 struct ivpu_file_priv;
 
 struct ivpu_bo {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 	struct ivpu_mmu_context *ctx;
 	struct list_head bo_list_node;
 	struct drm_mm_node mm_node;
Signature · 1 line
2.52.0
maintainer Reviewed-by on v1 12/13
#17 lore raw

Re: [PATCH 12/13] accel/ivpu: Use GEM-UMA helpers for memory management

Quoted 136 lines · Thomas Zimmermann

Convert ivpu from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as ivpu.

---
 drivers/accel/ivpu/Kconfig    |  2 +-
 drivers/accel/ivpu/ivpu_gem.c | 36 +++++++++++++++++------------------
 drivers/accel/ivpu/ivpu_gem.h |  4 ++--
 3 files changed, 21 insertions(+), 21 deletions(-)
drivers/accel/ivpu/Kconfig +1 -1
index 9e055b5ce03d..49ca139a9d31 100644
@@ -5,8 +5,8 @@ config DRM_ACCEL_IVPU
 	depends on DRM_ACCEL
 	depends on X86_64 && !UML
 	depends on PCI && PCI_MSI
+	select DRM_GEM_UMA_HELPER
 	select FW_LOADER
-	select DRM_GEM_SHMEM_HELPER
 	select GENERIC_ALLOCATOR
 	select WANT_DEV_COREDUMP
 	help
drivers/accel/ivpu/ivpu_gem.c +18 -18
index ece68f570b7e..7f4aeb482efb 100644
@@ -84,7 +84,7 @@ int __must_check ivpu_bo_bind(struct ivpu_bo *bo)
 	if (bo->base.base.import_attach)
 		sgt = ivpu_bo_map_attachment(vdev, bo);
 	else
-		sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
+		sgt = drm_gem_uma_get_pages_sgt(&bo->base);
 	if (IS_ERR(sgt)) {
 		ret = PTR_ERR(sgt);
 		ivpu_err(vdev, "Failed to map BO in IOMMU: %d\n", ret);
@@ -223,7 +223,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
 
 	get_dma_buf(dma_buf);
 
-	obj = drm_gem_shmem_prime_import_sg_table(dev, attach, NULL);
+	obj = drm_gem_uma_prime_import_sg_table(dev, attach, NULL);
 	if (IS_ERR(obj)) {
 		ret = PTR_ERR(obj);
 		goto fail_detach;
@@ -251,7 +251,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
 
 static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 flags)
 {
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	struct ivpu_bo *bo;
 
 	switch (flags & DRM_IVPU_BO_CACHE_MASK) {
@@ -262,11 +262,11 @@ static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 fla
 		return ERR_PTR(-EINVAL);
 	}
 
-	shmem = drm_gem_shmem_create(&vdev->drm, size);
-	if (IS_ERR(shmem))
-		return ERR_CAST(shmem);
+	uma = drm_gem_uma_create(&vdev->drm, size);
+	if (IS_ERR(uma))
+		return ERR_CAST(uma);
 
-	bo = to_ivpu_bo(&shmem->base);
+	bo = to_ivpu_bo(&uma->base);
 	bo->base.map_wc = flags & DRM_IVPU_BO_WC;
 	bo->flags = flags;
 
@@ -330,7 +330,7 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
 
 	drm_WARN_ON(obj->dev, refcount_read(&bo->base.pages_use_count) > 1);
 	drm_WARN_ON(obj->dev, bo->base.base.vma_node.vm_files.rb_node);
-	drm_gem_shmem_free(&bo->base);
+	drm_gem_uma_free(&bo->base);
 }
 
 static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
@@ -347,15 +347,15 @@ static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
 static const struct drm_gem_object_funcs ivpu_gem_funcs = {
 	.free = ivpu_gem_bo_free,
 	.open = ivpu_gem_bo_open,
-	.print_info = drm_gem_shmem_object_print_info,
-	.pin = drm_gem_shmem_object_pin,
-	.unpin = drm_gem_shmem_object_unpin,
-	.get_sg_table = drm_gem_shmem_object_get_sg_table,
-	.vmap = drm_gem_shmem_object_vmap,
-	.vunmap = drm_gem_shmem_object_vunmap,
-	.mmap = drm_gem_shmem_object_mmap,
+	.print_info = drm_gem_uma_object_print_info,
+	.pin = drm_gem_uma_object_pin,
+	.unpin = drm_gem_uma_object_unpin,
+	.get_sg_table = drm_gem_uma_object_get_sg_table,
+	.vmap = drm_gem_uma_object_vmap,
+	.vunmap = drm_gem_uma_object_vunmap,
+	.mmap = drm_gem_uma_object_mmap,
 	.status = ivpu_gem_status,
-	.vm_ops = &drm_gem_shmem_vm_ops,
+	.vm_ops = &drm_gem_uma_vm_ops,
 };
 
 int ivpu_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
@@ -435,7 +435,7 @@ ivpu_bo_create(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx,
 
 	if (flags & DRM_IVPU_BO_MAPPABLE) {
 		ivpu_bo_lock(bo);
-		ret = drm_gem_shmem_vmap_locked(&bo->base, &map);
+		ret = drm_gem_uma_vmap_locked(&bo->base, &map);
 		ivpu_bo_unlock(bo);
 
 		if (ret)
@@ -475,7 +475,7 @@ void ivpu_bo_free(struct ivpu_bo *bo)
 
 	if (bo->flags & DRM_IVPU_BO_MAPPABLE) {
 		ivpu_bo_lock(bo);
-		drm_gem_shmem_vunmap_locked(&bo->base, &map);
+		drm_gem_uma_vunmap_locked(&bo->base, &map);
 		ivpu_bo_unlock(bo);
 	}
 
drivers/accel/ivpu/ivpu_gem.h +1 -1
index 0c3350f22b55..3e5d1a64deab 100644
@@ -6,13 +6,13 @@
 #define __IVPU_GEM_H__
 
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>

drivers/accel/ivpu/ivpu_gem.h line 18

Quoted 10 lines
drivers/accel/ivpu/ivpu_gem.h +1 -1
 #include <drm/drm_mm.h>
 
 struct ivpu_file_priv;
 
 struct ivpu_bo {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 	struct ivpu_mmu_context *ctx;
 	struct list_head bo_list_node;
 	struct drm_mm_node mm_node;
maintainer Reviewed-by on v1 12/13
#18 lore raw

Re: [PATCH 12/13] accel/ivpu: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann
Quoted 136 lines · Thomas Zimmermann

Convert ivpu from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as ivpu.

---
 drivers/accel/ivpu/Kconfig    |  2 +-
 drivers/accel/ivpu/ivpu_gem.c | 36 +++++++++++++++++------------------
 drivers/accel/ivpu/ivpu_gem.h |  4 ++--
 3 files changed, 21 insertions(+), 21 deletions(-)
drivers/accel/ivpu/Kconfig +1 -1
index 9e055b5ce03d..49ca139a9d31 100644
@@ -5,8 +5,8 @@ config DRM_ACCEL_IVPU
 	depends on DRM_ACCEL
 	depends on X86_64 && !UML
 	depends on PCI && PCI_MSI
+	select DRM_GEM_UMA_HELPER
 	select FW_LOADER
-	select DRM_GEM_SHMEM_HELPER
 	select GENERIC_ALLOCATOR
 	select WANT_DEV_COREDUMP
 	help
drivers/accel/ivpu/ivpu_gem.c +18 -18
index ece68f570b7e..7f4aeb482efb 100644
@@ -84,7 +84,7 @@ int __must_check ivpu_bo_bind(struct ivpu_bo *bo)
 	if (bo->base.base.import_attach)
 		sgt = ivpu_bo_map_attachment(vdev, bo);
 	else
-		sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
+		sgt = drm_gem_uma_get_pages_sgt(&bo->base);
 	if (IS_ERR(sgt)) {
 		ret = PTR_ERR(sgt);
 		ivpu_err(vdev, "Failed to map BO in IOMMU: %d\n", ret);
@@ -223,7 +223,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
 
 	get_dma_buf(dma_buf);
 
-	obj = drm_gem_shmem_prime_import_sg_table(dev, attach, NULL);
+	obj = drm_gem_uma_prime_import_sg_table(dev, attach, NULL);
 	if (IS_ERR(obj)) {
 		ret = PTR_ERR(obj);
 		goto fail_detach;
@@ -251,7 +251,7 @@ struct drm_gem_object *ivpu_gem_prime_import(struct drm_device *dev,
 
 static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 flags)
 {
-	struct drm_gem_shmem_object *shmem;
+	struct drm_gem_uma_object *uma;
 	struct ivpu_bo *bo;
 
 	switch (flags & DRM_IVPU_BO_CACHE_MASK) {
@@ -262,11 +262,11 @@ static struct ivpu_bo *ivpu_bo_alloc(struct ivpu_device *vdev, u64 size, u32 fla
 		return ERR_PTR(-EINVAL);
 	}
 
-	shmem = drm_gem_shmem_create(&vdev->drm, size);
-	if (IS_ERR(shmem))
-		return ERR_CAST(shmem);
+	uma = drm_gem_uma_create(&vdev->drm, size);
+	if (IS_ERR(uma))
+		return ERR_CAST(uma);
 
-	bo = to_ivpu_bo(&shmem->base);
+	bo = to_ivpu_bo(&uma->base);
 	bo->base.map_wc = flags & DRM_IVPU_BO_WC;
 	bo->flags = flags;
 
@@ -330,7 +330,7 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
 
 	drm_WARN_ON(obj->dev, refcount_read(&bo->base.pages_use_count) > 1);
 	drm_WARN_ON(obj->dev, bo->base.base.vma_node.vm_files.rb_node);
-	drm_gem_shmem_free(&bo->base);
+	drm_gem_uma_free(&bo->base);
 }
 
 static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
@@ -347,15 +347,15 @@ static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
 static const struct drm_gem_object_funcs ivpu_gem_funcs = {
 	.free = ivpu_gem_bo_free,
 	.open = ivpu_gem_bo_open,
-	.print_info = drm_gem_shmem_object_print_info,
-	.pin = drm_gem_shmem_object_pin,
-	.unpin = drm_gem_shmem_object_unpin,
-	.get_sg_table = drm_gem_shmem_object_get_sg_table,
-	.vmap = drm_gem_shmem_object_vmap,
-	.vunmap = drm_gem_shmem_object_vunmap,
-	.mmap = drm_gem_shmem_object_mmap,
+	.print_info = drm_gem_uma_object_print_info,
+	.pin = drm_gem_uma_object_pin,
+	.unpin = drm_gem_uma_object_unpin,
+	.get_sg_table = drm_gem_uma_object_get_sg_table,
+	.vmap = drm_gem_uma_object_vmap,
+	.vunmap = drm_gem_uma_object_vunmap,
+	.mmap = drm_gem_uma_object_mmap,
 	.status = ivpu_gem_status,
-	.vm_ops = &drm_gem_shmem_vm_ops,
+	.vm_ops = &drm_gem_uma_vm_ops,
 };
 
 int ivpu_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
@@ -435,7 +435,7 @@ ivpu_bo_create(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx,
 
 	if (flags & DRM_IVPU_BO_MAPPABLE) {
 		ivpu_bo_lock(bo);
-		ret = drm_gem_shmem_vmap_locked(&bo->base, &map);
+		ret = drm_gem_uma_vmap_locked(&bo->base, &map);
 		ivpu_bo_unlock(bo);
 
 		if (ret)
@@ -475,7 +475,7 @@ void ivpu_bo_free(struct ivpu_bo *bo)
 
 	if (bo->flags & DRM_IVPU_BO_MAPPABLE) {
 		ivpu_bo_lock(bo);
-		drm_gem_shmem_vunmap_locked(&bo->base, &map);
+		drm_gem_uma_vunmap_locked(&bo->base, &map);
 		ivpu_bo_unlock(bo);
 	}
 
drivers/accel/ivpu/ivpu_gem.h +1 -1
index 0c3350f22b55..3e5d1a64deab 100644
@@ -6,13 +6,13 @@
 #define __IVPU_GEM_H__
 
 #include <drm/drm_gem.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>

drivers/accel/ivpu/ivpu_gem.h line 18

Quoted 10 lines
drivers/accel/ivpu/ivpu_gem.h +1 -1
 #include <drm/drm_mm.h>
 
 struct ivpu_file_priv;
 
 struct ivpu_bo {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 	struct ivpu_mmu_context *ctx;
 	struct list_head bo_list_node;
 	struct drm_mm_node mm_node;
author maintainer
#19 lore raw

PATCH 13/13 accel/rocket: Use GEM-UMA helpers for memory management

In reply to Thomas Zimmermann

Convert rocket from GEM-SHMEM to GEM-UMA. The latter is just a copy, so this change it merely renaming symbols. No functional changes.

GEM-SHMEM will become more self-contained for drivers without specific memory management. GEM-UMA's interfaces will remain flexible for drivers with UMA hardware, such as rocket.

---
 drivers/accel/rocket/Kconfig      |  2 +-
 drivers/accel/rocket/rocket_gem.c | 46 +++++++++++++++----------------
 drivers/accel/rocket/rocket_gem.h |  6 ++--
 3 files changed, 27 insertions(+), 27 deletions(-)
drivers/accel/rocket/Kconfig +1 -1
index 16465abe0660..26f760afdd7a 100644
@@ -6,8 +6,8 @@ config DRM_ACCEL_ROCKET
 	depends on (ARCH_ROCKCHIP && ARM64) || COMPILE_TEST
 	depends on ROCKCHIP_IOMMU || COMPILE_TEST
 	depends on MMU
+	select DRM_GEM_UMA_HELPER
 	select DRM_SCHED
-	select DRM_GEM_SHMEM_HELPER
 	help
 	  Choose this option if you have a Rockchip SoC that contains a
 	  compatible Neural Processing Unit (NPU), such as the RK3588. Called by
drivers/accel/rocket/rocket_gem.c +23 -23

112 lines not on this page · raw message

drivers/accel/rocket/rocket_gem.h +3 -3
index 240430334509..d5ea539519e7 100644
@@ -4,10 +4,10 @@
 #ifndef __ROCKET_GEM_H__
 #define __ROCKET_GEM_H__
 
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem_uma_helper.h>
 
 struct rocket_gem_object {
-	struct drm_gem_shmem_object base;
+	struct drm_gem_uma_object base;
 
 	struct rocket_file_priv *driver_priv;
 
@@ -28,7 +28,7 @@ int rocket_ioctl_fini_bo(struct drm_device *dev, void *data, struct drm_file *fi
 static inline
 struct  rocket_gem_object *to_rocket_bo(struct drm_gem_object *obj)
 {
-	return container_of(to_drm_gem_shmem_obj(obj), struct rocket_gem_object, base);
+	return container_of(to_drm_gem_uma_obj(obj), struct rocket_gem_object, base);
 }
 
 #endif
Signature · 1 line
2.52.0
maintainer
#20 lore raw
In reply to Thomas Zimmermann
Quoted 26 lines · On Tue, 9 Dec 2025 14:41:57 +0100 Thomas Zimmermann <[email protected]>…

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.

Quoted 7 lines

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.

Quoted 6 lines

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

Quoted 99 lines

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

author maintainer
#21 lore raw

Hi

Am 09.12.25 um 15:27 schrieb Boris Brezillon:

Quoted 36 lines
Quoted 26 lines · On Tue, 9 Dec 2025 14:41:57 +0100 Thomas Zimmermann <[email protected]>…

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.

Quoted 7 lines

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.

Quoted 13 lines

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.

Yeah, I've seen your update to that series. Making individual parts of the memory manager freely composable with each other is a fine idea.

But the flipside is that I also want the simple drivers to move away from the flexible approach that GEM-SHMEM currently takes. There are many drivers that do not need or want that. These drivers benefit from something that is self contained. Many of the drivers are also hardly maintained, so simplifying things will also be helpful.

I could have added a new GEM implementation for these drivers, but there are less UMA drivers to convert and the GEM-UMA naming generally fits better than GEM-SHMEM.

I'd rather have GEM-UMA and evolve it from where it stands now; and also evolve GEM-SHMEM in a different direction. There's a difference in concepts here.

Best regards
Thomas

Quoted 107 lines
Quoted 6 lines

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

Quoted 98 lines

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

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
maintainer
#22 lore raw
Quoted 62 lines · On Tue, 9 Dec 2025 15:51:21 +0100 Thomas Zimmermann <[email protected]> wrote:

Hi

Am 09.12.25 um 15:27 schrieb Boris Brezillon:

Quoted 36 lines
Quoted 26 lines · On Tue, 9 Dec 2025 14:41:57 +0100 Thomas Zimmermann <[email protected]>…

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.

Quoted 7 lines

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.

Quoted 13 lines

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.

Yeah, I've seen your update to that series. Making individual parts of the memory manager freely composable with each other is a fine idea.

But the flipside is that I also want the simple drivers to move away from the flexible approach that GEM-SHMEM currently takes. There are many drivers that do not need or want that. These drivers benefit from something that is self contained. Many of the drivers are also hardly maintained, so simplifying things will also be helpful.

Quoted 7 lines

I could have added a new GEM implementation for these drivers, but there are less UMA drivers to convert and the GEM-UMA naming generally fits better than GEM-SHMEM.

I'd rather have GEM-UMA and evolve it from where it stands now; and also evolve GEM-SHMEM in a different direction. There's a difference in concepts here.

Problem is, we'll be stuck trying to evolve gem-uma to something cleaner because of the existing abuse of gem-shmem that you're moving to gem-uma, so I'm not sure I like the idea to be honest. I'm all for this gem-uma thing, but I'm not convinced rushing it in is the right solution.

author maintainer
#23 lore raw

Hi

Am 09.12.25 um 16:30 schrieb Boris Brezillon:

Quoted 68 lines
Quoted 65 lines · On Tue, 9 Dec 2025 15:51:21 +0100 Thomas Zimmermann <[email protected]> wrote:

Hi

Am 09.12.25 um 15:27 schrieb Boris Brezillon:

Quoted 36 lines
Quoted 26 lines · On Tue, 9 Dec 2025 14:41:57 +0100 Thomas Zimmermann <[email protected]>…

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.

Quoted 7 lines

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.

Quoted 13 lines

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.

Yeah, I've seen your update to that series. Making individual parts of the memory manager freely composable with each other is a fine idea.

But the flipside is that I also want the simple drivers to move away from the flexible approach that GEM-SHMEM currently takes. There are many drivers that do not need or want that. These drivers benefit from something that is self contained. Many of the drivers are also hardly maintained, so simplifying things will also be helpful.

I could have added a new GEM implementation for these drivers, but there are less UMA drivers to convert and the GEM-UMA naming generally fits better than GEM-SHMEM.

Quoted 8 lines
Quoted 3 lines

I'd rather have GEM-UMA and evolve it from where it stands now; and also evolve GEM-SHMEM in a different direction. There's a difference in concepts here.

Problem is, we'll be stuck trying to evolve gem-uma to something cleaner because of the existing abuse of gem-shmem that you're moving to gem-uma, so I'm not sure I like the idea to be honest. I'm all for this gem-uma thing, but I'm not convinced rushing it in is the right solution.

The abuse you're talking about is what you mentioned about ivpu? How it uses the gem-shmem internals, right? Ivpu can get its own copy of gem-shmem, so that the developers can work it out. There's no benefit in sharing code at all cost. Code sharing only make sense if the callers are conceptually aligned on what the callee does.

Also what stops you from fixing any of this in the context of gem-uma? It should even be easier, as you won't have to keep my use cases in mind.

In parallel, gem-shmem could go in its own direction. I'd like to do some changes and simplifications there, which conflict with where gem-uma will be heading.

Best regards
Thomas

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
maintainer
#24 lore raw

Hi Thomas,

Quoted 80 lines · On Wed, 10 Dec 2025 08:34:02 +0100 Thomas Zimmermann <[email protected]>…

Hi

Am 09.12.25 um 16:30 schrieb Boris Brezillon:

Quoted 68 lines
Quoted 65 lines · On Tue, 9 Dec 2025 15:51:21 +0100 Thomas Zimmermann <[email protected]> wrote:

Hi

Am 09.12.25 um 15:27 schrieb Boris Brezillon:

Quoted 36 lines
Quoted 26 lines · On Tue, 9 Dec 2025 14:41:57 +0100 Thomas Zimmermann <[email protected]>…

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.

Quoted 7 lines

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.

Quoted 13 lines

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.

Yeah, I've seen your update to that series. Making individual parts of the memory manager freely composable with each other is a fine idea.

But the flipside is that I also want the simple drivers to move away from the flexible approach that GEM-SHMEM currently takes. There are many drivers that do not need or want that. These drivers benefit from something that is self contained. Many of the drivers are also hardly maintained, so simplifying things will also be helpful.

I could have added a new GEM implementation for these drivers, but there are less UMA drivers to convert and the GEM-UMA naming generally fits better than GEM-SHMEM.

Quoted 8 lines
Quoted 3 lines

I'd rather have GEM-UMA and evolve it from where it stands now; and also evolve GEM-SHMEM in a different direction. There's a difference in concepts here.

Problem is, we'll be stuck trying to evolve gem-uma to something cleaner because of the existing abuse of gem-shmem that you're moving to gem-uma, so I'm not sure I like the idea to be honest. I'm all for this gem-uma thing, but I'm not convinced rushing it in is the right solution.

Quoted 3 lines

The abuse you're talking about is what you mentioned about ivpu? How it uses the gem-shmem internals, right? Ivpu can get its own copy of gem-shmem, so that the developers can work it out.

There's that one, but there's also panfrost/lima manually filling the pages array for their on-fault-allocation mechanism, and probably other funky stuff I didn't notice yet.

Quoted 3 lines

There's no benefit in
sharing code at all cost. Code sharing only make sense if the callers are conceptually aligned on what the callee does.

At this point I think I'm clear on what you think about code sharing, and I can pretty safely say I don't fully agree with you on this point :P. IMHO, there's benefit in sharing code when the rules are clearly defined, but gem-shmem has been so lax that we reached a point where it has become the far west, and everyone happily manipulates gem_shmem internals without the core helpers knowing. That's when it becomes a mess, on that, I agree.

Quoted 2 lines

Also what stops you from fixing any of this in the context of gem-uma?

That's exactly what I want to do, except that, rather than fixing it, I'd like to get it right from the start and progressively move existing GPU/accel drivers using gem-shmem to gem-uma. If you blindly move every GPU/accel drivers currently using gem-shmem to gem-uma (which is just a rebranded gem-shmem), you're just moving the problem, you're not solving it. And all of a sudden, gem-uma, which I wanted to be this clean slate with well defined rules, on top of which we can more easily add building blocks for advanced stuff (reclaim, sparse allocation, ...), is back to this far west.

Quoted 1 line

It should even be easier, as you won't have to keep my use cases in mind.

I might be wrong, but KMS use cases are probably not the problematic ones.

Quoted 2 lines

In parallel, gem-shmem could go in its own direction.

My understanding is that you're primarily targeting KMS drivers, so why don't you fork gem-shem with something called gem-shmem-for-kms (or gem-shmem-dumb) that does just enough for you, and nothing more?

I'm saying that with a bit of sarcasm, and I certainly get how painful it is to go and patch all KMS drivers to rename things. But if you think about it for a second, it's just as painful (if not more) to fork gem-uma in all users that might get in the way of a cleaner abstraction. Not only that, but all of a sudden, you need a lot more synchronization to get that approved, and until that happens, you're blocked on the real stuff: designing something that's sounds for more complex use cases GPU/accel drivers care about.

Quoted 3 lines

I'd like to do
some changes and simplifications there, which conflict with where gem-uma will be heading.

Just to be clear, I'm not going to block this if that's the direction people want to take, but I wanted to point out that making it easier for you might mean making others' life harder. When I initially proposed to fork gem-shmem it was not with the goal of pulling all current GPU/accel users in directly, but rather design something that provides the same set of features (with the ability to add more), with better defined rules, so we don't end up in the same situation. What you're doing here is the opposite: gem-uma becomes the gem-shmem's forget-about box, and as a result, it becomes someone else's problem.

Regards,

Boris

author maintainer
#25 lore raw

Hi

Am 10.12.25 um 10:21 schrieb Boris Brezillon:
[...]

Quoted 9 lines

n that, I agree.

Quoted 1 line

Also what stops you from fixing any of this in the context of gem-uma?

That's exactly what I want to do, except that, rather than fixing it, I'd like to get it right from the start and progressively move existing GPU/accel drivers using gem-shmem to gem-uma. If you blindly move every GPU/accel drivers currently using gem-shmem to gem-uma (which is just a rebranded gem-shmem), you're just moving the problem, you're not solving it. And all of a sudden, gem-uma, which I wanted to be this

Just to be clear, I'm trying to get the simple drivers out of the way first. Nothing more. Solving problems with the UMA drivers is out of question wrt this series.

Quoted 3 lines

clean slate with well defined rules, on top of which we can more easily add building blocks for advanced stuff (reclaim, sparse allocation, ...), is back to this far west.

I've done something similar with GEM VRAM helpers a few years back. We had drivers running TTM on cinsiderably simple hardware. They all went to VRAM helpers at some point Still that took quite some time. With UMA the problem seems more complex and the drivers are moving targets. I feel like this will take years until you see the fruits of that work. All while you have to maintain GEM's UMA and SHMEM code at the same time.

Quoted 10 lines
Quoted 2 lines

It should even be easier, as you won't have to keep my use cases in mind.

I might be wrong, but KMS use cases are probably not the problematic ones.

Quoted 1 line

In parallel, gem-shmem could go in its own direction.

My understanding is that you're primarily targeting KMS drivers, so why don't you fork gem-shem with something called gem-shmem-for-kms (or gem-shmem-dumb) that does just enough for you, and nothing more?

Quoted 8 lines

I'm saying that with a bit of sarcasm, and I certainly get how painful it is to go and patch all KMS drivers to rename things. But if you think about it for a second, it's just as painful (if not more) to fork gem-uma in all users that might get in the way of a cleaner abstraction. Not only that, but all of a sudden, you need a lot more synchronization to get that approved, and until that happens, you're blocked on the real stuff: designing something that's sounds for more complex use cases GPU/accel drivers care about.

There's nothing sarcastic about that. Forking from GEM SHMEM in the 'opposite direction' would be the other alternative. I can try to provide something like GEM sysmem helpers with a simplified implementation of GEM shmem that provides what the simple drivers need.

Best regards
Thomas

Quoted 17 lines
Quoted 4 lines

I'd like to do
some changes and simplifications there, which conflict with where gem-uma will be heading.

Just to be clear, I'm not going to block this if that's the direction people want to take, but I wanted to point out that making it easier for you might mean making others' life harder. When I initially proposed to fork gem-shmem it was not with the goal of pulling all current GPU/accel users in directly, but rather design something that provides the same set of features (with the ability to add more), with better defined rules, so we don't end up in the same situation. What you're doing here is the opposite: gem-uma becomes the gem-shmem's forget-about box, and as a result, it becomes someone else's problem.

Regards,

Boris

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)