From patchwork Wed Nov 30 12:58:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13059777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B828C433FE for ; Wed, 30 Nov 2022 13:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=7Hhz7cSDS6hXTnX/OVKfnrYjCOfwAXfsFwAblmLBDDw=; b=fkrjot0tQK2b6W h4Jcaaj8pJkttbYl9KlsI+zedcfwG8LY8200Yv42Vvnhbil3Fu0x9er4VqAegYDRj6FZFawboisdA YROMLtKWQx6ROtQWOgZxdirl5A7tp70lZZ/joVRPBv8//EBDYKGOe5yvTve2YKvUTDWDjDBOBYJ6g RwyazEuHmPKpWYeaEN8+/q/N3FRXbOrbJsi+wp6D5WdfATigISqscsWNNImac2QkJywUMXWbVIZYt hy2MeO3/XZQoAMGa8nacSwB8UaqTOkP+2NmH8JnujsDY0/ga6TmkizB7rxXX+QkPDv6bj30PXmmqi /sz70fAiFlFlMM11yuhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0Mft-00GJGJ-PM; Wed, 30 Nov 2022 12:58:53 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0Mfq-00GJEq-0c for linux-arm-kernel@lists.infradead.org; Wed, 30 Nov 2022 12:58:51 +0000 Received: by mail-ej1-x635.google.com with SMTP id vp12so39862742ejc.8 for ; Wed, 30 Nov 2022 04:58:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=VZK/oG0G2NuDkN3Zt9Gzw1YbRQao+w/pvv7GC7syMzY=; b=cax1DoaooXKpn0DF2NXjX+cZUNFQzeHQsCF3ZlsrPv1mureGxgy8+ADefVUXNM9uIW CKdRCuZ1qiDSLkuA/mpqLbMJT48eBQA4KsmIXG17gTWU82KIzEJXH3n38mFc6HfFhK5+ ril5KOr3MFDTFh3dl6cvFxSrNY3+19bKzJ7HU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VZK/oG0G2NuDkN3Zt9Gzw1YbRQao+w/pvv7GC7syMzY=; b=cnEVParp9/0pTam8oB0AXDBXcExGIchtwX1RdzoXfiyK6s3fl2PWMEElg0VuH8Xt1d eZ6A3P9Un2QN7YxuM+jhfj/QzsEr7+4iPzwGmYiWAXh0PnojAcWMBNRkv4BH5rOxuJHP zwo4SpQmp7+13CY3bbQlcBvTMpEk7VSmqpm/wISGgdUJEf/aXZKP8gYpMzL+s5Yob6W4 rzXy8GsD2AzHfbn1Z0fJ5X5Q6eYbYCcG2FDLZbPIuoOfawYfnwf1MnO+ZC/tJ9YVor+4 67is5GmvCs6vZFoQKkqe7eLldqBVIzev4EAW5j33aCSyIz02WPNWJP8etJ5AZt6P6ehE +Hgg== X-Gm-Message-State: ANoB5pkGNl0PjQIckmyHJHpo25xmtXEkmzd1ghaxfk4pshdmcP7WcZdA SCLDk10bYu+WAb+7DEx6CXohPw== X-Google-Smtp-Source: AA0mqf7o7/gIBBokSQZ3QX/bREXblDhig+YjdUuH56LgZKXBvfJV2rnrsfAhMcMRbMa/ZSeYTImISQ== X-Received: by 2002:a17:906:dfc1:b0:78d:894d:e123 with SMTP id jt1-20020a170906dfc100b0078d894de123mr1246435ejc.112.1669813126359; Wed, 30 Nov 2022 04:58:46 -0800 (PST) Received: from alco.roam.corp.google.com ([2620:0:1059:10:29cf:b72a:5a9b:a4aa]) by smtp.gmail.com with ESMTPSA id j10-20020a50ed0a000000b0046892e493dcsm619872eds.26.2022.11.30.04.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 04:58:46 -0800 (PST) From: Ricardo Ribalda Date: Wed, 30 Nov 2022 13:58:22 +0100 Subject: [PATCH v3] mailbox: mtk-cmdq: Do not request irq until we are ready MIME-Version: 1.0 Message-Id: <20221125-mtk-mailbox-v3-0-c4b635052b65@chromium.org> To: Jassi Brar , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-arm-kernel@lists.infradead.org, Ricardo Ribalda , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=2213; i=ribalda@chromium.org; h=from:subject:message-id; bh=JaMGeOMpmAXuv3OKor0whCcN0kyMhzBZsPq/TlDMCd0=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjh1N1HmjWa3ZkM+ohfEpYfD/yTFRjgkqcXvs7TAbz iHD9waiJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4dTdQAKCRDRN9E+zzrEiNVbD/ 997bPhkM4Tp0Vm9eaTCHZ8XZDPLNvOrVogWdgK/ByjYWNQ4137QEZwgW+YLN7LCGEm6Z5ByeTACf0+ 3dSNgK+4ftYeEsYPIEzOVSVkfK+bWMz4H/y4/OrzicCKQOJTXsO9r47SmwYHLLM/7YL09pdpuGxAIG 7Aa2DYVQ8cQy0WctP5qFfZ7W6iGXFdZKRtTSCX2eHGwb6iPjCXAc1l+INxVyF8URkCIHF3zIF3zTL+ 3uyntHRoTPECk+hDVXm+htEE/l40MiVxoR6+/BH2YzMOJK4n0h8nhU4zTwok1Vkt5x8q9SpJsOnZFA nn3LauNEQJSHpUwhac+Y04QnL1FZCg6nhGOxLGtleSNrc3wDuLtHI0oMMx82SvGI7gH4FQgaP9yQte fvEClF21UVBxwTm0ZwEJG779oWAFitYo1NhkZOL2UN9/PytWLjI+NA8rj0bJVP+FNrvcQuMivvUbAv Xo6N5hFPbfCetD0jkRt0UGQ/FylvHNNzURWVIamvdZCuUTZUHcRQmojrT8EFSQKTprna5Q5HVYELKz LG/ze+fwSOUyskGXYl4KLaNvEjB7qZ/Q7t2YRAG1GnhHdZIlTEVrsiYL+e9OwA6eUSSvF+gxqAsqBx GaoDFXUS7nA3mDn7Joo3MvwEqbtrdjczM91St6Jt3JqhzuRpChFdNKAbrdYA== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_045850_062623_BD1EE11A X-CRM114-Status: GOOD ( 16.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Chun-Kuang Hu --- To: AngeloGioacchino Del Regno To: Jassi Brar To: Matthias Brugger 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, 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; }