Skip to contentSkip to conversation

Merge VRAM MM and GEM VRAM source files

PATCH Superseded Thomas Zimmermann 2 participants 9 messages Sep 9, 2019 – Sep 10, 2019

Subsystems (8)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover Merge VRAM MM and GEM VRAM source files

VRAM MM and GEM VRAM are only used with each other. This patch set moves VRAM MM into GEM VRAM source files and cleans up the helper's public interface.

Thomas Zimmermann (4):
drm/vram: Move VRAM memory manager to GEM VRAM implementation drm/vram: Have VRAM MM call GEM VRAM functions directly drm/vram: Unexport internal functions of VRAM MM drm/vram: Unconditonally set BO call-back functions

 Documentation/gpu/drm-mm.rst                  |  12 -
 drivers/gpu/drm/Makefile                      |   3 +-
 drivers/gpu/drm/ast/ast_drv.c                 |   1 -
 drivers/gpu/drm/ast/ast_main.c                |   1 -
 drivers/gpu/drm/ast/ast_ttm.c                 |   3 +-
 drivers/gpu/drm/bochs/bochs.h                 |   1 -
 drivers/gpu/drm/bochs/bochs_mm.c              |   3 +-
 drivers/gpu/drm/drm_gem_vram_helper.c         | 361 ++++++++++++++----
 drivers/gpu/drm/drm_vram_helper_common.c      |   8 +-
 drivers/gpu/drm/drm_vram_mm_helper.c          | 309 ---------------
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |   1 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   |   3 +-
 drivers/gpu/drm/mgag200/mgag200_drv.h         |   1 -
 drivers/gpu/drm/mgag200/mgag200_ttm.c         |   3 +-
 drivers/gpu/drm/vboxvideo/vbox_drv.h          |   2 -
 drivers/gpu/drm/vboxvideo/vbox_ttm.c          |   3 +-
 include/drm/drm_gem_vram_helper.h             |  90 ++++-
 include/drm/drm_vram_mm_helper.h              | 108 ------
 18 files changed, 375 insertions(+), 538 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_vram_mm_helper.c
 delete mode 100644 include/drm/drm_vram_mm_helper.h

--
2.23.0

author maintainer
#1 lore raw

PATCH 1/4 drm/vram: Move VRAM memory manager to GEM VRAM implementation

The separation between GEM VRAM objects and and the memory manager is artificial, as they are only used with each other. Copying both implementations into the same file is a first step to simplifying the code.

This patch only moves code without functional changes.

---
 Documentation/gpu/drm-mm.rst                  |  12 -
 drivers/gpu/drm/Makefile                      |   3 +-
 drivers/gpu/drm/ast/ast_drv.c                 |   1 -
 drivers/gpu/drm/ast/ast_main.c                |   1 -
 drivers/gpu/drm/ast/ast_ttm.c                 |   1 -
 drivers/gpu/drm/bochs/bochs.h                 |   1 -
 drivers/gpu/drm/drm_gem_vram_helper.c         | 303 +++++++++++++++++
 drivers/gpu/drm/drm_vram_mm_helper.c          | 309 ------------------
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |   1 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   |   1 -
 drivers/gpu/drm/mgag200/mgag200_drv.h         |   1 -
 drivers/gpu/drm/vboxvideo/vbox_drv.h          |   2 -
 include/drm/drm_gem_vram_helper.h             |  85 +++++
 include/drm/drm_vram_mm_helper.h              |  76 -----
 14 files changed, 389 insertions(+), 408 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_vram_mm_helper.c
Documentation/gpu/drm-mm.rst +0 -12
index b664f054c259..9e61fef3cf5b 100644
@@ -400,18 +400,6 @@ GEM VRAM Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_gem_vram_helper.c
    :export:
 
-VRAM MM Helper Functions Reference
-----------------------------------
-
-.. kernel-doc:: drivers/gpu/drm/drm_vram_mm_helper.c
-   :doc: overview
-
-.. kernel-doc:: include/drm/drm_vram_mm_helper.h
-   :internal:
-
-.. kernel-doc:: drivers/gpu/drm/drm_vram_mm_helper.c
-   :export:
-
 VMA Offset Manager
 ==================
 
