From patchwork Mon Nov 28 11:00:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13057285 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 24054C433FE for ; Mon, 28 Nov 2022 11:01:16 +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=CIDYmGAGVoFz+c2CgG12nMwwIcNA0tYW+iPCSgMffKs=; b=n56snwrVVJZsuJ Rc2O3N8tiNxjOFoMunrBonnVaXAh3fdA6FKru4Fe2KgVm6rAgSIATtkiERYnQrgpVnlu943ztwPx9 s8qc+w+gbRRvT4n6UF4+Fs3abUeYESPYOdGe+mqzxLOuUwU3tznXBSuQ4B1jWdpIN+QUb/bqdry04 hiC8tVrrRqx4ladUPiecZzaqaVLNhnbMF77Ot4zrSlPl4Xe4ffPkE7FwhP3L1n47pLr5wGxEM90d8 wvMfipj/RHl6FFppkr8mklbdflv3uumy6ArP1CBlEYnVYqHcbWykhaOffNOUL4CU1PXvi8ehoExO5 Bkw7cmp3BCqnTDLEboZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ozbrx-0019WS-0t; Mon, 28 Nov 2022 11:00:13 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ozbrt-0019UY-P1 for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2022 11:00:11 +0000 Received: by mail-ej1-x629.google.com with SMTP id n20so24862226ejh.0 for ; Mon, 28 Nov 2022 03:00:07 -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=n/FObQx7gNNEzu7Fz/r+02A9P2+kih+CkY8d1AEZ/l8=; b=h5o9ZaEMnmeJX3u40x3jnQaj68fWIfoDhpsEQ+uOJwWZ26WPgcBwccF8lp6Py+GV1y EaWDSfD1LmPrSaszCw2l58dT9n2shvErQOB1QYrBOtp20rTPAzaGGutEvhKFo8zaDjvV 1b3L8pQY4TzcHVDoUv9BmoLbS7difwkG2VgbY= 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=n/FObQx7gNNEzu7Fz/r+02A9P2+kih+CkY8d1AEZ/l8=; b=KMmKN7mjn1yhsRqI7RtHIMtzr1rZWlrDnvBVn3gH1MxF+lDR/oWtb+3tFnE2baPC4B hjL/YLtVWmSXfj7XagfjAVFeJTVmfR+L2MkpH/neLu8S6V541/p8yByNG4VkW/++dhFa ZqQhbGRot8ZdmpC43ECz2ZUfkgqk7Fw46lsLePffGRKeMJWbozz04zTNEGjpMsG2H+dr x6wBH60Pgyt4strD4uQHq2Ok9NHa7EiNYwqqTQi5/JYpUjz8hE/EabpBN9ZAibj37y6O ASnJotz7N0vqBSgznBBcsmK0Eve7l1nK513O5KCrCT52JaMXDHBZnDDE34W3aNREllXz JYdA== X-Gm-Message-State: ANoB5pkv3kvlkJbzyN+5fGFzh5xjcht88GCFXFaRf7BYyDC3fCTDuN2x nLQx2B1zaOAWpfpDKza1ADRZkQ== X-Google-Smtp-Source: AA0mqf4LpBI8mH+rTkJern/KmNlS838lVLrfISixZ5MmZ7sHkwspV51Z2RZT6R3QzAH/MKuIJ0nhHQ== X-Received: by 2002:a17:906:a983:b0:7b8:31b1:b23f with SMTP id jr3-20020a170906a98300b007b831b1b23fmr26249228ejb.591.1669633206252; Mon, 28 Nov 2022 03:00:06 -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 ku3-20020a170907788300b0078c213ad441sm4812218ejc.101.2022.11.28.03.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 03:00:05 -0800 (PST) From: Ricardo Ribalda Date: Mon, 28 Nov 2022 12:00:01 +0100 Subject: [PATCH] spi: mediatek: Enable irq when pdata is ready MIME-Version: 1.0 Message-Id: <20221128-spi-mt65xx-v1-0-509266830665@chromium.org> To: Mark Brown , Matthias Brugger Cc: Ricardo Ribalda , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.11.0-dev-696ae X-Developer-Signature: v=1; a=openpgp-sha256; l=1943; i=ribalda@chromium.org; h=from:subject:message-id; bh=ZM8EpoUpJvky3qvHPm0h+aUGkH0jg+w0Hxbl4l42SQ0=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjhJSy24ik16jMlF5x2yBj1XDSVYbw1Ttx2xgaYpdg PRJjjOqJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY4SUsgAKCRDRN9E+zzrEiEgYEA CGG7z/n18b8jhUn+olLZ/7A7n4m4s1/aTx0bJ8nwXO5rPTAuq6kV6cpMiiYj1duMK6N+1MLRuVHHPg c7i1Hj32bRjRv+XNNGsd3r5Yty83sMQDkva9tsj2IJ3+hNn0scOHih16CacBebGdLfaiU0sgBKwM28 uiqcCwcTh1gtxaGJx3EeK56m1E4PJc8EzuhqM5Blzj1PdoJyChKtkiZY8eXrlifGem0LoqUzHgXyHs XBR2JYEIfUNDGOhKbScPHgYNWdMwWpOFBtybfouI1oTnEk0soJtOaS7FxfnP9bctHouLnakmVkcwEz YJqq14kU5nT/XZBw5CLgowtPaVoLFCQ2x2SiZ8JKBGUDwspHJfvHwqTdghuRCcZpA5ZCz/WzGv2xg+ ODGEjhNYOi0s09zBYEOnJh6TAVKkTKjqIVsX7WsN/g8yWSbkblCqXnv/k7ewoyXVSw2JzuE5IhGEkN HtOcAQla8GLdwknrrJghh/kSo8cF0KtcK7+YOMAzfU8dptYovwUp0oaYZnrOFn4Z3WUVKBXyE5m5iu 8S65QPBq4cf8i/mKPM/UZSmH5p9OUwVTQz3I7LrrNq0oViGapj3+J8HOPHX9kOjkWO3y093TU4uXww 3Sb/4IHqTcla56jtdqq6CCIZQFwik8/pTr8pgA9mRkBBXrr6pgvTT1qES6pg== 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-20221128_030009_874842_5B0F7159 X-CRM114-Status: GOOD ( 13.73 ) 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 device does not come straight from reset, we might receive an IRQ before we are ready to handle it. Fixes: [ 0.832328] Unable to handle kernel read from unreadable memory at virtual address 0000000000000010 [ 1.040343] Call trace: [ 1.040347] mtk_spi_can_dma+0xc/0x40 ... [ 1.262265] start_kernel+0x338/0x42c Signed-off-by: Ricardo Ribalda Reviewed-by: AngeloGioacchino Del Regno --- To: Mark Brown To: Matthias Brugger Cc: linux-spi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/spi/spi-mt65xx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4 change-id: 20221128-spi-mt65xx-b92c9ca96ffa Best regards, diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index d6aff909fc36..6de8360e5c2a 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -1192,11 +1192,6 @@ static int mtk_spi_probe(struct platform_device *pdev) else dma_set_max_seg_size(dev, SZ_256K); - ret = devm_request_irq(dev, irq, mtk_spi_interrupt, - IRQF_TRIGGER_NONE, dev_name(dev), master); - if (ret) - return dev_err_probe(dev, ret, "failed to register irq\n"); - mdata->parent_clk = devm_clk_get(dev, "parent-clk"); if (IS_ERR(mdata->parent_clk)) return dev_err_probe(dev, PTR_ERR(mdata->parent_clk), @@ -1266,6 +1261,13 @@ static int mtk_spi_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "failed to register master\n"); } + ret = devm_request_irq(dev, irq, mtk_spi_interrupt, + IRQF_TRIGGER_NONE, dev_name(dev), master); + if (ret) { + pm_runtime_disable(dev); + return dev_err_probe(dev, ret, "failed to register irq\n"); + } + return 0; }