From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753633AbbKMJgP (ORCPT ); Fri, 13 Nov 2015 04:36:15 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:59684 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670AbbKMJgJ (ORCPT ); Fri, 13 Nov 2015 04:36:09 -0500 From: Arnd Bergmann To: Andy Shevchenko Cc: Ulf Hansson , Jaehoon Chung , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , linux-arm Mailing List Subject: Re: [PATCH] mmc: dw_mmc: use resource_size_t to store physical address Date: Fri, 13 Nov 2015 10:35:16 +0100 Message-ID: <6288847.N1QBIiXedG@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <28102387.ALpaBHpim0@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:Xt6mkKDhfqfsJPCxWs2umwzsr9yq7oM2+r2pqaxZDx1w+7bcmsM nTM0qjzMr5iiRezq8MkwZYJNMxXRHxBBcgtr+vtlZC5b1XVmAx+bib6I+XLOCsX4WNag8AC Rhoqg35jNE1KdnHuPfqlJckcsNw2+owLS6nYVQpr8M8cQYrhwfPIRIXsnVqQ1z3JTU/5IXM xhhQ77WqH9zASlx8FOg2Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:32mZjaxhNU0=:BMrIIwO3AzVaFQSTydrDJm s/SVDeNSXKkgvyOTALMyQYIq4dFXWw605+lAunWYONCPB31NNcuEXyeuYyS4DNyuU6SuAHBOz SfJ67qQSvAnRkuYyT3cZvDXgWnH4oBiImVrXrxSoqkOa9mv3s0fXAYROz5h9j1wwjoQucfLpL hCCzUB0UVYUOvpM1EOx3pSk246nIxwVRGodueKJ+3liuuuL+8I+90iKG12468YVhFJDM4A8gE NclErgOzalUaRJ1Cf/pOEat5O0W7WtDKu6uWhOskb8H9EPrvPtcYldalm2G6GtsEUEflyGPva znNJXHyVQmM98SBEdAdEE7fgzWTEcB/4bQUgcNoO5FRkLzxn8X+mDCNjjLDxL2CX2En6bPP2I pBECVV9+MaEsHRchlX1xyRMACM95SUxMquCtt21ZkY0f9GQZQMMOfwS5COc7Gz+PVXYfYt1qI HbzGSOw2qn/McNlm35hDsO15Ce+zFe/GhMgGdkv7N+AnzycaP+fs88CzxpyIOdXesExZNzFHi JH8RkuuWrDyPkg70p0DCrBfJl6Hu/zIPO4Mw0W+UyJxIXpnFbtri3hHCXbaOzmVgTNKKQcMwa yQldQgpsJOZvUwcxmEGcUBUfKUMUR+YzN3mTV7sfH1jO+b/cqzwMfoATjroWU6nZhxZ3SkIEZ X645YVMDwFvvBgJWCxIgDRkC9weQRj8eby4AanIYKe9TfMQTv5dDBrlXzO2Moo9lPBwvVdoyY uM9lGXLQy9RffC6u Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 13 November 2015 03:10:13 Andy Shevchenko wrote: > On Thu, Nov 12, 2015 at 4:14 PM, Arnd Bergmann wrote: > > The dw_mmc driver stores the physical address of the MMIO registers > > in a pointer, which requires the use of type casts, and is actually > > broken if anyone ever has this device on a 32-bit SoC in registers > > above 4GB. Gcc warns about this possibility when the driver is built > > with ARM LPAE enabled: > > > - host->phy_regs = (void *)(regs->start); > > + host->phy_regs = regs->start; > > > /* Set external dma config: burst size, burst width */ > > - cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); > > + cfg.dst_addr = host->phy_regs + fifo_offset; > > dst_addr is dma_addr_t? Sort of. It doesn't really fit into any of the categories, and we actually had a patch to change the type in the past, see https://lkml.org/lkml/2015/7/10/167. Not sure what is going on there. > > /* Registers's physical base address */ > > - void *phy_regs; > > + resource_size_t phy_regs; > > If dst_addr is dma_addr_t wouldn't be a problem when > resource_size_t is defined as 64-bit address, and dma_addr_t as 32-bit? > > Btw, for me casting to dma_addr_t looks sane. The background here is that the address comes from a resource_size_t that describes the MMIO register area as seen from the CPU, and that is normally a phys_addr_t (resource_size_t is defined as being long enough to store a phys_addr_t or various other things depending on resource->flags). dma_addr_t strictly speaking refers to a RAM location as seen by a DMA master, and that only comes out of dma_map_*() or dma_alloc_coherent(). The DMA engine wants something else here, which is an MMIO register address as seen by a DMA master, and we don't have a separate typedef for that. Almost universally all of resource_size_t, phys_addr_t and dma_addr_t are the same type, and if we ever get a platform that wants something other than a phys_addr_t to put into cfg.dst_addr, we are in deep trouble. Arnd