From patchwork Thu Aug 30 15:02:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_L=C3=BCbbe?= X-Patchwork-Id: 1388061 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 A3E7A3FC33 for ; Thu, 30 Aug 2012 15:03:05 +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 1T76Gv-0004nh-27; Thu, 30 Aug 2012 15:03:05 +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 1T76Gt-0004nN-LA for spi-devel-general@lists.sourceforge.net; Thu, 30 Aug 2012 15:03:03 +0000 X-ACL-Warn: Received: from metis.ext.pengutronix.de ([92.198.50.35]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1T76Gr-00074r-Dz for spi-devel-general@lists.sourceforge.net; Thu, 30 Aug 2012 15:03:03 +0000 Received: from coredoba.hi.pengutronix.de ([2001:6f8:1178:2:219:99ff:fe56:8d7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1T76Gk-0005Y7-Nz; Thu, 30 Aug 2012 17:02:54 +0200 Received: from jlu by coredoba.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1T76Gk-0002NW-KF; Thu, 30 Aug 2012 17:02:54 +0200 From: Jan Luebbe To: Grant Likely Subject: [PATCH 2/2] omap2-mcspi: fall back to PIO when the buffer is in high mem Date: Thu, 30 Aug 2012 17:02:51 +0200 Message-Id: <1346338971-9106-2-git-send-email-jlu@pengutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1346338971-9106-1-git-send-email-jlu@pengutronix.de> References: <1346338971-9106-1-git-send-email-jlu@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:219:99ff:fe56:8d7 X-SA-Exim-Mail-From: jlu@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: spi-devel-general@lists.sourceforge.net X-Spam-Score: -0.2 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1T76Gr-00074r-Dz Cc: spi-devel-general@lists.sourceforge.net, Jan Luebbe 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: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net UBI uses vmalloc'ed buffers in some cases which are not valid for DMA, so use PIO instead. Signed-off-by: Jan Luebbe --- drivers/spi/spi-omap2-mcspi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index ceb27fc..6f361a1 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -927,7 +927,9 @@ 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 (m->is_dma_mapped || (t->len >= DMA_MIN_BYTES + && t->tx_buf < high_memory + && t->rx_buf < high_memory)) count = omap2_mcspi_txrx_dma(spi, t); else count = omap2_mcspi_txrx_pio(spi, t); @@ -1004,6 +1006,11 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master, if (m->is_dma_mapped || len < DMA_MIN_BYTES) continue; + if (tx_buf >= high_memory || rx_buf >= high_memory) { + WARN_ONCE(1, "high memory is invalid for DMA, falling back to PIO\n"); + continue; + } + if (tx_buf != NULL) { t->tx_dma = dma_map_single(mcspi->dev, (void *) tx_buf, len, DMA_TO_DEVICE);