[PATCH v30 1/3] mailbox: pcc: Type3 Buffer handles ACK IRQ

Adam Young posted 3 patches 1 month, 4 weeks ago
[PATCH v30 1/3] mailbox: pcc: Type3 Buffer handles ACK IRQ
Posted by Adam Young 1 month, 4 weeks ago
The PCC protocol type 3 requests include a field that indicates that the
recipient should trigger an interrupt once the message has been read
from the buffer. The sender uses this interrupt to know that a
transmission is complete, and it is safe to send additional messages.

Signed-off-by: Adam Young <admiyo@os.amperecomputing.com>

mailbox/pcc extended memory helper functions
---
 drivers/mailbox/pcc.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index f6714c233f5a..978a7b674946 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -306,6 +306,18 @@ static void pcc_chan_acknowledge(struct pcc_chan_info *pchan)
 		pcc_chan_reg_read_modify_write(&pchan->db);
 }
 
+static bool pcc_last_tx_done(struct mbox_chan *chan)
+{
+	struct pcc_chan_info *pchan = chan->con_priv;
+	u64 val;
+
+	pcc_chan_reg_read(&pchan->cmd_complete, &val);
+	if (!val)
+		return false;
+	else
+		return true;
+}
+
 /**
  * pcc_mbox_irq - PCC mailbox interrupt handler
  * @irq:	interrupt number
@@ -340,6 +352,14 @@ 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;
+
+	/**
+	 * The remote side sent an ack.
+	 */
+	if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE &&
+	    chan->active_req)
+		mbox_chan_txdone(chan, 0);
+
 	mbox_chan_received_data(chan, NULL);
 
 	pcc_chan_acknowledge(pchan);
@@ -490,6 +510,7 @@ static const struct mbox_chan_ops pcc_chan_ops = {
 	.send_data = pcc_send_data,
 	.startup = pcc_startup,
 	.shutdown = pcc_shutdown,
+	.last_tx_done = pcc_last_tx_done,
 };
 
 /**
-- 
2.43.0
Re: [PATCH v30 1/3] mailbox: pcc: Type3 Buffer handles ACK IRQ
Posted by Adam Young 1 month, 3 weeks ago
This is obsoleted/duplicated by Sudeep's patch.  I am going to rebase on 
his patch series.

On 10/16/25 17:02, Adam Young wrote:
> The PCC protocol type 3 requests include a field that indicates that the
> recipient should trigger an interrupt once the message has been read
> from the buffer. The sender uses this interrupt to know that a
> transmission is complete, and it is safe to send additional messages.
>
> Signed-off-by: Adam Young <admiyo@os.amperecomputing.com>
>
> mailbox/pcc extended memory helper functions
> ---
>   drivers/mailbox/pcc.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
> index f6714c233f5a..978a7b674946 100644
> --- a/drivers/mailbox/pcc.c
> +++ b/drivers/mailbox/pcc.c
> @@ -306,6 +306,18 @@ static void pcc_chan_acknowledge(struct pcc_chan_info *pchan)
>   		pcc_chan_reg_read_modify_write(&pchan->db);
>   }
>   
> +static bool pcc_last_tx_done(struct mbox_chan *chan)
> +{
> +	struct pcc_chan_info *pchan = chan->con_priv;
> +	u64 val;
> +
> +	pcc_chan_reg_read(&pchan->cmd_complete, &val);
> +	if (!val)
> +		return false;
> +	else
> +		return true;
> +}
> +
>   /**
>    * pcc_mbox_irq - PCC mailbox interrupt handler
>    * @irq:	interrupt number
> @@ -340,6 +352,14 @@ 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;
> +
> +	/**
> +	 * The remote side sent an ack.
> +	 */
> +	if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE &&
> +	    chan->active_req)
> +		mbox_chan_txdone(chan, 0);
> +
>   	mbox_chan_received_data(chan, NULL);
>   
>   	pcc_chan_acknowledge(pchan);
> @@ -490,6 +510,7 @@ static const struct mbox_chan_ops pcc_chan_ops = {
>   	.send_data = pcc_send_data,
>   	.startup = pcc_startup,
>   	.shutdown = pcc_shutdown,
> +	.last_tx_done = pcc_last_tx_done,
>   };
>   
>   /**
Re: [PATCH v30 1/3] mailbox: pcc: Type3 Buffer handles ACK IRQ
Posted by Sudeep Holla 1 month, 3 weeks ago
On Fri, Oct 17, 2025 at 12:08:07PM -0400, Adam Young wrote:
> This is obsoleted/duplicated by Sudeep's patch.  I am going to rebase on his
> patch series.
> 

Thanks for looking at them. Sorry we just cross posted each other last night.

-- 
Regards,
Sudeep
Re: [PATCH v30 1/3] mailbox: pcc: Type3 Buffer handles ACK IRQ
Posted by Adam Young 1 month, 3 weeks ago
No need to apologize.  Thank you for writing them. And you caught 
several things I had overlooked.

I have tested the whole patch series with both my MCTP driver and the 
CPPC drivers.  I will post an updated driver (with fixes) in the next 
few days.

On 10/17/25 13:42, Sudeep Holla wrote:
> On Fri, Oct 17, 2025 at 12:08:07PM -0400, Adam Young wrote:
>> This is obsoleted/duplicated by Sudeep's patch.  I am going to rebase on his
>> patch series.
>>
> Thanks for looking at them. Sorry we just cross posted each other last night.
>