drivers/gpu/drm/Makefile +1 -2
index 82ff826b33cc..bb8cf02a604b 100644
@@ -33,8 +33,7 @@ drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 
 drm_vram_helper-y := drm_gem_vram_helper.o \
-		     drm_vram_helper_common.o \
-		     drm_vram_mm_helper.o
+		     drm_vram_helper_common.o
 obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o
 
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper.o \
drivers/gpu/drm/ast/ast_drv.c +0 -1
index 6ed6ff49efc0..e0e8770462bc 100644
@@ -35,7 +35,6 @@
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_pci.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "ast_drv.h"
 
drivers/gpu/drm/ast/ast_main.c +0 -1
index 50de8e47659c..21715d6a9b56 100644
@@ -33,7 +33,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_gem_vram_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "ast_drv.h"
 
drivers/gpu/drm/ast/ast_ttm.c +0 -1
index c52d92294171..08ba0a917593 100644
@@ -30,7 +30,6 @@
 
 #include <drm/drm_print.h>
 #include <drm/drm_gem_vram_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "ast_drv.h"
 
drivers/gpu/drm/bochs/bochs.h +0 -1
index 68483a2fc12c..917767173ee6 100644
@@ -10,7 +10,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 /* ---------------------------------------------------------------------- */
 
drivers/gpu/drm/drm_gem_vram_helper.c +303 -0

318 lines not on this page · raw message

drivers/gpu/drm/drm_vram_mm_helper.c deleted +0 -309

309 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +0 -1
index c103005b0a33..4f52c83b9b4c 100644
@@ -22,7 +22,6 @@
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "hibmc_drm_drv.h"
 #include "hibmc_drm_regs.h"
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +0 -1
index 9f6e473e6295..5d52cd748603 100644
@@ -17,7 +17,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_print.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "hibmc_drm_drv.h"
 
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -1
index 1c93f8dc08c7..37c003ed57c0 100644
@@ -19,7 +19,6 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "mgag200_reg.h"
 
drivers/gpu/drm/vboxvideo/vbox_drv.h +0 -2
index e8cb9efc6088..fb436ec760ea 100644
@@ -20,8 +20,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
 
-#include <drm/drm_vram_mm_helper.h>
-
 #include "vboxvideo_guest.h"
 #include "vboxvideo_vbe.h"
 #include "hgsmi_ch_setup.h"
include/drm/drm_gem_vram_helper.h +85 -0

98 lines not on this page · raw message

include/drm/drm_vram_mm_helper.h +0 -76

80 lines not on this page · raw message

Signature · 1 line
2.23.0
author maintainer
#3 lore raw

PATCH 2/4 drm/vram: Have VRAM MM call GEM VRAM functions directly

In reply to Thomas Zimmermann

VRAM MM and GEM VRAM buffer objects are only used with each other; connected via 3 function pointers. Simplifiy this code by making the memory manager call the rsp. functions from the BOs directly; and remove the functions from he BO's public interface.

---
 drivers/gpu/drm/ast/ast_ttm.c               |   2 +-
 drivers/gpu/drm/bochs/bochs_mm.c            |   3 +-
 drivers/gpu/drm/drm_gem_vram_helper.c       | 119 ++++++--------------
 drivers/gpu/drm/drm_vram_helper_common.c    |   8 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |   2 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c       |   3 +-
 drivers/gpu/drm/vboxvideo/vbox_ttm.c        |   3 +-
 include/drm/drm_gem_vram_helper.h           |  24 +---
 include/drm/drm_vram_mm_helper.h            |  32 ------
 9 files changed, 44 insertions(+), 152 deletions(-)
 delete mode 100644 include/drm/drm_vram_mm_helper.h
drivers/gpu/drm/ast/ast_ttm.c +1 -1
index 08ba0a917593..fad34106083a 100644
@@ -41,7 +41,7 @@ int ast_mm_init(struct ast_private *ast)
 
 	vmm = drm_vram_helper_alloc_mm(
 		dev, pci_resource_start(dev->pdev, 0),
-		ast->vram_size, &drm_gem_vram_mm_funcs);
+		ast->vram_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
drivers/gpu/drm/bochs/bochs_mm.c +1 -2
index 8f9bb886f7ad..1b74f530b07c 100644
@@ -11,8 +11,7 @@ int bochs_mm_init(struct bochs_device *bochs)
 	struct drm_vram_mm *vmm;
 
 	vmm = drm_vram_helper_alloc_mm(bochs->dev, bochs->fb_base,
-				       bochs->fb_size,
-				       &drm_gem_vram_mm_funcs);
+				       bochs->fb_size);
 	return PTR_ERR_OR_ZERO(vmm);
 }
 
drivers/gpu/drm/drm_gem_vram_helper.c +34 -85

204 lines not on this page · raw message

drivers/gpu/drm/drm_vram_helper_common.c +3 -5
index e9c9f9a80ba3..2000d9b33fd5 100644
@@ -7,9 +7,8 @@
  *
  * This library provides &struct drm_gem_vram_object (GEM VRAM), a GEM
  * buffer object that is backed by video RAM. It can be used for
- * framebuffer devices with dedicated memory. The video RAM can be
- * managed with &struct drm_vram_mm (VRAM MM). Both data structures are
- * supposed to be used together, but can also be used individually.
+ * framebuffer devices with dedicated memory. The video RAM is managed
+ * by &struct drm_vram_mm (VRAM MM).
  *
  * With the GEM interface userspace applications create, manage and destroy
  * graphics buffers, such as an on-screen framebuffer. GEM does not provide
@@ -50,8 +49,7 @@
  *		// setup device, vram base and size
  *		// ...
  *
- *		ret = drm_vram_helper_alloc_mm(dev, vram_base, vram_size,
- *					       &drm_gem_vram_mm_funcs);
+ *		ret = drm_vram_helper_alloc_mm(dev, vram_base, vram_size);
  *		if (ret)
  *			return ret;
  *		return 0;
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +1 -1
index 5d52cd748603..21b684eab5c9 100644
@@ -28,7 +28,7 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc)
 
 	vmm = drm_vram_helper_alloc_mm(dev,
 				       pci_resource_start(dev->pdev, 0),
-				       hibmc->fb_size, &drm_gem_vram_mm_funcs);
+				       hibmc->fb_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
drivers/gpu/drm/mgag200/mgag200_ttm.c +1 -2
index 73a6b848601c..69c81ebf3745 100644
@@ -37,8 +37,7 @@ int mgag200_mm_init(struct mga_device *mdev)
 	struct drm_device *dev = mdev->dev;
 
 	vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
-				       mdev->mc.vram_size,
-				       &drm_gem_vram_mm_funcs);
+				       mdev->mc.vram_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
drivers/gpu/drm/vboxvideo/vbox_ttm.c +1 -2
index b82595a9ed0f..976423d0c3cc 100644
@@ -17,8 +17,7 @@ int vbox_mm_init(struct vbox_private *vbox)
 	struct drm_device *dev = &vbox->ddev;
 
 	vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
-				       vbox->available_vram_size,
-				       &drm_gem_vram_mm_funcs);
+				       vbox->available_vram_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
include/drm/drm_gem_vram_helper.h +2 -22
index af7450851c09..52e3f2aff490 100644
@@ -109,22 +109,6 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
 				  bool interruptible,
 				  struct drm_mode_create_dumb *args);
 
-/*
- * Helpers for struct ttm_bo_driver
- */
-
-void drm_gem_vram_bo_driver_evict_flags(struct ttm_buffer_object *bo,
-					struct ttm_placement *pl);
-
-void drm_gem_vram_bo_driver_move_notify(struct ttm_buffer_object *bo,
-					bool evict,
-					struct ttm_mem_reg *new_mem);
-
-int drm_gem_vram_bo_driver_verify_access(struct ttm_buffer_object *bo,
-					 struct file *filp);
-
-extern const struct drm_vram_mm_funcs drm_gem_vram_mm_funcs;
-
 /*
  * Helpers for struct drm_driver
  */
@@ -169,8 +153,6 @@ struct drm_vram_mm {
 	size_t vram_size;
 
 	struct ttm_bo_device bdev;
-
-	const struct drm_vram_mm_funcs *funcs;
 };
 
 /**
@@ -188,8 +170,7 @@ static inline struct drm_vram_mm *drm_vram_mm_of_bdev(
 }
 
 int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
-		     uint64_t vram_base, size_t vram_size,
-		     const struct drm_vram_mm_funcs *funcs);
+		     uint64_t vram_base, size_t vram_size);
 void drm_vram_mm_cleanup(struct drm_vram_mm *vmm);
 
 int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
@@ -200,8 +181,7 @@ int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
  */
 
 struct drm_vram_mm *drm_vram_helper_alloc_mm(
-	struct drm_device *dev, uint64_t vram_base, size_t vram_size,
-	const struct drm_vram_mm_funcs *funcs);
+	struct drm_device *dev, uint64_t vram_base, size_t vram_size);
 void drm_vram_helper_release_mm(struct drm_device *dev);
 
 /*
include/drm/drm_vram_mm_helper.h deleted +0 -32
deleted file mode 100644
index e3b79e13e106..000000000000
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#ifndef DRM_VRAM_MM_HELPER_H
-#define DRM_VRAM_MM_HELPER_H
-
-#include <drm/drm_file.h>
-#include <drm/drm_ioctl.h>
-#include <drm/ttm/ttm_bo_driver.h>
-
-struct drm_device;
-
-/**
- * struct drm_vram_mm_funcs - Callback functions for &struct drm_vram_mm
- * @evict_flags:	Provides an implementation for struct \
-	&ttm_bo_driver.evict_flags
- * @verify_access:	Provides an implementation for \
-	struct &ttm_bo_driver.verify_access
- * @move_notify:	Provides an implementation for
- *			struct &ttm_bo_driver.move_notify
- *
- * These callback function integrate VRAM MM with TTM buffer objects. New
- * functions can be added if necessary.
- */
-struct drm_vram_mm_funcs {
-	void (*evict_flags)(struct ttm_buffer_object *bo,
-			    struct ttm_placement *placement);
-	int (*verify_access)(struct ttm_buffer_object *bo, struct file *filp);
-	void (*move_notify)(struct ttm_buffer_object *bo, bool evict,
-			    struct ttm_mem_reg *new_mem);
-};
-
-#endif
Signature · 1 line
2.23.0
author maintainer
#5 lore raw

PATCH 3/4 drm/vram: Unexport internal functions of VRAM MM

In reply to Thomas Zimmermann

The init, cleanup and mmap functions of VRAM MM are only used internally. Remove them from the public interface.

---
 drivers/gpu/drm/drm_gem_vram_helper.c | 38 ++++-----------------------
 include/drm/drm_gem_vram_helper.h     |  7 -----
 2 files changed, 5 insertions(+), 40 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +5 -33
index ed1ffbec5d02..73e81e3a8724 100644
@@ -844,19 +844,8 @@ static struct ttm_bo_driver bo_driver = {
  * struct drm_vram_mm
  */
 
-/**
- * drm_vram_mm_init() - Initialize an instance of VRAM MM.
- * @vmm:	the VRAM MM instance to initialize
- * @dev:	the DRM device
- * @vram_base:	the base address of the video memory
- * @vram_size:	the size of the video memory in bytes
- *
- * Returns:
- * 0 on success, or
- * a negative error code otherwise.
- */
-int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
-		     uint64_t vram_base, size_t vram_size)
+static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
+			    uint64_t vram_base, size_t vram_size)
 {
 	int ret;
 
@@ -875,34 +864,17 @@ int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
 
 	return 0;
 }
-EXPORT_SYMBOL(drm_vram_mm_init);
 
-/**
- * drm_vram_mm_cleanup() - Cleans up an initialized instance of VRAM MM.
- * @vmm:	the VRAM MM instance to clean up
- */
-void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
+static void drm_vram_mm_cleanup(struct drm_vram_mm *vmm)
 {
 	ttm_bo_device_release(&vmm->bdev);
 }
