From patchwork Wed Jul 25 06:20:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 1235641 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id A59843FD4F for ; Wed, 25 Jul 2012 06:29:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Stv5p-00017C-8r; Wed, 25 Jul 2012 06:29:09 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Stv5o-000177-Dq for spi-devel-general@lists.sourceforge.net; Wed, 25 Jul 2012 06:29:08 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of ti.com designates 198.47.26.153 as permitted sender) client-ip=198.47.26.153; envelope-from=shubhrajyoti@ti.com; helo=devils.ext.ti.com; Received: from devils.ext.ti.com ([198.47.26.153]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1Stv5n-0002Uh-H8 for spi-devel-general@lists.sourceforge.net; Wed, 25 Jul 2012 06:29:08 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6P6KZ3o015552; Wed, 25 Jul 2012 01:20:35 -0500 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6P6KXE3008139; Wed, 25 Jul 2012 11:50:34 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Wed, 25 Jul 2012 11:50:33 +0530 Received: from ula0393217.india.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6P6KWBx020301; Wed, 25 Jul 2012 11:50:33 +0530 From: Shubhrajyoti D To: Subject: [PATCH] spi: omap2-mcspi: In case of dma errors fall back to pio Date: Wed, 25 Jul 2012 11:50:29 +0530 Message-ID: <1343197229-15188-1-git-send-email-shubhrajyoti@ti.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 X-Spam-Score: -0.8 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record 0.7 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Stv5n-0002Uh-H8 Cc: Shubhrajyoti, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, D X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net 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 Acked-by: Philip, Avinash --- 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);