From patchwork Fri Nov 25 23:32: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: 13056315 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 E7124C43217 for ; Fri, 25 Nov 2022 23:33:56 +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=My+Eo+C1nmjvwdyJlXn+O1Haqo1wEcC6YI8J4jaLrjQ=; b=bQK+sc0OgQRZxO +yip0oavi1234ROGqwjsasFOwuCceqaQCix7CSoXRhKL7OsESHGQ9zX2INZ3rSrFTi0EEwM7GoakG yxMD4wso/vrbLoX7/HlzTb4eqKM3+AGdYGGIKT0h1vvm1tNg+UU8BV1puypGhAY2eQnvETmpZKdns gN7j7vZkwmL1KfuqDSPAySpa4f5DFqYzOzNwVXwcJ/WgYNgS0OfQXcr80rmsuQK9fd73V5C1dRZa5 ne/oDjPS6ve470Zq1ncu7N7+ByNjwYAnEoB7Va20boPlI41AymhCQSBOOJMfWRmhFpwIQyZwRuJ6p Fqn17a18wcMp1gWOdDCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyiBg-002qRt-5y; Fri, 25 Nov 2022 23:32:52 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyiBb-002qQC-Ev for linux-arm-kernel@lists.infradead.org; Fri, 25 Nov 2022 23:32:49 +0000 Received: by mail-ed1-x532.google.com with SMTP id z20so8160712edc.13 for ; Fri, 25 Nov 2022 15:32:46 -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=4NT0UyLFq74utORBOv4WInxsxyZMPY8J7uSXPHg5TpA=; b=BW6K4u2C+woJDSiuJAEih/ZnYA0F9FxR6us1Bde8zIK4mcIkcYMMCJwbyUWkXu1h6r pzcFc+fO6MESNK3xN9+ooAvVEEJLUNaWC6ccu35ftWDhQ+N/JEjs87zR178srgsfULL9 UF6Y8mXXg7QupirMwWMUkEm/9Dmif1V4FH+60= 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=4NT0UyLFq74utORBOv4WInxsxyZMPY8J7uSXPHg5TpA=; b=KvBWjVpkck2v0P1YzqIDkbpoEbo/oyv40dkEHOqQRac3aLWy8YqTmZzWkT76hr8MnK UMXWMmh+g0Hb7bt8GoLD/UpNyK3T2aC/H428G2T78ez19C25GEnNMybR4ka84fNA2JsF sQaqmWXAYn1oCNOsKKDv8RVMFgYazrqumGcHd0T15OAVX20j8YNg17Xm1jLkUCrkdHyR qPDlFVFgbEDyfrg8Xqkkd0JmXm4rbwbG0gCHaKTiTcdfy09/CPUCN1nEvKpg+xvhEhyJ 3ci2az6xw6wY5om6zNZCfdMk3NHniI4hOI8Vk4uAud7DDQOwZyqJTR9cdPORbL0c82kr DlnA== X-Gm-Message-State: ANoB5pk82OCuT4bSH+6tgkk7tB7gpSrLpuPCNL88x4Q0E+YDyY8k3MzP YWd1/mueq1nH+Jr5WQsDCNTC3J2N85qk3nZN X-Google-Smtp-Source: AA0mqf5aNjXsBsD6xe6UJddqUzfL16Tyg8A80VdfhLrJdfeM3jFl65zhd5cZyI803E0nQX/s+ODdqQ== X-Received: by 2002:a05:6402:e9c:b0:458:d064:a8c2 with SMTP id h28-20020a0564020e9c00b00458d064a8c2mr37748277eda.346.1669419165220; Fri, 25 Nov 2022 15:32:45 -0800 (PST) Received: from alco.roam.corp.google.com (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id a4-20020aa7d744000000b004615f7495e0sm2325076eds.8.2022.11.25.15.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 15:32:44 -0800 (PST) From: Ricardo Ribalda Date: Sat, 26 Nov 2022 00:32:22 +0100 Subject: [PATCH v2] mailbox: mtk-cmdq: Do not request irq until we are ready MIME-Version: 1.0 Message-Id: <20221125-mtk-mailbox-v2-0-886f70c7173c@chromium.org> To: Matthias Brugger , Jassi Brar Cc: linux-mediatek@lists.infradead.org, Ricardo Ribalda , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=1961; i=ribalda@chromium.org; h=from:subject:message-id; bh=QjxAB+2ksa7uNlJhD3r206IvwLS8xrHsNDF+xigH57s=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjgVCLcbL6+FYpmnVdQr6P3EW3wpQ5JbUz/SYX3vu5 oY2BcJ6JAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4FQiwAKCRDRN9E+zzrEiGx7D/ 4unhnIlngokFsgCtXIVGn9UwrructwwSqM3dW4jQBnylKPqVJBca+a8ifBW4QvCFH2SCFxLJEynWrN 4KtM6nYyBvJnucIh6FC4je5ktr11CplKMAxcBPEe6ICJffvI4Lmn7eiobgKrC2V8mBqm1KMhPHTBvI XRxf1SjycDxThmDNqZnBEBBbpKSMKnnNYet/PTydUs/vrpU84H+MplwHGKiqp/BX8GEU66oYrUZCeK T2BX4vf+3BySMNlY8McuJGyqG+ttCsVzc/Kku6QkxicxfouNV7AvaBo2ojfnR7v5F7+7AWm1ToaCLr 7gQgFT+yedAUHdoXmb+1dv59ZqAIuNW2tPcMM9/hhnlqDrcjskHRKGf/4Rg1TAwXaqXctMK7u8R4EY MEGFHMXAM116HamLBnLWOllsw/o31HMbxK5RBxtBHP61yJHdPKp74++DX6+oAKirP+EgSlqsWHv5ti PUg3rxPrngU/05UDKD6g3Z4piSUEgMo+Aks7CFnU9/5OZ4gcw6EiSTep8cdxR4SqjhmWEK7dRb0oKG OYoQX+yoX/03xtE8/GCy7uXJXQ1o4hT2UryOcBjQTfqInB3ypoJCBQ2tvWo9h0dGsSKgRds4Ihds7d YlO78muMw5YUW/EaMOwDE/dc5depwtst6yA0lnjtdAHP0WWufniasBGi1Emw== 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-20221125_153247_567252_B8F0F70C X-CRM114-Status: GOOD ( 15.75 ) 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 --- 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 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: 4312098baf37ee17a8350725e6e0d0e8590252d4 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 9465f9081515..9ff4f89a55c0 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -545,12 +545,6 @@ static int cmdq_probe(struct platform_device *pdev) cmdq->control_by_sw = plat_data->control_by_sw; cmdq->gce_num = plat_data->gce_num; cmdq->irq_mask = GENMASK(cmdq->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); @@ -617,6 +611,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; }