Commit 3f5f8596 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'sh-for-4.17-fixes' of git://git.libc.org/linux-sh

Pull arch/sh fixes from Rich Felker:
 "Fixes for critical regressions and a build failure.

  The regressions were introduced in 4.15 and 4.17-rc1 and prevented
  booting on affected systems"

* tag 'sh-for-4.17-fixes' of git://git.libc.org/linux-sh:
  sh: switch to NO_BOOTMEM
  sh: mm: Fix unprotected access to struct device
  sh: fix build failure for J2 cpu with SMP disabled
parents 7404bc27 ac21fc2d
...@@ -9,6 +9,7 @@ config SUPERH ...@@ -9,6 +9,7 @@ config SUPERH
select HAVE_IDE if HAS_IOPORT_MAP select HAVE_IDE if HAS_IOPORT_MAP
select HAVE_MEMBLOCK select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP select HAVE_MEMBLOCK_NODE_MAP
select NO_BOOTMEM
select ARCH_DISCARD_MEMBLOCK select ARCH_DISCARD_MEMBLOCK
select HAVE_OPROFILE select HAVE_OPROFILE
select HAVE_GENERIC_DMA_COHERENT select HAVE_GENERIC_DMA_COHERENT
......
...@@ -43,7 +43,11 @@ void __ref cpu_probe(void) ...@@ -43,7 +43,11 @@ void __ref cpu_probe(void)
#endif #endif
#if defined(CONFIG_CPU_J2) #if defined(CONFIG_CPU_J2)
#if defined(CONFIG_SMP)
unsigned cpu = hard_smp_processor_id(); unsigned cpu = hard_smp_processor_id();
#else
unsigned cpu = 0;
#endif
if (cpu == 0) of_scan_flat_dt(scan_cache, NULL); if (cpu == 0) of_scan_flat_dt(scan_cache, NULL);
if (j2_ccr_base) __raw_writel(0x80000303, j2_ccr_base + 4*cpu); if (j2_ccr_base) __raw_writel(0x80000303, j2_ccr_base + 4*cpu);
if (cpu != 0) return; if (cpu != 0) return;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/bootmem.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/root_dev.h> #include <linux/root_dev.h>
#include <linux/utsname.h> #include <linux/utsname.h>
......
...@@ -59,7 +59,9 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size, ...@@ -59,7 +59,9 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order); split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order);
*dma_handle = virt_to_phys(ret) - PFN_PHYS(dev->dma_pfn_offset); *dma_handle = virt_to_phys(ret);
if (!WARN_ON(!dev))
*dma_handle -= PFN_PHYS(dev->dma_pfn_offset);
return ret_nocache; return ret_nocache;
} }
...@@ -69,9 +71,12 @@ void dma_generic_free_coherent(struct device *dev, size_t size, ...@@ -69,9 +71,12 @@ void dma_generic_free_coherent(struct device *dev, size_t size,
unsigned long attrs) unsigned long attrs)
{ {
int order = get_order(size); int order = get_order(size);
unsigned long pfn = (dma_handle >> PAGE_SHIFT) + dev->dma_pfn_offset; unsigned long pfn = dma_handle >> PAGE_SHIFT;
int k; int k;
if (!WARN_ON(!dev))
pfn += dev->dma_pfn_offset;
for (k = 0; k < (1 << order); k++) for (k = 0; k < (1 << order); k++)
__free_pages(pfn_to_page(pfn + k), 0); __free_pages(pfn_to_page(pfn + k), 0);
...@@ -143,7 +148,7 @@ int __init platform_resource_setup_memory(struct platform_device *pdev, ...@@ -143,7 +148,7 @@ int __init platform_resource_setup_memory(struct platform_device *pdev,
if (!memsize) if (!memsize)
return 0; return 0;
buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL); buf = dma_alloc_coherent(&pdev->dev, memsize, &dma_handle, GFP_KERNEL);
if (!buf) { if (!buf) {
pr_warning("%s: unable to allocate memory\n", name); pr_warning("%s: unable to allocate memory\n", name);
return -ENOMEM; return -ENOMEM;
......
...@@ -211,59 +211,15 @@ void __init allocate_pgdat(unsigned int nid) ...@@ -211,59 +211,15 @@ void __init allocate_pgdat(unsigned int nid)
NODE_DATA(nid) = __va(phys); NODE_DATA(nid) = __va(phys);
memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
#endif #endif
NODE_DATA(nid)->node_start_pfn = start_pfn; NODE_DATA(nid)->node_start_pfn = start_pfn;
NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
} }
static void __init bootmem_init_one_node(unsigned int nid)
{
unsigned long total_pages, paddr;
unsigned long end_pfn;
struct pglist_data *p;
p = NODE_DATA(nid);
/* Nothing to do.. */
if (!p->node_spanned_pages)
return;
end_pfn = pgdat_end_pfn(p);
total_pages = bootmem_bootmap_pages(p->node_spanned_pages);
paddr = memblock_alloc(total_pages << PAGE_SHIFT, PAGE_SIZE);
if (!paddr)
panic("Can't allocate bootmap for nid[%d]\n", nid);
init_bootmem_node(p, paddr >> PAGE_SHIFT, p->node_start_pfn, end_pfn);
free_bootmem_with_active_regions(nid, end_pfn);
/*
* XXX Handle initial reservations for the system memory node
* only for the moment, we'll refactor this later for handling
* reservations in other nodes.
*/
if (nid == 0) {
struct memblock_region *reg;
/* Reserve the sections we're already using. */
for_each_memblock(reserved, reg) {
reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
}
}
sparse_memory_present_with_active_regions(nid);
}
static void __init do_init_bootmem(void) static void __init do_init_bootmem(void)
{ {
struct memblock_region *reg; struct memblock_region *reg;
int i;
/* Add active regions with valid PFNs. */ /* Add active regions with valid PFNs. */
for_each_memblock(memory, reg) { for_each_memblock(memory, reg) {
...@@ -279,9 +235,12 @@ static void __init do_init_bootmem(void) ...@@ -279,9 +235,12 @@ static void __init do_init_bootmem(void)
plat_mem_setup(); plat_mem_setup();
for_each_online_node(i) for_each_memblock(memory, reg) {
bootmem_init_one_node(i); int nid = memblock_get_region_node(reg);
memory_present(nid, memblock_region_memory_base_pfn(reg),
memblock_region_memory_end_pfn(reg));
}
sparse_init(); sparse_init();
} }
...@@ -322,7 +281,6 @@ void __init paging_init(void) ...@@ -322,7 +281,6 @@ void __init paging_init(void)
{ {
unsigned long max_zone_pfns[MAX_NR_ZONES]; unsigned long max_zone_pfns[MAX_NR_ZONES];
unsigned long vaddr, end; unsigned long vaddr, end;
int nid;
sh_mv.mv_mem_init(); sh_mv.mv_mem_init();
...@@ -377,21 +335,7 @@ void __init paging_init(void) ...@@ -377,21 +335,7 @@ void __init paging_init(void)
kmap_coherent_init(); kmap_coherent_init();
memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
for_each_online_node(nid) {
pg_data_t *pgdat = NODE_DATA(nid);
unsigned long low, start_pfn;
start_pfn = pgdat->bdata->node_min_pfn;
low = pgdat->bdata->node_low_pfn;
if (max_zone_pfns[ZONE_NORMAL] < low)
max_zone_pfns[ZONE_NORMAL] = low;
printk("Node %u: start_pfn = 0x%lx, low = 0x%lx\n",
nid, start_pfn, low);
}
free_area_init_nodes(max_zone_pfns); free_area_init_nodes(max_zone_pfns);
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
* for more details. * for more details.
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/bootmem.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/numa.h> #include <linux/numa.h>
...@@ -26,9 +25,7 @@ EXPORT_SYMBOL_GPL(node_data); ...@@ -26,9 +25,7 @@ EXPORT_SYMBOL_GPL(node_data);
*/ */
void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end) void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
{ {
unsigned long bootmap_pages;
unsigned long start_pfn, end_pfn; unsigned long start_pfn, end_pfn;
unsigned long bootmem_paddr;
/* Don't allow bogus node assignment */ /* Don't allow bogus node assignment */
BUG_ON(nid >= MAX_NUMNODES || nid <= 0); BUG_ON(nid >= MAX_NUMNODES || nid <= 0);
...@@ -48,25 +45,9 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end) ...@@ -48,25 +45,9 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
SMP_CACHE_BYTES, end)); SMP_CACHE_BYTES, end));
memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
NODE_DATA(nid)->node_start_pfn = start_pfn; NODE_DATA(nid)->node_start_pfn = start_pfn;
NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
/* Node-local bootmap */
bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
bootmem_paddr = memblock_alloc_base(bootmap_pages << PAGE_SHIFT,
PAGE_SIZE, end);
init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
start_pfn, end_pfn);
free_bootmem_with_active_regions(nid, end_pfn);
/* Reserve the pgdat and bootmap space with the bootmem allocator */
reserve_bootmem_node(NODE_DATA(nid), start_pfn << PAGE_SHIFT,
sizeof(struct pglist_data), BOOTMEM_DEFAULT);
reserve_bootmem_node(NODE_DATA(nid), bootmem_paddr,
bootmap_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
/* It's up */ /* It's up */
node_set_online(nid); node_set_online(nid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment