Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/irq: use memblock functions returning virtual address

Since only the virtual address of allocated blocks is used,
lets use functions returning directly virtual address.

Those functions have the advantage of also zeroing the block.

Suggested-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Christophe Leroy and committed by
Michael Ellerman
c8e409a3 eafd825e

+23 -27
-5
arch/powerpc/kernel/irq.c
··· 725 725 #endif 726 726 #endif 727 727 728 - memset((void *)critirq_ctx[cpu_nr], 0, THREAD_SIZE); 729 728 tp = critirq_ctx[cpu_nr]; 730 729 tp->cpu = cpu_nr; 731 730 tp->preempt_count = 0; 732 731 733 732 #ifdef CONFIG_BOOKE 734 - memset((void *)dbgirq_ctx[cpu_nr], 0, THREAD_SIZE); 735 733 tp = dbgirq_ctx[cpu_nr]; 736 734 tp->cpu = cpu_nr; 737 735 tp->preempt_count = 0; 738 736 739 - memset((void *)mcheckirq_ctx[cpu_nr], 0, THREAD_SIZE); 740 737 tp = mcheckirq_ctx[cpu_nr]; 741 738 tp->cpu = cpu_nr; 742 739 tp->preempt_count = HARDIRQ_OFFSET; ··· 751 754 int i; 752 755 753 756 for_each_possible_cpu(i) { 754 - memset((void *)softirq_ctx[i], 0, THREAD_SIZE); 755 757 tp = softirq_ctx[i]; 756 758 tp->cpu = i; 757 759 klp_init_thread_info(tp); 758 760 759 - memset((void *)hardirq_ctx[i], 0, THREAD_SIZE); 760 761 tp = hardirq_ctx[i]; 761 762 tp->cpu = i; 762 763 klp_init_thread_info(tp);
+16 -10
arch/powerpc/kernel/setup_32.c
··· 196 196 } 197 197 arch_initcall(ppc_init); 198 198 199 + static void *__init alloc_stack(void) 200 + { 201 + void *ptr = memblock_alloc(THREAD_SIZE, THREAD_SIZE); 202 + 203 + if (!ptr) 204 + panic("cannot allocate %d bytes for stack at %pS\n", 205 + THREAD_SIZE, (void *)_RET_IP_); 206 + 207 + return ptr; 208 + } 209 + 199 210 void __init irqstack_early_init(void) 200 211 { 201 212 unsigned int i; ··· 214 203 /* interrupt stacks must be in lowmem, we get that for free on ppc32 215 204 * as the memblock is limited to lowmem by default */ 216 205 for_each_possible_cpu(i) { 217 - softirq_ctx[i] = (struct thread_info *) 218 - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); 219 - hardirq_ctx[i] = (struct thread_info *) 220 - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); 206 + softirq_ctx[i] = alloc_stack(); 207 + hardirq_ctx[i] = alloc_stack(); 221 208 } 222 209 } 223 210 ··· 233 224 hw_cpu = 0; 234 225 #endif 235 226 236 - critirq_ctx[hw_cpu] = (struct thread_info *) 237 - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); 227 + critirq_ctx[hw_cpu] = alloc_stack(); 238 228 #ifdef CONFIG_BOOKE 239 - dbgirq_ctx[hw_cpu] = (struct thread_info *) 240 - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); 241 - mcheckirq_ctx[hw_cpu] = (struct thread_info *) 242 - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); 229 + dbgirq_ctx[hw_cpu] = alloc_stack(); 230 + mcheckirq_ctx[hw_cpu] = alloc_stack(); 243 231 #endif 244 232 } 245 233 }
+7 -12
arch/powerpc/kernel/setup_64.c
··· 634 634 635 635 static void *__init alloc_stack(unsigned long limit, int cpu) 636 636 { 637 - unsigned long pa; 637 + void *ptr; 638 638 639 639 BUILD_BUG_ON(STACK_INT_FRAME_SIZE % 16); 640 640 641 - pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit, 642 - early_cpu_to_node(cpu), MEMBLOCK_NONE); 643 - if (!pa) { 644 - pa = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); 645 - if (!pa) 646 - panic("cannot allocate stacks"); 647 - } 641 + ptr = memblock_alloc_try_nid(THREAD_SIZE, THREAD_SIZE, 642 + MEMBLOCK_LOW_LIMIT, limit, 643 + early_cpu_to_node(cpu)); 644 + if (!ptr) 645 + panic("cannot allocate stacks"); 648 646 649 - return __va(pa); 647 + return ptr; 650 648 } 651 649 652 650 void __init irqstack_early_init(void) ··· 737 739 struct thread_info *ti; 738 740 739 741 ti = alloc_stack(limit, i); 740 - memset(ti, 0, THREAD_SIZE); 741 742 emerg_stack_init_thread_info(ti, i); 742 743 paca_ptrs[i]->emergency_sp = (void *)ti + THREAD_SIZE; 743 744 744 745 #ifdef CONFIG_PPC_BOOK3S_64 745 746 /* emergency stack for NMI exception handling. */ 746 747 ti = alloc_stack(limit, i); 747 - memset(ti, 0, THREAD_SIZE); 748 748 emerg_stack_init_thread_info(ti, i); 749 749 paca_ptrs[i]->nmi_emergency_sp = (void *)ti + THREAD_SIZE; 750 750 751 751 /* emergency stack for machine check exception handling. */ 752 752 ti = alloc_stack(limit, i); 753 - memset(ti, 0, THREAD_SIZE); 754 753 emerg_stack_init_thread_info(ti, i); 755 754 paca_ptrs[i]->mc_emergency_sp = (void *)ti + THREAD_SIZE; 756 755 #endif