From patchwork Fri Feb 10 15:29:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Isaksen X-Patchwork-Id: 9567181 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 E887D60572 for ; Fri, 10 Feb 2017 17:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8650285A5 for ; Fri, 10 Feb 2017 17:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD3B8285AD; Fri, 10 Feb 2017 17:31:35 +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=unavailable 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 CF52B285A5 for ; Fri, 10 Feb 2017 17:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbdBJRba (ORCPT ); Fri, 10 Feb 2017 12:31:30 -0500 Received: from mail-wr0-f174.google.com ([209.85.128.174]:36576 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbdBJRb1 (ORCPT ); Fri, 10 Feb 2017 12:31:27 -0500 Received: by mail-wr0-f174.google.com with SMTP id k90so112790786wrc.3 for ; Fri, 10 Feb 2017 09:30:45 -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=3o/FRlW9fjt5DlQeklZOy3czT4wvhSryRhGCjBAFXmE=; b=hnP/Y5cP+LUatkRUzSKW6ypPNXjMDEH3WBxpkmfnPz6eyZCHGQ2/IBuygU5BXi3mK7 oCkyVou1ZLXDA4/Yb1NC9S+Z22QQaP6EKF0XTvevKX002ETf2Id9A9vfH5uu3pCnmDFZ ZBaxOZ/oCtrqfY8VUzpfZyWyxWwjWgbX1kmdNX+syekvLeza5vhRxfnfjko7j+99TtTQ RTtotmwvuL96VdQmtBAw6PFUca8RJJOZo4qrCZgQ/BeHOeUYgfBBxrk8Xcl78FYZiUuL E8JQbVQtzuSJKj0RLmggSkWZCTrBWlhGazvwHiD01vTSHC+nO5GapUiWmr4Eka9tx8Hz 2jJA== 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=3o/FRlW9fjt5DlQeklZOy3czT4wvhSryRhGCjBAFXmE=; b=trdeRBxCPWsDqfiv3IuusG07XIfhqdTcjKxK/y3f40buA/IbSWN8QsVPIKFN8aR08c +/+kktxRWDoG0o1bL0YUCAgr+EjTtf7nEU9VPe6zclA8eCDonW0mp1OYleBGy/LeYG+6 RX0BQ2TDC1zQ1qbXdVTYB+oTjZG2KiQkmQbHW7eM9hNA0zhJdPLtPF3+HC4w/Q7j89/B t7p8VWYpISeme+4JHfqHhIokmP2LXVdu62I7oMpJqyq/2ws1bXtInXEmtW69l0xx5u2T OMk6F5ysROF9jWrBmXwNfSBYMLq5z4GXt4rNp6B/CDUAAeeg2fiSa+XVkj7yPrL7aBIM MLwA== X-Gm-Message-State: AMke39nUsaDJYPOvm6osEYsqKnYXkElxfax5JfCY19gY2Htj9kOsLpbbC2N2Ae865ZpoR47u X-Received: by 10.223.163.75 with SMTP id d11mr8216477wrb.87.1486740643817; Fri, 10 Feb 2017 07:30:43 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id o143sm2068192wmd.3.2017.02.10.07.30.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Feb 2017 07:30:43 -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 4/8] spi: davinci: flush caches when performing DMA Date: Fri, 10 Feb 2017 16:29:40 +0100 Message-Id: <1486740584-17875-5-git-send-email-fisaksen@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486740584-17875-1-git-send-email-fisaksen@baylibre.com> References: <1486740584-17875-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 flash. Signed-off-by: Frode Isaksen --- drivers/spi/spi-davinci.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index f1b46f6..c735425 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -676,7 +677,9 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) } sg_dma_address(&sg_rx) = t->rx_dma; sg_dma_len(&sg_rx) = t->len; - } + } else if (is_vmalloc_addr(t->rx_buf)) + /* VIVT cache, flush since aliased address */ + flush_kernel_vmap_range((void *)t->rx_buf, t->len); sg_init_table(&sg_tx, 1); if (!t->tx_buf) { @@ -688,7 +691,9 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) } sg_dma_address(&sg_tx) = t->tx_dma; sg_dma_len(&sg_tx) = t->len; - } + } else if (is_vmalloc_addr(t->tx_buf)) + /* VIVT cache, flush since aliased address */ + flush_kernel_vmap_range((void *)t->tx_buf, t->len); rxdesc = dmaengine_prep_slave_sg(dspi->dma_rx, t->rx_sg.sgl ?: &sg_rx, t->rx_sg.nents ?: 1, @@ -741,6 +746,10 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) if (!t->rx_buf) dma_unmap_single(&spi->dev, t->rx_dma, t->len, DMA_FROM_DEVICE); + else if (is_vmalloc_addr(t->rx_buf)) + /* VIVT cache, invalidate since aliased address */ + invalidate_kernel_vmap_range((void *)t->rx_buf, t->len); + if (!t->tx_buf) dma_unmap_single(&spi->dev, t->tx_dma, t->len, DMA_TO_DEVICE);