powerpc/udbg: Fix Kconfig entry for avoiding 44x early debug with KVM
PATCH 1/21 powerpc/udbg: Fix Kconfig entry for avoiding 44x early debug with KVM
It was preventing the global early debug selection whenever KVM was enabled instead of only preventing the 440 specific one.
--- arch/powerpc/Kconfig.debug | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/Kconfig.debug +3 -4
@@ -141,9 +141,6 @@ config BOOTX_TEXT config PPC_EARLY_DEBUG bool "Early debugging (dangerous)" - # PPC_EARLY_DEBUG on 440 leaves AS=1 mappings above the TLB high water - # mark, which doesn't work with current 440 KVM. - depends on !KVM help Say Y to enable some early debugging facilities that may be available for your processor/board combination. Those facilities are hacks
@@ -222,7 +219,9 @@ config PPC_EARLY_DEBUG_BEAT config PPC_EARLY_DEBUG_44x bool "Early serial debugging for IBM/AMCC 44x CPUs" - depends on 44x + # PPC_EARLY_DEBUG on 440 leaves AS=1 mappings above the TLB high water + # mark, which doesn't work with current 440 KVM. + depends on 44x && !KVM help Select this to enable early debugging for IBM 44x chips via the inbuilt serial port. If you enable this, ensure you set
Signature · 1 line
1.7.4.1
PATCH 2/21 powerpc/smp: More generic support for "soft hotplug"
This adds more generic support for doing CPU hotplug with a simple idle loop and no actual reset of the processors. The generic smp_generic_kick_cpu() does the hotplug bringup trick if the PACA shows that the CPU has already been started at boot and we provide an accessor for the CPU state.
--- arch/powerpc/include/asm/smp.h | 1 + arch/powerpc/kernel/smp.c | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/smp.h +1 -0
@@ -65,6 +65,7 @@ int generic_cpu_disable(void);void generic_cpu_die (unsigned int cpu);void generic_mach_cpu_die (void );void generic_set_cpu_dead (unsigned int cpu); +int generic_check_cpu_restart (unsigned int cpu);#endif #ifdef CONFIG_PPC64
arch/powerpc/kernel/smp.c +25 -5
@@ -70,6 +70,10 @@ static DEFINE_PER_CPU(struct task_struct *, idle_thread_array);#define get_idle_for_cpu (x) (per_cpu(idle_thread_array, x))#define set_idle_for_cpu (x, p) (per_cpu(idle_thread_array, x) = (p)) + +/* State of each CPU during hotplug phases */ +static DEFINE_PER_CPU(int, cpu_state) = { 0 }; +#else static struct task_struct *idle_thread_array[NR_CPUS ]__cpuinitdata ;#define get_idle_for_cpu (x) (idle_thread_array[(x)])
@@ -104,12 +108,25 @@ int __devinit smp_generic_kick_cpu(int nr)* cpu_start field to become non-zero After we set cpu_start, * the processor will continue on to secondary_start */ - paca[nr].cpu_start =1 ; -smp_mb (); +if (!paca[nr].cpu_start) { + paca[nr].cpu_start =1 ; +smp_mb (); +return 0 ; + } + +#ifdef CONFIG_HOTPLUG_CPU +/* +* Ok it's not there, so it might be soft-unplugged, let's +* try to bring it back +*/ +per_cpu (cpu_state, nr) =CPU_UP_PREPARE ; +smp_wmb (); +smp_send_reschedule (nr); +#endif /* CONFIG_HOTPLUG_CPU */ return 0; } -#endif +#endif /* CONFIG_PPC64 */ static irqreturn_t call_function_action (int irq,void *data) {
@@ -357,8 +374,6 @@ void __devinit smp_prepare_boot_cpu(void) }#ifdef CONFIG_HOTPLUG_CPU -/* State of each CPU during hotplug phases */ -static DEFINE_PER_CPU(int, cpu_state) = { 0 };int generic_cpu_disable (void ) {
@@ -406,6 +421,11 @@ void generic_set_cpu_dead(unsigned int cpu) {per_cpu (cpu_state, cpu) =CPU_DEAD ; } + +int generic_check_cpu_restart (unsigned int cpu) +{ +return per_cpu (cpu_state, cpu) ==CPU_UP_PREPARE ; +}#endif struct create_idle {
Signature · 1 line
1.7.4.1
PATCH 3/21 powerpc/pci: Call pcie_bus_configure_settings()
In reply to Benjamin HerrenschmidtThis new function is used to properly setup the PCI Express Max Payload Size (and in some circumstances Max Read Request Size).
Some systems will not operate properly if these aren't set correctly and the firmware doesn't always do it.
--- arch/powerpc/kernel/pci-common.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
arch/powerpc/kernel/pci-common.c +11 -0
@@ -1730,6 +1730,17 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)if (mode ==PCI_PROBE_NORMAL ) hose->last_busno = bus->subordinate =pci_scan_child_bus (bus); + +/* Configure PCI Express settings */ +if (bus) { +struct pci_bus *child; +list_for_each_entry (child, &bus->children, node) { +struct pci_dev *self = child->self; +if (!self) +continue ; +pcie_bus_configure_settings (child, self->pcie_mpss); + } + } }static void fixup_hide_host_resource_fsl (struct pci_dev *dev)
Signature · 1 line
1.7.4.1
PATCH 4/21 tty/hvc/hvsi_lib: Updates for running under OPAL v2
In reply to Benjamin HerrenschmidtExperience shows that our hvsi negotiation timeouts were too short under OPAL v2. This patch bumps them from 200ms to 500ms.
To limit the impact when the console is repeatedly opened/closed, we also avoid re-negotiating an already opened & established connection which typically happens when running init scripts on the tty shared with the kernel console.
Finally, while touching hvsi, I added a comment explaining why we limit our output packet size to 12 bytes.
--- arch/powerpc/include/asm/hvsi.h | 4 ++++ drivers/tty/hvc/hvsi_lib.c | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/hvsi.h +4 -0
@@ -19,6 +19,10 @@#define HVSI_TSDTR 0x01#define HVSI_TSCD 0x20 +/* Never send more than 12 bytes at once, that is 16 bytes +* with header, which is the max pHyp can swallow in one +* hcall. +*/ #define HVSI_MAX_OUTGOING_DATA 12#define HVSI_VERSION 1
drivers/tty/hvc/hvsi_lib.c +7 -5
@@ -316,10 +316,10 @@ void hvsilib_establish(struct hvsi_priv *pv)pr_devel ("HVSI@%x: Establishing...\n" , pv->termno); -/* Try for up to 200ms, there can be a packet to +/* Try for up to 500ms, there can be a packet to * start the process waiting for us... */ -for (timeout =0 ; timeout <20 ; timeout++) { +for (timeout =0 ; timeout <50 ; timeout++) {if (pv->established) goto established;if (!hvsi_get_packet (pv))
@@ -341,8 +341,8 @@ void hvsilib_establish(struct hvsi_priv *pv)pr_devel ("HVSI@%x: ... waiting handshake\n" , pv->termno); -/* Try for up to 200s */ -for (timeout =0 ; timeout <20 ; timeout++) { +/* Try for up to 500ms */ +for (timeout =0 ; timeout <50 ; timeout++) {if (pv->established) goto established;if (!hvsi_get_packet (pv))
@@ -379,7 +379,9 @@ int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp)/* Keep track of the tty data structure */ pv->tty =tty_kref_get (hp->tty); -hvsilib_establish (pv); +WARN_ON (pv->opened && !pv->is_console); +if (!pv->opened) +hvsilib_establish (pv);return 0 ; }
Signature · 1 line
1.7.4.1
PATCH 5/21 powerpc/powernv: Don't clobber r9 in relative_toc()
In reply to Benjamin HerrenschmidtWith OPAL, r8 and r9 will be used to pass the OPAL base and entry for debugging purposes (those informations are also in the device-tree). We don't want to clobber those registers that early.
--- arch/powerpc/kernel/head_64.S | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kernel/head_64.S +3 -3
@@ -674,9 +674,9 @@ _GLOBAL(enable_64b_mode) _GLOBAL(relative_toc) mflr r0 bcl 20,31,$+4 -0: mflr r9 - ld r2,(p_toc - 0b)(r9) - add r2,r2,r9 +0: mflr r11 + ld r2,(p_toc - 0b)(r11) + add r2,r2,r11 mtlr r0 blr
Signature · 1 line
1.7.4.1
PATCH 6/21 powerpc: Add skeleton PowerNV platform
In reply to Benjamin HerrenschmidtThis adds a skeletton for the new Power "Non Virtualized" platform which will be used by machines supporting running without an hypervisor, for example in order to run KVM.
These machines will be using a new firmware called OPAL for which the support will be provided by later patches.
The PowerNV platform is intended to be also usable under the BML environment used internally for early CPU bringup which is why the code also supports using RTAS instead of OPAL in various places.
--- arch/powerpc/boot/Makefile | 1 + arch/powerpc/platforms/Kconfig | 1 + arch/powerpc/platforms/Makefile | 1 + arch/powerpc/platforms/powernv/Kconfig | 12 +++ arch/powerpc/platforms/powernv/Makefile | 2 + arch/powerpc/platforms/powernv/powernv.h | 10 ++ arch/powerpc/platforms/powernv/setup.c | 153 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/smp.c | 83 ++++++++++++++++ 8 files changed, 263 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/Kconfig create mode 100644 arch/powerpc/platforms/powernv/Makefile create mode 100644 arch/powerpc/platforms/powernv/powernv.h create mode 100644 arch/powerpc/platforms/powernv/setup.c create mode 100644 arch/powerpc/platforms/powernv/smp.c
arch/powerpc/boot/Makefile +1 -0
@@ -171,6 +171,7 @@ quiet_cmd_wrap = WRAP $@ $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux image-$(CONFIG_PPC_PSERIES) += zImage.pseries +image-$(CONFIG_PPC_POWERNV) += zImage.pseries image-$(CONFIG_PPC_MAPLE) += zImage.maple image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries image-$(CONFIG_PPC_PS3) += dtbImage.ps3
arch/powerpc/platforms/Kconfig +1 -0
@@ -1,5 +1,6 @@ menu "Platform support" +source "arch/powerpc/platforms/powernv/Kconfig" source "arch/powerpc/platforms/pseries/Kconfig" source "arch/powerpc/platforms/iseries/Kconfig" source "arch/powerpc/platforms/chrp/Kconfig"
arch/powerpc/platforms/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_PPC_82xx) += 82xx/ obj-$(CONFIG_PPC_83xx) += 83xx/ obj-$(CONFIG_FSL_SOC_BOOKE) += 85xx/ obj-$(CONFIG_PPC_86xx) += 86xx/ +obj-$(CONFIG_PPC_POWERNV) += powernv/ obj-$(CONFIG_PPC_PSERIES) += pseries/ obj-$(CONFIG_PPC_ISERIES) += iseries/ obj-$(CONFIG_PPC_MAPLE) += maple/
arch/powerpc/platforms/powernv/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +config PPC_POWERNV + depends on PPC64 && PPC_BOOK3S + bool "IBM PowerNV (Non-Virtualized) platform support" + select PPC_RTAS + select PPC_NATIVE + select PPC_XICS + select PPC_ICP_NATIVE + select PPC_ICS_RTAS + select PPC_P7_NAP + select PPC_PCI_CHOICE if EMBEDDED + default y +
arch/powerpc/platforms/powernv/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-y += setup.o +obj-$(CONFIG_SMP) += smp.o
arch/powerpc/platforms/powernv/powernv.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _POWERNV_H +#define _POWERNV_H + +#ifdef CONFIG_SMP +extern void pnv_smp_init (void ); +#else +static inline void pnv_smp_init (void ) { } +#endif + +#endif /* _POWERNV_H */
arch/powerpc/platforms/powernv/setup.c new file +153 -0
153 lines not on this page · raw message
arch/powerpc/platforms/powernv/smp.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [PATCH 06/21] powerpc: Add skeleton PowerNV platform
In message <[email protected]> you wro te:
Quoted 7 lines
This adds a skeletton for the new Power "Non Virtualized" platform which will be used by machines supporting running without an hypervisor, for example in order to run KVM.
These machines will be using a new firmware called OPAL for which the support will be provided by later patches.
Quoted 6 lines
The PowerNV platform is intended to be also usable under the BML environment used internally for early CPU bringup which is why the code also supports using RTAS instead of OPAL in various places.
Signed-off-by Benjamin Herrenschmidt <[email protected]>
Quoted 8 lines
--- arch/powerpc/boot/Makefile | 1 + arch/powerpc/platforms/Kconfig | 1 + arch/powerpc/platforms/Makefile | 1 + arch/powerpc/platforms/powernv/Kconfig | 12 +++ arch/powerpc/platforms/powernv/Makefile | 2 + arch/powerpc/platforms/powernv/powernv.h | 10 ++ arch/powerpc/platforms/powernv/setup.c | 153 ++++++++++++++++++++++++++++
++
arch/powerpc/platforms/Makefil
Quoted 32 lines
arch/powerpc/platforms/powernv/smp.c | 83 ++++++++++++++++ 8 files changed, 263 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/Kconfig create mode 100644 arch/powerpc/platforms/powernv/Makefile create mode 100644 arch/powerpc/platforms/powernv/powernv.h create mode 100644 arch/powerpc/platforms/powernv/setup.c create mode 100644 arch/powerpc/platforms/powernv/smp.carch/powerpc/boot/Makefile +1
-0@@ -171,6 +171,7 @@ quiet_cmd_wrap = WRAP $@ $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux image-$(CONFIG_PPC_PSERIES) += zImage.pseries +image-$(CONFIG_PPC_POWERNV) += zImage.pseries image-$(CONFIG_PPC_MAPLE) += zImage.maple image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries image-$(CONFIG_PPC_PS3) += dtbImage.ps3arch/powerpc/platforms/Kconfig +1
-0@@ -1,5 +1,6 @@ menu "Platform support" +source "arch/powerpc/platforms/powernv/Kconfig" source "arch/powerpc/platforms/pseries/Kconfig" source "arch/powerpc/platforms/iseries/Kconfig" source "arch/powerpc/platforms/chrp/Kconfig"arch/powerpc/platforms/Makefil renamed from arch/powerpc/platforms/Makefile +0
-0
e
arch/powerpc/platforms/
Quoted 12 lines
index 73e2116..2635a22 100644
arch/powerpc/platforms/Makefile +1
-0@@ -14,6 +14,7 @@ obj-$(CONFIG_PPC_82xx) += 82xx/ obj-$(CONFIG_PPC_83xx) += 83xx/ obj-$(CONFIG_FSL_SOC_BOOKE) += 85xx/ obj-$(CONFIG_PPC_86xx) += 86xx/ +obj-$(CONFIG_PPC_POWERNV) += powernv/ obj-$(CONFIG_PPC_PSERIES) += pseries/ obj-$(CONFIG_PPC_ISERIES) += iseries/ obj-$(CONFIG_PPC_MAPLE) += maple/arch/powerpc/platforms/ renamed from arch/powerpc/platforms/powernv/Kconfig +0
-0
powernv/Kconfig
arch/powerpc/platforms
Quoted 18 lines
new file mode 100644
index 0000000..5cd04f5arch/powerpc/platforms/powernv/Kconfig new file +12
-0@@ -0,0 +1,12 @@ +config PPC_POWERNV + depends on PPC64 && PPC_BOOK3S + bool "IBM PowerNV (Non-Virtualized) platform support" + select PPC_RTAS + select PPC_NATIVE + select PPC_XICS + select PPC_ICP_NATIVE + select PPC_ICS_RTAS + select PPC_P7_NAP + select PPC_PCI_CHOICE if EMBEDDED + default y +arch/powerpc/platforms renamed from arch/powerpc/platforms/powernv/Makefile +0
-0
/powernv/Makefile
arch/powerpc/platform
Quoted 8 lines
new file mode 100644
index 0000000..1c43250arch/powerpc/platforms/powernv/Makefile new file +2
-0@@ -0,0 +1,2 @@ +obj-y += setup.o +obj-$(CONFIG_SMP) += smp.oarch/powerpc/platform renamed from arch/powerpc/platforms/powernv/powernv.h +0
-0
s/powernv/powernv.h
arch/powerpc/platforms/
Quoted 16 lines
new file mode 100644
index 0000000..35b7160arch/powerpc/platforms/powernv/powernv.h new file +10
-0@@ -0,0 +1,10 @@ +#ifndef _POWERNV_H +#define _POWERNV_H + +#ifdef CONFIG_SMP +extern void pnv_smp_init (void ); +#else +static inline void pnv_smp_init (void ) { } +#endif + +#endif /* _POWERNV_H */ arch/powerpc/platforms/ renamed from arch/powerpc/platforms/powernv/setup.c +0
-0
powernv/setup.c
arch/powerpc/platforms/po
Quoted 159 lines
new file mode 100644
index 0000000..569f9ccarch/powerpc/platforms/powernv/setup.c new file +153
-0@@ -0,0 +1,153 @@ +/* +* PowerNV setup code. +* +* Copyright 2011 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#undef DEBUG + +#include <linux/cpu.h> +#include <linux/errno.h> +#include <linux/sched.h> +#include <linux/kernel.h> +#include <linux/tty.h> +#include <linux/reboot.h> +#include <linux/init.h> +#include <linux/console.h> +#include <linux/delay.h> +#include <linux/irq.h> +#include <linux/seq_file.h> +#include <linux/of.h> +#include <linux/interrupt.h> +#include <linux/bug.h> + +#include <asm/machdep.h> +#include <asm/firmware.h> +#include <asm/xics.h> + +#include "powernv.h" + +static void __init pnv_setup_arch (void ) +{ +/* Force console to hvc for now until we have sorted out the +* real console situation for the platform. This will make +* hvc_udbg work at least. +*/ +add_preferred_console ("hvc" ,0 ,NULL ); + +/* Initialize SMP */ +pnv_smp_init (); + +/* XXX PCI */ + +/* XXX NVRAM */ + +/* Enable NAP mode */ + powersave_nap =1 ; + +/* XXX PMCS */ +} + +static void __init pnv_init_early (void ) +{ +/* XXX IOMMU */ +} + +static void __init pnv_init_IRQ (void ) +{ +xics_init (); + +WARN_ON (!ppc_md.get_irq); +} + +static void pnv_show_cpuinfo (struct seq_file *m) +{ +struct device_node *root; +const char *model ="" ; + + root =of_find_node_by_path ("/" ); +if (root) + model =of_get_property (root,"model" ,NULL ); +seq_printf (m,"machine\t\t: PowerNV %s\n" , model); +of_node_put (root); +} + +static void pnv_restart (char *cmd) +{ +for (;;); +} + +static void pnv_power_off (void ) +{ +for (;;); +} + +static void pnv_halt (void ) +{ +for (;;); +} + +static unsigned long __init pnv_get_boot_time (void ) +{ +return 0 ; +} + +static void pnv_get_rtc_time (struct rtc_time *rtc_tm) +{ +} + +static int pnv_set_rtc_time (struct rtc_time *tm) +{ +return 0 ; +} + +static void pnv_progress (char *s,unsigned short hex) +{ +} + +#ifdef CONFIG_KEXEC +static void pnv_kexec_cpu_down (int crash_shutdown,int secondary) +{ +xics_kexec_teardown_cpu (secondary); +} +#endif /* CONFIG_KEXEC */ + +static int __init pnv_probe (void ) +{ +unsigned long root =of_get_flat_dt_root (); + +if (!of_flat_dt_is_compatible (root,"ibm,powernv" )) +return 0 ; + +hpte_init_native (); + +pr_debug ("PowerNV detected !\n" ); + +return 1 ; +} + +define_machine (powernv) { + .name = "PowerNV", + .probe = pnv_probe, + .setup_arch = pnv_setup_arch, + .init_early = pnv_init_early, + .init_IRQ = pnv_init_IRQ, + .show_cpuinfo = pnv_show_cpuinfo, + .restart = pnv_restart, + .power_off = pnv_power_off, + .halt = pnv_halt, + .get_boot_time = pnv_get_boot_time, + .get_rtc_time = pnv_get_rtc_time, + .set_rtc_time = pnv_set_rtc_time, + .progress = pnv_progress, + .power_save = power7_idle, + .calibrate_decr = generic_calibrate_decr, +#ifdef CONFIG_KEXEC + .kexec_cpu_down = pnv_kexec_cpu_down, +#endif +};arch/powerpc/platforms/po renamed from arch/powerpc/platforms/powernv/smp.c +0
-0
wernv/smp.c
Quoted 96 lines
new file mode 100644
index 0000000..36c7151arch/powerpc/platforms/powernv/smp.c new file +83
-0@@ -0,0 +1,83 @@ +/* +* SMP support for PowerNV machines. +* +* Copyright 2011 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#include <linux/kernel.h> +#include <linux/module.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/cpu.h> + +#include <asm/irq.h> +#include <asm/smp.h> +#include <asm/paca.h> +#include <asm/machdep.h> +#include <asm/cputable.h> +#include <asm/firmware.h> +#include <asm/system.h> +#include <asm/rtas.h> +#include <asm/vdso_datapage.h> +#include <asm/cputhreads.h> +#include <asm/xics.h> + +#include "powernv.h" + +static void __devinit pnv_smp_setup_cpu (int cpu) +{ +if (cpu != boot_cpuid) +xics_setup_cpu (); +} + +static int pnv_smp_cpu_bootable (unsigned int nr) +{ +/* Special case - we inhibit secondary thread startup +* during boot if the user requests it. +*/ +if (system_state <SYSTEM_RUNNING &&cpu_has_feature (CPU_FTR_SMT )) { +if (!smt_enabled_at_boot &&cpu_thread_in_core (nr) !=0 ) +return 0 ; +if (smt_enabled_at_boot + &&cpu_thread_in_core (nr) >= smt_enabled_at_boot) +return 0 ; + } + +return 1 ; +} + +static struct smp_ops_t pnv_smp_ops = { + .message_pass = smp_muxed_ipi_message_pass, + .cause_ipi =NULL ,/* Filled at runtime by xics_smp_probe() */ + .probe = xics_smp_probe, + .kick_cpu = smp_generic_kick_cpu, + .setup_cpu = pnv_smp_setup_cpu, + .cpu_bootable = pnv_smp_cpu_bootable, +}; + +/* This is called very early during platform setup_arch */ +void __init pnv_smp_init (void ) +{ + smp_ops = &pnv_smp_ops; + +/* XXX We don't yet have a proper entry point from HAL, for +* now we rely on kexec-style entry from BML +*/ + +#ifdef CONFIG_PPC_RTAS +/* Non-lpar has additional take/give timebase */ +if (rtas_token ("freeze-time-base" ) !=RTAS_UNKNOWN_SERVICE ) { + smp_ops->give_timebase = rtas_give_timebase; + smp_ops->take_timebase = rtas_take_timebase; + } +#endif /* CONFIG_PPC_RTAS */ +}Signature · 6 lines
1.7.4.1 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 06/21] powerpc: Add skeleton PowerNV platform
Hi Mikey,
Quoted 3 lines · Michael Neuling
Quoted 1 line
Signed-off-by Benjamin Herrenschmidt <[email protected]>Giggity-Giggity-by Michael Neuling <[email protected]>
Burps?
Gr{oetje,eeting}s,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k= .org
In personal conversations with technical people, I call myself a hacker. Bu= t
when I'm talking to journalists I just say "programmer" or something like t= hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds
PATCH 7/21 of: Change logic to overwrite cmd_line with CONFIG_CMDLINE
In reply to Benjamin HerrenschmidtWe used to overwrite with CONFIG_CMDLINE if we found a chosen node but failed to get bootargs out of it or they were empty, unless CONFIG_CMDLINE_FORCE is set.
Instead change that to overwrite if cmd_line is non empty after the bootargs check. It allows arch code to have other mechanisms to retrieve the command line prior to parsing the device-tree.
Note: CONFIG_CMDLINE_FORCE case should ideally be handled elsewhere as it won't work as it-is if the device-tree has no /chosen node
--- drivers/of/fdt.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/of/fdt.c +1 -1
@@ -683,7 +683,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,#ifdef CONFIG_CMDLINE #ifndef CONFIG_CMDLINE_FORCE - if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) + if (!cmd_line[0])#endif strlcpy (data,CONFIG_CMDLINE ,COMMAND_LINE_SIZE );#endif /* CONFIG_CMDLINE */
Signature · 1 line
1.7.4.1
PATCH 8/21 powerpc/powernv: Add CPU hotplug support
In reply to Benjamin HerrenschmidtUnplugged CPU go into NAP mode in a loop until woken up
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/platforms/powernv/smp.c | 78 +++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -323,7 +323,7 @@ config SWIOTLB config HOTPLUG_CPU bool "Support for enabling/disabling CPUs" - depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC) + depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC || PPC_POWERNV) ---help--- Say Y here to be able to disable and re-enable individual CPUs at runtime on SMP machines.
arch/powerpc/platforms/powernv/smp.c +77 -1
100 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 9/21 powerpc/powernv: Add OPAL takeover from PowerVM
In reply to Benjamin HerrenschmidtOn machines supporting the OPAL firmware version 1, the system is initially booted under pHyp. We then use a special hypercall to verify if OPAL is available and if it is, we then trigger a "takeover" which disables pHyp and loads the OPAL runtime firmware, giving control to the kernel in hypervisor mode.
This patch add the necessary code to detect that the OPAL takeover capability is present when running under PowerVM (aka pHyp) and perform said takeover to get hypervisor control of the processor.
To perform the takeover, we must first use RTAS (within Open Firmware runtime environment) to start all processors & threads, in order to give control to OPAL on all of them. We then call the takeover hypercall on everybody, OPAL will re-enter the kernel main entry point passing it a flat device-tree.
--- arch/powerpc/include/asm/opal.h | 50 +++++ arch/powerpc/kernel/head_64.S | 4 + arch/powerpc/kernel/prom_init.c | 239 ++++++++++++++++++++++-- arch/powerpc/kernel/prom_init_check.sh | 3 +- arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/opal-takeover.S | 140 ++++++++++++++ 6 files changed, 419 insertions(+), 19 deletions(-) create mode 100644 arch/powerpc/include/asm/opal.h create mode 100644 arch/powerpc/platforms/powernv/opal-takeover.S
arch/powerpc/include/asm/opal.h new file +50 -0
@@ -0,0 +1,50 @@ +/* +* PowerNV OPAL definitions. +* +* Copyright 2011 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef __OPAL_H +#define __OPAL_H + +/****** Takeover interface ********/ + +/* PAPR H-Call used to querty the HAL existence and/or instanciate +* it from within pHyp (tech preview only). +* +* This is exclusively used in prom_init.c +*/ + +#ifndef __ASSEMBLY__ + +struct opal_takeover_args { +u64 k_image;/* r4 */ +u64 k_size;/* r5 */ +u64 k_entry;/* r6 */ +u64 k_entry2;/* r7 */ +u64 hal_addr;/* r8 */ +u64 rd_image;/* r9 */ +u64 rd_size;/* r10 */ +u64 rd_loc;/* r11 */ +}; + +extern long opal_query_takeover (u64 *hal_size,u64 *hal_align); + +extern long opal_do_takeover (struct opal_takeover_args *args); + +extern int opal_enter_rtas (struct rtas_args *args, +unsigned long data, +unsigned long entry); + + +#endif /* __ASSEMBLY__ */ + +/****** OPAL APIs ******/ + + +#endif /* __OPAL_H */
arch/powerpc/kernel/head_64.S +4 -0
@@ -51,6 +51,10 @@ * For pSeries or server processors: * 1. The MMU is off & open firmware is running in real mode. * 2. The kernel is entered at __start + * -or- For OPAL entry: + * 1. The MMU is off, processor in HV mode, primary CPU enters at 0 + * with device-tree in gpr3 + * 2. Secondary processors enter at 0x60 with PIR in gpr3 * * For iSeries: * 1. The MMU is on (as it always is for iSeries)
arch/powerpc/kernel/prom_init.c +222 -17
302 lines not on this page · raw message
arch/powerpc/kernel/prom_init_check.sh +2 -1
@@ -20,7 +20,8 @@ WHITELIST="add_reloc_offset __bss_start __bss_stop copy_and_flush _end enter_prom memcpy memset reloc_offset __secondary_hold __secondary_hold_acknowledge __secondary_hold_spinloop __start strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224 -reloc_got2 kernstart_addr memstart_addr linux_banner" +reloc_got2 kernstart_addr memstart_addr linux_banner _stext +opal_query_takeover opal_do_takeover opal_enter_rtas opal_secondary_entry" NM="$1" OBJ="$2"
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-y += setup.o +obj-y += setup.o opal-takeover.o obj-$(CONFIG_SMP) += smp.o
arch/powerpc/platforms/powernv/opal-takeover.S new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 10/21 powerpc/powernv: Get kernel command line accross OPAL takeover
In reply to Benjamin HerrenschmidtWe stash it in boot_command_line which isn't in BSS and so won't be overwritten. We then use that as a default cmd_line before we walk the device-tree.
--- arch/powerpc/kernel/prom.c | 7 +++++++ arch/powerpc/kernel/prom_init.c | 4 ++++ arch/powerpc/kernel/prom_init_check.sh | 3 ++- 3 files changed, 13 insertions(+), 1 deletions(-)
arch/powerpc/kernel/prom.c +7 -0
@@ -712,6 +712,13 @@ void __init early_init_devtree(void *params)of_scan_flat_dt (early_init_dt_scan_phyp_dump,NULL );#endif +/* Pre-initialize the cmd_line with the content of boot_commmand_line, +* which will be empty except when the content of the variable has +* been overriden by a bootloading mechanism. This happens typically +* with HAL takeover +*/ +strlcpy (cmd_line, boot_command_line,COMMAND_LINE_SIZE ); +/* Retrieve various informations from the /chosen node of the * device-tree, including the platform type, initrd location and * size, TCE reserve, and more ...
arch/powerpc/kernel/prom_init.c +4 -0
@@ -1449,6 +1449,10 @@ static void prom_opal_takeover(void) opal_addr = top_addr; args->hal_addr = opal_addr; +/* Copy the command line to the kernel image */ +strlcpy (RELOC (boot_command_line),RELOC (prom_cmd_line), +COMMAND_LINE_SIZE ); +prom_debug (" k_image = 0x%lx\n" , args->k_image);prom_debug (" k_size = 0x%lx\n" , args->k_size);prom_debug (" k_entry = 0x%lx\n" , args->k_entry);
arch/powerpc/kernel/prom_init_check.sh +2 -1
@@ -21,7 +21,8 @@ _end enter_prom memcpy memset reloc_offset __secondary_hold __secondary_hold_acknowledge __secondary_hold_spinloop __start strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224 reloc_got2 kernstart_addr memstart_addr linux_banner _stext -opal_query_takeover opal_do_takeover opal_enter_rtas opal_secondary_entry" +opal_query_takeover opal_do_takeover opal_enter_rtas opal_secondary_entry +boot_command_line" NM="$1" OBJ="$2"
Signature · 1 line
1.7.4.1
PATCH 11/21 powerpc/powernv: Basic support for OPAL
In reply to Benjamin HerrenschmidtAdd definition of OPAL interfaces along with the wrappers to call into OPAL runtime and the early device-tree parsing hook to locate the OPAL runtime firmware.
--- arch/powerpc/include/asm/firmware.h | 10 + arch/powerpc/include/asm/opal.h | 382 +++++++++++++++++++++++- arch/powerpc/kernel/prom.c | 7 + arch/powerpc/platforms/powernv/Kconfig | 8 +- arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/opal-wrappers.S | 101 +++++++ arch/powerpc/platforms/powernv/opal.c | 154 ++++++++++ arch/powerpc/platforms/powernv/setup.c | 6 + arch/powerpc/platforms/powernv/smp.c | 25 ++- 9 files changed, 690 insertions(+), 5 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/opal-wrappers.S create mode 100644 arch/powerpc/platforms/powernv/opal.c
arch/powerpc/include/asm/firmware.h +10 -0
@@ -48,6 +48,8 @@#define FW_FEATURE_CMO ASM_CONST(0x0000000002000000)#define FW_FEATURE_VPHN ASM_CONST(0x0000000004000000)#define FW_FEATURE_XCMO ASM_CONST(0x0000000008000000) +#define FW_FEATURE_OPAL ASM_CONST(0x0000000010000000) +#define FW_FEATURE_OPALv2 ASM_CONST(0x0000000020000000)#ifndef __ASSEMBLY__
@@ -65,6 +67,8 @@ enum {FW_FEATURE_PSERIES_ALWAYS =0 ,FW_FEATURE_ISERIES_POSSIBLE =FW_FEATURE_ISERIES |FW_FEATURE_LPAR ,FW_FEATURE_ISERIES_ALWAYS =FW_FEATURE_ISERIES |FW_FEATURE_LPAR , +FW_FEATURE_POWERNV_POSSIBLE =FW_FEATURE_OPAL | FW_FEATURE_OPALv2, +FW_FEATURE_POWERNV_ALWAYS =0 ,FW_FEATURE_PS3_POSSIBLE =FW_FEATURE_LPAR |FW_FEATURE_PS3_LV1 ,FW_FEATURE_PS3_ALWAYS =FW_FEATURE_LPAR |FW_FEATURE_PS3_LV1 , FW_FEATURE_CELLEB_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_BEAT,
@@ -78,6 +82,9 @@ enum {#ifdef CONFIG_PPC_ISERIES FW_FEATURE_ISERIES_POSSIBLE |#endif +#ifdef CONFIG_PPC_POWERNV + FW_FEATURE_POWERNV_POSSIBLE | +#endif #ifdef CONFIG_PPC_PS3 FW_FEATURE_PS3_POSSIBLE |#endif
@@ -95,6 +102,9 @@ enum {#ifdef CONFIG_PPC_ISERIES FW_FEATURE_ISERIES_ALWAYS &#endif +#ifdef CONFIG_PPC_POWERNV + FW_FEATURE_POWERNV_ALWAYS & +#endif #ifdef CONFIG_PPC_PS3 FW_FEATURE_PS3_ALWAYS &#endif
arch/powerpc/include/asm/opal.h +381 -1
395 lines not on this page · raw message
arch/powerpc/kernel/prom.c +7 -0
@@ -54,6 +54,8 @@#include <asm/pci-bridge.h> #include <asm/phyp_dump.h> #include <asm/kexec.h> +#include <asm/opal.h> +#include <mm/mmu_decl.h> #ifdef DEBUG
@@ -707,6 +709,11 @@ void __init early_init_devtree(void *params)of_scan_flat_dt (early_init_dt_scan_rtas,NULL );#endif +#ifdef CONFIG_PPC_POWERNV +/* Some machines might need OPAL info for debugging, grab it now. */ +of_scan_flat_dt (early_init_dt_scan_opal,NULL ); +#endif +#ifdef CONFIG_PHYP_DUMP /* scan tree to see if dump occurred during last boot */ of_scan_flat_dt (early_init_dt_scan_phyp_dump,NULL );
arch/powerpc/platforms/powernv/Kconfig +6 -2
@@ -1,12 +1,16 @@ config PPC_POWERNV depends on PPC64 && PPC_BOOK3S bool "IBM PowerNV (Non-Virtualized) platform support" - select PPC_RTAS select PPC_NATIVE select PPC_XICS select PPC_ICP_NATIVE - select PPC_ICS_RTAS select PPC_P7_NAP select PPC_PCI_CHOICE if EMBEDDED default y +config PPC_POWERNV_RTAS + depends on PPC_POWERNV + bool "Support for RTAS based PowerNV platforms such as BML" + default y + select PPC_ICS_RTAS + select PPC_RTAS
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-y += setup.o opal-takeover.o +obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o obj-$(CONFIG_SMP) += smp.o
arch/powerpc/platforms/powernv/opal-wrappers.S new file +101 -0
101 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal.c new file +154 -0
154 lines not on this page · raw message
arch/powerpc/platforms/powernv/setup.c +6 -0
@@ -74,6 +74,12 @@ static void pnv_show_cpuinfo(struct seq_file *m)if (root) model =of_get_property (root,"model" ,NULL );seq_printf (m,"machine\t\t: PowerNV %s\n" , model); +if (firmware_has_feature (FW_FEATURE_OPALv2)) +seq_printf (m,"firmware\t: OPAL v2\n" ); +else if (firmware_has_feature (FW_FEATURE_OPAL )) +seq_printf (m,"firmware\t: OPAL v1\n" ); +else +seq_printf (m,"firmware\t: BML\n" );of_node_put (root); }
arch/powerpc/platforms/powernv/smp.c +24 -1
@@ -30,6 +30,7 @@#include <asm/vdso_datapage.h> #include <asm/cputhreads.h> #include <asm/xics.h> +#include <asm/opal.h> #include "powernv.h"
@@ -62,6 +63,28 @@ static int pnv_smp_cpu_bootable(unsigned int nr)return 1 ; } +int __devinit pnv_smp_kick_cpu (int nr) +{ +unsigned int pcpu =get_hard_smp_processor_id (nr); +unsigned long start_here =__pa (*((unsigned long *) + generic_secondary_smp_init)); +long rc; + +BUG_ON (nr <0 || nr >=NR_CPUS ); + +/* On OPAL v2 the CPU are still spinning inside OPAL itself, +* get them back now +*/ +if (firmware_has_feature (FW_FEATURE_OPALv2)) { +pr_devel ("OPAL: Starting CPU %d (HW 0x%x)...\n" , nr, pcpu); + rc =opal_start_cpu (pcpu, start_here); +if (rc !=OPAL_SUCCESS ) +pr_warn ("OPAL Error %ld starting CPU %d\n" , + rc, nr); + } +return smp_generic_kick_cpu (nr); +} +#ifdef CONFIG_HOTPLUG_CPU static int pnv_smp_cpu_disable (void )
@@ -127,7 +150,7 @@ static struct smp_ops_t pnv_smp_ops = { .message_pass = smp_muxed_ipi_message_pass, .cause_ipi = NULL, /* Filled at runtime by xics_smp_probe() */ .probe = xics_smp_probe, - .kick_cpu = smp_generic_kick_cpu, + .kick_cpu = pnv_smp_kick_cpu, .setup_cpu = pnv_smp_setup_cpu, .cpu_bootable = pnv_smp_cpu_bootable,#ifdef CONFIG_HOTPLUG_CPU
Signature · 1 line
1.7.4.1
PATCH 12/21 powerpc/powernv: Add support for instanciating OPAL v2 from Open Firmware
In reply to Benjamin HerrenschmidtOPAL v2 is instantiated in a way similar to RTAS using Open Firmware client interface calls, and the resulting address and entry point are put in the device-tree
--- arch/powerpc/kernel/prom_init.c | 136 +++++++++++++++++++++++++++++++++------ 1 files changed, 117 insertions(+), 19 deletions(-)
arch/powerpc/kernel/prom_init.c +117 -19
@@ -140,7 +140,9 @@ struct mem_map_entry {typedef u32 cell_t ; -extern void __start (unsigned long r3,unsigned long r4,unsigned long r5); +extern void __start (unsigned long r3,unsigned long r4,unsigned long r5, +unsigned long r6,unsigned long r7,unsigned long r8, +unsigned long r9);#ifdef CONFIG_PPC64 extern int enter_prom (struct prom_args *args,unsigned long entry);
@@ -1293,6 +1295,11 @@ static int __initdata prom_rtas_start_cpu;static u64 __initdata prom_rtas_data;static u64 __initdata prom_rtas_entry; +#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL +static u64 __initdata prom_opal_base; +static u64 __initdata prom_opal_entry; +#endif +/* XXX Don't change this structure without updating opal-takeover.S */ static struct opal_secondary_data { s64 ack; /* 0 */
@@ -1468,6 +1475,76 @@ static void prom_opal_takeover(void)for (;;) opal_do_takeover(args); } + +/* +* Allocate room for and instantiate OPAL +*/ +static void __init prom_instantiate_opal (void ) +{ +phandle opal_node; +ihandle opal_inst; +u64 base, entry; +u64 size =0 , align =0x10000 ; +u32 rets[2 ]; + +prom_debug ("prom_instantiate_opal: start...\n" ); + + opal_node =call_prom ("finddevice" ,1 ,1 ,ADDR ("/ibm,opal" )); +prom_debug ("opal_node: %x\n" , opal_node); +if (!PHANDLE_VALID (opal_node)) +return ; + +prom_getprop (opal_node,"opal-runtime-size" , &size,sizeof (size)); +if (size ==0 ) +return ; +prom_getprop (opal_node,"opal-runtime-alignment" , &align, +sizeof (align)); + + base =alloc_down (size, align,0 ); +if (base ==0 ) { +prom_printf ("OPAL allocation failed !\n" ); +return ; + } + + opal_inst =call_prom ("open" ,1 ,1 ,ADDR ("/ibm,opal" )); +if (!IHANDLE_VALID (opal_inst)) { +prom_printf ("opening opal package failed (%x)\n" , opal_inst); +return ; + } + +prom_printf ("instantiating opal at 0x%x..." , base); + +if (call_prom_ret ("call-method" ,4 ,3 , rets, +ADDR ("load-opal-runtime" ), + opal_inst, + base >>32 , base &0xffffffff ) !=0 + || (rets[0 ] ==0 && rets[1 ] ==0 )) { +prom_printf (" failed\n" ); +return ; + } + entry = (((u64 )rets[0 ]) <<32 ) | rets[1 ]; + +prom_printf (" done\n" ); + +reserve_mem (base, size); + +prom_debug ("opal base = 0x%x\n" , base); +prom_debug ("opal align = 0x%x\n" , align); +prom_debug ("opal entry = 0x%x\n" , entry); +prom_debug ("opal size = 0x%x\n" , (long )size); + +prom_setprop (opal_node,"/ibm,opal" ,"opal-base-address" , + &base,sizeof (base)); +prom_setprop (opal_node,"/ibm,opal" ,"opal-entry-address" , + &entry,sizeof (entry)); + +#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL +RELOC (prom_opal_base) = base; +RELOC (prom_opal_entry) = entry; +#endif +prom_debug ("prom_instantiate_opal: end...\n" ); +} +#endif /* CONFIG_PPC_POWERNV */ /*
@@ -1863,7 +1940,7 @@ static int __init prom_find_machine_type(void)int x;#endif -/* Look for a PowerMac */ +/* Look for a PowerMac or a Cell */ len =prom_getprop (_prom->root,"compatible" , compat,sizeof (compat)-1 );if (len >0 ) {
@@ -1889,7 +1966,11 @@ static int __init prom_find_machine_type(void) } }#ifdef CONFIG_PPC64 -/* If not a mac, try to figure out if it's an IBM pSeries or any other +/* Try to detect OPAL */ +if (PHANDLE_VALID (call_prom ("finddevice" ,1 ,1 ,ADDR ("/ibm,opal" )))) +return PLATFORM_OPAL ; + +/* Try to figure out if it's an IBM pSeries or any other * PAPR compliant platform. We assume it is if : * - /device_type is "chrp" (please, do NOT use that for future * non-IBM designs !
@@ -2116,7 +2197,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,unsigned long soff;unsigned char *valp;static char pname[MAX_PROPERTY_NAME ]; -int l, room; +int l, room, has_phandle;dt_push_token (OF_DT_BEGIN_NODE , mem_start, mem_end);
@@ -2200,19 +2281,26 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, valp =make_room (mem_start, mem_end, l,4 );call_prom ("getprop" ,4 ,1 , node,RELOC (pname), valp, l); *mem_start =_ALIGN (*mem_start,4 ); + +if (!strcmp (RELOC (pname),RELOC ("phandle" ))) + has_phandle =1 ; } -/* Add a "linux,phandle" property. */ - soff =dt_find_string (RELOC ("linux,phandle" )); -if (soff ==0 ) -prom_printf ("WARNING: Can't find string index for" -" <linux-phandle> node %s\n" , path); -else { -dt_push_token (OF_DT_PROP , mem_start, mem_end); -dt_push_token (4 , mem_start, mem_end); -dt_push_token (soff, mem_start, mem_end); - valp =make_room (mem_start, mem_end,4 ,4 ); - *(u32 *)valp = node; +/* Add a "linux,phandle" property if no "phandle" property already +* existed (can happen with OPAL) +*/ +if (!has_phandle) { + soff =dt_find_string (RELOC ("linux,phandle" )); +if (soff ==0 ) +prom_printf ("WARNING: Can't find string index for" +" <linux-phandle> node %s\n" , path); +else { +dt_push_token (OF_DT_PROP , mem_start, mem_end); +dt_push_token (4 , mem_start, mem_end); +dt_push_token (soff, mem_start, mem_end); + valp =make_room (mem_start, mem_end,4 ,4 ); + *(u32 *)valp = node; + } }/* do all our children */
@@ -2746,6 +2834,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,* between pSeries SMP and pSeries LPAR */ RELOC (of_platform) =prom_find_machine_type (); +prom_printf ("Detected machine type: %x\n" ,RELOC (of_platform));#ifndef CONFIG_RELOCATABLE /* Bail if this is a kdump kernel. */
@@ -2807,7 +2896,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,* On non-powermacs, try to instantiate RTAS. PowerMacs don't * have a usable RTAS implementation. */ -if (RELOC (of_platform) !=PLATFORM_POWERMAC ) +if (RELOC (of_platform) !=PLATFORM_POWERMAC && +RELOC (of_platform) !=PLATFORM_OPAL )prom_instantiate_rtas ();#ifdef CONFIG_PPC_POWERNV
@@ -2818,7 +2908,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,prom_opal_hold_cpus (); prom_opal_takeover(); } - } + }else if (RELOC (of_platform) ==PLATFORM_OPAL ) +prom_instantiate_opal ();#endif /*
@@ -2826,7 +2917,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,* * PowerMacs use a different mechanism to spin CPUs */ -if (RELOC (of_platform) !=PLATFORM_POWERMAC ) +if (RELOC (of_platform) !=PLATFORM_POWERMAC && +RELOC (of_platform) !=PLATFORM_OPAL )prom_hold_cpus ();/*
@@ -2894,7 +2986,13 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,reloc_got2 (-offset);#endif -__start (hdr, kbase,0 ); +#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL +/* OPAL early debug gets the OPAL base & entry in r8 and r9 */ +__start (hdr, kbase,0 ,0 ,0 , +RELOC (prom_opal_base),RELOC (prom_opal_entry)); +#else +__start (hdr, kbase,0 ,0 ,0 ,0 ,0 ); +#endif return 0 ; }
Signature · 1 line
1.7.4.1
PATCH 13/21 powerpc/powernv: Support for OPAL console
In reply to Benjamin HerrenschmidtThis adds a udbg and an hvc console backend for supporting a console using the OPAL console interfaces.
On OPAL v1 we have hvc0 mapped to whatever console the system was configured for (network or hvsi serial port) via the service processor.
On OPAL v2 we have hvcN mapped to the Nth console provided by OPAL which generally corresponds to:
hvc0 : network console (raw protocol)
hvc1 : serial port S1 (hvsi)
hvc2 : serial port S2 (hvsi)
Note: At this point, early debug console only works with OPAL v1 and shouldn't be enabled in a normal kernel.
--- arch/powerpc/Kconfig.debug | 31 +++ arch/powerpc/include/asm/opal.h | 5 + arch/powerpc/include/asm/udbg.h | 2 + arch/powerpc/kernel/head_64.S | 14 +- arch/powerpc/kernel/udbg.c | 4 + arch/powerpc/platforms/powernv/opal.c | 31 ++- arch/powerpc/platforms/powernv/setup.c | 14 +- drivers/tty/hvc/Kconfig | 9 + drivers/tty/hvc/Makefile | 1 + drivers/tty/hvc/hvc_opal.c | 424 ++++++++++++++++++++++++++++++++ drivers/tty/hvc/hvsi_lib.c | 4 +- 11 files changed, 517 insertions(+), 22 deletions(-) create mode 100644 drivers/tty/hvc/hvc_opal.c
arch/powerpc/Kconfig.debug +31 -0
@@ -257,8 +257,27 @@ config PPC_EARLY_DEBUG_WSP depends on PPC_WSP select PPC_UDBG_16550 +config PPC_EARLY_DEBUG_OPAL_RAW + bool "OPAL raw console" + depends on HVC_OPAL + help + Select this to enable early debugging for the PowerNV platform + using a "raw" console + +config PPC_EARLY_DEBUG_OPAL_HVSI + bool "OPAL hvsi console" + depends on HVC_OPAL + help + Select this to enable early debugging for the PowerNV platform + using an "hvsi" console + endchoice +config PPC_EARLY_DEBUG_OPAL + def_bool y + depends on PPC_EARLY_DEBUG_OPAL_RAW || PPC_EARLY_DEBUG_OPAL_HVSI + + config PPC_EARLY_DEBUG_HVSI_VTERMNO hex "vterm number to use with early debug HVSI" depends on PPC_EARLY_DEBUG_LPAR_HVSI
@@ -267,6 +286,18 @@ config PPC_EARLY_DEBUG_HVSI_VTERMNO You probably want 0x30000000 for your first serial port and 0x30000001 for your second one +config PPC_EARLY_DEBUG_OPAL_VTERMNO + hex "vterm number to use with OPAL early debug" + depends on PPC_EARLY_DEBUG_OPAL + default "0" + help + This correspond to which /dev/hvcN you want to use for early + debug. + + On OPAL v1 (takeover) this should always be 0 + On OPAL v2, this will be 0 for network console and 1 or 2 for + the machine built-in serial ports. + config PPC_EARLY_DEBUG_44x_PHYSLOW hex "Low 32 bits of early debug UART physical address" depends on PPC_EARLY_DEBUG_44x
arch/powerpc/include/asm/opal.h +5 -0
@@ -425,6 +425,11 @@ extern void hvc_opal_init_early(void);extern int early_init_dt_scan_opal (unsigned long node,const char *uname,int depth,void *data); +extern int opal_get_chars (uint32_t vtermno,char *buf,int count); +extern int opal_put_chars (uint32_t vtermno,const char *buf,int total_len); + +extern void hvc_opal_init_early (void ); +#endif /* __ASSEMBLY__ */ #endif /* __OPAL_H */
arch/powerpc/include/asm/udbg.h +2 -0
@@ -54,6 +54,8 @@ extern void __init udbg_init_40x_realmode(void);extern void __init udbg_init_cpm (void );extern void __init udbg_init_usbgecko (void );extern void __init udbg_init_wsp (void ); +extern void __init udbg_init_debug_opal_raw (void ); +extern void __init udbg_init_debug_opal_hvsi (void );#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/head_64.S +13 -1
@@ -53,7 +53,8 @@ * 2. The kernel is entered at __start * -or- For OPAL entry: * 1. The MMU is off, processor in HV mode, primary CPU enters at 0 - * with device-tree in gpr3 + * with device-tree in gpr3. We also get OPAL base in r8 and + * entry in r9 for debugging purposes * 2. Secondary processors enter at 0x60 with PIR in gpr3 * * For iSeries:
@@ -335,6 +336,11 @@ _GLOBAL(__start_initialization_multiplatform) /* Save parameters */ mr r31,r3 mr r30,r4 +#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL + /* Save OPAL entry */ + mr r28,r8 + mr r29,r9 +#endif #ifdef CONFIG_PPC_BOOK3E bl .start_initialization_book3e
@@ -711,6 +717,12 @@ _INIT_STATIC(start_here_multiplatform) bdnz 3b 4: +#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL + /* Setup OPAL entry */ + std r28,0(r11); + std r29,8(r11); +#endif + #ifndef CONFIG_PPC_BOOK3E mfmsr r6 ori r6,r6,MSR_RI
arch/powerpc/kernel/udbg.c +4 -0
@@ -67,6 +67,10 @@ void __init udbg_early_init(void)udbg_init_usbgecko ();#elif defined(CONFIG_PPC_EARLY_DEBUG_WSP )udbg_init_wsp (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_RAW ) +udbg_init_debug_opal_raw (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI ) +udbg_init_debug_opal_hvsi ();#endif #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/powernv/opal.c +19 -12
@@ -67,7 +67,7 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count)u64 evt;if (!opal.entry) -return 0 ; +return -ENODEV ;opal_poll_events (&evt);if ((evt &OPAL_EVENT_CONSOLE_INPUT ) ==0 )return 0 ;
@@ -81,31 +81,38 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count)int opal_put_chars (uint32_t vtermno,const char *data,int total_len) {int written =0 ; -s64 len, rc =OPAL_BUSY ; +s64 len, rc;unsigned long flags;u64 evt;if (!opal.entry) -return 0 ; +return -ENODEV ;/* We want put_chars to be atomic to avoid mangling of hvsi * packets. To do that, we first test for room and return -* -EAGAIN if there isn't enough +* -EAGAIN if there isn't enough. +* +* Unfortunately, opal_console_write_buffer_space() doesn't +* appear to work on opal v1, so we just assume there is +* enough room and be done with it */ spin_lock_irqsave (&opal_write_lock, flags); - rc =opal_console_write_buffer_space (vtermno, &len); -if (rc || len < total_len) { -spin_unlock_irqrestore (&opal_write_lock, flags); -/* Closed -> drop characters */ -if (rc) -return total_len; -opal_poll_events (&evt); -return -EAGAIN ; +if (firmware_has_feature (FW_FEATURE_OPALv2)) { + rc =opal_console_write_buffer_space (vtermno, &len); +if (rc || len < total_len) { +spin_unlock_irqrestore (&opal_write_lock, flags); +/* Closed -> drop characters */ +if (rc) +return total_len; +opal_poll_events (&evt); +return -EAGAIN ; + } }/* We still try to handle partial completions, though they * should no longer happen. */ + rc =OPAL_BUSY ;while (total_len >0 && (rc ==OPAL_BUSY || rc ==OPAL_BUSY_EVENT || rc ==OPAL_SUCCESS )) { len = total_len;
arch/powerpc/platforms/powernv/setup.c +7 -7
@@ -29,17 +29,12 @@#include <asm/machdep.h> #include <asm/firmware.h> #include <asm/xics.h> +#include <asm/opal.h> #include "powernv.h" static void __init pnv_setup_arch (void ) { -/* Force console to hvc for now until we have sorted out the -* real console situation for the platform. This will make -* hvc_udbg work at least. -*/ -add_preferred_console ("hvc" ,0 ,NULL ); -/* Initialize SMP */ pnv_smp_init ();
@@ -55,7 +50,12 @@ static void __init pnv_setup_arch(void)static void __init pnv_init_early (void ) { -/* XXX IOMMU */ +#ifdef CONFIG_HVC_OPAL +if (firmware_has_feature (FW_FEATURE_OPAL )) +hvc_opal_init_early (); + else +#endif +add_preferred_console ("hvc" ,0 ,NULL ); }static void __init pnv_init_IRQ (void )
drivers/tty/hvc/Kconfig +9 -0
@@ -34,6 +34,15 @@ config HVC_ISERIES help iSeries machines support a hypervisor virtual console. +config HVC_OPAL + bool "OPAL Console support" + depends on PPC_POWERNV + select HVC_DRIVER + select HVC_IRQ + default y + help + PowerNV machines running under OPAL need that driver to get a console + config HVC_RTAS bool "IBM RTAS Console support" depends on PPC_RTAS
drivers/tty/hvc/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi_lib.o +obj-$(CONFIG_HVC_OPAL) += hvc_opal.o hvsi_lib.o obj-$(CONFIG_HVC_OLD_HVSI) += hvsi.o obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
drivers/tty/hvc/hvc_opal.c new file +424 -0
424 lines not on this page · raw message
drivers/tty/hvc/hvsi_lib.c +2 -2
@@ -183,7 +183,7 @@ int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count)unsigned int tries, read =0 ;if (WARN_ON (!pv)) -return 0 ; +return -ENXIO ;/* If we aren't open, don't do anything in order to avoid races * with connection establishment. The hvc core will call this
@@ -234,7 +234,7 @@ int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count)int rc, adjcount =min (count,HVSI_MAX_OUTGOING_DATA );if (WARN_ON (!pv)) -return 0 ; +return -ENODEV ; dp.hdr.type =VS_DATA_PACKET_HEADER ; dp.hdr.len = adjcount +sizeof (struct hvsi_header );
Signature · 1 line
1.7.4.1
PATCH 14/21 powerpc/powernv: Hookup reboot and poweroff functions
In reply to Benjamin HerrenschmidtThis calls the respective HAL functions, and spin on hal_poll_event() to ensure the HAL has a chance to communicate with the FSP to trigger the reboot or shutdown operation
--- arch/powerpc/platforms/powernv/setup.c | 32 ++++++++++++++++++++++++++------ 1 files changed, 26 insertions(+), 6 deletions(-)
arch/powerpc/platforms/powernv/setup.c +26 -6
@@ -83,19 +83,39 @@ static void pnv_show_cpuinfo(struct seq_file *m)of_node_put (root); } -static void pnv_restart (char *cmd) +static void __noreturn pnv_restart (char *cmd) { -for (;;); +long rc =OPAL_BUSY ; + +while (rc ==OPAL_BUSY || rc ==OPAL_BUSY_EVENT ) { + rc =opal_cec_reboot (); +if (rc ==OPAL_BUSY_EVENT ) +opal_poll_events (NULL ); +else +mdelay (10 ); + } +for (;;) +opal_poll_events (NULL ); } -static void pnv_power_off (void ) +static void __noreturn pnv_power_off (void ) { -for (;;); +long rc =OPAL_BUSY ; + +while (rc ==OPAL_BUSY || rc ==OPAL_BUSY_EVENT ) { + rc =opal_cec_power_down (0 ); +if (rc ==OPAL_BUSY_EVENT ) +opal_poll_events (NULL ); +else +mdelay (10 ); + } +for (;;) +opal_poll_events (NULL ); } -static void pnv_halt (void ) +static void __noreturn pnv_halt (void ) { -for (;;); +pnv_power_off (); }static unsigned long __init pnv_get_boot_time (void )
Signature · 1 line
1.7.4.1
PATCH 15/21 powerpc/powernv: Add RTC and NVRAM support plus RTAS fallbacks
In reply to Benjamin HerrenschmidtImplements OPAL RTC and NVRAM support and wire all that up to the powernv platform.
We use RTAS for RTC as a fallback if available. Using RTAS for nvram is not supported yet, pending some rework/cleanup and generalization of the pSeries & CHRP code. We also use RTAS fallbacks for power off and reboot
--- arch/powerpc/include/asm/opal.h | 6 ++ arch/powerpc/platforms/powernv/Makefile | 2 + arch/powerpc/platforms/powernv/opal-nvram.c | 88 ++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-rtc.c | 97 +++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/setup.c | 57 ++++++++++------ 5 files changed, 229 insertions(+), 21 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/opal-nvram.c create mode 100644 arch/powerpc/platforms/powernv/opal-rtc.c
arch/powerpc/include/asm/opal.h +6 -0
@@ -430,6 +430,12 @@ extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);extern void hvc_opal_init_early (void ); +struct rtc_time ; +extern int opal_set_rtc_time (struct rtc_time *tm); +extern void opal_get_rtc_time (struct rtc_time *tm); +extern unsigned long opal_get_boot_time (void ); +extern void opal_nvram_init (void ); +#endif /* __ASSEMBLY__ */ #endif /* __OPAL_H */
arch/powerpc/platforms/powernv/Makefile +2 -0
@@ -1,2 +1,4 @@ obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o +obj-y += opal-rtc.o opal-nvram.o + obj-$(CONFIG_SMP) += smp.o
arch/powerpc/platforms/powernv/opal-nvram.c new file +88 -0
88 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-rtc.c new file +97 -0
97 lines not on this page · raw message
arch/powerpc/platforms/powernv/setup.c +36 -21
102 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 16/21 powerpc/powernv: Add OPAL ICS backend
In reply to Benjamin HerrenschmidtOPAL handles HW access to the various ICS or equivalent chips for us (with the exception of p5ioc2 based HEA which uses a different backend) similarily to what RTAS does on pSeries.
--- arch/powerpc/include/asm/xics.h | 19 +++ arch/powerpc/sysdev/xics/Makefile | 1 + arch/powerpc/sysdev/xics/ics-opal.c | 244 ++++++++++++++++++++++++++++++++ arch/powerpc/sysdev/xics/xics-common.c | 8 +- 4 files changed, 266 insertions(+), 6 deletions(-) create mode 100644 arch/powerpc/sysdev/xics/ics-opal.c
arch/powerpc/include/asm/xics.h +19 -0
@@ -27,10 +27,18 @@#define MAX_NUM_PRIORITIES 3/* Native ICP */ +#ifdef CONFIG_PPC_ICP_NATIVE extern int icp_native_init (void ); +#else +static inline int icp_native_init (void ) {return -ENODEV ; } +#endif /* PAPR ICP */ +#ifdef CONFIG_PPC_ICP_HV extern int icp_hv_init (void ); +#else +static inline int icp_hv_init (void ) {return -ENODEV ; } +#endif /* ICP ops */ struct icp_ops {
@@ -51,7 +59,18 @@ extern const struct icp_ops *icp_ops;extern int ics_native_init (void );/* RTAS ICS */ +#ifdef CONFIG_PPC_ICS_RTAS extern int ics_rtas_init (void ); +#else +static inline int ics_rtas_init (void ) {return -ENODEV ; } +#endif + +/* HAL ICS */ +#ifdef CONFIG_PPC_POWERNV +extern int ics_opal_init (void ); +#else +static inline int ics_opal_init (void ) {return -ENODEV ; } +#endif /* ICS instance, hooked up to chip_data of an irq */ struct ics {
arch/powerpc/sysdev/xics/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y += xics-common.o obj-$(CONFIG_PPC_ICP_NATIVE) += icp-native.o obj-$(CONFIG_PPC_ICP_HV) += icp-hv.o obj-$(CONFIG_PPC_ICS_RTAS) += ics-rtas.o +obj-$(CONFIG_PPC_POWERNV) += ics-opal.o
arch/powerpc/sysdev/xics/ics-opal.c new file +244 -0
244 lines not on this page · raw message
arch/powerpc/sysdev/xics/xics-common.c +2 -6
@@ -409,14 +409,10 @@ void __init xics_init(void)int rc =-1 ;/* Fist locate ICP */ -#ifdef CONFIG_PPC_ICP_HV if (firmware_has_feature (FW_FEATURE_LPAR )) rc =icp_hv_init (); -#endif -#ifdef CONFIG_PPC_ICP_NATIVE if (rc <0 ) rc =icp_native_init (); -#endif if (rc <0 ) {pr_warning ("XICS: Cannot find a Presentation Controller !\n" );return ;
@@ -429,9 +425,9 @@ void __init xics_init(void) xics_ipi_chip.irq_eoi = icp_ops->eoi;/* Now locate ICS */ -#ifdef CONFIG_PPC_ICS_RTAS rc =ics_rtas_init (); -#endif +if (rc <0 ) + rc =ics_opal_init ();if (rc <0 )pr_warning ("XICS: Cannot find a Source Controller !\n" );
Signature · 1 line
1.7.4.1
PATCH 17/21 powerpc/powernv: Register and handle OPAL interrupts
In reply to Benjamin HerrenschmidtWe do the minimum which is to "pass" interrupts to HAL, which makes the console smoother and will allow us to implement interrupt based completion and console.
--- arch/powerpc/platforms/powernv/opal.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/opal.c +31 -0
@@ -14,6 +14,7 @@#include <linux/types.h> #include <linux/of.h> #include <linux/of_platform.h> +#include <linux/interrupt.h> #include <asm/opal.h> #include <asm/firmware.h>
@@ -135,9 +136,22 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)return written; } +static irqreturn_t opal_interrupt (int irq,void *data) +{ +uint64_t events; + +opal_handle_interrupt (virq_to_hw (irq), &events); + +/* XXX TODO: Do something with the events */ + +return IRQ_HANDLED ; +} +static int __init opal_init (void ) {struct device_node *np, *consoles; +const u32 *irqs; +int rc, i, irqlen; opal_node =of_find_node_by_path ("/ibm,opal" );if (!opal_node) {
@@ -156,6 +170,23 @@ static int __init opal_init(void)of_platform_device_create (np,NULL ,NULL ); }of_node_put (consoles); + +/* Find all OPAL interrupts and request them */ + irqs =of_get_property (opal_node,"opal-interrupts" , &irqlen); +pr_debug ("opal: Found %d interrupts reserved for OPAL\n" , + irqs ? (irqlen /4 ) :0 ); +for (i =0 ; irqs && i < (irqlen /4 ); i++, irqs++) { +unsigned int hwirq =be32_to_cpup (irqs); +unsigned int irq =irq_create_mapping (NULL , hwirq); +if (irq ==NO_IRQ ) { +pr_warning ("opal: Failed to map irq 0x%x\n" , hwirq); +continue ; + } + rc =request_irq (irq, opal_interrupt,0 ,"opal" ,NULL ); +if (rc) +pr_warning ("opal: Error %d requesting irq %d" +" (0x%x)\n" , rc, irq, hwirq); + }return 0 ; }subsys_initcall (opal_init);
Signature · 1 line
1.7.4.1
PATCH 18/21 powerpc/powernv: Machine check and other system interrupts
In reply to Benjamin HerrenschmidtOPAL can handle various interrupt for us such as Machine Checks (it performs all sorts of recovery tasks and passes back control to us with informations about the error), Hardware Management Interrupts and Softpatch interrupts.
This wires up the mechanisms and prints out specific informations returned by HAL when a machine check occurs.
--- arch/powerpc/include/asm/opal.h | 2 + arch/powerpc/include/asm/paca.h | 8 ++ arch/powerpc/kernel/asm-offsets.c | 10 +++ arch/powerpc/kernel/exceptions-64s.S | 27 ++++++- arch/powerpc/platforms/powernv/opal.c | 130 ++++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/setup.c | 1 + 6 files changed, 174 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/opal.h +2 -0
@@ -436,6 +436,8 @@ extern void opal_get_rtc_time(struct rtc_time *tm);extern unsigned long opal_get_boot_time (void );extern void opal_nvram_init (void ); +extern int opal_machine_check (struct pt_regs *regs); +#endif /* __ASSEMBLY__ */ #endif /* __OPAL_H */
arch/powerpc/include/asm/paca.h +8 -0
@@ -43,6 +43,7 @@ extern unsigned int debug_smp_processor_id(void); /* from linux/smp.h */#define get_slb_shadow () (get_paca()->slb_shadow_ptr)struct task_struct ; +struct opal_machine_check_event ;/* * Defines the layout of the paca.
@@ -135,6 +136,13 @@ struct paca_struct {u8 io_sync;/* writel() needs spin_unlock sync */ u8 irq_work_pending;/* IRQ_WORK interrupt while soft-disable */ +#ifdef CONFIG_PPC_POWERNV +/* Pointer to OPAL machine check event structure set by the +* early exception handler for use by high level C handler +*/ +struct opal_machine_check_event *opal_mc_evt; +#endif +/* Stuff for accurate time accounting */ u64 user_time;/* accumulated usermode TB ticks */ u64 system_time;/* accumulated system TB ticks */
arch/powerpc/kernel/asm-offsets.c +10 -0
@@ -48,6 +48,9 @@#ifdef CONFIG_PPC_ISERIES #include <asm/iseries/alpaca.h> #endif +#ifdef CONFIG_PPC_POWERNV +#include <asm/opal.h> +#endif #if defined(CONFIG_KVM ) || defined(CONFIG_KVM_GUEST )#include <linux/kvm_host.h> #endif
@@ -609,5 +612,12 @@ int main(void) arch.timing_last_enter.tv32.tbl));#endif +#ifdef CONFIG_PPC_POWERNV +DEFINE (OPAL_MC_GPR3 , offsetof(struct opal_machine_check_event , gpr3)); +DEFINE (OPAL_MC_SRR0 , offsetof(struct opal_machine_check_event , srr0)); +DEFINE (OPAL_MC_SRR1 , offsetof(struct opal_machine_check_event , srr1)); +DEFINE (PACA_OPAL_MC_EVT , offsetof(struct paca_struct , opal_mc_evt)); +#endif +return 0 ; }
arch/powerpc/kernel/exceptions-64s.S +23 -4
@@ -1143,7 +1143,7 @@ _GLOBAL(do_stab_bolted) rfid b . /* prevent speculative execution */ -#ifdef CONFIG_PPC_PSERIES +#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) /* * Data area reserved for FWNMI option. * This address (0x7000) is fixed by the RPA.
@@ -1151,7 +1151,7 @@ _GLOBAL(do_stab_bolted) .= 0x7000 .globl fwnmi_data_area fwnmi_data_area: -#endif /* CONFIG_PPC_PSERIES */ +#endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */ /* iSeries does not use the FWNMI stuff, so it is safe to put * this here, even if we later allow kernels that will boot on
@@ -1176,9 +1176,12 @@ xLparMap: #endif /* CONFIG_PPC_ISERIES */ -#ifdef CONFIG_PPC_PSERIES +#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) + /* pseries and powernv need to keep the whole page from + * 0x7000 to 0x8000 free for use by the firmware + */ . = 0x8000 -#endif /* CONFIG_PPC_PSERIES */ +#endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */ /* * Space for CPU0's segment table.
@@ -1193,3 +1196,19 @@ xLparMap: .globl initial_stab initial_stab: .space 4096 +#ifdef CONFIG_PPC_POWERNV +_GLOBAL(opal_mc_secondary_handler) + HMT_MEDIUM + SET_SCRATCH0(r13) + GET_PACA(r13) + clrldi r3,r3,2 + tovirt(r3,r3) + std r3,PACA_OPAL_MC_EVT(r13) + ld r13,OPAL_MC_SRR0(r3) + mtspr SPRN_SRR0,r13 + ld r13,OPAL_MC_SRR1(r3) + mtspr SPRN_SRR1,r13 + ld r3,OPAL_MC_GPR3(r3) + GET_SCRATCH0(r13) + b machine_check_pSeries +#endif /* CONFIG_PPC_POWERNV */
arch/powerpc/platforms/powernv/opal.c +130 -0
154 lines not on this page · raw message
arch/powerpc/platforms/powernv/setup.c +1 -0
@@ -141,6 +141,7 @@ static void __init pnv_setup_machdep_opal(void) ppc_md.restart = pnv_restart; ppc_md.power_off = pnv_power_off; ppc_md.halt = pnv_halt; + ppc_md.machine_check_exception = opal_machine_check; }#ifdef CONFIG_PPC_POWERNV_RTAS
Signature · 1 line
1.7.4.1
PATCH 19/21 powerpc/powernv: Add support for p5ioc2 PCI-X and PCIe
In reply to Benjamin HerrenschmidtThis adds support for PCI-X and PCIe on the p5ioc2 IO hub using OPAL. This includes allocating & setting up TCE tables and config space access routines.
This also supports fallbacks via RTAS when OPAL is absent, using legacy TCE format pre-allocated via the device-tree (BML style)
--- arch/powerpc/platforms/powernv/Makefile | 2 + arch/powerpc/platforms/powernv/pci-p5ioc2.c | 185 +++++++++++++++++ arch/powerpc/platforms/powernv/pci.c | 286 +++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/pci.h | 38 ++++ arch/powerpc/platforms/powernv/powernv.h | 6 + arch/powerpc/platforms/powernv/setup.c | 3 +- 6 files changed, 519 insertions(+), 1 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/pci-p5ioc2.c create mode 100644 arch/powerpc/platforms/powernv/pci.c create mode 100644 arch/powerpc/platforms/powernv/pci.h
arch/powerpc/platforms/powernv/Makefile +2 -0
@@ -2,3 +2,5 @@ obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o obj-y += opal-rtc.o opal-nvram.o obj-$(CONFIG_SMP) += smp.o +obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o +
arch/powerpc/platforms/powernv/pci-p5ioc2.c new file +185 -0
185 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.c new file +286 -0
286 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.h new file +38 -0
@@ -0,0 +1,38 @@ +#ifndef __POWERNV_PCI_H +#define __POWERNV_PCI_H + +struct pci_dn ; + +enum pnv_phb_type { +PNV_PHB_P5IOC2 , +PNV_PHB_IODA1 , +PNV_PHB_IODA2 , +}; + +struct pnv_phb { +struct pci_controller *hose; +enum pnv_phb_type type; +u64 opal_id; +void __iomem *regs; +spinlock_t lock; + +void (*dma_dev_setup)(struct pnv_phb *phb,struct pci_dev *pdev); +void (*fixup_phb)(struct pci_controller *hose); +u32 (*bdfn_to_pe)(struct pnv_phb *phb,struct pci_bus *bus,u32 devfn); + +union { +struct { +struct iommu_table iommu_table; + } p5ioc2; + }; +}; + +extern struct pci_ops pnv_pci_ops; + +extern void pnv_pci_setup_iommu_table (struct iommu_table *tbl, +void *tce_mem,u64 tce_size, +u64 dma_offset); +extern void pnv_pci_init_p5ioc2_hub (struct device_node *np); + + +#endif /* __POWERNV_PCI_H */
arch/powerpc/platforms/powernv/powernv.h +6 -0
@@ -7,4 +7,10 @@ extern void pnv_smp_init(void);static inline void pnv_smp_init (void ) { }#endif +#ifdef CONFIG_PCI +extern void pnv_pci_init (void ); +#else +static inline void pnv_pci_init (void ) { } +#endif +#endif /* _POWERNV_H */
arch/powerpc/platforms/powernv/setup.c +2 -1
@@ -40,7 +40,8 @@ static void __init pnv_setup_arch(void)/* Initialize SMP */ pnv_smp_init (); -/* XXX PCI */ +/* Setup PCI */ +pnv_pci_init ();/* Setup RTC and NVRAM callbacks */ if (firmware_has_feature (FW_FEATURE_OPAL ))
Signature · 1 line
1.7.4.1
PATCH 20/21 powerpc/powernv: Implement MSI support for p5ioc2 PCIe
In reply to Benjamin HerrenschmidtThis implements support for MSIs on p5ioc2 PHBs. We only support MSIs on the PCIe PHBs, not the PCI-X ones as the later hasn't been properly verified in HW.
--- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 49 ++++++++++++ arch/powerpc/platforms/powernv/pci.c | 108 +++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/pci.h | 10 +++ 3 files changed, 167 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci-p5ioc2.c +49 -0
@@ -19,6 +19,7 @@#include <linux/bootmem.h> #include <linux/irq.h> #include <linux/io.h> +#include <linux/msi.h> #include <asm/sections.h> #include <asm/io.h>
@@ -39,6 +40,51 @@*/ #define P5IOC2_TCE_MEMORY 0x01000000 +#ifdef CONFIG_PCI_MSI +static int pnv_pci_p5ioc2_msi_setup (struct pnv_phb *phb,struct pci_dev *dev, +unsigned int hwirq,unsigned int is_64, +struct msi_msg *msg) +{ +if (WARN_ON (!is_64)) +return -ENXIO ; + msg->data = hwirq - phb->msi_base; + msg->address_hi =0x10000000 ; + msg->address_lo =0 ; + +return 0 ; +} + +static void pnv_pci_init_p5ioc2_msis (struct pnv_phb *phb) +{ +unsigned int bmap_size; +const __be32 *prop =of_get_property (phb->hose->dn, +"ibm,opal-msi-ranges" ,NULL ); +if (!prop) +return ; + +/* Don't do MSI's on p5ioc2 PCI-X are they are not properly +* verified in HW +*/ +if (of_device_is_compatible (phb->hose->dn,"ibm,p5ioc2-pcix" )) +return ; + phb->msi_base =be32_to_cpup (prop); + phb->msi_count =be32_to_cpup (prop +1 ); + bmap_size =BITS_TO_LONGS (phb->msi_count) *sizeof (unsigned long ); + phb->msi_map =zalloc_maybe_bootmem (bmap_size,GFP_KERNEL ); +if (!phb->msi_map) { +pr_err ("PCI %d: Failed to allocate MSI bitmap !\n" , + phb->hose->global_number); +return ; + } + phb->msi_setup = pnv_pci_p5ioc2_msi_setup; + phb->msi32_support =0 ; +pr_info (" Allocated bitmap for %d MSIs (base IRQ 0x%x)\n" , + phb->msi_count, phb->msi_base); +} +#else +static void pnv_pci_setup_p5ioc2_msis (struct pnv_phb *phb) { } +#endif /* CONFIG_PCI_MSI */ +static void __devinit pnv_pci_p5ioc2_dma_dev_setup (struct pnv_phb *phb,struct pci_dev *pdev) {
@@ -117,6 +163,9 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, phb->hose->ops = &pnv_pci_ops; +/* Setup MSI support */ +pnv_pci_init_p5ioc2_msis (phb); +/* Setup TCEs */ phb->dma_dev_setup = pnv_pci_p5ioc2_dma_dev_setup; pnv_pci_setup_iommu_table(&phb->p5ioc2.iommu_table,
arch/powerpc/platforms/powernv/pci.c +108 -0
125 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.h +10 -0
@@ -16,6 +16,16 @@ struct pnv_phb {void __iomem *regs;spinlock_t lock; +#ifdef CONFIG_PCI_MSI +unsigned long *msi_map; +unsigned int msi_base; +unsigned int msi_count; +unsigned int msi_next; +unsigned int msi32_support; +#endif +int (*msi_setup)(struct pnv_phb *phb,struct pci_dev *dev, +unsigned int hwirq,unsigned int is_64, +struct msi_msg *msg);void (*dma_dev_setup)(struct pnv_phb *phb,struct pci_dev *pdev);void (*fixup_phb)(struct pci_controller *hose);u32 (*bdfn_to_pe)(struct pnv_phb *phb,struct pci_bus *bus,u32 devfn);
Signature · 1 line
1.7.4.1
PATCH 21/21 powerpc/powernv: Handle PCI-X/PCIe reset delay
In reply to Benjamin HerrenschmidtThe firmware doesn't wait after lifting the PCI reset. However it does timestamp it in the device tree. We use that to ensure we wait long enough (3s is our current arbitrary setting) from that timestamp to actually probing the bus.
--- arch/powerpc/platforms/powernv/pci.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
arch/powerpc/platforms/powernv/pci.c +32 -0
@@ -35,6 +35,8 @@#include "powernv.h" #include "pci.h" +/* Delay in usec */ +#define PCI_RESET_DELAY_US 3000000 #define cfg_dbg(fmt...) do { } while(0)//#define cfg_dbg(fmt...) printk(fmt)
@@ -353,6 +355,35 @@ static void __devinit pnv_pci_dma_dev_setup(struct pci_dev *pdev)pnv_pci_dma_fallback_setup (hose, pdev); } +static int pnv_pci_probe_mode (struct pci_bus *bus) +{ +struct pci_controller *hose =pci_bus_to_host (bus); +const __be64 *tstamp; +u64 now, target; + + +/* We hijack this as a way to ensure we have waited long +* enough since the reset was lifted on the PCI bus +*/ +if (bus != hose->bus) +return PCI_PROBE_NORMAL ; + tstamp =of_get_property (hose->dn,"reset-clear-timestamp" ,NULL ); +if (!tstamp || !*tstamp) +return PCI_PROBE_NORMAL ; + + now =mftb () / tb_ticks_per_usec; + target = (be64_to_cpup (tstamp) / tb_ticks_per_usec) + +PCI_RESET_DELAY_US ; + +pr_devel ("pci %04d: Reset target: 0x%llx now: 0x%llx\n" , + hose->global_number, target, now); + +if (now < target) +msleep ((target - now +999 ) /1000 ); + +return PCI_PROBE_NORMAL ; +} +void __init pnv_pci_init (void ) {struct device_node *np;
@@ -383,6 +414,7 @@ void __init pnv_pci_init(void) ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup; ppc_md.tce_build = pnv_tce_build; ppc_md.tce_free = pnv_tce_free; + ppc_md.pci_probe_mode = pnv_pci_probe_mode;set_pci_dma_ops (&dma_iommu_ops);/* Configure MSIs */
Signature · 1 line
1.7.4.1