Skip to content

Commit

Permalink
arm64: mm: Simplify definition of virt_addr_valid()
Browse files Browse the repository at this point in the history
_virt_addr_valid() is defined as the same value in two places and rolls
its own version of virt_to_pfn() in both cases.

Consolidate these definitions by inlining a simplified version directly
into virt_addr_valid().

Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Will Deacon committed Aug 9, 2019
1 parent d2c68de commit d2d73d2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions arch/arm64/include/asm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ static inline void *phys_to_virt(phys_addr_t x)

#if !defined(CONFIG_SPARSEMEM_VMEMMAP) || defined(CONFIG_DEBUG_VIRTUAL)
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
#define _virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
#else
#define __virt_to_pgoff(kaddr) (((u64)(kaddr) - PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page))
#define __page_to_voff(kaddr) (((u64)(kaddr) - VMEMMAP_START) * PAGE_SIZE / sizeof(struct page))
Expand All @@ -326,15 +325,14 @@ static inline void *phys_to_virt(phys_addr_t x)
})

#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) + VMEMMAP_START))

#define _virt_addr_valid(kaddr) pfn_valid(__virt_to_phys((u64)(kaddr)) >> PAGE_SHIFT)
#endif
#endif

#define _virt_addr_is_linear(kaddr) \
(__tag_reset((u64)(kaddr)) >= PAGE_OFFSET)

#define virt_addr_valid(kaddr) \
(_virt_addr_is_linear(kaddr) && _virt_addr_valid(kaddr))
(_virt_addr_is_linear(kaddr) && pfn_valid(virt_to_pfn(kaddr)))

/*
* Given that the GIC architecture permits ITS implementations that can only be
Expand Down

0 comments on commit d2d73d2

Please sign in to comment.