Skip to content

Commit c5c3238

Browse files
Christoph Hellwigarndb
authored andcommitted
asm-generic: provide generic page_to_phys and phys_to_page implementations
page_to_phys is duplicated by all architectures, and from some strange reason placed in <asm/io.h> where it doesn't fit at all. phys_to_page is only provided by a few architectures despite having a lot of open coded users. Provide generic versions in <asm-generic/memory_model.h> to make these helpers more easily usable. Note with this patch powerpc loses the CONFIG_DEBUG_VIRTUAL pfn_valid check. It will be added back in a generic version later. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 6f043e7 commit c5c3238

22 files changed

Lines changed: 3 additions & 71 deletions

File tree

arch/alpha/include/asm/io.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static inline void * phys_to_virt(unsigned long address)
8888

8989
#define virt_to_phys virt_to_phys
9090
#define phys_to_virt phys_to_virt
91-
#define page_to_phys(page) page_to_pa(page)
9291

9392
/* Maximum PIO space address supported? */
9493
#define IO_SPACE_LIMIT 0xffff

arch/arc/include/asm/io.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ static inline void ioport_unmap(void __iomem *addr)
4242
#define iowrite16be(v,p) ({ __iowmb(); __raw_writew((__force u16)cpu_to_be16(v), p); })
4343
#define iowrite32be(v,p) ({ __iowmb(); __raw_writel((__force u32)cpu_to_be32(v), p); })
4444

45-
/* Change struct page to physical address */
46-
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
47-
4845
#define __raw_readb __raw_readb
4946
static inline u8 __raw_readb(const volatile void __iomem *addr)
5047
{

arch/arm/include/asm/memory.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@ extern unsigned long vectors_base;
147147
#define DTCM_OFFSET UL(0xfffe8000)
148148
#endif
149149

150-
/*
151-
* Convert a page to/from a physical address
152-
*/
153-
#define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
154-
#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
155-
156150
/*
157151
* PLAT_PHYS_OFFSET is the offset (from zero) of the start of physical
158152
* memory. This is used for XIP and NoMMU kernels, and on platforms that don't

arch/arm64/include/asm/memory.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,6 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
353353
#define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET)
354354
#define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset))
355355

356-
/*
357-
* Convert a page to/from a physical address
358-
*/
359-
#define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
360-
#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
361-
362356
/*
363357
* Note: Drivers should NOT use these. They are the wrong
364358
* translation for translating DMA addresses. Use the driver

arch/csky/include/asm/page.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ extern void *memcpy(void *to, const void *from, size_t l);
4343
#define clear_page(page) memset((page), 0, PAGE_SIZE)
4444
#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
4545

46-
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
47-
#define phys_to_page(paddr) (pfn_to_page(PFN_DOWN(paddr)))
48-
4946
struct page;
5047

5148
#include <abi/page.h>

arch/hexagon/include/asm/page.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ static inline void clear_page(void *page)
118118
#define clear_user_page(page, vaddr, pg) clear_page(page)
119119
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
120120

121-
/*
122-
* page_to_phys - convert page to physical address
123-
* @page - pointer to page entry in mem_map
124-
*/
125-
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
126-
127121
static inline unsigned long virt_to_pfn(const void *kaddr)
128122
{
129123
return __pa(kaddr) >> PAGE_SHIFT;

arch/loongarch/include/asm/page.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ struct page *tlb_virt_to_page(unsigned long kaddr);
8181
#define pfn_to_phys(pfn) __pfn_to_phys(pfn)
8282
#define phys_to_pfn(paddr) __phys_to_pfn(paddr)
8383

84-
#define page_to_phys(page) pfn_to_phys(page_to_pfn(page))
85-
#define phys_to_page(paddr) pfn_to_page(phys_to_pfn(paddr))
86-
8784
#ifndef CONFIG_KFENCE
8885

8986
#define page_to_virt(page) __va(page_to_phys(page))

arch/m68k/include/asm/virtconvert.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ static inline void *phys_to_virt(unsigned long address)
2828
return __va(address);
2929
}
3030

31-
/* Permanent address of a page. */
32-
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
33-
3431
/*
3532
* IO bus memory addresses are 1:1 with the physical address,
3633
* deprecated globally but still used on two machines.

arch/microblaze/include/asm/page.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ extern int page_is_ram(unsigned long pfn);
101101

102102
# define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
103103
# define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
104-
# define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
105104

106105
# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
107106
# endif /* __ASSEMBLY__ */

arch/mips/include/asm/io.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ static inline unsigned long isa_virt_to_bus(volatile void *address)
125125
return virt_to_phys(address);
126126
}
127127

128-
/*
129-
* Change "struct page" to physical address.
130-
*/
131-
#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
132-
133128
void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
134129
unsigned long prot_val);
135130
void iounmap(const volatile void __iomem *addr);

0 commit comments

Comments
 (0)