Re: [PATCH] ARC: HSDK: improve reset driver

2018-09-14 Thread Philipp Zabel
Hi Eugeniy,

On Mon, 2018-08-27 at 17:38 +0300, Eugeniy Paltsev wrote:
> As for today HSDK reset driver implements only
> .reset() callback.
> 
> In case of driver which implements one of standard
> reset controller usage pattern
> (call *_deassert() in probe(), call *_assert() in remove())
> that leads to inoperability of this reset driver.
> 
> Improve HSDK reset driver by calling .reset() callback inside of
> .assert()/.deassert() callbacks to avoid each reset controller
> user adaptation for work with both reset methods
> (reset() and .assert()/.deassert() pair)
> 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  drivers/reset/reset-hsdk.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
> index 8bce391c6943..1fd91df91343 100644
> --- a/drivers/reset/reset-hsdk.c
> +++ b/drivers/reset/reset-hsdk.c
> @@ -86,6 +86,8 @@ static int hsdk_reset_reset(struct reset_controller_dev 
> *rcdev,
>  
>  static const struct reset_control_ops hsdk_reset_ops = {
>   .reset  = hsdk_reset_reset,
> + .assert = hsdk_reset_reset,

This is incorrect for exclusive reset controls.
It will cause reset_control_assert() to return success for exclusive
reset controls, even though the .assert op failed to leave the reset
line asserted after the function returns.

While calling hsdk_reset_reset from .assert for shared reset controls
would be fine, I don't see how this is necessary of useful.
If a consumer driver requires the reset to be asserted upon remove(), it
must not request a shared reset control anyway, because with shared
reset controls other drivers may keep the reset line deasserted
indefinitely.

> + .deassert = hsdk_reset_reset,

This should be fine. I wonder from time to time whether this should be
implemented in the core, in reset_control_deassert().

regards
Philipp

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

[PATCH] ARC: fix spelling mistake "entires" -> "entries"

2018-09-14 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in Kconfig

Signed-off-by: Colin Ian King 
---
 arch/arc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index b4441b0764d7..a045f3086047 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -149,7 +149,7 @@ config ARC_CPU_770
  Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
  This core has a bunch of cool new features:
  -MMU-v3: Variable Page Sz (4k, 8k, 16k), bigger J-TLB (128x4)
-   Shared Address Spaces (for sharing TLB entires in MMU)
+   Shared Address Spaces (for sharing TLB entries in MMU)
  -Caches: New Prog Model, Region Flush
  -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr
 
-- 
2.17.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 00/30] mm: remove bootmem allocator

2018-09-14 Thread Mike Rapoport
Hi,

These patches switch early memory management to use memblock directly
without any bootmem compatibility wrappers. As the result both bootmem and
nobootmem are removed.

The patchset survived allyesconfig builds on arm, arm64, i386, mips, nds32,
parisc, powerpc, riscv, s390 and x86 and most of the *_defconfig builds for
all architectures except unicore32.

The patchset is based on v4.19-rc3-mmotm-2018-09-12-16-40, so I needed a
small PSI fix from [1] for some of the builds.

I did my best to verify that the failures are not caused by my changes, but
I may have missed something. Most defconfig build failures I've seen were
caused by assembler being unhappy about unsupported opcode, wrong encoding
or something else. Some builds for allyesconfig also failed because of it
and others failed because of symbol mismatch in spi-sprd or n_hdlc.

I've done boot testing on real x86-64 and Power8 machines and on
qemu-system-alpha and qemu-system-mips64el VMs.

I've tried to keep the distribution list as small as possible, but it's
still pretty log; my apologies for spamming.

Changes since RFC:
* updated MIPS conversion to nobootmem: 
  - set memblock limit to max_low_pfn to avoid allocation attempts from
high memory
  - use boottom-up mode for allocation of the exceptions base
* added elaborate changelogs
* updated boot-time-mm documentation

[1] https://lkml.org/lkml/2018/9/13/88

Mike Rapoport (30):
  mips: switch to NO_BOOTMEM
  mm: remove CONFIG_NO_BOOTMEM
  mm: remove CONFIG_HAVE_MEMBLOCK
  mm: remove bootmem allocator implementation.
  mm: nobootmem: remove dead code
  memblock: rename memblock_alloc{_nid,_try_nid} to memblock_phys_alloc*
  memblock: remove _virt from APIs returning virtual address
  memblock: replace alloc_bootmem_align with memblock_alloc
  memblock: replace alloc_bootmem_low with memblock_alloc_low
  memblock: replace __alloc_bootmem_node_nopanic with
memblock_alloc_try_nid_nopanic
  memblock: replace alloc_bootmem_pages_nopanic with
memblock_alloc_nopanic
  memblock: replace alloc_bootmem_low with memblock_alloc_low
  memblock: replace __alloc_bootmem_nopanic with
memblock_alloc_from_nopanic
  memblock: add align parameter to memblock_alloc_node()
  memblock: replace alloc_bootmem_pages_node with memblock_alloc_node
  memblock: replace __alloc_bootmem_node with appropriate memblock_ API
  memblock: replace alloc_bootmem_node with memblock_alloc_node
  memblock: replace alloc_bootmem_low_pages with memblock_alloc_low
  memblock: replace alloc_bootmem_pages with memblock_alloc
  memblock: replace __alloc_bootmem with memblock_alloc_from
  memblock: replace alloc_bootmem with memblock_alloc
  mm: nobootmem: remove bootmem allocation APIs
  memblock: replace free_bootmem{_node} with memblock_free
  memblock: replace free_bootmem_late with memblock_free_late
  memblock: rename free_all_bootmem to memblock_free_all
  memblock: rename __free_pages_bootmem to memblock_free_pages
  mm: remove nobootmem
  memblock: replace BOOTMEM_ALLOC_* with MEMBLOCK variants
  mm: remove include/linux/bootmem.h
  docs/boot-time-mm: remove bootmem documentation

 Documentation/core-api/boot-time-mm.rst |  71 +--
 arch/alpha/Kconfig  |   2 -
 arch/alpha/kernel/core_cia.c|   4 +-
 arch/alpha/kernel/core_irongate.c   |   4 +-
 arch/alpha/kernel/core_marvel.c |   6 +-
 arch/alpha/kernel/core_titan.c  |   2 +-
 arch/alpha/kernel/core_tsunami.c|   2 +-
 arch/alpha/kernel/pci-noop.c|   6 +-
 arch/alpha/kernel/pci.c |   6 +-
 arch/alpha/kernel/pci_iommu.c   |  14 +-
 arch/alpha/kernel/setup.c   |   3 +-
 arch/alpha/kernel/sys_nautilus.c|   2 +-
 arch/alpha/mm/init.c|   4 +-
 arch/alpha/mm/numa.c|   1 -
 arch/arc/Kconfig|   2 -
 arch/arc/kernel/unwind.c|   6 +-
 arch/arc/mm/highmem.c   |   4 +-
 arch/arc/mm/init.c  |   3 +-
 arch/arm/Kconfig|   2 -
 arch/arm/kernel/devtree.c   |   1 -
 arch/arm/kernel/setup.c |   5 +-
 arch/arm/mach-omap2/omap_hwmod.c|   8 +-
 arch/arm/mm/dma-mapping.c   |   1 -
 arch/arm/mm/init.c  |   3 +-
 arch/arm/mm/mmu.c   |   2 +-
 arch/arm/xen/mm.c   |   1 -
 arch/arm/xen/p2m.c  |   2 +-
 arch/arm64/Kconfig  |   2 -
 arch/arm64/kernel/acpi.c|   1 -
 arch/arm64/kernel/acpi_numa.c   |   1 -
 arch/arm64/kernel/setup.c   |   3 +-
 arch/arm64/mm/dma-mapping.c |   2 +-
 arch/arm64/mm/init.c|   5 +-
 arch/arm64/mm/kasan_init.c  |   3 +-
 arch/arm64/mm/mmu.c   

[PATCH 07/30] memblock: remove _virt from APIs returning virtual address

2018-09-14 Thread Mike Rapoport
The conversion is done using

sed -i 's@memblock_virt_alloc@memblock_alloc@g' \
$(git grep -l memblock_virt_alloc)

Signed-off-by: Mike Rapoport 
---
 arch/arm/kernel/setup.c   |  4 ++--
 arch/arm/mach-omap2/omap_hwmod.c  |  6 ++---
 arch/arm64/mm/kasan_init.c|  2 +-
 arch/arm64/mm/numa.c  |  2 +-
 arch/mips/kernel/setup.c  |  2 +-
 arch/powerpc/kernel/pci_32.c  |  2 +-
 arch/powerpc/lib/alloc.c  |  2 +-
 arch/powerpc/mm/mmu_context_nohash.c  |  6 ++---
 arch/powerpc/platforms/powermac/nvram.c   |  2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c |  6 ++---
 arch/powerpc/platforms/ps3/setup.c|  2 +-
 arch/powerpc/sysdev/msi_bitmap.c  |  2 +-
 arch/s390/kernel/setup.c  | 12 +-
 arch/s390/kernel/smp.c|  2 +-
 arch/s390/kernel/topology.c   |  4 ++--
 arch/s390/numa/mode_emu.c |  2 +-
 arch/s390/numa/toptree.c  |  2 +-
 arch/x86/mm/kasan_init_64.c   |  4 ++--
 arch/xtensa/mm/kasan_init.c   |  2 +-
 drivers/clk/ti/clk.c  |  2 +-
 drivers/firmware/memmap.c |  2 +-
 drivers/of/fdt.c  |  2 +-
 drivers/of/unittest.c |  2 +-
 include/linux/bootmem.h   | 38 +++
 init/main.c   |  6 ++---
 kernel/dma/swiotlb.c  |  8 +++
 kernel/power/snapshot.c   |  2 +-
 kernel/printk/printk.c|  4 ++--
 lib/cpumask.c |  2 +-
 mm/hugetlb.c  |  2 +-
 mm/kasan/kasan_init.c |  2 +-
 mm/memblock.c | 26 ++---
 mm/page_alloc.c   |  8 +++
 mm/page_ext.c |  2 +-
 mm/percpu.c   | 28 +++
 mm/sparse-vmemmap.c   |  2 +-
 mm/sparse.c   | 12 +-
 37 files changed, 108 insertions(+), 108 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 4c249cb..39e6090 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -857,7 +857,7 @@ static void __init request_standard_resources(const struct 
machine_desc *mdesc)
 */
boot_alias_start = phys_to_idmap(start);
if (arm_has_idmap_alias() && boot_alias_start != 
IDMAP_INVALID_ADDR) {
-   res = memblock_virt_alloc(sizeof(*res), 0);
+   res = memblock_alloc(sizeof(*res), 0);
res->name = "System RAM (boot alias)";
res->start = boot_alias_start;
res->end = phys_to_idmap(end);
@@ -865,7 +865,7 @@ static void __init request_standard_resources(const struct 
machine_desc *mdesc)
request_resource(&iomem_resource, res);
}
 
-   res = memblock_virt_alloc(sizeof(*res), 0);
+   res = memblock_alloc(sizeof(*res), 0);
res->name  = "System RAM";
res->start = start;
res->end = end;
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 56a1fe9..1f9b34a 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -726,7 +726,7 @@ static int __init _setup_clkctrl_provider(struct 
device_node *np)
u64 size;
int i;
 
-   provider = memblock_virt_alloc(sizeof(*provider), 0);
+   provider = memblock_alloc(sizeof(*provider), 0);
if (!provider)
return -ENOMEM;
 
@@ -736,12 +736,12 @@ static int __init _setup_clkctrl_provider(struct 
device_node *np)
of_property_count_elems_of_size(np, "reg", sizeof(u32)) / 2;
 
provider->addr =
-   memblock_virt_alloc(sizeof(void *) * provider->num_addrs, 0);
+   memblock_alloc(sizeof(void *) * provider->num_addrs, 0);
if (!provider->addr)
return -ENOMEM;
 
provider->size =
-   memblock_virt_alloc(sizeof(u32) * provider->num_addrs, 0);
+   memblock_alloc(sizeof(u32) * provider->num_addrs, 0);
if (!provider->size)
return -ENOMEM;
 
diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c
index 1214587..2391560 100644
--- a/arch/arm64/mm/kasan_init.c
+++ b/arch/arm64/mm/kasan_init.c
@@ -38,7 +38,7 @@ static pgd_t tmp_pg_dir[PTRS_PER_PGD] __initdata 
__aligned(PGD_SIZE);
 
 static phys_addr_t __init kasan_alloc_zeroed_page(int node)
 {
-   void *p = memblock_virt_alloc_try_nid(PAGE_SIZE, PAGE_SIZE,
+   void *p = memblock_alloc_try_nid(PAGE_SIZE, PAGE_SIZE,
  __pa(MAX_DMA_ADDRESS),
  

[PATCH 09/30] memblock: replace alloc_bootmem_low with memblock_alloc_low

2018-09-14 Thread Mike Rapoport
The functions are equivalent, just the later does not require nobootmem
translation layer.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/x86/kernel/tce_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/tce_64.c b/arch/x86/kernel/tce_64.c
index f386bad..54c9b5a 100644
--- a/arch/x86/kernel/tce_64.c
+++ b/arch/x86/kernel/tce_64.c
@@ -173,7 +173,7 @@ void * __init alloc_tce_table(void)
size = table_size_to_number_of_entries(specified_table_size);
size *= TCE_ENTRY_SIZE;
 
-   return __alloc_bootmem_low(size, size, 0);
+   return memblock_alloc_low(size, size);
 }
 
 void __init free_tce_table(void *tbl)
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 08/30] memblock: replace alloc_bootmem_align with memblock_alloc

2018-09-14 Thread Mike Rapoport
The functions are equivalent, just the later does not require nobootmem
translation layer.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/x86/xen/p2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index d6d74ef..5de761b 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -182,7 +182,7 @@ static void p2m_init_identity(unsigned long *p2m, unsigned 
long pfn)
 static void * __ref alloc_p2m_page(void)
 {
if (unlikely(!slab_is_available()))
-   return alloc_bootmem_align(PAGE_SIZE, PAGE_SIZE);
+   return memblock_alloc(PAGE_SIZE, PAGE_SIZE);
 
return (void *)__get_free_page(GFP_KERNEL);
 }
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 12/30] memblock: replace alloc_bootmem_low with memblock_alloc_low

2018-09-14 Thread Mike Rapoport
The alloc_bootmem_low(size) allocates low memory with default alignement
and can be replcaed by memblock_alloc_low(size, 0)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/arm64/kernel/setup.c | 2 +-
 arch/unicore32/kernel/setup.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 5b4fac4..cf7a7b7 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -213,7 +213,7 @@ static void __init request_standard_resources(void)
kernel_data.end = __pa_symbol(_end - 1);
 
for_each_memblock(memory, region) {
-   res = alloc_bootmem_low(sizeof(*res));
+   res = memblock_alloc_low(sizeof(*res), 0);
if (memblock_is_nomap(region)) {
res->name  = "reserved";
res->flags = IORESOURCE_MEM;
diff --git a/arch/unicore32/kernel/setup.c b/arch/unicore32/kernel/setup.c
index c2bffa5..9f163f9 100644
--- a/arch/unicore32/kernel/setup.c
+++ b/arch/unicore32/kernel/setup.c
@@ -207,7 +207,7 @@ request_standard_resources(struct meminfo *mi)
if (mi->bank[i].size == 0)
continue;
 
-   res = alloc_bootmem_low(sizeof(*res));
+   res = memblock_alloc_low(sizeof(*res), 0);
res->name  = "System RAM";
res->start = mi->bank[i].start;
res->end   = mi->bank[i].start + mi->bank[i].size - 1;
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 14/30] memblock: add align parameter to memblock_alloc_node()

2018-09-14 Thread Mike Rapoport
With the align parameter memblock_alloc_node() can be used as drop in
replacement for alloc_bootmem_pages_node() and __alloc_bootmem_node(),
which is done in the following patches.

Signed-off-by: Mike Rapoport 
---
 include/linux/bootmem.h | 4 ++--
 mm/sparse.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 7d91f0f..3896af2 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -157,9 +157,9 @@ static inline void * __init memblock_alloc_from_nopanic(
 }
 
 static inline void * __init memblock_alloc_node(
-   phys_addr_t size, int nid)
+   phys_addr_t size, phys_addr_t align, int nid)
 {
-   return memblock_alloc_try_nid(size, 0, BOOTMEM_LOW_LIMIT,
+   return memblock_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT,
BOOTMEM_ALLOC_ACCESSIBLE, nid);
 }
 
diff --git a/mm/sparse.c b/mm/sparse.c
index 04e97af..509828f 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -68,7 +68,7 @@ static noinline struct mem_section __ref 
*sparse_index_alloc(int nid)
if (slab_is_available())
section = kzalloc_node(array_size, GFP_KERNEL, nid);
else
-   section = memblock_alloc_node(array_size, nid);
+   section = memblock_alloc_node(array_size, 0, nid);
 
return section;
 }
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 16/30] memblock: replace __alloc_bootmem_node with appropriate memblock_ API

