Skip to contentSkip to conversation

soc: qcom: rpmh-rsc: Updates for RPMh read requests

PATCH Superseded Maulik Shah 4 participants 9 messages Sep 10 – Sep 11

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover soc: qcom: rpmh-rsc: Updates for RPMh read requests

This series carries two RPMh read request updates.

RSC v4.5 and newer expect read commands to use a 4-byte message payload, while write commands continue to use 8 bytes. Update the message length used for read requests on those controllers.

Some platforms either do not support RPMh read requests or AOSS does not respond to them. Issuing a read there can occupy an ACTIVE TCS indefinitely and block subsequent write requests. Skip read commands on sm8150 and sc8180x [1] returning a zero resource level so callers avoid error handling for an unsupported read path.

Patch-1 do not have any dependency. Fixes tag is not required as existing SoCs on upstream are all lower than v4.5 version. Patch-1 can be applied as preparation for Hawi SoC support.

Patch-2 of the series carries fixes tag. I do not have sm8150 or sc8180x to verify patch-2. If there are reports like [1] of read requests not working on past SoC the list can be expanded within newly added rpmh_rsc_no_rpmh_read() API.

[1] https://lore.kernel.org/linux-arm-msm/[email protected]/

---
Maulik Shah (2):
soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request
soc: qcom: rpmh-rsc: Skip read requests on unsupported platforms

 drivers/soc/qcom/rpmh-internal.h |  2 ++
 drivers/soc/qcom/rpmh-rsc.c      | 20 +++++++++++++++++---
 drivers/soc/qcom/rpmh.c          |  6 ++++++
 3 files changed, 25 insertions(+), 3 deletions(-)

---
base-commit: c68a982815dcce5464e3bf2a31ac94f5146c04ca
change-id: 20260910-rsc_read-27d689e37cb5

Best regards,

Signature · 1 line
Maulik Shah <[email protected]>
#1 lore raw

PATCH 1/2 soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request

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.

Update the read request message accordingly on RSC v4.5 and higher.

---
 drivers/soc/qcom/rpmh-rsc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +10 -3
index c4542318eac4..f84a399fa5dc 100644
@@ -86,6 +86,7 @@ enum {
 #define TCS_AMC_MODE_TRIGGER		BIT(24)
 
 /* TCS CMD register bit mask */
+#define CMD_MSGID_LEN_READ_v4_5		4
 #define CMD_MSGID_LEN			8
 #define CMD_MSGID_RESP_REQ		BIT(8)
 #define CMD_MSGID_WRITE			BIT(16)
@@ -499,15 +500,21 @@ 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 = 0;
 	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;
-	if (!msg->is_read)
-		cmd_msgid |= CMD_MSGID_WRITE;
+	if (!msg->is_read) {
+		cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE;
+	} else {
+		if (drv->ver.major >= 4 && drv->ver.minor >= 5)
+			cmd_msgid = CMD_MSGID_LEN_READ_v4_5;
+		else
+			cmd_msgid = CMD_MSGID_LEN;
+	}
 
 	for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) {
 		cmd = &msg->cmds[i];
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request

Quoted 28 lines · Maulik Shah

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.

Update the read request message accordingly on RSC v4.5 and higher.

---
 drivers/soc/qcom/rpmh-rsc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +1 -1
index c4542318eac4..f84a399fa5dc 100644
@@ -86,6 +86,7 @@ enum {
 #define TCS_AMC_MODE_TRIGGER		BIT(24)
 
 /* TCS CMD register bit mask */
+#define CMD_MSGID_LEN_READ_v4_5		4
 #define CMD_MSGID_LEN			8
 #define CMD_MSGID_RESP_REQ		BIT(8)
 #define CMD_MSGID_WRITE			BIT(16)
@@ -499,15 +500,21 @@ 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;

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 510

Quoted 10 lines
drivers/soc/qcom/rpmh-rsc.c +2 -2
+	u32 cmd_msgid = 0;
 	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;
-	if (!msg->is_read)
-		cmd_msgid |= CMD_MSGID_WRITE;
+	if (!msg->is_read) {

checking for the negative first is odd.. it's existing art, but let's invert that for readability

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 513

Quoted 3 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
+		cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE;
+	} else {
+		if (drv->ver.major >= 4 && drv->ver.minor >= 5)

This check will fail for e.g. v5.0

(major == 4 && minor >= 5) || major >= 5

Konrad

#3 lore raw

Re: [PATCH 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request

Quoted 34 lines · Konrad Dybcio
Quoted 33 lines · Maulik Shah

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.

Update the read request message accordingly on RSC v4.5 and higher.

---
 drivers/soc/qcom/rpmh-rsc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +2 -1
index c4542318eac4..f84a399fa5dc 100644
@@ -86,6 +86,7 @@ enum {
 #define TCS_AMC_MODE_TRIGGER		BIT(24)
 
 /* TCS CMD register bit mask */
+#define CMD_MSGID_LEN_READ_v4_5		4
 #define CMD_MSGID_LEN			8
 #define CMD_MSGID_RESP_REQ		BIT(8)
 #define CMD_MSGID_WRITE			BIT(16)
@@ -499,15 +500,21 @@ 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 = 0;
 	u32 cmd_enable = 0;
 	struct tcs_cmd *cmd;
 	int i, j;
 
Quoted 7 lines

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 510

Quoted 5 lines
drivers/soc/qcom/rpmh-rsc.c +1 -2
 	/* Convert all commands to RR when the request has wait_for_compl set */
 	cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0;
-	if (!msg->is_read)
-		cmd_msgid |= CMD_MSGID_WRITE;
+	if (!msg->is_read) {

checking for the negative first is odd.. it's existing art, but let's invert that for readability

Ack. will update in v2.

Quoted 9 lines

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 513

Quoted 4 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
+		cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE;
+	} else {
+		if (drv->ver.major >= 4 && drv->ver.minor >= 5)

This check will fail for e.g. v5.0

(major == 4 && minor >= 5) || major >= 5

Konrad

Ack. will update in v2.

Thanks,
Maulik

Tested-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request

In reply to Maulik Shah
Quoted 38 lines · Maulik Shah

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.

Update the read request message accordingly on RSC v4.5 and higher.

---
 drivers/soc/qcom/rpmh-rsc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +3 -3
index c4542318eac4..f84a399fa5dc 100644
@@ -86,6 +86,7 @@ enum {
 #define TCS_AMC_MODE_TRIGGER		BIT(24)
 
 /* TCS CMD register bit mask */
+#define CMD_MSGID_LEN_READ_v4_5		4
 #define CMD_MSGID_LEN			8
 #define CMD_MSGID_RESP_REQ		BIT(8)
 #define CMD_MSGID_WRITE			BIT(16)
@@ -499,15 +500,21 @@ 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 = 0;
 	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;
-	if (!msg->is_read)
-		cmd_msgid |= CMD_MSGID_WRITE;
+	if (!msg->is_read) {

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 520

Quoted 10 lines
drivers/soc/qcom/rpmh-rsc.c +7 -0
+		cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE;
+	} else {
+		if (drv->ver.major >= 4 && drv->ver.minor >= 5)
+			cmd_msgid = CMD_MSGID_LEN_READ_v4_5;
+		else
+			cmd_msgid = CMD_MSGID_LEN;
+	}
 
 	for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) {
 		cmd = &msg->cmds[i];

Tested this patch on Hawi, it works; without the patch boot up was stuck.

Signature · 1 line
-Mukesh Ojha
maintainer
#5 lore raw

Re: [PATCH 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request

In reply to Maulik Shah
Quoted 29 lines · Maulik Shah

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.

Update the read request message accordingly on RSC v4.5 and higher.

---
 drivers/soc/qcom/rpmh-rsc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +2 -1
index c4542318eac4..f84a399fa5dc 100644
@@ -86,6 +86,7 @@ enum {
 #define TCS_AMC_MODE_TRIGGER		BIT(24)
 
 /* TCS CMD register bit mask */
+#define CMD_MSGID_LEN_READ_v4_5		4
 #define CMD_MSGID_LEN			8
 #define CMD_MSGID_RESP_REQ		BIT(8)
 #define CMD_MSGID_WRITE			BIT(16)
@@ -499,15 +500,21 @@ 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 = 0;

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 511

Quoted 10 lines
drivers/soc/qcom/rpmh-rsc.c +2 -2
 	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;
-	if (!msg->is_read)
-		cmd_msgid |= CMD_MSGID_WRITE;
+	if (!msg->is_read) {
+		cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE;

I know this follows the current code, but CMD_MSGID_LEN doesn't seem like a "fixed" part of this message anymore. It seems rather that there's a few bits here which denotes the CMD_MSGID_LEN and the value thereof is either 8 or 4.

If this is the case, I'd find it cleaner to define CMD_MSGID_LEN_MASK and then just FIELD_PREP() to put a 4 or a 8 in the "length field" of the command.

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 514

Quoted 3 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
+	} else {
+		if (drv->ver.major >= 4 && drv->ver.minor >= 5)
+			cmd_msgid = CMD_MSGID_LEN_READ_v4_5;

If I understand your commit message, this line says "on DRV 4.5 and higher length is 4 otherwise it's 8" - but there's no way anyone can read this line and come to that conclusion.

In contrast, this would actually say that:
cmd_msgid |= FIELD_PREP(CMD_MSGID_LEN, 4);

Also, is this really supposed to apply to DRV versions such as 5.5, but not 6.1?

Regards,
Bjorn

Quoted 10 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
+		else
+			cmd_msgid = CMD_MSGID_LEN;
+	}
 
 	for (i = 0, j = cmd_id; i < msg->num_cmds; i++, j++) {
 		cmd = &msg->cmds[i];
Signature · 2 lines
-- 
2.43.0
#6 lore raw

Re: [PATCH 1/2] soc: qcom: rpmh-rsc: Update CMD_MSGID_LEN to 4 bytes for read request

Quoted 1 line · Bjorn Andersson

On Thu, Sep 10, 2026 at 02:23:01PM +0530, Maulik Shah wrote:

[...]

Quoted 12 lines
drivers/soc/qcom/rpmh-rsc.c +2 -2
 	/* Convert all commands to RR when the request has wait_for_compl set */
 	cmd_msgid |= msg->wait_for_compl ? CMD_MSGID_RESP_REQ : 0;
-	if (!msg->is_read)
-		cmd_msgid |= CMD_MSGID_WRITE;
+	if (!msg->is_read) {
+		cmd_msgid = CMD_MSGID_LEN | CMD_MSGID_WRITE;

I know this follows the current code, but CMD_MSGID_LEN doesn't seem like a "fixed" part of this message anymore. It seems rather that there's a few bits here which denotes the CMD_MSGID_LEN and the value thereof is either 8 or 4.

Quoted 3 lines

If this is the case, I'd find it cleaner to define CMD_MSGID_LEN_MASK and then just FIELD_PREP() to put a 4 or a 8 in the "length field" of the command.

Yes, updating v2 to use  FIELD_PREP().

Quoted 10 lines

drivers/soc/qcom/rpmh-rsc.c static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, · line 514

Quoted 4 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
+	} else {
+		if (drv->ver.major >= 4 && drv->ver.minor >= 5)
+			cmd_msgid = CMD_MSGID_LEN_READ_v4_5;

If I understand your commit message, this line says "on DRV 4.5 and higher length is 4 otherwise it's 8" - but there's no way anyone can read this line and come to that conclusion.

In contrast, this would actually say that:
cmd_msgid |= FIELD_PREP(CMD_MSGID_LEN, 4);

I will update to use FIELD_PREP.

Quoted 4 lines

Also, is this really supposed to apply to DRV versions such as 5.5, but not 6.1?

I will update version check in v2.

Thanks,
Maulik

#7 lore raw

PATCH 2/2 soc: qcom: rpmh-rsc: Skip read requests on unsupported platforms

In reply to 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")
---
 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(+)
drivers/soc/qcom/rpmh-internal.h +2 -0
index 39441a25af9b..960a62f0e931 100644
@@ -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;
 };
 
drivers/soc/qcom/rpmh-rsc.c +7 -0
index f84a399fa5dc..7a210f924af8 100644
@@ -986,6 +986,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 {
@@ -1155,6 +1161,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;
drivers/soc/qcom/rpmh.c +6 -0
index 360242a315e3..fed2ea06f490 100644
@@ -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;
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH 2/2] soc: qcom: rpmh-rsc: Skip read requests on unsupported platforms

Quoted 7 lines · 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.

FWIW, *some* reads (e.g. RPMH_REGULATOR_REG_ENABLE) seem to work on 8180:

https://lore.kernel.org/linux-arm-msm/[email protected]/

Konrad