Skip to content

Commit

Permalink
Merge branch 'dev/lppaca' into merge-test
Browse files Browse the repository at this point in the history
  • Loading branch information
mpe committed Aug 22, 2023
2 parents a888524 + 12d5b17 commit d9e93a4
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 49 deletions.
37 changes: 14 additions & 23 deletions arch/powerpc/include/asm/lppaca.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@
#ifndef _ASM_POWERPC_LPPACA_H
#define _ASM_POWERPC_LPPACA_H

/*
* The below VPHN macros are outside the __KERNEL__ check since these are
* used for compiling the vphn selftest in userspace
*/

/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers. */
#define VPHN_REGISTER_COUNT 6

/*
* 6 64-bit registers unpacked into up to 24 be32 associativity values. To
* form the complete property we have to add the length in the first cell.
*/
#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u16) + 1)

/*
* The H_HOME_NODE_ASSOCIATIVITY hcall takes two values for flags:
* 1 for retrieving associativity information for a guest cpu
* 2 for retrieving associativity information for a host/hypervisor cpu
*/
#define VPHN_FLAG_VCPU 1
#define VPHN_FLAG_PCPU 2

#ifdef __KERNEL__

/*
Expand All @@ -45,6 +23,11 @@
#include <asm/types.h>
#include <asm/mmu.h>
#include <asm/firmware.h>
#include <asm/paca.h>

#ifdef CONFIG_PPC_PSERIES
#define get_lppaca() (get_paca()->lppaca_ptr)
#endif

/*
* The lppaca is the "virtual processor area" registered with the hypervisor,
Expand Down Expand Up @@ -127,12 +110,20 @@ struct lppaca {
*/
#define LPPACA_OLD_SHARED_PROC 2

static inline bool lppaca_shared_proc(struct lppaca *l)
#ifdef CONFIG_PPC_PSERIES
/*
* All CPUs should have the same shared proc value, so directly access the PACA
* to avoid false positives from DEBUG_PREEMPT.
*/
static inline bool lppaca_shared_proc(void)
{
struct lppaca *l = local_paca->lppaca_ptr;

if (!firmware_has_feature(FW_FEATURE_SPLPAR))
return false;
return !!(l->__old_status & LPPACA_OLD_SHARED_PROC);
}
#endif

/*
* SLB shadow buffer structure as defined in the PAPR. The save_area
Expand Down
6 changes: 1 addition & 5 deletions arch/powerpc/include/asm/paca.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <linux/cache.h>
#include <linux/string.h>
#include <asm/types.h>
#include <asm/lppaca.h>
#include <asm/mmu.h>
#include <asm/page.h>
#ifdef CONFIG_PPC_BOOK3E_64
Expand Down Expand Up @@ -47,14 +46,11 @@ extern unsigned int debug_smp_processor_id(void); /* from linux/smp.h */
#define get_paca() local_paca
#endif

#ifdef CONFIG_PPC_PSERIES
#define get_lppaca() (get_paca()->lppaca_ptr)
#endif

#define get_slb_shadow() (get_paca()->slb_shadow_ptr)

struct task_struct;
struct rtas_args;
struct lppaca;

/*
* Defines the layout of the paca.
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <asm/smp.h>
#ifdef CONFIG_PPC64
#include <asm/paca.h>
#include <asm/lppaca.h>
#include <asm/hvcall.h>
#endif

Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/plpar_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <asm/hvcall.h>
#include <asm/paca.h>
#include <asm/lppaca.h>
#include <asm/page.h>

static inline long poll_pending(void)
Expand Down
22 changes: 22 additions & 0 deletions arch/powerpc/include/asm/vphn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef _ASM_POWERPC_VPHN_H
#define _ASM_POWERPC_VPHN_H

/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers. */
#define VPHN_REGISTER_COUNT 6

/*
* 6 64-bit registers unpacked into up to 24 be32 associativity values. To
* form the complete property we have to add the length in the first cell.
*/
#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u16) + 1)

/*
* The H_HOME_NODE_ASSOCIATIVITY hcall takes two values for flags:
* 1 for retrieving associativity information for a guest cpu
* 2 for retrieving associativity information for a host/hypervisor cpu
*/
#define VPHN_FLAG_VCPU 1
#define VPHN_FLAG_PCPU 2