2018-09-14 Thread Mike Rapoport
Use memblock_alloc_try_nid whenever goal (i.e. minimal address is
specified) and memblock_alloc_node otherwise.

Signed-off-by: Mike Rapoport 
---
 arch/ia64/mm/discontig.c   |  6 --
 arch/powerpc/kernel/setup_64.c |  6 --
 arch/sparc/kernel/setup_64.c   | 10 --
 arch/sparc/kernel/smp_64.c |  4 ++--
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 1928d57..918dda9 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -451,8 +451,10 @@ static void __init *memory_less_node_alloc(int nid, 
unsigned long pernodesize)
if (bestnode == -1)
bestnode = anynode;
 
-   ptr = __alloc_bootmem_node(pgdat_list[bestnode], pernodesize,
-   PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
+   ptr = memblock_alloc_try_nid(pernodesize, PERCPU_PAGE_SIZE,
+__pa(MAX_DMA_ADDRESS),
+BOOTMEM_ALLOC_ACCESSIBLE,
+bestnode);
 
return ptr;
 }
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 6a501b2..6add560 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -757,8 +757,10 @@ void __init emergency_stack_init(void)
 
 static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
 {
-   return __alloc_bootmem_node(NODE_DATA(early_cpu_to_node(cpu)), size, 
align,
-   __pa(MAX_DMA_ADDRESS));
+   return memblock_alloc_try_nid(size, align, __pa(MAX_DMA_ADDRESS),
+ BOOTMEM_ALLOC_ACCESSIBLE,
+ early_cpu_to_node(cpu));
+
 }
 
 static void __init pcpu_fc_free(void *ptr, size_t size)
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 206bf81..5fb11ea 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -622,12 +622,10 @@ void __init alloc_irqstack_bootmem(void)
for_each_possible_cpu(i) {
node = cpu_to_node(i);
 
-   softirq_stack[i] = __alloc_bootmem_node(NODE_DATA(node),
-   THREAD_SIZE,
-   THREAD_SIZE, 0);
-   hardirq_stack[i] = __alloc_bootmem_node(NODE_DATA(node),
-   THREAD_SIZE,
-   THREAD_SIZE, 0);
+   softirq_stack[i] = memblock_alloc_node(THREAD_SIZE,
+  THREAD_SIZE, node);
+   hardirq_stack[i] = memblock_alloc_node(THREAD_SIZE,
+  THREAD_SIZE, node);
}
 }
 
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index d3ea1f3..83ff88d 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1594,8 +1594,8 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
size_t size,
pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n",
 cpu, size, __pa(ptr));
} else {
-   ptr = __alloc_bootmem_node(NODE_DATA(node),
-  size, align, goal);
+   ptr = memblock_alloc_try_nid(size, align, goal,
+BOOTMEM_ALLOC_ACCESSIBLE, node);
pr_debug("per cpu data for cpu%d %lu bytes on node%d at "
 "%016lx\n", cpu, size, node, __pa(ptr));
}
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 13/30] memblock: replace __alloc_bootmem_nopanic with memblock_alloc_from_nopanic

2018-09-14 Thread Mike Rapoport
When __alloc_bootmem_nopanic() is used with explicit lower limit for the
allocation it attempts to allocate memory at or above that limit and falls
back to allocation with no limit set.

The memblock_alloc_from_nopanic() does exactly the same thing and can be
used as a replacement for __alloc_bootmem_nopanic() is such cases.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/arc/kernel/unwind.c   | 4 ++--
 arch/x86/kernel/setup_percpu.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c
index 183391d..2a01dd1 100644
--- a/arch/arc/kernel/unwind.c
+++ b/arch/arc/kernel/unwind.c
@@ -181,8 +181,8 @@ static void init_unwind_hdr(struct unwind_table *table,
  */
 static void *__init unw_hdr_alloc_early(unsigned long sz)
 {
-   return __alloc_bootmem_nopanic(sz, sizeof(unsigned int),
-  MAX_DMA_ADDRESS);
+   return memblock_alloc_from_nopanic(sz, sizeof(unsigned int),
+  MAX_DMA_ADDRESS);
 }
 
 static void *unw_hdr_alloc(unsigned long sz)
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 67d48e26..041663a 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -106,7 +106,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
unsigned long size,
void *ptr;
 
if (!node_online(node) || !NODE_DATA(node)) {
-   ptr = __alloc_bootmem_nopanic(size, align, goal);
+   ptr = memblock_alloc_from_nopanic(size, align, goal);
pr_info("cpu %d has no node %d or node-local memory\n",
cpu, node);
pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n",
@@ -121,7 +121,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
unsigned long size,
}
return ptr;
 #else
-   return __alloc_bootmem_nopanic(size, align, goal);
+   return memblock_alloc_from_nopanic(size, align, goal);
 #endif
 }
 
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 15/30] memblock: replace alloc_bootmem_pages_node with memblock_alloc_node

2018-09-14 Thread Mike Rapoport
The functions are equivalent, just the later does not require nobootmem
translation layer.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/ia64/mm/init.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 3b85c3e..2169ca5 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -447,19 +447,19 @@ int __init create_mem_map_page_table(u64 start, u64 end, 
void *arg)
for (address = start_page; address < end_page; address += PAGE_SIZE) {
pgd = pgd_offset_k(address);
if (pgd_none(*pgd))
-   pgd_populate(&init_mm, pgd, 
alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE));
+   pgd_populate(&init_mm, pgd, 
memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node));
pud = pud_offset(pgd, address);
 
if (pud_none(*pud))
-   pud_populate(&init_mm, pud, 
alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE));
+   pud_populate(&init_mm, pud, 
memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node));
pmd = pmd_offset(pud, address);
 
if (pmd_none(*pmd))
-   pmd_populate_kernel(&init_mm, pmd, 
alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE));
+   pmd_populate_kernel(&init_mm, pmd, 
memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node));
pte = pte_offset_kernel(pmd, address);
 
if (pte_none(*pte))
-   set_pte(pte, 
pfn_pte(__pa(alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE)) >> 
PAGE_SHIFT,
+   set_pte(pte, 
pfn_pte(__pa(memblock_alloc_node(PAGE_SIZE, PAGE_SIZE, node)) >> PAGE_SHIFT,
 PAGE_KERNEL));
}
return 0;
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 11/30] memblock: replace alloc_bootmem_pages_nopanic with memblock_alloc_nopanic

2018-09-14 Thread Mike Rapoport
The alloc_bootmem_pages_nopanic(size) is a shortcut for
__alloc_bootmem_nopanic(size, PAGE_SIZE, BOOTMEM_LOW_LIMIT) which allocates
PAGE_SIZE aligned memory. Since BOOTMEM_LOW_LIMIT is hardwired to 0 there
is no restrictions on where the allocated memory should reside.

The memblock_alloc_nopanic(size, PAGE_SIZE) also allocates PAGE_SIZE
aligned memory without any restrictions and thus can be used as a
replacement for alloc_bootmem_pages_nopanic()

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 drivers/usb/early/xhci-dbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index e15e896..16df968 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -94,7 +94,7 @@ static void * __init xdbc_get_page(dma_addr_t *dma_addr)
 {
void *virt;
 
-   virt = alloc_bootmem_pages_nopanic(PAGE_SIZE);
+   virt = memblock_alloc_nopanic(PAGE_SIZE, PAGE_SIZE);
if (!virt)
return NULL;
 
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 18/30] memblock: replace alloc_bootmem_low_pages with memblock_alloc_low

2018-09-14 Thread Mike Rapoport
The alloc_bootmem_low_pages() function allocates PAGE_SIZE aligned regions
from low memory. memblock_alloc_low() with alignment set to PAGE_SIZE does
exactly the same thing.

The conversion is done using the following semantic patch:

@@
expression e;
@@
- alloc_bootmem_low_pages(e)
+ memblock_alloc_low(e, PAGE_SIZE)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/arc/mm/highmem.c|  2 +-
 arch/m68k/atari/stram.c  |  3 ++-
 arch/m68k/mm/motorola.c  |  5 +++--
 arch/mips/cavium-octeon/dma-octeon.c |  2 +-
 arch/mips/mm/init.c  |  3 ++-
 arch/um/kernel/mem.c | 10 ++
 arch/xtensa/mm/mmu.c |  2 +-
 7 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c
index 77ff64a..f582dc8 100644
--- a/arch/arc/mm/highmem.c
+++ b/arch/arc/mm/highmem.c
@@ -123,7 +123,7 @@ static noinline pte_t * __init alloc_kmap_pgtable(unsigned 
long kvaddr)
pud_k = pud_offset(pgd_k, kvaddr);
pmd_k = pmd_offset(pud_k, kvaddr);
 
-   pte_k = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
+   pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
pmd_populate_kernel(&init_mm, pmd_k, pte_k);
return pte_k;
 }
