Skip to content

Commit 2475b36

Browse files
sudeep-hollaJassi Brar
authored andcommitted
mailbox: pcc: Refactor and simplify check_and_ack()
The existing check_and_ack() function had unnecessary complexity. The logic could be streamlined to improve code readability and maintainability. The command update register needs to be updated in order to acknowledge the platform notification through type 4 channel. So it can be done unconditionally. Currently it is complicated just to make use of pcc_send_data() which also executes the same updation. In order to simplify, let us just ring the doorbell directly from check_and_ack() instead of calling into pcc_send_data(). While at it, rename it into pcc_chan_check_and_ack() to maintain consistency in the driver. Acked-by: Huisong Li <lihuisong@huawei.com> Tested-by: Adam Young <admiyo@os.amperecomputing.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
1 parent fa362ff commit 2475b36

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

drivers/mailbox/pcc.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ struct pcc_chan_info {
117117
static struct pcc_chan_info *chan_info;
118118
static int pcc_chan_count;
119119

120-
static int pcc_send_data(struct mbox_chan *chan, void *data);
121-
122120
/*
123121
* PCC can be used with perf critical drivers such as CPPC
124122
* So it makes sense to locally cache the virtual address and
@@ -288,33 +286,24 @@ static int pcc_mbox_error_check_and_clear(struct pcc_chan_info *pchan)
288286
return 0;
289287
}
290288

291-
static void check_and_ack(struct pcc_chan_info *pchan, struct mbox_chan *chan)
289+
static void pcc_chan_acknowledge(struct pcc_chan_info *pchan)
292290
{
293-
struct acpi_pcct_ext_pcc_shared_memory pcc_hdr;
291+
struct acpi_pcct_ext_pcc_shared_memory __iomem *pcc_hdr;
294292

295293
if (pchan->type != ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE)
296294
return;
297-
/* If the memory region has not been mapped, we cannot
298-
* determine if we need to send the message, but we still
299-
* need to set the cmd_update flag before returning.
300-
*/
301-
if (pchan->chan.shmem == NULL) {
302-
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
303-
return;
304-
}
305-
memcpy_fromio(&pcc_hdr, pchan->chan.shmem,
306-
sizeof(struct acpi_pcct_ext_pcc_shared_memory));
295+
296+
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
297+
298+
pcc_hdr = pchan->chan.shmem;
299+
307300
/*
308-
* The PCC slave subspace channel needs to set the command complete bit
309-
* after processing message. If the PCC_ACK_FLAG is set, it should also
310-
* ring the doorbell.
311-
*
312-
* The PCC master subspace channel clears chan_in_use to free channel.
301+
* The PCC slave subspace channel needs to set the command
302+
* complete bit after processing message. If the PCC_ACK_FLAG
303+
* is set, it should also ring the doorbell.
313304
*/
314-
if (pcc_hdr.flags & PCC_CMD_COMPLETION_NOTIFY)
315-
pcc_send_data(chan, NULL);
316-
else
317-
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
305+
if (ioread32(&pcc_hdr->flags) & PCC_CMD_COMPLETION_NOTIFY)
306+
pcc_chan_reg_read_modify_write(&pchan->db);
318307
}
319308

320309
/**
@@ -353,7 +342,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
353342
pchan->chan_in_use = false;
354343
mbox_chan_received_data(chan, NULL);
355344

356-
check_and_ack(pchan, chan);
345+
pcc_chan_acknowledge(pchan);
357346

358347
return IRQ_HANDLED;
359348
}

0 commit comments

Comments
 (0)