From 1a394f02c013a9002c7e2252e923d12959422a3a Mon Sep 17 00:00:00 2001 From: Prakash Gupta Date: Tue, 15 Dec 2020 16:57:06 +0530 Subject: [PATCH 1/2] Revert "Revert "mm: cma: make writeable CMA debugfs optional"" This reverts commit 8d0b09d4f2e55a786da1adff07ed6ce02740c504. With CONFIG_DEBUG_FS enable for non-debug build, we can enable read only CMA debugfs nodes on all builds. Change-Id: Ia4a0a9431e27ec908feaae54dbe622a1d985958b Signed-off-by: Prakash Gupta --- mm/Kconfig | 9 +++++++++ mm/cma_debug.c | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/mm/Kconfig b/mm/Kconfig index d02e896f381e..09ff5730a3c0 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -518,6 +518,15 @@ config CMA_DEBUGFS help Turns on the DebugFS interface for CMA. +config CMA_ALLOW_WRITE_DEBUGFS + depends on CMA_DEBUGFS + bool "Allow CMA debugfs write" + help + Say 'y' here to allow the CMA debugfs write. + CMA debugfs write could be risky as it allows + cma allocation, so it is not recommended to + enable this option on any production device. + config CMA_AREAS int "Maximum count of the CMA areas" depends on CMA diff --git a/mm/cma_debug.c b/mm/cma_debug.c index bc9a7d681b7a..42ad17b64001 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c @@ -74,6 +74,7 @@ static int cma_maxchunk_get(void *data, u64 *val) } DEFINE_SIMPLE_ATTRIBUTE(cma_maxchunk_fops, cma_maxchunk_get, NULL, "%llu\n"); +#ifdef CONFIG_CMA_ALLOW_WRITE_DEBUGFS static void cma_add_to_cma_mem_list(struct cma *cma, struct cma_mem *mem) { spin_lock(&cma->mem_head_lock); @@ -132,8 +133,13 @@ static int cma_free_write(void *data, u64 val) return cma_free_mem(cma, pages); } +#else +#define cma_free_write NULL +#endif + DEFINE_SIMPLE_ATTRIBUTE(cma_free_fops, NULL, cma_free_write, "%llu\n"); +#ifdef CONFIG_CMA_ALLOW_WRITE_DEBUGFS static int cma_alloc_mem(struct cma *cma, int count) { struct cma_mem *mem; @@ -164,6 +170,10 @@ static int cma_alloc_write(void *data, u64 val) return cma_alloc_mem(cma, pages); } +#else +#define cma_alloc_write NULL +#endif + DEFINE_SIMPLE_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n"); static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry) From 285f7f6b94bf8c299aa4d3b0ee60c2ab7bb5233c Mon Sep 17 00:00:00 2001 From: Prakash Gupta Date: Thu, 17 Dec 2020 14:41:16 +0530 Subject: [PATCH 2/2] arm64: defconfig: enable cma debugfs Enable CONFIG_CMA_DEBUGFS for QGKI. This enables read only nodes on QGKI build. Enable CONFIG_CMA_ALLOW_WRITE_DEBUGFS for debug config. This enables writeable cma debugfs node for debug build. Change-Id: Ia40eea08c42b5c4d29691ea354411216c03e60a7 Signed-off-by: Prakash Gupta --- arch/arm64/configs/vendor/holi_QGKI.config | 1 + arch/arm64/configs/vendor/holi_debug.config | 2 +- arch/arm64/configs/vendor/lahaina_QGKI.config | 1 + arch/arm64/configs/vendor/lahaina_consolidate.config | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/configs/vendor/holi_QGKI.config b/arch/arm64/configs/vendor/holi_QGKI.config index d273e2cf696c..1e2a71c04482 100644 --- a/arch/arm64/configs/vendor/holi_QGKI.config +++ b/arch/arm64/configs/vendor/holi_QGKI.config @@ -1,5 +1,6 @@ CONFIG_LOCALVERSION="-qgki" # CONFIG_TRIM_UNUSED_KSYMS is not set +CONFIG_CMA_DEBUGFS=y CONFIG_QCOM_IOMMU_IO_PGTABLE_QUIRKS=y CONFIG_QCOM_IOMMU_TLBI_QUIRKS=y CONFIG_QCOM_LAZY_MAPPING=y diff --git a/arch/arm64/configs/vendor/holi_debug.config b/arch/arm64/configs/vendor/holi_debug.config index 8ead4eefb3c2..20aaba5b7897 100644 --- a/arch/arm64/configs/vendor/holi_debug.config +++ b/arch/arm64/configs/vendor/holi_debug.config @@ -3,7 +3,7 @@ CONFIG_IOMMU_TLBSYNC_DEBUG=y CONFIG_ARM_SMMU_TESTBUS_DUMP=y CONFIG_ARM_SMMU_TESTBUS_DEBUGFS=y CONFIG_IO_PGTABLE_PAGE_ACCOUNTING=y -CONFIG_CMA_DEBUGFS=y +CONFIG_CMA_ALLOW_WRITE_DEBUGFS=y CONFIG_CMA_DEBUG=y CONFIG_EDAC_KRYO_ARM64_PANIC_ON_CE=y CONFIG_QMP_DEBUGFS_CLIENT=y diff --git a/arch/arm64/configs/vendor/lahaina_QGKI.config b/arch/arm64/configs/vendor/lahaina_QGKI.config index 8509cf56b00e..50c2b03251cc 100644 --- a/arch/arm64/configs/vendor/lahaina_QGKI.config +++ b/arch/arm64/configs/vendor/lahaina_QGKI.config @@ -1,5 +1,6 @@ CONFIG_LOCALVERSION="-qgki" # CONFIG_TRIM_UNUSED_KSYMS is not set +CONFIG_CMA_DEBUGFS=y CONFIG_QCOM_IOMMU_IO_PGTABLE_QUIRKS=y CONFIG_QCOM_IOMMU_TLBI_QUIRKS=y CONFIG_QCOM_LAZY_MAPPING=y diff --git a/arch/arm64/configs/vendor/lahaina_consolidate.config b/arch/arm64/configs/vendor/lahaina_consolidate.config index 0a227034bc4d..3c948eb65ad7 100644 --- a/arch/arm64/configs/vendor/lahaina_consolidate.config +++ b/arch/arm64/configs/vendor/lahaina_consolidate.config @@ -5,7 +5,7 @@ CONFIG_IOMMU_TESTS=y CONFIG_ARM_SMMU_TESTBUS_DEBUGFS=y CONFIG_ARM_SMMU_TESTBUS_DUMP=y CONFIG_IO_PGTABLE_PAGE_ACCOUNTING=y -CONFIG_CMA_DEBUGFS=y +CONFIG_CMA_ALLOW_WRITE_DEBUGFS=y CONFIG_CMA_DEBUG=y CONFIG_DEBUG_PAGEALLOC=y CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y