-EXPORT_SYMBOL(drm_vram_mm_cleanup);
 
-/**
- * drm_vram_mm_mmap() - Helper for implementing &struct file_operations.mmap()
- * @filp:	the mapping's file structure
- * @vma:	the mapping's memory area
- * @vmm:	the VRAM MM instance
- *
- * Returns:
- * 0 on success, or
- * a negative error code otherwise.
- */
-int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
-		     struct drm_vram_mm *vmm)
+static int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
+			    struct drm_vram_mm *vmm)
 {
 	return ttm_bo_mmap(filp, vma, &vmm->bdev);
 }
-EXPORT_SYMBOL(drm_vram_mm_mmap);
 
 /*
  * Helpers for integration with struct drm_device
include/drm/drm_gem_vram_helper.h +0 -7
index 52e3f2aff490..3c204f17a0b8 100644
@@ -169,13 +169,6 @@ static inline struct drm_vram_mm *drm_vram_mm_of_bdev(
 	return container_of(bdev, struct drm_vram_mm, bdev);
 }
 
-int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
-		     uint64_t vram_base, size_t vram_size);
-void drm_vram_mm_cleanup(struct drm_vram_mm *vmm);
-
-int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
-		     struct drm_vram_mm *vmm);
-
 /*
  * Helpers for integration with struct drm_device
  */
Signature · 1 line
2.23.0
author maintainer
#6 lore raw

PATCH 4/4 drm/vram: Unconditonally set BO call-back functions

In reply to Thomas Zimmermann

The statement's condition is always true.

---
 drivers/gpu/drm/drm_gem_vram_helper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +1 -2
