Initial Panfrost driver
Subsystems (5)
Rob Herring
maintainerv3 cover Initial Panfrost driver
Here's v3 of the panfrost driver. Lot's of changes from review comments and further testing. Details are in each patch. Of note, a problem with MMU page faults has been addressed improving the stability. In the process, the TLB invalidate has been optimized which Tomeu says has improved the performance some.
Several dependencies have been applied already, but the first 2 patches are the remaining dependencies. We need to take the iommu change via drm-misc or we need a stable branch.
I'm hoping this is the last version. I'm hoping to apply this to drm-misc this week before -rc5 cutoff.
A git branch is here[1].
Rob
[1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git panfrost-rebase-v3
Rob Herring (3):
iommu: io-pgtable: Add ARM Mali midgard MMU page table format
drm: Add a drm_gem_objects_lookup helper drm/panfrost: Add initial panfrost driver
MAINTAINERS | 9 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_gem.c | 93 ++- drivers/gpu/drm/panfrost/Kconfig | 14 + drivers/gpu/drm/panfrost/Makefile | 12 + drivers/gpu/drm/panfrost/TODO | 27 + drivers/gpu/drm/panfrost/panfrost_devfreq.c | 218 ++++++++ drivers/gpu/drm/panfrost/panfrost_devfreq.h | 14 + drivers/gpu/drm/panfrost/panfrost_device.c | 252 +++++++++ drivers/gpu/drm/panfrost/panfrost_device.h | 124 ++++ drivers/gpu/drm/panfrost/panfrost_drv.c | 460 +++++++++++++++ drivers/gpu/drm/panfrost/panfrost_features.h | 309 ++++++++++ drivers/gpu/drm/panfrost/panfrost_gem.c | 95 ++++ drivers/gpu/drm/panfrost/panfrost_gem.h | 29 + drivers/gpu/drm/panfrost/panfrost_gpu.c | 362 ++++++++++++ drivers/gpu/drm/panfrost/panfrost_gpu.h | 19 + drivers/gpu/drm/panfrost/panfrost_issues.h | 176 ++++++ drivers/gpu/drm/panfrost/panfrost_job.c | 560 +++++++++++++++++++ drivers/gpu/drm/panfrost/panfrost_job.h | 51 ++ drivers/gpu/drm/panfrost/panfrost_mmu.c | 369 ++++++++++++ drivers/gpu/drm/panfrost/panfrost_mmu.h | 17 + drivers/gpu/drm/panfrost/panfrost_regs.h | 298 ++++++++++ drivers/iommu/io-pgtable-arm.c | 91 ++- drivers/iommu/io-pgtable.c | 1 + include/drm/drm_gem.h | 2 + include/linux/io-pgtable.h | 7 + include/uapi/drm/panfrost_drm.h | 142 +++++ 28 files changed, 3722 insertions(+), 32 deletions(-) create mode 100644 drivers/gpu/drm/panfrost/Kconfig create mode 100644 drivers/gpu/drm/panfrost/Makefile create mode 100644 drivers/gpu/drm/panfrost/TODO create mode 100644 drivers/gpu/drm/panfrost/panfrost_devfreq.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_devfreq.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_device.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_device.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_drv.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_features.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_gem.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_gem.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_gpu.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_gpu.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_issues.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_job.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_job.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_mmu.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_mmu.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_regs.h create mode 100644 include/uapi/drm/panfrost_drm.h
--
2.19.1
Rob Herring
maintainerPATCH v3 1/3 iommu: io-pgtable: Add ARM Mali midgard MMU page table format
ARM Mali midgard GPU is similar to standard 64-bit stage 1 page tables, but have a few differences. Add a new format type to represent the format. The input address size is 48-bits and the output address size is 40-bits (and possibly less?). Note that the later bifrost GPUs follow the standard 64-bit stage 1 format.
The differences in the format compared to 64-bit stage 1 format are:
The 3rd level page entry bits are 0x1 instead of 0x3 for page entries.
The access flags are not read-only and unprivileged, but read and write. This is similar to stage 2 entries, but the memory attributes field matches stage 1 being an index.
The nG bit is not set by the vendor driver. This one didn't seem to matter, but we'll keep it aligned to the vendor driver.
---
This is really v4 of the patch. v3 is the series version.
Joerg, please ack so we can take this via the drm tree.
v3:
- Incorporated refactoring from Robin
drivers/iommu/io-pgtable-arm.c | 91 ++++++++++++++++++++++++++-------- drivers/iommu/io-pgtable.c | 1 + include/linux/io-pgtable.h | 7 +++ 3 files changed, 77 insertions(+), 22 deletions(-)
drivers/iommu/io-pgtable-arm.c +69 -22
@@ -172,6 +172,10 @@#define ARM_LPAE_MAIR_ATTR_IDX_CACHE 1#define ARM_LPAE_MAIR_ATTR_IDX_DEV 2 +#define ARM_MALI_LPAE_TTBR_ADRMODE_TABLE (3u << 0) +#define ARM_MALI_LPAE_TTBR_READ_INNER BIT(2) +#define ARM_MALI_LPAE_TTBR_SHARE_OUTER BIT(4) +/* IOPTE accessors */ #define iopte_deref (pte,d) __va(iopte_to_paddr(pte, d))
@@ -180,11 +184,6 @@#define iopte_prot (pte) ((pte) & ARM_LPAE_PTE_ATTR_MASK) -#define iopte_leaf (pte,l) \ - (l == (ARM_LPAE_MAX_LEVELS - 1) ? \ - (iopte_type(pte,l) == ARM_LPAE_PTE_TYPE_PAGE) : \ - (iopte_type(pte,l) == ARM_LPAE_PTE_TYPE_BLOCK)) -struct arm_lpae_io_pgtable {struct io_pgtable iop;
@@ -198,6 +197,15 @@ struct arm_lpae_io_pgtable {typedef u64 arm_lpae_iopte ; +static inline bool iopte_leaf (arm_lpae_iopte pte,int lvl, +enum io_pgtable_fmt fmt) +{ +if (lvl == (ARM_LPAE_MAX_LEVELS -1 ) && fmt !=ARM_MALI_LPAE ) +return iopte_type (pte, lvl) ==ARM_LPAE_PTE_TYPE_PAGE ; + +return iopte_type (pte, lvl) ==ARM_LPAE_PTE_TYPE_BLOCK ; +} +static arm_lpae_iopte paddr_to_iopte (phys_addr_t paddr,struct arm_lpae_io_pgtable *data) {
@@ -303,12 +311,14 @@ static void __arm_lpae_init_pte(struct arm_lpae_io_pgtable *data,if (data->iop.cfg.quirks &IO_PGTABLE_QUIRK_ARM_NS ) pte |=ARM_LPAE_PTE_NS ; -if (lvl ==ARM_LPAE_MAX_LEVELS -1 ) +if (data->iop.fmt !=ARM_MALI_LPAE && lvl ==ARM_LPAE_MAX_LEVELS -1 ) pte |=ARM_LPAE_PTE_TYPE_PAGE ;else pte |=ARM_LPAE_PTE_TYPE_BLOCK ; - pte |=ARM_LPAE_PTE_AF |ARM_LPAE_PTE_SH_IS ; +if (data->iop.fmt !=ARM_MALI_LPAE ) + pte |=ARM_LPAE_PTE_AF ; + pte |=ARM_LPAE_PTE_SH_IS ; pte |=paddr_to_iopte (paddr, data);__arm_lpae_set_pte (ptep, pte, &data->iop.cfg);
@@ -321,7 +331,7 @@ static int arm_lpae_init_pte(struct arm_lpae_io_pgtable *data, {arm_lpae_iopte pte = *ptep; -if (iopte_leaf (pte, lvl)) { +if (iopte_leaf (pte, lvl, data->iop.fmt)) {/* We require an unmap first */ WARN_ON (!selftest_running);return -EEXIST ;
@@ -409,7 +419,7 @@ static int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova,__arm_lpae_sync_pte (ptep, cfg); } -if (pte && !iopte_leaf (pte, lvl)) { +if (pte && !iopte_leaf (pte, lvl, data->iop.fmt)) { cptep =iopte_deref (pte, data); }else if (pte) {/* We require an unmap first */
@@ -429,31 +439,37 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data,if (data->iop.fmt ==ARM_64_LPAE_S1 || data->iop.fmt ==ARM_32_LPAE_S1 ) { pte = ARM_LPAE_PTE_nG; -if (!(prot &IOMMU_WRITE ) && (prot &IOMMU_READ )) pte |=ARM_LPAE_PTE_AP_RDONLY ; -if (!(prot &IOMMU_PRIV )) pte |=ARM_LPAE_PTE_AP_UNPRIV ; - -if (prot &IOMMU_MMIO ) - pte |= (ARM_LPAE_MAIR_ATTR_IDX_DEV - <<ARM_LPAE_PTE_ATTRINDX_SHIFT ); -else if (prot &IOMMU_CACHE ) - pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE - <<ARM_LPAE_PTE_ATTRINDX_SHIFT ); }else { pte =ARM_LPAE_PTE_HAP_FAULT ;if (prot &IOMMU_READ ) pte |=ARM_LPAE_PTE_HAP_READ ;if (prot &IOMMU_WRITE ) pte |=ARM_LPAE_PTE_HAP_WRITE ; + } + +/* +* Note that this logic is structured to accommodate Mali LPAE +* having stage-1-like attributes but stage-2-like permissions. +*/ +if (data->iop.fmt ==ARM_64_LPAE_S2 || + data->iop.fmt ==ARM_32_LPAE_S2 ) {if (prot &IOMMU_MMIO ) pte |=ARM_LPAE_PTE_MEMATTR_DEV ;else if (prot &IOMMU_CACHE ) pte |=ARM_LPAE_PTE_MEMATTR_OIWB ;else pte |=ARM_LPAE_PTE_MEMATTR_NC ; + }else { +if (prot &IOMMU_MMIO ) + pte |= (ARM_LPAE_MAIR_ATTR_IDX_DEV + <<ARM_LPAE_PTE_ATTRINDX_SHIFT ); +else if (prot &IOMMU_CACHE ) + pte |= (ARM_LPAE_MAIR_ATTR_IDX_CACHE + <<ARM_LPAE_PTE_ATTRINDX_SHIFT ); }if (prot &IOMMU_NOEXEC )
@@ -511,7 +527,7 @@ static void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl,while (ptep != end) {arm_lpae_iopte pte = *ptep++; -if (!pte ||iopte_leaf (pte, lvl)) +if (!pte ||iopte_leaf (pte, lvl, data->iop.fmt))continue ;__arm_lpae_free_pgtable (data, lvl +1 ,iopte_deref (pte, data));
@@ -602,7 +618,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,if (size ==ARM_LPAE_BLOCK_SIZE (lvl, data)) {__arm_lpae_set_pte (ptep,0 , &iop->cfg); -if (!iopte_leaf (pte, lvl)) { +if (!iopte_leaf (pte, lvl, iop->fmt)) {/* Also flush any partial walks */ io_pgtable_tlb_add_flush (iop, iova, size,ARM_LPAE_GRANULE (data), false);
@@ -621,7 +637,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, }return size; - }else if (iopte_leaf (pte, lvl)) { + }else if (iopte_leaf (pte, lvl, iop->fmt)) {/* * Insert a table at the next level to map the old region, * minus the part we want to unmap
@@ -669,7 +685,7 @@ static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,return 0 ;/* Leaf entry? */ -if (iopte_leaf (pte,lvl)) +if (iopte_leaf (pte, lvl, data->iop.fmt)) goto found_translation;/* Take it to the next level */
@@ -995,6 +1011,32 @@ arm_32_lpae_alloc_pgtable_s2(struct io_pgtable_cfg *cfg, void *cookie)return iop; } +static struct io_pgtable * +arm_mali_lpae_alloc_pgtable (struct io_pgtable_cfg *cfg,void *cookie) +{ +struct io_pgtable *iop; + +if (cfg->ias !=48 || cfg->oas >40 ) +return NULL ; + + cfg->pgsize_bitmap &= (SZ_4K |SZ_2M |SZ_1G ); + iop =arm_64_lpae_alloc_pgtable_s1 (cfg, cookie); +if (iop) { +u64 mair, ttbr; + +/* Copy values as union fields overlap */ + mair = cfg->arm_lpae_s1_cfg.mair[0 ]; + ttbr = cfg->arm_lpae_s1_cfg.ttbr[0 ]; + + cfg->arm_mali_lpae_cfg.memattr = mair; + cfg->arm_mali_lpae_cfg.transtab = ttbr | +ARM_MALI_LPAE_TTBR_READ_INNER | +ARM_MALI_LPAE_TTBR_ADRMODE_TABLE ; + } + +return iop; +} +struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s1_init_fns = { .alloc = arm_64_lpae_alloc_pgtable_s1, .free = arm_lpae_free_pgtable,
@@ -1015,6 +1057,11 @@ struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s2_init_fns = { .free = arm_lpae_free_pgtable, }; +struct io_pgtable_init_fns io_pgtable_arm_mali_lpae_init_fns = { + .alloc = arm_mali_lpae_alloc_pgtable, + .free = arm_lpae_free_pgtable, +}; +#ifdef CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST static struct io_pgtable_cfg *cfg_cookie;
drivers/iommu/io-pgtable.c +1 -0
@@ -30,6 +30,7 @@ io_pgtable_init_table[IO_PGTABLE_NUM_FMTS] = { [ARM_32_LPAE_S2] = &io_pgtable_arm_32_lpae_s2_init_fns, [ARM_64_LPAE_S1] = &io_pgtable_arm_64_lpae_s1_init_fns, [ARM_64_LPAE_S2] = &io_pgtable_arm_64_lpae_s2_init_fns, + [ARM_MALI_LPAE ] = &io_pgtable_arm_mali_lpae_init_fns, #endif #ifdef CONFIG_IOMMU_IO_PGTABLE_ARMV7S [ARM_V7S] = &io_pgtable_arm_v7s_init_fns,
include/linux/io-pgtable.h +7 -0
@@ -12,6 +12,7 @@ enum io_pgtable_fmt {ARM_64_LPAE_S1 ,ARM_64_LPAE_S2 ,ARM_V7S , +ARM_MALI_LPAE , IO_PGTABLE_NUM_FMTS, };
@@ -108,6 +109,11 @@ struct io_pgtable_cfg {u32 nmrr;u32 prrr; } arm_v7s_cfg; + +struct { +u64 transtab; +u64 memattr; + } arm_mali_lpae_cfg; }; };
@@ -209,5 +215,6 @@ extern struct io_pgtable_init_fns io_pgtable_arm_32_lpae_s2_init_fns;extern struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s1_init_fns;extern struct io_pgtable_init_fns io_pgtable_arm_64_lpae_s2_init_fns;extern struct io_pgtable_init_fns io_pgtable_arm_v7s_init_fns; +extern struct io_pgtable_init_fns io_pgtable_arm_mali_lpae_init_fns;#endif /* __IO_PGTABLE_H */
--
2.19.1
Rob Herring
maintainerPATCH v3 3/3 drm/panfrost: Add initial panfrost driver
In reply to Rob HerringThis adds the initial driver for panfrost which supports Arm Mali Midgard and Bifrost family of GPUs. Currently, only the T860 and T760 Midgard GPUs have been tested.
v2:
- Add GPU reset on job hangs (Tomeu)
- Add RuntimePM and devfreq support (Tomeu)
- Fix T760 support (Tomeu)
- Add a TODO file (Rob, Tomeu)
- Support multiple in fences (Tomeu)
- Drop support for shared fences (Tomeu)
- Fill in MMU de-init (Rob)
- Move register definitions back to single header (Rob)
- Clean-up hardcoded job submit todos (Rob)
- Implement feature setup based on features/issues (Rob)
- Add remaining Midgard DT compatible strings (Rob)
v3:
- Add support for reset lines (Neil)
- Add a MAINTAINERS entry (Rob)
- Call dma_set_mask_and_coherent (Rob)
- Do MMU invalidate on map and unmap. Restructure to do a single
operation per map/unmap call. (Rob)
- Add a missing explicit padding to struct drm_panfrost_create_bo (Rob)
- Fix 0-day error: "panfrost_devfreq.c:151:9-16: ERROR: PTR_ERR applied after initialization to constant on line 150"
- Drop HW_FEATURE_AARCH64_MMU conditional (Rob)
- s/DRM_PANFROST_PARAM_GPU_ID/DRM_PANFROST_PARAM_GPU_PROD_ID/ (Rob)
- Check drm_gem_shmem_prime_import_sg_table() error code (Rob)
- Re-order power on sequence (Rob)
- Move panfrost_acquire_object_fences() before scheduling job (Rob)
- Add NULL checks on array pointers in job clean-up (Rob)
- Rework devfreq (Tomeu)
- Fix devfreq init with no regulator (Rob)
- Various WS and comments clean-up (Rob)
--- MAINTAINERS | 9 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/panfrost/Kconfig | 14 + drivers/gpu/drm/panfrost/Makefile | 12 + drivers/gpu/drm/panfrost/TODO | 27 + drivers/gpu/drm/panfrost/panfrost_devfreq.c | 218 ++++++++ drivers/gpu/drm/panfrost/panfrost_devfreq.h | 14 + drivers/gpu/drm/panfrost/panfrost_device.c | 252 +++++++++ drivers/gpu/drm/panfrost/panfrost_device.h | 124 ++++ drivers/gpu/drm/panfrost/panfrost_drv.c | 460 +++++++++++++++ drivers/gpu/drm/panfrost/panfrost_features.h | 309 ++++++++++ drivers/gpu/drm/panfrost/panfrost_gem.c | 95 ++++ drivers/gpu/drm/panfrost/panfrost_gem.h | 29 + drivers/gpu/drm/panfrost/panfrost_gpu.c | 362 ++++++++++++ drivers/gpu/drm/panfrost/panfrost_gpu.h | 19 + drivers/gpu/drm/panfrost/panfrost_issues.h | 176 ++++++ drivers/gpu/drm/panfrost/panfrost_job.c | 560 +++++++++++++++++++ drivers/gpu/drm/panfrost/panfrost_job.h | 51 ++ drivers/gpu/drm/panfrost/panfrost_mmu.c | 369 ++++++++++++ drivers/gpu/drm/panfrost/panfrost_mmu.h | 17 + drivers/gpu/drm/panfrost/panfrost_regs.h | 298 ++++++++++ include/uapi/drm/panfrost_drm.h | 142 +++++ 23 files changed, 3560 insertions(+) create mode 100644 drivers/gpu/drm/panfrost/Kconfig create mode 100644 drivers/gpu/drm/panfrost/Makefile create mode 100644 drivers/gpu/drm/panfrost/TODO create mode 100644 drivers/gpu/drm/panfrost/panfrost_devfreq.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_devfreq.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_device.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_device.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_drv.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_features.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_gem.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_gem.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_gpu.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_gpu.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_issues.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_job.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_job.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_mmu.c create mode 100644 drivers/gpu/drm/panfrost/panfrost_mmu.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_regs.h create mode 100644 include/uapi/drm/panfrost_drm.h
MAINTAINERS +9 -0
@@ -1153,6 +1153,15 @@ F: drivers/gpu/drm/arm/ F: Documentation/devicetree/bindings/display/arm,malidp.txt F: Documentation/gpu/afbc.rst +ARM MALI PANFROST DRM DRIVER +M: Rob Herring <[email protected]> +M: Tomeu Vizoso <[email protected]> +L: [email protected] +S: Supported +T: git git://anongit.freedesktop.org/drm/drm-misc +F: drivers/gpu/drm/panfrost/ +F: include/uapi/drm/panfrost_drm.h + ARM MFM AND FLOPPY DRIVERS M: Ian Molton <[email protected]> S: Maintained
drivers/gpu/drm/Kconfig +2 -0
@@ -339,6 +339,8 @@ source "drivers/gpu/drm/vboxvideo/Kconfig" source "drivers/gpu/drm/lima/Kconfig" +source "drivers/gpu/drm/panfrost/Kconfig" + # Keep legacy drivers last menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
@@ -112,3 +112,4 @@ obj-$(CONFIG_DRM_TVE200) += tve200/ obj-$(CONFIG_DRM_XEN) += xen/ obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/ obj-$(CONFIG_DRM_LIMA) += lima/ +obj-$(CONFIG_DRM_PANFROST) += panfrost/
drivers/gpu/drm/panfrost/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 + +config DRM_PANFROST + tristate "Panfrost (DRM support for ARM Mali Midgard/Bifrost GPUs)" + depends on DRM + depends on ARM || ARM64 || COMPILE_TEST + depends on MMU + select DRM_SCHED + select IOMMU_SUPPORT + select IOMMU_IO_PGTABLE_LPAE + select DRM_GEM_SHMEM_HELPER + help + DRM driver for ARM Mali Midgard (T6xx, T7xx, T8xx) and + Bifrost (G3x, G5x, G7x) GPUs.
drivers/gpu/drm/panfrost/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0 + +panfrost-y := \ + panfrost_drv.o \ + panfrost_device.o \ + panfrost_devfreq.o \ + panfrost_gem.o \ + panfrost_gpu.o \ + panfrost_job.o \ + panfrost_mmu.o + +obj-$(CONFIG_DRM_PANFROST) += panfrost.o
drivers/gpu/drm/panfrost/TODO new file +27 -0
@@ -0,0 +1,27 @@ +- Thermal support. + +- Bifrost support: + - DT bindings (Neil, WIP) + - MMU page table format and address space setup + - Bifrost specific feature and issue handling + - Coherent DMA support + +- Support for 2MB pages. The io-pgtable code already supports this. Finishing + support involves either copying or adapting the iommu API to handle passing + aligned addresses and sizes to the io-pgtable code. + +- Per FD address space support. The h/w supports multiple addresses spaces. + The hard part is handling when more address spaces are needed than what + the h/w provides. + +- Support pinning pages on demand (GPU page faults). + +- Support userspace controlled GPU virtual addresses. Needed for Vulkan. (Tomeu) + +- Support for madvise and a shrinker. + +- Compute job support. So called 'compute only' jobs need to be plumbed up to + userspace. + +- Performance counter support. (Boris) +
drivers/gpu/drm/panfrost/panfrost_devfreq.c new file +218 -0
218 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_devfreq.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2019 Collabora ltd. */ + +#ifndef __PANFROST_DEVFREQ_H__ +#define __PANFROST_DEVFREQ_H__ + +int panfrost_devfreq_init (struct panfrost_device *pfdev); + +void panfrost_devfreq_resume (struct panfrost_device *pfdev); +void panfrost_devfreq_suspend (struct panfrost_device *pfdev); + +void panfrost_devfreq_record_transition (struct panfrost_device *pfdev,int slot); + +#endif /* __PANFROST_DEVFREQ_H__ */
drivers/gpu/drm/panfrost/panfrost_device.c new file +252 -0
252 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_device.h new file +124 -0
124 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_drv.c new file +460 -0
460 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_features.h new file +309 -0
309 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_gem.c new file +95 -0
95 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_gem.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2019 Linaro, Ltd, Rob Herring <[email protected]> */ + +#ifndef __PANFROST_GEM_H__ +#define __PANFROST_GEM_H__ + +#include <drm/drm_gem_shmem_helper.h> +#include <drm/drm_mm.h> + +struct panfrost_gem_object { +struct drm_gem_shmem_object base; + +struct drm_mm_node node; +}; + +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); +} + +struct drm_gem_object *panfrost_gem_create_object (struct drm_device *dev,size_t size); + +struct drm_gem_object * +panfrost_gem_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sgt); + +#endif /* __PANFROST_GEM_H__ */
drivers/gpu/drm/panfrost/panfrost_gpu.c new file +362 -0
362 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_gpu.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2018 Marty E. Plummer <[email protected]> */ +/* Copyright 2019 Collabora ltd. */ + +#ifndef __PANFROST_GPU_H__ +#define __PANFROST_GPU_H__ + +struct panfrost_device ; + +int panfrost_gpu_init (struct panfrost_device *pfdev); +void panfrost_gpu_fini (struct panfrost_device *pfdev); + +u32 panfrost_gpu_get_latest_flush_id (struct panfrost_device *pfdev); + +int panfrost_gpu_soft_reset (struct panfrost_device *pfdev); +void panfrost_gpu_power_on (struct panfrost_device *pfdev); +void panfrost_gpu_power_off (struct panfrost_device *pfdev); + +#endif
drivers/gpu/drm/panfrost/panfrost_issues.h new file +176 -0
176 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_job.c new file +560 -0
560 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_job.h new file +51 -0
51 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_mmu.c new file +369 -0
251 lines not on this page · raw message
drivers/gpu/drm/panfrost/panfrost_mmu.h new file +17 -0
Lines of this file are not shown. View the raw message.
drivers/gpu/drm/panfrost/panfrost_regs.h new file +298 -0
298 lines not on this page · raw message
include/uapi/drm/panfrost_drm.h new file +142 -0
142 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.19.1
Part of the diff is not shown here. View the raw message.
Rob Herring
maintainerPATCH v3 2/3 drm: Add a drm_gem_objects_lookup helper
In reply to Rob HerringSimilar to the single handle drm_gem_object_lookup(), drm_gem_objects_lookup() takes an array of handles and returns an array of GEM objects.
v2:
- Take the userspace pointer directly and allocate the array.
- Expand the function documentation.
--- drivers/gpu/drm/drm_gem.c | 93 ++++++++++++++++++++++++++++++++++----- include/drm/drm_gem.h | 2 + 2 files changed, 85 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_gem.c +83 -10
@@ -663,6 +663,85 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, }EXPORT_SYMBOL (drm_gem_put_pages); +static int objects_lookup (struct drm_file *filp,u32 *handle,int count, +struct drm_gem_object **objs) +{ +int i, ret =0 ; +struct drm_gem_object *obj; + +spin_lock (&filp->table_lock); + +for (i =0 ; i < count; i++) { +/* Check if we currently have a reference on the object */ + obj =idr_find (&filp->object_idr, handle[i]); +if (!obj) { + ret = -ENOENT ; +break ; + } +drm_gem_object_get (obj); + objs[i] = obj; + } +spin_unlock (&filp->table_lock); + +return ret; +} + +/** +* drm_gem_objects_lookup - look up GEM objects from an array of handles +* @filp: DRM file private date +* @bo_handles: user pointer to array of userspace handle +* @count: size of handle array +* @objs_out: returned pointer to array of drm_gem_object pointers +* +* Takes an array of userspace handles and returns a newly allocated array of +* GEM objects. +* +* For a single handle lookup, use drm_gem_object_lookup(). +* +* Returns: +* +* @objs filled in with GEM object pointers. Returned GEM objects need to be +* released with drm_gem_object_put(). -ENOENT is returned on a lookup +* failure. 0 is returned on success. +* +*/ +int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out) +{ +int ret; +u32 *handles; +struct drm_gem_object **objs; + +if (!count) +return 0 ; + + objs =kvmalloc_array (count,sizeof (struct drm_gem_object *), +GFP_KERNEL | __GFP_ZERO); +if (!objs) +return -ENOMEM ; + + handles =kvmalloc_array (count,sizeof (u32),GFP_KERNEL ); +if (!handles) { + ret = -ENOMEM ; + goto out; + } + +if (copy_from_user (handles, bo_handles, count *sizeof (u32))) { + ret = -EFAULT ; +DRM_DEBUG ("Failed to copy in GEM handles\n" ); + goto out; + } + + ret =objects_lookup (filp, handles, count, objs); + *objs_out = objs; + +out: +kvfree (handles); +return ret; + +} +EXPORT_SYMBOL (drm_gem_objects_lookup); +/** * drm_gem_object_lookup - look up a GEM object from its handle * @filp: DRM file private date
@@ -672,21 +751,15 @@ EXPORT_SYMBOL(drm_gem_put_pages);* * A reference to the object named by the handle if such exists on @filp, NULL * otherwise. +* +* If looking up an array of handles, use drm_gem_objects_lookup(). */ struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle) { -struct drm_gem_object *obj; - -spin_lock (&filp->table_lock); - -/* Check if we currently have a reference on the object */ - obj =idr_find (&filp->object_idr, handle); -if (obj) -drm_gem_object_get (obj); - -spin_unlock (&filp->table_lock); +struct drm_gem_object *obj =NULL ; +objects_lookup (filp, &handle,1 , &obj);return obj; }EXPORT_SYMBOL (drm_gem_object_lookup);
include/drm/drm_gem.h +2 -0
@@ -381,6 +381,8 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj);void drm_gem_put_pages (struct drm_gem_object *obj,struct page **pages,bool dirty,bool accessed); +int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out);struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle);long drm_gem_reservation_object_wait (struct drm_file *filep,u32 handle,bool wait_all,unsigned long timeout);
--
2.19.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/3] drm/panfrost: Add initial panfrost driver
In reply to Rob Herringdrivers/gpu/drm/panfrost/panfrost_drv.c line 273
Quoted 11 lines · Rob Herring
This adds the initial driver for panfrost which supports Arm Mali Midgard and Bifrost family of GPUs. Currently, only the T860 and T760 Midgard GPUs have been tested.
drivers/gpu/drm/panfrost/panfrost_drv.c new file +7
-0+static int panfrost_ioctl_get_bo_offset (struct drm_device *dev,void *data, +struct drm_file *file_priv) +{ +struct drm_panfrost_get_bo_offset *args = data; +struct drm_gem_object *gem_obj; +struct panfrost_gem_object *bo; +
Missing check for pad == 0. With that fixed,
Quoted 17 lines
drivers/gpu/drm/panfrost/panfrost_job.c new file +15
-0+ gem_obj =drm_gem_object_lookup (file_priv, args->handle); +if (!gem_obj) { +DRM_DEBUG ("Failed to look up GEM BO %d\n" , args->handle); +return -ENOENT ; + } + bo =to_panfrost_bo (gem_obj); + + args->offset = bo->node.start <<PAGE_SHIFT ; + +drm_gem_object_put_unlocked (gem_obj); +return 0 ; +} +static void panfrost_job_timedout (struct drm_sched_job *sched_job) +{ +struct panfrost_job *job =to_panfrost_job (sched_job);
drivers/gpu/drm/panfrost/panfrost_job.c line 378
Quoted 10 lines
drivers/gpu/drm/panfrost/panfrost_job.c new file +10
-0+struct panfrost_device *pfdev = job->pfdev; +int js =panfrost_job_get_slot (job); +int i; + +/* +* If the GPU managed to complete this jobs fence, the timeout is +* spurious. Bail out. +*/ +if (dma_fence_is_signaled (job->done_fence)) +return ;
Note: The scheduler calls cancel_delayed_work_sync() in s_job->finish_work, so this is just reducing the race for the job successfully completing near the timeout but finish_work being in the workqueue across the timeout boundary. I dropped it from v3d.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/3] drm/panfrost: Add initial panfrost driver
Quoted 17 lines · Eric Anholt
[ Unknown signature status ]
drivers/gpu/drm/panfrost/panfrost_drv.c line 273
Quoted 11 lines · Rob Herring
This adds the initial driver for panfrost which supports Arm Mali Midgard and Bifrost family of GPUs. Currently, only the T860 and T760 Midgard GPUs have been tested.
drivers/gpu/drm/panfrost/panfrost_drv.c new file +7
-0+static int panfrost_ioctl_get_bo_offset (struct drm_device *dev,void *data, +struct drm_file *file_priv) +{ +struct drm_panfrost_get_bo_offset *args = data; +struct drm_gem_object *gem_obj; +struct panfrost_gem_object *bo; +Missing check for pad == 0. With that fixed,
Quoted 1 line
Reviewed-by Eric Anholt <[email protected]>
I suppose you could also drop both flags and pad from uapi, since both of them must be 0 filled and you could just add a new flags at the end of the create struct if you ever need one.
Re: [PATCH v3 3/3] drm/panfrost: Add initial panfrost driver
In reply to Rob HerringQuoted 47 lines · Rob Herring
This adds the initial driver for panfrost which supports Arm Mali Midgard and Bifrost family of GPUs. Currently, only the T860 and T760 Midgard GPUs have been tested.
v2:
- Add GPU reset on job hangs (Tomeu)
- Add RuntimePM and devfreq support (Tomeu)
- Fix T760 support (Tomeu)
- Add a TODO file (Rob, Tomeu)
- Support multiple in fences (Tomeu)
- Drop support for shared fences (Tomeu)
- Fill in MMU de-init (Rob)
- Move register definitions back to single header (Rob)
- Clean-up hardcoded job submit todos (Rob)
- Implement feature setup based on features/issues (Rob)
- Add remaining Midgard DT compatible strings (Rob)v3:
- Add support for reset lines (Neil)
- Add aMAINTAINERSentry (Rob)
- Calldma_set_mask_and_coherent(Rob)
- Do MMU invalidate on map and unmap. Restructure to do a single
operation per map/unmap call. (Rob)
- Add a missing explicit padding to structdrm_panfrost_create_bo(Rob)
- Fix 0-day error: "panfrost_devfreq.c:151:9-16: ERROR:PTR_ERRapplied after initialization to constant on line 150"
- DropHW_FEATURE_AARCH64_MMUconditional (Rob)
- s/DRM_PANFROST_PARAM_GPU_ID/DRM_PANFROST_PARAM_GPU_PROD_ID/ (Rob)
- Checkdrm_gem_shmem_prime_import_sg_table()error code (Rob)
- Re-order power on sequence (Rob)
- Movepanfrost_acquire_object_fences()before scheduling job (Rob)
- Add NULL checks on array pointers in job clean-up (Rob)
- Rework devfreq (Tomeu)
- Fix devfreq init with no regulator (Rob)
- Various WS and comments clean-up (Rob)Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Lyude Paul <[email protected]>Reviewed-by Alyssa Rosenzweig <[email protected]>Reviewed-by Eric Anholt <[email protected]>Signed-off-by Marty E. Plummer <[email protected]>Signed-off-by Tomeu Vizoso <[email protected]>Signed-off-by Neil Armstrong <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 1 line
---
This looks like it has addressed my comments, so:
There's a couple of nits below if you do respin, but these shouldn't block merging the driver.
[...]
drivers/gpu/drm/panfrost/panfrost_drv.c line 178
Quoted 10 lines
drivers/gpu/drm/panfrost/panfrost_drv.c new file +10
-0+static int panfrost_ioctl_submit (struct drm_device *dev,void *data, +struct drm_file *file) +{ +struct panfrost_device *pfdev = dev->dev_private; +struct drm_panfrost_submit *args = data; +struct drm_syncobj *sync_out; +struct panfrost_job *job; +int ret =0 ; + + job =kcalloc (1 ,sizeof (*job),GFP_KERNEL );
Why not simply kzalloc()? I think you're going to want a new ioctl if/when adding support for multiple job submissions in one ioctl.
[...]
Quoted 5 lines
drivers/gpu/drm/panfrost/panfrost_drv.c new file +5
-0+static int panfrost_probe (struct platform_device *pdev) +{ +struct panfrost_device *pfdev; +struct drm_device *ddev; +int err;
drivers/gpu/drm/panfrost/panfrost_drv.c line 366
Quoted 10 lines
drivers/gpu/drm/panfrost/panfrost_drv.c new file +10
-0+ + pfdev =devm_kzalloc (&pdev->dev,sizeof (*pfdev),GFP_KERNEL ); +if (!pfdev) +return -ENOMEM ; + + pfdev->pdev = pdev; + pfdev->dev = &pdev->dev; + +platform_set_drvdata (pdev, pfdev); +dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (40 ));
The hardware reports the correct mask, from kbase:
Quoted 9 lines
err = dma_set_mask(kbdev->dev, DMA_BIT_MASK(kbdev->gpu_props.mmu.pa_bits)); if (err) goto dma_set_mask_failed; err = dma_set_coherent_mask(kbdev->dev, DMA_BIT_MASK(kbdev->gpu_props.mmu.pa_bits)); if (err) goto dma_set_mask_failed;
Although I'm not sure if it has ever varied.
Thanks,
Steve
Re: [PATCH v3 2/3] drm: Add a drm_gem_objects_lookup helper
In reply to Rob HerringQuoted 156 lines · Rob Herring
Similar to the single handle
drm_gem_object_lookup(),drm_gem_objects_lookup()takes an array of handles and returns an array of GEM objects.v2:
- Take the userspace pointer directly and allocate the array.
- Expand the function documentation.Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/gpu/drm/drm_gem.c | 93 ++++++++++++++++++++++++++++++++++----- include/drm/drm_gem.h | 2 + 2 files changed, 85 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_gem.c +83
-10@@ -663,6 +663,85 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, }EXPORT_SYMBOL (drm_gem_put_pages); +static int objects_lookup (struct drm_file *filp,u32 *handle,int count, +struct drm_gem_object **objs) +{ +int i, ret =0 ; +struct drm_gem_object *obj; + +spin_lock (&filp->table_lock); + +for (i =0 ; i < count; i++) { +/* Check if we currently have a reference on the object */ + obj =idr_find (&filp->object_idr, handle[i]); +if (!obj) { + ret = -ENOENT ; +break ; + } +drm_gem_object_get (obj); + objs[i] = obj; + } +spin_unlock (&filp->table_lock); + +return ret; +} + +/** +* drm_gem_objects_lookup - look up GEM objects from an array of handles +* @filp: DRM file private date +* @bo_handles: user pointer to array of userspace handle +* @count: size of handle array +* @objs_out: returned pointer to array of drm_gem_object pointers +* +* Takes an array of userspace handles and returns a newly allocated array of +* GEM objects. +* +* For a single handle lookup, use drm_gem_object_lookup(). +* +* Returns: +* +* @objs filled in with GEM object pointers. Returned GEM objects need to be +* released with drm_gem_object_put(). -ENOENT is returned on a lookup +* failure. 0 is returned on success. +* +*/ +int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out) +{ +int ret; +u32 *handles; +struct drm_gem_object **objs; + +if (!count) +return 0 ; + + objs =kvmalloc_array (count,sizeof (struct drm_gem_object *), +GFP_KERNEL | __GFP_ZERO); +if (!objs) +return -ENOMEM ; + + handles =kvmalloc_array (count,sizeof (u32),GFP_KERNEL ); +if (!handles) { + ret = -ENOMEM ; + goto out; + } + +if (copy_from_user (handles, bo_handles, count *sizeof (u32))) { + ret = -EFAULT ; +DRM_DEBUG ("Failed to copy in GEM handles\n" ); + goto out; + } + + ret =objects_lookup (filp, handles, count, objs); + *objs_out = objs; + +out: +kvfree (handles); +return ret; + +} +EXPORT_SYMBOL (drm_gem_objects_lookup); +/** * drm_gem_object_lookup - look up a GEM object from its handle * @filp: DRM file private date @@ -672,21 +751,15 @@ EXPORT_SYMBOL(drm_gem_put_pages);* * A reference to the object named by the handle if such exists on @filp, NULL * otherwise. +* +* If looking up an array of handles, use drm_gem_objects_lookup(). */ struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle) { -struct drm_gem_object *obj; - -spin_lock (&filp->table_lock); - -/* Check if we currently have a reference on the object */ - obj =idr_find (&filp->object_idr, handle); -if (obj) -drm_gem_object_get (obj); - -spin_unlock (&filp->table_lock); +struct drm_gem_object *obj =NULL ; +objects_lookup (filp, &handle,1 , &obj);return obj; }EXPORT_SYMBOL (drm_gem_object_lookup);include/drm/drm_gem.h +2
-1@@ -381,6 +381,8 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj);void drm_gem_put_pages (struct drm_gem_object *obj,struct page **pages,bool dirty,bool accessed); +int drm_gem_objects_lookup (struct drm_file *filp,void __user *bo_handles, +int count,struct drm_gem_object ***objs_out);struct drm_gem_object *drm_gem_object_lookup (struct drm_file *filp,u32 handle);long drm_gem_reservation_object_wait (struct drm_file *filep,u32 handle,bool wait_all,unsigned long timeout); --2.19.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel