Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "mailbox/pcc: support mailbox management of the shared buffer"

This reverts commit 5378bdf6a611a32500fccf13d14156f219bb0c85.

Commit 5378bdf6a611 ("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: 5378bdf6a611 ("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>

authored by

Sudeep Holla and committed by
Jassi Brar
f82c3e62 b411f210

+4 -127
+4 -98
drivers/mailbox/pcc.c
··· 305 305 pcc_chan_reg_read_modify_write(&pchan->db); 306 306 } 307 307 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 - 324 308 /** 325 309 * pcc_mbox_irq - PCC mailbox interrupt handler 326 310 * @irq: interrupt number ··· 316 332 { 317 333 struct pcc_chan_info *pchan; 318 334 struct mbox_chan *chan = p; 319 - struct pcc_header *pcc_header = chan->active_req; 320 - void *handle = NULL; 321 335 322 336 pchan = chan->con_priv; 323 337 ··· 339 357 * required to avoid any possible race in updatation of this flag. 340 358 */ 341 359 pchan->chan_in_use = false; 342 - 343 - if (pchan->chan.rx_alloc) 344 - handle = write_response(pchan); 345 - 346 - if (chan->active_req) { 347 - pcc_header = chan->active_req; 348 - if (pcc_header->flags & PCC_CMD_COMPLETION_NOTIFY) 349 - mbox_chan_txdone(chan, 0); 350 - } 351 - 352 - mbox_chan_received_data(chan, handle); 360 + mbox_chan_received_data(chan, NULL); 353 361 354 362 pcc_chan_acknowledge(pchan); 355 363 ··· 383 411 pcc_mchan = &pchan->chan; 384 412 pcc_mchan->shmem = acpi_os_ioremap(pcc_mchan->shmem_base_addr, 385 413 pcc_mchan->shmem_size); 386 - if (!pcc_mchan->shmem) 387 - goto err; 414 + if (pcc_mchan->shmem) 415 + return pcc_mchan; 388 416 389 - pcc_mchan->manage_writes = false; 390 - 391 - /* This indicates that the channel is ready to accept messages. 392 - * This needs to happen after the channel has registered 393 - * its callback. There is no access point to do that in 394 - * the mailbox API. That implies that the mailbox client must 395 - * have set the allocate callback function prior to 396 - * sending any messages. 397 - */ 398 - if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE) 399 - pcc_chan_reg_read_modify_write(&pchan->cmd_update); 400 - 401 - return pcc_mchan; 402 - 403 - err: 404 417 mbox_free_channel(chan); 405 418 return ERR_PTR(-ENXIO); 406 419 } ··· 416 459 } 417 460 EXPORT_SYMBOL_GPL(pcc_mbox_free_channel); 418 461 419 - static int pcc_write_to_buffer(struct mbox_chan *chan, void *data) 420 - { 421 - struct pcc_chan_info *pchan = chan->con_priv; 422 - struct pcc_mbox_chan *pcc_mbox_chan = &pchan->chan; 423 - struct pcc_header *pcc_header = data; 424 - 425 - if (!pchan->chan.manage_writes) 426 - return 0; 427 - 428 - /* The PCC header length includes the command field 429 - * but not the other values from the header. 430 - */ 431 - int len = pcc_header->length - sizeof(u32) + sizeof(struct pcc_header); 432 - u64 val; 433 - 434 - pcc_chan_reg_read(&pchan->cmd_complete, &val); 435 - if (!val) { 436 - pr_info("%s pchan->cmd_complete not set", __func__); 437 - return -1; 438 - } 439 - memcpy_toio(pcc_mbox_chan->shmem, data, len); 440 - return 0; 441 - } 442 - 443 - 444 462 /** 445 - * pcc_send_data - Called from Mailbox Controller code. If 446 - * pchan->chan.rx_alloc is set, then the command complete 447 - * flag is checked and the data is written to the shared 448 - * buffer io memory. 449 - * 450 - * If pchan->chan.rx_alloc is not set, then it is used 463 + * pcc_send_data - Called from Mailbox Controller code. Used 451 464 * here only to ring the channel doorbell. The PCC client 452 465 * specific read/write is done in the client driver in 453 466 * order to maintain atomicity over PCC channel once ··· 433 506 int ret; 434 507 struct pcc_chan_info *pchan = chan->con_priv; 435 508 436 - ret = pcc_write_to_buffer(chan, data); 437 - if (ret) 438 - return ret; 439 - 440 509 ret = pcc_chan_reg_read_modify_write(&pchan->cmd_update); 441 510 if (ret) 442 511 return ret; 443 512 444 513 ret = pcc_chan_reg_read_modify_write(&pchan->db); 445 - 446 514 if (!ret && pchan->plat_irq > 0) 447 515 pchan->chan_in_use = true; 448 516 449 517 return ret; 450 518 } 451 - 452 - 453 - static bool pcc_last_tx_done(struct mbox_chan *chan) 454 - { 455 - struct pcc_chan_info *pchan = chan->con_priv; 456 - u64 val; 457 - 458 - pcc_chan_reg_read(&pchan->cmd_complete, &val); 459 - if (!val) 460 - return false; 461 - else 462 - return true; 463 - } 464 - 465 - 466 519 467 520 /** 468 521 * pcc_startup - Called from Mailbox Controller code. Used here ··· 489 582 .send_data = pcc_send_data, 490 583 .startup = pcc_startup, 491 584 .shutdown = pcc_shutdown, 492 - .last_tx_done = pcc_last_tx_done, 493 585 }; 494 586 495 587 /**
-29
include/acpi/pcc.h
··· 17 17 u32 latency; 18 18 u32 max_access_rate; 19 19 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; 49 20 }; 50 21 51 22 /* Generic Communications Channel Shared Memory Region */