index 73e81e3a8724..13717ae65da5 100644
@@ -91,8 +91,7 @@ static int drm_gem_vram_init(struct drm_device *dev,
 	int ret;
 	size_t acc_size;
 
-	if (!gbo->bo.base.funcs)
-		gbo->bo.base.funcs = &drm_gem_vram_object_funcs;
+	gbo->bo.base.funcs = &drm_gem_vram_object_funcs;
 
 	ret = drm_gem_object_init(dev, &gbo->bo.base, size);
 	if (ret)
Signature · 1 line
2.23.0
author maintainer
#2 lore raw

PATCH 1/4 drm/vram: Move VRAM memory manager to GEM VRAM implementation

In reply to Thomas Zimmermann

The separation between GEM VRAM objects and and the memory manager is artificial, as they are only used with each other. Copying both implementations into the same file is a first step to simplifying the code.

This patch only moves code without functional changes.

---
 Documentation/gpu/drm-mm.rst                  |  12 -
 drivers/gpu/drm/Makefile                      |   3 +-
 drivers/gpu/drm/ast/ast_drv.c                 |   1 -
 drivers/gpu/drm/ast/ast_main.c                |   1 -
 drivers/gpu/drm/ast/ast_ttm.c                 |   1 -
 drivers/gpu/drm/bochs/bochs.h                 |   1 -
 drivers/gpu/drm/drm_gem_vram_helper.c         | 303 +++++++++++++++++
 drivers/gpu/drm/drm_vram_mm_helper.c          | 309 ------------------
 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |   1 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c   |   1 -
 drivers/gpu/drm/mgag200/mgag200_drv.h         |   1 -
 drivers/gpu/drm/vboxvideo/vbox_drv.h          |   2 -
 include/drm/drm_gem_vram_helper.h             |  85 +++++
 include/drm/drm_vram_mm_helper.h              |  76 -----
 14 files changed, 389 insertions(+), 408 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_vram_mm_helper.c
Documentation/gpu/drm-mm.rst +0 -12
index b664f054c259..9e61fef3cf5b 100644
@@ -400,18 +400,6 @@ GEM VRAM Helper Functions Reference
 .. kernel-doc:: drivers/gpu/drm/drm_gem_vram_helper.c
    :export:
 
-VRAM MM Helper Functions Reference
-----------------------------------
-
-.. kernel-doc:: drivers/gpu/drm/drm_vram_mm_helper.c
-   :doc: overview
-
-.. kernel-doc:: include/drm/drm_vram_mm_helper.h
-   :internal:
-
-.. kernel-doc:: drivers/gpu/drm/drm_vram_mm_helper.c
-   :export:
-
 VMA Offset Manager
 ==================
 
drivers/gpu/drm/Makefile +1 -2
index 82ff826b33cc..bb8cf02a604b 100644
@@ -33,8 +33,7 @@ drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 
 drm_vram_helper-y := drm_gem_vram_helper.o \
-		     drm_vram_helper_common.o \
-		     drm_vram_mm_helper.o
+		     drm_vram_helper_common.o
 obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o
 
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper.o \
drivers/gpu/drm/ast/ast_drv.c +0 -1
index 6ed6ff49efc0..e0e8770462bc 100644
@@ -35,7 +35,6 @@
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_pci.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "ast_drv.h"
 
drivers/gpu/drm/ast/ast_main.c +0 -1
index 50de8e47659c..21715d6a9b56 100644
@@ -33,7 +33,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_gem_vram_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "ast_drv.h"
 
drivers/gpu/drm/ast/ast_ttm.c +0 -1
index c52d92294171..08ba0a917593 100644
@@ -30,7 +30,6 @@
 
 #include <drm/drm_print.h>
 #include <drm/drm_gem_vram_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "ast_drv.h"
 
drivers/gpu/drm/bochs/bochs.h +0 -1
index 68483a2fc12c..917767173ee6 100644
@@ -10,7 +10,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 /* ---------------------------------------------------------------------- */
 
drivers/gpu/drm/drm_gem_vram_helper.c +303 -0

318 lines not on this page · raw message

drivers/gpu/drm/drm_vram_mm_helper.c deleted +0 -309

309 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +0 -1
index c103005b0a33..4f52c83b9b4c 100644
@@ -22,7 +22,6 @@
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "hibmc_drm_drv.h"
 #include "hibmc_drm_regs.h"
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +0 -1
index 9f6e473e6295..5d52cd748603 100644
@@ -17,7 +17,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
 #include <drm/drm_print.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "hibmc_drm_drv.h"
 
drivers/gpu/drm/mgag200/mgag200_drv.h +0 -1
index 1c93f8dc08c7..37c003ed57c0 100644
@@ -19,7 +19,6 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
-#include <drm/drm_vram_mm_helper.h>
 
 #include "mgag200_reg.h"
 
drivers/gpu/drm/vboxvideo/vbox_drv.h +0 -2
index e8cb9efc6088..fb436ec760ea 100644
@@ -20,8 +20,6 @@
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_vram_helper.h>
 
-#include <drm/drm_vram_mm_helper.h>
-
 #include "vboxvideo_guest.h"
 #include "vboxvideo_vbe.h"
 #include "hgsmi_ch_setup.h"
include/drm/drm_gem_vram_helper.h +85 -0

98 lines not on this page · raw message

include/drm/drm_vram_mm_helper.h +0 -76

80 lines not on this page · raw message

Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#4 lore raw

PATCH 2/4 drm/vram: Have VRAM MM call GEM VRAM functions directly

In reply to Thomas Zimmermann

VRAM MM and GEM VRAM buffer objects are only used with each other; connected via 3 function pointers. Simplifiy this code by making the memory manager call the rsp. functions from the BOs directly; and remove the functions from he BO's public interface.

---
 drivers/gpu/drm/ast/ast_ttm.c               |   2 +-
 drivers/gpu/drm/bochs/bochs_mm.c            |   3 +-
 drivers/gpu/drm/drm_gem_vram_helper.c       | 119 ++++++--------------
 drivers/gpu/drm/drm_vram_helper_common.c    |   8 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |   2 +-
 drivers/gpu/drm/mgag200/mgag200_ttm.c       |   3 +-
 drivers/gpu/drm/vboxvideo/vbox_ttm.c        |   3 +-
 include/drm/drm_gem_vram_helper.h           |  24 +---
 include/drm/drm_vram_mm_helper.h            |  32 ------
 9 files changed, 44 insertions(+), 152 deletions(-)
 delete mode 100644 include/drm/drm_vram_mm_helper.h
drivers/gpu/drm/ast/ast_ttm.c +1 -1
index 08ba0a917593..fad34106083a 100644
@@ -41,7 +41,7 @@ int ast_mm_init(struct ast_private *ast)
 
 	vmm = drm_vram_helper_alloc_mm(
 		dev, pci_resource_start(dev->pdev, 0),
-		ast->vram_size, &drm_gem_vram_mm_funcs);
+		ast->vram_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
drivers/gpu/drm/bochs/bochs_mm.c +1 -2
index 8f9bb886f7ad..1b74f530b07c 100644
@@ -11,8 +11,7 @@ int bochs_mm_init(struct bochs_device *bochs)
 	struct drm_vram_mm *vmm;
 
 	vmm = drm_vram_helper_alloc_mm(bochs->dev, bochs->fb_base,
-				       bochs->fb_size,
-				       &drm_gem_vram_mm_funcs);
+				       bochs->fb_size);
 	return PTR_ERR_OR_ZERO(vmm);
 }
 
drivers/gpu/drm/drm_gem_vram_helper.c +34 -85

204 lines not on this page · raw message

drivers/gpu/drm/drm_vram_helper_common.c +3 -5
index e9c9f9a80ba3..2000d9b33fd5 100644
@@ -7,9 +7,8 @@
  *
  * This library provides &struct drm_gem_vram_object (GEM VRAM), a GEM
  * buffer object that is backed by video RAM. It can be used for
- * framebuffer devices with dedicated memory. The video RAM can be
- * managed with &struct drm_vram_mm (VRAM MM). Both data structures are
- * supposed to be used together, but can also be used individually.
+ * framebuffer devices with dedicated memory. The video RAM is managed
+ * by &struct drm_vram_mm (VRAM MM).
  *
  * With the GEM interface userspace applications create, manage and destroy
  * graphics buffers, such as an on-screen framebuffer. GEM does not provide
@@ -50,8 +49,7 @@
  *		// setup device, vram base and size
  *		// ...
  *
- *		ret = drm_vram_helper_alloc_mm(dev, vram_base, vram_size,
- *					       &drm_gem_vram_mm_funcs);
+ *		ret = drm_vram_helper_alloc_mm(dev, vram_base, vram_size);
  *		if (ret)
  *			return ret;
  *		return 0;
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +1 -1
index 5d52cd748603..21b684eab5c9 100644
@@ -28,7 +28,7 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc)
 
 	vmm = drm_vram_helper_alloc_mm(dev,
 				       pci_resource_start(dev->pdev, 0),
-				       hibmc->fb_size, &drm_gem_vram_mm_funcs);
+				       hibmc->fb_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
drivers/gpu/drm/mgag200/mgag200_ttm.c +1 -2
index 73a6b848601c..69c81ebf3745 100644
@@ -37,8 +37,7 @@ int mgag200_mm_init(struct mga_device *mdev)
 	struct drm_device *dev = mdev->dev;
 
 	vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
-				       mdev->mc.vram_size,
-				       &drm_gem_vram_mm_funcs);
+				       mdev->mc.vram_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
drivers/gpu/drm/vboxvideo/vbox_ttm.c +1 -2
index b82595a9ed0f..976423d0c3cc 100644
@@ -17,8 +17,7 @@ int vbox_mm_init(struct vbox_private *vbox)
 	struct drm_device *dev = &vbox->ddev;
 
 	vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
-				       vbox->available_vram_size,
-				       &drm_gem_vram_mm_funcs);
+				       vbox->available_vram_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
include/drm/drm_gem_vram_helper.h +2 -22
index af7450851c09..52e3f2aff490 100644
@@ -109,22 +109,6 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
 				  bool interruptible,
 				  struct drm_mode_create_dumb *args);
 
-/*
- * Helpers for struct ttm_bo_driver
- */
-
-void drm_gem_vram_bo_driver_evict_flags(struct ttm_buffer_object *bo,
-					struct ttm_placement *pl);
-
-void drm_gem_vram_bo_driver_move_notify(struct ttm_buffer_object *bo,
-					bool evict,
-					struct ttm_mem_reg *new_mem);
-
-int drm_gem_vram_bo_driver_verify_access(struct ttm_buffer_object *bo,
-					 struct file *filp);
-
-extern const struct drm_vram_mm_funcs drm_gem_vram_mm_funcs;
-
 /*
  * Helpers for struct drm_driver
  */
