From patchwork Fri Feb 17 10:38:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9579553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 395E1600F6 for ; Fri, 17 Feb 2017 10:38:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AEAA280B0 for ; Fri, 17 Feb 2017 10:38:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F55528383; Fri, 17 Feb 2017 10:38:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96B09280B0 for ; Fri, 17 Feb 2017 10:38:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933577AbdBQKin (ORCPT ); Fri, 17 Feb 2017 05:38:43 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:37618 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932556AbdBQKim (ORCPT ); Fri, 17 Feb 2017 05:38:42 -0500 Received: by mail-wm0-f41.google.com with SMTP id v77so7097624wmv.0 for ; Fri, 17 Feb 2017 02:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bH7oyIrpB3WYKZifVkBlIch+P66Aqbw7u7EW+r8HR2E=; b=SQ6HvJ/qK1dzME0pJTkuP5RDJeTHIrdZIPrI1GgJZhCT8L5FLZ1TtORfqEdRcl0uze gkhuoUcO0JpGcJb6igcmzAsckrN2zKtxYJlXrigSwA58+i8VjEDk9weNy3eXS4KYFbsl BgshFYqIQ/T2RzRbbsJvTLpS/Jsqn+i13Tu2+fwX1kHc5TGPfjv19I/R348E5zVkExBZ ZXMaxdGBM5rIq7by67Fz/TkbeytIlDqe27qQqUFYo7ay3smeGnPvpm7J0ZP3pvCDyMqh 0zE1XztYDR3lX9aCx9bbHqyrx7LrCA95DPZiZ37hJbzcXn23fWre+EQbfBLf/bb8cd8/ V7FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bH7oyIrpB3WYKZifVkBlIch+P66Aqbw7u7EW+r8HR2E=; b=hg1JOBQ2vWFG5gxPKT4lQViFh0ZM3SShrcPUiuSlagFYlGAsjPLuf62pLKTBeGr2aN 389UCRaY8iw/OnfsHt2OAfIFJuSRfR5EqvEPmbqVBBnmE0L4FhFYb6jsbEdsNMB0DxiT 3OI8OcuSdm18P7WkprrYc7xbUhU8/1evaahTpvYJu/idBq41Gee6M3Wb/Djfo9rb0uQJ X6pvd4zoWWretk3i1QN8NrW4464ABSpN98H9Bzm6ZEiQKZSSSoH60lYPq75CtQUcljuL kFFEpnACLCmc5FZe+xtR6MCrImmBBH0yPlJWjoa3u0YwVRYwgGVsYbonjx3wFGxrK7HF wcqg== X-Gm-Message-State: AMke39mH8Z6XfHofAuk3ajnn+/c0Hj78rQY5xw3uiQdXHxIIevFp8dXkKB+nHbdhG5sr7Qu3 X-Received: by 10.28.228.213 with SMTP id b204mr2727076wmh.59.1487327921011; Fri, 17 Feb 2017 02:38:41 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y80sm12531459wrb.12.2017.02.17.02.38.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 02:38:40 -0800 (PST) From: Frode Isaksen To: nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, linux-spi@vger.kernel.org, Frode Isaksen Subject: [PATCH v2 4/6] spi: davinci: flush caches when performing DMA Date: Fri, 17 Feb 2017 11:38:22 +0100 Message-Id: <1487327904-28311-5-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487327904-28311-1-git-send-email-fisaksen@baylibre.com> References: <1487327904-28311-1-git-send-email-fisaksen@baylibre.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This CPU has VIVT caches, so need to flush the cache for vmalloc'ed buffers, since the address may be aliased (same phyiscal address used by multiple virtual addresses). This fixes errors when mounting and reading/writing UBIFS volumes with SPI NOR flash. Signed-off-by: Frode Isaksen --- drivers/spi/spi-davinci.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 2632ae0..b69a370 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -650,6 +651,10 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) dmaengine_slave_config(dspi->dma_rx, &dma_rx_conf); dmaengine_slave_config(dspi->dma_tx, &dma_tx_conf); + if (is_vmalloc_addr(t->rx_buf)) + /* VIVT cache: flush since addr. may be aliased */ + flush_kernel_vmap_range((void *)t->rx_buf, t->len); + rxdesc = dmaengine_prep_slave_sg(dspi->dma_rx, t->rx_sg.sgl, t->rx_sg.nents, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -660,7 +665,9 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) /* use rx buffer as dummy tx buffer */ t->tx_sg.sgl = t->rx_sg.sgl; t->tx_sg.nents = t->rx_sg.nents; - } + } else if (is_vmalloc_addr(t->tx_buf)) + /* VIVT cache: flush since addr. may be aliased */ + flush_kernel_vmap_range((void *)t->tx_buf, t->len); txdesc = dmaengine_prep_slave_sg(dspi->dma_tx, t->tx_sg.sgl, t->tx_sg.nents, DMA_MEM_TO_DEV, @@ -699,8 +706,12 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) } clear_io_bits(dspi->base + SPIINT, SPIINT_MASKALL); - if (spicfg->io_type == SPI_IO_TYPE_DMA) + if (spicfg->io_type == SPI_IO_TYPE_DMA) { clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN); + if (is_vmalloc_addr(t->rx_buf)) + /* VIVT cache: invalidate since addr. may be aliased */ + invalidate_kernel_vmap_range((void *)t->rx_buf, t->len); + } clear_io_bits(dspi->base + SPIGCR1, SPIGCR1_SPIENA_MASK); set_io_bits(dspi->base + SPIGCR1, SPIGCR1_POWERDOWN_MASK);