From: Robin Gong <yibin.gong@nxp.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: "vkoul@kernel.org" <vkoul@kernel.org>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"u.kleine-koenig@pengutronix.de" <u.kleine-koenig@pengutronix.de>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"festevam@gmail.com" <festevam@gmail.com>,
"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
"mark.rutland@arm.com" <mark.rutland@arm.com>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"will.deacon@arm.com" <will.deacon@arm.com>,
"l.stach@pengutronix.de" <l.stach@pengutronix.de>,
"martin.fuzzey@flowbird.group" <martin.fuzzey@flowbird.group>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
dl-linux-imx <linux-imx@nxp.com>,
"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: RE: [PATCH v7 RESEND 07/13] spi: imx: fix ERR009165
Date: Wed, 13 May 2020 15:48:22 +0000 [thread overview]
Message-ID: <VE1PR04MB663876FA31A281A388F2BBEB89BF0@VE1PR04MB6638.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20200513092038.GR5877@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]
On 2020/05/13 Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Wed, May 13, 2020 at 08:52:39AM +0000, Robin Gong wrote:
> > On 2020/05/13 16:48 Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > > On Wed, May 13, 2020 at 08:38:26AM +0000, Robin Gong wrote:
> > > > On 2020/05/13 Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > > > > This patch is the one bisecting will end up with when somebody
> > > > > uses an older SDMA firmware or the ROM scripts. It should have a
> > > > > better description what happens and what should be done about it.
> > > > Emm..That's true. Timeout will be caught in such case, hence,
> > > > maybe we can
> > > fall back it to pio always.
> > >
> > > With my patch applied sdma_load_context() will fail. I don't know
> > > how exactly this hits into the SPI driver, but it won't be a timeout.
> > Thanks for your quick test, assume you use ROM firmware, right?
>
> Yes.
Would you please have a try with the attached patch which is based this patch set?
[-- Attachment #2: 0014-spi-imx-fallback-to-PIO-if-dma-setup-failure.patch --]
[-- Type: application/octet-stream, Size: 3274 bytes --]
From b4f9860be8cc8b9672626baa62a4cec89cf29e87 Mon Sep 17 00:00:00 2001
From: Robin Gong <yibin.gong@nxp.com>
Date: Thu, 14 May 2020 07:18:33 +0800
Subject: [PATCH v7 RESEND 14/14] spi: imx: fallback to PIO if dma setup
failure
Fallback to PIO in case dma setup failed. For example, sdma firmware not
updated but ERR009165 workaroud added in kernel.
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
---
drivers/spi/spi-imx.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index a57edcb..56505cb 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -72,6 +72,7 @@ struct spi_imx_devtype_data {
void (*reset)(struct spi_imx_data *);
void (*setup_wml)(struct spi_imx_data *);
void (*disable)(struct spi_imx_data *);
+ void (*disable_dma)(struct spi_imx_data *);
bool has_dmamode;
bool has_slavemode;
unsigned int fifo_size;
@@ -496,6 +497,11 @@ static void mx51_ecspi_trigger(struct spi_imx_data *spi_imx)
writel(reg, spi_imx->base + MX51_ECSPI_CTRL);
}
+static void mx51_disable_dma(struct spi_imx_data *spi_imx)
+{
+ writel(0, spi_imx->base + MX51_ECSPI_DMA);
+}
+
static void mx51_ecspi_disable(struct spi_imx_data *spi_imx)
{
u32 ctrl;
@@ -1008,6 +1014,7 @@ static struct spi_imx_devtype_data imx51_ecspi_devtype_data = {
.rx_available = mx51_ecspi_rx_available,
.reset = mx51_ecspi_reset,
.setup_wml = mx51_setup_wml,
+ .disable_dma = mx51_disable_dma,
.fifo_size = 64,
.has_dmamode = true,
.dynamic_burst = true,
@@ -1022,6 +1029,7 @@ static struct spi_imx_devtype_data imx53_ecspi_devtype_data = {
.prepare_transfer = mx51_ecspi_prepare_transfer,
.trigger = mx51_ecspi_trigger,
.rx_available = mx51_ecspi_rx_available,
+ .disable_dma = mx51_disable_dma,
.reset = mx51_ecspi_reset,
.fifo_size = 64,
.has_dmamode = true,
@@ -1430,6 +1438,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!desc_tx) {
dmaengine_terminate_all(master->dma_tx);
+ dmaengine_terminate_all(master->dma_rx);
return -EINVAL;
}
@@ -1543,6 +1552,7 @@ static int spi_imx_transfer(struct spi_device *spi,
struct spi_transfer *transfer)
{
struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
+ int ret;
/* flush rxfifo before transfer */
while (spi_imx->devtype_data->rx_available(spi_imx))
@@ -1551,10 +1561,23 @@ static int spi_imx_transfer(struct spi_device *spi,
if (spi_imx->slave_mode)
return spi_imx_pio_transfer_slave(spi, transfer);
- if (spi_imx->usedma)
- return spi_imx_dma_transfer(spi_imx, transfer);
- else
- return spi_imx_pio_transfer(spi, transfer);
+ /*
+ * fallback PIO mode if dma setup error happen, for example sdma
+ * firmware may not be updated as ERR009165 required.
+ */
+ if (spi_imx->usedma) {
+ ret = spi_imx_dma_transfer(spi_imx, transfer);
+ if (ret != -EINVAL)
+ return ret;
+
+ spi_imx->devtype_data->disable_dma(spi_imx);
+
+ spi_imx->usedma = false;
+ spi_imx->dynamic_burst = spi_imx->devtype_data->dynamic_burst;
+ dev_info(&spi->dev, "Fallback to PIO mode\n");
+ }
+
+ return spi_imx_pio_transfer(spi, transfer);
}
static int spi_imx_setup(struct spi_device *spi)
--
2.7.4
next prev parent reply other threads:[~2020-05-13 15:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 17:32 [PATCH v7 RESEND 00/13] add ecspi ERR009165 for i.mx6/7 soc family Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 01/13] Revert "ARM: dts: imx6q: Use correct SDMA script for SPI5 core" Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 02/13] Revert "ARM: dts: imx6: Use correct SDMA script for SPI cores" Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 03/13] Revert "dmaengine: imx-sdma: fix context cache" Robin Gong
2020-05-13 6:05 ` Sascha Hauer
2020-05-13 7:12 ` Fuzzey, Martin
2020-05-13 8:06 ` Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 04/13] Revert "dmaengine: imx-sdma: refine to load context only once" Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 05/13] dmaengine: imx-sdma: remove dupilicated sdma_load_context Robin Gong
2020-05-13 6:05 ` Sascha Hauer
2020-05-13 8:04 ` Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 06/13] dmaengine: imx-sdma: add mcu_2_ecspi script Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 07/13] spi: imx: fix ERR009165 Robin Gong
2020-05-13 7:21 ` Sascha Hauer
2020-05-13 8:38 ` Robin Gong
2020-05-13 8:48 ` Sascha Hauer
2020-05-13 8:52 ` Robin Gong
2020-05-13 9:20 ` Sascha Hauer
2020-05-13 15:48 ` Robin Gong [this message]
2020-05-13 7:33 ` Sascha Hauer
2020-05-13 9:05 ` Robin Gong
2020-05-13 9:20 ` Sascha Hauer
2020-05-13 9:36 ` Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 08/13] spi: imx: remove ERR009165 workaround on i.mx6ul Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 09/13] spi: imx: add new i.mx6ul compatible name in binding doc Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 10/13] dmaengine: imx-sdma: remove ERR009165 on i.mx6ul Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 11/13] dma: imx-sdma: add i.mx6ul compatible name Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 12/13] dmaengine: imx-sdma: fix ecspi1 rx dma not work on i.mx8mm Robin Gong
2020-05-11 17:32 ` [PATCH v7 RESEND 13/13] dmaengine: imx-sdma: add uart rom script Robin Gong
2020-05-13 21:06 ` Fabio Estevam
2020-05-14 1:45 ` Robin Gong
2020-05-13 7:20 ` [PATCH v7 RESEND 00/13] add ecspi ERR009165 for i.mx6/7 soc family Sascha Hauer
2020-05-13 8:20 ` Robin Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=VE1PR04MB663876FA31A281A388F2BBEB89BF0@VE1PR04MB6638.eurprd04.prod.outlook.com \
--to=yibin.gong@nxp.com \
--cc=catalin.marinas@arm.com \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=l.stach@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.fuzzey@flowbird.group \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vkoul@kernel.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).