Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2174267imu; Thu, 24 Jan 2019 08:21:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN44/p+/slIQea3oMeRYB5sHM22ZWNROLHkZoBE0GQYhrKc3lvWK+nyMPkpZuyVDPDgynVT2 X-Received: by 2002:a63:200e:: with SMTP id g14mr6529582pgg.235.1548346902283; Thu, 24 Jan 2019 08:21:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548346902; cv=none; d=google.com; s=arc-20160816; b=Rx78/Y/flTZ4vzYrFSTu9j/xk2BmoYFbG9LnMNmo4xAHfQPmwzg6q8gCfYjoa5B/ng 59Sahlc6YmEZq8ZC2uFPWLxAe/Mb9dOnHWJJDXeW8JNMzeIVjztAyVUC0yirZ1DB/wIF yzF22PM+1RBJBB0BepmbXAyZc5FsTDXb02PvjaQKi5wCwmWnNC2POsJbKeNDAHBFlLXt 2KQS08xmqwyAZzM4YoSUjJaW1kzHxk15uSr2ja7xpAVNhZ7hGj3rudvpWFIah9espbyw O9/8nNk/LhdZufa+S9xwWDDsHhVAY2qJ4JqXBSS69i9peI8cwRbWXYZ70TaHzcv5cUbL 34Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=muUnjtodzkXDEvyFhMe2FrngPGWY/Cl7K+jYdg8HHmA=; b=j6tHeamWZ88qalHAD2Ov9NPt7Rct6Bh/mlJN0UxKe7vbtP+KQXWxzf88qkUepQ9oS9 gNLSRgtiSGZhyahGpARkynuLZwDghuQmE0I+tDPKUo50VQhqbV9ajha6XE//OqcTQRRY ZeOfFKRWo8zat8VaxIRQYL2txS8YCeZ+sKFSCmpzRss8lMNNN6UQ1vn44LvAYVpsHpRT hKSiQboZAoVL6R9SN5bGTiTEgQzi3FJOqvHypuy2UQ1XYQEcNoJ8/Jysj8GvMPgxht6P dwvHo28SyVZLiyBRVVYN373q8FYw49Z6CDgsANdni3NW1DGI/Cnm+w12sLdGAtxYmqSL R1rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=AIgjNUPr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si21753317pgl.457.2019.01.24.08.21.26; Thu, 24 Jan 2019 08:21:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=AIgjNUPr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbfAXQTi (ORCPT + 99 others); Thu, 24 Jan 2019 11:19:38 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:30972 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727943AbfAXQTf (ORCPT ); Thu, 24 Jan 2019 11:19:35 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43lnRS0swmz9v01d; Thu, 24 Jan 2019 17:19:32 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=AIgjNUPr; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id s1VMGGJ4Clwk; Thu, 24 Jan 2019 17:19:32 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43lnRR6jLXz9v01Z; Thu, 24 Jan 2019 17:19:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1548346771; bh=muUnjtodzkXDEvyFhMe2FrngPGWY/Cl7K+jYdg8HHmA=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=AIgjNUPrfnLIAEIOx50djvO8fVDSPTTFFhPULoRA7M021xUlt2LkYJj6LUTA3eIXy 5kWH1sbzcnOhiRl26TpcY1EaVYZB1P4Slvp6nr+udAwmKT3g0haR0cDkIOIK5LsHbL LukYvlJpRrvjSlkPArRxjj7+0w1C5f2WDAw4Xu/U= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7E9658B863; Thu, 24 Jan 2019 17:19:33 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id i5FanRBBzaxb; Thu, 24 Jan 2019 17:19:33 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2F9258B850; Thu, 24 Jan 2019 17:19:33 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 040A872D88; Thu, 24 Jan 2019 16:19:33 +0000 (UTC) Message-Id: <1c8e658c094022a15e4b9f5ef5c191caab3c0dff.1548346225.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v14 02/12] powerpc/irq: use memblock functions returning virtual address To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , Mike Rapoport Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Mark Rutland Date: Thu, 24 Jan 2019 16:19:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Mike Rapoport Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/irq.c | 5 ----- arch/powerpc/kernel/setup_32.c | 25 +++++++++++++++---------- arch/powerpc/kernel/setup_64.c | 19 +++++++------------ 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index bb299613a462..4a5dd8800946 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -725,18 +725,15 @@ void exc_lvl_ctx_init(void) #endif #endif - memset((void *)critirq_ctx[cpu_nr], 0, THREAD_SIZE); tp = critirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count = 0; #ifdef CONFIG_BOOKE - memset((void *)dbgirq_ctx[cpu_nr], 0, THREAD_SIZE); tp = dbgirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count = 0; - memset((void *)mcheckirq_ctx[cpu_nr], 0, THREAD_SIZE); tp = mcheckirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count = HARDIRQ_OFFSET; @@ -754,12 +751,10 @@ void irq_ctx_init(void) int i; for_each_possible_cpu(i) { - memset((void *)softirq_ctx[i], 0, THREAD_SIZE); tp = softirq_ctx[i]; tp->cpu = i; klp_init_thread_info(tp); - memset((void *)hardirq_ctx[i], 0, THREAD_SIZE); tp = hardirq_ctx[i]; tp->cpu = i; klp_init_thread_info(tp); diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 947f904688b0..f0e25d845f8c 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -196,6 +196,16 @@ static int __init ppc_init(void) } arch_initcall(ppc_init); +static void *__init alloc_stack(void) +{ + void *ptr = memblock_alloc(THREAD_SIZE, THREAD_SIZE); + + if (!ptr) + panic("cannot allocate stacks"); + + return ptr; +} + void __init irqstack_early_init(void) { unsigned int i; @@ -203,10 +213,8 @@ void __init irqstack_early_init(void) /* interrupt stacks must be in lowmem, we get that for free on ppc32 * as the memblock is limited to lowmem by default */ for_each_possible_cpu(i) { - softirq_ctx[i] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); - hardirq_ctx[i] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); + softirq_ctx[i] = alloc_stack(); + hardirq_ctx[i] = alloc_stack(); } } @@ -224,13 +232,10 @@ void __init exc_lvl_early_init(void) hw_cpu = 0; #endif - critirq_ctx[hw_cpu] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); + critirq_ctx[hw_cpu] = alloc_stack(); #ifdef CONFIG_BOOKE - dbgirq_ctx[hw_cpu] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); - mcheckirq_ctx[hw_cpu] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); + dbgirq_ctx[hw_cpu] = alloc_stack(); + mcheckirq_ctx[hw_cpu] = alloc_stack(); #endif } } diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 236c1151a3a7..080dd515d587 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -634,19 +634,17 @@ __init u64 ppc64_bolted_size(void) static void *__init alloc_stack(unsigned long limit, int cpu) { - unsigned long pa; + void *ptr; BUILD_BUG_ON(STACK_INT_FRAME_SIZE % 16); - pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit, - early_cpu_to_node(cpu), MEMBLOCK_NONE); - if (!pa) { - pa = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); - if (!pa) - panic("cannot allocate stacks"); - } + ptr = memblock_alloc_try_nid(THREAD_SIZE, THREAD_SIZE, + MEMBLOCK_LOW_LIMIT, limit, + early_cpu_to_node(cpu)); + if (!ptr) + panic("cannot allocate stacks"); - return __va(pa); + return ptr; } void __init irqstack_early_init(void) @@ -739,20 +737,17 @@ void __init emergency_stack_init(void) struct thread_info *ti; ti = alloc_stack(limit, i); - memset(ti, 0, THREAD_SIZE); emerg_stack_init_thread_info(ti, i); paca_ptrs[i]->emergency_sp = (void *)ti + THREAD_SIZE; #ifdef CONFIG_PPC_BOOK3S_64 /* emergency stack for NMI exception handling. */ ti = alloc_stack(limit, i); - memset(ti, 0, THREAD_SIZE); emerg_stack_init_thread_info(ti, i); paca_ptrs[i]->nmi_emergency_sp = (void *)ti + THREAD_SIZE; /* emergency stack for machine check exception handling. */ ti = alloc_stack(limit, i); - memset(ti, 0, THREAD_SIZE); emerg_stack_init_thread_info(ti, i); paca_ptrs[i]->mc_emergency_sp = (void *)ti + THREAD_SIZE; #endif -- 2.13.3