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);