lkml.org 
[lkml]   [2013]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC/RFT PATCH 4/5] ARM: mm: change max*pfn to include the physical offset of memory
On Fri, Jul 12, 2013 at 05:48:13PM -0400, Santosh Shilimkar wrote:
> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
> index 5b579b9..b2d5937 100644
> --- a/arch/arm/include/asm/dma-mapping.h
> +++ b/arch/arm/include/asm/dma-mapping.h
> @@ -47,12 +47,12 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
> #ifndef __arch_pfn_to_dma
> static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> {
> - return (dma_addr_t)__pfn_to_bus(pfn);
> + return (dma_addr_t)__pfn_to_bus(pfn + PHYS_PFN_OFFSET);
> }
>
> static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> {
> - return __bus_to_pfn(addr);
> + return __bus_to_pfn(addr) - PHYS_PFN_OFFSET;
> }
>
> static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
> @@ -64,15 +64,16 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> {
> return (dma_addr_t)__virt_to_bus((unsigned long)(addr));
> }
> +
> #else
> static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn)
> {
> - return __arch_pfn_to_dma(dev, pfn);
> + return __arch_pfn_to_dma(dev, pfn + PHYS_PFN_OFFSET);
> }
>
> static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)
> {
> - return __arch_dma_to_pfn(dev, addr);
> + return __arch_dma_to_pfn(dev, addr) - PHYS_PFN_OFFSET;
> }
>
> static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
> @@ -86,6 +87,13 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr)
> }
> #endif

Note that I don't think the above are correct - the 'pfn' argument to the
above functions already includes the PFN offset of physical memory -
they're all physical_address >> PAGE_SHIFT values.

> +/* The ARM override for dma_max_pfn() */
> +static inline unsigned long dma_max_pfn(struct device *dev)
> +{
> + return dma_to_pfn(dev, *dev->dma_mask);
> +}
> +#define dma_max_pfn(dev) dma_max_pfn(dev)

So I'd suggest this becomes:

return PHYS_PFN_OFFSET + dma_to_pfn(dev, *dev->dma_mask);


\
 
 \ /
  Last update: 2013-07-31 13:21    [W:0.143 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site