* [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN()
@ 2020-04-20 18:36 Christophe Leroy
2020-04-20 18:36 ` [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() Christophe Leroy
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Christophe Leroy @ 2020-04-20 18:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: alsa-devel, kvm, linux-kernel, dri-devel, linux-fbdev, linuxppc-dev
_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>
---
drivers/ps3/ps3-lpm.c | 6 +++---
drivers/vfio/pci/vfio_pci_nvlink2.c | 2 +-
drivers/video/fbdev/ps3fb.c | 4 ++--
sound/ppc/snd_ps3.c | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index 83c45659bc9d..064b5884ba13 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -1096,8 +1096,8 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
lpm_priv->tb_cache_internal = NULL;
lpm_priv->tb_cache = NULL;
} else if (tb_cache) {
- if (tb_cache != (void *)_ALIGN_UP((unsigned long)tb_cache, 128)
- || tb_cache_size != _ALIGN_UP(tb_cache_size, 128)) {
+ if (tb_cache != (void *)ALIGN((unsigned long)tb_cache, 128)
+ || tb_cache_size != ALIGN(tb_cache_size, 128)) {
dev_err(sbd_core(), "%s:%u: unaligned tb_cache\n",
__func__, __LINE__);
result = -EINVAL;
@@ -1116,7 +1116,7 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
result = -ENOMEM;
goto fail_malloc;
}
- lpm_priv->tb_cache = (void *)_ALIGN_UP(
+ lpm_priv->tb_cache = (void *)ALIGN(
(unsigned long)lpm_priv->tb_cache_internal, 128);
}
diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
index ed20d73cc27c..65c61710c0e9 100644
--- a/drivers/vfio/pci/vfio_pci_nvlink2.c
+++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
@@ -67,7 +67,7 @@ static size_t vfio_pci_nvgpu_rw(struct vfio_pci_device *vdev,
*
* This is not fast path anyway.
*/
- sizealigned = _ALIGN_UP(posoff + count, PAGE_SIZE);
+ sizealigned = ALIGN(posoff + count, PAGE_SIZE);
ptr = ioremap_cache(data->gpu_hpa + posaligned, sizealigned);
if (!ptr)
return -EFAULT;
diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
index 834f63edf700..9df78fb77267 100644
--- a/drivers/video/fbdev/ps3fb.c
+++ b/drivers/video/fbdev/ps3fb.c
@@ -44,7 +44,7 @@
#define GPU_CMD_BUF_SIZE (2 * 1024 * 1024)
#define GPU_FB_START (64 * 1024)
#define GPU_IOIF (0x0d000000UL)
-#define GPU_ALIGN_UP(x) _ALIGN_UP((x), 64)
+#define GPU_ALIGN_UP(x) ALIGN((x), 64)
#define GPU_MAX_LINE_LENGTH (65536 - 64)
#define GPU_INTR_STATUS_VSYNC_0 0 /* vsync on head A */
@@ -1015,7 +1015,7 @@ static int ps3fb_probe(struct ps3_system_bus_device *dev)
}
#endif
- max_ps3fb_size = _ALIGN_UP(GPU_IOIF, 256*1024*1024) - GPU_IOIF;
+ max_ps3fb_size = ALIGN(GPU_IOIF, 256*1024*1024) - GPU_IOIF;
if (ps3fb_videomemory.size > max_ps3fb_size) {
dev_info(&dev->core, "Limiting ps3fb mem size to %lu bytes\n",
max_ps3fb_size);
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
index 6d2a33b8faa0..b8161a08f2ca 100644
--- a/sound/ppc/snd_ps3.c
+++ b/sound/ppc/snd_ps3.c
@@ -926,7 +926,7 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
PAGE_SHIFT, /* use system page size */
0, /* dma type; not used */
NULL,
- _ALIGN_UP(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
+ ALIGN(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
dev->d_region->ioid = PS3_AUDIO_IOID;
ret = ps3_dma_region_create(dev->d_region);
--
2.25.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
@ 2020-04-20 18:36 ` Christophe Leroy
2020-04-21 1:04 ` Joel Stanley
2020-04-20 18:36 ` [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Christophe Leroy @ 2020-04-20 18:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: alsa-devel, kvm, linux-kernel, dri-devel, linux-fbdev, linuxppc-dev
_ALIGN_DOWN() is specific to powerpc
ALIGN_DOWN() is generic and does the same
Replace _ALIGN_DOWN() by ALIGN_DOWN()
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/book3s/32/pgtable.h | 2 +-
arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +-
arch/powerpc/kernel/pci_64.c | 2 +-
arch/powerpc/kernel/prom.c | 6 +++---
arch/powerpc/kernel/prom_init.c | 8 ++++----
arch/powerpc/mm/book3s64/hash_tlb.c | 4 ++--
arch/powerpc/mm/init_64.c | 4 ++--
arch/powerpc/platforms/powernv/opal-fadump.c | 2 +-
arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
arch/powerpc/platforms/ps3/mm.c | 14 +++++++-------
arch/powerpc/platforms/pseries/rtas-fadump.c | 2 +-
11 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 7549393c4c43..53b5c93eaf5d 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -195,7 +195,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
#endif
#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
#define VMALLOC_END ioremap_bot
#endif
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index b04ba257fddb..5b4d4c4297e1 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
@@ -116,7 +116,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
#endif
#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
#define VMALLOC_END ioremap_bot
#endif
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index f83d1f69b1dd..e5d05af5a9af 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -130,7 +130,7 @@ static int pcibios_map_phb_io_space(struct pci_controller *hose)
unsigned long size_page;
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);
/* Make sure IO area address is clear */
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 6620f37abe73..10b5d5eafd34 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -96,7 +96,7 @@ static inline int overlaps_initrd(unsigned long start, unsigned long size)
if (!initrd_start)
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);
#else
return 0;
@@ -623,9 +623,9 @@ static void __init early_reserve_mem(void)
#ifdef CONFIG_BLK_DEV_INITRD
/* Then reserve the initrd, if any */
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_DOWN(initrd_start, PAGE_SIZE));
+ ALIGN_DOWN(initrd_start, PAGE_SIZE));
}
#endif /* CONFIG_BLK_DEV_INITRD */
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 806be751c336..4cf5958eebd4 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1500,7 +1500,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
if (highmem) {
/* 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)
return 0;
/* 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,
goto bail;
}
- base = _ALIGN_DOWN(alloc_top - size, align);
+ base = ALIGN_DOWN(alloc_top - size, align);
for (; base > alloc_bottom;
- base = _ALIGN_DOWN(base - 0x100000, align)) {
+ base = ALIGN_DOWN(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)
@@ -1586,7 +1586,7 @@ static void __init reserve_mem(u64 base, u64 size)
* have our terminator with "size" set to 0 since we are
* 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);
size = top - base;
diff --git a/arch/powerpc/mm/book3s64/hash_tlb.c b/arch/powerpc/mm/book3s64/hash_tlb.c
index 4a70d8dd39cd..2242d022b620 100644
--- a/arch/powerpc/mm/book3s64/hash_tlb.c
+++ b/arch/powerpc/mm/book3s64/hash_tlb.c
@@ -196,7 +196,7 @@ void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
int hugepage_shift;
unsigned long flags;
- start = _ALIGN_DOWN(start, PAGE_SIZE);
+ start = ALIGN_DOWN(start, PAGE_SIZE);
end = _ALIGN_UP(end, PAGE_SIZE);
BUG_ON(!mm->pgd);
@@ -238,7 +238,7 @@ void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr)
pte_t *start_pte;
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
* PTE locked section. This violates the rule, but will work
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 4002ced3596f..c7ce4ec5060e 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -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;
/* 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);
@@ -292,7 +292,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end,
unsigned long alt_start = ~0, alt_end = ~0;
unsigned long base_pfn;
- start = _ALIGN_DOWN(start, page_size);
+ start = ALIGN_DOWN(start, page_size);
if (altmap) {
alt_start = altmap->base_pfn;
alt_end = altmap->base_pfn + altmap->reserve +
diff --git a/arch/powerpc/platforms/powernv/opal-fadump.c b/arch/powerpc/platforms/powernv/opal-fadump.c
index d361d37d975f..9a360ced663b 100644
--- a/arch/powerpc/platforms/powernv/opal-fadump.c
+++ b/arch/powerpc/platforms/powernv/opal-fadump.c
@@ -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
* 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.
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 57d3a6af1d52..276b011cd45d 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -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))
continue;
- start = _ALIGN_DOWN(r->start - base, sgsz);
+ start = ALIGN_DOWN(r->start - base, sgsz);
end = _ALIGN_UP(r->end - base, sgsz);
for (segno = start / sgsz; segno < end / sgsz; segno++) {
if (pe_bitmap)
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 423be34f0f5f..71ed37f7f475 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -263,7 +263,7 @@ static int ps3_mm_region_create(struct mem_region *r, unsigned long size)
int result;
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 actual %llxh\n", __func__, __LINE__, r->size);
@@ -394,7 +394,7 @@ static struct dma_chunk * dma_find_chunk(struct ps3_dma_region *r,
unsigned long bus_addr, unsigned long len)
{
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,
1 << r->page_size);
@@ -423,7 +423,7 @@ static struct dma_chunk *dma_find_chunk_lpar(struct ps3_dma_region *r,
unsigned long lpar_addr, unsigned long len)
{
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,
1 << r->page_size);
@@ -775,7 +775,7 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
struct dma_chunk *c;
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_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
1 << r->page_size);
*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,
struct dma_chunk *c;
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_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
1 << r->page_size);
@@ -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);
if (!c) {
- unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
+ unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + bus_addr
- aligned_bus, 1 << r->page_size);
@@ -926,7 +926,7 @@ static int dma_ioc0_unmap_area(struct ps3_dma_region *r,
c = dma_find_chunk(r, bus_addr, len);
if (!c) {
- unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
+ unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
1 << r->page_size);
unsigned long aligned_len = _ALIGN_UP(len + bus_addr
- aligned_bus,
diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
index 70c3013fdd07..81343908ed33 100644
--- a/arch/powerpc/platforms/pseries/rtas-fadump.c
+++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
@@ -506,7 +506,7 @@ void __init rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node)
fadump_conf->fadump_supported = 1;
/* 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
--
2.25.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN()
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
2020-04-20 18:36 ` [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() Christophe Leroy
@ 2020-04-20 18:36 ` Christophe Leroy
2020-04-21 1:04 ` Joel Stanley
2020-04-20 18:36 ` [PATCH 4/5] powerpc: Replace _ALIGN() " Christophe Leroy
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Christophe Leroy @ 2020-04-20 18:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: alsa-devel, kvm, linux-kernel, dri-devel, linux-fbdev, linuxppc-dev
_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>
---
arch/powerpc/include/asm/iommu.h | 4 ++--
arch/powerpc/kernel/head_booke.h | 2 +-
arch/powerpc/kernel/nvram_64.c | 4 ++--
arch/powerpc/kernel/pci_64.c | 2 +-
arch/powerpc/kernel/prom.c | 4 ++--
arch/powerpc/kernel/prom_init.c | 8 ++++----
arch/powerpc/kvm/book3s_64_vio_hv.c | 2 +-
arch/powerpc/mm/book3s64/hash_tlb.c | 2 +-
arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +-
arch/powerpc/mm/slice.c | 2 +-
arch/powerpc/platforms/cell/iommu.c | 6 +++---
arch/powerpc/platforms/powermac/bootx_init.c | 10 +++++-----
arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++----
arch/powerpc/platforms/ps3/mm.c | 16 ++++++++--------
arch/powerpc/platforms/ps3/setup.c | 2 +-
15 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 350101e11ddb..5032f1593299 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -22,11 +22,11 @@
#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;
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index bd2e5ed8dd50..18f87bf9e32b 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -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__ */
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index fb4f61096613..314780e8ef78 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -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
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index e5d05af5a9af..ff8e3fbdf663 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -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;
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 10b5d5eafd34..1dcf0e214a22 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -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 */
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 4cf5958eebd4..3a5a7db4564f 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -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))
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 6fcaf1fa8e02..2d231eb5884a 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -208,7 +208,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])
diff --git a/arch/powerpc/mm/book3s64/hash_tlb.c b/arch/powerpc/mm/book3s64/hash_tlb.c
index 2242d022b620..081940b85e24 100644
--- a/arch/powerpc/mm/book3s64/hash_tlb.c
+++ b/arch/powerpc/mm/book3s64/hash_tlb.c
@@ -197,7 +197,7 @@ void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
unsigned long flags;
start = ALIGN_DOWN(start, PAGE_SIZE);
- end = _ALIGN_UP(end, PAGE_SIZE);
+ end = ALIGN(end, PAGE_SIZE);
BUG_ON(!mm->pgd);
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 8f9edf07063a..4bdfc8dff87d 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -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;
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index dffe1a45b6ed..82b45b1cb973 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -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 ||
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index ca9ffc1c8685..2124831cf57c 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -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;
}
diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
index af309ee99114..c3374a90952f 100644
--- a/arch/powerpc/platforms/powermac/bootx_init.c
+++ b/arch/powerpc/platforms/powermac/bootx_init.c
@@ -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);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 276b011cd45d..d1a16ebc31bb 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -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]);
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 71ed37f7f475..b83f2c851b40 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -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:
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
index b29368931c56..e9ae5dd03593 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -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;
}
--
2.25.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/5] powerpc: Replace _ALIGN() by ALIGN()
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
2020-04-20 18:36 ` [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() Christophe Leroy
2020-04-20 18:36 ` [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
@ 2020-04-20 18:36 ` Christophe Leroy
2020-04-21 1:11 ` Joel Stanley
2020-04-20 18:36 ` [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN() Christophe Leroy
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Christophe Leroy @ 2020-04-20 18:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: alsa-devel, kvm, linux-kernel, dri-devel, linux-fbdev, linuxppc-dev
_ALIGN() is specific to powerpc
ALIGN() is generic and does the same
Replace _ALIGN() by ALIGN()
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/book3s/32/pgtable.h | 2 +-
arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +-
arch/powerpc/kernel/prom_init.c | 8 ++++----
arch/powerpc/platforms/powermac/bootx_init.c | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 53b5c93eaf5d..0d4bccb4b9f2 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -188,7 +188,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
* memory shall not share segments.
*/
#if defined(CONFIG_STRICT_KERNEL_RWX) && defined(CONFIG_MODULES)
-#define VMALLOC_START ((_ALIGN((long)high_memory, 256L << 20) + VMALLOC_OFFSET) & \
+#define VMALLOC_START ((ALIGN((long)high_memory, 256L << 20) + VMALLOC_OFFSET) & \
~(VMALLOC_OFFSET - 1))
#else
#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 5b4d4c4297e1..4315d40906a0 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
@@ -110,7 +110,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
*/
#define VMALLOC_OFFSET (0x1000000) /* 16M */
#ifdef PPC_PIN_SIZE
-#define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
+#define VMALLOC_START (((ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
#else
#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
#endif
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 3a5a7db4564f..e3a9fde51c4f 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2426,7 +2426,7 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
{
void *ret;
- *mem_start = _ALIGN(*mem_start, align);
+ *mem_start = ALIGN(*mem_start, align);
while ((*mem_start + needed) > *mem_end) {
unsigned long room, chunk;
@@ -2562,7 +2562,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
*lp++ = *p;
}
*lp = 0;
- *mem_start = _ALIGN((unsigned long)lp + 1, 4);
+ *mem_start = ALIGN((unsigned long)lp + 1, 4);
}
/* get it again for debugging */
@@ -2608,7 +2608,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
/* push property content */
valp = make_room(mem_start, mem_end, l, 4);
call_prom("getprop", 4, 1, node, pname, valp, l);
- *mem_start = _ALIGN(*mem_start, 4);
+ *mem_start = ALIGN(*mem_start, 4);
if (!prom_strcmp(pname, "phandle"))
has_phandle = 1;
@@ -2667,7 +2667,7 @@ static void __init flatten_device_tree(void)
prom_panic ("couldn't get device tree root\n");
/* Build header and make room for mem rsv map */
- mem_start = _ALIGN(mem_start, 4);
+ mem_start = ALIGN(mem_start, 4);
hdr = make_room(&mem_start, &mem_end,
sizeof(struct boot_param_header), 4);
dt_header_start = (unsigned long)hdr;
diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
index c3374a90952f..9d4ecd292255 100644
--- a/arch/powerpc/platforms/powermac/bootx_init.c
+++ b/arch/powerpc/platforms/powermac/bootx_init.c
@@ -386,7 +386,7 @@ static unsigned long __init bootx_flatten_dt(unsigned long start)
hdr->dt_strings_size = bootx_dt_strend - bootx_dt_strbase;
/* Build structure */
- mem_end = _ALIGN(mem_end, 16);
+ mem_end = ALIGN(mem_end, 16);
DBG("Building device tree structure at: %x\n", mem_end);
hdr->off_dt_struct = mem_end - mem_start;
bootx_scan_dt_build_struct(base, 4, &mem_end);
@@ -404,7 +404,7 @@ static unsigned long __init bootx_flatten_dt(unsigned long start)
* also bump mem_reserve_cnt to cause further reservations to
* fail since it's too late.
*/
- mem_end = _ALIGN(mem_end, PAGE_SIZE);
+ mem_end = ALIGN(mem_end, PAGE_SIZE);
DBG("End of boot params: %x\n", mem_end);
rsvmap[0] = mem_start;
rsvmap[1] = mem_end;
--
2.25.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN()
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
` (2 preceding siblings ...)
2020-04-20 18:36 ` [PATCH 4/5] powerpc: Replace _ALIGN() " Christophe Leroy
@ 2020-04-20 18:36 ` Christophe Leroy
2020-04-21 1:04 ` Joel Stanley
2020-04-21 0:49 ` [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Joel Stanley
2020-05-20 10:59 ` Michael Ellerman
5 siblings, 1 reply; 12+ messages in thread
From: Christophe Leroy @ 2020-04-20 18:36 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: alsa-devel, kvm, linux-kernel, dri-devel, linux-fbdev, linuxppc-dev
These three powerpc macros have been replaced by
equivalent generic macros and are not used anymore.
Remove them.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/page.h | 7 -------
1 file changed, 7 deletions(-)
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 3ee8df0f66e0..a63fe6f3a0ff 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -249,13 +249,6 @@ static inline bool pfn_valid(unsigned long pfn)
#include <asm/page_32.h>
#endif
-/* align addr on a size boundary - adjust address up/down if needed */
-#define _ALIGN_UP(addr, size) __ALIGN_KERNEL(addr, size)
-#define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1)))
-
-/* align addr on a size boundary - adjust address up if needed */
-#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
-
/*
* Don't compare things with KERNELBASE or PAGE_OFFSET to test for
* "kernelness", use is_kernel_addr() - it should do what you want.
--
2.25.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN()
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
` (3 preceding siblings ...)
2020-04-20 18:36 ` [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN() Christophe Leroy
@ 2020-04-21 0:49 ` Joel Stanley
2020-05-20 10:59 ` Michael Ellerman
5 siblings, 0 replies; 12+ messages in thread
From: Joel Stanley @ 2020-04-21 0:49 UTC (permalink / raw)
To: Christophe Leroy
Cc: alsa-devel, kvm, Benjamin Herrenschmidt,
Linux Kernel Mailing List, dri-devel, Paul Mackerras,
linux-fbdev, Michael Ellerman, linuxppc-dev
On Mon, 20 Apr 2020 at 18:37, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>
> _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>
I was curious, so I expanded out the kernel one. Here's the diff:
- (((addr)+((size)-1))&(~((typeof(addr))(size)-1)))
+ (((addr)+((typeof(addr))(size) - 1))&~((typeof(addr))(size)-1))
So it adds a cast, but aside from that it's the same.
Reviewed-by: Joel Stanley <joel@jms.id.au>
> ---
> drivers/ps3/ps3-lpm.c | 6 +++---
> drivers/vfio/pci/vfio_pci_nvlink2.c | 2 +-
> drivers/video/fbdev/ps3fb.c | 4 ++--
> sound/ppc/snd_ps3.c | 2 +-
> 4 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
> index 83c45659bc9d..064b5884ba13 100644
> --- a/drivers/ps3/ps3-lpm.c
> +++ b/drivers/ps3/ps3-lpm.c
> @@ -1096,8 +1096,8 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
> lpm_priv->tb_cache_internal = NULL;
> lpm_priv->tb_cache = NULL;
> } else if (tb_cache) {
> - if (tb_cache != (void *)_ALIGN_UP((unsigned long)tb_cache, 128)
> - || tb_cache_size != _ALIGN_UP(tb_cache_size, 128)) {
> + if (tb_cache != (void *)ALIGN((unsigned long)tb_cache, 128)
> + || tb_cache_size != ALIGN(tb_cache_size, 128)) {
> dev_err(sbd_core(), "%s:%u: unaligned tb_cache\n",
> __func__, __LINE__);
> result = -EINVAL;
> @@ -1116,7 +1116,7 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
> result = -ENOMEM;
> goto fail_malloc;
> }
> - lpm_priv->tb_cache = (void *)_ALIGN_UP(
> + lpm_priv->tb_cache = (void *)ALIGN(
> (unsigned long)lpm_priv->tb_cache_internal, 128);
> }
>
> diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> index ed20d73cc27c..65c61710c0e9 100644
> --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> @@ -67,7 +67,7 @@ static size_t vfio_pci_nvgpu_rw(struct vfio_pci_device *vdev,
> *
> * This is not fast path anyway.
> */
> - sizealigned = _ALIGN_UP(posoff + count, PAGE_SIZE);
> + sizealigned = ALIGN(posoff + count, PAGE_SIZE);
> ptr = ioremap_cache(data->gpu_hpa + posaligned, sizealigned);
> if (!ptr)
> return -EFAULT;
> diff --git a/drivers/video/fbdev/ps3fb.c b/drivers/video/fbdev/ps3fb.c
> index 834f63edf700..9df78fb77267 100644
> --- a/drivers/video/fbdev/ps3fb.c
> +++ b/drivers/video/fbdev/ps3fb.c
> @@ -44,7 +44,7 @@
> #define GPU_CMD_BUF_SIZE (2 * 1024 * 1024)
> #define GPU_FB_START (64 * 1024)
> #define GPU_IOIF (0x0d000000UL)
> -#define GPU_ALIGN_UP(x) _ALIGN_UP((x), 64)
> +#define GPU_ALIGN_UP(x) ALIGN((x), 64)
> #define GPU_MAX_LINE_LENGTH (65536 - 64)
>
> #define GPU_INTR_STATUS_VSYNC_0 0 /* vsync on head A */
> @@ -1015,7 +1015,7 @@ static int ps3fb_probe(struct ps3_system_bus_device *dev)
> }
> #endif
>
> - max_ps3fb_size = _ALIGN_UP(GPU_IOIF, 256*1024*1024) - GPU_IOIF;
> + max_ps3fb_size = ALIGN(GPU_IOIF, 256*1024*1024) - GPU_IOIF;
> if (ps3fb_videomemory.size > max_ps3fb_size) {
> dev_info(&dev->core, "Limiting ps3fb mem size to %lu bytes\n",
> max_ps3fb_size);
> diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
> index 6d2a33b8faa0..b8161a08f2ca 100644
> --- a/sound/ppc/snd_ps3.c
> +++ b/sound/ppc/snd_ps3.c
> @@ -926,7 +926,7 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
> PAGE_SHIFT, /* use system page size */
> 0, /* dma type; not used */
> NULL,
> - _ALIGN_UP(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
> + ALIGN(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
> dev->d_region->ioid = PS3_AUDIO_IOID;
>
> ret = ps3_dma_region_create(dev->d_region);
> --
> 2.25.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
2020-04-20 18:36 ` [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() Christophe Leroy
@ 2020-04-21 1:04 ` Joel Stanley
2020-04-21 15:55 ` Segher Boessenkool
0 siblings, 1 reply; 12+ messages in thread
From: Joel Stanley @ 2020-04-21 1:04 UTC (permalink / raw)
To: Christophe Leroy
Cc: linux-fbdev, kvm, Benjamin Herrenschmidt,
Linux Kernel Mailing List, dri-devel, Paul Mackerras,
Michael Ellerman, alsa-devel, linuxppc-dev
On Mon, 20 Apr 2020 at 18:38, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>
> _ALIGN_DOWN() is specific to powerpc
> ALIGN_DOWN() is generic and does the same
>
> Replace _ALIGN_DOWN() by ALIGN_DOWN()
This one is a bit less obvious. It becomes (leaving the typeof's alone
for clarity):
-((addr)&(~((typeof(addr))(size)-1)))
+((((addr) - ((size) - 1)) + ((typeof(addr))(size) - 1)) &
~((typeof(addr))(size)-1))
Which I assume the compiler will sort out?
Reviewed-by: Joel Stanley <joel@jms.id.au>
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/include/asm/book3s/32/pgtable.h | 2 +-
> arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +-
> arch/powerpc/kernel/pci_64.c | 2 +-
> arch/powerpc/kernel/prom.c | 6 +++---
> arch/powerpc/kernel/prom_init.c | 8 ++++----
> arch/powerpc/mm/book3s64/hash_tlb.c | 4 ++--
> arch/powerpc/mm/init_64.c | 4 ++--
> arch/powerpc/platforms/powernv/opal-fadump.c | 2 +-
> arch/powerpc/platforms/powernv/pci-ioda.c | 2 +-
> arch/powerpc/platforms/ps3/mm.c | 14 +++++++-------
> arch/powerpc/platforms/pseries/rtas-fadump.c | 2 +-
> 11 files changed, 24 insertions(+), 24 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
> index 7549393c4c43..53b5c93eaf5d 100644
> --- a/arch/powerpc/include/asm/book3s/32/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
> @@ -195,7 +195,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
> #endif
>
> #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
> #define VMALLOC_END ioremap_bot
> #endif
> diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
> index b04ba257fddb..5b4d4c4297e1 100644
> --- a/arch/powerpc/include/asm/nohash/32/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
> @@ -116,7 +116,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
> #endif
>
> #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
> #define VMALLOC_END ioremap_bot
> #endif
> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index f83d1f69b1dd..e5d05af5a9af 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -130,7 +130,7 @@ static int pcibios_map_phb_io_space(struct pci_controller *hose)
> unsigned long size_page;
> 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);
>
> /* Make sure IO area address is clear */
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 6620f37abe73..10b5d5eafd34 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -96,7 +96,7 @@ static inline int overlaps_initrd(unsigned long start, unsigned long size)
> if (!initrd_start)
> 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);
> #else
> return 0;
> @@ -623,9 +623,9 @@ static void __init early_reserve_mem(void)
> #ifdef CONFIG_BLK_DEV_INITRD
> /* Then reserve the initrd, if any */
> 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_DOWN(initrd_start, PAGE_SIZE));
> + ALIGN_DOWN(initrd_start, PAGE_SIZE));
> }
> #endif /* CONFIG_BLK_DEV_INITRD */
>
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index 806be751c336..4cf5958eebd4 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -1500,7 +1500,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
>
> if (highmem) {
> /* 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)
> return 0;
> /* 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,
> goto bail;
> }
>
> - base = _ALIGN_DOWN(alloc_top - size, align);
> + base = ALIGN_DOWN(alloc_top - size, align);
> for (; base > alloc_bottom;
> - base = _ALIGN_DOWN(base - 0x100000, align)) {
> + base = ALIGN_DOWN(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)
> @@ -1586,7 +1586,7 @@ static void __init reserve_mem(u64 base, u64 size)
> * have our terminator with "size" set to 0 since we are
> * 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);
> size = top - base;
>
> diff --git a/arch/powerpc/mm/book3s64/hash_tlb.c b/arch/powerpc/mm/book3s64/hash_tlb.c
> index 4a70d8dd39cd..2242d022b620 100644
> --- a/arch/powerpc/mm/book3s64/hash_tlb.c
> +++ b/arch/powerpc/mm/book3s64/hash_tlb.c
> @@ -196,7 +196,7 @@ void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
> int hugepage_shift;
> unsigned long flags;
>
> - start = _ALIGN_DOWN(start, PAGE_SIZE);
> + start = ALIGN_DOWN(start, PAGE_SIZE);
> end = _ALIGN_UP(end, PAGE_SIZE);
>
> BUG_ON(!mm->pgd);
> @@ -238,7 +238,7 @@ void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd, unsigned long addr)
> pte_t *start_pte;
> 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
> * PTE locked section. This violates the rule, but will work
> diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
> index 4002ced3596f..c7ce4ec5060e 100644
> --- a/arch/powerpc/mm/init_64.c
> +++ b/arch/powerpc/mm/init_64.c
> @@ -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;
>
> /* 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);
>
> @@ -292,7 +292,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end,
> unsigned long alt_start = ~0, alt_end = ~0;
> unsigned long base_pfn;
>
> - start = _ALIGN_DOWN(start, page_size);
> + start = ALIGN_DOWN(start, page_size);
> if (altmap) {
> alt_start = altmap->base_pfn;
> alt_end = altmap->base_pfn + altmap->reserve +
> diff --git a/arch/powerpc/platforms/powernv/opal-fadump.c b/arch/powerpc/platforms/powernv/opal-fadump.c
> index d361d37d975f..9a360ced663b 100644
> --- a/arch/powerpc/platforms/powernv/opal-fadump.c
> +++ b/arch/powerpc/platforms/powernv/opal-fadump.c
> @@ -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
> * 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.
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 57d3a6af1d52..276b011cd45d 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -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))
> continue;
>
> - start = _ALIGN_DOWN(r->start - base, sgsz);
> + start = ALIGN_DOWN(r->start - base, sgsz);
> end = _ALIGN_UP(r->end - base, sgsz);
> for (segno = start / sgsz; segno < end / sgsz; segno++) {
> if (pe_bitmap)
> diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
> index 423be34f0f5f..71ed37f7f475 100644
> --- a/arch/powerpc/platforms/ps3/mm.c
> +++ b/arch/powerpc/platforms/ps3/mm.c
> @@ -263,7 +263,7 @@ static int ps3_mm_region_create(struct mem_region *r, unsigned long size)
> int result;
> 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 actual %llxh\n", __func__, __LINE__, r->size);
> @@ -394,7 +394,7 @@ static struct dma_chunk * dma_find_chunk(struct ps3_dma_region *r,
> unsigned long bus_addr, unsigned long len)
> {
> 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,
> 1 << r->page_size);
>
> @@ -423,7 +423,7 @@ static struct dma_chunk *dma_find_chunk_lpar(struct ps3_dma_region *r,
> unsigned long lpar_addr, unsigned long len)
> {
> 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,
> 1 << r->page_size);
>
> @@ -775,7 +775,7 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
> struct dma_chunk *c;
> 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_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
> unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
> 1 << r->page_size);
> *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,
> struct dma_chunk *c;
> 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_phys = ALIGN_DOWN(phys_addr, 1 << r->page_size);
> unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
> 1 << r->page_size);
>
> @@ -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);
>
> if (!c) {
> - unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
> + unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
> 1 << r->page_size);
> unsigned long aligned_len = _ALIGN_UP(len + bus_addr
> - aligned_bus, 1 << r->page_size);
> @@ -926,7 +926,7 @@ static int dma_ioc0_unmap_area(struct ps3_dma_region *r,
> c = dma_find_chunk(r, bus_addr, len);
>
> if (!c) {
> - unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
> + unsigned long aligned_bus = ALIGN_DOWN(bus_addr,
> 1 << r->page_size);
> unsigned long aligned_len = _ALIGN_UP(len + bus_addr
> - aligned_bus,
> diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
> index 70c3013fdd07..81343908ed33 100644
> --- a/arch/powerpc/platforms/pseries/rtas-fadump.c
> +++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
> @@ -506,7 +506,7 @@ void __init rtas_fadump_dt_scan(struct fw_dump *fadump_conf, u64 node)
> fadump_conf->fadump_supported = 1;
>
> /* 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
> --
> 2.25.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN()
2020-04-20 18:36 ` [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
@ 2020-04-21 1:04 ` Joel Stanley
0 siblings, 0 replies; 12+ messages in thread
From: Joel Stanley @ 2020-04-21 1:04 UTC (permalink / raw)
To: Christophe Leroy
Cc: linux-fbdev, kvm, Benjamin Herrenschmidt,
Linux Kernel Mailing List, dri-devel, Paul Mackerras,
Michael Ellerman, alsa-devel, linuxppc-dev
On Mon, 20 Apr 2020 at 18:39, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>
> _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>
Reviewed-by: Joel Stanley <joel@jms.id.au>
> ---
> arch/powerpc/include/asm/iommu.h | 4 ++--
> arch/powerpc/kernel/head_booke.h | 2 +-
> arch/powerpc/kernel/nvram_64.c | 4 ++--
> arch/powerpc/kernel/pci_64.c | 2 +-
> arch/powerpc/kernel/prom.c | 4 ++--
> arch/powerpc/kernel/prom_init.c | 8 ++++----
> arch/powerpc/kvm/book3s_64_vio_hv.c | 2 +-
> arch/powerpc/mm/book3s64/hash_tlb.c | 2 +-
> arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +-
> arch/powerpc/mm/slice.c | 2 +-
> arch/powerpc/platforms/cell/iommu.c | 6 +++---
> arch/powerpc/platforms/powermac/bootx_init.c | 10 +++++-----
> arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++----
> arch/powerpc/platforms/ps3/mm.c | 16 ++++++++--------
> arch/powerpc/platforms/ps3/setup.c | 2 +-
> 15 files changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
> index 350101e11ddb..5032f1593299 100644
> --- a/arch/powerpc/include/asm/iommu.h
> +++ b/arch/powerpc/include/asm/iommu.h
> @@ -22,11 +22,11 @@
> #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;
> diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
> index bd2e5ed8dd50..18f87bf9e32b 100644
> --- a/arch/powerpc/kernel/head_booke.h
> +++ b/arch/powerpc/kernel/head_booke.h
> @@ -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__ */
> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
> index fb4f61096613..314780e8ef78 100644
> --- a/arch/powerpc/kernel/nvram_64.c
> +++ b/arch/powerpc/kernel/nvram_64.c
> @@ -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
> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index e5d05af5a9af..ff8e3fbdf663 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -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;
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 10b5d5eafd34..1dcf0e214a22 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -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 */
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index 4cf5958eebd4..3a5a7db4564f 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -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))
> diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
> index 6fcaf1fa8e02..2d231eb5884a 100644
> --- a/arch/powerpc/kvm/book3s_64_vio_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
> @@ -208,7 +208,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])
> diff --git a/arch/powerpc/mm/book3s64/hash_tlb.c b/arch/powerpc/mm/book3s64/hash_tlb.c
> index 2242d022b620..081940b85e24 100644
> --- a/arch/powerpc/mm/book3s64/hash_tlb.c
> +++ b/arch/powerpc/mm/book3s64/hash_tlb.c
> @@ -197,7 +197,7 @@ void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
> unsigned long flags;
>
> start = ALIGN_DOWN(start, PAGE_SIZE);
> - end = _ALIGN_UP(end, PAGE_SIZE);
> + end = ALIGN(end, PAGE_SIZE);
>
> BUG_ON(!mm->pgd);
>
> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
> index 8f9edf07063a..4bdfc8dff87d 100644
> --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
> +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
> @@ -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;
> diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
> index dffe1a45b6ed..82b45b1cb973 100644
> --- a/arch/powerpc/mm/slice.c
> +++ b/arch/powerpc/mm/slice.c
> @@ -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 ||
> diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
> index ca9ffc1c8685..2124831cf57c 100644
> --- a/arch/powerpc/platforms/cell/iommu.c
> +++ b/arch/powerpc/platforms/cell/iommu.c
> @@ -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;
> }
> diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
> index af309ee99114..c3374a90952f 100644
> --- a/arch/powerpc/platforms/powermac/bootx_init.c
> +++ b/arch/powerpc/platforms/powermac/bootx_init.c
> @@ -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);
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 276b011cd45d..d1a16ebc31bb 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -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]);
> diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
> index 71ed37f7f475..b83f2c851b40 100644
> --- a/arch/powerpc/platforms/ps3/mm.c
> +++ b/arch/powerpc/platforms/ps3/mm.c
> @@ -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:
> diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
> index b29368931c56..e9ae5dd03593 100644
> --- a/arch/powerpc/platforms/ps3/setup.c
> +++ b/arch/powerpc/platforms/ps3/setup.c
> @@ -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;
> }
> --
> 2.25.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN()
2020-04-20 18:36 ` [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN() Christophe Leroy
@ 2020-04-21 1:04 ` Joel Stanley
0 siblings, 0 replies; 12+ messages in thread
From: Joel Stanley @ 2020-04-21 1:04 UTC (permalink / raw)
To: Christophe Leroy
Cc: linux-fbdev, kvm, Benjamin Herrenschmidt,
Linux Kernel Mailing List, dri-devel, Paul Mackerras,
Michael Ellerman, alsa-devel, linuxppc-dev
On Mon, 20 Apr 2020 at 18:39, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>
> These three powerpc macros have been replaced by
> equivalent generic macros and are not used anymore.
>
> Remove them.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-By: Joel Stanley <joel@jms.id.au>
riscv has a copy of these too that could probably be removed:
arch/riscv/include/asm/page.h:#define _ALIGN_UP(addr, size)
(((addr)+((size)-1))&(~((size)-1)))
arch/riscv/include/asm/page.h:#define _ALIGN(addr, size)
_ALIGN_UP(addr, size)
> ---
> arch/powerpc/include/asm/page.h | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index 3ee8df0f66e0..a63fe6f3a0ff 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -249,13 +249,6 @@ static inline bool pfn_valid(unsigned long pfn)
> #include <asm/page_32.h>
> #endif
>
> -/* align addr on a size boundary - adjust address up/down if needed */
> -#define _ALIGN_UP(addr, size) __ALIGN_KERNEL(addr, size)
> -#define _ALIGN_DOWN(addr, size) ((addr)&(~((typeof(addr))(size)-1)))
> -
> -/* align addr on a size boundary - adjust address up if needed */
> -#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
> -
> /*
> * Don't compare things with KERNELBASE or PAGE_OFFSET to test for
> * "kernelness", use is_kernel_addr() - it should do what you want.
> --
> 2.25.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/5] powerpc: Replace _ALIGN() by ALIGN()
2020-04-20 18:36 ` [PATCH 4/5] powerpc: Replace _ALIGN() " Christophe Leroy
@ 2020-04-21 1:11 ` Joel Stanley
0 siblings, 0 replies; 12+ messages in thread
From: Joel Stanley @ 2020-04-21 1:11 UTC (permalink / raw)
To: Christophe Leroy
Cc: linux-fbdev, kvm, Benjamin Herrenschmidt,
Linux Kernel Mailing List, dri-devel, Paul Mackerras,
Michael Ellerman, alsa-devel, linuxppc-dev
On Mon, 20 Apr 2020 at 18:39, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>
> _ALIGN() is specific to powerpc
> ALIGN() is generic and does the same
>
> Replace _ALIGN() by ALIGN()
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Joel Stanley <joel@jms.id.au>
> ---
> arch/powerpc/include/asm/book3s/32/pgtable.h | 2 +-
> arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +-
> arch/powerpc/kernel/prom_init.c | 8 ++++----
> arch/powerpc/platforms/powermac/bootx_init.c | 4 ++--
> 4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
> index 53b5c93eaf5d..0d4bccb4b9f2 100644
> --- a/arch/powerpc/include/asm/book3s/32/pgtable.h
> +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
> @@ -188,7 +188,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
> * memory shall not share segments.
> */
> #if defined(CONFIG_STRICT_KERNEL_RWX) && defined(CONFIG_MODULES)
> -#define VMALLOC_START ((_ALIGN((long)high_memory, 256L << 20) + VMALLOC_OFFSET) & \
> +#define VMALLOC_START ((ALIGN((long)high_memory, 256L << 20) + VMALLOC_OFFSET) & \
> ~(VMALLOC_OFFSET - 1))
> #else
> #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
> diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
> index 5b4d4c4297e1..4315d40906a0 100644
> --- a/arch/powerpc/include/asm/nohash/32/pgtable.h
> +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
> @@ -110,7 +110,7 @@ int map_kernel_page(unsigned long va, phys_addr_t pa, pgprot_t prot);
> */
> #define VMALLOC_OFFSET (0x1000000) /* 16M */
> #ifdef PPC_PIN_SIZE
> -#define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
> +#define VMALLOC_START (((ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
Perhaps this once needed to be more flexiable, but now it always
aligns to 256M and then to 16MB.
> #else
> #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
This is an open coded align to VMALLOC_OFFSET.
> #endif
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index 3a5a7db4564f..e3a9fde51c4f 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -2426,7 +2426,7 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
> {
> void *ret;
>
> - *mem_start = _ALIGN(*mem_start, align);
> + *mem_start = ALIGN(*mem_start, align);
> while ((*mem_start + needed) > *mem_end) {
> unsigned long room, chunk;
>
> @@ -2562,7 +2562,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
> *lp++ = *p;
> }
> *lp = 0;
> - *mem_start = _ALIGN((unsigned long)lp + 1, 4);
> + *mem_start = ALIGN((unsigned long)lp + 1, 4);
> }
>
> /* get it again for debugging */
> @@ -2608,7 +2608,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
> /* push property content */
> valp = make_room(mem_start, mem_end, l, 4);
> call_prom("getprop", 4, 1, node, pname, valp, l);
> - *mem_start = _ALIGN(*mem_start, 4);
> + *mem_start = ALIGN(*mem_start, 4);
>
> if (!prom_strcmp(pname, "phandle"))
> has_phandle = 1;
> @@ -2667,7 +2667,7 @@ static void __init flatten_device_tree(void)
> prom_panic ("couldn't get device tree root\n");
>
> /* Build header and make room for mem rsv map */
> - mem_start = _ALIGN(mem_start, 4);
> + mem_start = ALIGN(mem_start, 4);
> hdr = make_room(&mem_start, &mem_end,
> sizeof(struct boot_param_header), 4);
> dt_header_start = (unsigned long)hdr;
> diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
> index c3374a90952f..9d4ecd292255 100644
> --- a/arch/powerpc/platforms/powermac/bootx_init.c
> +++ b/arch/powerpc/platforms/powermac/bootx_init.c
> @@ -386,7 +386,7 @@ static unsigned long __init bootx_flatten_dt(unsigned long start)
> hdr->dt_strings_size = bootx_dt_strend - bootx_dt_strbase;
>
> /* Build structure */
> - mem_end = _ALIGN(mem_end, 16);
> + mem_end = ALIGN(mem_end, 16);
> DBG("Building device tree structure at: %x\n", mem_end);
> hdr->off_dt_struct = mem_end - mem_start;
> bootx_scan_dt_build_struct(base, 4, &mem_end);
> @@ -404,7 +404,7 @@ static unsigned long __init bootx_flatten_dt(unsigned long start)
> * also bump mem_reserve_cnt to cause further reservations to
> * fail since it's too late.
> */
> - mem_end = _ALIGN(mem_end, PAGE_SIZE);
> + mem_end = ALIGN(mem_end, PAGE_SIZE);
> DBG("End of boot params: %x\n", mem_end);
> rsvmap[0] = mem_start;
> rsvmap[1] = mem_end;
> --
> 2.25.0
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
2020-04-21 1:04 ` Joel Stanley
@ 2020-04-21 15:55 ` Segher Boessenkool
0 siblings, 0 replies; 12+ messages in thread
From: Segher Boessenkool @ 2020-04-21 15:55 UTC (permalink / raw)
To: Joel Stanley
Cc: Christophe Leroy, linux-fbdev, kvm, Linux Kernel Mailing List,
dri-devel, Paul Mackerras, alsa-devel, linuxppc-dev
Hi!
On Tue, Apr 21, 2020 at 01:04:05AM +0000, Joel Stanley wrote:
> On Mon, 20 Apr 2020 at 18:38, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > _ALIGN_DOWN() is specific to powerpc
> > ALIGN_DOWN() is generic and does the same
> >
> > Replace _ALIGN_DOWN() by ALIGN_DOWN()
>
> This one is a bit less obvious. It becomes (leaving the typeof's alone
> for clarity):
>
> -((addr)&(~((typeof(addr))(size)-1)))
> +((((addr) - ((size) - 1)) + ((typeof(addr))(size) - 1)) &
> ~((typeof(addr))(size)-1))
>
> Which I assume the compiler will sort out?
[ This is line-wrapped, something in your mailer? Took me a bit to figure
out the - and + are diff -u things :-) ]
In the common case where size is a constant integer power of two, the
compiler will have no problem with this. But why do so complicated?
Why are the casts there, btw?
Segher
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN()
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
` (4 preceding siblings ...)
2020-04-21 0:49 ` [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Joel Stanley
@ 2020-05-20 10:59 ` Michael Ellerman
5 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2020-05-20 10:59 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Michael Ellerman, Christophe Leroy,
Paul Mackerras
Cc: linux-fbdev, kvm, alsa-devel, dri-devel, linux-kernel, linuxppc-dev
On Mon, 20 Apr 2020 18:36:34 +0000 (UTC), Christophe Leroy wrote:
> _ALIGN_UP() is specific to powerpc
> ALIGN() is generic and does the same
>
> Replace _ALIGN_UP() by ALIGN()
Applied to powerpc/next.
[1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN()
https://git.kernel.org/powerpc/c/7bfc3c84cbf5167d943cff9b3d2619dab0b7894c
[2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
https://git.kernel.org/powerpc/c/e96d904ede6756641563d27daa746875b478a6c8
[3/5] powerpc: Replace _ALIGN_UP() by ALIGN()
https://git.kernel.org/powerpc/c/b711531641038f3ff3723914f3d5ba79848d347e
[4/5] powerpc: Replace _ALIGN() by ALIGN()
https://git.kernel.org/powerpc/c/d3f3d3bf76cfb04e73436a15e3987d3573e7523a
[5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN()
https://git.kernel.org/powerpc/c/4cdb2da654033d76e1b1cb4ac427d9193dce816b
cheers
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-05-20 11:51 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
2020-04-20 18:36 ` [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() Christophe Leroy
2020-04-21 1:04 ` Joel Stanley
2020-04-21 15:55 ` Segher Boessenkool
2020-04-20 18:36 ` [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
2020-04-21 1:04 ` Joel Stanley
2020-04-20 18:36 ` [PATCH 4/5] powerpc: Replace _ALIGN() " Christophe Leroy
2020-04-21 1:11 ` Joel Stanley
2020-04-20 18:36 ` [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN() Christophe Leroy
2020-04-21 1:04 ` Joel Stanley
2020-04-21 0:49 ` [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Joel Stanley
2020-05-20 10:59 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).