diff mbox series

[v3] mailbox: mtk-cmdq: Do not request irq until we are ready

Message ID 20221125-mtk-mailbox-v3-0-c4b635052b65@chromium.org (mailing list archive)
State New, archived
Headers show
Series [v3] mailbox: mtk-cmdq: Do not request irq until we are ready | expand

Commit Message

Ricardo Ribalda Nov. 30, 2022, 12:58 p.m. UTC
If the system comes from kexec() the peripheral might trigger an IRQ
befoe we are ready for it. Triggering a crash due to an access to
invalid memory.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Jassi Brar <jassisinghbrar@gmail.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
---
Changes in v3:
- Rebase on top of https://patchwork.kernel.org/project/linux-mediatek/patch/20221102100736.37815-1-angelogioacchino.delregno@collabora.com/
- Link to v2: https://lore.kernel.org/r/20221125-mtk-mailbox-v2-0-886f70c7173c@chromium.org

Changes in v2:
- I have managed to repro a different panic. Moving the irq enabling to the very end of probe.
- Link to v1: https://lore.kernel.org/r/20221125-mtk-mailbox-v1-0-2e3ee120850c@chromium.org
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)


---
base-commit: 1642107db81361b4339643eb90af4839e2cf229f
change-id: 20221125-mtk-mailbox-ba6cbd1d91b6

Best regards,

Comments

AngeloGioacchino Del Regno Dec. 1, 2022, 8:47 a.m. UTC | #1
Il 30/11/22 13:58, Ricardo Ribalda ha scritto:
> If the system comes from kexec() the peripheral might trigger an IRQ
> befoe we are ready for it. Triggering a crash due to an access to
> invalid memory.
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Chun-Kuang Hu Dec. 5, 2022, 11:16 p.m. UTC | #2
Ricardo Ribalda <ribalda@chromium.org> 於 2022年11月30日 週三 晚上8:59寫道:
>
> If the system comes from kexec() the peripheral might trigger an IRQ
> befoe we are ready for it. Triggering a crash due to an access to
> invalid memory.

Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>

>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> To: Jassi Brar <jassisinghbrar@gmail.com>
> To: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> ---
> Changes in v3:
> - Rebase on top of https://patchwork.kernel.org/project/linux-mediatek/patch/20221102100736.37815-1-angelogioacchino.delregno@collabora.com/
> - Link to v2: https://lore.kernel.org/r/20221125-mtk-mailbox-v2-0-886f70c7173c@chromium.org
>
> Changes in v2:
> - I have managed to repro a different panic. Moving the irq enabling to the very end of probe.
> - Link to v1: https://lore.kernel.org/r/20221125-mtk-mailbox-v1-0-2e3ee120850c@chromium.org
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index a460ee26eb11..b18d47ea13a0 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -569,12 +569,6 @@ static int cmdq_probe(struct platform_device *pdev)
>         }
>
>         cmdq->irq_mask = GENMASK(cmdq->pdata->thread_nr - 1, 0);
> -       err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
> -                              "mtk_cmdq", cmdq);
> -       if (err < 0) {
> -               dev_err(dev, "failed to register ISR (%d)\n", err);
> -               return err;
> -       }
>
>         dev_dbg(dev, "cmdq device: addr:0x%p, va:0x%p, irq:%d\n",
>                 dev, cmdq->base, cmdq->irq);
> @@ -641,6 +635,13 @@ static int cmdq_probe(struct platform_device *pdev)
>
>         cmdq_init(cmdq);
>
> +       err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
> +                              "mtk_cmdq", cmdq);
> +       if (err < 0) {
> +               dev_err(dev, "failed to register ISR (%d)\n", err);
> +               return err;
> +       }
> +
>         return 0;
>  }
>
>
> ---
> base-commit: 1642107db81361b4339643eb90af4839e2cf229f
> change-id: 20221125-mtk-mailbox-ba6cbd1d91b6
>
> Best regards,
> --
> Ricardo Ribalda <ribalda@chromium.org>
>
diff mbox series

Patch

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index a460ee26eb11..b18d47ea13a0 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -569,12 +569,6 @@  static int cmdq_probe(struct platform_device *pdev)
 	}
 
 	cmdq->irq_mask = GENMASK(cmdq->pdata->thread_nr - 1, 0);
-	err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
-			       "mtk_cmdq", cmdq);
-	if (err < 0) {
-		dev_err(dev, "failed to register ISR (%d)\n", err);
-		return err;
-	}
 
 	dev_dbg(dev, "cmdq device: addr:0x%p, va:0x%p, irq:%d\n",
 		dev, cmdq->base, cmdq->irq);
@@ -641,6 +635,13 @@  static int cmdq_probe(struct platform_device *pdev)
 
 	cmdq_init(cmdq);
 
+	err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
+			       "mtk_cmdq", cmdq);
+	if (err < 0) {
+		dev_err(dev, "failed to register ISR (%d)\n", err);
+		return err;
+	}
+
 	return 0;
 }