Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp491139pxu; Thu, 3 Dec 2020 05:39:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJycFnG7EGmRw+uupbaZmA+vrm+fuSshljpwHM6LEWSt0njKLs8DE43fbvyfhTQ3T2xCmGB2 X-Received: by 2002:a17:906:1481:: with SMTP id x1mr2569090ejc.186.1607002794496; Thu, 03 Dec 2020 05:39:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607002794; cv=none; d=google.com; s=arc-20160816; b=lZsBaRZdpvcIEV1JX2ZZg9a/Eg25IoGjygamZky0KGBFBtuIb55mPFg+Ogga4s2hcv g04REgqZKnV7Vwrv4Ks0BLFd65vHgBWSkM6SGVnUy+4lvFq2d/pCc2pwJPGwIU516iaQ BqEFhIxT9kq+2s++ig1EHRnjlGo3VKJ7JNG5NRWHdkOxHvNnHE55FXvd4nU1lo+ChEue PKE8Rz39leczMMckmCLOGMgZsP5DjuJE0zK/wbIw1ui97zPikAKqBrNwcK9uBCsU8FzV PagcLTK7/SUBlooMSFE1SyKIAHTqiqv0vk9f9j3CeHhVoIebAIdUDu30aMPFnbITtd04 XEQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Wa9TxwenCfzsNA0Zwgc7R2qNVXy/B+hsMho//d8AiY0=; b=EoRCN8GOeJc9sNbTkC40HDYrRD2PZl1p+PL2N/31gPDEXqr1BgALcCMXmMTktdGLkh vT8S/4Fa6SQ6ttqaknv8HZJiahSArBhlJaLZv57zDLhHSBtDXoVf9NLMdcZeeuL35vC4 q94O2G9PD8E0lVUnugHiTUTLF4Keu4BDIz7EMqxUdtSl92aAD7eaGKCbY1MWlNSknX2M xhcJbIoApOhBZBL8Y323AApdzxCMNXYT7bQbRYMHgFAdJtllO5cleqE3USi6Itus/1gs NNFdABWia6fBn72s2IVkuQsi1Rw85vVl+uDt58Zfl4NifCTDxXMyzPXceWy143dgHQ55 TkqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 92si958135edm.533.2020.12.03.05.39.27; Thu, 03 Dec 2020 05:39:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436886AbgLCNhv (ORCPT + 99 others); Thu, 3 Dec 2020 08:37:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:47840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436508AbgLCNaP (ORCPT ); Thu, 3 Dec 2020 08:30:15 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ran Wang , Han Xu , Mark Brown , Sasha Levin , linux-spi@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 21/39] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts Date: Thu, 3 Dec 2020 08:28:15 -0500 Message-Id: <20201203132834.930999-21-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201203132834.930999-1-sashal@kernel.org> References: <20201203132834.930999-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ran Wang [ Upstream commit 71d80563b0760a411cd90a3680536f5d887fff6b ] Given the case that bootloader(such as UEFI)'s FSPI driver might not handle all interrupts before loading kernel, those legacy interrupts would assert immidiately once kernel's FSPI driver enable them. Further, if it was FSPI_INTR_IPCMDDONE, the irq handler nxp_fspi_irq_handler() would call complete(&f->c) to notify others. However, f->c might not be initialized yet at that time, then cause kernel panic. Of cause, we should fix this issue within bootloader. But it would be better to have this pacth to make dirver more robust (by clearing all interrupt status bits before enabling interrupts). Suggested-by: Han Xu Signed-off-by: Ran Wang Link: https://lore.kernel.org/r/20201123025715.14635-1-ran.wang_1@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-nxp-fspi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index 1ccda82da2063..158e09470898b 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -991,6 +991,7 @@ static int nxp_fspi_probe(struct platform_device *pdev) struct resource *res; struct nxp_fspi *f; int ret; + u32 reg; ctlr = spi_alloc_master(&pdev->dev, sizeof(*f)); if (!ctlr) @@ -1017,6 +1018,12 @@ static int nxp_fspi_probe(struct platform_device *pdev) goto err_put_ctrl; } + /* Clear potential interrupts */ + reg = fspi_readl(f, f->iobase + FSPI_INTR); + if (reg) + fspi_writel(f, reg, f->iobase + FSPI_INTR); + + /* find the resources - controller memory mapped space */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fspi_mmap"); if (!res) { -- 2.27.0