diff options
Diffstat (limited to 'arch/powerpc/kernel/prom.c')
-rw-r--r-- | arch/powerpc/kernel/prom.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index d50c8df0183e..82d117c60d7f 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -491,7 +491,12 @@ void __init finish_device_tree(void) | |||
491 | size = 16; | 491 | size = 16; |
492 | finish_node(allnodes, &size, 1); | 492 | finish_node(allnodes, &size, 1); |
493 | size -= 16; | 493 | size -= 16; |
494 | end = start = (unsigned long) __va(lmb_alloc(size, 128)); | 494 | |
495 | if (0 == size) | ||
496 | end = start = 0; | ||
497 | else | ||
498 | end = start = (unsigned long)__va(lmb_alloc(size, 128)); | ||
499 | |||
495 | finish_node(allnodes, &end, 0); | 500 | finish_node(allnodes, &end, 0); |
496 | BUG_ON(end != start + size); | 501 | BUG_ON(end != start + size); |
497 | 502 | ||
@@ -826,10 +831,6 @@ void __init unflatten_device_tree(void) | |||
826 | 831 | ||
827 | /* Allocate memory for the expanded device tree */ | 832 | /* Allocate memory for the expanded device tree */ |
828 | mem = lmb_alloc(size + 4, __alignof__(struct device_node)); | 833 | mem = lmb_alloc(size + 4, __alignof__(struct device_node)); |
829 | if (!mem) { | ||
830 | DBG("Couldn't allocate memory with lmb_alloc()!\n"); | ||
831 | panic("Couldn't allocate memory with lmb_alloc()!\n"); | ||
832 | } | ||
833 | mem = (unsigned long) __va(mem); | 834 | mem = (unsigned long) __va(mem); |
834 | 835 | ||
835 | ((u32 *)mem)[size / 4] = 0xdeadbeef; | 836 | ((u32 *)mem)[size / 4] = 0xdeadbeef; |
@@ -1398,8 +1399,8 @@ struct device_node *of_find_node_by_name(struct device_node *from, | |||
1398 | 1399 | ||
1399 | read_lock(&devtree_lock); | 1400 | read_lock(&devtree_lock); |
1400 | np = from ? from->allnext : allnodes; | 1401 | np = from ? from->allnext : allnodes; |
1401 | for (; np != 0; np = np->allnext) | 1402 | for (; np != NULL; np = np->allnext) |
1402 | if (np->name != 0 && strcasecmp(np->name, name) == 0 | 1403 | if (np->name != NULL && strcasecmp(np->name, name) == 0 |
1403 | && of_node_get(np)) | 1404 | && of_node_get(np)) |
1404 | break; | 1405 | break; |
1405 | if (from) | 1406 | if (from) |
@@ -1917,3 +1918,30 @@ int prom_update_property(struct device_node *np, | |||
1917 | 1918 | ||
1918 | return 0; | 1919 | return 0; |
1919 | } | 1920 | } |
1921 | |||
1922 | #ifdef CONFIG_KEXEC | ||
1923 | /* We may have allocated the flat device tree inside the crash kernel region | ||
1924 | * in prom_init. If so we need to move it out into regular memory. */ | ||
1925 | void kdump_move_device_tree(void) | ||
1926 | { | ||
1927 | unsigned long start, end; | ||
1928 | struct boot_param_header *new; | ||
1929 | |||
1930 | start = __pa((unsigned long)initial_boot_params); | ||
1931 | end = start + initial_boot_params->totalsize; | ||
1932 | |||
1933 | if (end < crashk_res.start || start > crashk_res.end) | ||
1934 | return; | ||
1935 | |||
1936 | new = (struct boot_param_header*) | ||
1937 | __va(lmb_alloc(initial_boot_params->totalsize, PAGE_SIZE)); | ||
1938 | |||
1939 | memcpy(new, initial_boot_params, initial_boot_params->totalsize); | ||
1940 | |||
1941 | initial_boot_params = new; | ||
1942 | |||
1943 | DBG("Flat device tree blob moved to %p\n", initial_boot_params); | ||
1944 | |||
1945 | /* XXX should we unreserve the old DT? */ | ||
1946 | } | ||
1947 | #endif /* CONFIG_KEXEC */ | ||