Merge VRAM MM and GEM VRAM source files
Subsystems (8)
Thomas Zimmermann
maintainercover 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
Thomas Zimmermann
maintainerPATCH 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Thomas Zimmermann
maintainerPATCH 2/4 drm/vram: Have VRAM MM call GEM VRAM functions directly
In reply to Thomas ZimmermannVRAM 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Thomas Zimmermann
maintainerPATCH 3/4 drm/vram: Unexport internal functions of VRAM MM
In reply to Thomas ZimmermannThe 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
@@ -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
@@ -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
Thomas Zimmermann
maintainerPATCH 4/4 drm/vram: Unconditonally set BO call-back functions
In reply to Thomas ZimmermannThe 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
@@ -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
Thomas Zimmermann
maintainerPATCH 1/4 drm/vram: Move VRAM memory manager to GEM VRAM implementation
In reply to Thomas ZimmermannThe 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Thomas Zimmermann
maintainerPATCH 2/4 drm/vram: Have VRAM MM call GEM VRAM functions directly
In reply to Thomas ZimmermannVRAM 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Thomas Zimmermann
maintainerPATCH 4/4 drm/vram: Unconditonally set BO call-back functions
In reply to Thomas ZimmermannThe 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
@@ -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
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