From 66e3bf98d5efbe4231ed0e66de507b4efc9f5b4f Mon Sep 17 00:00:00 2001 From: Huang Yiwei Date: Thu, 15 Jun 2023 14:39:28 +0800 Subject: [PATCH] drivers: qcom: dcvs: Add zone and get api To allow users to config cache portion more flexibly, zone parameter is added. Also, get api is added to help confirm the cache portion setting. Change-Id: If2aec4a50a23dc7e5b56a249c258846b8c993f93 Signed-off-by: Huang Yiwei --- drivers/soc/qcom/dcvs/mpam.c | 24 +++++++++++++++++++----- include/soc/qcom/mpam.h | 12 +++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/dcvs/mpam.c b/drivers/soc/qcom/dcvs/mpam.c index ca9a954a6e5f..2f78b859a791 100644 --- a/drivers/soc/qcom/dcvs/mpam.c +++ b/drivers/soc/qcom/dcvs/mpam.c @@ -25,32 +25,46 @@ enum mpam_profiling_param_ids { struct mpam_cache_portion { uint32_t part_id; uint32_t cache_portion; + uint64_t config_ctrl; }; -static struct mpam_cache_portion cur_cache_portion; static struct scmi_protocol_handle *ph; static const struct qcom_scmi_vendor_ops *ops; static struct scmi_device *sdev; -int qcom_mpam_set_cache_portion(u32 part_id, u32 cache_portion) +int qcom_mpam_set_cache_portion(u32 part_id, u32 cache_portion, u64 config_ctrl) { int ret = -EPERM; struct mpam_cache_portion msg; msg.part_id = part_id; msg.cache_portion = cache_portion; + msg.config_ctrl = config_ctrl; if (ops) ret = ops->set_param(ph, &msg, MPAM_ALGO_STR, PARAM_CACHE_PORTION, sizeof(msg)); - if (!ret) - memcpy(&cur_cache_portion, &msg, sizeof(msg)); - return ret; } EXPORT_SYMBOL(qcom_mpam_set_cache_portion); +int qcom_mpam_get_cache_portion(u32 part_id, u64 *config_ctrl) +{ + int ret = -EPERM; + u64 buf = part_id; + + if (ops) + ret = ops->get_param(ph, &buf, MPAM_ALGO_STR, PARAM_CACHE_PORTION, + sizeof(part_id), sizeof(buf)); + + if (!ret) + *config_ctrl = buf; + + return ret; +} +EXPORT_SYMBOL(qcom_mpam_get_cache_portion); + static int mpam_dev_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; diff --git a/include/soc/qcom/mpam.h b/include/soc/qcom/mpam.h index 24922eb13278..99893a3d0a5f 100644 --- a/include/soc/qcom/mpam.h +++ b/include/soc/qcom/mpam.h @@ -7,11 +7,17 @@ #define _QCOM_MPAM_H #if IS_ENABLED(CONFIG_QTI_MPAM) -int qcom_mpam_set_cache_portion(u32 part_id, u32 cache_portion); +int qcom_mpam_set_cache_portion(u32 part_id, u32 cache_portion, u64 config_ctrl); +int qcom_mpam_get_cache_portion(u32 part_id, u64 *config_ctrl); #else -static inline int qcom_mpam_set_cache_portion(u32 part_id, u32 cache_portion) +static inline int qcom_mpam_set_cache_portion(u32 part_id, u32 cache_portion, u64 config_ctrl) { - return 0; + return -ENODEV; +} + +static inline int qcom_mpam_get_cache_portion(u32 part_id, u64 *config_ctrl) +{ + return -ENODEV; } #endif