Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3036271pxb; Mon, 18 Oct 2021 07:03:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynPFx9Awv9Zzs68iDNBusK1QNYThEZAaEZwdSYZvzxpT7c4BWSXcEwHsnOj7uPOgQNG7YL X-Received: by 2002:a17:907:c25:: with SMTP id ga37mr29661441ejc.2.1634565832709; Mon, 18 Oct 2021 07:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565832; cv=none; d=google.com; s=arc-20160816; b=UfRVEfz6m8BW2orYON2EqC/R+0R9dlZ5QCymN519URh1vm6qYVotXTlI0/Dshm/q9f CePQw4ED47rTa/euYWkUgG00/upKpRkd58EznesKJsglmsZjR77bxgr6l5XNXiFu69XQ Z3T0GSErw6coHVqxKijdcDkyUnE72XFXWUl47l2IxA2D1qRUUlyeUfugf06aAWX1Cz5T ZOuISTZxSbS1DDgFa/VkWVjoaKHvvpy3dfGI3IqUqfv2MWtzYqRqV4K6e3MCQnWMGGbt 13mebAh7l9SOxp8ErEgdXzUS8kDzrfdo16hsyp54EVzPMw2gPmpF9PwjNFs3iBHt83J0 Fn/Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xg+32yNBXIZVa0LNJg+Nay4wbtsMGS0HOtI0wEKbLlI=; b=GZ3m5GAK03wusMpaMBcmxQUG7aOaah7Xbyk00H6evX9sR41wuv1ITn6PoZl+01xqTX EXKTnTsiuR3L6MKTjDmPhcG0yjc5zAH1Nzb+4Qx4F+ns0Up//NN0DLZNKBaP+sfg8Vu2 nVRlhAO9xLtAu62idGGsVq8IwBMNtAxzXMNbJDT32re8xJGoYETTNLbqxu5SPp300gnD yAeW3C12w/Ofd2i2Ny+yEM1mQCj8i4Egy3RgCpjNwXXfw2452fiBB7OnhYEPpDFhJ+GX B+TImyXVV1aKJR/RblF+Yf7GmJWtIkXcnJev5EUbJxRXGVeIkWh8V736zI2xnFgIZ4lt M7GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B1QvUQtA; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si19518927edc.582.2021.10.18.07.03.27; Mon, 18 Oct 2021 07:03:52 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B1QvUQtA; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234327AbhJROCQ (ORCPT + 99 others); Mon, 18 Oct 2021 10:02:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:41656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234399AbhJROAR (ORCPT ); Mon, 18 Oct 2021 10:00:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3509860F56; Mon, 18 Oct 2021 13:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564531; bh=PcqQIb1IhiaRoWComIAtp2rMlcfK8hqwRoXaYragQ1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1QvUQtAcRDAzde4ZmbjIKzOx41rsl4+DLGaGnfA1EV+kqIe+Vh3K/RqpfArZh6gp vvxWECL0miM699onXJiua8qw2G0Lh9JRgDiHxkF5Dmqm2ImcCGQr+g0nsCwd/aGUZK HtQFFhVQk7GihvQn64OV1OLJ8R9t4SHz2m+QphCE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Dasu , Florian Fainelli , Mark Brown Subject: [PATCH 5.14 124/151] spi: bcm-qspi: clear MSPI spifie interrupt during probe Date: Mon, 18 Oct 2021 15:25:03 +0200 Message-Id: <20211018132344.700584835@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kamal Dasu commit 75b3cb97eb1f05042745c0655a7145b0262d4c5c upstream. Intermittent Kernel crash has been observed on probe in bcm_qspi_mspi_l2_isr() handler when the MSPI spifie interrupt bit has not been cleared before registering for interrupts. Fix the driver to move SoC specific custom interrupt handling code before we register IRQ in probe. Also clear MSPI interrupt status resgiter prior to registering IRQ handlers. Fixes: cc20a38612db ("spi: iproc-qspi: Add Broadcom iProc SoCs support") Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Link: https://lore.kernel.org/r/20211008203603.40915-3-kdasu.kdev@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-bcm-qspi.c | 77 ++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 32 deletions(-) --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -1250,10 +1250,14 @@ static void bcm_qspi_hw_init(struct bcm_ static void bcm_qspi_hw_uninit(struct bcm_qspi *qspi) { + u32 status = bcm_qspi_read(qspi, MSPI, MSPI_MSPI_STATUS); + bcm_qspi_write(qspi, MSPI, MSPI_SPCR2, 0); if (has_bspi(qspi)) bcm_qspi_write(qspi, MSPI, MSPI_WRITE_LOCK, 0); + /* clear interrupt */ + bcm_qspi_write(qspi, MSPI, MSPI_MSPI_STATUS, status & ~1); } static const struct spi_controller_mem_ops bcm_qspi_mem_ops = { @@ -1397,6 +1401,47 @@ int bcm_qspi_probe(struct platform_devic if (!qspi->dev_ids) return -ENOMEM; + /* + * Some SoCs integrate spi controller (e.g., its interrupt bits) + * in specific ways + */ + if (soc_intc) { + qspi->soc_intc = soc_intc; + soc_intc->bcm_qspi_int_set(soc_intc, MSPI_DONE, true); + } else { + qspi->soc_intc = NULL; + } + + if (qspi->clk) { + ret = clk_prepare_enable(qspi->clk); + if (ret) { + dev_err(dev, "failed to prepare clock\n"); + goto qspi_probe_err; + } + qspi->base_clk = clk_get_rate(qspi->clk); + } else { + qspi->base_clk = MSPI_BASE_FREQ; + } + + if (data->has_mspi_rev) { + rev = bcm_qspi_read(qspi, MSPI, MSPI_REV); + /* some older revs do not have a MSPI_REV register */ + if ((rev & 0xff) == 0xff) + rev = 0; + } + + qspi->mspi_maj_rev = (rev >> 4) & 0xf; + qspi->mspi_min_rev = rev & 0xf; + qspi->mspi_spcr3_sysclk = data->has_spcr3_sysclk; + + qspi->max_speed_hz = qspi->base_clk / (bcm_qspi_spbr_min(qspi) * 2); + + /* + * On SW resets it is possible to have the mask still enabled + * Need to disable the mask and clear the status while we init + */ + bcm_qspi_hw_uninit(qspi); + for (val = 0; val < num_irqs; val++) { irq = -1; name = qspi_irq_tab[val].irq_name; @@ -1433,38 +1478,6 @@ int bcm_qspi_probe(struct platform_devic goto qspi_probe_err; } - /* - * Some SoCs integrate spi controller (e.g., its interrupt bits) - * in specific ways - */ - if (soc_intc) { - qspi->soc_intc = soc_intc; - soc_intc->bcm_qspi_int_set(soc_intc, MSPI_DONE, true); - } else { - qspi->soc_intc = NULL; - } - - ret = clk_prepare_enable(qspi->clk); - if (ret) { - dev_err(dev, "failed to prepare clock\n"); - goto qspi_probe_err; - } - - qspi->base_clk = clk_get_rate(qspi->clk); - - if (data->has_mspi_rev) { - rev = bcm_qspi_read(qspi, MSPI, MSPI_REV); - /* some older revs do not have a MSPI_REV register */ - if ((rev & 0xff) == 0xff) - rev = 0; - } - - qspi->mspi_maj_rev = (rev >> 4) & 0xf; - qspi->mspi_min_rev = rev & 0xf; - qspi->mspi_spcr3_sysclk = data->has_spcr3_sysclk; - - qspi->max_speed_hz = qspi->base_clk / (bcm_qspi_spbr_min(qspi) * 2); - bcm_qspi_hw_init(qspi); init_completion(&qspi->mspi_done); init_completion(&qspi->bspi_done);