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: 26160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4355118wrr; Fri, 25 Nov 2022 15:45:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf4hp1BmZ5oBwnVROR5Br47xpwgY4UiNiH/1yIdgUhQPw01CDoh+Rdb8E5ggE9V6uKgtaBEy X-Received: by 2002:a17:903:2687:b0:172:b0f3:527f with SMTP id jf7-20020a170903268700b00172b0f3527fmr24273281plb.40.1669419924082; Fri, 25 Nov 2022 15:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669419924; cv=none; d=google.com; s=arc-20160816; b=zt8upEeGOcvk9Gq65YfSrITKTg9495vYjhYwnXPLi/753IXex3/wIb+tjkByoPQ9NO uwKAUUBvH17uQlJ/WA3kHQVEqOcLwqEbw3sEE6EUeCYjesljXRXahdeJMMOgr6NsvgaN ki43HFUe79SFq7Ws6uz00P5NSWZnon3P8YFw0NiwVQBYJMqbKcZwdwGEehF0wTu/Y3IT eK6LvJiVP02qV3iANMiYNNgr/4qUlOvciZbYlSSxa5jQhRdP5sWTGou75h6cgzPzDH8y bKGErkSPPTI0FYTSWyVOtztCrIakAcP7zSx/f5m21pB30KDrtgbSNOmtnCmsbDjSCej8 Cu5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=4NT0UyLFq74utORBOv4WInxsxyZMPY8J7uSXPHg5TpA=; b=zArLkJcD4v1vtpGw7Fub0OqaYRfAMwbDCJ3UeYYQNlWv2VlW/4jHm57axQwCi4ZzRs fgoXcG6LsM6EqpsRPG7y76fe/Ix31idbrf3McEGcKRn+Ly+1X8hBP21LIZqzojn7UEkE XW+i05k1xZvplIVqpSEc1Vf+uoOJvo781PvySJibv3NMODGloDodRod5JaQ7RwjsUWbp drqhyyyHnFarcn+q88Bg/Co+0y52KniYFrnm9q1ko8dz64XSQ+yIiZEj/HhARB66Pq6G 0861ESyuq3j4CIelUcuk8gtgPJtJaA2X4meQX8Hemm3GSf1V3tjCHsne+/1TCtv15ga4 quQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BW6K4u2C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l192-20020a6391c9000000b0046b2bef339csi4288990pge.257.2022.11.25.15.45.08; Fri, 25 Nov 2022 15:45:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BW6K4u2C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230006AbiKYXcw (ORCPT + 99 others); Fri, 25 Nov 2022 18:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229868AbiKYXcs (ORCPT ); Fri, 25 Nov 2022 18:32:48 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9513B1B7AA for ; Fri, 25 Nov 2022 15:32:46 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id z18so8149117edb.9 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=7IcPlcpQCNHRMum5NyUiPqs0jVfqYJVxykegYw5ms6gzIvSm9kKEnHZ80bwHJsbwq2 Bu9fcueODYomaxbZtXXo+VYW1DFhJRnCewRpTgP4AboEdYJh1IO6YnZdrMTgciSVPWoi uHHS4FWe8Sj6sExDUKvy7p05VFk0BcUSTMSb1R1vui0YbXg8o2XyRJgVuF2RrXaxZpJE k6Wgtn4uqe2ojcxRksJhrA6c2/zdXDf7jnncGSAjB1SsLeckIS5FgcaGKp1G3wZRdZ0H rApGWn0fcuYa3Oed7C5YLAoXFceoQIrEQ72GJhYg/uRmsqydnpTBwy48TfpLOGPsgHcv 2gXg== X-Gm-Message-State: ANoB5pn3+nV0VMm8O33bmyLbcCpE0PT30zsesStemdkbZEnJnwBtzg0o 4CCVkC4b+x42lJFeFlPwNKiyMA== 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750485980077311889?= X-GMAIL-MSGID: =?utf-8?q?1750513666715556933?= 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; }