@@ -169,8 +153,6 @@ struct drm_vram_mm {
 	size_t vram_size;
 
 	struct ttm_bo_device bdev;
-
-	const struct drm_vram_mm_funcs *funcs;
 };
 
 /**
@@ -188,8 +170,7 @@ static inline struct drm_vram_mm *drm_vram_mm_of_bdev(
 }
 
 int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
-		     uint64_t vram_base, size_t vram_size,
-		     const struct drm_vram_mm_funcs *funcs);
+		     uint64_t vram_base, size_t vram_size);
 void drm_vram_mm_cleanup(struct drm_vram_mm *vmm);
 
 int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
@@ -200,8 +181,7 @@ int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma,
  */
 
 struct drm_vram_mm *drm_vram_helper_alloc_mm(
-	struct drm_device *dev, uint64_t vram_base, size_t vram_size,
-	const struct drm_vram_mm_funcs *funcs);
+	struct drm_device *dev, uint64_t vram_base, size_t vram_size);
 void drm_vram_helper_release_mm(struct drm_device *dev);
 
 /*
include/drm/drm_vram_mm_helper.h deleted +0 -32
deleted file mode 100644
index e3b79e13e106..000000000000
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#ifndef DRM_VRAM_MM_HELPER_H
-#define DRM_VRAM_MM_HELPER_H
-
-#include <drm/drm_file.h>
-#include <drm/drm_ioctl.h>
-#include <drm/ttm/ttm_bo_driver.h>
-
-struct drm_device;
-
-/**
- * struct drm_vram_mm_funcs - Callback functions for &struct drm_vram_mm
- * @evict_flags:	Provides an implementation for struct \
-	&ttm_bo_driver.evict_flags
- * @verify_access:	Provides an implementation for \
-	struct &ttm_bo_driver.verify_access
- * @move_notify:	Provides an implementation for
- *			struct &ttm_bo_driver.move_notify
- *
- * These callback function integrate VRAM MM with TTM buffer objects. New
- * functions can be added if necessary.
- */
-struct drm_vram_mm_funcs {
-	void (*evict_flags)(struct ttm_buffer_object *bo,
-			    struct ttm_placement *placement);
-	int (*verify_access)(struct ttm_buffer_object *bo, struct file *filp);
-	void (*move_notify)(struct ttm_buffer_object *bo, bool evict,
-			    struct ttm_mem_reg *new_mem);
-};
-
-#endif
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#7 lore raw

PATCH 4/4 drm/vram: Unconditonally set BO call-back functions

In reply to Thomas Zimmermann

The statement's condition is always true.

---
 drivers/gpu/drm/drm_gem_vram_helper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +1 -2
index 73e81e3a8724..13717ae65da5 100644
@@ -91,8 +91,7 @@ static int drm_gem_vram_init(struct drm_device *dev,
 	int ret;
 	size_t acc_size;
 
-	if (!gbo->bo.base.funcs)
-		gbo->bo.base.funcs = &drm_gem_vram_object_funcs;
+	gbo->bo.base.funcs = &drm_gem_vram_object_funcs;
 
 	ret = drm_gem_object_init(dev, &gbo->bo.base, size);
 	if (ret)
Signature · 6 lines
2.23.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on the v1 series
#8 lore raw
In reply to Thomas Zimmermann
Quoted 9 lines · Thomas Zimmermann

VRAM MM and GEM VRAM are only used with each other. This patch set moves VRAM MM into GEM VRAM source files and cleans up the helper's public interface.

Thomas Zimmermann (4):
drm/vram: Move VRAM memory manager to GEM VRAM implementation drm/vram: Have VRAM MM call GEM VRAM functions directly drm/vram: Unexport internal functions of VRAM MM drm/vram: Unconditonally set BO call-back functions

Looks all sane.

cheers,
Gerd