Skip to content

Commit 060e4e8

Browse files
3V3RYONEJassi Brar
authored andcommitted
mailbox: omap-mailbox: Check for pending msgs only when mbox is exclusive
On TI K3 devices, the mailbox resides in the Always-On power domain (LPSC_main_alwayson) and is shared among multiple processors. The mailbox is not solely exclusive to Linux. Currently, the suspend path checks all FIFO queues for pending messages and blocks suspend if any are present. This behavior is unnecessary for K3 devices, since some of the FIFOs are used for RTOS<->RTOS communication and are independent of Linux. For FIFOs used in Linux<->RTOS communication, any pending message would trigger an interrupt, which naturally prevents suspend from completing. Hence, there is no need for the mailbox driver to explicitly check for pending messages on K3 platforms. Introduce a device match flag to indicate whether the mailbox instance is exclusive to Linux, and skip the pending message check for non-exclusive instances (such as in K3). Fixes: a49f991 ("arm64: dts: ti: k3-am62-verdin: Add missing cfg for TI IPC Firmware") Closes: https://lore.kernel.org/all/sid7gtg5vay5qgicsl6smnzwg5mnneoa35cempt5ddwjvedaio@hzsgcx6oo74l/ Signed-off-by: Beleswar Padhi <b-padhi@ti.com> Tested-by: Hiago De Franco <hiago.franco@toradex.com> Reviewed-by: Andrew Davis <afd@ti.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
1 parent ac3fd01 commit 060e4e8

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

drivers/mailbox/omap-mailbox.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct omap_mbox_fifo {
6868

6969
struct omap_mbox_match_data {
7070
u32 intr_type;
71+
bool is_exclusive;
7172
};
7273

7374
struct omap_mbox_device {
@@ -78,6 +79,7 @@ struct omap_mbox_device {
7879
u32 num_users;
7980
u32 num_fifos;
8081
u32 intr_type;
82+
const struct omap_mbox_match_data *mbox_data;
8183
};
8284

8385
struct omap_mbox {
@@ -341,11 +343,13 @@ static int omap_mbox_suspend(struct device *dev)
341343
if (pm_runtime_status_suspended(dev))
342344
return 0;
343345

344-
for (fifo = 0; fifo < mdev->num_fifos; fifo++) {
345-
if (mbox_read_reg(mdev, MAILBOX_MSGSTATUS(fifo))) {
346-
dev_err(mdev->dev, "fifo %d has unexpected unread messages\n",
347-
fifo);
348-
return -EBUSY;
346+
if (mdev->mbox_data->is_exclusive) {
347+
for (fifo = 0; fifo < mdev->num_fifos; fifo++) {
348+
if (mbox_read_reg(mdev, MAILBOX_MSGSTATUS(fifo))) {
349+
dev_err(mdev->dev, "fifo %d has unexpected unread messages\n",
350+
fifo);
351+
return -EBUSY;
352+
}
349353
}
350354
}
351355

@@ -378,8 +382,9 @@ static const struct dev_pm_ops omap_mbox_pm_ops = {
378382
SET_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume)
379383
};
380384

381-
static const struct omap_mbox_match_data omap2_data = { MBOX_INTR_CFG_TYPE1 };
382-
static const struct omap_mbox_match_data omap4_data = { MBOX_INTR_CFG_TYPE2 };
385+
static const struct omap_mbox_match_data omap2_data = { MBOX_INTR_CFG_TYPE1, true };
386+
static const struct omap_mbox_match_data omap4_data = { MBOX_INTR_CFG_TYPE2, true };
387+
static const struct omap_mbox_match_data am654_data = { MBOX_INTR_CFG_TYPE2, false };
383388

384389
static const struct of_device_id omap_mailbox_of_match[] = {
385390
{
@@ -396,11 +401,11 @@ static const struct of_device_id omap_mailbox_of_match[] = {
396401
},
397402
{
398403
.compatible = "ti,am654-mailbox",
399-
.data = &omap4_data,
404+
.data = &am654_data,
400405
},
401406
{
402407
.compatible = "ti,am64-mailbox",
403-
.data = &omap4_data,
408+
.data = &am654_data,
404409
},
405410
{
406411
/* end */
@@ -449,7 +454,6 @@ static int omap_mbox_probe(struct platform_device *pdev)
449454
struct omap_mbox_fifo *fifo;
450455
struct device_node *node = pdev->dev.of_node;
451456
struct device_node *child;
452-
const struct omap_mbox_match_data *match_data;
453457
struct mbox_controller *controller;
454458
u32 intr_type, info_count;
455459
u32 num_users, num_fifos;
@@ -462,11 +466,6 @@ static int omap_mbox_probe(struct platform_device *pdev)
462466
return -ENODEV;
463467
}
464468

465-
match_data = of_device_get_match_data(&pdev->dev);
466-
if (!match_data)
467-
return -ENODEV;
468-
intr_type = match_data->intr_type;
469-
470469
if (of_property_read_u32(node, "ti,mbox-num-users", &num_users))
471470
return -ENODEV;
472471

@@ -483,6 +482,12 @@ static int omap_mbox_probe(struct platform_device *pdev)
483482
if (!mdev)
484483
return -ENOMEM;
485484

485+
mdev->mbox_data = device_get_match_data(&pdev->dev);
486+
if (!mdev->mbox_data)
487+
return -ENODEV;
488+
489+
intr_type = mdev->mbox_data->intr_type;
490+
486491
mdev->mbox_base = devm_platform_ioremap_resource(pdev, 0);
487492
if (IS_ERR(mdev->mbox_base))
488493
return PTR_ERR(mdev->mbox_base);

0 commit comments

Comments
 (0)