Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp323439rwb; Fri, 12 Aug 2022 21:29:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR62GvOz62UGA2QeIxIsmQO+k3R1MvGWTkf/QsP3B+6+vIpNixfYaWvbMOUKe8yI3p5AE/aT X-Received: by 2002:a17:907:2d8a:b0:730:6880:c396 with SMTP id gt10-20020a1709072d8a00b007306880c396mr4393171ejc.192.1660364956011; Fri, 12 Aug 2022 21:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660364956; cv=none; d=google.com; s=arc-20160816; b=DYphDiiO/Z+nnAPBGpAL2S5TO6UK/C7/LL7s+j0gvyq7RkkmD+mDVJ6Jxo6SHNI2+E gO6VIBmV+a3tPv4BcpGG1HYEcCiOhVLivLpB/2EkvdhBKB3aHvGqEa7lW75YITLYC92j WgdGM9FvCkHZ7Rrr2aTLJCKWmmTowDTNQ2ebHMWKFYR57oJiwSDugVhqTJ+oEoUml+3I d0dF2p67mCC6eUhbtzsxEvM5xUuC5dNFkO5brQTNPuQ+4aWXkDiwoaFTcWWOgMf2Owvi eatQ0n1yuRzC3W5bxyhN/z+cYWVOaTV+7n7ibh1l21j4MT18f9Pcex54zHxXmxzdbQz3 NP3g== 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 :dkim-signature; bh=LVhzT9Np/1l3kNsxHYBQE/6+d1UVmbljYh4vnPXrjPU=; b=D4/XssdJavlt4HdYl2QRrvXI61eLr10lQ5C8jWLIjiVmojFS35JypjKPtPO472mGHF Na24wvYZp8r3mpvvYu3GdEfiPdgmTFSU3UBvBtEd6RCnT8/0kiDTo7XID4FUgrA7TiSA j1Vc/s5befI4PN92c/SA4Zvh4gHVWwlGbbYZvDp6RGX/04oaje8frrQKnfbzycR1Za/Q Y/2j/9Dr1GjO6+zr6bv7vwRA0ZSehHpaqqOWG62HCMkqWy/0VcHfKgaoYxs1Fo3wy7tJ PYvqMJ+Jt+CLxcH0gicJkKZvPrrT8gsyy/gDGNYv3lA/yEdYExcIT//GEA+sEQ3FFtUS lqfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eP5QAKli; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc10-20020a170907168a00b0073065f0ddbdsi3490416ejc.599.2022.08.12.21.28.47; Fri, 12 Aug 2022 21:29:16 -0700 (PDT) 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=@intel.com header.s=Intel header.b=eP5QAKli; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237115AbiHME1p (ORCPT + 99 others); Sat, 13 Aug 2022 00:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231424AbiHME1n (ORCPT ); Sat, 13 Aug 2022 00:27:43 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D38218B14; Fri, 12 Aug 2022 21:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660364862; x=1691900862; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nuSF/DPyH4hEc+MssLIdGaOyti4gnu6kxnq2sOYunFY=; b=eP5QAKlicvVBYSpkTjuFbvLDL3r9IPAUQzPZY+uuf2IqENPuI/jsVshB rJqxMHrRehcfadCQO1e0e054R9llDVuL/Kqw5TIvaA+uxCNRjc6qAfx4E l7R4HjHc/rN8FXBioBhZAL/3dEkVtiQF8KWoCTCdqgVKDFjiUUPI7+53v 3BKEW2o5dSEX3exPqgxY9ZPZBt0KLf4/HuMtmieth8yPLnUyXKJGTPm/f VRzay9vX1dYRI5ZcXElLQbLdwOuDtbCH9AuUAbyLUTAU4XQfH/Ga5SqAg UwKTyk8DDsJ+0mlErfzowqaMGG+QcJAKl32L4nmIZddeR0bHY0IuczZ/v w==; X-IronPort-AV: E=McAfee;i="6400,9594,10437"; a="317703189" X-IronPort-AV: E=Sophos;i="5.93,233,1654585200"; d="scan'208";a="317703189" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2022 21:27:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,233,1654585200"; d="scan'208";a="732433386" Received: from unknown (HELO localhost.localdomain) ([10.226.216.116]) by orsmga004.jf.intel.com with ESMTP; 12 Aug 2022 21:27:40 -0700 From: niravkumar.l.rabara@intel.com To: niravkumar.l.rabara@intel.com Cc: broonie@kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, p.zabel@pengutronix.de Subject: [PATCH v2] spi: cadence-quadspi: Disable irqs during indirect reads Date: Sat, 13 Aug 2022 12:27:36 +0800 Message-Id: <20220813042736.1372180-1-niravkumar.l.rabara@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220813040928.1353077-1-niravkumar.l.rabara@intel.com> References: <20220813040928.1353077-1-niravkumar.l.rabara@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 From: Niravkumar L Rabara On architecture where reading the SRAM is slower than the pace at controller fills it, with interrupt enabled while reading from SRAM FIFO causes unwanted interrupt storm to CPU. The inner "bytes to read" loop never exits and waits for the completion so it is enough to only enable the watermark interrupt when we are out of bytes to read, which only happens when we start the transfer (waiting for the FIFO to fill up initially) if the SRAM is slow. So only using read watermark interrupt, as the current implementation doesn't utilize the SRAM full and indirect complete read interrupt. And disable all the read interrupts while reading from SRAM. Signed-off-by: Niravkumar L Rabara --- drivers/spi/spi-cadence-quadspi.c | 38 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 72b1a5a2298c..e12ab5b43f34 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -39,6 +39,7 @@ #define CQSPI_DISABLE_DAC_MODE BIT(1) #define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) #define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) +#define CQSPI_SLOW_SRAM BIT(4) /* Capabilities */ #define CQSPI_SUPPORTS_OCTAL BIT(0) @@ -87,6 +88,7 @@ struct cqspi_st { bool use_dma_read; u32 pd_dev_id; bool wr_completion; + bool slow_sram; }; struct cqspi_driver_platdata { @@ -333,7 +335,10 @@ static irqreturn_t cqspi_irq_handler(int this_irq, void *dev) } } - irq_status &= CQSPI_IRQ_MASK_RD | CQSPI_IRQ_MASK_WR; + else if (!cqspi->slow_sram) + irq_status &= CQSPI_IRQ_MASK_RD | CQSPI_IRQ_MASK_WR; + else + irq_status &= CQSPI_REG_IRQ_WATERMARK | CQSPI_IRQ_MASK_WR; if (irq_status) complete(&cqspi->transfer_complete); @@ -673,7 +678,18 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata, /* Clear all interrupts. */ writel(CQSPI_IRQ_STATUS_MASK, reg_base + CQSPI_REG_IRQSTATUS); - writel(CQSPI_IRQ_MASK_RD, reg_base + CQSPI_REG_IRQMASK); + /* + * On SoCFPGA platform reading the SRAM is slow due to + * hardware limitation and causing read interrupt storm to CPU, + * so enabling only watermark interrupt to disable all read + * interrupts later as we want to run "bytes to read" loop with + * all the read interrupts disabled for max performance. + */ + + if (!cqspi->slow_sram) + writel(CQSPI_IRQ_MASK_RD, reg_base + CQSPI_REG_IRQMASK); + else + writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK); reinit_completion(&cqspi->transfer_complete); writel(CQSPI_REG_INDIRECTRD_START_MASK, @@ -684,6 +700,13 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata, msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS))) ret = -ETIMEDOUT; + /* + * Disable all read interrupts until + * we are out of "bytes to read" + */ + if (cqspi->slow_sram) + writel(0x0, reg_base + CQSPI_REG_IRQMASK); + bytes_to_read = cqspi_get_rd_sram_level(cqspi); if (ret && bytes_to_read == 0) { @@ -715,8 +738,11 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata, bytes_to_read = cqspi_get_rd_sram_level(cqspi); } - if (remaining > 0) + if (remaining > 0) { reinit_completion(&cqspi->transfer_complete); + if (cqspi->slow_sram) + writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK); + } } /* Check indirect done status */ @@ -1667,6 +1693,8 @@ static int cqspi_probe(struct platform_device *pdev) cqspi->use_dma_read = true; if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION) cqspi->wr_completion = false; + if (ddata->quirks & CQSPI_SLOW_SRAM) + cqspi->slow_sram = true; if (of_device_is_compatible(pdev->dev.of_node, "xlnx,versal-ospi-1.0")) @@ -1779,7 +1807,9 @@ static const struct cqspi_driver_platdata intel_lgm_qspi = { }; static const struct cqspi_driver_platdata socfpga_qspi = { - .quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_NO_SUPPORT_WR_COMPLETION, + .quirks = CQSPI_DISABLE_DAC_MODE + | CQSPI_NO_SUPPORT_WR_COMPLETION + | CQSPI_SLOW_SRAM, }; static const struct cqspi_driver_platdata versal_ospi = { -- 2.25.1