* [PATCH v2 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request
2026-09-11 9:08 [PATCH v2 0/2] soc: qcom: rpmh-rsc: Updates for RPMh read requests Maulik Shah
@ 2026-09-11 9:08 ` Maulik Shah
2026-09-11 9:08 ` [PATCH v2 2/2] soc: qcom: rpmh-rsc: Skip read requests on unsupported platforms Maulik Shah
1 sibling, 0 replies; 4+ messages in thread
From: Maulik Shah @ 2026-09-11 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Kamal Wadhwa, Dmitry Baryshkov,
Mark Brown
Cc: linux-arm-msm, linux-kernel, Konrad Dybcio, Maulik Shah, Mukesh Ojha
Newer SoC like hawi with RSC version v4.5 support 4 byte message read
request instead of default 8 byte on older SoCs. The write request
continues to be 8 bytes.
The CMD_MSGID_LEN field is [3:0] bits. Describe the length bits as a
GENMASK() and use FIELD_PREP() when programming 4-byte or 8-byte message
length.
Tested-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> #Hawi
Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
---
drivers/soc/qcom/rpmh-rsc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index c4542318eac4..c5ed9874bb67 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -7,6 +7,7 @@
#define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME
#include <linux/atomic.h>
+#include <linux/bitfield.h>
#include <linux/cpu_pm.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
@@ -86,7 +87,7 @@ enum {
#define TCS_AMC_MODE_TRIGGER BIT(24)
/* TCS CMD register bit mask */
-#define CMD_MSGID_LEN 8
+#define CMD_MSGID_LEN GENMASK(3, 0)
#define CMD_MSGID_RESP_REQ BIT(8)
#define CMD_MSGID_WRITE BIT(16)
#define CMD_STATUS_ISSUED BIT(8)
@@ -499,13 +500,20 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id,
const struct tcs_request *msg)
{
u32 msgid;
- u32 cmd_msgid = CMD_MSGID_LEN;
+ u32 cmd_msgid;
u32 cmd_enable = 0;
struct tcs_cmd *cmd;
int i, j;
/* Convert all commands to RR when the request has wait_for_compl set */
- cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0;
+ cmd_msgid = msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0;
+
+ if (msg->is_read && (drv->ver.major > 4 ||
+ (drv->ver.major == 4 && drv->ver.minor >= 5)))
+ cmd_msgid |= FIELD_PREP(CMD_MSGID_LEN, 4);
+ else
+ cmd_msgid |= FIELD_PREP(CMD_MSGID_LEN, 8);
+
if (!msg->is_read)
cmd_msgid |= CMD_MSGID_WRITE;
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 2/2] soc: qcom: rpmh-rsc: Skip read requests on unsupported platforms
2026-09-11 9:08 [PATCH v2 0/2] soc: qcom: rpmh-rsc: Updates for RPMh read requests Maulik Shah
2026-09-11 9:08 ` [PATCH v2 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request Maulik Shah
@ 2026-09-11 9:08 ` Maulik Shah
2026-09-21 14:29 ` Konrad Dybcio
1 sibling, 1 reply; 4+ messages in thread
From: Maulik Shah @ 2026-09-11 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Kamal Wadhwa, Dmitry Baryshkov,
Mark Brown
Cc: linux-arm-msm, linux-kernel, Konrad Dybcio, Maulik Shah
On some platforms AOSS do not respond to read requests. Read request in
such cases will consume the ACTIVE TCS but forever waits for a response
blocking the subsequent write requests.
Skip issuing read commands on sm8150 and sc8180x platforms. For such
platforms return success to the caller with the resource level at zero
to avoid the caller taking any action on error code.
Fixes: edbafe65eef2 ("soc: qcom: rpmh: Add support to read back resource settings")
Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
---
drivers/soc/qcom/rpmh-internal.h | 2 ++
drivers/soc/qcom/rpmh-rsc.c | 7 +++++++
drivers/soc/qcom/rpmh.c | 6 ++++++
3 files changed, 15 insertions(+)
diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 39441a25af9b..960a62f0e931 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -75,12 +75,14 @@ struct rpmh_request {
* @cache: the list of cached requests
* @cache_lock: synchronize access to the cache data
* @dirty: was the cache updated since flush
+ * @no_rpmh_read: controller does not support or respond to read commands
* @batch_cache: Cache sleep and wake requests sent as batch
*/
struct rpmh_ctrlr {
struct list_head cache;
spinlock_t cache_lock;
bool dirty;
+ bool no_rpmh_read;
struct list_head batch_cache;
};
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index c5ed9874bb67..054122ccc46c 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -987,6 +987,12 @@ static void rpmh_rsc_cpu_pm_unregister(void *data)
cpu_pm_unregister_notifier(data);
}
+static bool rpmh_rsc_no_rpmh_read(void)
+{
+ return of_machine_is_compatible("qcom,sm8150") ||
+ of_machine_is_compatible("qcom,sc8180x");
+}
+
static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv)
{
struct tcs_type_config {
@@ -1156,6 +1162,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
spin_lock_init(&drv->client.cache_lock);
INIT_LIST_HEAD(&drv->client.cache);
INIT_LIST_HEAD(&drv->client.batch_cache);
+ drv->client.no_rpmh_read = rpmh_rsc_no_rpmh_read();
dev_set_drvdata(&pdev->dev, drv);
drv->dev = &pdev->dev;
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 360242a315e3..fed2ea06f490 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -240,12 +240,18 @@ int rpmh_read(const struct device *dev, struct tcs_cmd *cmd)
{
DECLARE_COMPLETION_ONSTACK(compl);
DEFINE_RPMH_MSG_ONSTACK(dev, RPMH_ACTIVE_ONLY_STATE, &compl, rpm_msg);
+ struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
int ret;
ret = __fill_rpmh_msg(&rpm_msg, RPMH_ACTIVE_ONLY_STATE, cmd, 1, true);
if (ret)
return ret;
+ if (ctrlr->no_rpmh_read) {
+ cmd[0].data = 0;
+ return 0;
+ }
+
ret = __rpmh_write(dev, RPMH_ACTIVE_ONLY_STATE, &rpm_msg);
if (ret)
return ret;
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread