aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorNathan Fontenot <nfont@linux.vnet.ibm.com>2013-04-24 01:57:18 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-04-26 02:08:22 -0400
commitf0ff7eb483b4c9b24b83aa682c4f42db256f9bdb (patch)
treed1733adf54ac7c44fa5d2dbb7107e2133c3f2c45 /arch/powerpc
parent43c0ea60537d9423f0f1b5c14b0cd0a0b4af5c81 (diff)
powerpc/pseries: Update firmware_has_feature() to check architecture vector 5 bits
The firmware_has_feature() function makes it easy to check for supported features of the hypervisor. This patch extends the capability of firmware_has_feature() to include checking for specified bits in vector 5 of the architecture vector as reported in the device tree. As part of this the #defines used for the architecture vector are re-defined such that each option has the index into vector 5 and the feature bit encoded into it. This makes checking for architecture bits when initiating data for firmware_has_feature much easier. Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/firmware.h4
-rw-r--r--arch/powerpc/include/asm/prom.h45
-rw-r--r--arch/powerpc/kernel/prom_init.c23
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c49
-rw-r--r--arch/powerpc/platforms/pseries/pseries.h5
-rw-r--r--arch/powerpc/platforms/pseries/setup.c40
6 files changed, 111 insertions, 55 deletions
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index f9651b288da1..6e336e0978b1 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -50,6 +50,7 @@
50#define FW_FEATURE_OPALv2 ASM_CONST(0x0000000020000000) 50#define FW_FEATURE_OPALv2 ASM_CONST(0x0000000020000000)
51#define FW_FEATURE_SET_MODE ASM_CONST(0x0000000040000000) 51#define FW_FEATURE_SET_MODE ASM_CONST(0x0000000040000000)
52#define FW_FEATURE_BEST_ENERGY ASM_CONST(0x0000000080000000) 52#define FW_FEATURE_BEST_ENERGY ASM_CONST(0x0000000080000000)
53#define FW_FEATURE_TYPE1_AFFINITY ASM_CONST(0x0000000100000000)
53 54
54#ifndef __ASSEMBLY__ 55#ifndef __ASSEMBLY__
55 56
@@ -64,7 +65,8 @@ enum {
64 FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR | 65 FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR |
65 FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR | 66 FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR |
66 FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO | 67 FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO |
67 FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY, 68 FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY |
69 FW_FEATURE_TYPE1_AFFINITY,
68 FW_FEATURE_PSERIES_ALWAYS = 0, 70 FW_FEATURE_PSERIES_ALWAYS = 0,
69 FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2, 71 FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2,
70 FW_FEATURE_POWERNV_ALWAYS = 0, 72 FW_FEATURE_POWERNV_ALWAYS = 0,
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 811b78099055..2ea8b856d605 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -110,31 +110,28 @@ struct of_drconf_cell {
110/* Option vector 4: IBM PAPR implementation */ 110/* Option vector 4: IBM PAPR implementation */
111#define OV4_MIN_ENT_CAP 0x01 /* minimum VP entitled capacity */ 111#define OV4_MIN_ENT_CAP 0x01 /* minimum VP entitled capacity */
112 112
113/* Option vector 5: PAPR/OF options supported */ 113/* Option vector 5: PAPR/OF options supported
114#define OV5_LPAR 0x80 /* logical partitioning supported */ 114 * These bits are also used in firmware_has_feature() to validate
115#define OV5_SPLPAR 0x40 /* shared-processor LPAR supported */ 115 * the capabilities reported for vector 5 in the device tree so we
116 * encode the vector index in the define and use the OV5_FEAT()
117 * and OV5_INDX() macros to extract the desired information.
118 */
119#define OV5_FEAT(x) ((x) & 0xff)
120#define OV5_INDX(x) ((x) >> 8)
121#define OV5_LPAR 0x0280 /* logical partitioning supported */
122#define OV5_SPLPAR 0x0240 /* shared-processor LPAR supported */
116/* ibm,dynamic-reconfiguration-memory property supported */ 123/* ibm,dynamic-reconfiguration-memory property supported */
117#define OV5_DRCONF_MEMORY 0x20 124#define OV5_DRCONF_MEMORY 0x0220
118#define OV5_LARGE_PAGES 0x10 /* large pages supported */ 125#define OV5_LARGE_PAGES 0x0210 /* large pages supported */
119#define OV5_DONATE_DEDICATE_CPU 0x02 /* donate dedicated CPU support */ 126#define OV5_DONATE_DEDICATE_CPU 0x0202 /* donate dedicated CPU support */
120/* PCIe/MSI support. Without MSI full PCIe is not supported */ 127#define OV5_MSI 0x0201 /* PCIe/MSI support */
121#ifdef CONFIG_PCI_MSI 128#define OV5_CMO 0x0480 /* Cooperative Memory Overcommitment */
122#define OV5_MSI 0x01 /* PCIe/MSI support */ 129#define OV5_XCMO 0x0440 /* Page Coalescing */
123#else 130#define OV5_TYPE1_AFFINITY 0x0580 /* Type 1 NUMA affinity */
124#define OV5_MSI 0x00 131#define OV5_PFO_HW_RNG 0x0E80 /* PFO Random Number Generator */
125#endif /* CONFIG_PCI_MSI */ 132#define OV5_PFO_HW_842 0x0E40 /* PFO Compression Accelerator */
126#ifdef CONFIG_PPC_SMLPAR 133#define OV5_PFO_HW_ENCR 0x0E20 /* PFO Encryption Accelerator */
127#define OV5_CMO 0x80 /* Cooperative Memory Overcommitment */ 134#define OV5_SUB_PROCESSORS 0x0F01 /* 1,2,or 4 Sub-Processors supported */
128#define OV5_XCMO 0x40 /* Page Coalescing */
129#else
130#define OV5_CMO 0x00
131#define OV5_XCMO 0x00
132#endif
133#define OV5_TYPE1_AFFINITY 0x80 /* Type 1 NUMA affinity */
134#define OV5_PFO_HW_RNG 0x80 /* PFO Random Number Generator */
135#define OV5_PFO_HW_842 0x40 /* PFO Compression Accelerator */
136#define OV5_PFO_HW_ENCR 0x20 /* PFO Encryption Accelerator */
137#define OV5_SUB_PROCESSORS 0x01 /* 1,2,or 4 Sub-Processors supported */
138 135
139/* Option Vector 6: IBM PAPR hints */ 136/* Option Vector 6: IBM PAPR hints */
140#define OV6_LINUX 0x02 /* Linux is our OS */ 137#define OV6_LINUX 0x02 /* Linux is our OS */
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 4a9e50cf8ab9..1b0000a247d8 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -684,11 +684,21 @@ unsigned char ibm_architecture_vec[] = {
684 /* option vector 5: PAPR/OF options */ 684 /* option vector 5: PAPR/OF options */
685 19 - 2, /* length */ 685 19 - 2, /* length */
686 0, /* don't ignore, don't halt */ 686 0, /* don't ignore, don't halt */
687 OV5_LPAR | OV5_SPLPAR | OV5_LARGE_PAGES | OV5_DRCONF_MEMORY | 687 OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) |
688 OV5_DONATE_DEDICATE_CPU | OV5_MSI, 688 OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) |
689#ifdef CONFIG_PCI_MSI
690 /* PCIe/MSI support. Without MSI full PCIe is not supported */
691 OV5_FEAT(OV5_MSI),
692#else
693 0,
694#endif
689 0, 695 0,
690 OV5_CMO | OV5_XCMO, 696#ifdef CONFIG_PPC_SMLPAR
691 OV5_TYPE1_AFFINITY, 697 OV5_FEAT(OV5_CMO) | OV5_FEAT(OV5_XCMO),
698#else
699 0,
700#endif
701 OV5_FEAT(OV5_TYPE1_AFFINITY),
692 0, 702 0,
693 0, 703 0,
694 0, 704 0,
@@ -702,8 +712,9 @@ unsigned char ibm_architecture_vec[] = {
702 0, 712 0,
703 0, 713 0,
704 0, 714 0,
705 OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR | OV5_PFO_HW_842, 715 OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) |
706 OV5_SUB_PROCESSORS, 716 OV5_FEAT(OV5_PFO_HW_842),
717 OV5_FEAT(OV5_SUB_PROCESSORS),
707 /* option vector 6: IBM PAPR hints */ 718 /* option vector 6: IBM PAPR hints */
708 4 - 2, /* length */ 719 4 - 2, /* length */
709 0, 720 0,
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index 1236a9d6146a..06639fa2d61d 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -28,18 +28,18 @@
28 28
29#include "pseries.h" 29#include "pseries.h"
30 30
31typedef struct { 31struct hypertas_fw_feature {
32 unsigned long val; 32 unsigned long val;
33 char * name; 33 char * name;
34} firmware_feature_t; 34};
35 35
36/* 36/*
37 * The names in this table match names in rtas/ibm,hypertas-functions. If the 37 * The names in this table match names in rtas/ibm,hypertas-functions. If the
38 * entry ends in a '*', only upto the '*' is matched. Otherwise the entire 38 * entry ends in a '*', only upto the '*' is matched. Otherwise the entire
39 * string must match. 39 * string must match.
40 */ 40 */
41static __initdata firmware_feature_t 41static __initdata struct hypertas_fw_feature
42firmware_features_table[] = { 42hypertas_fw_features_table[] = {
43 {FW_FEATURE_PFT, "hcall-pft"}, 43 {FW_FEATURE_PFT, "hcall-pft"},
44 {FW_FEATURE_TCE, "hcall-tce"}, 44 {FW_FEATURE_TCE, "hcall-tce"},
45 {FW_FEATURE_SPRG0, "hcall-sprg0"}, 45 {FW_FEATURE_SPRG0, "hcall-sprg0"},
@@ -69,16 +69,16 @@ firmware_features_table[] = {
69 * device-tree/ibm,hypertas-functions. Ultimately this functionality may 69 * device-tree/ibm,hypertas-functions. Ultimately this functionality may
70 * be moved into prom.c prom_init(). 70 * be moved into prom.c prom_init().
71 */ 71 */
72void __init fw_feature_init(const char *hypertas, unsigned long len) 72void __init fw_hypertas_feature_init(const char *hypertas, unsigned long len)
73{ 73{
74 const char *s; 74 const char *s;
75 int i; 75 int i;
76 76
77 pr_debug(" -> fw_feature_init()\n"); 77 pr_debug(" -> fw_hypertas_feature_init()\n");
78 78
79 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) { 79 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
80 for (i = 0; i < ARRAY_SIZE(firmware_features_table); i++) { 80 for (i = 0; i < ARRAY_SIZE(hypertas_fw_features_table); i++) {
81 const char *name = firmware_features_table[i].name; 81 const char *name = hypertas_fw_features_table[i].name;
82 size_t size; 82 size_t size;
83 83
84 /* 84 /*
@@ -94,10 +94,39 @@ void __init fw_feature_init(const char *hypertas, unsigned long len)
94 94
95 /* we have a match */ 95 /* we have a match */
96 powerpc_firmware_features |= 96 powerpc_firmware_features |=
97 firmware_features_table[i].val; 97 hypertas_fw_features_table[i].val;
98 break; 98 break;
99 } 99 }
100 } 100 }
101 101
102 pr_debug(" <- fw_feature_init()\n"); 102 pr_debug(" <- fw_hypertas_feature_init()\n");
103}
104
105struct vec5_fw_feature {
106 unsigned long val;
107 unsigned int feature;
108};
109
110static __initdata struct vec5_fw_feature
111vec5_fw_features_table[] = {
112 {FW_FEATURE_TYPE1_AFFINITY, OV5_TYPE1_AFFINITY},
113};
114
115void __init fw_vec5_feature_init(const char *vec5, unsigned long len)
116{
117 unsigned int index, feat;
118 int i;
119
120 pr_debug(" -> fw_vec5_feature_init()\n");
121
122 for (i = 0; i < ARRAY_SIZE(vec5_fw_features_table); i++) {
123 index = OV5_INDX(vec5_fw_features_table[i].feature);
124 feat = OV5_FEAT(vec5_fw_features_table[i].feature);
125
126 if (vec5[index] & feat)
127 powerpc_firmware_features |=
128 vec5_fw_features_table[i].val;
129 }
130
131 pr_debug(" <- fw_vec5_feature_init()\n");
103} 132}
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 9a3dda07566f..8af71e4cc17f 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -19,7 +19,10 @@ extern void request_event_sources_irqs(struct device_node *np,
19 19
20#include <linux/of.h> 20#include <linux/of.h>
21 21
22extern void __init fw_feature_init(const char *hypertas, unsigned long len); 22extern void __init fw_hypertas_feature_init(const char *hypertas,
23 unsigned long len);
24extern void __init fw_vec5_feature_init(const char *hypertas,
25 unsigned long len);
23 26
24struct pt_regs; 27struct pt_regs;
25 28
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 8bcc9ca6682f..ac932a9eb440 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -628,25 +628,39 @@ static void __init pSeries_init_early(void)
628 * Called very early, MMU is off, device-tree isn't unflattened 628 * Called very early, MMU is off, device-tree isn't unflattened
629 */ 629 */
630 630
631static int __init pSeries_probe_hypertas(unsigned long node, 631static int __init pseries_probe_fw_features(unsigned long node,
632 const char *uname, int depth, 632 const char *uname, int depth,
633 void *data) 633 void *data)
634{ 634{
635 const char *hypertas; 635 const char *prop;
636 unsigned long len; 636 unsigned long len;
637 static int hypertas_found;
638 static int vec5_found;
637 639
638 if (depth != 1 || 640 if (depth != 1)
639 (strcmp(uname, "rtas") != 0 && strcmp(uname, "rtas@0") != 0))
640 return 0; 641 return 0;
641 642
642 hypertas = of_get_flat_dt_prop(node, "ibm,hypertas-functions", &len); 643 if (!strcmp(uname, "rtas") || !strcmp(uname, "rtas@0")) {
643 if (!hypertas) 644 prop = of_get_flat_dt_prop(node, "ibm,hypertas-functions",
644 return 1; 645 &len);
646 if (prop) {
647 powerpc_firmware_features |= FW_FEATURE_LPAR;
648 fw_hypertas_feature_init(prop, len);
649 }
645 650
646 powerpc_firmware_features |= FW_FEATURE_LPAR; 651 hypertas_found = 1;
647 fw_feature_init(hypertas, len); 652 }
648 653
649 return 1; 654 if (!strcmp(uname, "chosen")) {
655 prop = of_get_flat_dt_prop(node, "ibm,architecture-vec-5",
656 &len);
657 if (prop)
658 fw_vec5_feature_init(prop, len);
659
660 vec5_found = 1;
661 }
662
663 return hypertas_found && vec5_found;
650} 664}
651 665
652static int __init pSeries_probe(void) 666static int __init pSeries_probe(void)
@@ -669,7 +683,7 @@ static int __init pSeries_probe(void)
669 pr_debug("pSeries detected, looking for LPAR capability...\n"); 683 pr_debug("pSeries detected, looking for LPAR capability...\n");
670 684
671 /* Now try to figure out if we are running on LPAR */ 685 /* Now try to figure out if we are running on LPAR */
672 of_scan_flat_dt(pSeries_probe_hypertas, NULL); 686 of_scan_flat_dt(pseries_probe_fw_features, NULL);
673 687
674 if (firmware_has_feature(FW_FEATURE_LPAR)) 688 if (firmware_has_feature(FW_FEATURE_LPAR))
675 hpte_init_lpar(); 689 hpte_init_lpar();