diff options
40 files changed, 546 insertions, 738 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 0f4344e6fbca..4c0cedf4e2c7 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
@@ -74,6 +74,7 @@ override CROSS32AS += -mlittle-endian | |||
74 | LDEMULATION := lppc | 74 | LDEMULATION := lppc |
75 | GNUTARGET := powerpcle | 75 | GNUTARGET := powerpcle |
76 | MULTIPLEWORD := -mno-multiple | 76 | MULTIPLEWORD := -mno-multiple |
77 | KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) | ||
77 | else | 78 | else |
78 | ifeq ($(call cc-option-yn,-mbig-endian),y) | 79 | ifeq ($(call cc-option-yn,-mbig-endian),y) |
79 | override CC += -mbig-endian | 80 | override CC += -mbig-endian |
diff --git a/arch/powerpc/include/asm/emulated_ops.h b/arch/powerpc/include/asm/emulated_ops.h index 4358e3002f35..f00e10e2a335 100644 --- a/arch/powerpc/include/asm/emulated_ops.h +++ b/arch/powerpc/include/asm/emulated_ops.h | |||
@@ -54,6 +54,7 @@ extern struct ppc_emulated { | |||
54 | #ifdef CONFIG_PPC64 | 54 | #ifdef CONFIG_PPC64 |
55 | struct ppc_emulated_entry mfdscr; | 55 | struct ppc_emulated_entry mfdscr; |
56 | struct ppc_emulated_entry mtdscr; | 56 | struct ppc_emulated_entry mtdscr; |
57 | struct ppc_emulated_entry lq_stq; | ||
57 | #endif | 58 | #endif |
58 | } ppc_emulated; | 59 | } ppc_emulated; |
59 | 60 | ||
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index fe2aa0b48d2b..a2efdaa020b0 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h | |||
@@ -87,6 +87,7 @@ extern int opal_enter_rtas(struct rtas_args *args, | |||
87 | #define OPAL_ASYNC_COMPLETION -15 | 87 | #define OPAL_ASYNC_COMPLETION -15 |
88 | 88 | ||
89 | /* API Tokens (in r0) */ | 89 | /* API Tokens (in r0) */ |
90 | #define OPAL_INVALID_CALL -1 | ||
90 | #define OPAL_CONSOLE_WRITE 1 | 91 | #define OPAL_CONSOLE_WRITE 1 |
91 | #define OPAL_CONSOLE_READ 2 | 92 | #define OPAL_CONSOLE_READ 2 |
92 | #define OPAL_RTC_READ 3 | 93 | #define OPAL_RTC_READ 3 |
@@ -177,6 +178,8 @@ extern int opal_enter_rtas(struct rtas_args *args, | |||
177 | 178 | ||
178 | #ifndef __ASSEMBLY__ | 179 | #ifndef __ASSEMBLY__ |
179 | 180 | ||
181 | #include <linux/notifier.h> | ||
182 | |||
180 | /* Other enums */ | 183 | /* Other enums */ |
181 | enum OpalVendorApiTokens { | 184 | enum OpalVendorApiTokens { |
182 | OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999 | 185 | OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999 |
@@ -422,9 +425,9 @@ enum OpalSysparamPerm { | |||
422 | }; | 425 | }; |
423 | 426 | ||
424 | struct opal_msg { | 427 | struct opal_msg { |
425 | uint32_t msg_type; | 428 | __be32 msg_type; |
426 | uint32_t reserved; | 429 | __be32 reserved; |
427 | uint64_t params[8]; | 430 | __be64 params[8]; |
428 | }; | 431 | }; |
429 | 432 | ||
430 | struct opal_machine_check_event { | 433 | struct opal_machine_check_event { |
@@ -730,7 +733,11 @@ typedef struct oppanel_line { | |||
730 | /* /sys/firmware/opal */ | 733 | /* /sys/firmware/opal */ |
731 | extern struct kobject *opal_kobj; | 734 | extern struct kobject *opal_kobj; |
732 | 735 | ||
736 | /* /ibm,opal */ | ||
737 | extern struct device_node *opal_node; | ||
738 | |||
733 | /* API functions */ | 739 | /* API functions */ |
740 | int64_t opal_invalid_call(void); | ||
734 | int64_t opal_console_write(int64_t term_number, __be64 *length, | 741 | int64_t opal_console_write(int64_t term_number, __be64 *length, |
735 | const uint8_t *buffer); | 742 | const uint8_t *buffer); |
736 | int64_t opal_console_read(int64_t term_number, __be64 *length, | 743 | int64_t opal_console_read(int64_t term_number, __be64 *length, |
@@ -874,8 +881,7 @@ int64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer, | |||
874 | size_t length); | 881 | size_t length); |
875 | int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer, | 882 | int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer, |
876 | size_t length); | 883 | size_t length); |
877 | int64_t opal_sensor_read(uint32_t sensor_hndl, int token, | 884 | int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data); |
878 | uint32_t *sensor_data); | ||
879 | 885 | ||
880 | /* Internal functions */ | 886 | /* Internal functions */ |
881 | extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); | 887 | extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); |
@@ -892,6 +898,8 @@ extern int early_init_dt_scan_opal(unsigned long node, const char *uname, | |||
892 | int depth, void *data); | 898 | int depth, void *data); |
893 | 899 | ||
894 | extern int opal_notifier_register(struct notifier_block *nb); | 900 | extern int opal_notifier_register(struct notifier_block *nb); |
901 | extern int opal_notifier_unregister(struct notifier_block *nb); | ||
902 | |||
895 | extern int opal_message_notifier_register(enum OpalMessageType msg_type, | 903 | extern int opal_message_notifier_register(enum OpalMessageType msg_type, |
896 | struct notifier_block *nb); | 904 | struct notifier_block *nb); |
897 | extern void opal_notifier_enable(void); | 905 | extern void opal_notifier_enable(void); |
@@ -919,6 +927,7 @@ extern void opal_flash_init(void); | |||
919 | extern int opal_elog_init(void); | 927 | extern int opal_elog_init(void); |
920 | extern void opal_platform_dump_init(void); | 928 | extern void opal_platform_dump_init(void); |
921 | extern void opal_sys_param_init(void); | 929 | extern void opal_sys_param_init(void); |
930 | extern void opal_msglog_init(void); | ||
922 | 931 | ||
923 | extern int opal_machine_check(struct pt_regs *regs); | 932 | extern int opal_machine_check(struct pt_regs *regs); |
924 | extern bool opal_mce_check_early_recovery(struct pt_regs *regs); | 933 | extern bool opal_mce_check_early_recovery(struct pt_regs *regs); |
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h index a0e1add01ef5..b390f55b0df1 100644 --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h | |||
@@ -150,19 +150,53 @@ struct rtas_suspend_me_data { | |||
150 | #define RTAS_VECTOR_EXTERNAL_INTERRUPT 0x500 | 150 | #define RTAS_VECTOR_EXTERNAL_INTERRUPT 0x500 |
151 | 151 | ||
152 | struct rtas_error_log { | 152 | struct rtas_error_log { |
153 | unsigned long version:8; /* Architectural version */ | 153 | /* Byte 0 */ |
154 | unsigned long severity:3; /* Severity level of error */ | 154 | uint8_t byte0; /* Architectural version */ |
155 | unsigned long disposition:2; /* Degree of recovery */ | 155 | |
156 | unsigned long extended:1; /* extended log present? */ | 156 | /* Byte 1 */ |
157 | unsigned long /* reserved */ :2; /* Reserved for future use */ | 157 | uint8_t byte1; |
158 | unsigned long initiator:4; /* Initiator of event */ | 158 | /* XXXXXXXX |
159 | unsigned long target:4; /* Target of failed operation */ | 159 | * XXX 3: Severity level of error |
160 | unsigned long type:8; /* General event or error*/ | 160 | * XX 2: Degree of recovery |
161 | unsigned long extended_log_length:32; /* length in bytes */ | 161 | * X 1: Extended log present? |
162 | unsigned char buffer[1]; /* Start of extended log */ | 162 | * XX 2: Reserved |
163 | */ | ||
164 | |||
165 | /* Byte 2 */ | ||
166 | uint8_t byte2; | ||
167 | /* XXXXXXXX | ||
168 | * XXXX 4: Initiator of event | ||
169 | * XXXX 4: Target of failed operation | ||
170 | */ | ||
171 | uint8_t byte3; /* General event or error*/ | ||
172 | __be32 extended_log_length; /* length in bytes */ | ||
173 | unsigned char buffer[1]; /* Start of extended log */ | ||
163 | /* Variable length. */ | 174 | /* Variable length. */ |
164 | }; | 175 | }; |
165 | 176 | ||
177 | static inline uint8_t rtas_error_severity(const struct rtas_error_log *elog) | ||
178 | { | ||
179 | return (elog->byte1 & 0xE0) >> 5; | ||
180 | } | ||
181 | |||
182 | static inline uint8_t rtas_error_disposition(const struct rtas_error_log *elog) | ||
183 | { | ||
184 | return (elog->byte1 & 0x18) >> 3; | ||
185 | } | ||
186 | |||
187 | static inline uint8_t rtas_error_extended(const struct rtas_error_log *elog) | ||
188 | { | ||
189 | return (elog->byte1 & 0x04) >> 2; | ||
190 | } | ||
191 | |||
192 | #define rtas_error_type(x) ((x)->byte3) | ||
193 | |||
194 | static inline | ||
195 | uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog) | ||
196 | { | ||
197 | return be32_to_cpu(elog->extended_log_length); | ||
198 | } | ||
199 | |||
166 | #define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14 | 200 | #define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14 |
167 | 201 | ||
168 | #define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8)) | 202 | #define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8)) |
@@ -172,32 +206,35 @@ struct rtas_error_log { | |||
172 | */ | 206 | */ |
173 | struct rtas_ext_event_log_v6 { | 207 | struct rtas_ext_event_log_v6 { |
174 | /* Byte 0 */ | 208 | /* Byte 0 */ |
175 | uint32_t log_valid:1; /* 1:Log valid */ | 209 | uint8_t byte0; |
176 | uint32_t unrecoverable_error:1; /* 1:Unrecoverable error */ | 210 | /* XXXXXXXX |
177 | uint32_t recoverable_error:1; /* 1:recoverable (correctable */ | 211 | * X 1: Log valid |
178 | /* or successfully retried) */ | 212 | * X 1: Unrecoverable error |
179 | uint32_t degraded_operation:1; /* 1:Unrecoverable err, bypassed*/ | 213 | * X 1: Recoverable (correctable or successfully retried) |
180 | /* - degraded operation (e.g. */ | 214 | * X 1: Bypassed unrecoverable error (degraded operation) |
181 | /* CPU or mem taken off-line) */ | 215 | * X 1: Predictive error |
182 | uint32_t predictive_error:1; | 216 | * X 1: "New" log (always 1 for data returned from RTAS) |
183 | uint32_t new_log:1; /* 1:"New" log (Always 1 for */ | 217 | * X 1: Big Endian |
184 | /* data returned from RTAS */ | 218 | * X 1: Reserved |
185 | uint32_t big_endian:1; /* 1: Big endian */ | 219 | */ |
186 | uint32_t :1; /* reserved */ | 220 | |
187 | /* Byte 1 */ | 221 | /* Byte 1 */ |
188 | uint32_t :8; /* reserved */ | 222 | uint8_t byte1; /* reserved */ |
223 | |||
189 | /* Byte 2 */ | 224 | /* Byte 2 */ |
190 | uint32_t powerpc_format:1; /* Set to 1 (indicating log is */ | 225 | uint8_t byte2; |
191 | /* in PowerPC format */ | 226 | /* XXXXXXXX |
192 | uint32_t :3; /* reserved */ | 227 | * X 1: Set to 1 (indicating log is in PowerPC format) |
193 | uint32_t log_format:4; /* Log format indicator. Define */ | 228 | * XXX 3: Reserved |
194 | /* format used for byte 12-2047 */ | 229 | * XXXX 4: Log format used for bytes 12-2047 |
230 | */ | ||
231 | |||
195 | /* Byte 3 */ | 232 | /* Byte 3 */ |
196 | uint32_t :8; /* reserved */ | 233 | uint8_t byte3; /* reserved */ |
197 | /* Byte 4-11 */ | 234 | /* Byte 4-11 */ |
198 | uint8_t reserved[8]; /* reserved */ | 235 | uint8_t reserved[8]; /* reserved */ |
199 | /* Byte 12-15 */ | 236 | /* Byte 12-15 */ |
200 | uint32_t company_id; /* Company ID of the company */ | 237 | __be32 company_id; /* Company ID of the company */ |
201 | /* that defines the format for */ | 238 | /* that defines the format for */ |
202 | /* the vendor specific log type */ | 239 | /* the vendor specific log type */ |
203 | /* Byte 16-end of log */ | 240 | /* Byte 16-end of log */ |
@@ -205,6 +242,18 @@ struct rtas_ext_event_log_v6 { | |||
205 | /* Variable length. */ | 242 | /* Variable length. */ |
206 | }; | 243 | }; |
207 | 244 | ||
245 | static | ||
246 | inline uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log) | ||
247 | { | ||
248 | return ext_log->byte2 & 0x0F; | ||
249 | } | ||
250 | |||
251 | static | ||
252 | inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log) | ||
253 | { | ||
254 | return be32_to_cpu(ext_log->company_id); | ||
255 | } | ||
256 | |||
208 | /* pSeries event log format */ | 257 | /* pSeries event log format */ |
209 | 258 | ||
210 | /* Two bytes ASCII section IDs */ | 259 | /* Two bytes ASCII section IDs */ |
@@ -227,14 +276,26 @@ struct rtas_ext_event_log_v6 { | |||
227 | 276 | ||
228 | /* Vendor specific Platform Event Log Format, Version 6, section header */ | 277 | /* Vendor specific Platform Event Log Format, Version 6, section header */ |
229 | struct pseries_errorlog { | 278 | struct pseries_errorlog { |
230 | uint16_t id; /* 0x00 2-byte ASCII section ID */ | 279 | __be16 id; /* 0x00 2-byte ASCII section ID */ |
231 | uint16_t length; /* 0x02 Section length in bytes */ | 280 | __be16 length; /* 0x02 Section length in bytes */ |
232 | uint8_t version; /* 0x04 Section version */ | 281 | uint8_t version; /* 0x04 Section version */ |
233 | uint8_t subtype; /* 0x05 Section subtype */ | 282 | uint8_t subtype; /* 0x05 Section subtype */ |
234 | uint16_t creator_component; /* 0x06 Creator component ID */ | 283 | __be16 creator_component; /* 0x06 Creator component ID */ |
235 | uint8_t data[]; /* 0x08 Start of section data */ | 284 | uint8_t data[]; /* 0x08 Start of section data */ |
236 | }; | 285 | }; |
237 | 286 | ||
287 | static | ||
288 | inline uint16_t pseries_errorlog_id(struct pseries_errorlog *sect) | ||
289 | { | ||
290 | return be16_to_cpu(sect->id); | ||
291 | } | ||
292 | |||
293 | static | ||
294 | inline uint16_t pseries_errorlog_length(struct pseries_errorlog *sect) | ||
295 | { | ||
296 | return be16_to_cpu(sect->length); | ||
297 | } | ||
298 | |||
238 | struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, | 299 | struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, |
239 | uint16_t section_id); | 300 | uint16_t section_id); |
240 | 301 | ||
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c index de91f3ae631e..94908af308d8 100644 --- a/arch/powerpc/kernel/align.c +++ b/arch/powerpc/kernel/align.c | |||
@@ -73,7 +73,7 @@ static struct aligninfo aligninfo[128] = { | |||
73 | { 8, LD+F }, /* 00 0 1001: lfd */ | 73 | { 8, LD+F }, /* 00 0 1001: lfd */ |
74 | { 4, ST+F+S }, /* 00 0 1010: stfs */ | 74 | { 4, ST+F+S }, /* 00 0 1010: stfs */ |
75 | { 8, ST+F }, /* 00 0 1011: stfd */ | 75 | { 8, ST+F }, /* 00 0 1011: stfd */ |
76 | INVALID, /* 00 0 1100 */ | 76 | { 16, LD }, /* 00 0 1100: lq */ |
77 | { 8, LD }, /* 00 0 1101: ld/ldu/lwa */ | 77 | { 8, LD }, /* 00 0 1101: ld/ldu/lwa */ |
78 | INVALID, /* 00 0 1110 */ | 78 | INVALID, /* 00 0 1110 */ |
79 | { 8, ST }, /* 00 0 1111: std/stdu */ | 79 | { 8, ST }, /* 00 0 1111: std/stdu */ |
@@ -140,7 +140,7 @@ static struct aligninfo aligninfo[128] = { | |||
140 | { 2, LD+SW }, /* 10 0 1100: lhbrx */ | 140 | { 2, LD+SW }, /* 10 0 1100: lhbrx */ |
141 | { 4, LD+SE }, /* 10 0 1101 lwa */ | 141 | { 4, LD+SE }, /* 10 0 1101 lwa */ |
142 | { 2, ST+SW }, /* 10 0 1110: sthbrx */ | 142 | { 2, ST+SW }, /* 10 0 1110: sthbrx */ |
143 | INVALID, /* 10 0 1111 */ | 143 | { 16, ST }, /* 10 0 1111: stq */ |
144 | INVALID, /* 10 1 0000 */ | 144 | INVALID, /* 10 1 0000 */ |
145 | INVALID, /* 10 1 0001 */ | 145 | INVALID, /* 10 1 0001 */ |
146 | INVALID, /* 10 1 0010 */ | 146 | INVALID, /* 10 1 0010 */ |
@@ -385,8 +385,6 @@ static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg, | |||
385 | char *ptr1 = (char *) ¤t->thread.TS_FPR(reg+1); | 385 | char *ptr1 = (char *) ¤t->thread.TS_FPR(reg+1); |
386 | int i, ret, sw = 0; | 386 | int i, ret, sw = 0; |
387 | 387 | ||
388 | if (!(flags & F)) | ||
389 | return 0; | ||
390 | if (reg & 1) | 388 | if (reg & 1) |
391 | return 0; /* invalid form: FRS/FRT must be even */ | 389 | return 0; /* invalid form: FRS/FRT must be even */ |
392 | if (flags & SW) | 390 | if (flags & SW) |
@@ -406,6 +404,34 @@ static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg, | |||
406 | return 1; /* exception handled and fixed up */ | 404 | return 1; /* exception handled and fixed up */ |
407 | } | 405 | } |
408 | 406 | ||
407 | #ifdef CONFIG_PPC64 | ||
408 | static int emulate_lq_stq(struct pt_regs *regs, unsigned char __user *addr, | ||
409 | unsigned int reg, unsigned int flags) | ||
410 | { | ||
411 | char *ptr0 = (char *)®s->gpr[reg]; | ||
412 | char *ptr1 = (char *)®s->gpr[reg+1]; | ||
413 | int i, ret, sw = 0; | ||
414 | |||
415 | if (reg & 1) | ||
416 | return 0; /* invalid form: GPR must be even */ | ||
417 | if (flags & SW) | ||
418 | sw = 7; | ||
419 | ret = 0; | ||
420 | for (i = 0; i < 8; ++i) { | ||
421 | if (!(flags & ST)) { | ||
422 | ret |= __get_user(ptr0[i^sw], addr + i); | ||
423 | ret |= __get_user(ptr1[i^sw], addr + i + 8); | ||
424 | } else { | ||
425 | ret |= __put_user(ptr0[i^sw], addr + i); | ||
426 | ret |= __put_user(ptr1[i^sw], addr + i + 8); | ||
427 | } | ||
428 | } | ||
429 | if (ret) | ||
430 | return -EFAULT; | ||
431 | return 1; /* exception handled and fixed up */ | ||
432 | } | ||
433 | #endif /* CONFIG_PPC64 */ | ||
434 | |||
409 | #ifdef CONFIG_SPE | 435 | #ifdef CONFIG_SPE |
410 | 436 | ||
411 | static struct aligninfo spe_aligninfo[32] = { | 437 | static struct aligninfo spe_aligninfo[32] = { |
@@ -914,10 +940,20 @@ int fix_alignment(struct pt_regs *regs) | |||
914 | flush_fp_to_thread(current); | 940 | flush_fp_to_thread(current); |
915 | } | 941 | } |
916 | 942 | ||
917 | /* Special case for 16-byte FP loads and stores */ | 943 | if ((nb == 16)) { |
918 | if (nb == 16) { | 944 | if (flags & F) { |
919 | PPC_WARN_ALIGNMENT(fp_pair, regs); | 945 | /* Special case for 16-byte FP loads and stores */ |
920 | return emulate_fp_pair(addr, reg, flags); | 946 | PPC_WARN_ALIGNMENT(fp_pair, regs); |
947 | return emulate_fp_pair(addr, reg, flags); | ||
948 | } else { | ||
949 | #ifdef CONFIG_PPC64 | ||
950 | /* Special case for 16-byte loads and stores */ | ||
951 | PPC_WARN_ALIGNMENT(lq_stq, regs); | ||
952 | return emulate_lq_stq(regs, addr, reg, flags); | ||
953 | #else | ||
954 | return 0; | ||
955 | #endif | ||
956 | } | ||
921 | } | 957 | } |
922 | 958 | ||
923 | PPC_WARN_ALIGNMENT(unaligned, regs); | 959 | PPC_WARN_ALIGNMENT(unaligned, regs); |
diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S index 37d1bb002aa9..1557e7c2c7e1 100644 --- a/arch/powerpc/kernel/cpu_setup_power.S +++ b/arch/powerpc/kernel/cpu_setup_power.S | |||
@@ -56,7 +56,6 @@ _GLOBAL(__setup_cpu_power8) | |||
56 | li r0,0 | 56 | li r0,0 |
57 | mtspr SPRN_LPID,r0 | 57 | mtspr SPRN_LPID,r0 |
58 | mfspr r3,SPRN_LPCR | 58 | mfspr r3,SPRN_LPCR |
59 | oris r3, r3, LPCR_AIL_3@h | ||
60 | bl __init_LPCR | 59 | bl __init_LPCR |
61 | bl __init_HFSCR | 60 | bl __init_HFSCR |
62 | bl __init_tlb_power8 | 61 | bl __init_tlb_power8 |
@@ -75,7 +74,6 @@ _GLOBAL(__restore_cpu_power8) | |||
75 | li r0,0 | 74 | li r0,0 |
76 | mtspr SPRN_LPID,r0 | 75 | mtspr SPRN_LPID,r0 |
77 | mfspr r3,SPRN_LPCR | 76 | mfspr r3,SPRN_LPCR |
78 | oris r3, r3, LPCR_AIL_3@h | ||
79 | bl __init_LPCR | 77 | bl __init_LPCR |
80 | bl __init_HFSCR | 78 | bl __init_HFSCR |
81 | bl __init_tlb_power8 | 79 | bl __init_tlb_power8 |
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index d9c650ec7dac..3afd3915921a 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
@@ -54,14 +54,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \ | |||
54 | xori r12,r12,MSR_LE ; \ | 54 | xori r12,r12,MSR_LE ; \ |
55 | mtspr SPRN_SRR1,r12 ; \ | 55 | mtspr SPRN_SRR1,r12 ; \ |
56 | rfid ; /* return to userspace */ \ | 56 | rfid ; /* return to userspace */ \ |
57 | b . ; \ | ||
58 | 2: mfspr r12,SPRN_SRR1 ; \ | ||
59 | andi. r12,r12,MSR_PR ; \ | ||
60 | bne 0b ; \ | ||
61 | mtspr SPRN_SRR0,r3 ; \ | ||
62 | mtspr SPRN_SRR1,r4 ; \ | ||
63 | mtspr SPRN_SDR1,r5 ; \ | ||
64 | rfid ; \ | ||
65 | b . ; /* prevent speculative execution */ | 57 | b . ; /* prevent speculative execution */ |
66 | 58 | ||
67 | #if defined(CONFIG_RELOCATABLE) | 59 | #if defined(CONFIG_RELOCATABLE) |
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index bf0aada02fe4..ad302f845e5d 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c | |||
@@ -152,7 +152,8 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu) | |||
152 | new_paca->paca_index = cpu; | 152 | new_paca->paca_index = cpu; |
153 | new_paca->kernel_toc = kernel_toc; | 153 | new_paca->kernel_toc = kernel_toc; |
154 | new_paca->kernelbase = (unsigned long) _stext; | 154 | new_paca->kernelbase = (unsigned long) _stext; |
155 | new_paca->kernel_msr = MSR_KERNEL; | 155 | /* Only set MSR:IR/DR when MMU is initialized */ |
156 | new_paca->kernel_msr = MSR_KERNEL & ~(MSR_IR | MSR_DR); | ||
156 | new_paca->hw_cpu_id = 0xffff; | 157 | new_paca->hw_cpu_id = 0xffff; |
157 | new_paca->kexec_state = KEXEC_STATE_NONE; | 158 | new_paca->kexec_state = KEXEC_STATE_NONE; |
158 | new_paca->__current = &init_task; | 159 | new_paca->__current = &init_task; |
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index af064d28b365..31d021506d21 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -610,6 +610,31 @@ out_and_saveregs: | |||
610 | tm_save_sprs(thr); | 610 | tm_save_sprs(thr); |
611 | } | 611 | } |
612 | 612 | ||
613 | extern void __tm_recheckpoint(struct thread_struct *thread, | ||
614 | unsigned long orig_msr); | ||
615 | |||
616 | void tm_recheckpoint(struct thread_struct *thread, | ||
617 | unsigned long orig_msr) | ||
618 | { | ||
619 | unsigned long flags; | ||
620 | |||
621 | /* We really can't be interrupted here as the TEXASR registers can't | ||
622 | * change and later in the trecheckpoint code, we have a userspace R1. | ||
623 | * So let's hard disable over this region. | ||
624 | */ | ||
625 | local_irq_save(flags); | ||
626 | hard_irq_disable(); | ||
627 | |||
628 | /* The TM SPRs are restored here, so that TEXASR.FS can be set | ||
629 | * before the trecheckpoint and no explosion occurs. | ||
630 | */ | ||
631 | tm_restore_sprs(thread); | ||
632 | |||
633 | __tm_recheckpoint(thread, orig_msr); | ||
634 | |||
635 | local_irq_restore(flags); | ||
636 | } | ||
637 | |||
613 | static inline void tm_recheckpoint_new_task(struct task_struct *new) | 638 | static inline void tm_recheckpoint_new_task(struct task_struct *new) |
614 | { | 639 | { |
615 | unsigned long msr; | 640 | unsigned long msr; |
@@ -628,13 +653,10 @@ static inline void tm_recheckpoint_new_task(struct task_struct *new) | |||
628 | if (!new->thread.regs) | 653 | if (!new->thread.regs) |
629 | return; | 654 | return; |
630 | 655 | ||
631 | /* The TM SPRs are restored here, so that TEXASR.FS can be set | 656 | if (!MSR_TM_ACTIVE(new->thread.regs->msr)){ |
632 | * before the trecheckpoint and no explosion occurs. | 657 | tm_restore_sprs(&new->thread); |
633 | */ | ||
634 | tm_restore_sprs(&new->thread); | ||
635 | |||
636 | if (!MSR_TM_ACTIVE(new->thread.regs->msr)) | ||
637 | return; | 658 | return; |
659 | } | ||
638 | msr = new->thread.tm_orig_msr; | 660 | msr = new->thread.tm_orig_msr; |
639 | /* Recheckpoint to restore original checkpointed register state. */ | 661 | /* Recheckpoint to restore original checkpointed register state. */ |
640 | TM_DEBUG("*** tm_recheckpoint of pid %d " | 662 | TM_DEBUG("*** tm_recheckpoint of pid %d " |
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index dd72bebd708a..668aa4791fd7 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -347,45 +347,45 @@ static int __init early_init_dt_scan_cpus(unsigned long node, | |||
347 | #endif | 347 | #endif |
348 | } | 348 | } |
349 | 349 | ||
350 | if (found >= 0) { | 350 | /* Not the boot CPU */ |
351 | DBG("boot cpu: logical %d physical %d\n", found, | 351 | if (found < 0) |
352 | be32_to_cpu(intserv[found_thread])); | 352 | return 0; |
353 | boot_cpuid = found; | ||
354 | set_hard_smp_processor_id(found, | ||
355 | be32_to_cpu(intserv[found_thread])); | ||
356 | 353 | ||
357 | /* | 354 | DBG("boot cpu: logical %d physical %d\n", found, |
358 | * PAPR defines "logical" PVR values for cpus that | 355 | be32_to_cpu(intserv[found_thread])); |
359 | * meet various levels of the architecture: | 356 | boot_cpuid = found; |
360 | * 0x0f000001 Architecture version 2.04 | 357 | set_hard_smp_processor_id(found, be32_to_cpu(intserv[found_thread])); |
361 | * 0x0f000002 Architecture version 2.05 | ||
362 | * If the cpu-version property in the cpu node contains | ||
363 | * such a value, we call identify_cpu again with the | ||
364 | * logical PVR value in order to use the cpu feature | ||
365 | * bits appropriate for the architecture level. | ||
366 | * | ||
367 | * A POWER6 partition in "POWER6 architected" mode | ||
368 | * uses the 0x0f000002 PVR value; in POWER5+ mode | ||
369 | * it uses 0x0f000001. | ||
370 | */ | ||
371 | prop = of_get_flat_dt_prop(node, "cpu-version", NULL); | ||
372 | if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000) | ||
373 | identify_cpu(0, be32_to_cpup(prop)); | ||
374 | 358 | ||
375 | identical_pvr_fixup(node); | 359 | /* |
376 | } | 360 | * PAPR defines "logical" PVR values for cpus that |
361 | * meet various levels of the architecture: | ||
362 | * 0x0f000001 Architecture version 2.04 | ||
363 | * 0x0f000002 Architecture version 2.05 | ||
364 | * If the cpu-version property in the cpu node contains | ||
365 | * such a value, we call identify_cpu again with the | ||
366 | * logical PVR value in order to use the cpu feature | ||
367 | * bits appropriate for the architecture level. | ||
368 | * | ||
369 | * A POWER6 partition in "POWER6 architected" mode | ||
370 | * uses the 0x0f000002 PVR value; in POWER5+ mode | ||
371 | * it uses 0x0f000001. | ||
372 | */ | ||
373 | prop = of_get_flat_dt_prop(node, "cpu-version", NULL); | ||
374 | if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000) | ||
375 | identify_cpu(0, be32_to_cpup(prop)); | ||
376 | |||
377 | identical_pvr_fixup(node); | ||
377 | 378 | ||
378 | check_cpu_feature_properties(node); | 379 | check_cpu_feature_properties(node); |
379 | check_cpu_pa_features(node); | 380 | check_cpu_pa_features(node); |
380 | check_cpu_slb_size(node); | 381 | check_cpu_slb_size(node); |
381 | 382 | ||
382 | #ifdef CONFIG_PPC_PSERIES | 383 | #ifdef CONFIG_PPC64 |
383 | if (nthreads > 1) | 384 | if (nthreads > 1) |
384 | cur_cpu_spec->cpu_features |= CPU_FTR_SMT; | 385 | cur_cpu_spec->cpu_features |= CPU_FTR_SMT; |
385 | else | 386 | else |
386 | cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT; | 387 | cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT; |
387 | #endif | 388 | #endif |
388 | |||
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |
391 | 391 | ||
@@ -747,6 +747,10 @@ void __init early_init_devtree(void *params) | |||
747 | * (altivec support, boot CPU ID, ...) | 747 | * (altivec support, boot CPU ID, ...) |
748 | */ | 748 | */ |
749 | of_scan_flat_dt(early_init_dt_scan_cpus, NULL); | 749 | of_scan_flat_dt(early_init_dt_scan_cpus, NULL); |
750 | if (boot_cpuid < 0) { | ||
751 | printk("Failed to indentify boot CPU !\n"); | ||
752 | BUG(); | ||
753 | } | ||
750 | 754 | ||
751 | #if defined(CONFIG_SMP) && defined(CONFIG_PPC64) | 755 | #if defined(CONFIG_SMP) && defined(CONFIG_PPC64) |
752 | /* We'll later wait for secondaries to check in; there are | 756 | /* We'll later wait for secondaries to check in; there are |
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c index f386296ff378..8cd5ed049b5d 100644 --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c | |||
@@ -993,21 +993,24 @@ struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, | |||
993 | (struct rtas_ext_event_log_v6 *)log->buffer; | 993 | (struct rtas_ext_event_log_v6 *)log->buffer; |
994 | struct pseries_errorlog *sect; | 994 | struct pseries_errorlog *sect; |
995 | unsigned char *p, *log_end; | 995 | unsigned char *p, *log_end; |
996 | uint32_t ext_log_length = rtas_error_extended_log_length(log); | ||
997 | uint8_t log_format = rtas_ext_event_log_format(ext_log); | ||
998 | uint32_t company_id = rtas_ext_event_company_id(ext_log); | ||
996 | 999 | ||
997 | /* Check that we understand the format */ | 1000 | /* Check that we understand the format */ |
998 | if (log->extended_log_length < sizeof(struct rtas_ext_event_log_v6) || | 1001 | if (ext_log_length < sizeof(struct rtas_ext_event_log_v6) || |
999 | ext_log->log_format != RTAS_V6EXT_LOG_FORMAT_EVENT_LOG || | 1002 | log_format != RTAS_V6EXT_LOG_FORMAT_EVENT_LOG || |
1000 | ext_log->company_id != RTAS_V6EXT_COMPANY_ID_IBM) | 1003 | company_id != RTAS_V6EXT_COMPANY_ID_IBM) |
1001 | return NULL; | 1004 | return NULL; |
1002 | 1005 | ||
1003 | log_end = log->buffer + log->extended_log_length; | 1006 | log_end = log->buffer + ext_log_length; |
1004 | p = ext_log->vendor_log; | 1007 | p = ext_log->vendor_log; |
1005 | 1008 | ||
1006 | while (p < log_end) { | 1009 | while (p < log_end) { |
1007 | sect = (struct pseries_errorlog *)p; | 1010 | sect = (struct pseries_errorlog *)p; |
1008 | if (sect->id == section_id) | 1011 | if (pseries_errorlog_id(sect) == section_id) |
1009 | return sect; | 1012 | return sect; |
1010 | p += sect->length; | 1013 | p += pseries_errorlog_length(sect); |
1011 | } | 1014 | } |
1012 | 1015 | ||
1013 | return NULL; | 1016 | return NULL; |
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c index 1130c53ad652..e736387fee6a 100644 --- a/arch/powerpc/kernel/rtasd.c +++ b/arch/powerpc/kernel/rtasd.c | |||
@@ -150,8 +150,8 @@ static void printk_log_rtas(char *buf, int len) | |||
150 | struct rtas_error_log *errlog = (struct rtas_error_log *)buf; | 150 | struct rtas_error_log *errlog = (struct rtas_error_log *)buf; |
151 | 151 | ||
152 | printk(RTAS_DEBUG "event: %d, Type: %s, Severity: %d\n", | 152 | printk(RTAS_DEBUG "event: %d, Type: %s, Severity: %d\n", |
153 | error_log_cnt, rtas_event_type(errlog->type), | 153 | error_log_cnt, rtas_event_type(rtas_error_type(errlog)), |
154 | errlog->severity); | 154 | rtas_error_severity(errlog)); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
@@ -159,14 +159,16 @@ static int log_rtas_len(char * buf) | |||
159 | { | 159 | { |
160 | int len; | 160 | int len; |
161 | struct rtas_error_log *err; | 161 | struct rtas_error_log *err; |
162 | uint32_t extended_log_length; | ||
162 | 163 | ||
163 | /* rtas fixed header */ | 164 | /* rtas fixed header */ |
164 | len = 8; | 165 | len = 8; |
165 | err = (struct rtas_error_log *)buf; | 166 | err = (struct rtas_error_log *)buf; |
166 | if (err->extended && err->extended_log_length) { | 167 | extended_log_length = rtas_error_extended_log_length(err); |
168 | if (rtas_error_extended(err) && extended_log_length) { | ||
167 | 169 | ||
168 | /* extended header */ | 170 | /* extended header */ |
169 | len += err->extended_log_length; | 171 | len += extended_log_length; |
170 | } | 172 | } |
171 | 173 | ||
172 | if (rtas_error_log_max == 0) | 174 | if (rtas_error_log_max == 0) |
@@ -293,15 +295,13 @@ void prrn_schedule_update(u32 scope) | |||
293 | 295 | ||
294 | static void handle_rtas_event(const struct rtas_error_log *log) | 296 | static void handle_rtas_event(const struct rtas_error_log *log) |
295 | { | 297 | { |
296 | if (log->type == RTAS_TYPE_PRRN) { | 298 | if (rtas_error_type(log) != RTAS_TYPE_PRRN || !prrn_is_enabled()) |
297 | /* For PRRN Events the extended log length is used to denote | 299 | return; |
298 | * the scope for calling rtas update-nodes. | ||
299 | */ | ||
300 | if (prrn_is_enabled()) | ||
301 | prrn_schedule_update(log->extended_log_length); | ||
302 | } | ||
303 | 300 | ||
304 | return; | 301 | /* For PRRN Events the extended log length is used to denote |
302 | * the scope for calling rtas update-nodes. | ||
303 | */ | ||
304 | prrn_schedule_update(rtas_error_extended_log_length(log)); | ||
305 | } | 305 | } |
306 | 306 | ||
307 | #else | 307 | #else |
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index bc76cc6b419c..79b7612ac6fa 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c | |||
@@ -76,6 +76,9 @@ EXPORT_SYMBOL(ppc_md); | |||
76 | struct machdep_calls *machine_id; | 76 | struct machdep_calls *machine_id; |
77 | EXPORT_SYMBOL(machine_id); | 77 | EXPORT_SYMBOL(machine_id); |
78 | 78 | ||
79 | int boot_cpuid = -1; | ||
80 | EXPORT_SYMBOL_GPL(boot_cpuid); | ||
81 | |||
79 | unsigned long klimit = (unsigned long) _end; | 82 | unsigned long klimit = (unsigned long) _end; |
80 | 83 | ||
81 | char cmd_line[COMMAND_LINE_SIZE]; | 84 | char cmd_line[COMMAND_LINE_SIZE]; |
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 04cc4fcca78b..ea4fda60e57b 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c | |||
@@ -44,8 +44,6 @@ | |||
44 | 44 | ||
45 | extern void bootx_init(unsigned long r4, unsigned long phys); | 45 | extern void bootx_init(unsigned long r4, unsigned long phys); |
46 | 46 | ||
47 | int boot_cpuid = -1; | ||
48 | EXPORT_SYMBOL_GPL(boot_cpuid); | ||
49 | int boot_cpuid_phys; | 47 | int boot_cpuid_phys; |
50 | EXPORT_SYMBOL_GPL(boot_cpuid_phys); | 48 | EXPORT_SYMBOL_GPL(boot_cpuid_phys); |
51 | 49 | ||
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 4933909cc5c0..3d7a50a08f5e 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -74,7 +74,6 @@ | |||
74 | #define DBG(fmt...) | 74 | #define DBG(fmt...) |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | int boot_cpuid = 0; | ||
78 | int spinning_secondaries; | 77 | int spinning_secondaries; |
79 | u64 ppc64_pft_size; | 78 | u64 ppc64_pft_size; |
80 | 79 | ||
@@ -196,6 +195,18 @@ static void fixup_boot_paca(void) | |||
196 | get_paca()->data_offset = 0; | 195 | get_paca()->data_offset = 0; |
197 | } | 196 | } |
198 | 197 | ||
198 | static void cpu_ready_for_interrupts(void) | ||
199 | { | ||
200 | /* Set IR and DR in PACA MSR */ | ||
201 | get_paca()->kernel_msr = MSR_KERNEL; | ||
202 | |||
203 | /* Enable AIL if supported */ | ||
204 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) { | ||
205 | unsigned long lpcr = mfspr(SPRN_LPCR); | ||
206 | mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3); | ||
207 | } | ||
208 | } | ||
209 | |||
199 | /* | 210 | /* |
200 | * Early initialization entry point. This is called by head.S | 211 | * Early initialization entry point. This is called by head.S |
201 | * with MMU translation disabled. We rely on the "feature" of | 212 | * with MMU translation disabled. We rely on the "feature" of |
@@ -262,6 +273,14 @@ void __init early_setup(unsigned long dt_ptr) | |||
262 | /* Initialize the hash table or TLB handling */ | 273 | /* Initialize the hash table or TLB handling */ |
263 | early_init_mmu(); | 274 | early_init_mmu(); |
264 | 275 | ||
276 | /* | ||
277 | * At this point, we can let interrupts switch to virtual mode | ||
278 | * (the MMU has been setup), so adjust the MSR in the PACA to | ||
279 | * have IR and DR set and enable AIL if it exists | ||
280 | */ | ||
281 | cpu_ready_for_interrupts(); | ||
282 | |||
283 | /* Reserve large chunks of memory for use by CMA for KVM */ | ||
265 | kvm_cma_reserve(); | 284 | kvm_cma_reserve(); |
266 | 285 | ||
267 | /* | 286 | /* |
@@ -294,6 +313,13 @@ void early_setup_secondary(void) | |||
294 | 313 | ||
295 | /* Initialize the hash table or TLB handling */ | 314 | /* Initialize the hash table or TLB handling */ |
296 | early_init_mmu_secondary(); | 315 | early_init_mmu_secondary(); |
316 | |||
317 | /* | ||
318 | * At this point, we can let interrupts switch to virtual mode | ||
319 | * (the MMU has been setup), so adjust the MSR in the PACA to | ||
320 | * have IR and DR set. | ||
321 | */ | ||
322 | cpu_ready_for_interrupts(); | ||
297 | } | 323 | } |
298 | 324 | ||
299 | #endif /* CONFIG_SMP */ | 325 | #endif /* CONFIG_SMP */ |
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index a67e00aa3caa..4e47db686b5d 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c | |||
@@ -881,6 +881,8 @@ static long restore_tm_user_regs(struct pt_regs *regs, | |||
881 | * transactional versions should be loaded. | 881 | * transactional versions should be loaded. |
882 | */ | 882 | */ |
883 | tm_enable(); | 883 | tm_enable(); |
884 | /* Make sure the transaction is marked as failed */ | ||
885 | current->thread.tm_texasr |= TEXASR_FS; | ||
884 | /* This loads the checkpointed FP/VEC state, if used */ | 886 | /* This loads the checkpointed FP/VEC state, if used */ |
885 | tm_recheckpoint(¤t->thread, msr); | 887 | tm_recheckpoint(¤t->thread, msr); |
886 | /* Get the top half of the MSR */ | 888 | /* Get the top half of the MSR */ |
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 8d253c29649b..d501dc4dc3e6 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c | |||
@@ -527,6 +527,8 @@ static long restore_tm_sigcontexts(struct pt_regs *regs, | |||
527 | } | 527 | } |
528 | #endif | 528 | #endif |
529 | tm_enable(); | 529 | tm_enable(); |
530 | /* Make sure the transaction is marked as failed */ | ||
531 | current->thread.tm_texasr |= TEXASR_FS; | ||
530 | /* This loads the checkpointed FP/VEC state, if used */ | 532 | /* This loads the checkpointed FP/VEC state, if used */ |
531 | tm_recheckpoint(¤t->thread, msr); | 533 | tm_recheckpoint(¤t->thread, msr); |
532 | 534 | ||
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S index ef47bcbd4352..03567c05950a 100644 --- a/arch/powerpc/kernel/tm.S +++ b/arch/powerpc/kernel/tm.S | |||
@@ -307,7 +307,7 @@ dont_backup_fp: | |||
307 | * Call with IRQs off, stacks get all out of sync for | 307 | * Call with IRQs off, stacks get all out of sync for |
308 | * some periods in here! | 308 | * some periods in here! |
309 | */ | 309 | */ |
310 | _GLOBAL(tm_recheckpoint) | 310 | _GLOBAL(__tm_recheckpoint) |
311 | mfcr r5 | 311 | mfcr r5 |
312 | mflr r0 | 312 | mflr r0 |
313 | stw r5, 8(r1) | 313 | stw r5, 8(r1) |
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index df86f0ce2d36..1bd7ca298fa1 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c | |||
@@ -1868,6 +1868,7 @@ struct ppc_emulated ppc_emulated = { | |||
1868 | #ifdef CONFIG_PPC64 | 1868 | #ifdef CONFIG_PPC64 |
1869 | WARN_EMULATED_SETUP(mfdscr), | 1869 | WARN_EMULATED_SETUP(mfdscr), |
1870 | WARN_EMULATED_SETUP(mtdscr), | 1870 | WARN_EMULATED_SETUP(mtdscr), |
1871 | WARN_EMULATED_SETUP(lq_stq), | ||
1871 | #endif | 1872 | #endif |
1872 | }; | 1873 | }; |
1873 | 1874 | ||
diff --git a/arch/powerpc/math-emu/mtfsf.c b/arch/powerpc/math-emu/mtfsf.c index dbce92e4f046..44b0fc8214f4 100644 --- a/arch/powerpc/math-emu/mtfsf.c +++ b/arch/powerpc/math-emu/mtfsf.c | |||
@@ -11,48 +11,36 @@ mtfsf(unsigned int FM, u32 *frB) | |||
11 | u32 mask; | 11 | u32 mask; |
12 | u32 fpscr; | 12 | u32 fpscr; |
13 | 13 | ||
14 | if (FM == 0) | 14 | if (likely(FM == 1)) |
15 | return 0; | 15 | mask = 0x0f; |
16 | 16 | else if (likely(FM == 0xff)) | |
17 | if (FM == 0xff) | 17 | mask = ~0; |
18 | mask = 0x9fffffff; | ||
19 | else { | 18 | else { |
20 | mask = 0; | 19 | mask = ((FM & 1) | |
21 | if (FM & (1 << 0)) | 20 | ((FM << 3) & 0x10) | |
22 | mask |= 0x90000000; | 21 | ((FM << 6) & 0x100) | |
23 | if (FM & (1 << 1)) | 22 | ((FM << 9) & 0x1000) | |
24 | mask |= 0x0f000000; | 23 | ((FM << 12) & 0x10000) | |
25 | if (FM & (1 << 2)) | 24 | ((FM << 15) & 0x100000) | |
26 | mask |= 0x00f00000; | 25 | ((FM << 18) & 0x1000000) | |
27 | if (FM & (1 << 3)) | 26 | ((FM << 21) & 0x10000000)) * 15; |
28 | mask |= 0x000f0000; | ||
29 | if (FM & (1 << 4)) | ||
30 | mask |= 0x0000f000; | ||
31 | if (FM & (1 << 5)) | ||
32 | mask |= 0x00000f00; | ||
33 | if (FM & (1 << 6)) | ||
34 | mask |= 0x000000f0; | ||
35 | if (FM & (1 << 7)) | ||
36 | mask |= 0x0000000f; | ||
37 | } | 27 | } |
38 | 28 | ||
39 | __FPU_FPSCR &= ~(mask); | 29 | fpscr = ((__FPU_FPSCR & ~mask) | (frB[1] & mask)) & |
40 | __FPU_FPSCR |= (frB[1] & mask); | 30 | ~(FPSCR_VX | FPSCR_FEX | 0x800); |
41 | 31 | ||
42 | __FPU_FPSCR &= ~(FPSCR_VX); | 32 | if (fpscr & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI | |
43 | if (__FPU_FPSCR & (FPSCR_VXSNAN | FPSCR_VXISI | FPSCR_VXIDI | | ||
44 | FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC | | 33 | FPSCR_VXZDZ | FPSCR_VXIMZ | FPSCR_VXVC | |
45 | FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI)) | 34 | FPSCR_VXSOFT | FPSCR_VXSQRT | FPSCR_VXCVI)) |
46 | __FPU_FPSCR |= FPSCR_VX; | 35 | fpscr |= FPSCR_VX; |
47 | 36 | ||
48 | fpscr = __FPU_FPSCR; | 37 | /* The bit order of exception enables and exception status |
49 | fpscr &= ~(FPSCR_FEX); | 38 | * is the same. Simply shift and mask to check for enabled |
50 | if (((fpscr & FPSCR_VX) && (fpscr & FPSCR_VE)) || | 39 | * exceptions. |
51 | ((fpscr & FPSCR_OX) && (fpscr & FPSCR_OE)) || | 40 | */ |
52 | ((fpscr & FPSCR_UX) && (fpscr & FPSCR_UE)) || | 41 | if (fpscr & (fpscr >> 22) & 0xf8) |
53 | ((fpscr & FPSCR_ZX) && (fpscr & FPSCR_ZE)) || | ||
54 | ((fpscr & FPSCR_XX) && (fpscr & FPSCR_XE))) | ||
55 | fpscr |= FPSCR_FEX; | 42 | fpscr |= FPSCR_FEX; |
43 | |||
56 | __FPU_FPSCR = fpscr; | 44 | __FPU_FPSCR = fpscr; |
57 | 45 | ||
58 | #ifdef DEBUG | 46 | #ifdef DEBUG |
diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c index c5f734e20b0f..d8746684f606 100644 --- a/arch/powerpc/mm/gup.c +++ b/arch/powerpc/mm/gup.c | |||
@@ -36,6 +36,11 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr, | |||
36 | do { | 36 | do { |
37 | pte_t pte = ACCESS_ONCE(*ptep); | 37 | pte_t pte = ACCESS_ONCE(*ptep); |
38 | struct page *page; | 38 | struct page *page; |
39 | /* | ||
40 | * Similar to the PMD case, NUMA hinting must take slow path | ||
41 | */ | ||
42 | if (pte_numa(pte)) | ||
43 | return 0; | ||
39 | 44 | ||
40 | if ((pte_val(pte) & mask) != result) | 45 | if ((pte_val(pte) & mask) != result) |
41 | return 0; | 46 | return 0; |
@@ -75,6 +80,14 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end, | |||
75 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) | 80 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) |
76 | return 0; | 81 | return 0; |
77 | if (pmd_huge(pmd) || pmd_large(pmd)) { | 82 | if (pmd_huge(pmd) || pmd_large(pmd)) { |
83 | /* | ||
84 | * NUMA hinting faults need to be handled in the GUP | ||
85 | * slowpath for accounting purposes and so that they | ||
86 | * can be serialised against THP migration. | ||
87 | */ | ||
88 | if (pmd_numa(pmd)) | ||
89 | return 0; | ||
90 | |||
78 | if (!gup_hugepte((pte_t *)pmdp, PMD_SIZE, addr, next, | 91 | if (!gup_hugepte((pte_t *)pmdp, PMD_SIZE, addr, next, |
79 | write, pages, nr)) | 92 | write, pages, nr)) |
80 | return 0; | 93 | return 0; |
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 30a42e24bf14..4ebbb9e99286 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
@@ -1591,6 +1591,20 @@ int arch_update_cpu_topology(void) | |||
1591 | cpu = cpu_last_thread_sibling(cpu); | 1591 | cpu = cpu_last_thread_sibling(cpu); |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | /* | ||
1595 | * In cases where we have nothing to update (because the updates list | ||
1596 | * is too short or because the new topology is same as the old one), | ||
1597 | * skip invoking update_cpu_topology() via stop-machine(). This is | ||
1598 | * necessary (and not just a fast-path optimization) since stop-machine | ||
1599 | * can end up electing a random CPU to run update_cpu_topology(), and | ||
1600 | * thus trick us into setting up incorrect cpu-node mappings (since | ||
1601 | * 'updates' is kzalloc()'ed). | ||
1602 | * | ||
1603 | * And for the similar reason, we will skip all the following updating. | ||
1604 | */ | ||
1605 | if (!cpumask_weight(&updated_cpus)) | ||
1606 | goto out; | ||
1607 | |||
1594 | stop_machine(update_cpu_topology, &updates[0], &updated_cpus); | 1608 | stop_machine(update_cpu_topology, &updates[0], &updated_cpus); |
1595 | 1609 | ||
1596 | /* | 1610 | /* |
@@ -1612,6 +1626,7 @@ int arch_update_cpu_topology(void) | |||
1612 | changed = 1; | 1626 | changed = 1; |
1613 | } | 1627 | } |
1614 | 1628 | ||
1629 | out: | ||
1615 | kfree(updates); | 1630 | kfree(updates); |
1616 | return changed; | 1631 | return changed; |
1617 | } | 1632 | } |
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c index 3844f1397fc3..38e0a1a5cec3 100644 --- a/arch/powerpc/platforms/cell/spu_syscalls.c +++ b/arch/powerpc/platforms/cell/spu_syscalls.c | |||
@@ -170,7 +170,7 @@ EXPORT_SYMBOL_GPL(register_spu_syscalls); | |||
170 | void unregister_spu_syscalls(struct spufs_calls *calls) | 170 | void unregister_spu_syscalls(struct spufs_calls *calls) |
171 | { | 171 | { |
172 | BUG_ON(spufs_calls->owner != calls->owner); | 172 | BUG_ON(spufs_calls->owner != calls->owner); |
173 | rcu_assign_pointer(spufs_calls, NULL); | 173 | RCU_INIT_POINTER(spufs_calls, NULL); |
174 | synchronize_rcu(); | 174 | synchronize_rcu(); |
175 | } | 175 | } |
176 | EXPORT_SYMBOL_GPL(unregister_spu_syscalls); | 176 | EXPORT_SYMBOL_GPL(unregister_spu_syscalls); |
diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index f324ea099503..63cebb9b4d45 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o opal-async.o | 1 | obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o opal-async.o |
2 | obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o | 2 | obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o |
3 | obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o | 3 | obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o |
4 | obj-y += opal-msglog.o | ||
4 | 5 | ||
5 | obj-$(CONFIG_SMP) += smp.o | 6 | obj-$(CONFIG_SMP) += smp.o |
6 | obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o | 7 | obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o |
diff --git a/arch/powerpc/platforms/powernv/opal-async.c b/arch/powerpc/platforms/powernv/opal-async.c index cd0c1354d404..32e2adfa5320 100644 --- a/arch/powerpc/platforms/powernv/opal-async.c +++ b/arch/powerpc/platforms/powernv/opal-async.c | |||
@@ -125,14 +125,15 @@ static int opal_async_comp_event(struct notifier_block *nb, | |||
125 | { | 125 | { |
126 | struct opal_msg *comp_msg = msg; | 126 | struct opal_msg *comp_msg = msg; |
127 | unsigned long flags; | 127 | unsigned long flags; |
128 | uint64_t token; | ||
128 | 129 | ||
129 | if (msg_type != OPAL_MSG_ASYNC_COMP) | 130 | if (msg_type != OPAL_MSG_ASYNC_COMP) |
130 | return 0; | 131 | return 0; |
131 | 132 | ||
132 | memcpy(&opal_async_responses[comp_msg->params[0]], comp_msg, | 133 | token = be64_to_cpu(comp_msg->params[0]); |
133 | sizeof(*comp_msg)); | 134 | memcpy(&opal_async_responses[token], comp_msg, sizeof(*comp_msg)); |
134 | spin_lock_irqsave(&opal_async_comp_lock, flags); | 135 | spin_lock_irqsave(&opal_async_comp_lock, flags); |
135 | __set_bit(comp_msg->params[0], opal_async_complete_map); | 136 | __set_bit(token, opal_async_complete_map); |
136 | spin_unlock_irqrestore(&opal_async_comp_lock, flags); | 137 | spin_unlock_irqrestore(&opal_async_comp_lock, flags); |
137 | 138 | ||
138 | wake_up(&opal_async_wait); | 139 | wake_up(&opal_async_wait); |
diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c index 0c767c561dc9..b9827b0d87e4 100644 --- a/arch/powerpc/platforms/powernv/opal-dump.c +++ b/arch/powerpc/platforms/powernv/opal-dump.c | |||
@@ -86,19 +86,14 @@ static int64_t dump_send_ack(uint32_t dump_id) | |||
86 | return rc; | 86 | return rc; |
87 | } | 87 | } |
88 | 88 | ||
89 | static void delay_release_kobj(void *kobj) | ||
90 | { | ||
91 | kobject_put((struct kobject *)kobj); | ||
92 | } | ||
93 | |||
94 | static ssize_t dump_ack_store(struct dump_obj *dump_obj, | 89 | static ssize_t dump_ack_store(struct dump_obj *dump_obj, |
95 | struct dump_attribute *attr, | 90 | struct dump_attribute *attr, |
96 | const char *buf, | 91 | const char *buf, |
97 | size_t count) | 92 | size_t count) |
98 | { | 93 | { |
99 | dump_send_ack(dump_obj->id); | 94 | dump_send_ack(dump_obj->id); |
100 | sysfs_schedule_callback(&dump_obj->kobj, delay_release_kobj, | 95 | sysfs_remove_file_self(&dump_obj->kobj, &attr->attr); |
101 | &dump_obj->kobj, THIS_MODULE); | 96 | kobject_put(&dump_obj->kobj); |
102 | return count; | 97 | return count; |
103 | } | 98 | } |
104 | 99 | ||
diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c index 1d7355bc9db0..ef7bc2a97862 100644 --- a/arch/powerpc/platforms/powernv/opal-elog.c +++ b/arch/powerpc/platforms/powernv/opal-elog.c | |||
@@ -70,19 +70,14 @@ static ssize_t elog_ack_show(struct elog_obj *elog_obj, | |||
70 | return sprintf(buf, "ack - acknowledge log message\n"); | 70 | return sprintf(buf, "ack - acknowledge log message\n"); |
71 | } | 71 | } |
72 | 72 | ||
73 | static void delay_release_kobj(void *kobj) | ||
74 | { | ||
75 | kobject_put((struct kobject *)kobj); | ||
76 | } | ||
77 | |||
78 | static ssize_t elog_ack_store(struct elog_obj *elog_obj, | 73 | static ssize_t elog_ack_store(struct elog_obj *elog_obj, |
79 | struct elog_attribute *attr, | 74 | struct elog_attribute *attr, |
80 | const char *buf, | 75 | const char *buf, |
81 | size_t count) | 76 | size_t count) |
82 | { | 77 | { |
83 | opal_send_ack_elog(elog_obj->id); | 78 | opal_send_ack_elog(elog_obj->id); |
84 | sysfs_schedule_callback(&elog_obj->kobj, delay_release_kobj, | 79 | sysfs_remove_file_self(&elog_obj->kobj, &attr->attr); |
85 | &elog_obj->kobj, THIS_MODULE); | 80 | kobject_put(&elog_obj->kobj); |
86 | return count; | 81 | return count; |
87 | } | 82 | } |
88 | 83 | ||
diff --git a/arch/powerpc/platforms/powernv/opal-msglog.c b/arch/powerpc/platforms/powernv/opal-msglog.c new file mode 100644 index 000000000000..1bb25b952504 --- /dev/null +++ b/arch/powerpc/platforms/powernv/opal-msglog.c | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | * PowerNV OPAL in-memory console interface | ||
3 | * | ||
4 | * Copyright 2014 IBM Corp. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <asm/io.h> | ||
13 | #include <asm/opal.h> | ||
14 | #include <linux/debugfs.h> | ||
15 | #include <linux/of.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <asm/barrier.h> | ||
18 | |||
19 | /* OPAL in-memory console. Defined in OPAL source at core/console.c */ | ||
20 | struct memcons { | ||
21 | __be64 magic; | ||
22 | #define MEMCONS_MAGIC 0x6630696567726173L | ||
23 | __be64 obuf_phys; | ||
24 | __be64 ibuf_phys; | ||
25 | __be32 obuf_size; | ||
26 | __be32 ibuf_size; | ||
27 | __be32 out_pos; | ||
28 | #define MEMCONS_OUT_POS_WRAP 0x80000000u | ||
29 | #define MEMCONS_OUT_POS_MASK 0x00ffffffu | ||
30 | __be32 in_prod; | ||
31 | __be32 in_cons; | ||
32 | }; | ||
33 | |||
34 | static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj, | ||
35 | struct bin_attribute *bin_attr, char *to, | ||
36 | loff_t pos, size_t count) | ||
37 | { | ||
38 | struct memcons *mc = bin_attr->private; | ||
39 | const char *conbuf; | ||
40 | size_t ret, first_read = 0; | ||
41 | uint32_t out_pos, avail; | ||
42 | |||
43 | if (!mc) | ||
44 | return -ENODEV; | ||
45 | |||
46 | out_pos = be32_to_cpu(ACCESS_ONCE(mc->out_pos)); | ||
47 | |||
48 | /* Now we've read out_pos, put a barrier in before reading the new | ||
49 | * data it points to in conbuf. */ | ||
50 | smp_rmb(); | ||
51 | |||
52 | conbuf = phys_to_virt(be64_to_cpu(mc->obuf_phys)); | ||
53 | |||
54 | /* When the buffer has wrapped, read from the out_pos marker to the end | ||
55 | * of the buffer, and then read the remaining data as in the un-wrapped | ||
56 | * case. */ | ||
57 | if (out_pos & MEMCONS_OUT_POS_WRAP) { | ||
58 | |||
59 | out_pos &= MEMCONS_OUT_POS_MASK; | ||
60 | avail = be32_to_cpu(mc->obuf_size) - out_pos; | ||
61 | |||
62 | ret = memory_read_from_buffer(to, count, &pos, | ||
63 | conbuf + out_pos, avail); | ||
64 | |||
65 | if (ret < 0) | ||
66 | goto out; | ||
67 | |||
68 | first_read = ret; | ||
69 | to += first_read; | ||
70 | count -= first_read; | ||
71 | pos -= avail; | ||
72 | } | ||
73 | |||
74 | /* Sanity check. The firmware should not do this to us. */ | ||
75 | if (out_pos > be32_to_cpu(mc->obuf_size)) { | ||
76 | pr_err("OPAL: memory console corruption. Aborting read.\n"); | ||
77 | return -EINVAL; | ||
78 | } | ||
79 | |||
80 | ret = memory_read_from_buffer(to, count, &pos, conbuf, out_pos); | ||
81 | |||
82 | if (ret < 0) | ||
83 | goto out; | ||
84 | |||
85 | ret += first_read; | ||
86 | out: | ||
87 | return ret; | ||
88 | } | ||
89 | |||
90 | static struct bin_attribute opal_msglog_attr = { | ||
91 | .attr = {.name = "msglog", .mode = 0444}, | ||
92 | .read = opal_msglog_read | ||
93 | }; | ||
94 | |||
95 | void __init opal_msglog_init(void) | ||
96 | { | ||
97 | u64 mcaddr; | ||
98 | struct memcons *mc; | ||
99 | |||
100 | if (of_property_read_u64(opal_node, "ibm,opal-memcons", &mcaddr)) { | ||
101 | pr_warn("OPAL: Property ibm,opal-memcons not found, no message log\n"); | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | mc = phys_to_virt(mcaddr); | ||
106 | if (!mc) { | ||
107 | pr_warn("OPAL: memory console address is invalid\n"); | ||
108 | return; | ||
109 | } | ||
110 | |||
111 | if (be64_to_cpu(mc->magic) != MEMCONS_MAGIC) { | ||
112 | pr_warn("OPAL: memory console version is invalid\n"); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | opal_msglog_attr.private = mc; | ||
117 | |||
118 | if (sysfs_create_bin_file(opal_kobj, &opal_msglog_attr) != 0) | ||
119 | pr_warn("OPAL: sysfs file creation failed\n"); | ||
120 | } | ||
diff --git a/arch/powerpc/platforms/powernv/opal-sensor.c b/arch/powerpc/platforms/powernv/opal-sensor.c index 663cc9c65613..10271ad1fac4 100644 --- a/arch/powerpc/platforms/powernv/opal-sensor.c +++ b/arch/powerpc/platforms/powernv/opal-sensor.c | |||
@@ -33,6 +33,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) | |||
33 | { | 33 | { |
34 | int ret, token; | 34 | int ret, token; |
35 | struct opal_msg msg; | 35 | struct opal_msg msg; |
36 | __be32 data; | ||
36 | 37 | ||
37 | token = opal_async_get_token_interruptible(); | 38 | token = opal_async_get_token_interruptible(); |
38 | if (token < 0) { | 39 | if (token < 0) { |
@@ -42,7 +43,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) | |||
42 | } | 43 | } |
43 | 44 | ||
44 | mutex_lock(&opal_sensor_mutex); | 45 | mutex_lock(&opal_sensor_mutex); |
45 | ret = opal_sensor_read(sensor_hndl, token, sensor_data); | 46 | ret = opal_sensor_read(sensor_hndl, token, &data); |
46 | if (ret != OPAL_ASYNC_COMPLETION) | 47 | if (ret != OPAL_ASYNC_COMPLETION) |
47 | goto out_token; | 48 | goto out_token; |
48 | 49 | ||
@@ -53,7 +54,8 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) | |||
53 | goto out_token; | 54 | goto out_token; |
54 | } | 55 | } |
55 | 56 | ||
56 | ret = msg.params[1]; | 57 | *sensor_data = be32_to_cpu(data); |
58 | ret = be64_to_cpu(msg.params[1]); | ||
57 | 59 | ||
58 | out_token: | 60 | out_token: |
59 | mutex_unlock(&opal_sensor_mutex); | 61 | mutex_unlock(&opal_sensor_mutex); |
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c index 0bd249a26f30..6b614726baf2 100644 --- a/arch/powerpc/platforms/powernv/opal-sysparam.c +++ b/arch/powerpc/platforms/powernv/opal-sysparam.c | |||
@@ -64,7 +64,7 @@ static int opal_get_sys_param(u32 param_id, u32 length, void *buffer) | |||
64 | goto out_token; | 64 | goto out_token; |
65 | } | 65 | } |
66 | 66 | ||
67 | ret = msg.params[1]; | 67 | ret = be64_to_cpu(msg.params[1]); |
68 | 68 | ||
69 | out_token: | 69 | out_token: |
70 | opal_async_release_token(token); | 70 | opal_async_release_token(token); |
@@ -98,7 +98,7 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer) | |||
98 | goto out_token; | 98 | goto out_token; |
99 | } | 99 | } |
100 | 100 | ||
101 | ret = msg.params[1]; | 101 | ret = be64_to_cpu(msg.params[1]); |
102 | 102 | ||
103 | out_token: | 103 | out_token: |
104 | opal_async_release_token(token); | 104 | opal_async_release_token(token); |
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S index bb90f9a4e027..f531ffe35b3e 100644 --- a/arch/powerpc/platforms/powernv/opal-wrappers.S +++ b/arch/powerpc/platforms/powernv/opal-wrappers.S | |||
@@ -61,6 +61,7 @@ _STATIC(opal_return) | |||
61 | mtcr r4; | 61 | mtcr r4; |
62 | rfid | 62 | rfid |
63 | 63 | ||
64 | OPAL_CALL(opal_invalid_call, OPAL_INVALID_CALL); | ||
64 | OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE); | 65 | OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE); |
65 | OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ); | 66 | OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ); |
66 | OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE); | 67 | OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE); |
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index e92f2f67640f..49d2f00019e5 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c | |||
@@ -46,7 +46,7 @@ struct mcheck_recoverable_range { | |||
46 | static struct mcheck_recoverable_range *mc_recoverable_range; | 46 | static struct mcheck_recoverable_range *mc_recoverable_range; |
47 | static int mc_recoverable_range_len; | 47 | static int mc_recoverable_range_len; |
48 | 48 | ||
49 | static struct device_node *opal_node; | 49 | struct device_node *opal_node; |
50 | static DEFINE_SPINLOCK(opal_write_lock); | 50 | static DEFINE_SPINLOCK(opal_write_lock); |
51 | extern u64 opal_mc_secondary_handler[]; | 51 | extern u64 opal_mc_secondary_handler[]; |
52 | static unsigned int *opal_irqs; | 52 | static unsigned int *opal_irqs; |
@@ -102,13 +102,13 @@ int __init early_init_dt_scan_opal(unsigned long node, | |||
102 | int __init early_init_dt_scan_recoverable_ranges(unsigned long node, | 102 | int __init early_init_dt_scan_recoverable_ranges(unsigned long node, |
103 | const char *uname, int depth, void *data) | 103 | const char *uname, int depth, void *data) |
104 | { | 104 | { |
105 | unsigned long i, size; | 105 | unsigned long i, psize, size; |
106 | const __be32 *prop; | 106 | const __be32 *prop; |
107 | 107 | ||
108 | if (depth != 1 || strcmp(uname, "ibm,opal") != 0) | 108 | if (depth != 1 || strcmp(uname, "ibm,opal") != 0) |
109 | return 0; | 109 | return 0; |
110 | 110 | ||
111 | prop = of_get_flat_dt_prop(node, "mcheck-recoverable-ranges", &size); | 111 | prop = of_get_flat_dt_prop(node, "mcheck-recoverable-ranges", &psize); |
112 | 112 | ||
113 | if (!prop) | 113 | if (!prop) |
114 | return 1; | 114 | return 1; |
@@ -116,6 +116,23 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node, | |||
116 | pr_debug("Found machine check recoverable ranges.\n"); | 116 | pr_debug("Found machine check recoverable ranges.\n"); |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Calculate number of available entries. | ||
120 | * | ||
121 | * Each recoverable address range entry is (start address, len, | ||
122 | * recovery address), 2 cells each for start and recovery address, | ||
123 | * 1 cell for len, totalling 5 cells per entry. | ||
124 | */ | ||
125 | mc_recoverable_range_len = psize / (sizeof(*prop) * 5); | ||
126 | |||
127 | /* Sanity check */ | ||
128 | if (!mc_recoverable_range_len) | ||
129 | return 1; | ||
130 | |||
131 | /* Size required to hold all the entries. */ | ||
132 | size = mc_recoverable_range_len * | ||
133 | sizeof(struct mcheck_recoverable_range); | ||
134 | |||
135 | /* | ||
119 | * Allocate a buffer to hold the MC recoverable ranges. We would be | 136 | * Allocate a buffer to hold the MC recoverable ranges. We would be |
120 | * accessing them in real mode, hence it needs to be within | 137 | * accessing them in real mode, hence it needs to be within |
121 | * RMO region. | 138 | * RMO region. |
@@ -124,11 +141,7 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node, | |||
124 | ppc64_rma_size)); | 141 | ppc64_rma_size)); |
125 | memset(mc_recoverable_range, 0, size); | 142 | memset(mc_recoverable_range, 0, size); |
126 | 143 | ||
127 | /* | 144 | for (i = 0; i < mc_recoverable_range_len; i++) { |
128 | * Each recoverable address entry is an (start address,len, | ||
129 | * recover address) pair, * 2 cells each, totalling 4 cells per entry. | ||
130 | */ | ||
131 | for (i = 0; i < size / (sizeof(*prop) * 5); i++) { | ||
132 | mc_recoverable_range[i].start_addr = | 145 | mc_recoverable_range[i].start_addr = |
133 | of_read_number(prop + (i * 5) + 0, 2); | 146 | of_read_number(prop + (i * 5) + 0, 2); |
134 | mc_recoverable_range[i].end_addr = | 147 | mc_recoverable_range[i].end_addr = |
@@ -142,7 +155,6 @@ int __init early_init_dt_scan_recoverable_ranges(unsigned long node, | |||
142 | mc_recoverable_range[i].end_addr, | 155 | mc_recoverable_range[i].end_addr, |
143 | mc_recoverable_range[i].recover_addr); | 156 | mc_recoverable_range[i].recover_addr); |
144 | } | 157 | } |
145 | mc_recoverable_range_len = i; | ||
146 | return 1; | 158 | return 1; |
147 | } | 159 | } |
148 | 160 | ||
@@ -180,6 +192,20 @@ int opal_notifier_register(struct notifier_block *nb) | |||
180 | atomic_notifier_chain_register(&opal_notifier_head, nb); | 192 | atomic_notifier_chain_register(&opal_notifier_head, nb); |
181 | return 0; | 193 | return 0; |
182 | } | 194 | } |
195 | EXPORT_SYMBOL_GPL(opal_notifier_register); | ||
196 | |||
197 | int opal_notifier_unregister(struct notifier_block *nb) | ||
198 | { | ||
199 | if (!nb) { | ||
200 | pr_warning("%s: Invalid argument (%p)\n", | ||
201 | __func__, nb); | ||
202 | return -EINVAL; | ||
203 | } | ||
204 | |||
205 | atomic_notifier_chain_unregister(&opal_notifier_head, nb); | ||
206 | return 0; | ||
207 | } | ||
208 | EXPORT_SYMBOL_GPL(opal_notifier_unregister); | ||
183 | 209 | ||
184 | static void opal_do_notifier(uint64_t events) | 210 | static void opal_do_notifier(uint64_t events) |
185 | { | 211 | { |
@@ -267,6 +293,7 @@ static void opal_handle_message(void) | |||
267 | * value in /proc/device-tree. | 293 | * value in /proc/device-tree. |
268 | */ | 294 | */ |
269 | static struct opal_msg msg; | 295 | static struct opal_msg msg; |
296 | u32 type; | ||
270 | 297 | ||
271 | ret = opal_get_msg(__pa(&msg), sizeof(msg)); | 298 | ret = opal_get_msg(__pa(&msg), sizeof(msg)); |
272 | /* No opal message pending. */ | 299 | /* No opal message pending. */ |
@@ -280,13 +307,14 @@ static void opal_handle_message(void) | |||
280 | return; | 307 | return; |
281 | } | 308 | } |
282 | 309 | ||
310 | type = be32_to_cpu(msg.msg_type); | ||
311 | |||
283 | /* Sanity check */ | 312 | /* Sanity check */ |
284 | if (msg.msg_type > OPAL_MSG_TYPE_MAX) { | 313 | if (type > OPAL_MSG_TYPE_MAX) { |
285 | pr_warning("%s: Unknown message type: %u\n", | 314 | pr_warning("%s: Unknown message type: %u\n", __func__, type); |
286 | __func__, msg.msg_type); | ||
287 | return; | 315 | return; |
288 | } | 316 | } |
289 | opal_message_do_notify(msg.msg_type, (void *)&msg); | 317 | opal_message_do_notify(type, (void *)&msg); |
290 | } | 318 | } |
291 | 319 | ||
292 | static int opal_message_notify(struct notifier_block *nb, | 320 | static int opal_message_notify(struct notifier_block *nb, |
@@ -574,6 +602,8 @@ static int __init opal_init(void) | |||
574 | opal_platform_dump_init(); | 602 | opal_platform_dump_init(); |
575 | /* Setup system parameters interface */ | 603 | /* Setup system parameters interface */ |
576 | opal_sys_param_init(); | 604 | opal_sys_param_init(); |
605 | /* Setup message log interface. */ | ||
606 | opal_msglog_init(); | ||
577 | } | 607 | } |
578 | 608 | ||
579 | return 0; | 609 | return 0; |
@@ -605,3 +635,6 @@ void opal_shutdown(void) | |||
605 | mdelay(10); | 635 | mdelay(10); |
606 | } | 636 | } |
607 | } | 637 | } |
638 | |||
639 | /* Export this so that test modules can use it */ | ||
640 | EXPORT_SYMBOL_GPL(opal_invalid_call); | ||
diff --git a/arch/powerpc/platforms/pseries/io_event_irq.c b/arch/powerpc/platforms/pseries/io_event_irq.c index 5ea88d1541f7..0240c4ff878a 100644 --- a/arch/powerpc/platforms/pseries/io_event_irq.c +++ b/arch/powerpc/platforms/pseries/io_event_irq.c | |||
@@ -82,9 +82,9 @@ static struct pseries_io_event * ioei_find_event(struct rtas_error_log *elog) | |||
82 | * RTAS_TYPE_IO only exists in extended event log version 6 or later. | 82 | * RTAS_TYPE_IO only exists in extended event log version 6 or later. |
83 | * No need to check event log version. | 83 | * No need to check event log version. |
84 | */ | 84 | */ |
85 | if (unlikely(elog->type != RTAS_TYPE_IO)) { | 85 | if (unlikely(rtas_error_type(elog) != RTAS_TYPE_IO)) { |
86 | printk_once(KERN_WARNING "io_event_irq: Unexpected event type %d", | 86 | printk_once(KERN_WARNING"io_event_irq: Unexpected event type %d", |
87 | elog->type); | 87 | rtas_error_type(elog)); |
88 | return NULL; | 88 | return NULL; |
89 | } | 89 | } |
90 | 90 | ||
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c index d7096f2f7751..0cc240b7f694 100644 --- a/arch/powerpc/platforms/pseries/nvram.c +++ b/arch/powerpc/platforms/pseries/nvram.c | |||
@@ -298,13 +298,13 @@ int nvram_write_os_partition(struct nvram_os_partition *part, char * buff, | |||
298 | 298 | ||
299 | rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), &tmp_index); | 299 | rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), &tmp_index); |
300 | if (rc <= 0) { | 300 | if (rc <= 0) { |
301 | pr_err("%s: Failed nvram_write (%d)\n", __FUNCTION__, rc); | 301 | pr_err("%s: Failed nvram_write (%d)\n", __func__, rc); |
302 | return rc; | 302 | return rc; |
303 | } | 303 | } |
304 | 304 | ||
305 | rc = ppc_md.nvram_write(buff, length, &tmp_index); | 305 | rc = ppc_md.nvram_write(buff, length, &tmp_index); |
306 | if (rc <= 0) { | 306 | if (rc <= 0) { |
307 | pr_err("%s: Failed nvram_write (%d)\n", __FUNCTION__, rc); | 307 | pr_err("%s: Failed nvram_write (%d)\n", __func__, rc); |
308 | return rc; | 308 | return rc; |
309 | } | 309 | } |
310 | 310 | ||
@@ -351,15 +351,14 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff, | |||
351 | sizeof(struct err_log_info), | 351 | sizeof(struct err_log_info), |
352 | &tmp_index); | 352 | &tmp_index); |
353 | if (rc <= 0) { | 353 | if (rc <= 0) { |
354 | pr_err("%s: Failed nvram_read (%d)\n", __FUNCTION__, | 354 | pr_err("%s: Failed nvram_read (%d)\n", __func__, rc); |
355 | rc); | ||
356 | return rc; | 355 | return rc; |
357 | } | 356 | } |
358 | } | 357 | } |
359 | 358 | ||
360 | rc = ppc_md.nvram_read(buff, length, &tmp_index); | 359 | rc = ppc_md.nvram_read(buff, length, &tmp_index); |
361 | if (rc <= 0) { | 360 | if (rc <= 0) { |
362 | pr_err("%s: Failed nvram_read (%d)\n", __FUNCTION__, rc); | 361 | pr_err("%s: Failed nvram_read (%d)\n", __func__, rc); |
363 | return rc; | 362 | return rc; |
364 | } | 363 | } |
365 | 364 | ||
@@ -869,7 +868,7 @@ static void oops_to_nvram(struct kmsg_dumper *dumper, | |||
869 | break; | 868 | break; |
870 | default: | 869 | default: |
871 | pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n", | 870 | pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n", |
872 | __FUNCTION__, (int) reason); | 871 | __func__, (int) reason); |
873 | return; | 872 | return; |
874 | } | 873 | } |
875 | 874 | ||
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index 721c0586b284..9c5778e6ed4b 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c | |||
@@ -236,7 +236,8 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id) | |||
236 | 236 | ||
237 | rtas_elog = (struct rtas_error_log *)ras_log_buf; | 237 | rtas_elog = (struct rtas_error_log *)ras_log_buf; |
238 | 238 | ||
239 | if ((status == 0) && (rtas_elog->severity >= RTAS_SEVERITY_ERROR_SYNC)) | 239 | if (status == 0 && |
240 | rtas_error_severity(rtas_elog) >= RTAS_SEVERITY_ERROR_SYNC) | ||
240 | fatal = 1; | 241 | fatal = 1; |
241 | else | 242 | else |
242 | fatal = 0; | 243 | fatal = 0; |
@@ -300,13 +301,14 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) | |||
300 | 301 | ||
301 | /* If it isn't an extended log we can use the per cpu 64bit buffer */ | 302 | /* If it isn't an extended log we can use the per cpu 64bit buffer */ |
302 | h = (struct rtas_error_log *)&savep[1]; | 303 | h = (struct rtas_error_log *)&savep[1]; |
303 | if (!h->extended) { | 304 | if (!rtas_error_extended(h)) { |
304 | memcpy(&__get_cpu_var(mce_data_buf), h, sizeof(__u64)); | 305 | memcpy(&__get_cpu_var(mce_data_buf), h, sizeof(__u64)); |
305 | errhdr = (struct rtas_error_log *)&__get_cpu_var(mce_data_buf); | 306 | errhdr = (struct rtas_error_log *)&__get_cpu_var(mce_data_buf); |
306 | } else { | 307 | } else { |
307 | int len; | 308 | int len, error_log_length; |
308 | 309 | ||
309 | len = max_t(int, 8+h->extended_log_length, RTAS_ERROR_LOG_MAX); | 310 | error_log_length = 8 + rtas_error_extended_log_length(h); |
311 | len = max_t(int, error_log_length, RTAS_ERROR_LOG_MAX); | ||
310 | memset(global_mce_data_buf, 0, RTAS_ERROR_LOG_MAX); | 312 | memset(global_mce_data_buf, 0, RTAS_ERROR_LOG_MAX); |
311 | memcpy(global_mce_data_buf, h, len); | 313 | memcpy(global_mce_data_buf, h, len); |
312 | errhdr = (struct rtas_error_log *)global_mce_data_buf; | 314 | errhdr = (struct rtas_error_log *)global_mce_data_buf; |
@@ -350,23 +352,24 @@ int pSeries_system_reset_exception(struct pt_regs *regs) | |||
350 | static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err) | 352 | static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err) |
351 | { | 353 | { |
352 | int recovered = 0; | 354 | int recovered = 0; |
355 | int disposition = rtas_error_disposition(err); | ||
353 | 356 | ||
354 | if (!(regs->msr & MSR_RI)) { | 357 | if (!(regs->msr & MSR_RI)) { |
355 | /* If MSR_RI isn't set, we cannot recover */ | 358 | /* If MSR_RI isn't set, we cannot recover */ |
356 | recovered = 0; | 359 | recovered = 0; |
357 | 360 | ||
358 | } else if (err->disposition == RTAS_DISP_FULLY_RECOVERED) { | 361 | } else if (disposition == RTAS_DISP_FULLY_RECOVERED) { |
359 | /* Platform corrected itself */ | 362 | /* Platform corrected itself */ |
360 | recovered = 1; | 363 | recovered = 1; |
361 | 364 | ||
362 | } else if (err->disposition == RTAS_DISP_LIMITED_RECOVERY) { | 365 | } else if (disposition == RTAS_DISP_LIMITED_RECOVERY) { |
363 | /* Platform corrected itself but could be degraded */ | 366 | /* Platform corrected itself but could be degraded */ |
364 | printk(KERN_ERR "MCE: limited recovery, system may " | 367 | printk(KERN_ERR "MCE: limited recovery, system may " |
365 | "be degraded\n"); | 368 | "be degraded\n"); |
366 | recovered = 1; | 369 | recovered = 1; |
367 | 370 | ||
368 | } else if (user_mode(regs) && !is_global_init(current) && | 371 | } else if (user_mode(regs) && !is_global_init(current) && |
369 | err->severity == RTAS_SEVERITY_ERROR_SYNC) { | 372 | rtas_error_severity(err) == RTAS_SEVERITY_ERROR_SYNC) { |
370 | 373 | ||
371 | /* | 374 | /* |
372 | * If we received a synchronous error when in userspace | 375 | * If we received a synchronous error when in userspace |
diff --git a/arch/powerpc/sysdev/msi_bitmap.c b/arch/powerpc/sysdev/msi_bitmap.c index 8ba60424be95..2ff630267e9e 100644 --- a/arch/powerpc/sysdev/msi_bitmap.c +++ b/arch/powerpc/sysdev/msi_bitmap.c | |||
@@ -202,7 +202,7 @@ void __init test_of_node(void) | |||
202 | 202 | ||
203 | /* There should really be a struct device_node allocator */ | 203 | /* There should really be a struct device_node allocator */ |
204 | memset(&of_node, 0, sizeof(of_node)); | 204 | memset(&of_node, 0, sizeof(of_node)); |
205 | kref_init(&of_node.kobj.kref); | 205 | of_node_init(&of_node); |
206 | of_node.full_name = node_name; | 206 | of_node.full_name = node_name; |
207 | 207 | ||
208 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); | 208 | check(0 == msi_bitmap_alloc(&bmp, size, &of_node)); |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index b13172cfbeef..bc196f49ec53 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -554,14 +554,6 @@ config SENSORS_IBMPEX | |||
554 | This driver can also be built as a module. If so, the module | 554 | This driver can also be built as a module. If so, the module |
555 | will be called ibmpex. | 555 | will be called ibmpex. |
556 | 556 | ||
557 | config SENSORS_IBMPOWERNV | ||
558 | tristate "IBM PowerNv Platform temperature/power/fan sensor" | ||
559 | depends on PPC_POWERNV | ||
560 | default y | ||
561 | help | ||
562 | If you say yes here you get support for the temperature/fan/power | ||
563 | sensors on your platform. | ||
564 | |||
565 | config SENSORS_IIO_HWMON | 557 | config SENSORS_IIO_HWMON |
566 | tristate "Hwmon driver that uses channels specified via iio maps" | 558 | tristate "Hwmon driver that uses channels specified via iio maps" |
567 | depends on IIO | 559 | depends on IIO |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 199c401bf8d9..c48f9873ac73 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -71,7 +71,6 @@ obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o | |||
71 | obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o | 71 | obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o |
72 | obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o | 72 | obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o |
73 | obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o | 73 | obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o |
74 | obj-$(CONFIG_SENSORS_IBMPOWERNV)+= ibmpowernv.o | ||
75 | obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o | 74 | obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o |
76 | obj-$(CONFIG_SENSORS_INA209) += ina209.o | 75 | obj-$(CONFIG_SENSORS_INA209) += ina209.o |
77 | obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o | 76 | obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o |
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c deleted file mode 100644 index b7b1297a9b02..000000000000 --- a/drivers/hwmon/ibmpowernv.c +++ /dev/null | |||
@@ -1,529 +0,0 @@ | |||
1 | /* | ||
2 | * hwmon driver for temperature/power/fan on IBM PowerNV platform | ||
3 | * Copyright (C) 2013 IBM | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/init.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/hwmon.h> | ||
24 | #include <linux/hwmon-sysfs.h> | ||
25 | #include <linux/of.h> | ||
26 | #include <linux/slab.h> | ||
27 | |||
28 | #include <linux/jiffies.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | #include <asm/opal.h> | ||
31 | #include <linux/err.h> | ||
32 | |||
33 | MODULE_DESCRIPTION("IBM PowerNV Platform power/temp/fan sensor hwmon module"); | ||
34 | MODULE_LICENSE("GPL"); | ||
35 | |||
36 | #define MAX_ATTR_LENGTH 32 | ||
37 | |||
38 | /* Device tree sensor name prefixes. The device tree has the names in the | ||
39 | * format "cooling-fan#2-faulted" where the "cooling-fan" is the sensor type, | ||
40 | * 2 is the sensor count, and "faulted" is the sensor data attribute type. | ||
41 | */ | ||
42 | #define DT_FAULT_ATTR_SUFFIX "faulted" | ||
43 | #define DT_DATA_ATTR_SUFFIX "data" | ||
44 | #define DT_THRESHOLD_ATTR_SUFFIX "thrs" | ||
45 | |||
46 | enum sensors { | ||
47 | FAN, | ||
48 | TEMPERATURE, | ||
49 | POWERSUPPLY, | ||
50 | POWER, | ||
51 | MAX_SENSOR_TYPE, | ||
52 | }; | ||
53 | |||
54 | enum attributes { | ||
55 | INPUT, | ||
56 | MINIMUM, | ||
57 | MAXIMUM, | ||
58 | FAULT, | ||
59 | MAX_ATTR_TYPES | ||
60 | }; | ||
61 | |||
62 | static struct sensor_name { | ||
63 | char *name; | ||
64 | char *compaible; | ||
65 | } sensor_names[] = { | ||
66 | {"fan-sensor", "ibm,opal-sensor-cooling-fan"}, | ||
67 | {"amb-temp-sensor", "ibm,opal-sensor-amb-temp"}, | ||
68 | {"power-sensor", "ibm,opal-sensor-power-supply"}, | ||
69 | {"power", "ibm,opal-sensor-power"} | ||
70 | }; | ||
71 | |||
72 | static const char * const attribute_type_table[] = { | ||
73 | "input", | ||
74 | "min", | ||
75 | "max", | ||
76 | "fault", | ||
77 | NULL | ||
78 | }; | ||
79 | |||
80 | struct pdev_entry { | ||
81 | struct list_head list; | ||
82 | struct platform_device *pdev; | ||
83 | enum sensors type; | ||
84 | }; | ||
85 | |||
86 | static LIST_HEAD(pdev_list); | ||
87 | |||
88 | /* The sensors are categorised on type. | ||
89 | * | ||
90 | * The sensors of same type are categorised under a common platform device. | ||
91 | * So, The pdev is shared by all sensors of same type. | ||
92 | * Ex : temp1_input, temp1_max, temp2_input,temp2_max all share same platform | ||
93 | * device. | ||
94 | * | ||
95 | * "sensor_data" is the Platform device specific data. | ||
96 | * There is one hwmon_device instance for all the sensors of same type. | ||
97 | * This also holds the list of all sensors with same type but different | ||
98 | * attribute and index. | ||
99 | */ | ||
100 | struct sensor_specific_data { | ||
101 | u32 sensor_id; /* The hex value as in the device tree */ | ||
102 | u32 sensor_index; /* The sensor instance index */ | ||
103 | struct sensor_device_attribute sd_attr; | ||
104 | enum attributes attr_type; | ||
105 | char attr_name[64]; | ||
106 | }; | ||
107 | |||
108 | struct sensor_data { | ||
109 | struct device *hwmon_dev; | ||
110 | struct list_head sensor_list; | ||
111 | struct device_attribute name_attr; | ||
112 | }; | ||
113 | |||
114 | struct sensor_entry { | ||
115 | struct list_head list; | ||
116 | struct sensor_specific_data *sensor_data; | ||
117 | }; | ||
118 | |||
119 | static struct platform_device *powernv_sensor_get_pdev(enum sensors type) | ||
120 | { | ||
121 | struct pdev_entry *p; | ||
122 | list_for_each_entry(p, &pdev_list, list) | ||
123 | if (p->type == type) | ||
124 | return p->pdev; | ||
125 | |||
126 | return NULL; | ||
127 | } | ||
128 | |||
129 | static struct sensor_specific_data *powernv_sensor_get_sensor_data( | ||
130 | struct sensor_data *pdata, | ||
131 | int index, enum attributes attr_type) | ||
132 | { | ||
133 | struct sensor_entry *p; | ||
134 | list_for_each_entry(p, &pdata->sensor_list, list) | ||
135 | if ((p->sensor_data->sensor_index == index) && | ||
136 | (attr_type == p->sensor_data->attr_type)) | ||
137 | return p->sensor_data; | ||
138 | |||
139 | return NULL; | ||
140 | } | ||
141 | |||
142 | static ssize_t show_name(struct device *dev, | ||
143 | struct device_attribute *devattr, char *buf) | ||
144 | { | ||
145 | struct platform_device *pdev = to_platform_device(dev); | ||
146 | |||
147 | return sprintf(buf, "%s\n", pdev->name); | ||
148 | } | ||
149 | |||
150 | /* Note: Data from the sensors for each sensor type needs to be converted to | ||
151 | * the dimension appropriate. | ||
152 | */ | ||
153 | static ssize_t show_sensor(struct device *dev, | ||
154 | struct device_attribute *devattr, char *buf) | ||
155 | { | ||
156 | struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(devattr); | ||
157 | struct platform_device *pdev = to_platform_device(dev); | ||
158 | struct sensor_data *pdata = platform_get_drvdata(pdev); | ||
159 | struct sensor_specific_data *tdata = NULL; | ||
160 | enum sensors sensor_type = pdev->id; | ||
161 | u32 x = -1; | ||
162 | int ret; | ||
163 | |||
164 | if (sd_attr && sd_attr->dev_attr.attr.name) { | ||
165 | char *pos = strchr(sd_attr->dev_attr.attr.name, '_'); | ||
166 | int i; | ||
167 | |||
168 | for (i = 0; i < MAX_ATTR_TYPES; i++) { | ||
169 | if (strcmp(pos+1, attribute_type_table[i]) == 0) { | ||
170 | tdata = powernv_sensor_get_sensor_data(pdata, | ||
171 | sd_attr->index, i); | ||
172 | break; | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | |||
177 | if (tdata) { | ||
178 | ret = opal_get_sensor_data(tdata->sensor_id, &x); | ||
179 | if (ret) | ||
180 | x = -1; | ||
181 | } | ||
182 | |||
183 | if (sensor_type == TEMPERATURE && x > 0) { | ||
184 | /* Temperature comes in Degrees and convert it to | ||
185 | * milli-degrees. | ||
186 | */ | ||
187 | x = x*1000; | ||
188 | } else if (sensor_type == POWER && x > 0) { | ||
189 | /* Power value comes in watts, convert to micro-watts */ | ||
190 | x = x * 1000000; | ||
191 | } | ||
192 | |||
193 | return sprintf(buf, "%d\n", x); | ||
194 | } | ||
195 | |||
196 | static u32 get_sensor_index_from_name(const char *name) | ||
197 | { | ||
198 | char *hash_position = strchr(name, '#'); | ||
199 | u32 index = 0, copy_length; | ||
200 | char newbuf[8]; | ||
201 | |||
202 | if (hash_position) { | ||
203 | copy_length = strchr(hash_position, '-') - hash_position - 1; | ||
204 | if (copy_length < sizeof(newbuf)) { | ||
205 | strncpy(newbuf, hash_position + 1, copy_length); | ||
206 | sscanf(newbuf, "%d", &index); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | return index; | ||
211 | } | ||
212 | |||
213 | static inline void get_sensor_suffix_from_name(const char *name, char *suffix) | ||
214 | { | ||
215 | char *dash_position = strrchr(name, '-'); | ||
216 | if (dash_position) | ||
217 | strncpy(suffix, dash_position+1, MAX_ATTR_LENGTH); | ||
218 | else | ||
219 | strcpy(suffix,""); | ||
220 | } | ||
221 | |||
222 | static int get_sensor_attr_properties(const char *sensor_name, | ||
223 | enum sensors sensor_type, enum attributes *attr_type, | ||
224 | u32 *sensor_index) | ||
225 | { | ||
226 | char suffix[MAX_ATTR_LENGTH]; | ||
227 | |||
228 | *attr_type = MAX_ATTR_TYPES; | ||
229 | *sensor_index = get_sensor_index_from_name(sensor_name); | ||
230 | if (*sensor_index == 0) | ||
231 | return -EINVAL; | ||
232 | |||
233 | get_sensor_suffix_from_name(sensor_name, suffix); | ||
234 | if (strcmp(suffix, "") == 0) | ||
235 | return -EINVAL; | ||
236 | |||
237 | if (strcmp(suffix, DT_FAULT_ATTR_SUFFIX) == 0) | ||
238 | *attr_type = FAULT; | ||
239 | else if (strcmp(suffix, DT_DATA_ATTR_SUFFIX) == 0) | ||
240 | *attr_type = INPUT; | ||
241 | else if ((sensor_type == TEMPERATURE) && | ||
242 | (strcmp(suffix, DT_THRESHOLD_ATTR_SUFFIX) == 0)) | ||
243 | *attr_type = MAXIMUM; | ||
244 | else if ((sensor_type == FAN) && | ||
245 | (strcmp(suffix, DT_THRESHOLD_ATTR_SUFFIX) == 0)) | ||
246 | *attr_type = MINIMUM; | ||
247 | else | ||
248 | return -ENOENT; | ||
249 | |||
250 | if (((sensor_type == FAN) && ((*attr_type == INPUT) || | ||
251 | (*attr_type == MINIMUM))) | ||
252 | || ((sensor_type == TEMPERATURE) && ((*attr_type == INPUT) || | ||
253 | (*attr_type == MAXIMUM))) | ||
254 | || ((sensor_type == POWER) && ((*attr_type == INPUT)))) | ||
255 | return 0; | ||
256 | |||
257 | return -ENOENT; | ||
258 | } | ||
259 | |||
260 | static int create_sensor_attr(struct sensor_specific_data *tdata, | ||
261 | struct device *dev, enum sensors sensor_type, | ||
262 | enum attributes attr_type) | ||
263 | { | ||
264 | int err = 0; | ||
265 | char temp_file_prefix[50]; | ||
266 | static const char *const file_name_format = "%s%d_%s"; | ||
267 | |||
268 | tdata->attr_type = attr_type; | ||
269 | |||
270 | if (sensor_type == FAN) | ||
271 | strcpy(temp_file_prefix, "fan"); | ||
272 | else if (sensor_type == TEMPERATURE) | ||
273 | strcpy(temp_file_prefix, "temp"); | ||
274 | else if (sensor_type == POWERSUPPLY) | ||
275 | strcpy(temp_file_prefix, "powersupply"); | ||
276 | else if (sensor_type == POWER) | ||
277 | strcpy(temp_file_prefix, "power"); | ||
278 | |||
279 | snprintf(tdata->attr_name, sizeof(tdata->attr_name), file_name_format, | ||
280 | temp_file_prefix, tdata->sensor_index, | ||
281 | attribute_type_table[tdata->attr_type]); | ||
282 | |||
283 | sysfs_attr_init(&tdata->sd_attr.dev_attr.attr); | ||
284 | tdata->sd_attr.dev_attr.attr.name = tdata->attr_name; | ||
285 | tdata->sd_attr.dev_attr.attr.mode = S_IRUGO; | ||
286 | tdata->sd_attr.dev_attr.show = show_sensor; | ||
287 | |||
288 | tdata->sd_attr.index = tdata->sensor_index; | ||
289 | err = device_create_file(dev, &tdata->sd_attr.dev_attr); | ||
290 | |||
291 | return err; | ||
292 | } | ||
293 | |||
294 | static int create_name_attr(struct sensor_data *pdata, | ||
295 | struct device *dev) | ||
296 | { | ||
297 | sysfs_attr_init(&pdata->name_attr.attr); | ||
298 | pdata->name_attr.attr.name = "name"; | ||
299 | pdata->name_attr.attr.mode = S_IRUGO; | ||
300 | pdata->name_attr.show = show_name; | ||
301 | return device_create_file(dev, &pdata->name_attr); | ||
302 | } | ||
303 | |||
304 | static int create_platform_device(enum sensors sensor_type, | ||
305 | struct platform_device **pdev) | ||
306 | { | ||
307 | struct pdev_entry *pdev_entry = NULL; | ||
308 | int err; | ||
309 | |||
310 | *pdev = platform_device_alloc(sensor_names[sensor_type].name, | ||
311 | sensor_type); | ||
312 | if (!*pdev) { | ||
313 | pr_err("Device allocation failed\n"); | ||
314 | err = -ENOMEM; | ||
315 | goto exit; | ||
316 | } | ||
317 | |||
318 | pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL); | ||
319 | if (!pdev_entry) { | ||
320 | pr_err("Device allocation failed\n"); | ||
321 | err = -ENOMEM; | ||
322 | goto exit_device_put; | ||
323 | } | ||
324 | |||
325 | err = platform_device_add(*pdev); | ||
326 | if (err) { | ||
327 | pr_err("Device addition failed (%d)\n", err); | ||
328 | goto exit_device_free; | ||
329 | } | ||
330 | |||
331 | pdev_entry->pdev = *pdev; | ||
332 | pdev_entry->type = (*pdev)->id; | ||
333 | |||
334 | list_add_tail(&pdev_entry->list, &pdev_list); | ||
335 | |||
336 | return 0; | ||
337 | exit_device_free: | ||
338 | kfree(pdev_entry); | ||
339 | exit_device_put: | ||
340 | platform_device_put(*pdev); | ||
341 | exit: | ||
342 | return err; | ||
343 | } | ||
344 | |||
345 | static int create_sensor_data(struct platform_device *pdev) | ||
346 | { | ||
347 | struct sensor_data *pdata = NULL; | ||
348 | int err = 0; | ||
349 | |||
350 | pdata = kzalloc(sizeof(struct sensor_data), GFP_KERNEL); | ||
351 | if (!pdata) { | ||
352 | err = -ENOMEM; | ||
353 | goto exit; | ||
354 | } | ||
355 | |||
356 | err = create_name_attr(pdata, &pdev->dev); | ||
357 | if (err) | ||
358 | goto exit_free; | ||
359 | |||
360 | pdata->hwmon_dev = hwmon_device_register(&pdev->dev); | ||
361 | if (IS_ERR(pdata->hwmon_dev)) { | ||
362 | err = PTR_ERR(pdata->hwmon_dev); | ||
363 | dev_err(&pdev->dev, "Class registration failed (%d)\n", | ||
364 | err); | ||
365 | goto exit_name; | ||
366 | } | ||
367 | |||
368 | INIT_LIST_HEAD(&pdata->sensor_list); | ||
369 | platform_set_drvdata(pdev, pdata); | ||
370 | |||
371 | return 0; | ||
372 | |||
373 | exit_name: | ||
374 | device_remove_file(&pdev->dev, &pdata->name_attr); | ||
375 | exit_free: | ||
376 | kfree(pdata); | ||
377 | exit: | ||
378 | return err; | ||
379 | } | ||
380 | |||
381 | static void delete_sensor_attr(struct sensor_data *pdata) | ||
382 | { | ||
383 | struct sensor_entry *s, *l; | ||
384 | |||
385 | list_for_each_entry_safe(s, l, &pdata->sensor_list, list) { | ||
386 | struct sensor_specific_data *tdata = s->sensor_data; | ||
387 | kfree(tdata); | ||
388 | list_del(&s->list); | ||
389 | kfree(s); | ||
390 | } | ||
391 | } | ||
392 | |||
393 | static int powernv_sensor_init(u32 sensor_id, const struct device_node *np, | ||
394 | enum sensors sensor_type, enum attributes attr_type, | ||
395 | u32 sensor_index) | ||
396 | { | ||
397 | struct platform_device *pdev = powernv_sensor_get_pdev(sensor_type); | ||
398 | struct sensor_specific_data *tdata; | ||
399 | struct sensor_entry *sensor_entry; | ||
400 | struct sensor_data *pdata; | ||
401 | int err = 0; | ||
402 | |||
403 | if (!pdev) { | ||
404 | err = create_platform_device(sensor_type, &pdev); | ||
405 | if (err) | ||
406 | goto exit; | ||
407 | |||
408 | err = create_sensor_data(pdev); | ||
409 | if (err) | ||
410 | goto exit; | ||
411 | } | ||
412 | |||
413 | pdata = platform_get_drvdata(pdev); | ||
414 | if (!pdata) { | ||
415 | err = -ENOMEM; | ||
416 | goto exit; | ||
417 | } | ||
418 | |||
419 | tdata = kzalloc(sizeof(struct sensor_specific_data), GFP_KERNEL); | ||
420 | if (!tdata) { | ||
421 | err = -ENOMEM; | ||
422 | goto exit; | ||
423 | } | ||
424 | |||
425 | tdata->sensor_id = sensor_id; | ||
426 | tdata->sensor_index = sensor_index; | ||
427 | |||
428 | err = create_sensor_attr(tdata, &pdev->dev, sensor_type, attr_type); | ||
429 | if (err) | ||
430 | goto exit_free; | ||
431 | |||
432 | sensor_entry = kzalloc(sizeof(struct sensor_entry), GFP_KERNEL); | ||
433 | if (!sensor_entry) { | ||
434 | err = -ENOMEM; | ||
435 | goto exit_attr; | ||
436 | } | ||
437 | |||
438 | sensor_entry->sensor_data = tdata; | ||
439 | |||
440 | list_add_tail(&sensor_entry->list, &pdata->sensor_list); | ||
441 | |||
442 | return 0; | ||
443 | exit_attr: | ||
444 | device_remove_file(&pdev->dev, &tdata->sd_attr.dev_attr); | ||
445 | exit_free: | ||
446 | kfree(tdata); | ||
447 | exit: | ||
448 | return err; | ||
449 | } | ||
450 | |||
451 | static void delete_unregister_sensors(void) | ||
452 | { | ||
453 | struct pdev_entry *p, *n; | ||
454 | |||
455 | list_for_each_entry_safe(p, n, &pdev_list, list) { | ||
456 | struct sensor_data *pdata = platform_get_drvdata(p->pdev); | ||
457 | if (pdata) { | ||
458 | delete_sensor_attr(pdata); | ||
459 | |||
460 | hwmon_device_unregister(pdata->hwmon_dev); | ||
461 | kfree(pdata); | ||
462 | } | ||
463 | platform_device_unregister(p->pdev); | ||
464 | list_del(&p->list); | ||
465 | kfree(p); | ||
466 | } | ||
467 | } | ||
468 | |||
469 | static int __init powernv_hwmon_init(void) | ||
470 | { | ||
471 | struct device_node *opal, *np = NULL; | ||
472 | enum attributes attr_type; | ||
473 | enum sensors type; | ||
474 | const u32 *sensor_id; | ||
475 | u32 sensor_index; | ||
476 | int err; | ||
477 | |||
478 | opal = of_find_node_by_path("/ibm,opal/sensors"); | ||
479 | if (!opal) { | ||
480 | pr_err("%s: Opal 'sensors' node not found\n", __func__); | ||
481 | return -ENXIO; | ||
482 | } | ||
483 | |||
484 | for_each_child_of_node(opal, np) { | ||
485 | if (np->name == NULL) | ||
486 | continue; | ||
487 | |||
488 | for (type = 0; type < MAX_SENSOR_TYPE; type++) | ||
489 | if (of_device_is_compatible(np, | ||
490 | sensor_names[type].compaible)) | ||
491 | break; | ||
492 | |||
493 | if (type == MAX_SENSOR_TYPE) | ||
494 | continue; | ||
495 | |||
496 | if (get_sensor_attr_properties(np->name, type, &attr_type, | ||
497 | &sensor_index)) | ||
498 | continue; | ||
499 | |||
500 | sensor_id = of_get_property(np, "sensor-id", NULL); | ||
501 | if (!sensor_id) { | ||
502 | pr_info("%s: %s doesn't have sensor-id\n", __func__, | ||
503 | np->name); | ||
504 | continue; | ||
505 | } | ||
506 | |||
507 | err = powernv_sensor_init(*sensor_id, np, type, attr_type, | ||
508 | sensor_index); | ||
509 | if (err) { | ||
510 | of_node_put(opal); | ||
511 | goto exit; | ||
512 | } | ||
513 | } | ||
514 | of_node_put(opal); | ||
515 | |||
516 | return 0; | ||
517 | exit: | ||
518 | delete_unregister_sensors(); | ||
519 | return err; | ||
520 | |||
521 | } | ||
522 | |||
523 | static void powernv_hwmon_exit(void) | ||
524 | { | ||
525 | delete_unregister_sensors(); | ||
526 | } | ||
527 | |||
528 | module_init(powernv_hwmon_init); | ||
529 | module_exit(powernv_hwmon_exit); | ||
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index b01659bd4f7c..a585079b4b38 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c | |||
@@ -61,6 +61,7 @@ static struct hvc_opal_priv *hvc_opal_privs[MAX_NR_HVC_CONSOLES]; | |||
61 | /* For early boot console */ | 61 | /* For early boot console */ |
62 | static struct hvc_opal_priv hvc_opal_boot_priv; | 62 | static struct hvc_opal_priv hvc_opal_boot_priv; |
63 | static u32 hvc_opal_boot_termno; | 63 | static u32 hvc_opal_boot_termno; |
64 | static bool hvc_opal_event_registered; | ||
64 | 65 | ||
65 | static const struct hv_ops hvc_opal_raw_ops = { | 66 | static const struct hv_ops hvc_opal_raw_ops = { |
66 | .get_chars = opal_get_chars, | 67 | .get_chars = opal_get_chars, |
@@ -161,6 +162,18 @@ static const struct hv_ops hvc_opal_hvsi_ops = { | |||
161 | .tiocmset = hvc_opal_hvsi_tiocmset, | 162 | .tiocmset = hvc_opal_hvsi_tiocmset, |
162 | }; | 163 | }; |
163 | 164 | ||
165 | static int hvc_opal_console_event(struct notifier_block *nb, | ||
166 | unsigned long events, void *change) | ||
167 | { | ||
168 | if (events & OPAL_EVENT_CONSOLE_INPUT) | ||
169 | hvc_kick(); | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | static struct notifier_block hvc_opal_console_nb = { | ||
174 | .notifier_call = hvc_opal_console_event, | ||
175 | }; | ||
176 | |||
164 | static int hvc_opal_probe(struct platform_device *dev) | 177 | static int hvc_opal_probe(struct platform_device *dev) |
165 | { | 178 | { |
166 | const struct hv_ops *ops; | 179 | const struct hv_ops *ops; |
@@ -170,6 +183,7 @@ static int hvc_opal_probe(struct platform_device *dev) | |||
170 | unsigned int termno, boot = 0; | 183 | unsigned int termno, boot = 0; |
171 | const __be32 *reg; | 184 | const __be32 *reg; |
172 | 185 | ||
186 | |||
173 | if (of_device_is_compatible(dev->dev.of_node, "ibm,opal-console-raw")) { | 187 | if (of_device_is_compatible(dev->dev.of_node, "ibm,opal-console-raw")) { |
174 | proto = HV_PROTOCOL_RAW; | 188 | proto = HV_PROTOCOL_RAW; |
175 | ops = &hvc_opal_raw_ops; | 189 | ops = &hvc_opal_raw_ops; |
@@ -213,12 +227,18 @@ static int hvc_opal_probe(struct platform_device *dev) | |||
213 | dev->dev.of_node->full_name, | 227 | dev->dev.of_node->full_name, |
214 | boot ? " (boot console)" : ""); | 228 | boot ? " (boot console)" : ""); |
215 | 229 | ||
216 | /* We don't do IRQ yet */ | 230 | /* We don't do IRQ ... */ |
217 | hp = hvc_alloc(termno, 0, ops, MAX_VIO_PUT_CHARS); | 231 | hp = hvc_alloc(termno, 0, ops, MAX_VIO_PUT_CHARS); |
218 | if (IS_ERR(hp)) | 232 | if (IS_ERR(hp)) |
219 | return PTR_ERR(hp); | 233 | return PTR_ERR(hp); |
220 | dev_set_drvdata(&dev->dev, hp); | 234 | dev_set_drvdata(&dev->dev, hp); |
221 | 235 | ||
236 | /* ... but we use OPAL event to kick the console */ | ||
237 | if (!hvc_opal_event_registered) { | ||
238 | opal_notifier_register(&hvc_opal_console_nb); | ||
239 | hvc_opal_event_registered = true; | ||
240 | } | ||
241 | |||
222 | return 0; | 242 | return 0; |
223 | } | 243 | } |
224 | 244 | ||