diff --git a/arch/m68k/atari/stram.c b/arch/m68k/atari/stram.c
index c83d664..1089d67 100644
--- a/arch/m68k/atari/stram.c
+++ b/arch/m68k/atari/stram.c
@@ -95,7 +95,8 @@ void __init atari_stram_reserve_pages(void *start_mem)
 {
if (kernel_in_stram) {
pr_debug("atari_stram pool: kernel in ST-RAM, using 
alloc_bootmem!\n");
-   stram_pool.start = 
(resource_size_t)alloc_bootmem_low_pages(pool_size);
+   stram_pool.start = 
(resource_size_t)memblock_alloc_low(pool_size,
+  
PAGE_SIZE);
stram_pool.end = stram_pool.start + pool_size - 1;
request_resource(&iomem_resource, &stram_pool);
stram_virt_offset = 0;
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 4e17ecb..8bcf57e 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -55,7 +55,7 @@ static pte_t * __init kernel_page_table(void)
 {
pte_t *ptablep;
 
-   ptablep = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
+   ptablep = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
 
clear_page(ptablep);
__flush_page_to_ram(ptablep);
@@ -95,7 +95,8 @@ static pmd_t * __init kernel_ptr_table(void)
 
last_pgtable += PTRS_PER_PMD;
if (((unsigned long)last_pgtable & ~PAGE_MASK) == 0) {
-   last_pgtable = (pmd_t *)alloc_bootmem_low_pages(PAGE_SIZE);
+   last_pgtable = (pmd_t *)memblock_alloc_low(PAGE_SIZE,
+  PAGE_SIZE);
 
clear_page(last_pgtable);
__flush_page_to_ram(last_pgtable);
diff --git a/arch/mips/cavium-octeon/dma-octeon.c 
b/arch/mips/cavium-octeon/dma-octeon.c
index 236833b..c44c1a6 100644
--- a/arch/mips/cavium-octeon/dma-octeon.c
+++ b/arch/mips/cavium-octeon/dma-octeon.c
@@ -244,7 +244,7 @@ void __init plat_swiotlb_setup(void)
swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
 
-   octeon_swiotlb = alloc_bootmem_low_pages(swiotlbsize);
+   octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
 
if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM)
panic("Cannot allocate SWIOTLB buffer");
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 400676c..a010fba7 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -244,7 +244,8 @@ void __init fixrange_init(unsigned long start, unsigned 
long end,
pmd = (pmd_t *)pud;
for (; (k < PTRS_PER_PMD) && (vaddr < end); pmd++, k++) 
{
if (pmd_none(*pmd)) {
-   pte = (pte_t *) 
alloc_bootmem_low_pages(PAGE_SIZE);
+   pte = (pte_t *) 
memblock_alloc_low(PAGE_SIZE,
+  
PAGE_SIZE);
set_pmd(pmd, __pmd((unsigned long)pte));
BUG_ON(pte != pte_offset_kernel(pmd, 
0));
}
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 3c0e470..185f6bb 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -64,7 +64,8 @@ void __init mem_init(void)
 static void __init one_page_table_init(pmd_t *pmd)
 {
if (pmd_none(*pmd)) {
-   pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+   pte_t *pte = (pte_t *) memblock_alloc_low(PAGE_SIZE,
+ P

[PATCH 17/30] memblock: replace alloc_bootmem_node with memblock_alloc_node

2018-09-14 Thread Mike Rapoport
Both functions attempt to allocate memory with specified alignment from a
particular node. If the allocation from that node fails, they both fall
back to allocating from any node in the system.

Usage of native memblock API eliminates the nobootmem translation layer.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/alpha/kernel/pci_iommu.c   | 4 ++--
 arch/ia64/sn/kernel/io_common.c | 7 ++-
 arch/ia64/sn/kernel/setup.c | 4 ++--
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 6923b0d..b52d76f 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -74,7 +74,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, 
dma_addr_t base,
 
 #ifdef CONFIG_DISCONTIGMEM
 
-   arena = alloc_bootmem_node(NODE_DATA(nid), sizeof(*arena));
+   arena = memblock_alloc_node(sizeof(*arena), align, nid);
if (!NODE_DATA(nid) || !arena) {
printk("%s: couldn't allocate arena from node %d\n"
   "falling back to system-wide allocation\n",
@@ -82,7 +82,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, 
dma_addr_t base,
arena = alloc_bootmem(sizeof(*arena));
}
 
-   arena->ptes = __alloc_bootmem_node(NODE_DATA(nid), mem_size, align, 0);
+   arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid);
if (!NODE_DATA(nid) || !arena->ptes) {
printk("%s: couldn't allocate arena ptes from node %d\n"
   "falling back to system-wide allocation\n",
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 102aaba..8b05d55 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -385,16 +385,13 @@ void __init hubdev_init_node(nodepda_t * npda, cnodeid_t 
node)
 {
struct hubdev_info *hubdev_info;
int size;
-   pg_data_t *pg;
 
size = sizeof(struct hubdev_info);
 
if (node >= num_online_nodes()) /* Headless/memless IO nodes */
-   pg = NODE_DATA(0);
-   else
-   pg = NODE_DATA(node);
+   node = 0;
 
-   hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
+   hubdev_info = (struct hubdev_info *)memblock_alloc_node(size, 0, node);
 
npda->pdinfo = (void *)hubdev_info;
 }
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index 5f6b6b4..ab2564f 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -511,7 +511,7 @@ static void __init sn_init_pdas(char **cmdline_p)
 */
for_each_online_node(cnode) {
nodepdaindr[cnode] =
-   alloc_bootmem_node(NODE_DATA(cnode), sizeof(nodepda_t));
+   memblock_alloc_node(sizeof(nodepda_t), 0, cnode);
memset(nodepdaindr[cnode]->phys_cpuid, -1,
sizeof(nodepdaindr[cnode]->phys_cpuid));
spin_lock_init(&nodepdaindr[cnode]->ptc_lock);
@@ -522,7 +522,7 @@ static void __init sn_init_pdas(char **cmdline_p)
 */
for (cnode = num_online_nodes(); cnode < num_cnodes; cnode++)
nodepdaindr[cnode] =
-   alloc_bootmem_node(NODE_DATA(0), sizeof(nodepda_t));
+   memblock_alloc_node(sizeof(nodepda_t), 0, 0);
 
/*
 * Now copy the array of nodepda pointers to each nodepda.
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 20/30] memblock: replace __alloc_bootmem with memblock_alloc_from

2018-09-14 Thread Mike Rapoport
The functions are equivalent, just the later does not require nobootmem
translation layer.

The conversion is done using the following semantic patch:

@@
expression size, align, goal;
@@
- __alloc_bootmem(size, align, goal)
+ memblock_alloc_from(size, align, goal)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/alpha/kernel/core_cia.c  |  2 +-
 arch/alpha/kernel/pci_iommu.c |  4 ++--
 arch/alpha/kernel/setup.c |  2 +-
 arch/ia64/kernel/mca.c|  4 ++--
 arch/ia64/mm/contig.c |  5 +++--
 arch/mips/kernel/traps.c  |  2 +-
 arch/sparc/kernel/prom_32.c   |  2 +-
 arch/sparc/kernel/smp_64.c| 10 +-
 arch/sparc/mm/init_32.c   |  2 +-
 arch/sparc/mm/init_64.c   |  9 ++---
 arch/sparc/mm/srmmu.c | 10 +-
 include/linux/bootmem.h   |  8 
 12 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/arch/alpha/kernel/core_cia.c b/arch/alpha/kernel/core_cia.c
index 4b38386..026ee95 100644
--- a/arch/alpha/kernel/core_cia.c
+++ b/arch/alpha/kernel/core_cia.c
@@ -331,7 +331,7 @@ cia_prepare_tbia_workaround(int window)
long i;
 
/* Use minimal 1K map. */
-   ppte = __alloc_bootmem(CIA_BROKEN_TBIA_SIZE, 32768, 0);
+   ppte = memblock_alloc_from(CIA_BROKEN_TBIA_SIZE, 32768, 0);
pte = (virt_to_phys(ppte) >> (PAGE_SHIFT - 1)) | 1;
 
for (i = 0; i < CIA_BROKEN_TBIA_SIZE / sizeof(unsigned long); ++i)
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index b52d76f..0c05493 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -87,13 +87,13 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, 
dma_addr_t base,
printk("%s: couldn't allocate arena ptes from node %d\n"
   "falling back to system-wide allocation\n",
   __func__, nid);
-   arena->ptes = __alloc_bootmem(mem_size, align, 0);
+   arena->ptes = memblock_alloc_from(mem_size, align, 0);
}
 
 #else /* CONFIG_DISCONTIGMEM */
 
arena = alloc_bootmem(sizeof(*arena));
-   arena->ptes = __alloc_bootmem(mem_size, align, 0);
+   arena->ptes = memblock_alloc_from(mem_size, align, 0);
 
 #endif /* CONFIG_DISCONTIGMEM */
 
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 4f0d944..64c06a0 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -294,7 +294,7 @@ move_initrd(unsigned long mem_limit)
unsigned long size;
 
size = initrd_end - initrd_start;
-   start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
+   start = memblock_alloc_from(PAGE_ALIGN(size), PAGE_SIZE, 0);
if (!start || __pa(start) + size > mem_limit) {
initrd_start = initrd_end = 0;
return NULL;
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 6115464..5586926 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1835,8 +1835,8 @@ format_mca_init_stack(void *mca_data, unsigned long 
offset,
 /* Caller prevents this from being called after init */
 static void * __ref mca_bootmem(void)
 {
-   return __alloc_bootmem(sizeof(struct ia64_mca_cpu),
-   KERNEL_STACK_SIZE, 0);
+   return memblock_alloc_from(sizeof(struct ia64_mca_cpu),
+  KERNEL_STACK_SIZE, 0);
 }
 
 /* Do per-CPU MCA-related initialization.  */
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index e2e40bb..9e5c23a 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -85,8 +85,9 @@ void *per_cpu_init(void)
 static inline void
 alloc_per_cpu_data(void)
 {
-   cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * num_possible_cpus(),
-  PERCPU_PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
+   cpu_data = memblock_alloc_from(PERCPU_PAGE_SIZE * num_possible_cpus(),
+  PERCPU_PAGE_SIZE,
+  __pa(MAX_DMA_ADDRESS));
 }
 
 /**
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 5feef28..623dc18 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -2263,7 +2263,7 @@ void __init trap_init(void)
 
memblock_set_bottom_up(true);
ebase = (unsigned long)
-   __alloc_bootmem(size, 1 << fls(size), 0);
+   memblock_alloc_from(size, 1 << fls(size), 0);
memblock_set_bottom_up(false);
 
/*
diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c
index b51cbb9..4389944 100644
--- a/arch/sparc/kernel/prom_32.c
+++ b/arch/sparc/kernel/prom_32.c
@@ -32,7 +32,7 @@ void * __init prom_early_alloc(unsigned long size)
 {
void *ret;
 
-   ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL);
+   ret = memblock_alloc_from(size, SMP_CACHE_BYTES, 0UL);
if (ret != NULL)
memset(ret, 0, size

[PATCH 22/30] mm: nobootmem: remove bootmem allocation APIs

2018-09-14 Thread Mike Rapoport
The bootmem compatibility APIs are not used and can be removed.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 include/linux/bootmem.h |  47 --
 mm/nobootmem.c  | 224 
 2 files changed, 271 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index c97c105..73f1272 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -36,33 +36,6 @@ extern void free_bootmem_node(pg_data_t *pgdat,
 extern void free_bootmem(unsigned long physaddr, unsigned long size);
 extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
 
-extern void *__alloc_bootmem(unsigned long size,
-unsigned long align,
-unsigned long goal);
-extern void *__alloc_bootmem_nopanic(unsigned long size,
-unsigned long align,
-unsigned long goal) __malloc;
-extern void *__alloc_bootmem_node(pg_data_t *pgdat,
- unsigned long size,
- unsigned long align,
- unsigned long goal) __malloc;
-void *__alloc_bootmem_node_high(pg_data_t *pgdat,
- unsigned long size,
- unsigned long align,
- unsigned long goal) __malloc;
-extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
- unsigned long size,
- unsigned long align,
- unsigned long goal) __malloc;
-void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
- unsigned long size,
- unsigned long align,
- unsigned long goal,
- unsigned long limit) __malloc;
-extern void *__alloc_bootmem_low(unsigned long size,
-unsigned long align,
-unsigned long goal) __malloc;
-
 /* We are using top down, so it is safe to use 0 here */
 #define BOOTMEM_LOW_LIMIT 0
 
@@ -70,26 +43,6 @@ extern void *__alloc_bootmem_low(unsigned long size,
 #define ARCH_LOW_ADDRESS_LIMIT  0xUL
 #endif
 
-#define alloc_bootmem(x) \
-   __alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_align(x, align) \
-   __alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_pages(x) \
-   __alloc_bootmem(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_pages_nopanic(x) \
-   __alloc_bootmem_nopanic(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_node(pgdat, x) \
-   __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_node_nopanic(pgdat, x) \
-   __alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, 
BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_pages_node(pgdat, x) \
-   __alloc_bootmem_node(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
-
-#define alloc_bootmem_low(x) \
-   __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
-#define alloc_bootmem_low_pages(x) \
-   __alloc_bootmem_low(x, PAGE_SIZE, 0)
-
 /* FIXME: use MEMBLOCK_ALLOC_* variants here */
 #define BOOTMEM_ALLOC_ACCESSIBLE   0
 #define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0)
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 44ce7de..bc38e56 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -33,41 +33,6 @@ unsigned long min_low_pfn;
 unsigned long max_pfn;
 unsigned long long max_possible_pfn;
 
-static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
-   u64 goal, u64 limit)
-{
-   void *ptr;
-   u64 addr;
-   enum memblock_flags flags = choose_memblock_flags();
-
-   if (limit > memblock.current_limit)
-   limit = memblock.current_limit;
-
-again:
-   addr = memblock_find_in_range_node(size, align, goal, limit, nid,
-  flags);
-   if (!addr && (flags & MEMBLOCK_MIRROR)) {
-   flags &= ~MEMBLOCK_MIRROR;
-   pr_warn("Could not allocate %pap bytes of mirrored memory\n",
-   &size);
-   goto again;
-   }
-   if (!addr)
-   return NULL;
-
-   if (memblock_reserve(addr, size))
-   return NULL;
-
-   ptr = phys_to_virt(addr);
-   memset(ptr, 0, size);
-   /*
-* The min_count is set to 0 so that bootmem allocated blocks
-* are never reported as leaks.
-*/
-   kmemleak_alloc(ptr, size, 0, 0);
-   return ptr;
-}
-
 /**
  * free_bootmem_late - free bootmem pages directly to page allocator
  * @addr: starting address of the range
@@ -215,192 +180,3 @@ void __init free_bootmem(unsigned long addr, unsigned 
long size)
 {
memblock_free(addr, size);
 }
-
-static void * __init ___

[PATCH 21/30] memblock: replace alloc_bootmem with memblock_alloc

2018-09-14 Thread Mike Rapoport
The alloc_bootmem(size) is a shortcut for allocation of SMP_CACHE_BYTES
aligned memory. When the align parameter of memblock_alloc() is 0, the
alignment is implicitly set to SMP_CACHE_BYTES and thus alloc_bootmem(size)
and memblock_alloc(size, 0) are equivalent.

The conversion is done using the following semantic patch:

@@
expression size;
@@
- alloc_bootmem(size)
+ memblock_alloc(size, 0)

Signed-off-by: Mike Rapoport 
---
 arch/alpha/kernel/core_marvel.c | 4 ++--
 arch/alpha/kernel/pci-noop.c| 4 ++--
 arch/alpha/kernel/pci.c | 4 ++--
 arch/alpha/kernel/pci_iommu.c   | 4 ++--
 arch/ia64/kernel/mca.c  | 4 ++--
 arch/ia64/mm/tlb.c  | 4 ++--
 arch/m68k/sun3/sun3dvma.c   | 3 ++-
 arch/microblaze/mm/init.c   | 2 +-
 arch/mips/kernel/setup.c| 2 +-
 arch/um/drivers/net_kern.c  | 2 +-
 arch/um/drivers/vector_kern.c   | 2 +-
 arch/um/kernel/initrd.c | 2 +-
 arch/x86/kernel/acpi/boot.c | 3 ++-
 arch/x86/kernel/apic/io_apic.c  | 2 +-
 arch/x86/kernel/e820.c  | 2 +-
 arch/x86/platform/olpc/olpc_dt.c| 2 +-
 arch/xtensa/platforms/iss/network.c | 2 +-
 drivers/macintosh/smu.c | 2 +-
 init/main.c | 4 ++--
 19 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
index bdebb8c2..1f00c94 100644
--- a/arch/alpha/kernel/core_marvel.c
+++ b/arch/alpha/kernel/core_marvel.c
@@ -82,7 +82,7 @@ mk_resource_name(int pe, int port, char *str)
char *name;

sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port);
-   name = alloc_bootmem(strlen(tmp) + 1);
+   name = memblock_alloc(strlen(tmp) + 1, 0);
strcpy(name, tmp);
 
return name;
@@ -117,7 +117,7 @@ alloc_io7(unsigned int pe)
return NULL;
}
 
-   io7 = alloc_bootmem(sizeof(*io7));
+   io7 = memblock_alloc(sizeof(*io7), 0);
io7->pe = pe;
raw_spin_lock_init(&io7->irq_lock);
 
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index c7c5879..59cbfc2 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -33,7 +33,7 @@ alloc_pci_controller(void)
 {
struct pci_controller *hose;
 
-   hose = alloc_bootmem(sizeof(*hose));
+   hose = memblock_alloc(sizeof(*hose), 0);
 
*hose_tail = hose;
hose_tail = &hose->next;
@@ -44,7 +44,7 @@ alloc_pci_controller(void)
 struct resource * __init
 alloc_resource(void)
 {
-   return alloc_bootmem(sizeof(struct resource));
+   return memblock_alloc(sizeof(struct resource), 0);
 }
 
 SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c668c3b..4cc3eb9 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -392,7 +392,7 @@ alloc_pci_controller(void)
 {
struct pci_controller *hose;
 
-   hose = alloc_bootmem(sizeof(*hose));
+   hose = memblock_alloc(sizeof(*hose), 0);
 
*hose_tail = hose;
hose_tail = &hose->next;
@@ -403,7 +403,7 @@ alloc_pci_controller(void)
 struct resource * __init
 alloc_resource(void)
 {
-   return alloc_bootmem(sizeof(struct resource));
+   return memblock_alloc(sizeof(struct resource), 0);
 }
 
 
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 0c05493..5d178c7 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -79,7 +79,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, 
dma_addr_t base,
printk("%s: couldn't allocate arena from node %d\n"
   "falling back to system-wide allocation\n",
   __func__, nid);
-   arena = alloc_bootmem(sizeof(*arena));
+   arena = memblock_alloc(sizeof(*arena), 0);
}
 
arena->ptes = memblock_alloc_node(sizeof(*arena), align, nid);
@@ -92,7 +92,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, 
dma_addr_t base,
 
 #else /* CONFIG_DISCONTIGMEM */
 
-   arena = alloc_bootmem(sizeof(*arena));
+   arena = memblock_alloc(sizeof(*arena), 0);
arena->ptes = memblock_alloc_from(mem_size, align, 0);
 
 #endif /* CONFIG_DISCONTIGMEM */
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 5586926..7120976 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -361,9 +361,9 @@ static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES];
 
 #define IA64_LOG_ALLOCATE(it, size) \
{ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \
-   (ia64_err_rec_t *)alloc_bootmem(size); \
+   (ia64_err_rec_t *)memblock_alloc(size, 0); \
ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \
-   (ia64_err_rec_t *)alloc_bootmem(size);}
+   (ia64_err_rec_t *)memblock_alloc(size, 0);}
 #de

[PATCH 23/30] memblock: replace free_bootmem{_node} with memblock_free

2018-09-14 Thread Mike Rapoport
The free_bootmem and free_bootmem_node are merely wrappers for
memblock_free. Replace their usage with a call to memblock_free using the
following semantic patch:

@@
expression e1, e2, e3;
@@
(
- free_bootmem(e1, e2)
+ memblock_free(e1, e2)
|
- free_bootmem_node(e1, e2, e3)
+ memblock_free(e2, e3)
)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/alpha/kernel/core_irongate.c |  3 +--
 arch/arm64/mm/init.c  |  2 +-
 arch/mips/kernel/setup.c  |  2 +-
 arch/powerpc/kernel/setup_64.c|  2 +-
 arch/sparc/kernel/smp_64.c|  2 +-
 arch/um/kernel/mem.c  |  3 ++-
 arch/unicore32/mm/init.c  |  2 +-
 arch/x86/kernel/setup_percpu.c|  3 ++-
 arch/x86/kernel/tce_64.c  |  3 ++-
 arch/x86/xen/p2m.c|  3 ++-
 drivers/macintosh/smu.c   |  2 +-
 drivers/usb/early/xhci-dbc.c  | 11 ++-
 drivers/xen/swiotlb-xen.c |  4 +++-
 include/linux/bootmem.h   |  4 
 mm/nobootmem.c| 30 --
 15 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/arch/alpha/kernel/core_irongate.c 
b/arch/alpha/kernel/core_irongate.c
index f709866..35572be 100644
--- a/arch/alpha/kernel/core_irongate.c
+++ b/arch/alpha/kernel/core_irongate.c
@@ -234,8 +234,7 @@ albacore_init_arch(void)
unsigned long size;
 
size = initrd_end - initrd_start;
-   free_bootmem_node(NODE_DATA(0), __pa(initrd_start),
- PAGE_ALIGN(size));
+   memblock_free(__pa(initrd_start), PAGE_ALIGN(size));
if (!move_initrd(pci_mem))
printk("irongate_init_arch: initrd too big "
   "(%ldK)\ndisabling initrd\n",
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 787e279..e335452 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -538,7 +538,7 @@ static inline void free_memmap(unsigned long start_pfn, 
unsigned long end_pfn)
 * memmap array.
 */
if (pg < pgend)
-   free_bootmem(pg, pgend - pg);
+   memblock_free(pg, pgend - pg);
 }
 
 /*
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index a6bc2f6..86c9eda 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -561,7 +561,7 @@ static void __init bootmem_init(void)
extern void show_kernel_relocation(const char *level);
 
offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS);
-   free_bootmem(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset);
+   memblock_free(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset);
 
 #if defined(CONFIG_DEBUG_KERNEL) && defined(CONFIG_DEBUG_INFO)
/*
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 6add560..e564b27 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -765,7 +765,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t 
size, size_t align)
 
 static void __init pcpu_fc_free(void *ptr, size_t size)
 {
-   free_bootmem(__pa(ptr), size);
+   memblock_free(__pa(ptr), size);
 }
 
 static int pcpu_cpu_distance(unsigned int from, unsigned int to)
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 337febd..a087a6a 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1607,7 +1607,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
size_t size,
 
 static void __init pcpu_free_bootmem(void *ptr, size_t size)
 {
-   free_bootmem(__pa(ptr), size);
+   memblock_free(__pa(ptr), size);
 }
 
 static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 185f6bb..3555c13 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -46,7 +47,7 @@ void __init mem_init(void)
 */
brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
-   free_bootmem(__pa(brk_end), uml_reserved - brk_end);
+   memblock_free(__pa(brk_end), uml_reserved - brk_end);
uml_reserved = brk_end;
 
/* this will put all low memory onto the freelists */
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index 44ccc15..4c572ab 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -241,7 +241,7 @@ free_memmap(unsigned long start_pfn, unsigned long end_pfn)
 * free the section of the memmap array.
 */
if (pg < pgend)
-   free_bootmem(pg, pgend - pg);
+   memblock_free(pg, pgend - pg);
 }
 
 /*
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 041663

[PATCH 27/30] mm: remove nobootmem

2018-09-14 Thread Mike Rapoport
Move a few remaining functions from nobootmem.c to memblock.c and remove
nobootmem

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 mm/Makefile|   1 -
 mm/memblock.c  | 104 ++
 mm/nobootmem.c | 128 -
 3 files changed, 104 insertions(+), 129 deletions(-)
 delete mode 100644 mm/nobootmem.c

diff --git a/mm/Makefile b/mm/Makefile
index ca3c844..d210cc9 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -42,7 +42,6 @@ obj-y := filemap.o mempool.o oom_kill.o 
fadvise.o \
   debug.o $(mmu-y)
 
 obj-y += init-mm.o
-obj-y += nobootmem.o
 obj-y += memblock.o
 
 ifdef CONFIG_MMU
diff --git a/mm/memblock.c b/mm/memblock.c
index a2cd61d..4591f38 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -82,6 +82,16 @@
  * initialization compltes.
  */
 
+#ifndef CONFIG_NEED_MULTIPLE_NODES
+struct pglist_data __refdata contig_page_data;
+EXPORT_SYMBOL(contig_page_data);
+#endif
+
+unsigned long max_low_pfn;
+unsigned long min_low_pfn;
+unsigned long max_pfn;
+unsigned long long max_possible_pfn;
+
 static struct memblock_region 
memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
 static struct memblock_region 
memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
@@ -1929,6 +1939,100 @@ static int __init early_memblock(char *p)
 }
 early_param("memblock", early_memblock);
 
+static void __init __free_pages_memory(unsigned long start, unsigned long end)
+{
+   int order;
+
+   while (start < end) {
+   order = min(MAX_ORDER - 1UL, __ffs(start));
+
+   while (start + (1UL << order) > end)
+   order--;
+
+   memblock_free_pages(pfn_to_page(start), start, order);
+
+   start += (1UL << order);
+   }
+}
+
+static unsigned long __init __free_memory_core(phys_addr_t start,
+phys_addr_t end)
+{
+   unsigned long start_pfn = PFN_UP(start);
+   unsigned long end_pfn = min_t(unsigned long,
+ PFN_DOWN(end), max_low_pfn);
+
+   if (start_pfn >= end_pfn)
+   return 0;
+
+   __free_pages_memory(start_pfn, end_pfn);
+
+   return end_pfn - start_pfn;
+}
+
+static unsigned long __init free_low_memory_core_early(void)
+{
+   unsigned long count = 0;
+   phys_addr_t start, end;
+   u64 i;
+
+   memblock_clear_hotplug(0, -1);
+
+   for_each_reserved_mem_region(i, &start, &end)
+   reserve_bootmem_region(start, end);
+
+   /*
+* We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id
+*  because in some case like Node0 doesn't have RAM installed
+*  low ram will be on Node1
+*/
+   for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end,
+   NULL)
+   count += __free_memory_core(start, end);
+
+   return count;
+}
+
+static int reset_managed_pages_done __initdata;
+
+void reset_node_managed_pages(pg_data_t *pgdat)
+{
+   struct zone *z;
+
+   for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
+   z->managed_pages = 0;
+}
+
+void __init reset_all_zones_managed_pages(void)
+{
+   struct pglist_data *pgdat;
+
+   if (reset_managed_pages_done)
+   return;
+
+   for_each_online_pgdat(pgdat)
+   reset_node_managed_pages(pgdat);
+
+   reset_managed_pages_done = 1;
+}
+
+/**
+ * memblock_free_all - release free pages to the buddy allocator
+ *
+ * Return: the number of pages actually released.
+ */
+unsigned long __init memblock_free_all(void)
+{
+   unsigned long pages;
+
+   reset_all_zones_managed_pages();
+
+   pages = free_low_memory_core_early();
+   totalram_pages += pages;
+
+   return pages;
+}
+
 #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK)
 
 static int memblock_debug_show(struct seq_file *m, void *private)
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
deleted file mode 100644
index 9608bc5..000
--- a/mm/nobootmem.c
+++ /dev/null
@@ -1,128 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- *  bootmem - A boot-time physical memory allocator and configurator
- *
- *  Copyright (C) 1999 Ingo Molnar
- *1999 Kanoj Sarcar, SGI
- *2008 Johannes Weiner
- *
- * Access to this subsystem has to be serialized externally (which is true
- * for the boot process anyway).
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-
-#include "internal.h"
-
-#ifndef CONFIG_NEED_MULTIPLE_NODES
-struct pglist_data __refdata contig_page_data;
-EXPORT_SYMBOL(contig_page_data);
-#endif
-
-unsigned long max_low_pfn;
-unsigned long min_low_pfn;
-unsigned long max_pfn;
-unsigned long long max_possible_pfn;
-
-static void

[PATCH 28/30] memblock: replace BOOTMEM_ALLOC_* with MEMBLOCK variants

2018-09-14 Thread Mike Rapoport
Drop BOOTMEM_ALLOC_ACCESSIBLE and BOOTMEM_ALLOC_ANYWHERE in favor of
identical MEMBLOCK definitions.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/ia64/mm/discontig.c   | 2 +-
 arch/powerpc/kernel/setup_64.c | 2 +-
 arch/sparc/kernel/smp_64.c | 2 +-
 arch/x86/kernel/setup_percpu.c | 2 +-
 arch/x86/mm/kasan_init_64.c| 4 ++--
 mm/hugetlb.c   | 3 ++-
 mm/kasan/kasan_init.c  | 2 +-
 mm/memblock.c  | 8 
 mm/page_ext.c  | 2 +-
 mm/sparse-vmemmap.c| 3 ++-
 mm/sparse.c| 5 +++--
 11 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 918dda9..70609f8 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -453,7 +453,7 @@ static void __init *memory_less_node_alloc(int nid, 
unsigned long pernodesize)
 
ptr = memblock_alloc_try_nid(pernodesize, PERCPU_PAGE_SIZE,
 __pa(MAX_DMA_ADDRESS),
-BOOTMEM_ALLOC_ACCESSIBLE,
+MEMBLOCK_ALLOC_ACCESSIBLE,
 bestnode);
 
return ptr;
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index e564b27..b3e70cc 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -758,7 +758,7 @@ void __init emergency_stack_init(void)
 static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
 {
return memblock_alloc_try_nid(size, align, __pa(MAX_DMA_ADDRESS),
- BOOTMEM_ALLOC_ACCESSIBLE,
+ MEMBLOCK_ALLOC_ACCESSIBLE,
  early_cpu_to_node(cpu));
 
 }
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index a087a6a..6cc80d0 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1595,7 +1595,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
size_t size,
 cpu, size, __pa(ptr));
} else {
ptr = memblock_alloc_try_nid(size, align, goal,
-BOOTMEM_ALLOC_ACCESSIBLE, node);
+MEMBLOCK_ALLOC_ACCESSIBLE, node);
pr_debug("per cpu data for cpu%d %lu bytes on node%d at "
 "%016lx\n", cpu, size, node, __pa(ptr));
}
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index a006f1b..483412f 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -114,7 +114,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
unsigned long size,
 cpu, size, __pa(ptr));
} else {
ptr = memblock_alloc_try_nid_nopanic(size, align, goal,
-BOOTMEM_ALLOC_ACCESSIBLE,
+MEMBLOCK_ALLOC_ACCESSIBLE,
 node);
 
pr_debug("per cpu data for cpu%d %lu bytes on node%d at 
%016lx\n",
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c
index 77b857c..8f87499 100644
--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -29,10 +29,10 @@ static __init void *early_alloc(size_t size, int nid, bool 
panic)
 {
if (panic)
return memblock_alloc_try_nid(size, size,
-   __pa(MAX_DMA_ADDRESS), BOOTMEM_ALLOC_ACCESSIBLE, nid);
+   __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid);
else
return memblock_alloc_try_nid_nopanic(size, size,
-   __pa(MAX_DMA_ADDRESS), BOOTMEM_ALLOC_ACCESSIBLE, nid);
+   __pa(MAX_DMA_ADDRESS), MEMBLOCK_ALLOC_ACCESSIBLE, nid);
 }
 
 static void __init kasan_populate_pmd(pmd_t *pmd, unsigned long addr,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 3b63370..67629dc 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2102,7 +2103,7 @@ int __alloc_bootmem_huge_page(struct hstate *h)
 
addr = memblock_alloc_try_nid_raw(
huge_page_size(h), huge_page_size(h),
-   0, BOOTMEM_ALLOC_ACCESSIBLE, node);
+   0, MEMBLOCK_ALLOC_ACCESSIBLE, node);
if (addr) {
/*
 * Use the beginning of the huge page to store the
diff --git a/mm/kasan/kasan_init.c b/mm/kasan/kasan_init.c
index 24d734b..785a970 100644
--- a/mm/kasan/kasan_init.c
+++ b/mm/kasan/kasan_init.c
@@ -84,7 +84,7 @@ static inline bool kasan_zero_page_entry(pte_t pte)
 static __init void *early_alloc(size_t size, int node)
 {

[PATCH 29/30] mm: remove include/linux/bootmem.h

2018-09-14 Thread Mike Rapoport
Move remaining definitions and declarations from include/linux/bootmem.h
into include/linux/memblock.h and remove the redundant header.

The includes were replaced with the semantic patch below and then
semi-automated removal of duplicated '#include 

@@
@@
- #include 
+ #include 

Signed-off-by: Mike Rapoport 
---
 arch/alpha/kernel/core_cia.c|   2 +-
 arch/alpha/kernel/core_irongate.c   |   1 -
 arch/alpha/kernel/core_marvel.c |   2 +-
 arch/alpha/kernel/core_titan.c  |   2 +-
 arch/alpha/kernel/core_tsunami.c|   2 +-
 arch/alpha/kernel/pci-noop.c|   2 +-
 arch/alpha/kernel/pci.c |   2 +-
 arch/alpha/kernel/pci_iommu.c   |   2 +-
 arch/alpha/kernel/setup.c   |   1 -
 arch/alpha/kernel/sys_nautilus.c|   2 +-
 arch/alpha/mm/init.c|   2 +-
 arch/alpha/mm/numa.c|   1 -
 arch/arc/kernel/unwind.c|   2 +-
 arch/arc/mm/highmem.c   |   2 +-
 arch/arc/mm/init.c  |   1 -
 arch/arm/kernel/devtree.c   |   1 -
 arch/arm/kernel/setup.c |   1 -
 arch/arm/mach-omap2/omap_hwmod.c|   2 +-
 arch/arm/mm/dma-mapping.c   |   1 -
 arch/arm/mm/init.c  |   1 -
 arch/arm/xen/mm.c   |   1 -
 arch/arm/xen/p2m.c  |   2 +-
 arch/arm64/kernel/acpi.c|   1 -
 arch/arm64/kernel/acpi_numa.c   |   1 -
 arch/arm64/kernel/setup.c   |   1 -
 arch/arm64/mm/dma-mapping.c |   2 +-
 arch/arm64/mm/init.c|   1 -
 arch/arm64/mm/kasan_init.c  |   1 -
 arch/arm64/mm/numa.c|   1 -
 arch/c6x/kernel/setup.c |   1 -
 arch/c6x/mm/init.c  |   2 +-
 arch/h8300/kernel/setup.c   |   1 -
 arch/h8300/mm/init.c|   2 +-
 arch/hexagon/kernel/dma.c   |   2 +-
 arch/hexagon/kernel/setup.c |   2 +-
 arch/hexagon/mm/init.c  |   1 -
 arch/ia64/kernel/crash.c|   2 +-
 arch/ia64/kernel/efi.c  |   2 +-
 arch/ia64/kernel/ia64_ksyms.c   |   2 +-
 arch/ia64/kernel/iosapic.c  |   2 +-
 arch/ia64/kernel/mca.c  |   2 +-
 arch/ia64/kernel/mca_drv.c  |   2 +-
 arch/ia64/kernel/setup.c|   1 -
 arch/ia64/kernel/smpboot.c  |   2 +-
 arch/ia64/kernel/topology.c |   2 +-
 arch/ia64/kernel/unwind.c   |   2 +-
 arch/ia64/mm/contig.c   |   1 -
 arch/ia64/mm/discontig.c|   1 -
 arch/ia64/mm/init.c |   1 -
 arch/ia64/mm/numa.c |   2 +-
 arch/ia64/mm/tlb.c  |   2 +-
 arch/ia64/pci/pci.c |   2 +-
 arch/ia64/sn/kernel/bte.c   |   2 +-
 arch/ia64/sn/kernel/io_common.c |   2 +-
 arch/ia64/sn/kernel/setup.c |   2 +-
 arch/m68k/atari/stram.c |   2 +-
 arch/m68k/coldfire/m54xx.c  |   2 +-
 arch/m68k/kernel/setup_mm.c |   1 -
 arch/m68k/kernel/setup_no.c |   1 -
 arch/m68k/kernel/uboot.c|   2 +-
 arch/m68k/mm/init.c |   2 +-
 arch/m68k/mm/mcfmmu.c   |   1 -
 arch/m68k/mm/motorola.c |   1 -
 arch/m68k/mm/sun3mmu.c  |   2 +-
 arch/m68k/sun3/config.c |   2 +-
 arch/m68k/sun3/dvma.c   |   2 +-
 arch/m68k/sun3/mmu_emu.c|   2 +-
 arch/m68k/sun3/sun3dvma.c   |   2 +-
 arch/m68k/sun3x/dvma.c  |   2 +-
 arch/microblaze/mm/consistent.c |   2 +-
 arch/microblaze/mm/init.c   |   3 +-
 arch/microblaze/pci/pci-common.c|   2 +-
 arch/mips/ar7/memory.c  |   2 +-
 arch/mips/ath79/setup.c |   2 +-
 arch/mips/bcm63xx/prom.c|   2 +-
 arch/mips/bcm63xx/setup.c   |   2 +-
 arch/mips/bmips/setup.c |   2 +-
 arch/mips/cavium-octeon/dma-octeon.c|   2 +-
 arch/mips/dec/prom/memory.c |   2 +-
 arch/mips/emma/common/prom.c|   2 +-
 arch/mips/fw/arc/memory.c   |   2 +-
 arch/mips/jazz/jazzdma.c|   2 +-
 arch/mips/kernel/crash.c|   2 +-
 arch/mips/kernel/crash_dump.c   |   2 +-
 arch/mips/kernel/prom.c |   2 +-
 arch/mips/kernel/setup.c|   1 -
 arch/mips/kernel/traps.c|   1 -
 arch/mips/k

[PATCH 02/30] mm: remove CONFIG_NO_BOOTMEM

2018-09-14 Thread Mike Rapoport
All achitectures select NO_BOOTMEM which essentially becomes 'Y' for any
kernel configuration and therefore it can be removed.

Signed-off-by: Mike Rapoport 
---
 arch/alpha/Kconfig  |  1 -
 arch/arc/Kconfig|  1 -
 arch/arm/Kconfig|  1 -
 arch/arm64/Kconfig  |  1 -
 arch/c6x/Kconfig|  1 -
 arch/h8300/Kconfig  |  1 -
 arch/hexagon/Kconfig|  1 -
 arch/ia64/Kconfig   |  1 -
 arch/m68k/Kconfig   |  1 -
 arch/microblaze/Kconfig |  1 -
 arch/mips/Kconfig   |  1 -
 arch/nds32/Kconfig  |  1 -
 arch/nios2/Kconfig  |  1 -
 arch/openrisc/Kconfig   |  1 -
 arch/parisc/Kconfig |  1 -
 arch/powerpc/Kconfig|  1 -
 arch/riscv/Kconfig  |  1 -
 arch/s390/Kconfig   |  1 -
 arch/sh/Kconfig |  1 -
 arch/sparc/Kconfig  |  1 -
 arch/um/Kconfig |  1 -
 arch/unicore32/Kconfig  |  1 -
 arch/x86/Kconfig|  3 ---
 arch/xtensa/Kconfig |  1 -
 include/linux/bootmem.h | 36 ++--
 include/linux/mmzone.h  |  5 +
 mm/Kconfig  |  3 ---
 mm/Makefile |  7 +--
 mm/memblock.c   |  2 --
 29 files changed, 4 insertions(+), 75 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 620b0a7..04de6be 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -32,7 +32,6 @@ config ALPHA
select OLD_SIGSUSPEND
select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67
select HAVE_MEMBLOCK
-   select NO_BOOTMEM
help
  The Alpha is a 64-bit general-purpose processor designed and
  marketed by the Digital Equipment Corporation of blessed memory,
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index b4441b0..04ebead 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -44,7 +44,6 @@ config ARC
select HANDLE_DOMAIN_IRQ
select IRQ_DOMAIN
select MODULES_USE_ELF_RELA
-   select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
select OF_RESERVED_MEM
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4607d32..a961d70 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -100,7 +100,6 @@ config ARM
select IRQ_FORCED_THREADING
select MODULES_USE_ELF_REL
select NEED_DMA_MAP_STATE
-   select NO_BOOTMEM
select OF_EARLY_FLATTREE if OF
select OF_RESERVED_MEM if OF
select OLD_SIGACTION
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0128d84..1795eaa 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -156,7 +156,6 @@ config ARM64
select MULTI_IRQ_HANDLER
select NEED_DMA_MAP_STATE
select NEED_SG_DMA_LENGTH
-   select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
select OF_RESERVED_MEM
diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig
index 85ed568..a641b0b 100644
--- a/arch/c6x/Kconfig
+++ b/arch/c6x/Kconfig
@@ -14,7 +14,6 @@ config C6X
select GENERIC_IRQ_SHOW
select HAVE_ARCH_TRACEHOOK
select HAVE_MEMBLOCK
-   select NO_BOOTMEM
select SPARSE_IRQ
select IRQ_DOMAIN
select OF
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 0b334b6..5e89d40 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -16,7 +16,6 @@ config H8300
select OF_IRQ
select OF_EARLY_FLATTREE
select HAVE_MEMBLOCK
-   select NO_BOOTMEM
select TIMER_OF
select H8300_TMR8
select HAVE_KERNEL_GZIP
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 3ba6873..24a6da9 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -33,7 +33,6 @@ config HEXAGON
select GENERIC_CPU_DEVICES
select HAVE_MEMBLOCK
select ARCH_DISCARD_MEMBLOCK
-   select NO_BOOTMEM
---help---
  Qualcomm Hexagon is a processor architecture designed for high
  performance and low power across a wide variety of applications.
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 8b4a0c17..2bf4ef7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -28,7 +28,6 @@ config IA64
select HAVE_ARCH_TRACEHOOK
select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP
-   select NO_BOOTMEM
select HAVE_VIRT_CPU_ACCOUNTING
select ARCH_HAS_DMA_MARK_CLEAN
select ARCH_HAS_SG_CHAIN
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 0705537..8c7111d 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -29,7 +29,6 @@ config M68K
select DMA_NONCOHERENT_OPS if HAS_DMA
select HAVE_MEMBLOCK
select ARCH_DISCARD_MEMBLOCK
-   select NO_BOOTMEM
 
 config CPU_BIG_ENDIAN
def_bool y
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index ace5c5b..56379b9 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -28,7 +28,6 @@ config MICROBLAZE
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
-   

[PATCH 26/30] memblock: rename __free_pages_bootmem to memblock_free_pages

2018-09-14 Thread Mike Rapoport
The conversion is done using

sed -i 's@__free_pages_bootmem@memblock_free_pages@' \
$(git grep -l __free_pages_bootmem)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 mm/internal.h   | 2 +-
 mm/memblock.c   | 2 +-
 mm/nobootmem.c  | 2 +-
 mm/page_alloc.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/internal.h b/mm/internal.h
index 87256ae..291eb2b 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -161,7 +161,7 @@ static inline struct page *pageblock_pfn_to_page(unsigned 
long start_pfn,
 }
 
 extern int __isolate_free_page(struct page *page, unsigned int order);
-extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
+extern void memblock_free_pages(struct page *page, unsigned long pfn,
unsigned int order);
 extern void prep_compound_page(struct page *page, unsigned int order);
 extern void post_alloc_hook(struct page *page, unsigned int order,
diff --git a/mm/memblock.c b/mm/memblock.c
index 1534edb..a2cd61d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1615,7 +1615,7 @@ void __init __memblock_free_late(phys_addr_t base, 
phys_addr_t size)
end = PFN_DOWN(base + size);
 
for (; cursor < end; cursor++) {
-   __free_pages_bootmem(pfn_to_page(cursor), cursor, 0);
+   memblock_free_pages(pfn_to_page(cursor), cursor, 0);
totalram_pages++;
}
 }
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index bb64b09..9608bc5 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -43,7 +43,7 @@ static void __init __free_pages_memory(unsigned long start, 
unsigned long end)
while (start + (1UL << order) > end)
order--;
 
-   __free_pages_bootmem(pfn_to_page(start), start, order);
+   memblock_free_pages(pfn_to_page(start), start, order);
 
start += (1UL << order);
}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 13e394c..f4a8bc8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1334,7 +1334,7 @@ meminit_pfn_in_nid(unsigned long pfn, int node,
 #endif
 
 
-void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
+void __init memblock_free_pages(struct page *page, unsigned long pfn,
unsigned int order)
 {
if (early_page_uninitialised(pfn))
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 10/30] memblock: replace __alloc_bootmem_node_nopanic with memblock_alloc_try_nid_nopanic

2018-09-14 Thread Mike Rapoport
The __alloc_bootmem_node_nopanic() attempts to allocate memory for a
specified node. If the allocation fails it then retries to allocate memory
from any node. Upon success, the allocated memory is set to 0.

The memblock_alloc_try_nid_nopanic() does exactly the same thing and can be
used instead.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/x86/kernel/setup_percpu.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index ea554f8..67d48e26 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -112,8 +112,10 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, 
unsigned long size,
pr_debug("per cpu data for cpu%d %lu bytes at %016lx\n",
 cpu, size, __pa(ptr));
} else {
-   ptr = __alloc_bootmem_node_nopanic(NODE_DATA(node),
-  size, align, goal);
+   ptr = memblock_alloc_try_nid_nopanic(size, align, goal,
+BOOTMEM_ALLOC_ACCESSIBLE,
+node);
+
pr_debug("per cpu data for cpu%d %lu bytes on node%d at 
%016lx\n",
 cpu, size, node, __pa(ptr));
}
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 30/30] docs/boot-time-mm: remove bootmem documentation

2018-09-14 Thread Mike Rapoport
Signed-off-by: Mike Rapoport 
---
 Documentation/core-api/boot-time-mm.rst | 71 +
 1 file changed, 10 insertions(+), 61 deletions(-)

diff --git a/Documentation/core-api/boot-time-mm.rst 
b/Documentation/core-api/boot-time-mm.rst
index 03cb164..e5ec9f1 100644
--- a/Documentation/core-api/boot-time-mm.rst
+++ b/Documentation/core-api/boot-time-mm.rst
@@ -5,54 +5,23 @@ Boot time memory management
 Early system initialization cannot use "normal" memory management
 simply because it is not set up yet. But there is still need to
 allocate memory for various data structures, for instance for the
-physical page allocator. To address this, a specialized allocator
-called the :ref:`Boot Memory Allocator `, or bootmem, was
-introduced. Several years later PowerPC developers added a "Logical
-Memory Blocks" allocator, which was later adopted by other
-architectures and renamed to :ref:`memblock `. There is also
-a compatibility layer called `nobootmem` that translates bootmem
-allocation interfaces to memblock calls.
+physical page allocator.
 
-The selection of the early allocator is done using
-``CONFIG_NO_BOOTMEM`` and ``CONFIG_HAVE_MEMBLOCK`` kernel
-configuration options. These options are enabled or disabled
-statically by the architectures' Kconfig files.
-
-* Architectures that rely only on bootmem select
-  ``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=n``.
-* The users of memblock with the nobootmem compatibility layer set
-  ``CONFIG_NO_BOOTMEM=y && CONFIG_HAVE_MEMBLOCK=y``.
-* And for those that use both memblock and bootmem the configuration
-  includes ``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=y``.
-
-Whichever allocator is used, it is the responsibility of the
-architecture specific initialization to set it up in
-:c:func:`setup_arch` and tear it down in :c:func:`mem_init` functions.
+A specialized allocator called ``memblock`` performs the
+boot time memory management. The architecture specific initialization
+must set it up in :c:func:`setup_arch` and tear it down in
+:c:func:`mem_init` functions.
 
 Once the early memory management is available it offers a variety of
 functions and macros for memory allocations. The allocation request
 may be directed to the first (and probably the only) node or to a
 particular node in a NUMA system. There are API variants that panic
-when an allocation fails and those that don't. And more recent and
-advanced memblock even allows controlling its own behaviour.
-
-.. _bootmem:
-
-Bootmem
-===
-
-(mostly stolen from Mel Gorman's "Understanding the Linux Virtual
-Memory Manager" `book`_)
-
-.. _book: https://www.kernel.org/doc/gorman/
-
-.. kernel-doc:: mm/bootmem.c
-   :doc: bootmem overview
+when an allocation fails and those that don't.
 
-.. _memblock:
+Memblock also offers a variety of APIs that control its own behaviour.
 
-Memblock
-
+Memblock Overview
+=
 
 .. kernel-doc:: mm/memblock.c
:doc: memblock overview
@@ -61,26 +30,6 @@ Memblock
 Functions and structures
 
 
-Common API
---
-
-The functions that are described in this section are available
-regardless of what early memory manager is enabled.
-
-.. kernel-doc:: mm/nobootmem.c
-
-Bootmem specific API
-
-
-These interfaces available only with bootmem, i.e when ``CONFIG_NO_BOOTMEM=n``
-
-.. kernel-doc:: include/linux/bootmem.h
-.. kernel-doc:: mm/bootmem.c
-   :nodocs:
-
-Memblock specific API
--
-
 Here is the description of memblock data structures, functions and
 macros. Some of them are actually internal, but since they are
 documented it would be silly to omit them. Besides, reading the
@@ -89,4 +38,4 @@ really happens under the hood.
 
 .. kernel-doc:: include/linux/memblock.h
 .. kernel-doc:: mm/memblock.c
-   :nodocs:
+   :functions:
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 06/30] memblock: rename memblock_alloc{_nid, _try_nid} to memblock_phys_alloc*

2018-09-14 Thread Mike Rapoport
Make it explicit that the caller gets a physical address rather than a
virtual one.

This will also allow using meblock_alloc prefix for memblock allocations
returning virtual address, which is done in the following patches.

The conversion is done using the following semantic patch:

@@
expression e1, e2, e3;
@@
(
- memblock_alloc(e1, e2)
+ memblock_phys_alloc(e1, e2)
|
- memblock_alloc_nid(e1, e2, e3)
+ memblock_phys_alloc_nid(e1, e2, e3)
|
- memblock_alloc_try_nid(e1, e2, e3)
+ memblock_phys_alloc_try_nid(e1, e2, e3)
)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/arm/mm/mmu.c |  2 +-
 arch/arm64/mm/mmu.c   |  2 +-
 arch/arm64/mm/numa.c  |  2 +-
 arch/c6x/mm/dma-coherent.c|  4 ++--
 arch/nds32/mm/init.c  |  8 
 arch/openrisc/mm/init.c   |  2 +-
 arch/openrisc/mm/ioremap.c|  2 +-
 arch/powerpc/kernel/dt_cpu_ftrs.c |  4 +---
 arch/powerpc/kernel/paca.c|  2 +-
 arch/powerpc/kernel/prom.c|  2 +-
 arch/powerpc/kernel/setup-common.c|  3 +--
 arch/powerpc/kernel/setup_32.c| 10 +-
 arch/powerpc/mm/numa.c|  2 +-
 arch/powerpc/mm/pgtable_32.c  |  2 +-
 arch/powerpc/mm/ppc_mmu_32.c  |  2 +-
 arch/powerpc/platforms/pasemi/iommu.c |  2 +-
 arch/powerpc/platforms/powernv/opal.c |  2 +-
 arch/powerpc/sysdev/dart_iommu.c  |  2 +-
 arch/s390/kernel/crash_dump.c |  2 +-
 arch/s390/kernel/setup.c  |  3 ++-
 arch/s390/mm/vmem.c   |  4 ++--
 arch/s390/numa/numa.c |  2 +-
 arch/sparc/kernel/mdesc.c |  2 +-
 arch/sparc/kernel/prom_64.c   |  2 +-
 arch/sparc/mm/init_64.c   | 11 ++-
 arch/unicore32/mm/mmu.c   |  2 +-
 arch/x86/mm/numa.c|  2 +-
 drivers/firmware/efi/memmap.c |  2 +-
 include/linux/memblock.h  |  6 +++---
 mm/memblock.c |  8 
 30 files changed, 50 insertions(+), 51 deletions(-)

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index e46a6a4..f5cc1cc 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -721,7 +721,7 @@ EXPORT_SYMBOL(phys_mem_access_prot);
 
 static void __init *early_alloc_aligned(unsigned long sz, unsigned long align)
 {
-   void *ptr = __va(memblock_alloc(sz, align));
+   void *ptr = __va(memblock_phys_alloc(sz, align));
memset(ptr, 0, sz);
return ptr;
 }
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 8080c9f..b8e037b 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -83,7 +83,7 @@ static phys_addr_t __init early_pgtable_alloc(void)
phys_addr_t phys;
void *ptr;
 
-   phys = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
+   phys = memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE);
 
/*
 * The FIX_{PGD,PUD,PMD} slots may be in active use, but the FIX_PTE
diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
index 146c04c..e5aacd6 100644
--- a/arch/arm64/mm/numa.c
+++ b/arch/arm64/mm/numa.c
@@ -237,7 +237,7 @@ static void __init setup_node_data(int nid, u64 start_pfn, 
u64 end_pfn)
if (start_pfn >= end_pfn)
pr_info("Initmem setup node %d []\n", nid);
 
-   nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid);
+   nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid);
nd = __va(nd_pa);
 
/* report and initialize */
diff --git a/arch/c6x/mm/dma-coherent.c b/arch/c6x/mm/dma-coherent.c
index d0a8e0c..01305c7 100644
--- a/arch/c6x/mm/dma-coherent.c
+++ b/arch/c6x/mm/dma-coherent.c
@@ -135,8 +135,8 @@ void __init coherent_mem_init(phys_addr_t start, u32 size)
if (dma_size & (PAGE_SIZE - 1))
++dma_pages;
 
-   bitmap_phys = memblock_alloc(BITS_TO_LONGS(dma_pages) * sizeof(long),
-sizeof(long));
+   bitmap_phys = memblock_phys_alloc(BITS_TO_LONGS(dma_pages) * 
sizeof(long),
+ sizeof(long));
 
dma_bitmap = phys_to_virt(bitmap_phys);
memset(dma_bitmap, 0, dma_pages * PAGE_SIZE);
diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c
index c713d2a..5af81b8 100644
--- a/arch/nds32/mm/init.c
+++ b/arch/nds32/mm/init.c
@@ -81,7 +81,7 @@ static void __init map_ram(void)
}
 
/* Alloc one page for holding PTE's... */
-   pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
+   pte = (pte_t *) __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE));
memset(pte, 0, PAGE_SIZE);
set_pmd(pme, __pmd(__pa(pte) + _PAGE_KERNEL_TABLE));
 
@@ -114,7 +114,7 @@ static void __init fixedrange_init(void)
pgd = swapper_pg_dir + pgd_index(vaddr);
pud = pud_offset(pgd, vaddr);
pmd = pmd_offset(pud, vaddr);
-   fixmap_pmd_p = (pmd_t *) __va(memblock_alloc(PAGE_SIZ

[PATCH 25/30] memblock: rename free_all_bootmem to memblock_free_all

2018-09-14 Thread Mike Rapoport
The conversion is done using

sed -i 's@free_all_bootmem@memblock_free_all@' \
$(git grep -l free_all_bootmem)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/alpha/mm/init.c   | 2 +-
 arch/arc/mm/init.c | 2 +-
 arch/arm/mm/init.c | 2 +-
 arch/arm64/mm/init.c   | 2 +-
 arch/c6x/mm/init.c | 2 +-
 arch/h8300/mm/init.c   | 2 +-
 arch/hexagon/mm/init.c | 2 +-
 arch/ia64/mm/init.c| 2 +-
 arch/m68k/mm/init.c| 2 +-
 arch/microblaze/mm/init.c  | 2 +-
 arch/mips/loongson64/loongson-3/numa.c | 2 +-
 arch/mips/mm/init.c| 2 +-
 arch/mips/sgi-ip27/ip27-memory.c   | 2 +-
 arch/nds32/mm/init.c   | 2 +-
 arch/nios2/mm/init.c   | 2 +-
 arch/openrisc/mm/init.c| 2 +-
 arch/parisc/mm/init.c  | 2 +-
 arch/powerpc/mm/mem.c  | 2 +-
 arch/riscv/mm/init.c   | 2 +-
 arch/s390/mm/init.c| 2 +-
 arch/sh/mm/init.c  | 2 +-
 arch/sparc/mm/init_32.c| 2 +-
 arch/sparc/mm/init_64.c| 4 ++--
 arch/um/kernel/mem.c   | 2 +-
 arch/unicore32/mm/init.c   | 2 +-
 arch/x86/mm/highmem_32.c   | 2 +-
 arch/x86/mm/init_32.c  | 4 ++--
 arch/x86/mm/init_64.c  | 4 ++--
 arch/x86/xen/mmu_pv.c  | 2 +-
 arch/xtensa/mm/init.c  | 2 +-
 include/linux/bootmem.h| 2 +-
 mm/memblock.c  | 2 +-
 mm/nobootmem.c | 4 ++--
 mm/page_alloc.c| 2 +-
 mm/page_poison.c   | 2 +-
 35 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 9d74520..853d153 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -282,7 +282,7 @@ mem_init(void)
 {
set_max_mapnr(max_low_pfn);
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
-   free_all_bootmem();
+   memblock_free_all();
mem_init_print_info(NULL);
 }
 
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ba14506..0f29c65 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -218,7 +218,7 @@ void __init mem_init(void)
free_highmem_page(pfn_to_page(tmp));
 #endif
 
-   free_all_bootmem();
+   memblock_free_all();
mem_init_print_info(NULL);
 }
 
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 0cc8e04..d421a10 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -508,7 +508,7 @@ void __init mem_init(void)
 
/* this will put all unused low memory onto the freelists */
free_unused_memmap();
-   free_all_bootmem();
+   memblock_free_all();
 
 #ifdef CONFIG_SA
/* now that our DMA memory is actually so designated, we can free it */
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index e335452..ae21849 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -601,7 +601,7 @@ void __init mem_init(void)
free_unused_memmap();
 #endif
/* this will put all unused low memory onto the freelists */
-   free_all_bootmem();
+   memblock_free_all();
 
kexec_reserve_crashkres_pages();
 
diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c
index dc369ad..3383df8 100644
--- a/arch/c6x/mm/init.c
+++ b/arch/c6x/mm/init.c
@@ -62,7 +62,7 @@ void __init mem_init(void)
high_memory = (void *)(memory_end & PAGE_MASK);
 
/* this will put all memory onto the freelists */
-   free_all_bootmem();
+   memblock_free_all();
 
mem_init_print_info(NULL);
 }
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 5d31ac9..f2bf448 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -96,7 +96,7 @@ void __init mem_init(void)
max_mapnr = MAP_NR(high_memory);
 
/* this will put all low memory onto the freelists */
-   free_all_bootmem();
+   memblock_free_all();
 
mem_init_print_info(NULL);
 }
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index d789b9c..88643fa 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -68,7 +68,7 @@ unsigned long long kmap_generation;
 void __init mem_init(void)
 {
/*  No idea where this is actually declared.  Seems to evade LXR.  */
-   free_all_bootmem();
+   memblock_free_all();
mem_init_print_info(NULL);
 
/*
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 2169ca5..43ea4a4 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -627,7 +627,7 @@ mem_init (void)
 
set_max_mapnr(max_low_pfn);
high_memory = __va(max_low_pfn * PAGE_SIZE);
-   free_all_bootmem();
+   memblock_free_all();
mem_init_print_info(NULL);
 
/*

[PATCH 24/30] memblock: replace free_bootmem_late with memblock_free_late

2018-09-14 Thread Mike Rapoport
The free_bootmem_late and memblock_free_late do exactly the same thing:
they iterate over a range and give pages to the page allocator.

Replace calls to free_bootmem_late with calls to memblock_free_late and
remove the bootmem variant.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/sparc/kernel/mdesc.c   |  3 ++-
 arch/x86/platform/efi/quirks.c  |  6 +++---
 drivers/firmware/efi/apple-properties.c |  2 +-
 include/linux/bootmem.h |  2 --
 mm/nobootmem.c  | 24 
 5 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 59131e7..a41526b 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -190,7 +191,7 @@ static void __init mdesc_memblock_free(struct mdesc_handle 
*hp)
 
alloc_size = PAGE_ALIGN(hp->handle_size);
start = __pa(hp);
-   free_bootmem_late(start, alloc_size);
+   memblock_free_late(start, alloc_size);
 }
 
 static struct mdesc_mem_ops memblock_mdesc_ops = {
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 844d31c..7b4854c 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -332,7 +332,7 @@ void __init efi_reserve_boot_services(void)
 
/*
 * Because the following memblock_reserve() is paired
-* with free_bootmem_late() for this region in
+* with memblock_free_late() for this region in
 * efi_free_boot_services(), we must be extremely
 * careful not to reserve, and subsequently free,
 * critical regions of memory (like the kernel image) or
@@ -363,7 +363,7 @@ void __init efi_reserve_boot_services(void)
 * doesn't make sense as far as the firmware is
 * concerned, but it does provide us with a way to tag
 * those regions that must not be paired with
-* free_bootmem_late().
+* memblock_free_late().
 */
md->attribute |= EFI_MEMORY_RUNTIME;
}
@@ -413,7 +413,7 @@ void __init efi_free_boot_services(void)
size -= rm_size;
}
 
-   free_bootmem_late(start, size);
+   memblock_free_late(start, size);
}
 
if (!num_entries)
diff --git a/drivers/firmware/efi/apple-properties.c 
b/drivers/firmware/efi/apple-properties.c
index 60a9571..2b675f7 100644
--- a/drivers/firmware/efi/apple-properties.c
+++ b/drivers/firmware/efi/apple-properties.c
@@ -235,7 +235,7 @@ static int __init map_properties(void)
 */
data->len = 0;
memunmap(data);
-   free_bootmem_late(pa_data + sizeof(*data), data_len);
+   memblock_free_late(pa_data + sizeof(*data), data_len);
 
return ret;
}
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 706cf8e..bcc7e2f 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -30,8 +30,6 @@ extern unsigned long free_all_bootmem(void);
 extern void reset_node_managed_pages(pg_data_t *pgdat);
 extern void reset_all_zones_managed_pages(void);
 
-extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
-
 /* We are using top down, so it is safe to use 0 here */
 #define BOOTMEM_LOW_LIMIT 0
 
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 85e1822..ee0f7fc 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -33,30 +33,6 @@ unsigned long min_low_pfn;
 unsigned long max_pfn;
 unsigned long long max_possible_pfn;
 
-/**
- * free_bootmem_late - free bootmem pages directly to page allocator
- * @addr: starting address of the range
- * @size: size of the range in bytes
- *
- * This is only useful when the bootmem allocator has already been torn
- * down, but we are still initializing the system.  Pages are given directly
- * to the page allocator, no bootmem metadata is updated because it is gone.
- */
-void __init free_bootmem_late(unsigned long addr, unsigned long size)
-{
-   unsigned long cursor, end;
-
-   kmemleak_free_part_phys(addr, size);
-
-   cursor = PFN_UP(addr);
-   end = PFN_DOWN(addr + size);
-
-   for (; cursor < end; cursor++) {
-   __free_pages_bootmem(pfn_to_page(cursor), cursor, 0);
-   totalram_pages++;
-   }
-}
-
 static void __init __free_pages_memory(unsigned long start, unsigned long end)
 {
int order;
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 05/30] mm: nobootmem: remove dead code

2018-09-14 Thread Mike Rapoport
Several bootmem functions and macros are not used. Remove them.

