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: 101073 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2602110lbb; Wed, 27 Jan 2016 06:06:40 -0800 (PST) X-Received: by 10.98.9.220 with SMTP id 89mr42872428pfj.17.1453903600461; Wed, 27 Jan 2016 06:06:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xp4si9784778pab.1.2016.01.27.06.06.40; Wed, 27 Jan 2016 06:06:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932686AbcA0OGh (ORCPT + 4 others); Wed, 27 Jan 2016 09:06:37 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:63193 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754261AbcA0OGg (ORCPT ); Wed, 27 Jan 2016 09:06:36 -0500 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" Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org 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= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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(-) -- 2.7.0 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)