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.

Merge tag 'mailbox-v7.1' of git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox

Pull mailbox updates from Jassi Brar:

- core: fix NULL message handling and add API to query TX queue slots

- test: resolve concurrency bugs, dangling IRQs, and memory leaks

- dt-bindings: qcom: add Eliza IPCC

- mtk: fix address calculation and pointer handling bugs

- cix: resolve SCMI suspend timeouts

- misc memory allocation optimizations and cleanups

* tag 'mailbox-v7.1' of git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox:
mailbox: mailbox-test: make data_ready a per-instance variable
mailbox: mailbox-test: initialize struct earlier
mailbox: mailbox-test: don't free the reused channel
mailbox: mailbox-test: handle channel errors consistently
mailbox: update kdoc for struct mbox_controller
mailbox: add sanity check for channel array
mailbox: mailbox-test: free channels on probe error
mailbox: prefix new constants with MBOX_
dt-bindings: mailbox: qcom-ipcc: Document the Eliza Inter-Processor Communication Controller
mailbox: cix: Add IRQF_NO_SUSPEND to mailbox interrupt
mailbox: Fix NULL message support in mbox_send_message()
mailbox: remove superfluous internal header
mailbox: correct kdoc title for mbox_bind_client
mailbox: test: really ignore optional memory resources
mailbox: exynos: drop superfluous mbox setting per channel
mailbox: mtk-cmdq: Fix CURR and END addr for task insert case
mailbox: mtk-vcp-mailbox: Fix the return value in mtk_vcp_mbox_xlate()
mailbox: hi6220: kzalloc + kcalloc to kzalloc
mailbox: rockchip: kzalloc + kcalloc to kzalloc
mailbox: add API to query available TX queue slots

