From patchwork Sat Jul 22 01:17:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 792434 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xDqnW72zcz9s81 for ; Sat, 22 Jul 2017 11:30:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JgYxLHOg"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xDqnW5TRKzDqpp for ; Sat, 22 Jul 2017 11:30:07 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JgYxLHOg"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xDqWm2T7WzDqyH for ; Sat, 22 Jul 2017 11:18:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JgYxLHOg"; dkim-atps=neutral Received: by mail-pf0-x242.google.com with SMTP id a11so5889390pfj.3 for ; Fri, 21 Jul 2017 18:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RjtDCDZpZ8xc5BR9KX9S0m/ydBOMdiI3x88n2aN5Bk0=; b=JgYxLHOglXHTxVfdfg+M8/asVU4Cu31tP5kXbGMpmvZbdKaiAFsiI41J9NmLQhwGeD dNSfmYf5N3hHdSlNM94qDPLH1MnvZXFc5F7d0Qpg10e2vdc623Qn9MmJ93gYcN+gNyJz 8J5tAQFRNeSvkcOnVAnBorWyPWH/zlvvLMaSTIaS+394TQ3ckrdIgHSnDnYf1HuPZfn9 rkpN0wVEVws/c7NsT5+IUbCOM/AveH/lJTm7TSqpc+mWVhdM/qRg86l/wz93YEy9Y9aE 5NhtmvsgH9Pv44R3+QMX7hRgkFqWxUFAjbBFdQO/g1D477KzPj3/DWZ8yW8H1U0NS0q7 KGpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RjtDCDZpZ8xc5BR9KX9S0m/ydBOMdiI3x88n2aN5Bk0=; b=f0RiP9ZzZPc7WtLhU2m9MeXbBzdU1DlLFwnajZdgnG4SuHJM4D8jRn3R8+4bRqAuWI EI9dR5P+9zWwY79LQGt7+NcwvA8l+eLiNi7WonojuU14G14IJbGU4zy8vZ/92k2U//mP 9P6t8sYcSysL76Ok1oDhREGEvJaqswIX7GiekBVTedLD4KgQsO00nXOAggixeGvTZHIh rmLM40KCr6oPKYVuEqAF2lif7amS5/YaA49pfoSuQ5q0KGJvFtDjpXHh9ACLZib0TTa0 bjpRRoE9XiH+QHOHfJEA5Zq0anvkrCrRbgmVTP+TR9V4Ny4oNi55jyzzC6l+6h9YjkIb AQCw== X-Gm-Message-State: AIVw112m97PC6Zv1cKYjv1jAwSFjW66GjT2nF5pFp3x8Oz7EkwkPb7h6 1Tirw3pVKdFzfpKkb0KEUA== X-Received: by 10.98.152.208 with SMTP id d77mr9286251pfk.210.1500686290313; Fri, 21 Jul 2017 18:18:10 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([1.129.31.184]) by smtp.gmail.com with ESMTPSA id o1sm10224206pgq.10.2017.07.21.18.18.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2017 18:18:09 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 06/11] powerpc/64s: do not allocate lppaca if we are not virtualized Date: Sat, 22 Jul 2017 11:17:36 +1000 Message-Id: <20170722011741.13942-7-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170722011741.13942-1-npiggin@gmail.com> References: <20170722011741.13942-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The "lppaca" is a structure registered with the hypervisor. This is unnecessary when running on non-virtualised platforms. One field from the lppaca is also used by the host, so move that out into the paca. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/paca.h | 8 ++++++-- arch/powerpc/include/asm/pmc.h | 10 +++++++++- arch/powerpc/kernel/asm-offsets.c | 7 +++++++ arch/powerpc/kernel/paca.c | 13 ++++++++++--- arch/powerpc/kernel/prom.c | 10 +++++++--- arch/powerpc/kvm/book3s_hv_interrupts.S | 3 +-- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 5 ++--- 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index dc88a31cc79a..de47c5a4f132 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -57,7 +57,7 @@ struct task_struct; * processor. */ struct paca_struct { -#ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_PSERIES /* * Because hw_cpu_id, unlike other paca fields, is accessed * routinely from other CPUs (from the IRQ code), we stick to @@ -66,7 +66,8 @@ struct paca_struct { */ struct lppaca *lppaca_ptr; /* Pointer to LpPaca for PLIC */ -#endif /* CONFIG_PPC_BOOK3S */ +#endif /* CONFIG_PPC_PSERIES */ + /* * MAGIC: the spinlock functions in arch/powerpc/lib/locks.c * load lock_token and paca_index with a single lwz @@ -158,6 +159,9 @@ struct paca_struct { u64 saved_r1; /* r1 save for RTAS calls or PM */ u64 saved_msr; /* MSR saved here by enter_rtas */ u16 trap_save; /* Used when bad stack is encountered */ +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE + u8 pmcregs_in_use; /* pseries puts this in lppaca */ +#endif u8 soft_enabled; /* irq soft-enable flag */ u8 irq_happened; /* irq happened while soft-disabled */ u8 io_sync; /* writel() needs spin_unlock sync */ diff --git a/arch/powerpc/include/asm/pmc.h b/arch/powerpc/include/asm/pmc.h index 5a9ede4962cb..7b672a72cb0b 100644 --- a/arch/powerpc/include/asm/pmc.h +++ b/arch/powerpc/include/asm/pmc.h @@ -31,10 +31,18 @@ void ppc_enable_pmcs(void); #ifdef CONFIG_PPC_BOOK3S_64 #include +#include static inline void ppc_set_pmu_inuse(int inuse) { - get_lppaca()->pmcregs_in_use = inuse; +#ifdef CONFIG_PPC_PSERIES + if (firmware_has_feature(FW_FEATURE_LPAR)) + get_lppaca()->pmcregs_in_use = inuse; +#endif + +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE + get_paca()->pmcregs_in_use = inuse; +#endif } extern void power4_enable_pmcs(void); diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 6e95c2c19a7e..831b277c91c7 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -221,12 +221,19 @@ int main(void) OFFSET(PACA_EXMC, paca_struct, exmc); OFFSET(PACA_EXSLB, paca_struct, exslb); OFFSET(PACA_EXNMI, paca_struct, exnmi); +#ifdef CONFIG_PPC_PSERIES OFFSET(PACALPPACAPTR, paca_struct, lppaca_ptr); +#endif OFFSET(PACA_SLBSHADOWPTR, paca_struct, slb_shadow_ptr); OFFSET(SLBSHADOW_STACKVSID, slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid); OFFSET(SLBSHADOW_STACKESID, slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid); OFFSET(SLBSHADOW_SAVEAREA, slb_shadow, save_area); +#ifdef CONFIG_PPC_PSERIES OFFSET(LPPACA_PMCINUSE, lppaca, pmcregs_in_use); +#endif +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE + OFFSET(PACA_PMCINUSE, paca_struct, pmcregs_in_use); +#endif OFFSET(LPPACA_DTLIDX, lppaca, dtl_idx); OFFSET(LPPACA_YIELDCOUNT, lppaca, yield_count); OFFSET(PACA_DTL_RIDX, paca_struct, dtl_ridx); diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 032b073c2c30..801ce2e9c9ac 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -18,7 +18,7 @@ #include #include -#ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_PSERIES /* * The structure which the hypervisor knows about - this structure @@ -45,6 +45,9 @@ static long __initdata lppaca_size; static void __init allocate_lppacas(int nr_cpus, unsigned long limit) { + if (!firmware_has_feature(FW_FEATURE_LPAR)) + return; + if (nr_cpus <= NR_LPPACAS) return; @@ -58,6 +61,9 @@ static struct lppaca * __init new_lppaca(int cpu) { struct lppaca *lp; + if (!firmware_has_feature(FW_FEATURE_LPAR)) + return NULL; + if (cpu < NR_LPPACAS) return &lppaca[cpu]; @@ -155,9 +161,10 @@ EXPORT_SYMBOL(paca); void __init initialise_paca(struct paca_struct *new_paca, int cpu) { -#ifdef CONFIG_PPC_BOOK3S +#ifdef CONFIG_PPC_PSERIES new_paca->lppaca_ptr = new_lppaca(cpu); -#else +#endif +#ifdef CONFIG_PPC_BOOK3E new_paca->kernel_pgd = swapper_pg_dir; #endif new_paca->lock_token = 0x8000; diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index f83056297441..6f29c6d1cb76 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -728,6 +728,13 @@ void __init early_init_devtree(void *params) * FIXME .. and the initrd too? */ move_device_tree(); + /* + * Now try to figure out if we are running on LPAR and so on + * This must run before allocate_pacas() in order to allocate + * lppacas or not. + */ + pseries_probe_fw_features(); + allocate_pacas(); DBG("Scanning CPUs ...\n"); @@ -758,9 +765,6 @@ void __init early_init_devtree(void *params) #endif epapr_paravirt_early_init(); - /* Now try to figure out if we are running on LPAR and so on */ - pseries_probe_fw_features(); - #ifdef CONFIG_PPC_PS3 /* Identify PS3 firmware */ if (of_flat_dt_is_compatible(of_get_flat_dt_root(), "sony,ps3")) diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S index dc54373c8780..0e8493033288 100644 --- a/arch/powerpc/kvm/book3s_hv_interrupts.S +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S @@ -79,8 +79,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) li r5, 0 mtspr SPRN_MMCRA, r5 isync - ld r3, PACALPPACAPTR(r13) /* is the host using the PMU? */ - lbz r5, LPPACA_PMCINUSE(r3) + lbz r5, PACA_PMCINUSE(r13) /* is the host using the PMU? */ cmpwi r5, 0 beq 31f /* skip if not */ mfspr r5, SPRN_MMCR1 diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index cb44065e2946..e94233de56eb 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -99,8 +99,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) mtspr SPRN_SPRG_VDSO_WRITE,r3 /* Reload the host's PMU registers */ - ld r3, PACALPPACAPTR(r13) /* is the host using the PMU? */ - lbz r4, LPPACA_PMCINUSE(r3) + lbz r4, PACA_PMCINUSE(r13) /* is the host using the PMU? */ cmpwi r4, 0 beq 23f /* skip if not */ BEGIN_FTR_SECTION @@ -1669,7 +1668,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) mtspr SPRN_MMCRA, r7 isync beq 21f /* if no VPA, save PMU stuff anyway */ - lbz r7, LPPACA_PMCINUSE(r8) + lbz r7, PACA_PMCINUSE(r13) cmpwi r7, 0 /* did they ask for PMU stuff to be saved? */ bne 21f std r3, VCPU_MMCR(r9) /* if not, set saved MMCR0 to FC */