From 8d0b09d4f2e55a786da1adff07ed6ce02740c504 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Wed, 15 Jan 2020 23:53:01 -0800 Subject: [PATCH 1/2] Revert "mm: cma: make writeable CMA debugfs optional" This reverts commit 099c0c9a642569edfe672eeb983876b0e6662a75. CONFIG_CMA_DEBUGFS is only enabled in debug builds on 5.4+ and the purpose of this commit is to disallow CMA allocations through debugfs on production builds. Since, this is no longer possible, revert this change. Change-Id: If1f322533660bfc7609fb09a5b13ff2ecbbe3135 Signed-off-by: Isaac J. Manjarres --- mm/Kconfig | 9 --------- mm/cma_debug.c | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 880a5221a5ea..183096ddd744 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -519,15 +519,6 @@ 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 42ad17b64001..bc9a7d681b7a 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c @@ -74,7 +74,6 @@ 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); @@ -133,13 +132,8 @@ 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; @@ -170,10 +164,6 @@ 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 103eb3b3d9956944a5a8900de833d418a68aa0d8 Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Thu, 10 Oct 2019 09:49:41 -0700 Subject: [PATCH 2/2] arm64: defconfig: Enable CMA debug configs on Lahaina Enable CMA_DEBUGFS and CMA_DEBUG on Lahaina debug builds to collect information about CMA statistics/allocation times through DEBUGFS. Change-Id: Iae10513210c85ad32101720b9ee57ac5fe49d6fb Signed-off-by: Isaac J. Manjarres --- arch/arm64/configs/vendor/lahaina_debug.config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/configs/vendor/lahaina_debug.config b/arch/arm64/configs/vendor/lahaina_debug.config index 65d618d8128c..8a185f61f721 100644 --- a/arch/arm64/configs/vendor/lahaina_debug.config +++ b/arch/arm64/configs/vendor/lahaina_debug.config @@ -1,4 +1,6 @@ CONFIG_IOMMU_TLBSYNC_DEBUG=y +CONFIG_CMA_DEBUGFS=y +CONFIG_CMA_DEBUG=y CONFIG_EDAC_KRYO_ARM64_PANIC_ON_CE=y CONFIG_IPC_LOGGING=y CONFIG_QMP_DEBUGFS_CLIENT=y