+124 -119
+1
Documentation/devicetree/bindings/mailbox/qcom-ipcc.yaml
··· 24 24 compatible: 25 25 items: 26 26 - enum: 27 + - qcom,eliza-ipcc 27 28 - qcom,glymur-ipcc 28 29 - qcom,kaanapali-ipcc 29 30 - qcom,milos-ipcc
+2 -4
drivers/mailbox/cix-mailbox.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/platform_device.h> 14 14 15 - #include "mailbox.h" 16 - 17 15 /* 18 16 * The maximum transmission size is 32 words or 128 bytes. 19 17 */ ··· 403 405 int index = cp->index, ret; 404 406 u32 val; 405 407 406 - ret = request_irq(priv->irq, cix_mbox_isr, 0, 408 + ret = request_irq(priv->irq, cix_mbox_isr, IRQF_NO_SUSPEND, 407 409 dev_name(priv->dev), chan); 408 410 if (ret) { 409 411 dev_err(priv->dev, "Unable to acquire IRQ %d\n", priv->irq); ··· 413 415 switch (cp->type) { 414 416 case CIX_MBOX_TYPE_DB: 415 417 /* Overwrite txdone_method for DB channel */ 416 - chan->txdone_method = TXDONE_BY_ACK; 418 + chan->txdone_method = MBOX_TXDONE_BY_ACK; 417 419 fallthrough; 418 420 case CIX_MBOX_TYPE_REG: 419 421 if (priv->dir == CIX_MBOX_TX) {
-4
drivers/mailbox/exynos-mailbox.c
··· 99 99 struct mbox_controller *mbox; 100 100 struct mbox_chan *chans; 101 101 struct clk *pclk; 102 - int i; 103 102 104 103 exynos_mbox = devm_kzalloc(dev, sizeof(*exynos_mbox), GFP_KERNEL); 105 104 if (!exynos_mbox) ··· 127 128 mbox->dev = dev; 128 129 mbox->ops = &exynos_mbox_chan_ops; 129 130 mbox->of_xlate = exynos_mbox_of_xlate; 130 - 131 - for (i = 0; i < EXYNOS_MBOX_CHAN_COUNT; i++) 132 - chans[i].mbox = mbox; 133 131 134 132 exynos_mbox->mbox = mbox; 135 133
-2
drivers/mailbox/hi3660-mailbox.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/slab.h> 17 17 18 - #include "mailbox.h" 19 - 20 18 #define MBOX_CHAN_MAX 32 21 19 22 20 #define MBOX_RX 0x0
+5 -9
drivers/mailbox/hi6220-mailbox.c
··· 79 79 /* region for mailbox */ 80 80 void __iomem *base; 81 81 82 - unsigned int chan_num; 83 - struct hi6220_mbox_chan *mchan; 84 - 85 82 void *irq_map_chan[MBOX_CHAN_MAX]; 86 83 struct mbox_chan *chan; 87 84 struct mbox_controller controller; 85 + 86 + unsigned int chan_num; 87 + struct hi6220_mbox_chan mchan[] __counted_by(chan_num); 88 88 }; 89 89 90 90 static void mbox_set_state(struct hi6220_mbox *mbox, ··· 267 267 struct hi6220_mbox *mbox; 268 268 int i, err; 269 269 270 - mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); 270 + mbox = devm_kzalloc(dev, struct_size(mbox, mchan, MBOX_CHAN_MAX), GFP_KERNEL); 271 271 if (!mbox) 272 272 return -ENOMEM; 273 273 274 - mbox->dev = dev; 275 274 mbox->chan_num = MBOX_CHAN_MAX; 276 - mbox->mchan = devm_kcalloc(dev, 277 - mbox->chan_num, sizeof(*mbox->mchan), GFP_KERNEL); 278 - if (!mbox->mchan) 279 - return -ENOMEM; 275 + mbox->dev = dev; 280 276 281 277 mbox->chan = devm_kcalloc(dev, 282 278 mbox->chan_num, sizeof(*mbox->chan), GFP_KERNEL);
+1 -3
drivers/mailbox/imx-mailbox.c
··· 23 23 #include <linux/slab.h> 24 24 #include <linux/workqueue.h> 25 25 26 - #include "mailbox.h" 27 - 28 26 #define IMX_MU_CHANS 24 29 27 /* TX0/RX0/RXDB[0-3] */ 30 28 #define IMX_MU_SCU_CHANS 6 ··· 732 734 p_chan = &mbox->chans[chan]; 733 735 734 736 if (type == IMX_MU_TYPE_TXDB_V2) 735 - p_chan->txdone_method = TXDONE_BY_ACK; 737 + p_chan->txdone_method = MBOX_TXDONE_BY_ACK; 736 738 737 739 return p_chan; 738 740 }
-2
drivers/mailbox/mailbox-sti.c
··· 21 21 #include <linux/property.h> 22 22 #include <linux/slab.h> 23 23 24 - #include "mailbox.h" 25 - 26 24 #define STI_MBOX_INST_MAX 4 /* RAM saving: Max supported instances */ 27 25 #define STI_MBOX_CHAN_MAX 20 /* RAM saving: Max supported channels */ 28 26
+46 -34
drivers/mailbox/mailbox-test.c
··· 28 28 #define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \ 29 29 (MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE)) 30 30 31 - static bool mbox_data_ready; 32 - 33 31 struct mbox_test_device { 34 32 struct device *dev; 35 33 void __iomem *tx_mmio; ··· 40 42 spinlock_t lock; 41 43 struct mutex mutex; 42 44 wait_queue_head_t waitq; 45 + bool data_ready; 43 46 struct fasync_struct *async_queue; 44 47 struct dentry *root_debugfs_dir; 45 48 }; ··· 161 162 unsigned long flags; 162 163 163 164 spin_lock_irqsave(&tdev->lock, flags); 164 - data_ready = mbox_data_ready; 165 + data_ready = tdev->data_ready; 165 166 spin_unlock_irqrestore(&tdev->lock, flags); 166 167 167 168 return data_ready; ··· 226 227 *(touser + l) = '\0'; 227 228 228 229 memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN); 229 - mbox_data_ready = false; 230 + tdev->data_ready = false; 230 231 231 232 spin_unlock_irqrestore(&tdev->lock, flags); 232 233 ··· 296 297 message, MBOX_MAX_MSG_LEN); 297 298 memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN); 298 299 } 299 - mbox_data_ready = true; 300 + tdev->data_ready = true; 300 301 spin_unlock_irqrestore(&tdev->lock, flags); 301 302 302 303 wake_up_interruptible(&tdev->waitq); ··· 335 336 336 337 client = devm_kzalloc(&pdev->dev, sizeof(*client), GFP_KERNEL); 337 338 if (!client) 338 - return ERR_PTR(-ENOMEM); 339 + return NULL; 339 340 340 341 client->dev = &pdev->dev; 341 342 client->rx_callback = mbox_test_receive_message; ··· 354 355 return channel; 355 356 } 356 357 358 + static void __iomem *mbox_test_ioremap(struct platform_device *pdev, unsigned int res_num) 359 + { 360 + struct resource *res; 361 + void __iomem *mmio; 362 + 363 + res = platform_get_resource(pdev, IORESOURCE_MEM, res_num); 364 + if (!res) 365 + return NULL; 366 + 367 + mmio = devm_ioremap_resource(&pdev->dev, res); 368 + if (PTR_ERR(mmio) == -EBUSY) { 369 + dev_info(&pdev->dev, "trying workaround with plain ioremap\n"); 370 + return devm_ioremap(&pdev->dev, res->start, resource_size(res)); 371 + } 372 + 373 + return IS_ERR(mmio) ? NULL : mmio; 374 + } 375 + 357 376 static int mbox_test_probe(struct platform_device *pdev) 358 377 { 359 378 struct mbox_test_device *tdev; 360 - struct resource *res; 361 - resource_size_t size; 362 379 int ret; 363 380 364 381 tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); 365 382 if (!tdev) 366 383 return -ENOMEM; 367 384 385 + tdev->dev = &pdev->dev; 386 + spin_lock_init(&tdev->lock); 387 + mutex_init(&tdev->mutex); 388 + init_waitqueue_head(&tdev->waitq); 389 + platform_set_drvdata(pdev, tdev); 390 + 368 391 /* It's okay for MMIO to be NULL */ 369 - tdev->tx_mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 370 - if (PTR_ERR(tdev->tx_mmio) == -EBUSY) { 371 - /* if reserved area in SRAM, try just ioremap */ 372 - size = resource_size(res); 373 - tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size); 374 - } else if (IS_ERR(tdev->tx_mmio)) { 375 - tdev->tx_mmio = NULL; 376 - } 392 + tdev->tx_mmio = mbox_test_ioremap(pdev, 0); 377 393 378 394 /* If specified, second reg entry is Rx MMIO */ 379 - tdev->rx_mmio = devm_platform_get_and_ioremap_resource(pdev, 1, &res); 380 - if (PTR_ERR(tdev->rx_mmio) == -EBUSY) { 381 - size = resource_size(res); 382 - tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size); 383 - } else if (IS_ERR(tdev->rx_mmio)) { 395 + tdev->rx_mmio = mbox_test_ioremap(pdev, 1); 396 + if (!tdev->rx_mmio) 384 397 tdev->rx_mmio = tdev->tx_mmio; 385 - } 386 398 387 399 tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); 388 400 tdev->rx_channel = mbox_test_request_channel(pdev, "rx"); 389 401 390 - if (IS_ERR_OR_NULL(tdev->tx_channel) && IS_ERR_OR_NULL(tdev->rx_channel)) 402 + if (!tdev->tx_channel && !tdev->rx_channel) 391 403 return -EPROBE_DEFER; 392 404 393 405 /* If Rx is not specified but has Rx MMIO, then Rx = Tx */ 394 406 if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio)) 395 407 tdev->rx_channel = tdev->tx_channel; 396 408 397 - tdev->dev = &pdev->dev; 398 - platform_set_drvdata(pdev, tdev); 399 - 400 - spin_lock_init(&tdev->lock); 401 - mutex_init(&tdev->mutex); 402 - 403 409 if (tdev->rx_channel) { 404 410 tdev->rx_buffer = devm_kzalloc(&pdev->dev, 405 411 MBOX_MAX_MSG_LEN, GFP_KERNEL); 406 - if (!tdev->rx_buffer) 407 - return -ENOMEM; 412 + if (!tdev->rx_buffer) { 413 + ret = -ENOMEM; 414 + goto err_free_chans; 415 + } 408 416 } 409 417 410 418 ret = mbox_test_add_debugfs(pdev, tdev); 411 419 if (ret) 412 - return ret; 420 + goto err_free_chans; 413 421 414 - init_waitqueue_head(&tdev->waitq); 415 422 dev_info(&pdev->dev, "Successfully registered\n"); 416 423 417 424 return 0; 425 + 426 + err_free_chans: 427 + if (tdev->tx_channel) 428 + mbox_free_channel(tdev->tx_channel); 429 + if (tdev->rx_channel && tdev->rx_channel != tdev->tx_channel) 430 + mbox_free_channel(tdev->rx_channel); 431 + return ret; 418 432 } 419 433 420 434 static void mbox_test_remove(struct platform_device *pdev) ··· 438 426 439 427 if (tdev->tx_channel) 440 428 mbox_free_channel(tdev->tx_channel); 441 - if (tdev->rx_channel) 429 + if (tdev->rx_channel && tdev->rx_channel != tdev->tx_channel) 442 430 mbox_free_channel(tdev->rx_channel); 443 431 } 444 432
+44 -23
drivers/mailbox/mailbox.c
··· 18 18 #include <linux/property.h> 19 19 #include <linux/spinlock.h> 20 20 21 - #include "mailbox.h" 22 - 23 21 static LIST_HEAD(mbox_cons); 24 22 static DEFINE_MUTEX(con_mutex); 25 23 ··· 50 52 int err = -EBUSY; 51 53 52 54 scoped_guard(spinlock_irqsave, &chan->lock) { 53 - if (!chan->msg_count || chan->active_req) 55 + if (!chan->msg_count || chan->active_req != MBOX_NO_MSG) 54 56 break; 55 57 56 58 count = chan->msg_count; ··· 72 74 } 73 75 } 74 76 75 - if (!err && (chan->txdone_method & TXDONE_BY_POLL)) { 77 + if (!err && (chan->txdone_method & MBOX_TXDONE_BY_POLL)) { 76 78 /* kick start the timer immediately to avoid delays */ 77 79 scoped_guard(spinlock_irqsave, &chan->mbox->poll_hrt_lock) 78 80 hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL); ··· 85 87 86 88 scoped_guard(spinlock_irqsave, &chan->lock) { 87 89 mssg = chan->active_req; 88 - chan->active_req = NULL; 90 + chan->active_req = MBOX_NO_MSG; 89 91 } 90 92 91 93 /* Submit next message */ 92 94 msg_submit(chan); 93 95 94 - if (!mssg) 96 + if (mssg == MBOX_NO_MSG) 95 97 return; 96 98 97 99 /* Notify the client */ ··· 112 114 for (i = 0; i < mbox->num_chans; i++) { 113 115 struct mbox_chan *chan = &mbox->chans[i]; 114 116 115 - if (chan->active_req && chan->cl) { 117 + if (chan->active_req != MBOX_NO_MSG && chan->cl) { 116 118 txdone = chan->mbox->ops->last_tx_done(chan); 117 119 if (txdone) 118 120 tx_tick(chan, 0); ··· 162 164 */ 163 165 void mbox_chan_txdone(struct mbox_chan *chan, int r) 164 166 { 165 - if (unlikely(!(chan->txdone_method & TXDONE_BY_IRQ))) { 167 + if (unlikely(!(chan->txdone_method & MBOX_TXDONE_BY_IRQ))) { 166 168 dev_err(chan->mbox->dev, 167 169 "Controller can't run the TX ticker\n"); 168 170 return; ··· 183 185 */ 184 186 void mbox_client_txdone(struct mbox_chan *chan, int r) 185 187 { 186 - if (unlikely(!(chan->txdone_method & TXDONE_BY_ACK))) { 188 + if (unlikely(!(chan->txdone_method & MBOX_TXDONE_BY_ACK))) { 187 189 dev_err(chan->mbox->dev, "Client can't run the TX ticker\n"); 188 190 return; 189 191 } ··· 217 219 EXPORT_SYMBOL_GPL(mbox_client_peek_data); 218 220 219 221 /** 222 + * mbox_chan_tx_slots_available - Query the number of available TX queue slots. 223 + * @chan: Mailbox channel to query. 224 + * 225 + * Clients may call this to check how many messages can be queued via 226 + * mbox_send_message() before the channel's TX queue is full. This helps 227 + * clients avoid the -ENOBUFS error without needing to increase 228 + * MBOX_TX_QUEUE_LEN. 229 + * This can be called from atomic context. 230 + * 231 + * Return: Number of available slots in the channel's TX queue. 232 + */ 233 + unsigned int mbox_chan_tx_slots_available(struct mbox_chan *chan) 234 + { 235 + unsigned int ret; 236 + 237 + guard(spinlock_irqsave)(&chan->lock); 238 + ret = MBOX_TX_QUEUE_LEN - chan->msg_count; 239 + 240 + return ret; 241 + } 242 + EXPORT_SYMBOL_GPL(mbox_chan_tx_slots_available); 243 + 244 + /** 220 245 * mbox_send_message - For client to submit a message to be 221 246 * sent to the remote. 222 247 * @chan: Mailbox channel assigned to this client. ··· 267 246 { 268 247 int t; 269 248 270 - if (!chan || !chan->cl) 249 + if (!chan || !chan->cl || mssg == MBOX_NO_MSG) 271 250 return -EINVAL; 272 251 273 252 t = add_to_rbuf(chan, mssg); ··· 340 319 scoped_guard(spinlock_irqsave, &chan->lock) { 341 320 chan->msg_free = 0; 342 321 chan->msg_count = 0; 343 - chan->active_req = NULL; 322 + chan->active_req = MBOX_NO_MSG; 344 323 chan->cl = cl; 345 324 init_completion(&chan->tx_complete); 346 325 347 - if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone) 348 - chan->txdone_method = TXDONE_BY_ACK; 326 + if (chan->txdone_method == MBOX_TXDONE_BY_POLL && cl->knows_txdone) 327 + chan->txdone_method = MBOX_TXDONE_BY_ACK; 349 328 } 350 329 351 330 if (chan->mbox->ops->startup) { ··· 362 341 } 363 342 364 343 /** 365 - * mbox_bind_client - Request a mailbox channel. 344 + * mbox_bind_client - Bind client to a mailbox channel. 366 345 * @chan: The mailbox channel to bind the client to. 367 346 * @cl: Identity of the client requesting the channel. 368 347 * ··· 498 477 /* The queued TX requests are simply aborted, no callbacks are made */ 499 478 scoped_guard(spinlock_irqsave, &chan->lock) { 500 479 chan->cl = NULL; 501 - chan->active_req = NULL; 502 - if (chan->txdone_method == TXDONE_BY_ACK) 503 - chan->txdone_method = TXDONE_BY_POLL; 480 + chan->active_req = MBOX_NO_MSG; 481 + if (chan->txdone_method == MBOX_TXDONE_BY_ACK) 482 + chan->txdone_method = MBOX_TXDONE_BY_POLL; 504 483 } 505 484 506 485 module_put(chan->mbox->dev->driver->owner); ··· 526 505 { 527 506 int i, txdone; 528 507 529 - /* Sanity check */ 530 - if (!mbox || !mbox->dev || !mbox->ops || !mbox->num_chans) 508 + if (!mbox || !mbox->dev || !mbox->ops || !mbox->chans || !mbox->num_chans) 531 509 return -EINVAL; 532 510 533 511 if (mbox->txdone_irq) 534 - txdone = TXDONE_BY_IRQ; 512 + txdone = MBOX_TXDONE_BY_IRQ; 535 513 else if (mbox->txdone_poll) 536 - txdone = TXDONE_BY_POLL; 514 + txdone = MBOX_TXDONE_BY_POLL; 537 515 else /* It has to be ACK then */ 538 - txdone = TXDONE_BY_ACK; 516 + txdone = MBOX_TXDONE_BY_ACK; 539 517 540 - if (txdone == TXDONE_BY_POLL) { 518 + if (txdone == MBOX_TXDONE_BY_POLL) { 541 519 542 520 if (!mbox->ops->last_tx_done) { 543 521 dev_err(mbox->dev, "last_tx_done method is absent\n"); ··· 552 532 553 533 chan->cl = NULL; 554 534 chan->mbox = mbox; 535 + chan->active_req = MBOX_NO_MSG; 555 536 chan->txdone_method = txdone; 556 537 spin_lock_init(&chan->lock); 557 538 }
-12
drivers/mailbox/mailbox.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - 3 - #ifndef __MAILBOX_H 4 - #define __MAILBOX_H 5 - 6 - #include <linux/bits.h> 7 - 8 - #define TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */ 9 - #define TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */ 10 - #define TXDONE_BY_ACK BIT(2) /* S/W ACK received by Client ticks the TX */ 11 - 12 - #endif /* __MAILBOX_H */
+5 -5
drivers/mailbox/mtk-cmdq-mailbox.c
··· 493 493 if (curr_pa == end_pa - CMDQ_INST_SIZE || 494 494 curr_pa == end_pa) { 495 495 /* set to this task directly */ 496 - writel(task->pa_base >> cmdq->pdata->shift, 497 - thread->base + CMDQ_THR_CURR_ADDR); 496 + gce_addr = cmdq_convert_gce_addr(task->pa_base, cmdq->pdata); 497 + writel(gce_addr, thread->base + CMDQ_THR_CURR_ADDR); 498 498 } else { 499 499 cmdq_task_insert_into_thread(task); 500 500 smp_mb(); /* modify jump before enable thread */ 501 501 } 502 - writel((task->pa_base + pkt->cmd_buf_size) >> cmdq->pdata->shift, 503 - thread->base + CMDQ_THR_END_ADDR); 502 + gce_addr = cmdq_convert_gce_addr(task->pa_base + pkt->cmd_buf_size, cmdq->pdata); 503 + writel(gce_addr, thread->base + CMDQ_THR_END_ADDR); 504 504 cmdq_thread_resume(thread); 505 505 } 506 506 list_move_tail(&task->list_entry, &thread->task_busy_list); ··· 728 728 cmdq->mbox.ops = &cmdq_mbox_chan_ops; 729 729 cmdq->mbox.of_xlate = cmdq_xlate; 730 730 731 - /* make use of TXDONE_BY_ACK */ 731 + /* make use of MBOX_TXDONE_BY_ACK */ 732 732 cmdq->mbox.txdone_irq = false; 733 733 cmdq->mbox.txdone_poll = false; 734 734
+1 -1
drivers/mailbox/mtk-vcp-mailbox.c
··· 50 50 const struct of_phandle_args *sp) 51 51 { 52 52 if (sp->args_count) 53 - return NULL; 53 + return ERR_PTR(-EINVAL); 54 54 55 55 return &mbox->chans[0]; 56 56 }
+1 -3
drivers/mailbox/omap-mailbox.c
··· 22 22 #include <linux/pm_runtime.h> 23 23 #include <linux/mailbox_controller.h> 24 24 25 - #include "mailbox.h" 26 - 27 25 #define MAILBOX_REVISION 0x000 28 26 #define MAILBOX_MESSAGE(m) (0x040 + 4 * (m)) 29 27 #define MAILBOX_FIFOSTATUS(m) (0x080 + 4 * (m)) ··· 238 240 } 239 241 240 242 if (mbox->send_no_irq) 241 - mbox->chan->txdone_method = TXDONE_BY_ACK; 243 + mbox->chan->txdone_method = MBOX_TXDONE_BY_ACK; 242 244 243 245 omap_mbox_enable_irq(mbox, IRQ_RX); 244 246
-2
drivers/mailbox/pcc.c
··· 59 59 #include <linux/io-64-nonatomic-lo-hi.h> 60 60 #include <acpi/pcc.h> 61 61 62 - #include "mailbox.h" 63 - 64 62 #define MBOX_IRQ_NAME "pcc-mbox" 65 63 66 64 /**
+2 -7
drivers/mailbox/rockchip-mailbox.c
··· 46 46 /* The maximum size of buf for each channel */ 47 47 u32 buf_size; 48 48 49 - struct rockchip_mbox_chan *chans; 49 + struct rockchip_mbox_chan chans[]; 50 50 }; 51 51 52 52 static int rockchip_mbox_send_data(struct mbox_chan *chan, void *data) ··· 173 173 174 174 drv_data = (const struct rockchip_mbox_data *) device_get_match_data(&pdev->dev); 175 175 176 - mb = devm_kzalloc(&pdev->dev, sizeof(*mb), GFP_KERNEL); 176 + mb = devm_kzalloc(&pdev->dev, struct_size(mb, chans, drv_data->num_chans), GFP_KERNEL); 177 177 if (!mb) 178 - return -ENOMEM; 179 - 180 - mb->chans = devm_kcalloc(&pdev->dev, drv_data->num_chans, 181 - sizeof(*mb->chans), GFP_KERNEL); 182 - if (!mb->chans) 183 178 return -ENOMEM; 184 179 185 180 mb->mbox.chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,
+2 -4
drivers/mailbox/tegra-hsp.c
··· 16 16 17 17 #include <dt-bindings/mailbox/tegra186-hsp.h> 18 18 19 - #include "mailbox.h" 20 - 21 19 #define HSP_INT_IE(x) (0x100 + ((x) * 4)) 22 20 #define HSP_INT_IV 0x300 23 21 #define HSP_INT_IR 0x304 ··· 495 497 mbox_chan_txdone(chan, 0); 496 498 497 499 /* Wait until channel is empty */ 498 - if (chan->active_req != NULL) 500 + if (chan->active_req != MBOX_NO_MSG) 499 501 continue; 500 502 501 503 return 0; ··· 514 516 struct tegra_hsp *hsp = mb->channel.hsp; 515 517 unsigned long flags; 516 518 517 - chan->txdone_method = TXDONE_BY_IRQ; 519 + chan->txdone_method = MBOX_TXDONE_BY_IRQ; 518 520 519 521 /* 520 522 * Shared mailboxes start out as consumers by default. FULL and EMPTY
+1
include/linux/mailbox_client.h
··· 45 45 int mbox_flush(struct mbox_chan *chan, unsigned long timeout); 46 46 void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */ 47 47 bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */ 48 + unsigned int mbox_chan_tx_slots_available(struct mbox_chan *chan); /* atomic */ 48 49 void mbox_free_channel(struct mbox_chan *chan); /* may sleep */ 49 50 50 51 #endif /* __MAILBOX_CLIENT_H */
+13 -4
include/linux/mailbox_controller.h
··· 3 3 #ifndef __MAILBOX_CONTROLLER_H 4 4 #define __MAILBOX_CONTROLLER_H 5 5 6 + #include <linux/bits.h> 6 7 #include <linux/completion.h> 7 8 #include <linux/device.h> 8 9 #include <linux/hrtimer.h> ··· 11 10 #include <linux/types.h> 12 11 13 12 struct mbox_chan; 13 + 14 + /* Sentinel value distinguishing "no active request" from "NULL message data" */ 15 + #define MBOX_NO_MSG ((void *)-1) 16 + 17 + #define MBOX_TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */ 18 + #define MBOX_TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */ 19 + #define MBOX_TXDONE_BY_ACK BIT(2) /* S/W ACK received by Client ticks the TX */ 14 20 15 21 /** 16 22 * struct mbox_chan_ops - methods to control mailbox channels ··· 62 54 63 55 /** 64 56 * struct mbox_controller - Controller of a class of communication channels 65 - * @dev: Device backing this controller 66 - * @ops: Operators that work on each communication chan 67 - * @chans: Array of channels 68 - * @num_chans: Number of channels in the 'chans' array. 57 + * @dev: Device backing this controller. Required. 58 + * @ops: Operators that work on each communication chan. Required. 59 + * @chans: Array of channels. Required. 60 + * @num_chans: Number of channels in the 'chans' array. Required. 69 61 * @txdone_irq: Indicates if the controller can report to API when 70 62 * the last transmitted data was read by the remote. 71 63 * Eg, if it has some TX ACK irq. ··· 78 70 * @of_xlate: Controller driver specific mapping of channel via DT 79 71 * @poll_hrt: API private. hrtimer used to poll for TXDONE on all 80 72 * channels. 73 + * @poll_hrt_lock: API private. Lock protecting access to poll_hrt. 81 74 * @node: API private. To hook into list of controllers. 82 75 */ 83 76 struct mbox_controller {