{"id":806274,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806274/?format=json","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.0/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/"},"msgid":"<20170827161032.22772-12-hch@lst.de>","date":"2017-08-27T16:10:31","name":"[11/12] sh: make dma_cache_sync a no-op","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"100b1ff406d3c0334b82a7d7e0014e72fdbe99e3","submitter":{"id":82,"url":"http://patchwork.ozlabs.org/api/1.0/people/82/?format=json","name":"Christoph Hellwig","email":"hch@lst.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170827161032.22772-12-hch@lst.de/mbox/","series":[{"id":29,"url":"http://patchwork.ozlabs.org/api/1.0/series/29/?format=json","date":"2017-08-27T16:10:24","name":"[01/12] floppy: consolidate the dummy fd_cacheflush definition","version":1,"mbox":"http://patchwork.ozlabs.org/series/29/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806274/checks/","tags":{},"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xgL6j1zgMz9sD9\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 28 Aug 2017 02:33:01 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xgL6j0bBRzDq5b\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 28 Aug 2017 02:33:01 +1000 (AEST)","from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xgKdX74s2zDqg9\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 28 Aug 2017 02:11:12 +1000 (AEST)","from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost)\n\tby bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat\n\tLinux)) id 1dm09Q-0006uW-S6; Sun, 27 Aug 2017 16:11:05 +0000"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=infradead.org header.i=@infradead.org\n\theader.b=\"IwKIqPGv\"; dkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=infradead.org header.i=@infradead.org\n\theader.b=\"IwKIqPGv\"; dkim-atps=neutral","lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=infradead.org header.i=@infradead.org\n\theader.b=\"IwKIqPGv\"; dkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=infradead.org; s=bombadil.20170209;\n\th=References:In-Reply-To:Message-Id:\n\tDate:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type:\n\tContent-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:\n\tResent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:\n\tList-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;\n\tbh=5Qh6Q+WmM30Wy4lfWH6lLzvaz34BCe1nSnPtDjZFjCM=;\n\tb=IwKIqPGv95iKnfYDSvYESHBtl\n\tCkhnwqImewrwo++5PKvntBb5WiljRACpuL0cuxh3t7y//4w4Oag6Y4nn6IOAC/l+kqQQSyPwzD560\n\teOm7U/fTVX5V/ukx6TIUxlCAQg0ZjotEy0wOSXyzqaRY7nTrbwy9VAM6pUkGJWkhQEuxtDGOnXk5j\n\tGZ615nNaCX8t0BmxWX+FvAnURUjrixbN4QkGk5F9y3n+ZIw67w0sCa2hfUBF1i9k3x1fYDuzBBkFp\n\tCbymRDucRbHOUw6eEeP5nQ+uKLLHvDzpXAwPjKiomTD0W6Vs7TTwAOio/oPWoqA2U/eoCdgRWCB6Q\n\tp2Ff+9lGQ==;","From":"Christoph Hellwig <hch@lst.de>","To":"iommu@lists.linux-foundation.org","Subject":"[PATCH 11/12] sh: make dma_cache_sync a no-op","Date":"Sun, 27 Aug 2017 18:10:31 +0200","Message-Id":"<20170827161032.22772-12-hch@lst.de>","X-Mailer":"git-send-email 2.11.0","In-Reply-To":"<20170827161032.22772-1-hch@lst.de>","References":"<20170827161032.22772-1-hch@lst.de>","X-SRS-Rewrite":"SMTP reverse-path rewritten from <hch@infradead.org> by\n\tbombadil.infradead.org. See http://www.infradead.org/rpr.html","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Chris Zankel <chris@zankel.net>, Michal Simek <monstr@monstr.eu>,\n\tlinux-ia64@vger.kernel.org, linux-mips@linux-mips.org,\n\tlinux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,\n\tlinux-xtensa@linux-xtensa.org, x86@kernel.org,\n\tlinux-kernel@vger.kernel.org, \n\tDavid Howells <dhowells@redhat.com>, Max Filippov <jcmvbkbc@gmail.com>,\n\tGuan Xuetao <gxt@mprc.pku.edu.cn>, Robin Murphy <robin.murphy@arm.com>,\n\tMarek Szyprowski <m.szyprowski@samsung.com>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"sh does not implement DMA_ATTR_NON_CONSISTENT allocations, so it doesn't\nmake any sense to do any work in dma_cache_sync given that it\nmust be a no-op when dma_alloc_attrs returns coherent memory.\n\nOn the other hand sh uses dma_cache_sync internally in the dma_ops\nimplementation and for the maple bus that does not use the DMA API,\nso a the old functionality for dma_cache_sync is still provided under\nthe name sh_sync_dma_for_device, and without the redundant dev\nargument.  While at it two of the syncing dma_ops also go the proper\n_for_device postfix.\n\nSigned-off-by: Christoph Hellwig <hch@lst.de>\n---\n arch/sh/include/asm/dma-mapping.h |  9 +++++++--\n arch/sh/kernel/dma-nommu.c        | 17 +++++++++--------\n arch/sh/mm/consistent.c           |  6 +++---\n drivers/sh/maple/maple.c          |  5 ++---\n 4 files changed, 21 insertions(+), 16 deletions(-)","diff":"diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h\nindex 9b06be07db4d..b46194ecef17 100644\n--- a/arch/sh/include/asm/dma-mapping.h\n+++ b/arch/sh/include/asm/dma-mapping.h\n@@ -9,8 +9,10 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)\n \treturn dma_ops;\n }\n \n-void dma_cache_sync(struct device *dev, void *vaddr, size_t size,\n-\t\t    enum dma_data_direction dir);\n+static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,\n+\t\t    enum dma_data_direction dir)\n+{\n+}\n \n /* arch/sh/mm/consistent.c */\n extern void *dma_generic_alloc_coherent(struct device *dev, size_t size,\n@@ -20,4 +22,7 @@ extern void dma_generic_free_coherent(struct device *dev, size_t size,\n \t\t\t\t      void *vaddr, dma_addr_t dma_handle,\n \t\t\t\t      unsigned long attrs);\n \n+void sh_sync_dma_for_device(void *vaddr, size_t size,\n+\t    enum dma_data_direction dir);\n+\n #endif /* __ASM_SH_DMA_MAPPING_H */\ndiff --git a/arch/sh/kernel/dma-nommu.c b/arch/sh/kernel/dma-nommu.c\nindex d24c707b2181..62b485107eae 100644\n--- a/arch/sh/kernel/dma-nommu.c\n+++ b/arch/sh/kernel/dma-nommu.c\n@@ -9,6 +9,7 @@\n  */\n #include <linux/dma-mapping.h>\n #include <linux/io.h>\n+#include <asm/cacheflush.h>\n \n static dma_addr_t nommu_map_page(struct device *dev, struct page *page,\n \t\t\t\t unsigned long offset, size_t size,\n@@ -20,7 +21,7 @@ static dma_addr_t nommu_map_page(struct device *dev, struct page *page,\n \tWARN_ON(size == 0);\n \n \tif (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))\n-\t\tdma_cache_sync(dev, page_address(page) + offset, size, dir);\n+\t\tsh_sync_dma_for_device(page_address(page) + offset, size, dir);\n \n \treturn addr;\n }\n@@ -38,7 +39,7 @@ static int nommu_map_sg(struct device *dev, struct scatterlist *sg,\n \t\tBUG_ON(!sg_page(s));\n \n \t\tif (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))\n-\t\t\tdma_cache_sync(dev, sg_virt(s), s->length, dir);\n+\t\t\tsh_sync_dma_for_device(sg_virt(s), s->length, dir);\n \n \t\ts->dma_address = sg_phys(s);\n \t\ts->dma_length = s->length;\n@@ -48,20 +49,20 @@ static int nommu_map_sg(struct device *dev, struct scatterlist *sg,\n }\n \n #ifdef CONFIG_DMA_NONCOHERENT\n-static void nommu_sync_single(struct device *dev, dma_addr_t addr,\n+static void nommu_sync_single_for_device(struct device *dev, dma_addr_t addr,\n \t\t\t      size_t size, enum dma_data_direction dir)\n {\n-\tdma_cache_sync(dev, phys_to_virt(addr), size, dir);\n+\tsh_sync_dma_for_device(phys_to_virt(addr), size, dir);\n }\n \n-static void nommu_sync_sg(struct device *dev, struct scatterlist *sg,\n+static void nommu_sync_sg_for_device(struct device *dev, struct scatterlist *sg,\n \t\t\t  int nelems, enum dma_data_direction dir)\n {\n \tstruct scatterlist *s;\n \tint i;\n \n \tfor_each_sg(sg, s, nelems, i)\n-\t\tdma_cache_sync(dev, sg_virt(s), s->length, dir);\n+\t\tsh_sync_dma_for_device(sg_virt(s), s->length, dir);\n }\n #endif\n \n@@ -71,8 +72,8 @@ const struct dma_map_ops nommu_dma_ops = {\n \t.map_page\t\t= nommu_map_page,\n \t.map_sg\t\t\t= nommu_map_sg,\n #ifdef CONFIG_DMA_NONCOHERENT\n-\t.sync_single_for_device\t= nommu_sync_single,\n-\t.sync_sg_for_device\t= nommu_sync_sg,\n+\t.sync_single_for_device\t= nommu_sync_single_for_device,\n+\t.sync_sg_for_device\t= nommu_sync_sg_for_device,\n #endif\n \t.is_phys\t\t= 1,\n };\ndiff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c\nindex d1275adfa0ef..6ea3aab508f2 100644\n--- a/arch/sh/mm/consistent.c\n+++ b/arch/sh/mm/consistent.c\n@@ -49,7 +49,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,\n \t * Pages from the page allocator may have data present in\n \t * cache. So flush the cache before using uncached memory.\n \t */\n-\tdma_cache_sync(dev, ret, size, DMA_BIDIRECTIONAL);\n+\tsh_sync_dma_for_device(ret, size, DMA_BIDIRECTIONAL);\n \n \tret_nocache = (void __force *)ioremap_nocache(virt_to_phys(ret), size);\n \tif (!ret_nocache) {\n@@ -78,7 +78,7 @@ void dma_generic_free_coherent(struct device *dev, size_t size,\n \tiounmap(vaddr);\n }\n \n-void dma_cache_sync(struct device *dev, void *vaddr, size_t size,\n+void sh_sync_dma_for_device(void *vaddr, size_t size,\n \t\t    enum dma_data_direction direction)\n {\n \tvoid *addr;\n@@ -100,7 +100,7 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,\n \t\tBUG();\n \t}\n }\n-EXPORT_SYMBOL(dma_cache_sync);\n+EXPORT_SYMBOL(sh_sync_dma_for_device);\n \n static int __init memchunk_setup(char *str)\n {\ndiff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c\nindex bec81c2404f7..7525039d812c 100644\n--- a/drivers/sh/maple/maple.c\n+++ b/drivers/sh/maple/maple.c\n@@ -300,7 +300,7 @@ static void maple_send(void)\n \tmutex_unlock(&maple_wlist_lock);\n \tif (maple_packets > 0) {\n \t\tfor (i = 0; i < (1 << MAPLE_DMA_PAGES); i++)\n-\t\t\tdma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE,\n+\t\t\tsh_sync_dma_for_device(maple_sendbuf + i * PAGE_SIZE,\n \t\t\t\t       PAGE_SIZE, DMA_BIDIRECTIONAL);\n \t}\n \n@@ -642,8 +642,7 @@ static void maple_dma_handler(struct work_struct *work)\n \t\tlist_for_each_entry_safe(mq, nmq, &maple_sentq, list) {\n \t\t\tmdev = mq->dev;\n \t\t\trecvbuf = mq->recvbuf->buf;\n-\t\t\tdma_cache_sync(&mdev->dev, recvbuf, 0x400,\n-\t\t\t\tDMA_FROM_DEVICE);\n+\t\t\tsh_sync_dma_for_device(recvbuf, 0x400, DMA_FROM_DEVICE);\n \t\t\tcode = recvbuf[0];\n \t\t\tkfree(mq->sendbuf);\n \t\t\tlist_del_init(&mq->list);\n","prefixes":["11/12"]}