Commit e96d904e authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()

_ALIGN_DOWN() is specific to powerpc
ALIGN_DOWN() is generic and does the same

Replace _ALIGN_DOWN() by ALIGN_DOWN()
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Reviewed-by: default avatarJoel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/3911a86d6b5bfa7ad88cd7c82416fbe6bb47e793.1587407777.git.christophe.leroy@c-s.fr
parent 7bfc3c84
...@@ -195,7 +195,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); ...@@ -195,7 +195,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
#endif #endif
#ifdef CONFIG_KASAN_VMALLOC #ifdef CONFIG_KASAN_VMALLOC
#define VMALLOC_END _ALIGN_DOWN(ioremap_bot, PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT) #define VMALLOC_END ALIGN_DOWN(ioremap_bot, PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
#else #else
#define VMALLOC_END ioremap_bot #define VMALLOC_END ioremap_bot
#endif #endif
......
...@@ -116,7 +116,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot); ...@@ -116,7 +116,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
#endif #endif
#ifdef CONFIG_KASAN_VMALLOC #ifdef CONFIG_KASAN_VMALLOC
#define VMALLOC_END _ALIGN_DOWN(ioremap_bot, PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT) #define VMALLOC_END ALIGN_DOWN(ioremap_bot, PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
#else #else
#define VMALLOC_END ioremap_bot #define VMALLOC_END ioremap_bot
#endif #endif
......
...@@ -130,7 +130,7 @@ static int pcibios_map_phb_io_space(struct pci_controller *hose) ...@@ -130,7 +130,7 @@ static int pcibios_map_phb_io_space(struct pci_controller *hose)
unsigned long size_page; unsigned long size_page;
unsigned long io_virt_offset; unsigned long io_virt_offset;
phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE); phys_page = ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE); size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
/* Make sure IO area address is clear */ /* Make sure IO area address is clear */
......
...@@ -96,7 +96,7 @@ static inline int overlaps_initrd(unsigned long start, unsigned long size) ...@@ -96,7 +96,7 @@ static inline int overlaps_initrd(unsigned long start, unsigned long size)
if (!initrd_start) if (!initrd_start)
return 0; return 0;
return (start + size) > _ALIGN_DOWN(initrd_start, PAGE_SIZE) && return (start + size) > ALIGN_DOWN(initrd_start, PAGE_SIZE) &&
start <= _ALIGN_UP(initrd_end, PAGE_SIZE); start <= _ALIGN_UP(initrd_end, PAGE_SIZE);
#else #else
return 0; return 0;
...@@ -623,9 +623,9 @@ static void __init early_reserve_mem(void) ...@@ -623,9 +623,9 @@ static void __init early_reserve_mem(void)
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD
/* Then reserve the initrd, if any */ /* Then reserve the initrd, if any */
if (initrd_start && (initrd_end > initrd_start)) { if (initrd_start && (initrd_end > initrd_start)) {
memblock_reserve(_ALIGN_DOWN(__pa(initrd_start), PAGE_SIZE), memblock_reserve(ALIGN_DOWN(__pa(initrd_start), PAGE_SIZE),
_ALIGN_UP(initrd_end, PAGE_SIZE) - _ALIGN_UP(initrd_end, PAGE_SIZE) -
_ALIGN_DOWN(initrd_start, PAGE_SIZE)); ALIGN_DOWN(initrd_start, PAGE_SIZE));
} }
#endif /* CONFIG_BLK_DEV_INITRD */ #endif /* CONFIG_BLK_DEV_INITRD */
......
...@@ -1500,7 +1500,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align, ...@@ -1500,7 +1500,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
if (highmem) { if (highmem) {
/* Carve out storage for the TCE table. */ /* Carve out storage for the TCE table. */
addr = _ALIGN_DOWN(alloc_top_high - size, align); addr = ALIGN_DOWN(alloc_top_high - size, align);
if (addr <= alloc_bottom) if (addr <= alloc_bottom)
return 0; return 0;
/* Will we bump into the RMO ? If yes, check out that we /* Will we bump into the RMO ? If yes, check out that we
...@@ -1518,9 +1518,9 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align, ...@@ -1518,9 +1518,9 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
goto bail; goto bail;
} }
base = _ALIGN_DOWN(alloc_top - size, align); base = ALIGN_DOWN(alloc_top - size, align);
for (; base > alloc_bottom; for (; base > alloc_bottom;
base = _ALIGN_DOWN(base - 0x100000, align)) { base = ALIGN_DOWN(base - 0x100000, align)) {
prom_debug(" trying: 0x%lx\n\r", base); prom_debug(" trying: 0x%lx\n\r", base);
addr = (unsigned long)prom_claim(base, size, 0); addr = (unsigned long)prom_claim(base, size, 0);
if (addr != PROM_ERROR && addr != 0) if (addr != PROM_ERROR && addr != 0)
...@@ -1586,7 +1586,7 @@ static void __init reserve_mem(u64 base, u64 size) ...@@ -1586,7 +1586,7 @@ static void __init reserve_mem(u64 base, u64 size)
* have our terminator with "size" set to 0 since we are * have our terminator with "size" set to 0 since we are
* dumb and just copy this entire array to the boot params * dumb and just copy this entire array to the boot params
*/ */
base = _ALIGN_DOWN(base, PAGE_SIZE); base = ALIGN_DOWN(base, PAGE_SIZE);
top = _ALIGN_UP(top, PAGE_SIZE); top = _ALIGN_UP(top, PAGE_SIZE);
size = top - base; size = top - base;
......
...@@ -193,7 +193,7 @@ void __flush_hash_table_range(unsigned long start, unsigned long end) ...@@ -193,7 +193,7 @@ void __flush_hash_table_range(unsigned long start, unsigned long end)
int hugepage_shift; int hugepage_shift;
unsigned long flags; unsigned long flags;
start = _ALIGN_DOWN(start, PAGE_SIZE); start = ALIGN_DOWN(start, PAGE_SIZE);
end = _ALIGN_UP(end, PAGE_SIZE); end = _ALIGN_UP(end, PAGE_SIZE);
...@@ -228,7 +228,7 @@ void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr) ...@@ -228,7 +228,7 @@ void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr)
pte_t *start_pte; pte_t *start_pte;
unsigned long flags; unsigned long flags;
addr = _ALIGN_DOWN(addr, PMD_SIZE); addr = ALIGN_DOWN(addr, PMD_SIZE);
/* /*
* Note: Normally, we should only ever use a batch within a * Note: Normally, we should only ever use a batch within a
* PTE locked section. This violates the rule, but will work * PTE locked section. This violates the rule, but will work
......
...@@ -203,7 +203,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, ...@@ -203,7 +203,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift; unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift;
/* Align to the page size of the linear mapping. */ /* Align to the page size of the linear mapping. */
start = _ALIGN_DOWN(start, page_size); start = ALIGN_DOWN(start, page_size);
pr_debug("vmemmap_populate %lx..%lx, node %d\n", start, end, node); pr_debug("vmemmap_populate %lx..%lx, node %d\n", start, end, node);
...@@ -292,7 +292,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end, ...@@ -292,7 +292,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end,
unsigned long alt_start = ~0, alt_end = ~0; unsigned long alt_start = ~0, alt_end = ~0;
unsigned long base_pfn; unsigned long base_pfn;
start = _ALIGN_DOWN(start, page_size); start = ALIGN_DOWN(start, page_size);
if (altmap) { if (altmap) {
alt_start = altmap->base_pfn; alt_start = altmap->base_pfn;
alt_end = altmap->base_pfn + altmap->reserve + alt_end = altmap->base_pfn + altmap->reserve +
......
...@@ -671,7 +671,7 @@ void __init opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) ...@@ -671,7 +671,7 @@ void __init opal_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node)
* Firmware supports 32-bit field for size. Align it to PAGE_SIZE * Firmware supports 32-bit field for size. Align it to PAGE_SIZE
* and request firmware to copy multiple kernel boot memory regions. * and request firmware to copy multiple kernel boot memory regions.
*/ */
fadump_conf->max_copy_size = _ALIGN_DOWN(U32_MAX, PAGE_SIZE); fadump_conf->max_copy_size = ALIGN_DOWN(U32_MAX, PAGE_SIZE);
/* /*
* Check if dump has been initiated on last reboot. * Check if dump has been initiated on last reboot.
......
...@@ -264,7 +264,7 @@ static void pnv_ioda_reserve_dev_m64_pe(struct pci_dev *pdev, ...@@ -264,7 +264,7 @@ static void pnv_ioda_reserve_dev_m64_pe(struct pci_dev *pdev,
if (!r->parent || !pnv_pci_is_m64(phb, r)) if (!r->parent || !pnv_pci_is_m64(phb, r))
continue; continue;
start = _ALIGN_DOWN(r->start - base, sgsz); start = ALIGN_DOWN(r->start - base, sgsz);
end = _ALIGN_UP(r->end - base, sgsz); end = _ALIGN_UP(r->end - base, sgsz);
for (segno = start / sgsz; segno < end / sgsz; segno++) { for (segno = start / sgsz; segno < end / sgsz; segno++) {
if (pe_bitmap) if (pe_bitmap)
......
...@@ -263,7 +263,7 @@ static int ps3_mm_region_create(struct mem_region *r, unsigned long size) ...@@ -263,7 +263,7 @@ static int ps3_mm_region_create(struct mem_region *r, unsigned long size)
int result; int result;
u64 muid; u64 muid;
r->size = _ALIGN_DOWN(size, 1 << PAGE_SHIFT_16M); r->size = ALIGN_DOWN(size, 1 << PAGE_SHIFT_16M);
DBG("%s:%d requested %lxh\n", __func__, __LINE__, size); DBG("%s:%d requested %lxh\n", __func__, __LINE__, size);
DBG("%s:%d actual %llxh\n", __func__, __LINE__, r->size); DBG("%s:%d actual %llxh\n", __func__, __LINE__, r->size);
...@@ -394,7 +394,7 @@ static struct dma_chunk * dma_find_chunk(struct ps3_dma_region *r, ...@@ -394,7 +394,7 @@ static struct dma_chunk * dma_find_chunk(struct ps3_dma_region *r,
unsigned long bus_addr, unsigned long len) unsigned long bus_addr, unsigned long len)
{ {
struct dma_chunk *c; struct dma_chunk *c;
unsigned long aligned_bus = _ALIGN_DOWN(bus_addr, 1 << r->page_size); unsigned long aligned_bus = ALIGN_DOWN(bus_addr, 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len+bus_addr-aligned_bus, unsigned long aligned_len = _ALIGN_UP(len+bus_addr-aligned_bus,
1 << r->page_size); 1 << r->page_size);
...@@ -423,7 +423,7 @@ static struct dma_chunk *dma_find_chunk_lpar(struct ps3_dma_region *r, ...@@ -423,7 +423,7 @@ static struct dma_chunk *dma_find_chunk_lpar(struct ps3_dma_region *r,
unsigned long lpar_addr, unsigned long len) unsigned long lpar_addr, unsigned long len)
{ {
struct dma_chunk *c; struct dma_chunk *c;
unsigned long aligned_lpar = _ALIGN_DOWN(lpar_addr, 1 << r->page_size); unsigned long aligned_lpar = ALIGN_DOWN(lpar_addr, 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + lpar_addr - aligned_lpar, unsigned long aligned_len = _ALIGN_UP(len + lpar_addr - aligned_lpar,
1 << r->page_size); 1 << r->page_size);
...@@ -775,7 +775,7 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr, ...@@ -775,7 +775,7 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
struct dma_chunk *c; struct dma_chunk *c;
unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr) unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
: virt_addr; : virt_addr;
unsigned long aligned_phys = _ALIGN_DOWN(phys_addr, 1 << r->page_size); unsigned long aligned_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys, unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
1 << r->page_size); 1 << r->page_size);
*bus_addr = dma_sb_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr)); *bus_addr = dma_sb_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr));
...@@ -830,7 +830,7 @@ static int dma_ioc0_map_area(struct ps3_dma_region *r, unsigned long virt_addr, ...@@ -830,7 +830,7 @@ static int dma_ioc0_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
struct dma_chunk *c; struct dma_chunk *c;
unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr) unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
: virt_addr; : virt_addr;
unsigned long aligned_phys = _ALIGN_DOWN(phys_addr, 1 << r->page_size); unsigned long aligned_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys, unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
1 << r->page_size); 1 << r->page_size);
...@@ -889,7 +889,7 @@ static int dma_sb_unmap_area(struct ps3_dma_region *r, dma_addr_t bus_addr, ...@@ -889,7 +889,7 @@ static int dma_sb_unmap_area(struct ps3_dma_region *r, dma_addr_t bus_addr,
c = dma_find_chunk(r, bus_addr, len); c = dma_find_chunk(r, bus_addr, len);
if (!c) { if (!c) {
unsigned long aligned_bus = _ALIGN_DOWN(bus_addr, unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
1 << r->page_size); 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + bus_addr unsigned long aligned_len = _ALIGN_UP(len + bus_addr
- aligned_bus, 1 << r->page_size); - aligned_bus, 1 << r->page_size);
...@@ -926,7 +926,7 @@ static int dma_ioc0_unmap_area(struct ps3_dma_region *r, ...@@ -926,7 +926,7 @@ static int dma_ioc0_unmap_area(struct ps3_dma_region *r,
c = dma_find_chunk(r, bus_addr, len); c = dma_find_chunk(r, bus_addr, len);
if (!c) { if (!c) {
unsigned long aligned_bus = _ALIGN_DOWN(bus_addr, unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
1 << r->page_size); 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + bus_addr unsigned long aligned_len = _ALIGN_UP(len + bus_addr
- aligned_bus, - aligned_bus,
......
...@@ -506,7 +506,7 @@ void __init rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node) ...@@ -506,7 +506,7 @@ void __init rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node)
fadump_conf->fadump_supported = 1; fadump_conf->fadump_supported = 1;
/* Firmware supports 64-bit value for size, align it to pagesize. */ /* Firmware supports 64-bit value for size, align it to pagesize. */
fadump_conf->max_copy_size = _ALIGN_DOWN(U64_MAX, PAGE_SIZE); fadump_conf->max_copy_size = ALIGN_DOWN(U64_MAX, PAGE_SIZE);
/* /*
* The 'ibm,kernel-dump' rtas node is present only if there is * The 'ibm,kernel-dump' rtas node is present only if there is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment