powerpc: Replace _ALIGN_UP() by ALIGN()
authorChristophe Leroy <christophe.leroy@c-s.fr>
Mon, 20 Apr 2020 18:36:36 +0000 (18:36 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 11 May 2020 13:15:15 +0000 (23:15 +1000)
_ALIGN_UP() is specific to powerpc
ALIGN() is generic and does the same

Replace _ALIGN_UP() by ALIGN()

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Link: https://lore.kernel.org/r/8a6d7e45f7904c73a0af539642d3962e2a3c7268.1587407777.git.christophe.leroy@c-s.fr
15 files changed:
arch/powerpc/include/asm/iommu.h
arch/powerpc/kernel/head_booke.h
arch/powerpc/kernel/nvram_64.c
arch/powerpc/kernel/pci_64.c
arch/powerpc/kernel/prom.c
arch/powerpc/kernel/prom_init.c
arch/powerpc/kvm/book3s_64_vio_hv.c
arch/powerpc/mm/book3s64/hash_tlb.c
arch/powerpc/mm/book3s64/radix_pgtable.c
arch/powerpc/mm/slice.c
arch/powerpc/platforms/cell/iommu.c
arch/powerpc/platforms/powermac/bootx_init.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/ps3/mm.c
arch/powerpc/platforms/ps3/setup.c

index 350101e11ddb4a6395a6cf352a0008616afee083..5032f1593299ef86111d04ba4d37083782f8292f 100644 (file)
 #define IOMMU_PAGE_SHIFT_4K      12
 #define IOMMU_PAGE_SIZE_4K       (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K)
 #define IOMMU_PAGE_MASK_4K       (~((1 << IOMMU_PAGE_SHIFT_4K) - 1))
-#define IOMMU_PAGE_ALIGN_4K(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE_4K)
+#define IOMMU_PAGE_ALIGN_4K(addr) ALIGN(addr, IOMMU_PAGE_SIZE_4K)
 
 #define IOMMU_PAGE_SIZE(tblptr) (ASM_CONST(1) << (tblptr)->it_page_shift)
 #define IOMMU_PAGE_MASK(tblptr) (~((1 << (tblptr)->it_page_shift) - 1))
-#define IOMMU_PAGE_ALIGN(addr, tblptr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE(tblptr))
+#define IOMMU_PAGE_ALIGN(addr, tblptr) ALIGN(addr, IOMMU_PAGE_SIZE(tblptr))
 
 /* Boot time flags */
 extern int iommu_is_off;
index bd2e5ed8dd50fb310b337bd22b92f3616a810a50..18f87bf9e32b065bb84ae0c9fdfee0ea2e6df2a1 100644 (file)
@@ -534,7 +534,7 @@ struct exception_regs {
 };
 
 /* ensure this structure is always sized to a multiple of the stack alignment */
-#define STACK_EXC_LVL_FRAME_SIZE       _ALIGN_UP(sizeof (struct exception_regs), 16)
+#define STACK_EXC_LVL_FRAME_SIZE       ALIGN(sizeof (struct exception_regs), 16)
 
 #endif /* __ASSEMBLY__ */
 #endif /* __HEAD_BOOKE_H__ */
index fb4f61096613217503c089561cff8ea85575f2c2..314780e8ef784b5a89222470e966af4ec2b76eb4 100644 (file)
@@ -854,8 +854,8 @@ loff_t __init nvram_create_partition(const char *name, int sig,
        BUILD_BUG_ON(NVRAM_BLOCK_LEN != 16);
 
        /* Convert sizes from bytes to blocks */
-       req_size = _ALIGN_UP(req_size, NVRAM_BLOCK_LEN) / NVRAM_BLOCK_LEN;
-       min_size = _ALIGN_UP(min_size, NVRAM_BLOCK_LEN) / NVRAM_BLOCK_LEN;
+       req_size = ALIGN(req_size, NVRAM_BLOCK_LEN) / NVRAM_BLOCK_LEN;
+       min_size = ALIGN(min_size, NVRAM_BLOCK_LEN) / NVRAM_BLOCK_LEN;
 
        /* If no minimum size specified, make it the same as the
         * requested size
index 89591fb31fb65a1a4afe83480b0f5f767b4646aa..6a932de18aa61f05b62c543dbc5d4c44deaf5108 100644 (file)
@@ -131,7 +131,7 @@ static int pcibios_map_phb_io_space(struct pci_controller *hose)
        unsigned long io_virt_offset;
 
        phys_page = ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
-       size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
+       size_page = ALIGN(hose->pci_io_size, PAGE_SIZE);
 
        /* Make sure IO area address is clear */
        hose->io_base_alloc = NULL;
index 10b5d5eafd34cdf3facf04640e098d4d4a0cd524..1dcf0e214a223b2ac4919cc25fe47108c0cfdfa9 100644 (file)
@@ -97,7 +97,7 @@ static inline int overlaps_initrd(unsigned long start, unsigned long size)
                return 0;
 
        return  (start + size) > ALIGN_DOWN(initrd_start, PAGE_SIZE) &&
-                       start <= _ALIGN_UP(initrd_end, PAGE_SIZE);
+                       start <= ALIGN(initrd_end, PAGE_SIZE);
 #else
        return 0;
 #endif
@@ -624,7 +624,7 @@ static void __init early_reserve_mem(void)
        /* Then reserve the initrd, if any */
        if (initrd_start && (initrd_end > initrd_start)) {
                memblock_reserve(ALIGN_DOWN(__pa(initrd_start), PAGE_SIZE),
-                       _ALIGN_UP(initrd_end, PAGE_SIZE) -
+                       ALIGN(initrd_end, PAGE_SIZE) -
                        ALIGN_DOWN(initrd_start, PAGE_SIZE));
        }
 #endif /* CONFIG_BLK_DEV_INITRD */
index 4cf5958eebd40ee015690d6597e64b01c25fef84..3a5a7db4564f7dfd4b1d14f18a32f17e9beefeb9 100644 (file)
@@ -1449,18 +1449,18 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
        unsigned long addr = 0;
 
        if (align)
-               base = _ALIGN_UP(base, align);
+               base = ALIGN(base, align);
        prom_debug("%s(%lx, %lx)\n", __func__, size, align);
        if (ram_top == 0)
                prom_panic("alloc_up() called with mem not initialized\n");
 
        if (align)
-               base = _ALIGN_UP(alloc_bottom, align);
+               base = ALIGN(alloc_bottom, align);
        else
                base = alloc_bottom;
 
        for(; (base + size) <= alloc_top; 
-           base = _ALIGN_UP(base + 0x100000, align)) {
+           base = ALIGN(base + 0x100000, align)) {
                prom_debug("    trying: 0x%lx\n\r", base);
                addr = (unsigned long)prom_claim(base, size, 0);
                if (addr != PROM_ERROR && addr != 0)
@@ -1587,7 +1587,7 @@ static void __init reserve_mem(u64 base, u64 size)
         * dumb and just copy this entire array to the boot params
         */
        base = ALIGN_DOWN(base, PAGE_SIZE);
-       top = _ALIGN_UP(top, PAGE_SIZE);
+       top = ALIGN(top, PAGE_SIZE);
        size = top - base;
 
        if (cnt >= (MEM_RESERVE_MAP_SIZE - 1))
index 167029e57c8ff6dc8b615cab912ce3b70aeba9b2..ac6ac192b8bb2f195e262135dfc5c6351db382e1 100644 (file)
@@ -205,7 +205,7 @@ static long kvmppc_rm_ioba_validate(struct kvmppc_spapr_tce_table *stt,
 
        idx = (ioba >> stt->page_shift) - stt->offset;
        sttpage = idx / TCES_PER_PAGE;
-       sttpages = _ALIGN_UP(idx % TCES_PER_PAGE + npages, TCES_PER_PAGE) /
+       sttpages = ALIGN(idx % TCES_PER_PAGE + npages, TCES_PER_PAGE) /
                        TCES_PER_PAGE;
        for (i = sttpage; i < sttpage + sttpages; ++i)
                if (!stt->pages[i])
index a500979fbc59d140cc3f90a2ea946461a88999ef..0fbf3dc9f2c29292ea529d9230a3de1ed46b242f 100644 (file)
@@ -194,7 +194,7 @@ void __flush_hash_table_range(unsigned long start, unsigned long end)
        unsigned long flags;
 
        start = ALIGN_DOWN(start, PAGE_SIZE);
-       end = _ALIGN_UP(end, PAGE_SIZE);
+       end = ALIGN(end, PAGE_SIZE);
 
 
        /*
index dfb9fe92aea8c0c740f2b4d11cee668d06a4188f..408176086dd53c4b5a4b0b71ff8895675088836f 100644 (file)
@@ -261,7 +261,7 @@ static int __meminit create_physical_mapping(unsigned long start,
        pgprot_t prot;
        int psize;
 
-       start = _ALIGN_UP(start, PAGE_SIZE);
+       start = ALIGN(start, PAGE_SIZE);
        for (addr = start; addr < end; addr += mapping_size) {
                unsigned long gap, previous_size;
                int rc;
index dffe1a45b6ed4df131f8e18c6cbe851bd1b3fded..82b45b1cb9737bc5eca274383b064dc191540a4c 100644 (file)
@@ -478,7 +478,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
 
        /* If hint, make sure it matches our alignment restrictions */
        if (!fixed && addr) {
-               addr = _ALIGN_UP(addr, page_size);
+               addr = ALIGN(addr, page_size);
                slice_dbg(" aligned addr=%lx\n", addr);
                /* Ignore hint if it's too large or overlaps a VMA */
                if (addr > high_limit - len || addr < mmap_min_addr ||
index ca9ffc1c8685d17b9e6b50a37e882c7005313fb7..2124831cf57c081e7625be24fc25ea9c0e0ba286 100644 (file)
@@ -943,7 +943,7 @@ static int __init cell_iommu_fixed_mapping_init(void)
                fbase = max(fbase, dbase + dsize);
        }
 
-       fbase = _ALIGN_UP(fbase, 1 << IO_SEGMENT_SHIFT);
+       fbase = ALIGN(fbase, 1 << IO_SEGMENT_SHIFT);
        fsize = memblock_phys_mem_size();
 
        if ((fbase + fsize) <= 0x800000000ul)
@@ -963,8 +963,8 @@ static int __init cell_iommu_fixed_mapping_init(void)
                hend  = hbase + htab_size_bytes;
 
                /* The window must start and end on a segment boundary */
-               if ((hbase != _ALIGN_UP(hbase, 1 << IO_SEGMENT_SHIFT)) ||
-                   (hend != _ALIGN_UP(hend, 1 << IO_SEGMENT_SHIFT))) {
+               if ((hbase != ALIGN(hbase, 1 << IO_SEGMENT_SHIFT)) ||
+                   (hend != ALIGN(hend, 1 << IO_SEGMENT_SHIFT))) {
                        pr_debug("iommu: hash window not segment aligned\n");
                        return -1;
                }
index af309ee991143c17671b287b494bd2df6220ae38..c3374a90952f9dbd0823f525a74ee4d394186a5d 100644 (file)
@@ -108,7 +108,7 @@ static void * __init bootx_early_getprop(unsigned long base,
 
 #define dt_push_token(token, mem) \
        do { \
-               *(mem) = _ALIGN_UP(*(mem),4); \
+               *(mem) = ALIGN(*(mem),4); \
                *((u32 *)*(mem)) = token; \
                *(mem) += 4; \
        } while(0)
@@ -150,7 +150,7 @@ static void __init bootx_dt_add_prop(char *name, void *data, int size,
        /* push property content */
        if (size && data) {
                memcpy((void *)*mem_end, data, size);
-               *mem_end = _ALIGN_UP(*mem_end + size, 4);
+               *mem_end = ALIGN(*mem_end + size, 4);
        }
 }
 
@@ -303,7 +303,7 @@ static void __init bootx_scan_dt_build_struct(unsigned long base,
                        *lp++ = *p;
        }
        *lp = 0;
-       *mem_end = _ALIGN_UP((unsigned long)lp + 1, 4);
+       *mem_end = ALIGN((unsigned long)lp + 1, 4);
 
        /* get and store all properties */
        while (*ppp) {
@@ -356,11 +356,11 @@ static unsigned long __init bootx_flatten_dt(unsigned long start)
        /* Start using memory after the big blob passed by BootX, get
         * some space for the header
         */
-       mem_start = mem_end = _ALIGN_UP(((unsigned long)bi) + start, 4);
+       mem_start = mem_end = ALIGN(((unsigned long)bi) + start, 4);
        DBG("Boot params header at: %x\n", mem_start);
        hdr = (struct boot_param_header *)mem_start;
        mem_end += sizeof(struct boot_param_header);
-       rsvmap = (u64 *)(_ALIGN_UP(mem_end, 8));
+       rsvmap = (u64 *)(ALIGN(mem_end, 8));
        hdr->off_mem_rsvmap = ((unsigned long)rsvmap) - mem_start;
        mem_end = ((unsigned long)rsvmap) + 8 * sizeof(u64);
 
index 276b011cd45d2b0842eb74bd3b59ee639f5ad0c4..d1a16ebc31bb92d5e2c24eec834222b8999c6dc8 100644 (file)
@@ -265,7 +265,7 @@ static void pnv_ioda_reserve_dev_m64_pe(struct pci_dev *pdev,
                        continue;
 
                start = ALIGN_DOWN(r->start - base, sgsz);
-               end = _ALIGN_UP(r->end - base, sgsz);
+               end = ALIGN(r->end - base, sgsz);
                for (segno = start / sgsz; segno < end / sgsz; segno++) {
                        if (pe_bitmap)
                                set_bit(segno, pe_bitmap);
@@ -361,7 +361,7 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
                return NULL;
 
        /* Allocate bitmap */
-       size = _ALIGN_UP(phb->ioda.total_pe_num / 8, sizeof(unsigned long));
+       size = ALIGN(phb->ioda.total_pe_num / 8, sizeof(unsigned long));
        pe_alloc = kzalloc(size, GFP_KERNEL);
        if (!pe_alloc) {
                pr_warn("%s: Out of memory !\n",
@@ -2537,7 +2537,7 @@ unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
        direct_table_size =  1UL << table_shift;
 
        for ( ; levels; --levels) {
-               bytes += _ALIGN_UP(tce_table_size, direct_table_size);
+               bytes += ALIGN(tce_table_size, direct_table_size);
 
                tce_table_size /= direct_table_size;
                tce_table_size <<= 3;
@@ -3863,7 +3863,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
                                PNV_IODA1_DMA32_SEGSIZE;
 
        /* Allocate aux data & arrays. We don't have IO ports on PHB3 */
-       size = _ALIGN_UP(max_t(unsigned, phb->ioda.total_pe_num, 8) / 8,
+       size = ALIGN(max_t(unsigned, phb->ioda.total_pe_num, 8) / 8,
                        sizeof(unsigned long));
        m64map_off = size;
        size += phb->ioda.total_pe_num * sizeof(phb->ioda.m64_segmap[0]);
index 71ed37f7f475e7b4b78621be1867b32ccea99684..b83f2c851b400ed5a76080f65b6534540e4008f4 100644 (file)
@@ -395,7 +395,7 @@ static struct dma_chunk * dma_find_chunk(struct ps3_dma_region *r,
 {
        struct dma_chunk *c;
        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(len+bus_addr-aligned_bus,
                                              1 << r->page_size);
 
        list_for_each_entry(c, &r->chunk_list.head, link) {
@@ -424,7 +424,7 @@ static struct dma_chunk *dma_find_chunk_lpar(struct ps3_dma_region *r,
 {
        struct dma_chunk *c;
        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(len + lpar_addr - aligned_lpar,
                                              1 << r->page_size);
 
        list_for_each_entry(c, &r->chunk_list.head, link) {
@@ -776,7 +776,7 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
        unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
                : virt_addr;
        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(len + phys_addr - aligned_phys,
                                              1 << r->page_size);
        *bus_addr = dma_sb_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr));
 
@@ -831,7 +831,7 @@ static int dma_ioc0_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
        unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
                : virt_addr;
        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(len + phys_addr - aligned_phys,
                                              1 << r->page_size);
 
        DBG(KERN_ERR "%s: vaddr=%#lx, len=%#lx\n", __func__,
@@ -891,7 +891,7 @@ static int dma_sb_unmap_area(struct ps3_dma_region *r, dma_addr_t bus_addr,
        if (!c) {
                unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
                        1 << r->page_size);
-               unsigned long aligned_len = _ALIGN_UP(len + bus_addr
+               unsigned long aligned_len = ALIGN(len + bus_addr
                        - aligned_bus, 1 << r->page_size);
                DBG("%s:%d: not found: bus_addr %llxh\n",
                        __func__, __LINE__, bus_addr);
@@ -928,7 +928,7 @@ static int dma_ioc0_unmap_area(struct ps3_dma_region *r,
        if (!c) {
                unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
                                                        1 << r->page_size);
-               unsigned long aligned_len = _ALIGN_UP(len + bus_addr
+               unsigned long aligned_len = ALIGN(len + bus_addr
                                                      - aligned_bus,
                                                      1 << r->page_size);
                DBG("%s:%d: not found: bus_addr %llxh\n",
@@ -974,7 +974,7 @@ static int dma_sb_region_create_linear(struct ps3_dma_region *r)
                        pr_info("%s:%d: forcing 16M pages for linear map\n",
                                __func__, __LINE__);
                        r->page_size = PS3_DMA_16M;
-                       r->len = _ALIGN_UP(r->len, 1 << r->page_size);
+                       r->len = ALIGN(r->len, 1 << r->page_size);
                }
        }
 
@@ -1125,7 +1125,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
        r->offset = lpar_addr;
        if (r->offset >= map.rm.size)
                r->offset -= map.r1.offset;
-       r->len = len ? len : _ALIGN_UP(map.total, 1 << r->page_size);
+       r->len = len ? len : ALIGN(map.total, 1 << r->page_size);
 
        switch (dev->dev_type) {
        case PS3_DEVICE_TYPE_SB:
index b29368931c56db5c5ca98c65ffa8875e249b6f27..e9ae5dd03593e256cc5770312607332567132875 100644 (file)
@@ -138,7 +138,7 @@ static int __init early_parse_ps3fb(char *p)
        if (!p)
                return 1;
 
-       ps3fb_videomemory.size = _ALIGN_UP(memparse(p, &p),
+       ps3fb_videomemory.size = ALIGN(memparse(p, &p),
                                           ps3fb_videomemory.align);
        return 0;
 }