Skip to content

Commit f82c3e6

Browse files
sudeep-hollaJassi Brar
authored andcommitted
Revert "mailbox/pcc: support mailbox management of the shared buffer"
This reverts commit 5378bdf. Commit 5378bdf ("mailbox/pcc: support mailbox management of the shared buffer") attempted to introduce generic helpers for managing the PCC shared memory, but it largely duplicates functionality already provided by the mailbox core and leaves gaps: 1. TX preparation: The mailbox framework already supports this via ->tx_prepare callback for mailbox clients. The patch adds pcc_write_to_buffer() and expects clients to toggle pchan->chan.manage_writes, but no drivers set manage_writes, so pcc_write_to_buffer() has no users. 2. RX handling: Data reception is already delivered through mbox_chan_received_data() and client ->rx_callback. The patch adds an optional pchan->chan.rx_alloc, which again has no users and duplicates the existing path. 3. Completion handling: While adding last_tx_done is directionally useful, the implementation only covers Type 3/4 and fails to handle the absence of a command_complete register, so it is incomplete for other types. Given the duplication and incomplete coverage, revert this change. Any new requirements should be addressed in focused follow-ups rather than bundling multiple behavioral changes together. Fixes: 5378bdf ("mailbox/pcc: support mailbox management of the shared buffer") Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
1 parent b411f21 commit f82c3e6

2 files changed

Lines changed: 4 additions & 127 deletions

File tree

drivers/mailbox/pcc.c

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -305,22 +305,6 @@ static void pcc_chan_acknowledge(struct pcc_chan_info *pchan)
305305
pcc_chan_reg_read_modify_write(&pchan->db);
306306
}
307307

308-
static void *write_response(struct pcc_chan_info *pchan)
309-
{
310-
struct pcc_header pcc_header;
311-
void *buffer;
312-
int data_len;
313-
314-
memcpy_fromio(&pcc_header, pchan->chan.shmem,
315-
sizeof(pcc_header));
316-
data_len = pcc_header.length - sizeof(u32) + sizeof(struct pcc_header);
317-
318-
buffer = pchan->chan.rx_alloc(pchan->chan.mchan->cl, data_len);
319-
if (buffer != NULL)
320-
memcpy_fromio(buffer, pchan->chan.shmem, data_len);
321-
return buffer;
322-
}
323-
324308
/**
325309
* pcc_mbox_irq - PCC mailbox interrupt handler
326310
* @irq: interrupt number
@@ -332,8 +316,6 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
332316
{
333317
struct pcc_chan_info *pchan;
334318
struct mbox_chan *chan = p;
335-
struct pcc_header *pcc_header = chan->active_req;
336-
void *handle = NULL;
337319

338320
pchan = chan->con_priv;
339321

@@ -357,17 +339,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
357339
* required to avoid any possible race in updatation of this flag.
358340
*/
359341
pchan->chan_in_use = false;
360-
361-
if (pchan->chan.rx_alloc)
362-
handle = write_response(pchan);
363-
364-
if (chan->active_req) {
365-
pcc_header = chan->active_req;
366-
if (pcc_header->flags & PCC_CMD_COMPLETION_NOTIFY)
367-
mbox_chan_txdone(chan, 0);
368-
}
369-
370-
mbox_chan_received_data(chan, handle);
342+
mbox_chan_received_data(chan, NULL);
371343

372344
pcc_chan_acknowledge(pchan);
373345

@@ -411,24 +383,9 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
411383
pcc_mchan = &pchan->chan;
412384
pcc_mchan->shmem = acpi_os_ioremap(pcc_mchan->shmem_base_addr,
413385
pcc_mchan->shmem_size);
414-
if (!pcc_mchan->shmem)
415-
goto err;
416-
417-
pcc_mchan->manage_writes = false;
418-
419-
/* This indicates that the channel is ready to accept messages.
420-
* This needs to happen after the channel has registered
421-
* its callback. There is no access point to do that in
422-
* the mailbox API. That implies that the mailbox client must
423-
* have set the allocate callback function prior to
424-
* sending any messages.
425-
*/
426-
if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE)
427-
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
428-
429-
return pcc_mchan;
386+
if (pcc_mchan->shmem)
387+
return pcc_mchan;
430388

431-
err:
432389
mbox_free_channel(chan);
433390
return ERR_PTR(-ENXIO);
434391
}
@@ -459,38 +416,8 @@ void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan)
459416
}
460417
EXPORT_SYMBOL_GPL(pcc_mbox_free_channel);
461418

462-
static int pcc_write_to_buffer(struct mbox_chan *chan, void *data)
463-
{
464-
struct pcc_chan_info *pchan = chan->con_priv;
465-
struct pcc_mbox_chan *pcc_mbox_chan = &pchan->chan;
466-
struct pcc_header *pcc_header = data;
467-
468-
if (!pchan->chan.manage_writes)
469-
return 0;
470-
471-
/* The PCC header length includes the command field
472-
* but not the other values from the header.
473-
*/
474-
int len = pcc_header->length - sizeof(u32) + sizeof(struct pcc_header);
475-
u64 val;
476-
477-
pcc_chan_reg_read(&pchan->cmd_complete, &val);
478-
if (!val) {
479-
pr_info("%s pchan->cmd_complete not set", __func__);
480-
return -1;
481-
}
482-
memcpy_toio(pcc_mbox_chan->shmem, data, len);
483-
return 0;
484-
}
485-
486-
487419
/**
488-
* pcc_send_data - Called from Mailbox Controller code. If
489-
* pchan->chan.rx_alloc is set, then the command complete
490-
* flag is checked and the data is written to the shared
491-
* buffer io memory.
492-
*
493-
* If pchan->chan.rx_alloc is not set, then it is used
420+
* pcc_send_data - Called from Mailbox Controller code. Used
494421
* here only to ring the channel doorbell. The PCC client
495422
* specific read/write is done in the client driver in
496423
* order to maintain atomicity over PCC channel once
@@ -506,37 +433,17 @@ static int pcc_send_data(struct mbox_chan *chan, void *data)
506433
int ret;
507434
struct pcc_chan_info *pchan = chan->con_priv;
508435

509-
ret = pcc_write_to_buffer(chan, data);
510-
if (ret)
511-
return ret;
512-
513436
ret = pcc_chan_reg_read_modify_write(&pchan->cmd_update);
514437
if (ret)
515438
return ret;
516439

517440
ret = pcc_chan_reg_read_modify_write(&pchan->db);
518-
519441
if (!ret && pchan->plat_irq > 0)
520442
pchan->chan_in_use = true;
521443

522444
return ret;
523445
}
524446

525-
526-
static bool pcc_last_tx_done(struct mbox_chan *chan)
527-
{
528-
struct pcc_chan_info *pchan = chan->con_priv;
529-
u64 val;
530-
531-
pcc_chan_reg_read(&pchan->cmd_complete, &val);
532-
if (!val)
533-
return false;
534-
else
535-
return true;
536-
}
537-
538-
539-
540447
/**
541448
* pcc_startup - Called from Mailbox Controller code. Used here
542449
* to request the interrupt.
@@ -582,7 +489,6 @@ static const struct mbox_chan_ops pcc_chan_ops = {
582489
.send_data = pcc_send_data,
583490
.startup = pcc_startup,
584491
.shutdown = pcc_shutdown,
585-
.last_tx_done = pcc_last_tx_done,
586492
};
587493

588494
/**

include/acpi/pcc.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,6 @@ struct pcc_mbox_chan {
1717
u32 latency;
1818
u32 max_access_rate;
1919
u16 min_turnaround_time;
20-
21-
/* Set to true to indicate that the mailbox should manage
22-
* writing the dat to the shared buffer. This differs from
23-
* the case where the drivesr are writing to the buffer and
24-
* using send_data only to ring the doorbell. If this flag
25-
* is set, then the void * data parameter of send_data must
26-
* point to a kernel-memory buffer formatted in accordance with
27-
* the PCC specification.
28-
*
29-
* The active buffer management will include reading the
30-
* notify_on_completion flag, and will then
31-
* call mbox_chan_txdone when the acknowledgment interrupt is
32-
* received.
33-
*/
34-
bool manage_writes;
35-
36-
/* Optional callback that allows the driver
37-
* to allocate the memory used for receiving
38-
* messages. The return value is the location
39-
* inside the buffer where the mailbox should write the data.
40-
*/
41-
void *(*rx_alloc)(struct mbox_client *cl, int size);
42-
};
43-
44-
struct pcc_header {
45-
u32 signature;
46-
u32 flags;
47-
u32 length;
48-
u32 command;
4920
};
5021

5122
/* Generic Communications Channel Shared Memory Region */

0 commit comments

Comments
 (0)