From patchwork Wed Jan 27 14:04:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8134161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C19F1BEEE5 for ; Wed, 27 Jan 2016 14:08:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5790200FF for ; Wed, 27 Jan 2016 14:08:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC214202E6 for ; Wed, 27 Jan 2016 14:08:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOQkE-0001B1-FB; Wed, 27 Jan 2016 14:06:50 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOQjv-0000sg-BX for linux-arm-kernel@lists.infradead.org; Wed, 27 Jan 2016 14:06:34 +0000 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPA (Nemesis) id 0MZ5ZT-1acR5e4Act-00Vknw; Wed, 27 Jan 2016 15:06:02 +0100 From: Arnd Bergmann To: "David S. Miller" Subject: [PATCH 1/9] net: davinci_cpdma: use dma_addr_t for DMA address Date: Wed, 27 Jan 2016 15:04:51 +0100 Message-Id: <1453903507-3427225-2-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453903507-3427225-1-git-send-email-arnd@arndb.de> References: <1453903507-3427225-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:ccpKAqQWTPUStZfxZQMfoTEC5A4iPkvwCBCWcVfeXwfHCy9Wzvr 3rh9pFmkLkkLhBx1RbIT0i2Vf+803XmsxueqSiSbvnsFgL611YpG2hWylrva5i8Gcyoif6x 8L6xH6Kjbb2EGo3ik2jnq6CkWbJu9WDVonrOH05dLAQM5GMYHWRIRahuFQDyZ7FOlseYGot W1uKkYuAxfCryjSIHxEEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:bjZ4JbSPHDM=:WirqtIf9PjCXaNzYzZiMT8 KFB4jvBfzC9UHRF+RVeT+aH/M802znWzv1W9biFrhders1YIQvI2XRKwVDwp8rzq4M7KXPP+L i+IWDujfvEej4KhzanbH+WhAXzsIAO44tGAzSkYdIoTcHQGbl5PQ87Xg92zlkvxRZfMNG2GyW LRTUykCzHDHeDIFhNZMYYESDSRI3wjAwhMPCumrnEoXuJplnPrOiQWa5aZ51Co+xZUfUbKJNb dxwvqT6aLdyFCXcSHBMy7u+3k4Vxc8IJ7f867Ow7/I+rPNRcKOAwyZsce85CXjZ5xOwBcQ8y5 Nqi41JzhR3Xto+NNkBtYLHGOJvLffymH3OtKi4qMpiNhJbiVukb3rNIngOQmvjJSCQ2TMGWd9 aLGlZfiz1e0LBs/3MYIfCxNR8nenuPcAE6asX5fvW1DlxXrI/pSOn4ODQNsS/oxBdJAF17sOg 50AeQAe6pRFwwkw2AMVc3LxTqek9+uPCNtvlc7UtdOk3aWJ5B1jXQuFZv3E6wPqXzH81LlS2j 1uE0Mq8e2kcoZK4mcnrFPjVNNpi75mtcKoHgOy8SwbfsclzAcmz9s8ZA5xZeYtkDfVD0uUW2n 4aY7L/xGCJNkZNClqpMQ/82shrXag+J5/7HZHT5dL0jh6G2hu8XtlpksnvtZLrnjvqfFxQMDH C8BOA1iXEOpsIYN2ZJR0HwneoE0B42V/TP7nK48wQtFaEFAzYPOOIVp4PLfcnP61EKbs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160127_060632_070327_49907BE4 X-CRM114-Status: GOOD ( 16.99 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The davinci_cpdma mixes up physical addresses as seen from the CPU and DMA addresses as seen from a DMA master, since it can operate on both normal memory or an on-chip buffer. If dma_addr_t is different from phys_addr_t, this means we get a compile-time warning about the type mismatch: ethernet/ti/davinci_cpdma.c: In function 'cpdma_desc_pool_create': ethernet/ti/davinci_cpdma.c:182:48: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys, In file included from ethernet/ti/davinci_cpdma.c:21:0: dma-mapping.h:398:21: note: expected 'dma_addr_t * {aka long long unsigned int *}' but argument is of type 'phys_addr_t * {aka unsigned int *}' static inline void *dma_alloc_coherent(struct device *dev, size_t size, This slightly restructures the code so the address we use for mapping RAM into a DMA address is always a dma_addr_t, avoiding the warning. The code is correct even if both types are 32-bit because the DMA master in this device only supports 32-bit addressing anyway, independent of the types that are used. We still assign this value to pool->phys, and that is wrong if the driver is ever used with an IOMMU, but that value appears to be never used, so there is no problem really. I've added a couple of comments about where we do things that are slightly violating the API. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/ti/davinci_cpdma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 657b65bf5cac..18bf3a8fdc50 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -82,7 +82,7 @@ struct cpdma_desc { struct cpdma_desc_pool { phys_addr_t phys; - u32 hw_addr; + dma_addr_t hw_addr; void __iomem *iomap; /* ioremap map */ void *cpumap; /* dma_alloc map */ int desc_size, mem_size; @@ -152,7 +152,7 @@ struct cpdma_chan { * abstract out these details */ static struct cpdma_desc_pool * -cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr, +cpdma_desc_pool_create(struct device *dev, u32 phys, dma_addr_t hw_addr, int size, int align) { int bitmap_size; @@ -176,13 +176,13 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr, if (phys) { pool->phys = phys; - pool->iomap = ioremap(phys, size); + pool->iomap = ioremap(phys, size); /* should be memremap? */ pool->hw_addr = hw_addr; } else { - pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys, + pool->cpumap = dma_alloc_coherent(dev, size, &pool->hw_addr, GFP_KERNEL); - pool->iomap = pool->cpumap; - pool->hw_addr = pool->phys; + pool->iomap = (void __iomem __force *)pool->cpumap; + pool->phys = pool->hw_addr; /* assumes no IOMMU, don't use this value */ } if (pool->iomap)