Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3024404pxb; Mon, 18 Oct 2021 06:49:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKcoUfiUrMRwW7DLwf2mDbyvKZH86/Szf6tCPHhQNCj1snayBpO3j3WKGaczxyM7HZsdAc X-Received: by 2002:a17:90b:1d05:: with SMTP id on5mr25551966pjb.53.1634564997793; Mon, 18 Oct 2021 06:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564997; cv=none; d=google.com; s=arc-20160816; b=ecDmS1TIFWM9MGaxuAUN2UzSBAf9HgYaQyl7XS90Zec1Kr8pFCMV/Rri2dVbMMGQa6 GwMYztxiBH5Cgn8WHSV/uydGh3WIIQF57bnYTNsTAifdkfAfgxvHnBT1GfilYBye3+hh LHnocEr4Qli/Oe90qGtfZro9c39SHbDnib4AFk+YoO51EE/bC/gfmbJ4rPNwxP79xYV5 66qzZ0U1rzFb3uxCzgeq8519L8J4ExWPn5iRS2jb/FxdRAQF65+ZGuj5zGIotQcBZLWQ ZCHsHpVdD+rZTHcq3YQxOY8ZKk0J0wUvqHNY0xwVRQ/AZ6G7KHZXatu3PNVWtVZsah// vi+A== 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=Mxdvv1xiapdIouy+8vmiwR3qHn2L/R2kRwdL88wXdNwrW/LP4jSIQdrj6xAac5OW4D i2xoc8Lauhx+k1/a6xIrhDCKQGZyWLSYGvLYrQsTA7Bm2JZQ93qW/VCxu54/nkLbpIzU rDbRt9pAv8asJsA+5ESjbqAVyisTs4H1z+MXRoB3WDwneDWbeAq045A8mCXq0700Z3ue iEr9hZwuyMRGiLp2AcPAkVU3xXtrNifhXn9sRiGiJBFTSehL5an5nc+ABAn/787BH7k0 JYF7zG2ZQURhIABJuUs/ShgT900wmS4rOTdTOYgiPhOz/i3bNtYEASCFTAmO6jyJX2LE zOxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jUGggrUL; 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 f4si22896685pgl.598.2021.10.18.06.49.41; Mon, 18 Oct 2021 06:49:57 -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=jUGggrUL; 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 S232045AbhJRNuV (ORCPT + 99 others); Mon, 18 Oct 2021 09:50:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:47684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234014AbhJRNsU (ORCPT ); Mon, 18 Oct 2021 09:48:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D3B196135F; Mon, 18 Oct 2021 13:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564220; bh=PcqQIb1IhiaRoWComIAtp2rMlcfK8hqwRoXaYragQ1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jUGggrULULqLi1rDtfVIKeZNd+xvil9S9hR7C10/MUd99iY6PjJlrj6ZwqI4pfG/a 2ZAcESugcAa7ZObDHjiHmDg4uZXif5yr7mUHbOdnwIRZ+mz7w+40LE96WyPQ3+eLLV MCugUFnG7W4Oy1oE4LxWfLYPRm1gEyyFAV1QbtUs= 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.10 087/103] spi: bcm-qspi: clear MSPI spifie interrupt during probe Date: Mon, 18 Oct 2021 15:25:03 +0200 Message-Id: <20211018132337.674188687@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132334.702559133@linuxfoundation.org> References: <20211018132334.702559133@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);