From: Shubhrajyoti D <shubhrajyoti@ti.com> To: <spi-devel-general@lists.sourceforge.net> Cc: <linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Shubhrajyoti D <shubhrajyoti@ti.com> Subject: [PATCH] spi: omap2-mcspi: In case of dma errors fall back to pio Date: Wed, 25 Jul 2012 11:50:29 +0530 [thread overview] Message-ID: <1343197229-15188-1-git-send-email-shubhrajyoti@ti.com> (raw) In case there are dma errors currently the driver exits. Make the spi driver fall back to pio mode in case of dma errors. If the DMA engine is not selected the driver exits.This patch makes the spi fall back to pio in that case. Also adds a field dma_unusable to struct omap2_mcspi. Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> --- drivers/spi/spi-omap2-mcspi.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index bc47781..f243a39 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -129,6 +129,7 @@ struct omap2_mcspi { struct omap2_mcspi_dma *dma_channels; struct device *dev; struct omap2_mcspi_regs ctx; + int dma_unusable; }; struct omap2_mcspi_cs { @@ -845,7 +846,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) { ret = omap2_mcspi_request_dma(spi); if (ret < 0) - return ret; + mcspi->dma_unusable = 1; } ret = omap2_mcspi_enable_clocks(mcspi); @@ -956,7 +957,8 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) __raw_writel(0, cs->base + OMAP2_MCSPI_TX0); - if (m->is_dma_mapped || t->len >= DMA_MIN_BYTES) + if (!mcspi->dma_unusable && (m->is_dma_mapped || + t->len >= DMA_MIN_BYTES)) count = omap2_mcspi_txrx_dma(spi, t); else count = omap2_mcspi_txrx_pio(spi, t); @@ -1030,7 +1032,8 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, return -EINVAL; } - if (m->is_dma_mapped || len < DMA_MIN_BYTES) + if (mcspi->dma_unusable || m->is_dma_mapped || + len < DMA_MIN_BYTES) continue; if (tx_buf != NULL) { @@ -1054,6 +1057,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, return -EINVAL; } } + } omap2_mcspi_work(mcspi, m); @@ -1216,9 +1220,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start; } - if (status < 0) - goto dma_chnl_free; - + if (status < 0) { + dev_err(&pdev->dev, "cannot get DMA channel switching to pio\n"); + mcspi->dma_unusable = 1; + status = 0; + kfree(mcspi->dma_channels); + } pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); pm_runtime_enable(&pdev->dev); @@ -1229,14 +1236,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) status = spi_register_master(master); if (status < 0) goto err_spi_register; - return status; err_spi_register: spi_master_put(master); disable_pm: pm_runtime_disable(&pdev->dev); -dma_chnl_free: kfree(mcspi->dma_channels); free_master: kfree(master); -- 1.7.5.4
WARNING: multiple messages have this Message-ID (diff)
From: Shubhrajyoti D <shubhrajyoti@ti.com> To: spi-devel-general@lists.sourceforge.net Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Shubhrajyoti D <shubhrajyoti@ti.com> Subject: [PATCH] spi: omap2-mcspi: In case of dma errors fall back to pio Date: Wed, 25 Jul 2012 11:50:29 +0530 [thread overview] Message-ID: <1343197229-15188-1-git-send-email-shubhrajyoti@ti.com> (raw) In case there are dma errors currently the driver exits. Make the spi driver fall back to pio mode in case of dma errors. If the DMA engine is not selected the driver exits.This patch makes the spi fall back to pio in that case. Also adds a field dma_unusable to struct omap2_mcspi. Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> --- drivers/spi/spi-omap2-mcspi.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index bc47781..f243a39 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -129,6 +129,7 @@ struct omap2_mcspi { struct omap2_mcspi_dma *dma_channels; struct device *dev; struct omap2_mcspi_regs ctx; + int dma_unusable; }; struct omap2_mcspi_cs { @@ -845,7 +846,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) { ret = omap2_mcspi_request_dma(spi); if (ret < 0) - return ret; + mcspi->dma_unusable = 1; } ret = omap2_mcspi_enable_clocks(mcspi); @@ -956,7 +957,8 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) __raw_writel(0, cs->base + OMAP2_MCSPI_TX0); - if (m->is_dma_mapped || t->len >= DMA_MIN_BYTES) + if (!mcspi->dma_unusable && (m->is_dma_mapped || + t->len >= DMA_MIN_BYTES)) count = omap2_mcspi_txrx_dma(spi, t); else count = omap2_mcspi_txrx_pio(spi, t); @@ -1030,7 +1032,8 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, return -EINVAL; } - if (m->is_dma_mapped || len < DMA_MIN_BYTES) + if (mcspi->dma_unusable || m->is_dma_mapped || + len < DMA_MIN_BYTES) continue; if (tx_buf != NULL) { @@ -1054,6 +1057,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, return -EINVAL; } } + } omap2_mcspi_work(mcspi, m); @@ -1216,9 +1220,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start; } - if (status < 0) - goto dma_chnl_free; - + if (status < 0) { + dev_err(&pdev->dev, "cannot get DMA channel switching to pio\n"); + mcspi->dma_unusable = 1; + status = 0; + kfree(mcspi->dma_channels); + } pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); pm_runtime_enable(&pdev->dev); @@ -1229,14 +1236,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev) status = spi_register_master(master); if (status < 0) goto err_spi_register; - return status; err_spi_register: spi_master_put(master); disable_pm: pm_runtime_disable(&pdev->dev); -dma_chnl_free: kfree(mcspi->dma_channels); free_master: kfree(master); -- 1.7.5.4
next reply other threads:[~2012-07-25 6:20 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-07-25 6:20 Shubhrajyoti D [this message] 2012-07-25 6:20 ` [PATCH] spi: omap2-mcspi: In case of dma errors fall back to pio Shubhrajyoti D 2012-08-07 7:47 ` Tony Lindgren 2012-08-07 11:21 ` Shubhrajyoti 2012-08-07 12:02 ` Tony Lindgren 2012-08-07 12:21 ` Felipe Balbi 2012-08-08 14:39 ` Philip, Avinash 2012-08-08 14:39 ` Philip, Avinash
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=1343197229-15188-1-git-send-email-shubhrajyoti@ti.com \ --to=shubhrajyoti@ti.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ --cc=spi-devel-general@lists.sourceforge.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.