RFC Per-instance pagetables for MSM GPUs
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest14 patches 8 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/14 | iommu: Add DOMAIN_ATTR_ENABLE_TTBR1include/ | +1 | 1 reply | |
| 2/14 | iommu/arm-smmu: Add support for TTBR1drivers/ drivers/ drivers/ +2 more | +192 | 2 replies | |
| 3/14 | iommu: Create a base struct for io_mmdrivers/ drivers/ include/ | +47 | 2 replies | |
| 4/14 | iommu: sva: Add support for pasid allocationdrivers/ drivers/ include/ | +297 | 2 replies | |
| 5/14 | iommu: arm-smmu: Add pasid implementationdrivers/ | +143 | 0 replies | |
| 6/14 | iommu: arm-smmu: Add side-band function to specific pasid callbacksdrivers/ include/ | +58 | 0 replies | |
| 7/14 | drm/msm: Enable 64 bit mode by defaultdrivers/ drivers/ | +15 | 0 replies | |
| 8/14 | drm/msm: Pass the MMU domain index in struct msm_file_privatedrivers/ drivers/ drivers/ +2 more | +16 | 0 replies | |
| 9/14 | drm/msm/gpu: Support using TTBR1 for kernel buffer objectsdrivers/ drivers/ | +20 | 0 replies | |
| 10/14 | drm/msm: Add msm_mmu featuresdrivers/ | +13 | 0 replies | |
| 11/14 | drm/msm: Add support for iommu-sva PASIDsdrivers/ drivers/ | +190 | 1 reply | |
| 12/14 | drm/msm: Add support for per-instance address spacesdrivers/ drivers/ | +34 | 0 replies | |
| 13/14 | drm/msm: Support per-instance address spacesdrivers/ | +28 | 0 replies | |
| 14/14 | drm/msm/a5xx: Support per-instance pagetablesdrivers/ drivers/ drivers/ +3 more | +152 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC 00/14] Per-instance pagetables for MSM GPUs
This is a request for comment for support in the iommu, arm-smmu and MSM GPU driver to support per (GPU) instance pagetables.
The general idea behind per-instance pagetables is that each GPU client can have its own pagetable and virtual memory space which prevents malicious or accidental corruption or copying. We say per-instance because the pagetables are unique to each DRM file handle and there could be multiple instances per process.
In newer arm-smmu implementations this behavior could be managed with hardware based PASIDs (see Jean Phillipe's epic SVA stack https://patchwork.kernel.org/patch/10214963/)
but all the MSM GPU implementations in existence use arm-smmu-v2 which doesn't have the ability to support switching pagetables in hardware. As a result the vendor has added a bit of hardware specific glue to allow the GPU microcode to switch the pagetable asynchronously during execution (basically it reaches out and reprograms some of the context bank registers).
To support all of this we need a handful of changes to allow the client driver to create a properly formatted pagetable and directly map and unmap buffers inside of that pagetable and get the parameters (i.e. the physical address of the pagetable) to program into the GPU at the appropriate time.
This stack builds on the aforementioned code from Jean-Phillipe to add the needed support to iommu core and arm-smmu and then implement per-instance pagetables in the MSM DRM GPU driver for the a5xx family (tested on the db820c).
The first two patches add support to create enable a TTBR1 pagetable for arm-smmuv-2 if the appropriate domain attribute is selected. It creates a pagetable and programs the appropriate registers to enable TTBR1. The sign extension bit is programmed as the highest bit in the ibs region (or the special 48th bit when the UBS is 49 bits). The correct pagetable is automatically selected for map/unmap based on the sign extension bit.
The next three patches add "virtual" pasid support. This allows a client to allocate a pasid which is an index to a pagetable structure. The pasid token is used to map and unmap entries in that pagetable structure. The existing pasid idr for SVA is reused so that clients that also support hardware PASID entries can use both types if they wish.
Th next patch adds a special side-band function for arm-smmu that registers two callbacks to inform the client driver when a new pasid is created/destroyed. This allows the arm-smmu driver to pass the pagetable information (ttbr and asid) to the client without needing changes to the IOMMU core.
All the following patches are for the DRM/GPU driver. The first enables 64 bit mode for a5xx which lets us use all 48 bits. The next patch 5 patches are infrastructure patches to cleanup address spaces and prepare for having a per-instance address space and the final patch enables per-instance pagetables for a5xx and implements the PM4 to switch the pagetable at create time.
Please know that nearly all of this is up for discussion. In particular since we all know that the two hardest problems in computer science are caches, naming and off-by-one errors I am open to fixing the vocabulary and terminology for "pasid" and "per-instance" and whatever - please paint that bikeshed if you feel so inclined. Thanks for reading this far. On with the code.
Applies against git://linux-arm.org/linux-jpb.git sva/v1
Jordan Crouse (14):
iommu: Add DOMAIN_ATTR_ENABLE_TTBR1
iommu/arm-smmu: Add support for TTBR1
iommu: Create a base struct for io_mm
iommu: sva: Add support for pasid allocation
iommu: arm-smmu: Add pasid implementation
iommu: arm-smmu: Add side-band function to specific pasid callbacks drm/msm: Enable 64 bit mode by default
drm/msm: Pass the MMU domain index in struct msm_file_private drm/msm/gpu: Support using TTBR1 for kernel buffer objects drm/msm: Add msm_mmu features
drm/msm: Add support for iommu-sva PASIDs
drm/msm: Add support for per-instance address spaces drm/msm: Support per-instance address spaces drm/msm/a5xx: Support per-instance pagetables
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 69 +++++++ drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 17 ++ drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 76 ++++++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 ++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 5 + drivers/gpu/drm/msm/msm_drv.c | 45 +++-- drivers/gpu/drm/msm/msm_drv.h | 4 + drivers/gpu/drm/msm/msm_gem.h | 1 + drivers/gpu/drm/msm/msm_gem_submit.c | 13 +- drivers/gpu/drm/msm/msm_gem_vma.c | 36 +++- drivers/gpu/drm/msm/msm_gpu.c | 25 ++- drivers/gpu/drm/msm/msm_gpu.h | 4 +- drivers/gpu/drm/msm/msm_iommu.c | 186 ++++++++++++++++++- drivers/gpu/drm/msm/msm_mmu.h | 19 ++ drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + drivers/iommu/arm-smmu-regs.h | 2 - drivers/iommu/arm-smmu-v3.c | 8 +- drivers/iommu/arm-smmu.c | 210 +++++++++++++++++++++- drivers/iommu/io-pgtable-arm.c | 160 +++++++++++++++-- drivers/iommu/io-pgtable-arm.h | 20 +++ drivers/iommu/io-pgtable.h | 16 +- drivers/iommu/iommu-sva.c | 289 ++++++++++++++++++++++++++++-- drivers/iommu/iommu.c | 3 +- include/linux/arm-smmu.h | 18 ++ include/linux/iommu.h | 68 ++++++- 25 files changed, 1205 insertions(+), 101 deletions(-) create mode 100644 include/linux/arm-smmu.h
Signature · 6 lines
2.16.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno