From patchwork Fri Jan 29 11:39:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101038 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1059185lbb; Fri, 29 Jan 2016 03:42:33 -0800 (PST) X-Received: by 10.98.13.68 with SMTP id v65mr12468398pfi.54.1454067753669; Fri, 29 Jan 2016 03:42:33 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id bc9si1765005pad.140.2016.01.29.03.42.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jan 2016 03:42:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1aP7Qb-00073i-Ch; Fri, 29 Jan 2016 11:41:25 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aP7Pe-0005Ei-19 for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2016 11:40:27 +0000 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue005) with ESMTPA (Nemesis) id 0M85Ej-1aBjG31ko5-00vcW7; Fri, 29 Jan 2016 12:39:58 +0100 From: Arnd Bergmann To: David Miller Subject: [PATCH v2 2/7] net: davinci_cpdma: use dma_addr_t for DMA address Date: Fri, 29 Jan 2016 12:39:10 +0100 Message-Id: <1454067557-3546883-3-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454067557-3546883-1-git-send-email-arnd@arndb.de> References: <1454067557-3546883-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:ZtkUFvbxz+X98nRbd6pwiTodY4xVkN0n1B8AqnGR7V+n/BV7u60 rXybdGahfMX1y5s/oQyD2SZcGMEA0jzw/R44M3l+Z0mxKPig4bu/vZqeDDuAGxYvUJjk0l9 gdpVgOLI8Im5H5jWwddYGqS6pYVjcvietGjqbMJiMuRPqqHc/9HyTFNAU7ZDmWZZtkF3kO6 ZgD4vIX96itBQXTgJ+F0Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:lVGydQBJtcc=:zMC06BjqXHaVeC5olPOX52 T/MVzt3oq6Sj/nsKU0hiTQ67Q4qZFAY5amLAV8Tb8bks4pNInWEWbpqMzb0hdNBOGdyXyNHS2 C+7e5g/VpX/PCgkAc1fpIpeF3GxhMesKELcIVPrIgB8AjKG5CZNFsfDtL5lkE32oboRTzH0l5 hnDVRGmV9dajwdtctFsXuu9AzkHomvFuD1/RYjTQHCIIMv+DQWYPJkiVzvKLhG9Eszy3H9r57 z2Ww7QgzkGiK1P/9Anczvpvx3TdWGxYUaiJkFVp6G3Rue87sCRcnmolW+NLU4TMcsFD5Yt6SH Z1X8wCX5ZaXnTFq7t3VqfEL1hCBxwDQKDPoFc4aSSkR2tm9+38qFyFaAe3y4x03ECFEMsvtMJ dr/P/54mKAGDGrH0a1KgmHsZv1YNfmqdcZobjRK7gnFoc92IhRMUVqsMc15oT2J5lw1WwRkFf RkbFPIxq9X3qFhTHD3POSM7TjUSybBROQbAbQw0DZ1onlc+KiqCja2f3gJSFSXCG7sf7TgPSQ GtqsNDD7F6D78Q8di+3GSB9gsLDFXzsLVs+8a0mDVV9ltTyCS3kHo1lWWGGDS9QVuFsK46PMq YxKafAaoPv9rBMqMY6DSuDvhejAxWKJ84TfXjakE1Vlb/0lKZkr6Iyo+pdx8kt5OQdsglLh7h Tw0JcGmCHfrQvGj0wqotdtNdxk24YGq7igWUHavYsko9dlQ4e9xN2bUooFL3ZSfn8Oiw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160129_034026_606957_4B234367 X-CRM114-Status: GOOD ( 16.91 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.135 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.135 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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+patch=linaro.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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)