From 5c3224adf43bcbd3184bdd42d9ea12b155ae2bda Mon Sep 17 00:00:00 2001 From: Chris Goldsworthy Date: Wed, 31 Aug 2022 19:07:19 -0700 Subject: [PATCH] mem-buf: Allow selective usage of *memory_subsection functions add_memory_subsection() and remove_memory_subsection() are only needed on the TVM and OEM VMs. These are downstream functions as well. Thus, selectively allow them to be enabled so that we only compile them on downstream kernels. Change-Id: I8416cd8eb8db74cf8a3cfbc8e3d7ea2fff112353 Signed-off-by: Chris Goldsworthy --- drivers/soc/qcom/mem_buf/Kconfig | 14 ++++++++++++++ drivers/soc/qcom/mem_buf/mem-buf-dev-gh.c | 2 ++ drivers/soc/qcom/mem_buf/mem-buf-dev.h | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/drivers/soc/qcom/mem_buf/Kconfig b/drivers/soc/qcom/mem_buf/Kconfig index 273d1a77dd1a..13f63ec7b3bd 100644 --- a/drivers/soc/qcom/mem_buf/Kconfig +++ b/drivers/soc/qcom/mem_buf/Kconfig @@ -27,6 +27,20 @@ config QCOM_MEM_BUF_DEV config QCOM_MEM_BUF_DEV_GH bool +config QCOM_MEM_BUF_UPDATE_S1 + tristate "Map imported memory into the S1 logical kernel mapping for cache maintenance" + depends on QCOM_MEM_BUF_DEV_GH + help + When mapping memory into a VM, we must add it to the logical mapping in Linux in + order to perform cache maintenance on the memory. The default functions used for + adding memory, add_memory(), only maps memory at 128 MB chunks and has a 256 KB + overhead in the page table space it consumes (assuming the logical mapping is not + using block mappings). We accordingly use a downstream functions instead - + add_memory_subsection() - that adds memory on a section-size granularity + (currently 4 MB). Select this config option to enable the usage of these functions + on VMs, where these functions will be available using our downstream kernels. + If unsure, say N. + config QCOM_MEM_BUF_MSGQ tristate "Qualcomm Technologies, Inc. Memory Buffer Message Queue Support" depends on GH_MSGQ && QCOM_MEM_BUF_DEV_GH diff --git a/drivers/soc/qcom/mem_buf/mem-buf-dev-gh.c b/drivers/soc/qcom/mem_buf/mem-buf-dev-gh.c index 18194d375677..c227d7bf966e 100644 --- a/drivers/soc/qcom/mem_buf/mem-buf-dev-gh.c +++ b/drivers/soc/qcom/mem_buf/mem-buf-dev-gh.c @@ -252,6 +252,7 @@ int mem_buf_unmap_mem_s2(gh_memparcel_handle_t memparcel_hdl) } EXPORT_SYMBOL(mem_buf_unmap_mem_s2); +#ifdef CONFIG_QCOM_MEM_BUF_UPDATE_S1 int mem_buf_map_mem_s1(struct gh_sgl_desc *sgl_desc) { u64 base, size; @@ -300,6 +301,7 @@ int mem_buf_unmap_mem_s1(struct gh_sgl_desc *sgl_desc) return ret; } EXPORT_SYMBOL(mem_buf_unmap_mem_s1); +#endif /* CONFIG_QCOM_MEM_BUF_UPDATE_S1 */ static int mem_buf_hyp_assign_table_gh(struct gh_sgl_desc *sgl_desc, int src_vmid, struct gh_acl_desc *acl_desc) diff --git a/drivers/soc/qcom/mem_buf/mem-buf-dev.h b/drivers/soc/qcom/mem_buf/mem-buf-dev.h index 04a44dc6beca..ccafbccbe543 100644 --- a/drivers/soc/qcom/mem_buf/mem-buf-dev.h +++ b/drivers/soc/qcom/mem_buf/mem-buf-dev.h @@ -31,8 +31,22 @@ int mem_buf_hyp_assign_table(struct sg_table *sgt, u32 *src_vmid, int source_nel int *dest_vmids, int *dest_perms, int dest_nelems); #ifdef CONFIG_QCOM_MEM_BUF_DEV_GH + +#ifdef CONFIG_QCOM_MEM_BUF_UPDATE_S1 int mem_buf_map_mem_s1(struct gh_sgl_desc *sgl_desc); int mem_buf_unmap_mem_s1(struct gh_sgl_desc *sgl_desc); +#else +static inline int mem_buf_map_mem_s1(struct gh_sgl_desc *sgl_desc) +{ + return -EINVAL; +} + +static inline int mem_buf_unmap_mem_s1(struct gh_sgl_desc *sgl_desc) +{ + return -EINVAL; +} +#endif /* CONFIG_QCOM_MEM_BUF_UPDATE_S1 */ + struct gh_acl_desc *mem_buf_vmid_perm_list_to_gh_acl(int *vmids, int *perms, unsigned int nr_acl_entries); struct gh_sgl_desc *mem_buf_sgt_to_gh_sgl_desc(struct sg_table *sgt);