From ac2b8a2c228911aa909c6deda85c4d24522a68d1 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Tue, 7 Jul 2020 17:52:44 -0700 Subject: [PATCH 1/4] defconfig: Enable CONFIG_ARM_SMMU for sdxlemur Enable the ARM smmu driver, and its associated debugfs. Change-Id: I6249b155a02299d6e5e3b6da807d7936c5f89736 Signed-off-by: Patrick Daly --- arch/arm/configs/vendor/sdxlemur-debug.config | 3 +++ arch/arm/configs/vendor/sdxlemur.config | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/arm/configs/vendor/sdxlemur-debug.config b/arch/arm/configs/vendor/sdxlemur-debug.config index e643d47b3e3f..b13509e05364 100644 --- a/arch/arm/configs/vendor/sdxlemur-debug.config +++ b/arch/arm/configs/vendor/sdxlemur-debug.config @@ -18,6 +18,9 @@ CONFIG_FAULT_INJECTION_DEBUG_FS=y CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y CONFIG_DEBUG_USER=y # CONFIG_USB_GADGET_DEBUG_FS is not set +CONFIG_IOMMU_DEBUG=y +CONFIG_IOMMU_TESTS=y +CONFIG_IOMMU_TLBSYNC_DEBUG=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_PROXY_CONSUMER=y CONFIG_REGULATOR_STUB=y diff --git a/arch/arm/configs/vendor/sdxlemur.config b/arch/arm/configs/vendor/sdxlemur.config index 9f24fdac83e5..0afdb85e17a3 100644 --- a/arch/arm/configs/vendor/sdxlemur.config +++ b/arch/arm/configs/vendor/sdxlemur.config @@ -11,6 +11,14 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_PROXY_CONSUMER=y CONFIG_REGULATOR_STUB=y # CONFIG_REGULATOR_PROXY_CONSUMER_LEGACY is not set +CONFIG_ARM_SMMU=y +CONFIG_IOMMU_IO_PGTABLE_FAST=y +CONFIG_QCOM_IOMMU_IO_PGTABLE_QUIRKS=y +CONFIG_IOMMU_LIMIT_IOVA_ALIGNMENT=y +CONFIG_QTI_IOMMU_SUPPORT=y +CONFIG_QCOM_SCM=y +CONFIG_QCOM_SECURE_BUFFER=y +CONFIG_DMA_COHERENT_HINT_CACHED=y CONFIG_QRTR=y CONFIG_QRTR_SMD=y CONFIG_MAILBOX=y From afb2fe3b88c364b415c6c5fb81c32a66f13ec2b8 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Fri, 10 Jul 2020 14:58:20 -0700 Subject: [PATCH 2/4] defconfig: Enable Ion for sdxlemur Enable the ion memory manager, which allows both kernel and userspace clients to allocate buffers from specific memory regions. Change-Id: Ie583cbf6b8836e1b4459bcd27399a965384d6a52 Signed-off-by: Patrick Daly --- arch/arm/configs/vendor/sdxlemur.config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/configs/vendor/sdxlemur.config b/arch/arm/configs/vendor/sdxlemur.config index 0afdb85e17a3..a09539d0d34b 100644 --- a/arch/arm/configs/vendor/sdxlemur.config +++ b/arch/arm/configs/vendor/sdxlemur.config @@ -19,6 +19,10 @@ CONFIG_QTI_IOMMU_SUPPORT=y CONFIG_QCOM_SCM=y CONFIG_QCOM_SECURE_BUFFER=y CONFIG_DMA_COHERENT_HINT_CACHED=y +CONFIG_ION=y +CONFIG_ION_MSM_HEAPS=y +CONFIG_ION_DEFER_FREE_NO_SCHED_IDLE=y +CONFIG_QCOM_LAZY_MAPPING=y CONFIG_QRTR=y CONFIG_QRTR_SMD=y CONFIG_MAILBOX=y From c87e65b5dbefe4fb6b2fba47ab5b69c755057026 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Tue, 14 Jul 2020 16:01:34 -0700 Subject: [PATCH 3/4] defconfig: Enable MM defconfigs for sdxlemur Enable ZRAM, as well as slub freelist randomization. Change-Id: I15f248b4ac11353c90b8bb4d60073ce033357f64 Signed-off-by: Patrick Daly --- arch/arm/configs/vendor/sdxlemur-debug.config | 2 ++ arch/arm/configs/vendor/sdxlemur.config | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm/configs/vendor/sdxlemur-debug.config b/arch/arm/configs/vendor/sdxlemur-debug.config index b13509e05364..52a32aa67a95 100644 --- a/arch/arm/configs/vendor/sdxlemur-debug.config +++ b/arch/arm/configs/vendor/sdxlemur-debug.config @@ -21,6 +21,8 @@ CONFIG_DEBUG_USER=y CONFIG_IOMMU_DEBUG=y CONFIG_IOMMU_TESTS=y CONFIG_IOMMU_TLBSYNC_DEBUG=y +CONFIG_DEBUG_PANIC_ON_OOM=y +CONFIG_OF_RESERVED_MEM_CHECK=y CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_PROXY_CONSUMER=y CONFIG_REGULATOR_STUB=y diff --git a/arch/arm/configs/vendor/sdxlemur.config b/arch/arm/configs/vendor/sdxlemur.config index a09539d0d34b..ac8bc17ad35c 100644 --- a/arch/arm/configs/vendor/sdxlemur.config +++ b/arch/arm/configs/vendor/sdxlemur.config @@ -23,6 +23,12 @@ CONFIG_ION=y CONFIG_ION_MSM_HEAPS=y CONFIG_ION_DEFER_FREE_NO_SCHED_IDLE=y CONFIG_QCOM_LAZY_MAPPING=y +CONFIG_SLAB_FREELIST_RANDOM=y +CONFIG_SLAB_FREELIST_HARDENED=y +CONFIG_ZSMALLOC=y +CONFIG_ZRAM=y +CONFIG_BALANCE_ANON_FILE_RECLAIM=y +CONFIG_VM_EVENT_COUNT_CLEAN_PAGE_RECLAIM=y CONFIG_QRTR=y CONFIG_QRTR_SMD=y CONFIG_MAILBOX=y From 031eda4b53f6a0a475402e9f334425f93962bb06 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Fri, 5 Jun 2020 19:52:20 -0700 Subject: [PATCH 4/4] io-pgtable-fast: Remove av8l_fast_cfg Fastmap uses the same page table format as arm_lpae_s1_cfg, so they can share the same data structure format. Additionally, arm-smmu.c *assumes* that struct arm_lpae_s1_cfg is in use. This has not caused any issues so far because the formats of av8l_fast_cfg and arm_lpae_s1_cfg are sufficiently similar. Change-Id: I93dc42f82d988318af35125df3a5fa0739ebae6a Signed-off-by: Patrick Daly --- drivers/iommu/dma-mapping-fast.c | 10 +++++----- drivers/iommu/io-pgtable-fast.c | 30 +++++------------------------- drivers/iommu/iommu-logger.c | 10 +++------- include/linux/io-pgtable-fast.h | 23 +++++++++++++++++++++-- include/linux/io-pgtable.h | 9 --------- 5 files changed, 34 insertions(+), 48 deletions(-) diff --git a/drivers/iommu/dma-mapping-fast.c b/drivers/iommu/dma-mapping-fast.c index e86139c16177..04b5afde3d43 100644 --- a/drivers/iommu/dma-mapping-fast.c +++ b/drivers/iommu/dma-mapping-fast.c @@ -731,15 +731,15 @@ static void fast_smmu_dma_unmap_resource( } static void __fast_smmu_mapped_over_stale(struct dma_fast_smmu_mapping *fast, - void *data) + void *priv) { - av8l_fast_iopte *pmds, *ptep = data; + av8l_fast_iopte *pmds, *ptep = priv; dma_addr_t iova; unsigned long bitmap_idx; - struct io_pgtable *tbl; + struct av8l_fast_io_pgtable *data; - tbl = container_of(fast->pgtbl_ops, struct io_pgtable, ops); - pmds = tbl->cfg.av8l_fast_cfg.pmds; + data = iof_pgtable_ops_to_data(fast->pgtbl_ops); + pmds = data->pmds; bitmap_idx = (unsigned long)(ptep - pmds); iova = bitmap_idx << FAST_PAGE_SHIFT; diff --git a/drivers/iommu/io-pgtable-fast.c b/drivers/iommu/io-pgtable-fast.c index 6661afa5172b..abd7e19bdea1 100644 --- a/drivers/iommu/io-pgtable-fast.c +++ b/drivers/iommu/io-pgtable-fast.c @@ -20,24 +20,6 @@ #define AV8L_FAST_MAX_ADDR_BITS 48 -/* Struct accessors */ -#define iof_pgtable_to_data(x) \ - container_of((x), struct av8l_fast_io_pgtable, iop) - -#define iof_pgtable_ops_to_pgtable(x) \ - container_of((x), struct io_pgtable, ops) - -#define iof_pgtable_ops_to_data(x) \ - iof_pgtable_to_data(iof_pgtable_ops_to_pgtable(x)) - -struct av8l_fast_io_pgtable { - struct io_pgtable iop; - av8l_fast_iopte *pgd; - av8l_fast_iopte *puds[4]; - av8l_fast_iopte *pmds; - struct page **pages; /* page table memory */ -}; - /* Page table bits */ #define AV8L_FAST_PTE_TYPE_SHIFT 0 #define AV8L_FAST_PTE_TYPE_MASK 0x3 @@ -588,7 +570,7 @@ av8l_fast_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) #if defined(CONFIG_ARM) reg |= ARM_32_LPAE_TCR_EAE; #endif - cfg->av8l_fast_cfg.tcr = reg; + cfg->arm_lpae_s1_cfg.tcr = reg; /* MAIRs */ reg = (AV8L_FAST_MAIR_ATTR_NC @@ -600,18 +582,16 @@ av8l_fast_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) (AV8L_FAST_MAIR_ATTR_UPSTREAM << AV8L_FAST_MAIR_ATTR_SHIFT(AV8L_FAST_MAIR_ATTR_IDX_UPSTREAM)); - cfg->av8l_fast_cfg.mair[0] = reg; - cfg->av8l_fast_cfg.mair[1] = 0; + cfg->arm_lpae_s1_cfg.mair[0] = reg; + cfg->arm_lpae_s1_cfg.mair[1] = 0; /* Allocate all page table memory! */ if (av8l_fast_prepopulate_pgtables(data, cfg, cookie)) goto out_free_data; - cfg->av8l_fast_cfg.pmds = data->pmds; - /* TTBRs */ - cfg->av8l_fast_cfg.ttbr[0] = virt_to_phys(data->pgd); - cfg->av8l_fast_cfg.ttbr[1] = 0; + cfg->arm_lpae_s1_cfg.ttbr[0] = virt_to_phys(data->pgd); + cfg->arm_lpae_s1_cfg.ttbr[1] = 0; return &data->iop; out_free_data: diff --git a/drivers/iommu/iommu-logger.c b/drivers/iommu/iommu-logger.c index 190b2604f48f..53a300f15742 100644 --- a/drivers/iommu/iommu-logger.c +++ b/drivers/iommu/iommu-logger.c @@ -62,17 +62,13 @@ static int iommu_logger_domain_ttbrs(struct io_pgtable *iop, void **ttbr0_ptr, switch (iop->fmt) { case ARM_32_LPAE_S1: case ARM_64_LPAE_S1: +#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST + case ARM_V8L_FAST: +#endif ttbr0 = iop->cfg.arm_lpae_s1_cfg.ttbr[0]; ttbr1 = iop->cfg.arm_lpae_s1_cfg.ttbr[1]; ret = 0; break; -#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST - case ARM_V8L_FAST: - ttbr0 = iop->cfg.av8l_fast_cfg.ttbr[0]; - ttbr1 = iop->cfg.av8l_fast_cfg.ttbr[1]; - ret = 0; - break; -#endif default: ret = -EINVAL; } diff --git a/include/linux/io-pgtable-fast.h b/include/linux/io-pgtable-fast.h index 7a94e4cd0bec..1b9cc19370fd 100644 --- a/include/linux/io-pgtable-fast.h +++ b/include/linux/io-pgtable-fast.h @@ -1,13 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */ #ifndef __LINUX_IO_PGTABLE_FAST_H #define __LINUX_IO_PGTABLE_FAST_H #include - +#include /* * This ought to be private to io-pgtable-fast, but dma-mapping-fast * currently requires it for a debug usecase. @@ -17,6 +17,25 @@ typedef u64 av8l_fast_iopte; struct io_pgtable_ops; struct scatterlist; +struct av8l_fast_io_pgtable { + struct io_pgtable iop; + av8l_fast_iopte *pgd; + av8l_fast_iopte *puds[4]; + av8l_fast_iopte *pmds; + struct page **pages; /* page table memory */ +}; + +/* Struct accessors */ +#define iof_pgtable_to_data(x) \ + container_of((x), struct av8l_fast_io_pgtable, iop) + +#define iof_pgtable_ops_to_pgtable(x) \ + container_of((x), struct io_pgtable, ops) + +#define iof_pgtable_ops_to_data(x) \ + iof_pgtable_to_data(iof_pgtable_ops_to_pgtable(x)) + + #ifdef CONFIG_IOMMU_IO_PGTABLE_FAST int av8l_fast_map_public(struct io_pgtable_ops *ops, unsigned long iova, diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index 00fd7388708a..31332876d2b8 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -157,15 +157,6 @@ struct io_pgtable_cfg { u64 transtab; u64 memattr; } arm_mali_lpae_cfg; - -#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST - struct { - u64 ttbr[2]; - u64 tcr; - u64 mair[2]; - void *pmds; - } av8l_fast_cfg; -#endif }; };