Skip to contentSkip to conversation

mailbox: pcc: Notify clients on polled completion

PATCH Superseded Sudeep Holla 2 participants 5 messages Jun 12 – Jun 23

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sudeep Holla

author maintainer
#0 lore raw

PATCH 1/1 mailbox: pcc: Notify clients on polled completion

PCC channels without a platform interrupt rely on the mailbox polling path to detect command completion.

That path currently only reports transmit completion to the mailbox core, so clients that wait for their receive callback do not get notified when the command completes.

Call mbox_chan_received_data() when polling observes completion on a channel without a platform IRQ, matching the interrupt-driven completion path.

---
 drivers/mailbox/pcc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +6 -1
index 636879ae1db7..7c9451ab4527 100644
@@ -447,9 +447,14 @@ static int pcc_send_data(struct mbox_chan *chan, void *data)
 
 static bool pcc_last_tx_done(struct mbox_chan *chan)
 {
+	bool ret;
 	struct pcc_chan_info *pchan = chan->con_priv;
 
-	return pcc_mbox_cmd_complete_check(pchan);
+	ret = pcc_mbox_cmd_complete_check(pchan);
+	if (ret && !pchan->plat_irq)
+		mbox_chan_received_data(chan, NULL);
+
+	return ret;
 }
 
 /**
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw

Hi Sudeep,

Quoted 25 lines · Sudeep Holla

PCC channels without a platform interrupt rely on the mailbox polling path to detect command completion.

That path currently only reports transmit completion to the mailbox core, so clients that wait for their receive callback do not get notified when the command completes.

Call mbox_chan_received_data() when polling observes completion on a channel without a platform IRQ, matching the interrupt-driven completion path.

---
  drivers/mailbox/pcc.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +0 -0
index 636879ae1db7..7c9451ab4527 100644
@@ -447,9 +447,14 @@ static int pcc_send_data(struct mbox_chan *chan, void *data)
 
  static bool pcc_last_tx_done(struct mbox_chan *chan)
  {

drivers/mailbox/pcc.c static int pcc_send_data(struct mbox_chan *chan, void *data) · line 458

Quoted 10 lines
drivers/mailbox/pcc.c +6 -1
+	bool ret;
  	struct pcc_chan_info *pchan = chan->con_priv;
 
-	return pcc_mbox_cmd_complete_check(pchan);
+	ret = pcc_mbox_cmd_complete_check(pchan);
+	if (ret && !pchan->plat_irq)
+		mbox_chan_received_data(chan, NULL);
+
+	return ret;
  }

The mailbox_controller.h said that .last_tx_done() is used only if txdone_poll:=true && txdone_irq:=false.
How about add a verification at the begining of this function? like "if (chan->txdone_method != MBOX_TXDONE_BY_POLL) return false;" And then call mbox_chan_received_data() directly if command completed.

This patch is ok to me if has above changes.

But pcc mbox controller can no longer work in MBOX_TXDONE_BY_ACK after your commit:
3349f800609e (mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags).
This may lead to above client drivers fail to send mailbox command, like cppc_acpi,hisi_uncore_freq and kunpeng_hccs. Because these client driver knows tx_done(knows_txdone: true), work on this mode and need to call mbox_client_txdone. Do you have some idea for this?

Quoted 2 lines
drivers/mailbox/pcc.c +0 -0
  /**
author maintainer
#2 lore raw
Quoted 33 lines · lihuisong (C)

Hi Sudeep,

Quoted 30 lines · Sudeep Holla

PCC channels without a platform interrupt rely on the mailbox polling path to detect command completion.

That path currently only reports transmit completion to the mailbox core, so clients that wait for their receive callback do not get notified when the command completes.

Call mbox_chan_received_data() when polling observes completion on a channel without a platform IRQ, matching the interrupt-driven completion path.

---
  drivers/mailbox/pcc.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +4 -1
index 636879ae1db7..7c9451ab4527 100644
@@ -447,9 +447,14 @@ static int pcc_send_data(struct mbox_chan *chan, void *data)
  static bool pcc_last_tx_done(struct mbox_chan *chan)
  {
+	bool ret;
  	struct pcc_chan_info *pchan = chan->con_priv;
-	return pcc_mbox_cmd_complete_check(pchan);
+	ret = pcc_mbox_cmd_complete_check(pchan);
+	if (ret && !pchan->plat_irq)
+		mbox_chan_received_data(chan, NULL);
Quoted 9 lines

drivers/mailbox/pcc.c static int pcc_send_data(struct mbox_chan *chan, void *data) · line 458

Quoted 3 lines
drivers/mailbox/pcc.c +2 -0
+
+	return ret;
  }

The mailbox_controller.h said that .last_tx_done() is used only if txdone_poll:=true && txdone_irq:=false.
How about add a verification at the begining of this function? like "if (chan->txdone_method != MBOX_TXDONE_BY_POLL) return false;" And then call mbox_chan_received_data() directly if command completed.

Thanks, it does makes sense to me. I will have look.

Quoted 4 lines

This patch is ok to me if has above changes.

Quoted 8 lines

But pcc mbox controller can no longer work in MBOX_TXDONE_BY_ACK after your commit:
3349f800609e (mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). This may lead to above client drivers fail to send mailbox command, like cppc_acpi,hisi_uncore_freq and kunpeng_hccs.
Because these client driver knows tx_done(knows_txdone: true), work on this mode and need to call mbox_client_txdone.
Do you have some idea for this?

I wonder if we can ask the platform to avoid generating interrupts in those case by setting/clearing "Notify on completion" in shmem. Do you think that would work ?

Signature · 2 lines
Regards,
Sudeep
#3 lore raw
Quoted 57 lines · Sudeep Holla
Quoted 33 lines · lihuisong (C)

Hi Sudeep,

Quoted 30 lines · Sudeep Holla

PCC channels without a platform interrupt rely on the mailbox polling path to detect command completion.

That path currently only reports transmit completion to the mailbox core, so clients that wait for their receive callback do not get notified when the command completes.

Call mbox_chan_received_data() when polling observes completion on a channel without a platform IRQ, matching the interrupt-driven completion path.

---
   drivers/mailbox/pcc.c | 7 ++++++-
   1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +4 -1
index 636879ae1db7..7c9451ab4527 100644
@@ -447,9 +447,14 @@ static int pcc_send_data(struct mbox_chan *chan, void *data)
   static bool pcc_last_tx_done(struct mbox_chan *chan)
   {
+	bool ret;
   	struct pcc_chan_info *pchan = chan->con_priv;
-	return pcc_mbox_cmd_complete_check(pchan);
+	ret = pcc_mbox_cmd_complete_check(pchan);
+	if (ret && !pchan->plat_irq)
+		mbox_chan_received_data(chan, NULL);
Quoted 9 lines

drivers/mailbox/pcc.c static int pcc_send_data(struct mbox_chan *chan, void *data) · line 458

Quoted 3 lines
drivers/mailbox/pcc.c +2 -0
+
+	return ret;
   }

The mailbox_controller.h said that .last_tx_done() is used only if txdone_poll:=true && txdone_irq:=false.
How about add a verification at the begining of this function? like "if (chan->txdone_method != MBOX_TXDONE_BY_POLL) return false;" And then call mbox_chan_received_data() directly if command completed.

Thanks, it does makes sense to me. I will have look.

Quoted 4 lines

This patch is ok to me if has above changes.

Quoted 8 lines

But pcc mbox controller can no longer work in MBOX_TXDONE_BY_ACK after your commit:
3349f800609e (mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). This may lead to above client drivers fail to send mailbox command, like cppc_acpi,hisi_uncore_freq and kunpeng_hccs.
Because these client driver knows tx_done(knows_txdone: true), work on this mode and need to call mbox_client_txdone.
Do you have some idea for this?

Quoted 3 lines

I wonder if we can ask the platform to avoid generating interrupts in those case by setting/clearing "Notify on completion" in shmem. Do you think that would work ?

These drivers didn't work on interrupt mode.
They poll the complete status of command.

Quoted 1 line
#4 lore raw
In reply to Sudeep Holla
Quoted 57 lines · Sudeep Holla
Quoted 33 lines · lihuisong (C)

Hi Sudeep,

Quoted 30 lines · Sudeep Holla

PCC channels without a platform interrupt rely on the mailbox polling path to detect command completion.

That path currently only reports transmit completion to the mailbox core, so clients that wait for their receive callback do not get notified when the command completes.

Call mbox_chan_received_data() when polling observes completion on a channel without a platform IRQ, matching the interrupt-driven completion path.

---
   drivers/mailbox/pcc.c | 7 ++++++-
   1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mailbox/pcc.c +4 -1
index 636879ae1db7..7c9451ab4527 100644
@@ -447,9 +447,14 @@ static int pcc_send_data(struct mbox_chan *chan, void *data)
   static bool pcc_last_tx_done(struct mbox_chan *chan)
   {
+	bool ret;
   	struct pcc_chan_info *pchan = chan->con_priv;
-	return pcc_mbox_cmd_complete_check(pchan);
+	ret = pcc_mbox_cmd_complete_check(pchan);
+	if (ret && !pchan->plat_irq)
+		mbox_chan_received_data(chan, NULL);
Quoted 9 lines

drivers/mailbox/pcc.c static int pcc_send_data(struct mbox_chan *chan, void *data) · line 458

Quoted 3 lines
drivers/mailbox/pcc.c +2 -0
+
+	return ret;
   }

The mailbox_controller.h said that .last_tx_done() is used only if txdone_poll:=true && txdone_irq:=false.
How about add a verification at the begining of this function? like "if (chan->txdone_method != MBOX_TXDONE_BY_POLL) return false;" And then call mbox_chan_received_data() directly if command completed.

Thanks, it does makes sense to me. I will have look.

Quoted 4 lines

This patch is ok to me if has above changes.

Quoted 8 lines

But pcc mbox controller can no longer work in MBOX_TXDONE_BY_ACK after your commit:
3349f800609e (mailbox: pcc: Set txdone_irq/txdone_poll based on PCCT flags). This may lead to above client drivers fail to send mailbox command, like cppc_acpi,hisi_uncore_freq and kunpeng_hccs.
Because these client driver knows tx_done(knows_txdone: true), work on this mode and need to call mbox_client_txdone.
Do you have some idea for this?

Quoted 3 lines

I wonder if we can ask the platform to avoid generating interrupts in those case by setting/clearing "Notify on completion" in shmem. Do you think that would work ?

Hi Sudeep,

Review this logic again.
The mbox_bind_client is called on requesting PCC channel.
And mbox_bind_client could modify chan->txdone_method to MBOX_TXDONE_BY_ACK if client knows txdone and 'txdone_method' is MBOX_TXDONE_BY_POLL. So I think your above commit is ok for these client drivers.

/Huisong