drm/imagination: Add GEM and VM related code
Subsystems (3)
PATCH v4 8/17 drm/imagination: Add GEM and VM related code
Add a GEM implementation based on drm_gem_shmem, and support code for the PowerVR GPU MMU. The GPU VA manager is used for address space management.
This patch depends on :maple_tree: split up MA_STATE() macro:
https://lore.kernel.org/dri-devel/[email protected]/
drm: manager to keep track of GPUs VA mappings:
https://lore.kernel.org/dri-devel/[email protected]/
Changes since v3:
- Split MMU and VM code
- Register page table allocations with kmemleak
- Use drm_dev_{enter,exit}
Changes since v2:
- Use GPU VA manager
- Use drm_gem_shmem
--- drivers/gpu/drm/imagination/Makefile | 3 + drivers/gpu/drm/imagination/pvr_device.c | 19 +- drivers/gpu/drm/imagination/pvr_device.h | 18 + drivers/gpu/drm/imagination/pvr_drv.c | 314 ++- drivers/gpu/drm/imagination/pvr_gem.c | 388 ++++ drivers/gpu/drm/imagination/pvr_gem.h | 185 ++ drivers/gpu/drm/imagination/pvr_mmu.c | 2395 ++++++++++++++++++++++ drivers/gpu/drm/imagination/pvr_mmu.h | 103 + drivers/gpu/drm/imagination/pvr_vm.c | 931 +++++++++ drivers/gpu/drm/imagination/pvr_vm.h | 60 + 10 files changed, 4406 insertions(+), 10 deletions(-) create mode 100644 drivers/gpu/drm/imagination/pvr_gem.c create mode 100644 drivers/gpu/drm/imagination/pvr_gem.h create mode 100644 drivers/gpu/drm/imagination/pvr_mmu.c create mode 100644 drivers/gpu/drm/imagination/pvr_mmu.h create mode 100644 drivers/gpu/drm/imagination/pvr_vm.c create mode 100644 drivers/gpu/drm/imagination/pvr_vm.h
drivers/gpu/drm/imagination/Makefile +3 -0
@@ -7,5 +7,8 @@ powervr-y := \ pvr_device.o \ pvr_device_info.o \ pvr_drv.o \ + pvr_gem.o \ + pvr_mmu.o \ + pvr_vm.o obj-$(CONFIG_DRM_POWERVR) += powervr.o
drivers/gpu/drm/imagination/pvr_device.c +18 -1
@@ -6,6 +6,7 @@#include "pvr_fw.h" #include "pvr_rogue_cr_defs.h" +#include "pvr_vm.h" #include <drm/drm_print.h>
@@ -309,7 +310,21 @@ pvr_device_gpu_init(struct pvr_device *pvr_dev)if (err)return err; -return pvr_request_firmware (pvr_dev); + pvr_dev->kernel_vm_ctx =pvr_vm_create_context (pvr_dev, false); +if (IS_ERR (pvr_dev->kernel_vm_ctx)) +return PTR_ERR (pvr_dev->kernel_vm_ctx); + + err =pvr_request_firmware (pvr_dev); +if (err) + goto err_vm_ctx_put; + +return 0 ; + +err_vm_ctx_put: +pvr_vm_context_put (pvr_dev->kernel_vm_ctx); + pvr_dev->kernel_vm_ctx =NULL ; + +return err; }/**
@@ -320,6 +335,8 @@ static void pvr_device_gpu_fini(struct pvr_device *pvr_dev) {release_firmware (pvr_dev->fw_dev.firmware); +WARN_ON (!pvr_vm_context_put (pvr_dev->kernel_vm_ctx)); + pvr_dev->kernel_vm_ctx =NULL ; }/**
drivers/gpu/drm/imagination/pvr_device.h +18 -0
@@ -123,6 +123,16 @@ struct pvr_device {*/ struct clk *mem_clk; +/** +* @kernel_vm_ctx: Virtual memory context used for kernel mappings. +* +* This is used for mappings in the firmware address region when a META firmware processor +* is in use. +* +* When a MIPS firmware processor is in use, this will be %NULL. +*/ +struct pvr_vm_context *kernel_vm_ctx; +/** @fw_dev: Firmware related data. */ struct pvr_fw_device fw_dev; };
@@ -145,6 +155,14 @@ struct pvr_file {* to_pvr_device(). */ struct pvr_device *pvr_dev; + +/** +* @vm_ctx_handles: Array of VM contexts belonging to this file. Array +* members are of type "struct pvr_vm_context *". +* +* This array is used to allocate handles returned to userspace. +*/ +struct xarray vm_ctx_handles; };/**
drivers/gpu/drm/imagination/pvr_drv.c +305 -9
391 lines not on this page · raw message
drivers/gpu/drm/imagination/pvr_gem.c new file +388 -0
388 lines not on this page · raw message
drivers/gpu/drm/imagination/pvr_gem.h new file +185 -0
185 lines not on this page · raw message
drivers/gpu/drm/imagination/pvr_mmu.c new file +2395 -0
1,961 lines not on this page · raw message
drivers/gpu/drm/imagination/pvr_mmu.h new file +103 -0
103 lines not on this page · raw message
drivers/gpu/drm/imagination/pvr_vm.c new file +931 -0
931 lines not on this page · raw message
drivers/gpu/drm/imagination/pvr_vm.h new file +60 -0
60 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.41.0
Part of the diff is not shown here. View the raw message.