Signed-off-by: Mike Rapoport 
---
 include/linux/bootmem.h | 26 --
 mm/nobootmem.c  | 35 ---
 2 files changed, 61 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index fce6278..b74bafd1 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -36,17 +36,6 @@ extern void free_bootmem_node(pg_data_t *pgdat,
 extern void free_bootmem(unsigned long physaddr, unsigned long size);
 extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
 
-/*
- * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
- * the architecture-specific code should honor this).
- *
- * If flags is BOOTMEM_DEFAULT, then the return value is always 0 (success).
- * If flags contains BOOTMEM_EXCLUSIVE, then -EBUSY is returned if the memory
- * already was reserved.
- */
-#define BOOTMEM_DEFAULT0
-#define BOOTMEM_EXCLUSIVE  (1<<0)
-
 extern void *__alloc_bootmem(unsigned long size,
 unsigned long align,
 unsigned long goal);
@@ -73,13 +62,6 @@ void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
 extern void *__alloc_bootmem_low(unsigned long size,
 unsigned long align,
 unsigned long goal) __malloc;
-void *__alloc_bootmem_low_nopanic(unsigned long size,
-unsigned long align,
-unsigned long goal) __malloc;
-extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
- unsigned long size,
- unsigned long align,
- unsigned long goal) __malloc;
 
 /* We are using top down, so it is safe to use 0 here */
 #define BOOTMEM_LOW_LIMIT 0
@@ -92,8 +74,6 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
__alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
 #define alloc_bootmem_align(x, align) \
__alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_nopanic(x) \
-   __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
 #define alloc_bootmem_pages(x) \
__alloc_bootmem(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
 #define alloc_bootmem_pages_nopanic(x) \
@@ -104,17 +84,11 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
__alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, 
BOOTMEM_LOW_LIMIT)
 #define alloc_bootmem_pages_node(pgdat, x) \
__alloc_bootmem_node(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
-#define alloc_bootmem_pages_node_nopanic(pgdat, x) \
-   __alloc_bootmem_node_nopanic(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
 
 #define alloc_bootmem_low(x) \
__alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
-#define alloc_bootmem_low_pages_nopanic(x) \
-   __alloc_bootmem_low_nopanic(x, PAGE_SIZE, 0)
 #define alloc_bootmem_low_pages(x) \
__alloc_bootmem_low(x, PAGE_SIZE, 0)
-#define alloc_bootmem_low_pages_node(pgdat, x) \
-   __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
 
 /* FIXME: use MEMBLOCK_ALLOC_* variants here */
 #define BOOTMEM_ALLOC_ACCESSIBLE   0
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index d4d0cd4..44ce7de 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -404,38 +404,3 @@ void * __init __alloc_bootmem_low(unsigned long size, 
unsigned long align,
 {
return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT);
 }
-
-void * __init __alloc_bootmem_low_nopanic(unsigned long size,
- unsigned long align,
- unsigned long goal)
-{
-   return ___alloc_bootmem_nopanic(size, align, goal,
-   ARCH_LOW_ADDRESS_LIMIT);
-}
-
-/**
- * __alloc_bootmem_low_node - allocate low boot memory from a specific node
- * @pgdat: node to allocate from
- * @size: size of the request in bytes
- * @align: alignment of the region
- * @goal: preferred starting address of the region
- *
- * The goal is dropped if it can not be satisfied and the allocation will
- * fall back to memory below @goal.
- *
- * Allocation may fall back to any node in the system if the specified node
- * can not hold the requested memory.
- *
- * The function panics if the request can not be satisfied.
- *
- * Return: address of the allocated region.
- */
-void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
-  unsigned long align, unsigned long goal)
-{
-   if (WARN_ON_ONCE(slab_is_available()))
-   return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
-
-   return ___alloc_bootmem_node(pgdat, size, align, goal,
-ARCH_LOW_ADDRESS_LIMIT);
-}
-- 
2.7.4


___
linux-snps-arc mailing list
linux-snps-a

[PATCH 04/30] mm: remove bootmem allocator implementation.

2018-09-14 Thread Mike Rapoport
All architectures have been converted to use MEMBLOCK + NO_BOOTMEM. The
bootmem allocator implementation can be removed.

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 include/linux/bootmem.h |  16 -
 mm/bootmem.c| 811 
 2 files changed, 827 deletions(-)
 delete mode 100644 mm/bootmem.c

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index ee61ac3..fce6278 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -26,14 +26,6 @@ extern unsigned long max_pfn;
  */
 extern unsigned long long max_possible_pfn;
 
-extern unsigned long bootmem_bootmap_pages(unsigned long);
-
-extern unsigned long init_bootmem_node(pg_data_t *pgdat,
-  unsigned long freepfn,
-  unsigned long startpfn,
-  unsigned long endpfn);
-extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
-
 extern unsigned long free_all_bootmem(void);
 extern void reset_node_managed_pages(pg_data_t *pgdat);
 extern void reset_all_zones_managed_pages(void);
@@ -55,14 +47,6 @@ extern void free_bootmem_late(unsigned long physaddr, 
unsigned long size);
 #define BOOTMEM_DEFAULT0
 #define BOOTMEM_EXCLUSIVE  (1<<0)
 
-extern int reserve_bootmem(unsigned long addr,
-  unsigned long size,
-  int flags);
-extern int reserve_bootmem_node(pg_data_t *pgdat,
-   unsigned long physaddr,
-   unsigned long size,
-   int flags);
-
 extern void *__alloc_bootmem(unsigned long size,
 unsigned long align,
 unsigned long goal);
diff --git a/mm/bootmem.c b/mm/bootmem.c
deleted file mode 100644
index 97db0e8..000
--- a/mm/bootmem.c
+++ /dev/null
@@ -1,811 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- *  bootmem - A boot-time physical memory allocator and configurator
- *
- *  Copyright (C) 1999 Ingo Molnar
- *1999 Kanoj Sarcar, SGI
- *2008 Johannes Weiner
- *
- * Access to this subsystem has to be serialized externally (which is true
- * for the boot process anyway).
- */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "internal.h"
-
-/**
- * DOC: bootmem overview
- *
- * Bootmem is a boot-time physical memory allocator and configurator.
- *
- * It is used early in the boot process before the page allocator is
- * set up.
- *
- * Bootmem is based on the most basic of allocators, a First Fit
- * allocator which uses a bitmap to represent memory. If a bit is 1,
- * the page is allocated and 0 if unallocated. To satisfy allocations
- * of sizes smaller than a page, the allocator records the Page Frame
- * Number (PFN) of the last allocation and the offset the allocation
- * ended at. Subsequent small allocations are merged together and
- * stored on the same page.
- *
- * The information used by the bootmem allocator is represented by
- * :c:type:`struct bootmem_data`. An array to hold up to %MAX_NUMNODES
- * such structures is statically allocated and then it is discarded
- * when the system initialization completes. Each entry in this array
- * corresponds to a node with memory. For UMA systems only entry 0 is
- * used.
- *
- * The bootmem allocator is initialized during early architecture
- * specific setup. Each architecture is required to supply a
- * :c:func:`setup_arch` function which, among other tasks, is
- * responsible for acquiring the necessary parameters to initialise
- * the boot memory allocator. These parameters define limits of usable
- * physical memory:
- *
- * * @min_low_pfn - the lowest PFN that is available in the system
- * * @max_low_pfn - the highest PFN that may be addressed by low
- *   memory (%ZONE_NORMAL)
- * * @max_pfn - the last PFN available to the system.
- *
- * After those limits are determined, the :c:func:`init_bootmem` or
- * :c:func:`init_bootmem_node` function should be called to initialize
- * the bootmem allocator. The UMA case should use the `init_bootmem`
- * function. It will initialize ``contig_page_data`` structure that
- * represents the only memory node in the system. In the NUMA case the
- * `init_bootmem_node` function should be called to initialize the
- * bootmem allocator for each node.
- *
- * Once the allocator is set up, it is possible to use either single
- * node or NUMA variant of the allocation APIs.
- */
-
-#ifndef CONFIG_NEED_MULTIPLE_NODES
-struct pglist_data __refdata contig_page_data = {
-   .bdata = &bootmem_node_data[0]
-};
-EXPORT_SYMBOL(contig_page_data);
-#endif
-
-unsigned long max_low_pfn;
-unsigned long min_low_pfn;
-unsigned long max_pfn;
-unsigned long long max_possible_pfn;
-
-bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
-
-static struct list_head bd

[PATCH 19/30] memblock: replace alloc_bootmem_pages with memblock_alloc

2018-09-14 Thread Mike Rapoport
The alloc_bootmem_pages() function allocates PAGE_SIZE aligned memory.
memblock_alloc() with alignment set to PAGE_SIZE does exactly the same
thing.

The conversion is done using the following semantic patch:

@@
expression e;
@@
- alloc_bootmem_pages(e)
+ memblock_alloc(e, PAGE_SIZE)

Signed-off-by: Mike Rapoport 
Acked-by: Michal Hocko 
---
 arch/c6x/mm/init.c | 3 ++-
 arch/h8300/mm/init.c   | 2 +-
 arch/m68k/mm/init.c| 2 +-
 arch/m68k/mm/mcfmmu.c  | 4 ++--
 arch/m68k/mm/motorola.c| 2 +-
 arch/m68k/mm/sun3mmu.c | 4 ++--
 arch/sh/mm/init.c  | 4 ++--
 arch/x86/kernel/apic/io_apic.c | 3 ++-
 arch/x86/mm/init_64.c  | 2 +-
 drivers/xen/swiotlb-xen.c  | 3 ++-
 10 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c
index 4cc72b0..dc369ad 100644
--- a/arch/c6x/mm/init.c
+++ b/arch/c6x/mm/init.c
@@ -38,7 +38,8 @@ void __init paging_init(void)
struct pglist_data *pgdat = NODE_DATA(0);
unsigned long zones_size[MAX_NR_ZONES] = {0, };
 
-   empty_zero_page  = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page  = (unsigned long) memblock_alloc(PAGE_SIZE,
+ PAGE_SIZE);
memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
/*
diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 015287a..5d31ac9 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -67,7 +67,7 @@ void __init paging_init(void)
 * Initialize the bad page table and bad page to point
 * to a couple of allocated pages.
 */
-   empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page = (unsigned long)memblock_alloc(PAGE_SIZE, PAGE_SIZE);
memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
/*
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 38e2b27..977363e 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -93,7 +93,7 @@ void __init paging_init(void)
 
high_memory = (void *) end_mem;
 
-   empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
 
/*
 * Set up SFC/DFC registers (user data space).
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index f5453d9..38a1d92 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -44,7 +44,7 @@ void __init paging_init(void)
enum zone_type zone;
int i;
 
-   empty_zero_page = (void *) alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page = (void *) memblock_alloc(PAGE_SIZE, PAGE_SIZE);
memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
pg_dir = swapper_pg_dir;
@@ -52,7 +52,7 @@ void __init paging_init(void)
 
size = num_pages * sizeof(pte_t);
size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
-   next_pgtable = (unsigned long) alloc_bootmem_pages(size);
+   next_pgtable = (unsigned long) memblock_alloc(size, PAGE_SIZE);
 
bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
pg_dir += PAGE_OFFSET >> PGDIR_SHIFT;
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 8bcf57e..2113eec 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -276,7 +276,7 @@ void __init paging_init(void)
 * initialize the bad page table and bad page to point
 * to a couple of allocated pages
 */
-   empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
 
/*
 * Set up SFC/DFC registers
diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
index 4a99799..19c05ab 100644
--- a/arch/m68k/mm/sun3mmu.c
+++ b/arch/m68k/mm/sun3mmu.c
@@ -45,7 +45,7 @@ void __init paging_init(void)
unsigned long zones_size[MAX_NR_ZONES] = { 0, };
unsigned long size;
 
-   empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
+   empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
 
address = PAGE_OFFSET;
pg_dir = swapper_pg_dir;
@@ -55,7 +55,7 @@ void __init paging_init(void)
size = num_pages * sizeof(pte_t);
size = (size + PAGE_SIZE) & ~(PAGE_SIZE-1);
 
-   next_pgtable = (unsigned long)alloc_bootmem_pages(size);
+   next_pgtable = (unsigned long)memblock_alloc(size, PAGE_SIZE);
bootmem_end = (next_pgtable + size + PAGE_SIZE) & PAGE_MASK;
 
/* Map whole memory from PAGE_OFFSET (0x0E00) */
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 7713c08..c884b76 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -128,7 +128,7 @@ static pmd_t * __init one_md_table_init(pud_t *pud)
if (pud_none(*pud)) {
pmd_t *pmd;
 
-   pmd = alloc_bootmem_pages(PAGE_SIZE);
+   pmd = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
pud_populate(&init_mm, pud, pmd);
   

[PATCH 03/30] mm: remove CONFIG_HAVE_MEMBLOCK

2018-09-14 Thread Mike Rapoport
All architecures use memblock for early memory management. There is no need
for the CONFIG_HAVE_MEMBLOCK configuration option.

Signed-off-by: Mike Rapoport 
---
 arch/alpha/Kconfig  |   1 -
 arch/arc/Kconfig|   1 -
 arch/arm/Kconfig|   1 -
 arch/arm64/Kconfig  |   1 -
 arch/c6x/Kconfig|   1 -
 arch/h8300/Kconfig  |   1 -
 arch/hexagon/Kconfig|   1 -
 arch/ia64/Kconfig   |   1 -
 arch/m68k/Kconfig   |   1 -
 arch/microblaze/Kconfig |   1 -
 arch/mips/Kconfig   |   1 -
 arch/nds32/Kconfig  |   1 -
 arch/nios2/Kconfig  |   1 -
 arch/openrisc/Kconfig   |   1 -
 arch/parisc/Kconfig |   1 -
 arch/powerpc/Kconfig|   1 -
 arch/riscv/Kconfig  |   1 -
 arch/s390/Kconfig   |   1 -
 arch/sh/Kconfig |   1 -
 arch/sparc/Kconfig  |   1 -
 arch/um/Kconfig |   1 -
 arch/unicore32/Kconfig  |   1 -
 arch/x86/Kconfig|   1 -
 arch/xtensa/Kconfig |   1 -
 drivers/of/fdt.c|   2 -
 drivers/of/of_reserved_mem.c|  13 +
 drivers/staging/android/ion/Kconfig |   2 +-
 fs/pstore/Kconfig   |   1 -
 include/linux/bootmem.h | 112 
 include/linux/memblock.h|   2 -
 include/linux/mm.h  |   2 +-
 lib/Kconfig.debug   |   3 +-
 mm/Kconfig  |   5 +-
 mm/Makefile |   2 +-
 mm/nobootmem.c  |   4 --
 mm/page_alloc.c |   4 +-
 36 files changed, 8 insertions(+), 168 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 04de6be..5b4f883 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -31,7 +31,6 @@ config ALPHA
select ODD_RT_SIGACTION
select OLD_SIGSUSPEND
select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67
-   select HAVE_MEMBLOCK
help
  The Alpha is a 64-bit general-purpose processor designed and
  marketed by the Digital Equipment Corporation of blessed memory,
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 04ebead..5260440 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -37,7 +37,6 @@ config ARC
select HAVE_KERNEL_LZMA
select HAVE_KPROBES
select HAVE_KRETPROBES
-   select HAVE_MEMBLOCK
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_OPROFILE
select HAVE_PERF_EVENTS
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a961d70..33f4653 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -82,7 +82,6 @@ config ARM
select HAVE_KERNEL_XZ
select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
select HAVE_KRETPROBES if (HAVE_KPROBES)
-   select HAVE_MEMBLOCK
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_NMI
select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1795eaa..23ae619 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -134,7 +134,6 @@ config ARM64
select HAVE_GENERIC_DMA_COHERENT
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
-   select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP if NUMA
select HAVE_NMI
select HAVE_PATA_PLATFORM
diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig
index a641b0b..833fdb0 100644
--- a/arch/c6x/Kconfig
+++ b/arch/c6x/Kconfig
@@ -13,7 +13,6 @@ config C6X
select GENERIC_ATOMIC64
select GENERIC_IRQ_SHOW
select HAVE_ARCH_TRACEHOOK
-   select HAVE_MEMBLOCK
select SPARSE_IRQ
select IRQ_DOMAIN
select OF
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 5e89d40..d19c6b16 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -15,7 +15,6 @@ config H8300
select OF
select OF_IRQ
select OF_EARLY_FLATTREE
-   select HAVE_MEMBLOCK
select TIMER_OF
select H8300_TMR8
select HAVE_KERNEL_GZIP
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 24a6da9..d9ae82b 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -31,7 +31,6 @@ config HEXAGON
select GENERIC_CLOCKEVENTS_BROADCAST
select MODULES_USE_ELF_RELA
select GENERIC_CPU_DEVICES
-   select HAVE_MEMBLOCK
select ARCH_DISCARD_MEMBLOCK
---help---
  Qualcomm Hexagon is a processor architecture designed for high
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 2bf4ef7..36773de 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -26,7 +26,6 @@ config IA64
select HAVE_FUNCTION_TRACER
select TTY
select HAVE_ARCH_TRACEHOOK
- 

[PATCH 01/30] mips: switch to NO_BOOTMEM

2018-09-14 Thread Mike Rapoport
MIPS already has memblock support and all the memory is already registered
with it.

This patch replaces bootmem memory reservations with memblock ones and
removes the bootmem initialization.

Since memblock allocates memory in top-down mode, we ensure that memblock
limit is max_low_pfn to prevent allocations from the high memory.

To have the exceptions base in the lower 512M of the physical memory, its
allocation in arch/mips/kernel/traps.c::traps_init() is using bottom-up
mode.

Signed-off-by: Mike Rapoport 
---
 arch/mips/Kconfig  |  1 +
 arch/mips/kernel/setup.c   | 99 --
 arch/mips/kernel/traps.c   |  3 ++
 arch/mips/loongson64/loongson-3/numa.c | 34 ++--
 arch/mips/sgi-ip27/ip27-memory.c   | 11 ++--
 5 files changed, 46 insertions(+), 102 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 54532f2..1b5fa1a 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -78,6 +78,7 @@ config MIPS
select RTC_LIB
select SYSCTL_EXCEPTION_TRACE
select VIRT_TO_BUS
+   select NO_BOOTMEM
 
 menu "Machine selection"
 
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 32fc11d..2fde53e 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -333,7 +333,7 @@ static void __init finalize_initrd(void)
 
maybe_bswap_initrd();
 
-   reserve_bootmem(__pa(initrd_start), size, BOOTMEM_DEFAULT);
+   memblock_reserve(__pa(initrd_start), size);
initrd_below_start_ok = 1;
 
pr_info("Initial ramdisk at: 0x%lx (%lu bytes)\n",
@@ -370,20 +370,10 @@ static void __init bootmem_init(void)
 
 #else  /* !CONFIG_SGI_IP27 */
 
-static unsigned long __init bootmap_bytes(unsigned long pages)
-{
-   unsigned long bytes = DIV_ROUND_UP(pages, 8);
-
-   return ALIGN(bytes, sizeof(long));
-}
-
 static void __init bootmem_init(void)
 {
unsigned long reserved_end;
-   unsigned long mapstart = ~0UL;
-   unsigned long bootmap_size;
phys_addr_t ramstart = PHYS_ADDR_MAX;
-   bool bootmap_valid = false;
int i;
 
/*
@@ -395,6 +385,8 @@ static void __init bootmem_init(void)
init_initrd();
reserved_end = (unsigned long) PFN_UP(__pa_symbol(&_end));
 
+   memblock_reserve(PHYS_OFFSET, reserved_end << PAGE_SHIFT);
+
/*
 * max_low_pfn is not a number of pages. The number of pages
 * of the system is given by 'max_low_pfn - min_low_pfn'.
@@ -442,9 +434,6 @@ static void __init bootmem_init(void)
if (initrd_end && end <= (unsigned 
long)PFN_UP(__pa(initrd_end)))
continue;
 #endif
-   if (start >= mapstart)
-   continue;
-   mapstart = max(reserved_end, start);
}
 
if (min_low_pfn >= max_low_pfn)
@@ -456,9 +445,11 @@ static void __init bootmem_init(void)
/*
 * Reserve any memory between the start of RAM and PHYS_OFFSET
 */
-   if (ramstart > PHYS_OFFSET)
+   if (ramstart > PHYS_OFFSET) {
add_memory_region(PHYS_OFFSET, ramstart - PHYS_OFFSET,
  BOOT_MEM_RESERVED);
+   memblock_reserve(PHYS_OFFSET, ramstart - PHYS_OFFSET);
+   }
 
if (min_low_pfn > ARCH_PFN_OFFSET) {
pr_info("Wasting %lu bytes for tracking %lu unused pages\n",
@@ -483,52 +474,6 @@ static void __init bootmem_init(void)
max_low_pfn = PFN_DOWN(HIGHMEM_START);
}
 
-#ifdef CONFIG_BLK_DEV_INITRD
-   /*
-* mapstart should be after initrd_end
-*/
-   if (initrd_end)
-   mapstart = max(mapstart, (unsigned 
long)PFN_UP(__pa(initrd_end)));
-#endif
-
-   /*
-* check that mapstart doesn't overlap with any of
-* memory regions that have been reserved through eg. DTB
-*/
-   bootmap_size = bootmap_bytes(max_low_pfn - min_low_pfn);
-
-   bootmap_valid = memory_region_available(PFN_PHYS(mapstart),
-   bootmap_size);
-   for (i = 0; i < boot_mem_map.nr_map && !bootmap_valid; i++) {
-   unsigned long mapstart_addr;
-
-   switch (boot_mem_map.map[i].type) {
-   case BOOT_MEM_RESERVED:
-   mapstart_addr = PFN_ALIGN(boot_mem_map.map[i].addr +
-   boot_mem_map.map[i].size);
-   if (PHYS_PFN(mapstart_addr) < mapstart)
-   break;
-
-   bootmap_valid = memory_region_available(mapstart_addr,
-   bootmap_size);
-   if (bootmap_valid)
-   mapstart = PHYS_PFN(mapstart_addr);
-   break;
-   default:
-   break;
-   }
-   }
-
-   if (!boo

Re: [PATCH] drm/etnaviv: add DMA configuration for etnaviv platform device

2018-09-14 Thread Eugeniy Paltsev
Hi Lucas,

On Fri, 2018-09-14 at 11:24 +0200, Lucas Stach wrote:
> The etnaviv device is a virtual device backing the DRM device, which may
> drive multiple hardware GPU core devies. As most of the dma-mapping handling
> is done through the virtual device, we need to make sure that a proper DMA
> setup is in place. The easiest way to get a reasonable configuration is
> to let the virtual device share the DMA configuration with one of the GPU
> devices, so call of_dma_configure() with the right parameters manually.
> 
> This assumes that all etnaviv driven GPU devices in the system share the
> same DMA configuration. If we ever encounter a SoC where the GPUs are on
> busses with different offsets or behind different IOMMUs that will require
> much deeper changes to the driver, as we would need to implement etnaviv
> specific versions of most of the DRM helper functions.
> 
> For now we should be fine with this solution.

This works fine on HSDK, thanks!

Tested-By: Eugeniy Paltsev 

> 
> Signed-off-by: Lucas Stach 
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 27 +--
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
> b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 9b2720b41571..83c1f46670bf 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -592,8 +592,6 @@ static int etnaviv_pdev_probe(struct platform_device 
> *pdev)
>   struct device *dev = &pdev->dev;
>   struct component_match *match = NULL;
>  
> - dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> -
>   if (!dev->platform_data) {
>   struct device_node *core_node;
>  
> @@ -655,13 +653,30 @@ static int __init etnaviv_init(void)
>   for_each_compatible_node(np, NULL, "vivante,gc") {
>   if (!of_device_is_available(np))
>   continue;
> - pdev = platform_device_register_simple("etnaviv", -1,
> -NULL, 0);
> - if (IS_ERR(pdev)) {
> - ret = PTR_ERR(pdev);
> +
> + pdev = platform_device_alloc("etnaviv", -1);
> + if (!pdev) {
> + ret = -ENOMEM;
> + of_node_put(np);
> + goto unregister_platform_driver;
> + }
> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40);
> + pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
> +
> + /*
> +  * Apply the same DMA configuration to the virtual etnaviv
> +  * device as the GPU we found. This assumes that all Vivante
> +  * GPUs in the system share the same DMA constraints.
> +  */
> + of_dma_configure(&pdev->dev, np, true);
> +
> + ret = platform_device_add(pdev);
> + if (ret) {
> + platform_device_put(pdev);
>   of_node_put(np);
>   goto unregister_platform_driver;
>   }
> +
>   etnaviv_drm = pdev;
>   of_node_put(np);
>   break;
-- 
 Eugeniy Paltsev
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] ARC: fix spelling mistake "entires" -> "entries"

2018-09-14 Thread Vineet Gupta
On 09/14/2018 04:27 AM, Colin King wrote:
> From: Colin Ian King 
>
> Trivial fix to spelling mistake in Kconfig
>
> Signed-off-by: Colin Ian King 

Applied !

Thx,
-Vineet

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc