Skip to contentSkip to conversation

mailbox: pcc: report errors for PCC clients

PATCH Superseded Adam Young 2 participants 2 messages May 15

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Adam Young

author
#0 lore raw

PATCH 1/1 mailbox: pcc: report errors for PCC clients

The tx_done callback function has a return code (rc) parameter that the tx_done callback can use to determine how to handle an error. However the IRQ handler was not setting that value if there is an error.

The following clients are affected:

drivers/acpi/cppc_acpi.c
drivers/i2c/busses/i2c-xgene-slimpro.c
drivers/hwmon/xgene-hwmon.c
drivers/soc/hisilicon/kunpeng_hccs.c
drivers/devfreq/hisi_uncore_freq.c

All of these only use the error code to report, so they are expecting an error code to come thorugh, but they do not modify behavior based on this code.

Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")

---

---
 drivers/mailbox/pcc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +5 -1
index 636879ae1db7..25650446cd2b 100644
@@ -314,6 +314,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
 {
 	struct pcc_chan_info *pchan;
 	struct mbox_chan *chan = p;
+	int rc;
 
 	pchan = chan->con_priv;
 
@@ -327,8 +328,11 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
 	if (!pcc_mbox_cmd_complete_check(pchan))
 		return IRQ_NONE;
 
-	if (pcc_mbox_error_check_and_clear(pchan))
+	rc = pcc_mbox_error_check_and_clear(pchan);
+	if (rc) {
+		mbox_chan_txdone(chan, rc);
 		return IRQ_NONE;
+	}
 
 	/*
 	 * Clear this flag after updating interrupt ack register and just
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] The error path fails to clear the `pchan->chan_in_use` flag, leading to state machine corruption…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The error path fails to clear the pchan->chan_in_use flag, leading to state machine corruption and spurious client callbacks.
- [High] The error path fails to acknowledge Slave Subspace notifications, which can permanently hang the channel.
- [High] The interrupt handler incorrectly returns IRQ_NONE after successfully handling a mailbox error condition, risking the disablement of the shared IRQ line. --

commit 8be35a18843a43d39fee5986fb5339b3f4e55c68
Author: Adam Young <[email protected]>

mailbox: pcc: report errors for PCC clients

This commit updates the PCC mailbox interrupt handler to pass the error code to the tx_done callback via mbox_chan_txdone() when a channel error is detected. This allows several clients to accurately report these errors.

Quoted 3 lines
drivers/mailbox/pcc.c +0 -0

[ ... ]

drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 334

Quoted 9 lines
drivers/mailbox/pcc.c +3 -1
@@ -327,8 +328,11 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
 	if (!pcc_mbox_cmd_complete_check(pchan))
 		return IRQ_NONE;
 
-	if (pcc_mbox_error_check_and_clear(pchan))
+	rc = pcc_mbox_error_check_and_clear(pchan);
+	if (rc) {
+		mbox_chan_txdone(chan, rc);
 		return IRQ_NONE;

Since the early return is taken when an error occurs, does this code need to clear pchan->chan_in_use? If it remains true while the channel is idle, could the next interrupt on a shared IRQ line bypass the !pchan->chan_in_use filter, incorrectly evaluate cmd_complete as true, and spuriously call mbox_chan_received_data() with phantom data?

Also, for PCC Slave Subspaces, the platform sends asynchronous notifications that must be acknowledged. By returning early, this path skips calling pcc_chan_acknowledge(pchan). Can this leave the command unacknowledged and hang the Slave Subspace if the platform stops sending notifications?

Finally, since pcc_mbox_error_check_and_clear() clears the hardware error register, it confirms the device legitimately generated the interrupt. Does returning IRQ_NONE here risk having the kernel's spurious interrupt detector eventually disable the shared IRQ line if this error path is triggered repeatedly?

Quoted 4 lines
drivers/mailbox/pcc.c +1 -0
+	}
 
 	/*
 	 * Clear this flag after updating interrupt ack register and just
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1