#endif // _ASM_POWERPC_VPHN_H
1 change: 1 addition & 0 deletions arch/powerpc/kvm/book3s_hv_ras.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/kvm.h>
#include <linux/kvm_host.h>
#include <linux/kernel.h>
#include <asm/lppaca.h>
#include <asm/opal.h>
#include <asm/mce.h>
#include <asm/machdep.h>
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/mm/book3s64/slb.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <asm/mmu.h>
#include <asm/mmu_context.h>
#include <asm/paca.h>
#include <asm/lppaca.h>
#include <asm/ppc-opcode.h>
#include <asm/cputable.h>
#include <asm/cacheflush.h>
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/mm/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <asm/hvcall.h>
#include <asm/setup.h>
#include <asm/vdso.h>
#include <asm/vphn.h>
#include <asm/drmem.h>

static int numa_enabled = 1;
Expand Down
11 changes: 2 additions & 9 deletions arch/powerpc/platforms/pseries/lpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <asm/kexec.h>
#include <asm/fadump.h>
#include <asm/dtl.h>
#include <asm/vphn.h>

#include "pseries.h"

Expand Down Expand Up @@ -639,16 +640,8 @@ static const struct proc_ops vcpudispatch_stats_freq_proc_ops = {

static int __init vcpudispatch_stats_procfs_init(void)
{
/*
* Avoid smp_processor_id while preemptible. All CPUs should have
* the same value for lppaca_shared_proc.
*/
preempt_disable();
if (!lppaca_shared_proc(get_lppaca())) {
preempt_enable();
if (!lppaca_shared_proc())
return 0;
}
preempt_enable();

if (!proc_create("powerpc/vcpudispatch_stats", 0600, NULL,
&vcpudispatch_stats_proc_ops))
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/pseries/lparcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static void parse_ppp_data(struct seq_file *m)
ppp_data.active_system_procs);

/* pool related entries are appropriate for shared configs */
if (lppaca_shared_proc(get_lppaca())) {
if (lppaca_shared_proc()) {
unsigned long pool_idle_time, pool_procs;

seq_printf(m, "pool=%d\n", ppp_data.pool_num);
Expand Down Expand Up @@ -560,7 +560,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
partition_potential_processors);

seq_printf(m, "shared_processor_mode=%d\n",
lppaca_shared_proc(get_lppaca()));
lppaca_shared_proc());

#ifdef CONFIG_PPC_64S_HASH_MMU
if (!radix_enabled())
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ static void __init pSeries_setup_arch(void)
if (firmware_has_feature(FW_FEATURE_LPAR)) {
vpa_init(boot_cpuid);

if (lppaca_shared_proc(get_lppaca())) {
if (lppaca_shared_proc()) {
static_branch_enable(&shared_processor);
pv_spinlocks_init();
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/platforms/pseries/vas.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <asm/hvcall.h>
#include <asm/plpar_wrappers.h>
#include <asm/firmware.h>
#include <asm/vphn.h>
#include <asm/vas.h>
#include "vas.h"

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/vphn.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <asm/byteorder.h>
#include <asm/lppaca.h>
#include <asm/vphn.h>

/*
* The associativity domain numbers are returned from the hypervisor as a
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/xmon/xmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#ifdef CONFIG_PPC64
#include <asm/hvcall.h>
#include <asm/paca.h>
#include <asm/lppaca.h>
#endif

#include "nonstdio.h"
Expand Down
8 changes: 1 addition & 7 deletions drivers/cpuidle/cpuidle-pseries.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,7 @@ static int __init pseries_idle_probe(void)
return -ENODEV;

if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
/*
* Use local_paca instead of get_lppaca() since
* preemption is not disabled, and it is not required in
* fact, since lppaca_ptr does not need to be the value
* associated to the current CPU, it can be from any CPU.
*/
if (lppaca_shared_proc(local_paca->lppaca_ptr)) {
if (lppaca_shared_proc()) {
cpuidle_state_table = shared_states;
max_idle_state = ARRAY_SIZE(shared_states);
} else {
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/powerpc/vphn/asm/lppaca.h

This file was deleted.

1 change: 1 addition & 0 deletions tools/testing/selftests/powerpc/vphn/asm/vphn.h

0 comments on commit d9e93a4

Please sign in to comment.