Re: [PATCH v3 2/3] mailbox: mediatek: add support for adsp mailbox controller
From: allen-kh.cheng <hidden>
Date: 2021-11-25 01:53:19
Also in:
alsa-devel, linux-mediatek
Hi Tzung-Bi, Thanks for your suggestions. On Wed, 2021-11-24 at 18:25 +0800, Tzung-Bi Shih wrote:
quoted
On Wed, Nov 24, 2021 at 04:45:13PM +0800, allen-kh.cheng wrote:quoted
quoted
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index c9fc06c7e685..fc99d9fc80af 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig@@ -236,6 +236,13 @@ config MTK_CMDQ_MBOX critical time limitation, such as updating displayconfiguration during the vblank. +config MTK_ADSP_IPC_MBOX + tristate "MediaTek ADSP Mailbox Controller" + depends on ARCH_MEDIATEK || COMPILE_TEST + help + Say yes here to add support for MediaTek ADSP IPC mailbox controller + driver. It is used to send short messages betweenprocessorsquoted
quoted
with dsp.quoted
Although the file didn't maintain alphabetical order, to be neat, moving MTK_ADSP_IPC_MBOX before MTK_CMDQ_MBOX makes more sense.quoted
quoted
diff --git a/drivers/mailbox/Makefileb/drivers/mailbox/Makefilequoted
quoted
index c2089f04887e..479a9ae56d5e 100644--- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile@@ -51,6 +51,8 @@ obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o obj-$(CONFIG_MTK_CMDQ_MBOX) += mtk-cmdq-mailbox.o +obj-$(CONFIG_MTK_ADSP_IPC_MBOX) += mtk-adsp-mailbox.o +quoted
Ditto. Move CONFIG_MTK_ADSP_IPC_MBOX before CONFIG_MTK_CMDQ_MBOX without blank line separation.quoted
quoted
diff --git a/drivers/mailbox/mtk-adsp-mailbox.cb/drivers/mailbox/mtk-adsp-mailbox.cquoted
[...]quoted
quoted
+static irqreturn_t mtk_adsp_ipc_irq_handler(int irq, void*data)quoted
quoted
+{ + struct mbox_chan *ch = (struct mbox_chan *)data;quoted
The cast should be able to remove.quoted
quoted
+static irqreturn_t mtk_adsp_ipc_handler(int irq, void *data) +{ + struct mbox_chan *ch = (struct mbox_chan *)data;quoted
The cast should be able to remove.quoted
quoted
+static int mtk_adsp_mbox_startup(struct mbox_chan *chan) +{ + struct adsp_mbox_ch_info *ch_info = chan->con_priv; + void __iomem *reg = ch_info->va_reg; + + /* Clear DSP mbox command */ + writel(0xFFFFFFFF, reg + MTK_ADSP_MBOX_IN_CMD_CLR); + writel(0xFFFFFFFF, reg + MTK_ADSP_MBOX_OUT_CMD_CLR); + + return 0; +} + +static void mtk_adsp_mbox_shutdown(struct mbox_chan *chan) +{ + chan->con_priv = NULL; +}quoted
Shall mtk_adsp_mbox_shutdown() also clear DSP mbox? I.e.: writel(0xFFFFFFFF, reg + MTK_ADSP_MBOX_IN_CMD_CLR); writel(0xFFFFFFFF, reg + MTK_ADSP_MBOX_OUT_CMD_CLR);quoted
quoted
+static int mtk_adsp_mbox_send_data(struct mbox_chan *chan,voidquoted
quoted
*data) +{ + struct adsp_mbox_ch_info *ch_info = chan->con_priv; + void __iomem *reg = ch_info->va_reg; + + spin_lock(&ch_info->lock); + writel(ch_info->ipc_op_val, reg + MTK_ADSP_MBOX_IN_CMD); + spin_unlock(&ch_info->lock);quoted
Why does it need the lock? Is the write to MTK_ADSP_MBOX_IN_CMD a synchronous operation? - If yes, I failed to understand why does it need the lock. Every calls to mtk_adsp_mbox_send_data() should wait for the datatransferquoted
completion. - If no, I also failed to understandwhy. mtk_adsp_mbox_send_data()quoted
has no way to be aware of the transfer completion. Would expect a loop for checking the completion for the case.
In ADSP MBOX IPC flow, Host would call mbox send data when the shared data transfer completed. (mtk_adsp_mbox_send_data will notice client using MTK_ADSP_MBOX_IN_CMD) It’s more like a signal. In general case, There may be some hosts use the same mbox channel. I think it’s better using lock to protect access to MTK_ADSP_MBOX_IN_CMD registers Thanks, Allen
quoted
quoted
quoted
+static bool mtk_adsp_mbox_last_tx_done(struct mbox_chan *chan) +{ + struct adsp_mbox_ch_info *ch_info = chan->con_priv; + void __iomem *reg = ch_info->va_reg; + u32 op = readl(reg + MTK_ADSP_MBOX_IN_CMD); + + return (op == 0) ? true : false;quoted
To be concise, return readl(...) == 0;quoted
quoted
+static int mtk_adsp_mbox_probe(struct platform_device *pdev) +{quoted
[...]quoted
quoted
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "no adsp mbox register resource\n"); + return -ENXIO; + } + + size = resource_size(res); + priv->va_mboxreg = devm_ioremap(dev, (phys_addr_t)res-start,quoted
size); + if (IS_ERR(priv->va_mboxreg)) + return PTR_ERR(priv->va_mboxreg);quoted
Use devm_platform_ioremap_resource(), it should be equivalent.quoted
quoted
+ /* set adsp mbox channel info */ + ch_info = devm_kzalloc(mbox->dev, sizeof(*ch_info), GFP_KERNEL);quoted
To be neat, use dev instead of mbox->dev.quoted
quoted
+ ret = devm_mbox_controller_register(dev, &priv->mbox); + if (ret < 0) + dev_err(dev, "error: failed to register mailbox:%d\n", ret); + + return ret;quoted
To be concise, return devm_mbox_controller_register(...);
_______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel