2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-10-10 20:03:41 +08:00
|
|
|
* SMP support for pSeries machines.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Dave Engebretsen, Peter Bergner, and
|
|
|
|
* Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
|
|
|
|
*
|
|
|
|
* Plus various changes from other IBM teams...
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/cache.h>
|
|
|
|
#include <linux/err.h>
|
2011-12-22 08:26:03 +08:00
|
|
|
#include <linux/device.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/cpu.h>
|
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/smp.h>
|
|
|
|
#include <asm/paca.h>
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/cputable.h>
|
2005-08-03 12:35:25 +08:00
|
|
|
#include <asm/firmware.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/rtas.h>
|
2005-11-11 20:04:40 +08:00
|
|
|
#include <asm/vdso_datapage.h>
|
2007-10-25 13:27:44 +08:00
|
|
|
#include <asm/cputhreads.h>
|
2011-04-04 11:46:58 +08:00
|
|
|
#include <asm/xics.h>
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-31 03:46:11 +08:00
|
|
|
#include <asm/xive.h>
|
2012-11-15 02:49:50 +08:00
|
|
|
#include <asm/dbell.h>
|
2013-08-22 17:53:52 +08:00
|
|
|
#include <asm/plpar_wrappers.h>
|
2014-03-11 08:54:06 +08:00
|
|
|
#include <asm/code-patching.h>
|
2019-08-20 10:13:22 +08:00
|
|
|
#include <asm/svm.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-08 15:33:55 +08:00
|
|
|
#include "pseries.h"
|
2009-10-30 03:22:53 +08:00
|
|
|
#include "offline_states.h"
|
2005-11-03 12:33:31 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2008-10-20 23:37:03 +08:00
|
|
|
* The Primary thread of each non-boot processor was started from the OF client
|
|
|
|
* interface by prom_hold_cpus and is spinning on secondary_hold_spinloop.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2010-04-26 23:32:37 +08:00
|
|
|
static cpumask_var_t of_spin_mask;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-28 21:39:41 +08:00
|
|
|
/* Query where a cpu is now. Return codes #defined in plpar_wrappers.h */
|
|
|
|
int smp_query_cpu_stopped(unsigned int pcpu)
|
|
|
|
{
|
|
|
|
int cpu_status, status;
|
|
|
|
int qcss_tok = rtas_token("query-cpu-stopped-state");
|
|
|
|
|
|
|
|
if (qcss_tok == RTAS_UNKNOWN_SERVICE) {
|
2011-03-21 16:12:13 +08:00
|
|
|
printk_once(KERN_INFO
|
|
|
|
"Firmware doesn't support query-cpu-stopped-state\n");
|
2010-04-28 21:39:41 +08:00
|
|
|
return QCSS_HARDWARE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = rtas_call(qcss_tok, 1, 2, &cpu_status, pcpu);
|
|
|
|
if (status != 0) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"RTAS query-cpu-stopped-state failed: %i\n", status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cpu_status;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**
|
|
|
|
* smp_startup_cpu() - start the given cpu
|
|
|
|
*
|
|
|
|
* At boot time, there is nothing to do for primary threads which were
|
|
|
|
* started from Open Firmware. For anything else, call RTAS with the
|
|
|
|
* appropriate start location.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - failure
|
|
|
|
* 1 - success
|
|
|
|
*/
|
2012-12-22 06:04:10 +08:00
|
|
|
static inline int smp_startup_cpu(unsigned int lcpu)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int status;
|
2014-03-11 08:54:06 +08:00
|
|
|
unsigned long start_here =
|
|
|
|
__pa(ppc_function_entry(generic_secondary_smp_init));
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int pcpu;
|
2005-09-12 11:17:27 +08:00
|
|
|
int start_cpu;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-26 23:32:37 +08:00
|
|
|
if (cpumask_test_cpu(lcpu, of_spin_mask))
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Already started by OF and sitting in spin loop */
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
pcpu = get_hard_smp_processor_id(lcpu);
|
|
|
|
|
2010-04-28 21:39:41 +08:00
|
|
|
/* Check to see if the CPU out of FW already for kexec */
|
|
|
|
if (smp_query_cpu_stopped(pcpu) == QCSS_NOT_STOPPED){
|
2010-04-26 23:32:37 +08:00
|
|
|
cpumask_set_cpu(lcpu, of_spin_mask);
|
2010-04-28 21:39:41 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Fixup atomic count: it exited inside IRQ handler. */
|
2018-02-13 23:08:12 +08:00
|
|
|
task_thread_info(paca_ptrs[lcpu]->__current)->preempt_count = 0;
|
2011-04-01 03:33:08 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2009-10-30 03:22:53 +08:00
|
|
|
if (get_cpu_current_state(lcpu) == CPU_STATE_INACTIVE)
|
|
|
|
goto out;
|
2011-04-01 03:33:08 +08:00
|
|
|
#endif
|
2005-09-12 11:17:27 +08:00
|
|
|
/*
|
|
|
|
* If the RTAS start-cpu token does not exist then presume the
|
|
|
|
* cpu is already spinning.
|
|
|
|
*/
|
|
|
|
start_cpu = rtas_token("start-cpu");
|
|
|
|
if (start_cpu == RTAS_UNKNOWN_SERVICE)
|
|
|
|
return 1;
|
|
|
|
|
2006-02-16 11:13:53 +08:00
|
|
|
status = rtas_call(start_cpu, 3, 1, NULL, pcpu, start_here, pcpu);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (status != 0) {
|
|
|
|
printk(KERN_ERR "start-cpu failed: %i\n", status);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-09-12 11:17:27 +08:00
|
|
|
|
2011-04-01 03:33:08 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2009-10-30 03:22:53 +08:00
|
|
|
out:
|
2011-04-01 03:33:08 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-30 14:18:12 +08:00
|
|
|
static void smp_setup_cpu(int cpu)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-31 03:46:11 +08:00
|
|
|
if (xive_enabled())
|
|
|
|
xive_smp_setup_cpu();
|
|
|
|
else if (cpu != boot_cpuid)
|
2005-04-17 06:20:36 +08:00
|
|
|
xics_setup_cpu();
|
|
|
|
|
2005-08-03 12:35:25 +08:00
|
|
|
if (firmware_has_feature(FW_FEATURE_SPLPAR))
|
2005-04-17 06:20:36 +08:00
|
|
|
vpa_init(cpu);
|
|
|
|
|
2010-04-26 23:32:37 +08:00
|
|
|
cpumask_clear_cpu(cpu, of_spin_mask);
|
2011-04-01 03:33:08 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2009-10-30 03:22:53 +08:00
|
|
|
set_cpu_current_state(cpu, CPU_STATE_ONLINE);
|
|
|
|
set_default_offline_state(cpu);
|
2011-04-01 03:33:08 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-12-22 06:04:10 +08:00
|
|
|
static int smp_pSeries_kick_cpu(int nr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-06-27 15:00:06 +08:00
|
|
|
if (nr < 0 || nr >= nr_cpu_ids)
|
2017-06-27 15:00:05 +08:00
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (!smp_startup_cpu(nr))
|
2011-04-12 05:46:19 +08:00
|
|
|
return -ENOENT;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The processor is currently spinning, waiting for the
|
|
|
|
* cpu_start field to become non-zero After we set cpu_start,
|
|
|
|
* the processor will continue on to secondary_start
|
|
|
|
*/
|
2018-02-13 23:08:12 +08:00
|
|
|
paca_ptrs[nr]->cpu_start = 1;
|
2011-04-01 03:33:08 +08:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
2009-10-30 03:22:53 +08:00
|
|
|
set_preferred_offline_state(nr, CPU_STATE_ONLINE);
|
|
|
|
|
|
|
|
if (get_cpu_current_state(nr) == CPU_STATE_INACTIVE) {
|
2011-04-01 03:33:08 +08:00
|
|
|
long rc;
|
|
|
|
unsigned long hcpuid;
|
|
|
|
|
2009-10-30 03:22:53 +08:00
|
|
|
hcpuid = get_hard_smp_processor_id(nr);
|
|
|
|
rc = plpar_hcall_norets(H_PROD, hcpuid);
|
|
|
|
if (rc != H_SUCCESS)
|
2010-01-31 18:02:03 +08:00
|
|
|
printk(KERN_ERR "Error: Prod to wake up processor %d "
|
|
|
|
"Ret= %ld\n", nr, rc);
|
2009-10-30 03:22:53 +08:00
|
|
|
}
|
2011-04-01 03:33:08 +08:00
|
|
|
#endif
|
2011-04-12 05:46:19 +08:00
|
|
|
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-31 03:46:11 +08:00
|
|
|
static int pseries_smp_prepare_cpu(int cpu)
|
|
|
|
{
|
|
|
|
if (xive_enabled())
|
|
|
|
return xive_smp_prepare_cpu(cpu);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-13 18:16:21 +08:00
|
|
|
static void smp_pseries_cause_ipi(int cpu)
|
2012-11-15 02:49:50 +08:00
|
|
|
{
|
2017-04-13 18:16:21 +08:00
|
|
|
/* POWER9 should not use this handler */
|
|
|
|
if (doorbell_try_core_ipi(cpu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
icp_ops->cause_ipi(cpu);
|
2012-11-15 02:49:50 +08:00
|
|
|
}
|
|
|
|
|
2016-12-20 02:30:10 +08:00
|
|
|
static int pseries_cause_nmi_ipi(int cpu)
|
|
|
|
{
|
|
|
|
int hwcpu;
|
|
|
|
|
|
|
|
if (cpu == NMI_IPI_ALL_OTHERS) {
|
|
|
|
hwcpu = H_SIGNAL_SYS_RESET_ALL_OTHERS;
|
|
|
|
} else {
|
|
|
|
if (cpu < 0) {
|
|
|
|
WARN_ONCE(true, "incorrect cpu parameter %d", cpu);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwcpu = get_hard_smp_processor_id(cpu);
|
|
|
|
}
|
|
|
|
|
2018-03-08 10:54:41 +08:00
|
|
|
if (plpar_signal_sys_reset(hwcpu) == H_SUCCESS)
|
2016-12-20 02:30:10 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-31 03:46:11 +08:00
|
|
|
static __init void pSeries_smp_probe_xics(void)
|
2012-11-15 02:49:50 +08:00
|
|
|
{
|
2015-04-04 16:28:50 +08:00
|
|
|
xics_smp_probe();
|
2012-11-15 02:49:50 +08:00
|
|
|
|
2019-08-20 10:13:22 +08:00
|
|
|
if (cpu_has_feature(CPU_FTR_DBELL) && !is_secure_guest())
|
2017-04-13 18:16:21 +08:00
|
|
|
smp_ops->cause_ipi = smp_pseries_cause_ipi;
|
|
|
|
else
|
|
|
|
smp_ops->cause_ipi = icp_ops->cause_ipi;
|
2012-11-15 02:49:50 +08:00
|
|
|
}
|
|
|
|
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-31 03:46:11 +08:00
|
|
|
static __init void pSeries_smp_probe(void)
|
|
|
|
{
|
|
|
|
if (xive_enabled())
|
|
|
|
/*
|
|
|
|
* Don't use P9 doorbells when XIVE is enabled. IPIs
|
|
|
|
* using MMIOs should be faster
|
|
|
|
*/
|
|
|
|
xive_smp_probe();
|
|
|
|
else
|
|
|
|
pSeries_smp_probe_xics();
|
|
|
|
}
|
|
|
|
|
2016-05-30 14:18:12 +08:00
|
|
|
static struct smp_ops_t pseries_smp_ops = {
|
2011-05-26 07:34:12 +08:00
|
|
|
.message_pass = NULL, /* Use smp_muxed_ipi_message_pass */
|
2012-11-15 02:49:50 +08:00
|
|
|
.cause_ipi = NULL, /* Filled at runtime by pSeries_smp_probe() */
|
2016-12-20 02:30:10 +08:00
|
|
|
.cause_nmi_ipi = pseries_cause_nmi_ipi,
|
2012-11-15 02:49:50 +08:00
|
|
|
.probe = pSeries_smp_probe,
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-31 03:46:11 +08:00
|
|
|
.prepare_cpu = pseries_smp_prepare_cpu,
|
2005-04-17 06:20:36 +08:00
|
|
|
.kick_cpu = smp_pSeries_kick_cpu,
|
2016-05-30 14:18:12 +08:00
|
|
|
.setup_cpu = smp_setup_cpu,
|
2013-08-06 03:58:35 +08:00
|
|
|
.cpu_bootable = smp_generic_cpu_bootable,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This is called very early */
|
2016-05-30 14:18:12 +08:00
|
|
|
void __init smp_init_pseries(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-04-24 13:13:19 +08:00
|
|
|
pr_debug(" -> smp_init_pSeries()\n");
|
2016-05-30 14:18:12 +08:00
|
|
|
smp_ops = &pseries_smp_ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-26 23:32:37 +08:00
|
|
|
alloc_bootmem_cpumask_var(&of_spin_mask);
|
|
|
|
|
2013-09-25 12:02:50 +08:00
|
|
|
/*
|
|
|
|
* Mark threads which are still spinning in hold loops
|
|
|
|
*
|
|
|
|
* We know prom_init will not have started them if RTAS supports
|
|
|
|
* query-cpu-stopped-state.
|
|
|
|
*/
|
|
|
|
if (rtas_token("query-cpu-stopped-state") == RTAS_UNKNOWN_SERVICE) {
|
|
|
|
if (cpu_has_feature(CPU_FTR_SMT)) {
|
|
|
|
for_each_present_cpu(i) {
|
|
|
|
if (cpu_thread_in_core(i) == 0)
|
|
|
|
cpumask_set_cpu(i, of_spin_mask);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
cpumask_copy(of_spin_mask, cpu_present_mask);
|
|
|
|
|
|
|
|
cpumask_clear_cpu(boot_cpuid, of_spin_mask);
|
2005-06-20 19:43:15 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Non-lpar has additional take/give timebase */
|
|
|
|
if (rtas_token("freeze-time-base") != RTAS_UNKNOWN_SERVICE) {
|
2009-06-17 00:42:50 +08:00
|
|
|
smp_ops->give_timebase = rtas_give_timebase;
|
|
|
|
smp_ops->take_timebase = rtas_take_timebase;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-04-24 13:13:19 +08:00
|
|
|
pr_debug(" <- smp_init_pSeries()\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|