From: Jaehoon Chung <jh80.chung@samsung.com>
To: Arnd Bergmann <arnd@arndb.de>,
Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] mmc: dw_mmc: use resource_size_t to store physical address
Date: Wed, 18 Nov 2015 09:13:14 +0900 [thread overview]
Message-ID: <564BC29A.9010306@samsung.com> (raw)
In-Reply-To: <6288847.N1QBIiXedG@wuerfel>
Dear, Arnd.
On 11/13/2015 06:35 PM, Arnd Bergmann wrote:
> On Friday 13 November 2015 03:10:13 Andy Shevchenko wrote:
>> On Thu, Nov 12, 2015 at 4:14 PM, Arnd Bergmann <arnd@arndb.de> 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.
why isn't the patch applied on mainline yet? :)
Best Regards,
Jaehoon Chung
>
>>> /* 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
>
WARNING: multiple messages have this Message-ID (diff)
From: jh80.chung@samsung.com (Jaehoon Chung)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mmc: dw_mmc: use resource_size_t to store physical address
Date: Wed, 18 Nov 2015 09:13:14 +0900 [thread overview]
Message-ID: <564BC29A.9010306@samsung.com> (raw)
In-Reply-To: <6288847.N1QBIiXedG@wuerfel>
Dear, Arnd.
On 11/13/2015 06:35 PM, Arnd Bergmann wrote:
> On Friday 13 November 2015 03:10:13 Andy Shevchenko wrote:
>> On Thu, Nov 12, 2015 at 4:14 PM, Arnd Bergmann <arnd@arndb.de> 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.
why isn't the patch applied on mainline yet? :)
Best Regards,
Jaehoon Chung
>
>>> /* 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
>
next prev parent reply other threads:[~2015-11-18 0:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-12 14:14 [PATCH] mmc: dw_mmc: use resource_size_t to store physical address Arnd Bergmann
2015-11-12 14:14 ` Arnd Bergmann
2015-11-13 1:10 ` Andy Shevchenko
2015-11-13 1:10 ` Andy Shevchenko
2015-11-13 9:35 ` Arnd Bergmann
2015-11-13 9:35 ` Arnd Bergmann
2015-11-18 0:13 ` Jaehoon Chung [this message]
2015-11-18 0:13 ` Jaehoon Chung
2015-11-18 9:35 ` Andy Shevchenko
2015-11-18 9:35 ` Andy Shevchenko
2015-11-18 12:38 ` Arnd Bergmann
2015-11-18 12:38 ` Arnd Bergmann
2015-11-18 15:29 ` Andy Shevchenko
2015-11-18 15:29 ` Andy Shevchenko
2015-11-18 15:45 ` Arnd Bergmann
2015-11-18 15:45 ` Arnd Bergmann
2015-11-18 16:17 ` Andy Shevchenko
2015-11-18 16:17 ` Andy Shevchenko
2015-11-18 16:22 ` Arnd Bergmann
2015-11-18 16:22 ` Arnd Bergmann
2015-11-18 16:22 ` Arnd Bergmann
2015-11-18 18:10 ` Andy Shevchenko
2015-11-18 18:10 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=564BC29A.9010306@samsung.com \
--to=jh80.chung@samsung.com \
--cc=andy.shevchenko@gmail.com \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.