mailbox: pcc: report errors for PCC clients
Subsystems (4)
PATCH v2 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/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.
In the case of an error code in the IRQ, the handler was returning IRQ_NONE which is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.
In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mailbox/pcc.c +5 -4
@@ -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,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);/* * Clear this flag after updating interrupt ack register and just
@@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL ); +mbox_chan_txdone (chan, rc);pcc_chan_acknowledge (pchan);
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Clients relying on `rx_callback` for completion will timeout on error because…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Clients relying on rx_callback for completion will timeout on error because mbox_chan_received_data is skipped.
- [High] Slave subspace (Type 4) messages from the platform are silently dropped and acknowledged on error.
- [Medium] Positive ACPI status codes are leaked into the mailbox framework as error codes.
--
commit 02ebdabd8b273de3b908d80f12b3a4d373284736
Author: Adam Young <[email protected]>
mailbox: pcc: report errors for PCC clients
The commit modifies the PCC mailbox IRQ handler to read the error status and pass it to the tx_done callback. It also skips the receive callback if an error occurred.
Quoted 4 lines
drivers/mailbox/pcc.c +0
-0
[ ... ]
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 331
Quoted 7 lines
drivers/mailbox/pcc.c +1
-2@@ -327,8 +328,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);
Can pcc_mbox_error_check_and_clear() return a positive acpi_status value (like AE_ERROR) if pcc_chan_reg_read() fails?
If so, this positive value would be passed to mbox_chan_txdone(), which might cause issues for clients that check if the returned error is less than zero.
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 341
Quoted 11 lines
drivers/mailbox/pcc.c +2
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL );
Since clients like drivers/acpi/cppc_acpi.c and drivers/soc/hisilicon/kunpeng_hccs.c rely on rx_callback (invoked by mbox_chan_received_data()) to signal their completions, will skipping it here cause them to block until their timeout expires instead of processing the error?
For ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE channels used by the platform to send notifications to the OS, does skipping mbox_chan_received_data() cause the OS to silently drop the platform's notification?
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 344
Quoted 3 lines
drivers/mailbox/pcc.c +1
-0+mbox_chan_txdone (chan, rc);pcc_chan_acknowledge (pchan);
If a slave subspace notification is dropped due to an error, does calling pcc_chan_acknowledge() falsely indicate to the platform that the notification was successfully handled?
Quoted 1 line
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 30 lines · On 5/18/26 16:35, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Clients relying onrx_callbackfor completion will timeout on error becausembox_chan_received_datais skipped.
- [High] Slave subspace (Type 4) messages from the platform are silently dropped and acknowledged on error.
- [Medium] Positive ACPI status codes are leaked into the mailbox framework as error codes.
--commit
02ebdabd8b273de3b908d80f12b3a4d373284736
Author: Adam Young <[email protected]>mailbox: pcc: report errors for PCC clients
The commit modifies the PCC mailbox IRQ handler to read the error status and pass it to the
tx_donecallback. It also skips the receive callback if an error occurred.Quoted 4 lines
drivers/mailbox/pcc.c +0
-0[ ... ]
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 331
Quoted 7 lines
drivers/mailbox/pcc.c +1
-2@@ -327,8 +328,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);Can
pcc_mbox_error_check_and_clear()return a positiveacpi_statusvalue (likeAE_ERROR) ifpcc_chan_reg_read()fails?
Quoted 3 lines
If so, this positive value would be passed to
mbox_chan_txdone(), which might cause issues for clients that check if the returned error is less than zero.
Anything is possible. It depends on what the PCC endpoint put in the register. Right now, the value is ignored, and only used for error reporting, which never happens.
Quoted 17 lines
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 341
Quoted 12 lines
drivers/mailbox/pcc.c +2
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL );Since clients like
drivers/acpi/cppc_acpi.canddrivers/soc/hisilicon/kunpeng_hccs.crely onrx_callback(invoked bymbox_chan_received_data()) to signal their completions, will skipping it here cause them to block until their timeout expires instead of processing the error?
It is the same path as what happened before the change. So they would not have gotten the error passed to them.
Quoted 4 lines
For
ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACEchannels used by the platform to send notifications to the OS, does skippingmbox_chan_received_data()cause the OS to silently drop the platform's notification?
That is what happens now.
Quoted 7 lines
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 344
Quoted 4 lines
drivers/mailbox/pcc.c +1
-0+mbox_chan_txdone (chan, rc);pcc_chan_acknowledge (pchan);If a slave subspace notification is dropped due to an error, does calling
pcc_chan_acknowledge()falsely indicate to the platform that the notification was successfully handled?
All it says is that the error was processed. If this is not returned to the caller, the caller will never send another message.
Quoted 1 line
Sudeep Holla
maintainerQuoted 45 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")Signed-off-by Adam Young <[email protected]>---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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;
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 331
Quoted 6 lines
drivers/mailbox/pcc.c +1
-2@@ -327,8 +328,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);
I think we may have to skip the check inside pcc_mbox_error_check_and_clear() for Type 4 channel as the spec expects OSPM to ignore it. It is a separate fix, just noting that here.
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 341
Quoted 11 lines
drivers/mailbox/pcc.c +2
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL );
Not sure if making this conditional is good as some platforms may expect it to move the state machine, I am not sure 100% just thinking aloud here.
Signature · 2 lines
Regards, Sudeep
I am geting ready to resubmit this patch along with a series of other PCC based changes that show how it is necessary
for MCTP-PCC.
Quoted 49 lines · Sudeep Holla
Quoted 48 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")Signed-off-by Adam Young <[email protected]>---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)if (!pcc_mbox_cmd_complete_check (pchan))return IRQ_NONE ;
Quoted 6 lines
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 331
Quoted 3 lines
drivers/mailbox/pcc.c +1
-2-if (pcc_mbox_error_check_and_clear (pchan)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);I think we may have to skip the check inside
pcc_mbox_error_check_and_clear()for Type 4 channel as the spec expects OSPM to ignore it. It is a separate fix, just noting that here.
I will submit this as a pre-req patch.
Quoted 14 lines
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 341
Quoted 12 lines
drivers/mailbox/pcc.c +2
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL );Not sure if making this conditional is good as some platforms may expect it to move the state machine, I am not sure 100% just thinking aloud here.
That is currently not the case. Right now, and error code short-circuits and further execution of the IRC handler. I think that those drivers would need to be changes to have a tx_done callback instead.
Quoted 1 line
Quoted 49 lines · Sudeep Holla
Quoted 48 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")Signed-off-by Adam Young <[email protected]>---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)if (!pcc_mbox_cmd_complete_check (pchan))return IRQ_NONE ;
Quoted 6 lines
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 331
Quoted 3 lines
drivers/mailbox/pcc.c +1
-2-if (pcc_mbox_error_check_and_clear (pchan)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);I think we may have to skip the check inside
pcc_mbox_error_check_and_clear()for Type 4 channel as the spec expects OSPM to ignore it. It is a separate fix, just noting that here.
I think that should be in this patch, for correctness. It is a small enough change. I'll update.
Quoted 14 lines
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 341
Quoted 12 lines
drivers/mailbox/pcc.c +2
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL );Not sure if making this conditional is good as some platforms may expect it to move the state machine, I am not sure 100% just thinking aloud here.
They don't do that now. If the RC is non-zero there is no call to mbox_chan_received_data, it just short circuits above, so I do not see how we could break something that is currently working by bypassing the mbox_chan_received_data, whereas by not-skipping it, we will trigger the call, and that will likely not handle the error. I think we need to skip it.
Quoted 55 lines · Adam Young
Quoted 44 lines · Sudeep Holla
Quoted 43 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")Signed-off-by Adam Young <[email protected]>---
---
drivers/mailbox/pcc.c| 9 +++++----1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)Quoted 8 lines
Quoted 5 lines
drivers/mailbox/pcc.c +0
-0if (!pcc_mbox_cmd_complete_check(pchan))return
IRQ_NONE;
- if (pcc_mbox_error_check_and_clear(pchan))
- returnIRQ_NONE;
+ rc =pcc_mbox_error_check_and_clear(pchan);I think we may have to skip the check inside
pcc_mbox_error_check_and_clear()for Type 4 channel as the spec expects OSPM to ignore it. It is a separate fix, just noting that here.
Quoted 2 lines
I think that should be in this patch, for correctness. It is a small enough change. I'll update.
Actually, it is a fix in its own right, and can be merged regardless of this patch, so:
https://lore.kernel.org/lkml/[email protected]/
Quoted 21 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.
Quoted 4 lines
In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")
Not fix above commit.mbox_chan_txdone() was added in below patch.
Quoted 20 lines
Signed-off-by Adam Young <[email protected]>---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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;
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 331
Quoted 6 lines
drivers/mailbox/pcc.c +1
-2@@ -327,8 +328,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);
I think it is not necessary. This function just return -EIO on failure.
drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 342
Quoted 12 lines
drivers/mailbox/pcc.c +3
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL ); +mbox_chan_txdone (chan, rc);
@Sudeep, I have always had doubts about the addition of this line of code in the
commit 9c753f7c953c (mailbox: pcc: Mark Tx as complete in PCC IRQ handler).
The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to call mbox_chan_txdone() to tell mailbox core. This is done after executing mbox_chan_received_data(). So I think this line in this function is redundant.
Can you take a look at this agian?
Quoted 3 lines
drivers/mailbox/pcc.c +0
-0pcc_chan_acknowledge (pchan);
Sudeep Holla
maintainerQuoted 67 lines · lihuisong (C)
Quoted 21 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.Quoted 4 lines
In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")Not fix above commit.
mbox_chan_txdone()was added in below patch.Fixes 9c753f7c953c (mailbox: pcc: Mark Tx as complete in PCC IRQ handler)Quoted 18 lines
Signed-off-by Adam Young <[email protected]>---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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;drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 330
Quoted 5 lines
drivers/mailbox/pcc.c +1
-2@@ -327,8 +328,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);I think it is not necessary. This function just return
-EIOon failure.drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 342
Quoted 11 lines
drivers/mailbox/pcc.c +3
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL ); +mbox_chan_txdone (chan, rc);
Quoted 8 lines
@Sudeep, I have always had doubts about the addition of this line of code in the
commit9c753f7c953c(mailbox: pcc: Mark Tx as complete in PCC IRQ handler). The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to callmbox_chan_txdone()to tell mailbox core.
Few controller drivers do have mbox_chan_txdone(), so Tx complete is detected by PCC, so not sure why you think this is not the right place to do. The irq is to indicate the completion. I am confused as why you think otherwise. It is defined in include/linux/mailbox_controller.h for the same reason.
The client drivers can you mbox_client_txdone() if they wish to as defined in include/linux/mailbox_client.h
Quoted 2 lines
This is done after executing
mbox_chan_received_data(). So I think this line in this function is redundant.
No, I think otherwise, see details above.
Signature · 2 lines
Regards, Sudeep
Quoted 74 lines · Sudeep Holla
Quoted 65 lines · lihuisong (C)
Quoted 21 lines · Adam Young
The
tx_donecallback function has a return code (rc) parameter that thetx_donecallback 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.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/hwmon/xgene-hwmon.cdrivers/soc/hisilicon/kunpeng_hccs.cdrivers/devfreq/hisi_uncore_freq.cAll 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.
In the case of an error code in the IRQ, the handler was returning
IRQ_NONEwhich is not correct: the IRQ handler was matched to the IRQ. This mean that multiple error codes returned from a PCC triggered interrupt would end up disabling the device.Quoted 4 lines
In addition, if the error code IRQ was coming from a Type4 Device that was expecting an IRQ response, that device would then be hung.
Fixes c45ded7e1135 ("mailbox: pcc: Add support for PCCT extended PCC subspaces(type 3/4)")Not fix above commit.
mbox_chan_txdone()was added in below patch.Fixes 9c753f7c953c (mailbox: pcc: Mark Tx as complete in PCC IRQ handler)Quoted 18 lines
Signed-off-by Adam Young <[email protected]>---
--- drivers/mailbox/pcc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/mailbox/pcc.c +1
-0@@ -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;drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 330
Quoted 5 lines
drivers/mailbox/pcc.c +1
-2@@ -327,8 +328,7 @@ 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)) -return IRQ_NONE ; + rc =pcc_mbox_error_check_and_clear (pchan);I think it is not necessary. This function just return
-EIOon failure.drivers/mailbox/pcc.c static irqreturn_t pcc_mbox_irq(int irq, void *p) · line 342
Quoted 11 lines
drivers/mailbox/pcc.c +3
-2/* * Clear this flag after updating interrupt ack register and just @@ -337,8 +337,9 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)* required to avoid any possible race in updatation of this flag. */ pchan->chan_in_use = false; -mbox_chan_received_data (chan,NULL ); -mbox_chan_txdone (chan,0 ); +if (!rc) +mbox_chan_received_data (chan,NULL ); +mbox_chan_txdone (chan, rc);Quoted 8 lines
@Sudeep, I have always had doubts about the addition of this line of code in the
commit9c753f7c953c(mailbox: pcc: Mark Tx as complete in PCC IRQ handler).
The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to callmbox_chan_txdone()to tell mailbox core.
Quoted 1 line
Few controller drivers do have
mbox_chan_txdone(), so Tx complete is detected
Which controller driver?
Quoted 1 line
by PCC, so not sure why you think this is not the right place to do. The irq
Because many mbox client drivers call mbox_chan_txdone() after running rx_callback() in mbox_chan_received_data(). These drivers doesn't set chan->cl->tx_block to true.
It seems that the client driver having tx_block need to set chan->tx_complete in tx_tick().
Do you add this code for them?
Quoted 5 lines
is to indicate the completion. I am confused as why you think otherwise. It is defined in
include/linux/mailbox_controller.hfor the same reason.The client drivers can you
mbox_client_txdone()if they wish to as defined ininclude/linux/mailbox_client.h
mbox_client_txdone() is used in the case that txdone_method is MBOX_TXDONE_BY_ACK. And mbox clinte driver using IRQ method need to use mbox_chan_txdone(). It seems that all the current client drivers are used in this way. These interface internal would verify chan->txdone_method.
In addition, I find that you also modify the txdone_irq/poll in the commit 3349f800609e (mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). The txdone_method will change from MBOX_TXDONE_BY_ACK to MBOX_TXDONE_BY_POLL on the platform using poll mode.
This may lead to the original mbox client driver printing exceptions in mbox_client_txdone.
I haven't observed it based on the latest code yet, it's just code analysis.
Quoted 5 lines
Quoted 3 lines
This is done after executing
mbox_chan_received_data(). So I think this line in this function is redundant.No, I think otherwise, see details above.
Sudeep Holla
maintainerQuoted 3 lines · lihuisong (C)
Quoted 1 line · Sudeep Holla
On Tue, May 19, 2026 at 09:54:47PM +0800, lihuisong (C) wrote:
[...]
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
@Sudeep, I have always had doubts about the addition of this line of code in the
commit9c753f7c953c(mailbox: pcc: Mark Tx as complete in PCC IRQ handler).
The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to callmbox_chan_txdone()to tell mailbox core.Few controller drivers do have
mbox_chan_txdone(), so Tx complete is detectedWhich controller driver?
git grep mbox_chan_txdone drivers/mailbox/
Quoted 3 lines
Quoted 1 line
by PCC, so not sure why you think this is not the right place to do. The irq
Because many mbox client drivers call
mbox_chan_txdone()after runningrx_callback()inmbox_chan_received_data().
OK, but why can't the controller hide that for the clients ? What am I missing?
Quoted 4 lines
These drivers doesn't set
chan->cl->tx_blockto true. It seems that the client driver havingtx_blockneed to setchan->tx_completeintx_tick().
Do you add this code for them?
I don't quite follow you.
Quoted 7 lines
Quoted 5 lines
is to indicate the completion. I am confused as why you think otherwise. It is defined in
include/linux/mailbox_controller.hfor the same reason.The client drivers can you
mbox_client_txdone()if they wish to as defined ininclude/linux/mailbox_client.hmbox_client_txdone() is used in the case that
txdone_methodisMBOX_TXDONE_BY_ACK.
Yes and agreed.
Quoted 1 line
And mbox clinte driver using IRQ method need to use
mbox_chan_txdone().
Client doesn't handle IRQ its always controller driver and client must have no business to do that IMO.
Quoted 3 lines
It seems that all the current client drivers are used in this way. These interface internal would verify
chan->txdone_method.
Yes, sounds wrong to me.
drivers/acpi/acpi_pcc.cdrivers/acpi/cppc_acpi.cdrivers/hwmon/xgene-hwmon.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/soc/hisilicon/kunpeng_hccs.c
It is very clear from the code in mailbox.c, mbox_client_txdone() is for the client drivers and mbox_chan_txdone() is for the controller. We need to fix the above list but I need to check if there is anything I am missing to understand first. Please let me know.
Quoted 7 lines
In addition, I find that you also modify the txdone_irq/poll in the commit
3349f800609e(mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). Thetxdone_methodwill change fromMBOX_TXDONE_BY_ACKtoMBOX_TXDONE_BY_POLLon the platform using poll mode.
This may lead to the original mbox client driver printing exceptions inmbox_client_txdone.
I haven't observed it based on the latest code yet, it's just code analysis.
Right, I do remember seeing something and wonder if I moved to mbox_chan_txdone() in drivers/acpi/acpi_pcc.c for that reason. But if the expectations I have mentioned are correct, then we need to fix the framework to avoid throwing that warnings.
Signature · 2 lines
Regards, Sudeep
Quoted 13 lines · Sudeep Holla
Quoted 2 lines · lihuisong (C)
Quoted 1 line · Sudeep Holla
On Tue, May 19, 2026 at 09:54:47PM +0800, lihuisong (C) wrote:
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
@Sudeep, I have always had doubts about the addition of this line of code in the
commit9c753f7c953c(mailbox: pcc: Mark Tx as complete in PCC IRQ handler).
The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to callmbox_chan_txdone()to tell mailbox core.
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
Few controller drivers do have
mbox_chan_txdone(), so Tx complete is detectedWhich controller driver?
git grep
mbox_chan_txdonedrivers/mailbox/
Ok
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
by PCC, so not sure why you think this is not the right place to do. The irq
Because many mbox client drivers call
mbox_chan_txdone()after runningrx_callback()inmbox_chan_received_data().OK, but why can't the controller hide that for the clients ? What am I missing?
Now I know what you want to do.
It's ok for me to do that in controller on irq scene.
But we also need to fix the mbox_chan_txdone() code in all client drivers.
Quoted 6 lines
Quoted 5 lines
These drivers doesn't set
chan->cl->tx_blockto true. It seems that the client driver havingtx_blockneed to setchan->tx_completeintx_tick().
Do you add this code for them?I don't quite follow you.
please ship this.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
is to indicate the completion. I am confused as why you think otherwise. It is defined in
include/linux/mailbox_controller.hfor the same reason.The client drivers can you
mbox_client_txdone()if they wish to as defined ininclude/linux/mailbox_client.h
Quoted 7 lines
Quoted 2 lines
mbox_client_txdone() is used in the case that
txdone_methodisMBOX_TXDONE_BY_ACK.Yes and agreed.
Quoted 1 line
And mbox clinte driver using IRQ method need to use
mbox_chan_txdone().Client doesn't handle IRQ its always controller driver and client must have no business to do that IMO.
Ackmbox_chan_txdone should be used by controller as this function comment said.
Quoted 12 lines
Quoted 4 lines
It seems that all the current client drivers are used in this way. These interface internal would verify
chan->txdone_method.Yes, sounds wrong to me.
drivers/acpi/acpi_pcc.cdrivers/acpi/cppc_acpi.cdrivers/hwmon/xgene-hwmon.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/soc/hisilicon/kunpeng_hccs.c
Quoted 4 lines
It is very clear from the code in
mailbox.c,mbox_client_txdone()is for the client drivers andmbox_chan_txdone()is for the controller. We need to fix the above list but I need to check if there is anything I am missing to understand first. Please let me know.
Agreed.
Quoted 8 lines
Quoted 8 lines
In addition, I find that you also modify the txdone_irq/poll in the commit
3349f800609e(mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). Thetxdone_methodwill change fromMBOX_TXDONE_BY_ACKtoMBOX_TXDONE_BY_POLLon the platform using poll mode.
This may lead to the original mbox client driver printing exceptions inmbox_client_txdone.
I haven't observed it based on the latest code yet, it's just code analysis.
Quoted 4 lines
Right, I do remember seeing something and wonder if I moved to
mbox_chan_txdone()indrivers/acpi/acpi_pcc.cfor that reason. But if the expectations I have mentioned are correct, then we need to fix the framework to avoid throwing that warnings.
Yeah, we also need to do something for your another commit 3349f800609e (mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags).
Quoted 1 line
I am not getting li hui song's messages, only your (Sudeep's) responses.
Quoted 13 lines · Sudeep Holla
Quoted 2 lines · lihuisong (C)
Quoted 1 line · Sudeep Holla
On Tue, May 19, 2026 at 09:54:47PM +0800, lihuisong (C) wrote:
[...]
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
@Sudeep, I have always had doubts about the addition of this line of code in the
commit9c753f7c953c(mailbox: pcc: Mark Tx as complete in PCC IRQ handler).
The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to callmbox_chan_txdone()to tell mailbox core.
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
Few controller drivers do have
mbox_chan_txdone(), so Tx complete is detectedWhich controller driver?
git grep
mbox_chan_txdonedrivers/mailbox/
These are the only drivers that have a callback defined so far. IN all cases, they are only doing error reporting, but no change of behavior.
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
Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
by PCC, so not sure why you think this is not the right place to do. The irq
Because many mbox client drivers call
mbox_chan_txdone()after runningrx_callback()inmbox_chan_received_data().OK, but why can't the controller hide that for the clients ? What am I missing?
Quoted 4 lines
These drivers doesn't set
chan->cl->tx_blockto true. It seems that the client driver havingtx_blockneed to setchan->tx_completeintx_tick().
Do you add this code for them?I don't quite follow you.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
is to indicate the completion. I am confused as why you think otherwise. It is defined in
include/linux/mailbox_controller.hfor the same reason.The client drivers can you
mbox_client_txdone()if they wish to as defined ininclude/linux/mailbox_client.hmbox_client_txdone() is used in the case that
txdone_methodisMBOX_TXDONE_BY_ACK.Yes and agreed.
I could make this path conditional on that being set. Something like:
rc = pcc_mbox_error_check_and_clear(pchan);
if (rc && chan->txdone_method & MBOX_TXDONE_BY_POLL) - return IRQ_NONE;
Which lets the ACK and IRQ paths continue.
Quoted 4 lines
Quoted 2 lines
And mbox clinte driver using IRQ method need to use
mbox_chan_txdone().Client doesn't handle IRQ its always controller driver and client must have no business to do that IMO.
IN the PCC case, an error in handling a packet (PCC message) is returned in the error register and read during the IRQ response. That error message needs to propagate to the MCTP network driver so it can free up the SKB and not leak memory. We cannot free it before that point as it is still in the rbuf/active_request pointer.
Quoted 29 lines
Quoted 4 lines
It seems that all the current client drivers are used in this way. These interface internal would verify
chan->txdone_method.Yes, sounds wrong to me.
drivers/acpi/acpi_pcc.cdrivers/acpi/cppc_acpi.cdrivers/hwmon/xgene-hwmon.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/soc/hisilicon/kunpeng_hccs.cIt is very clear from the code in
mailbox.c,mbox_client_txdone()is for the client drivers andmbox_chan_txdone()is for the controller. We need to fix the above list but I need to check if there is anything I am missing to understand first. Please let me know.Quoted 7 lines
In addition, I find that you also modify the txdone_irq/poll in the commit
3349f800609e(mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). Thetxdone_methodwill change fromMBOX_TXDONE_BY_ACKtoMBOX_TXDONE_BY_POLLon the platform using poll mode.
This may lead to the original mbox client driver printing exceptions inmbox_client_txdone.
I haven't observed it based on the latest code yet, it's just code analysis.Right, I do remember seeing something and wonder if I moved to
mbox_chan_txdone()indrivers/acpi/acpi_pcc.cfor that reason. But if the expectations I have mentioned are correct, then we need to fix the framework to avoid throwing that warnings.
Quoted 22 lines · Adam Young
I am not getting li hui song's messages, only your (Sudeep's) responses.
Quoted 14 lines · Sudeep Holla
Quoted 2 lines · lihuisong (C)
Quoted 1 line · Sudeep Holla
On Tue, May 19, 2026 at 09:54:47PM +0800, lihuisong (C) wrote:
[...]
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
@Sudeep, I have always had doubts about the addition of this line of code in
the
commit9c753f7c953c(mailbox: pcc: Mark Tx as complete in PCC IRQ handler). The patch seems to avoid the timeouts in the mailbox core according to its commit log.
Regardless of whether the command succeeds or fails, each mbox client driver, like cppc_acpi/acpi_pcc,kunpeng_hccs and so on, is responsible to callmbox_chan_txdone()to tell mailbox core.Quoted 3 lines
Quoted 2 lines
Quoted 1 line
Few controller drivers do have
mbox_chan_txdone(), so Tx complete is detectedWhich controller driver?
git grep
mbox_chan_txdonedrivers/mailbox/
Quoted 9 lines
These are the only drivers that have a callback defined so far. IN all cases, they are only doing error reporting, but no change of behavior.
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
Need to cleanup for these driver without introducing other issues.
Quoted 22 lines
Quoted 13 lines
Quoted 5 lines
Quoted 3 lines
by PCC, so not sure why you think this is not the right place to do. The irq
Because many mbox client drivers call
mbox_chan_txdone()after runningrx_callback()inmbox_chan_received_data().OK, but why can't the controller hide that for the clients ? What am I missing?
Quoted 4 lines
These drivers doesn't set
chan->cl->tx_blockto true. It seems that the client driver havingtx_blockneed to setchan->tx_completeintx_tick().
Do you add this code for them?I don't quite follow you.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
is to indicate the completion. I am confused as why you think otherwise. It is defined in
include/linux/mailbox_controller.hfor the same reason.The client drivers can you
mbox_client_txdone()if they wish to as defined ininclude/linux/mailbox_client.hmbox_client_txdone() is used in the case that
txdone_methodisMBOX_TXDONE_BY_ACK.Yes and agreed.
Quoted 8 lines
I could make this path conditional on that being set. Something like:
rc =
pcc_mbox_error_check_and_clear(pchan);if (rc && chan->txdone_method &
MBOX_TXDONE_BY_POLL) - returnIRQ_NONE;Which lets the ACK and IRQ paths continue.
Client using POLL doesn't reach this code.
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
And mbox clinte driver using IRQ method need to use
mbox_chan_txdone().Client doesn't handle IRQ its always controller driver and client must have no business to do that IMO.
IN the PCC case, an error in handling a packet (PCC message) is returned in the error register and read during the IRQ response. That error message needs to propagate to the MCTP network driver so it can free up the SKB and not leak memory. We cannot free it before that point as it is still in the rbuf/active_request pointer.
The direction you said should be Tx, right?
I understand that your driver needs to wait for this message to be processed.
If the driver does not wait for the message, driver will receive timeout and can instruct to release the SKB.
Quoted 31 lines
Quoted 30 lines
Quoted 5 lines
It seems that all the current client drivers are used in this way. These interface internal would verify
chan->txdone_method.Yes, sounds wrong to me.
drivers/acpi/acpi_pcc.cdrivers/acpi/cppc_acpi.cdrivers/hwmon/xgene-hwmon.cdrivers/i2c/busses/i2c-xgene-slimpro.cdrivers/soc/hisilicon/kunpeng_hccs.cIt is very clear from the code in
mailbox.c,mbox_client_txdone()is for the client drivers andmbox_chan_txdone()is for the controller. We need to fix the above list but I need to check if there is anything I am missing to understand first. Please let me know.Quoted 7 lines
In addition, I find that you also modify the txdone_irq/poll in the commit
3349f800609e(mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). Thetxdone_methodwill change fromMBOX_TXDONE_BY_ACKtoMBOX_TXDONE_BY_POLLon the platform using poll mode.
This may lead to the original mbox client driver printing exceptions inmbox_client_txdone.
I haven't observed it based on the latest code yet, it's just code analysis.Right, I do remember seeing something and wonder if I moved to
mbox_chan_txdone()indrivers/acpi/acpi_pcc.cfor that reason. But if the expectations I have mentioned are correct, then we need to fix the framework to avoid throwing that warnings.