Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/time: remove ETR support

The External-Time-Reference (ETR) clock synchronization interface has
been superseded by Server-Time-Protocol (STP). Remove the outdated
ETR interface.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

+55 -1229
-229
arch/s390/include/asm/etr.h
··· 1 - /* 2 - * Copyright IBM Corp. 2006 3 - * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 - */ 5 - #ifndef __S390_ETR_H 6 - #define __S390_ETR_H 7 - 8 - /* ETR attachment control register */ 9 - struct etr_eacr { 10 - unsigned int e0 : 1; /* port 0 stepping control */ 11 - unsigned int e1 : 1; /* port 1 stepping control */ 12 - unsigned int _pad0 : 5; /* must be 00100 */ 13 - unsigned int dp : 1; /* data port control */ 14 - unsigned int p0 : 1; /* port 0 change recognition control */ 15 - unsigned int p1 : 1; /* port 1 change recognition control */ 16 - unsigned int _pad1 : 3; /* must be 000 */ 17 - unsigned int ea : 1; /* ETR alert control */ 18 - unsigned int es : 1; /* ETR sync check control */ 19 - unsigned int sl : 1; /* switch to local control */ 20 - } __attribute__ ((packed)); 21 - 22 - /* Port state returned by steai */ 23 - enum etr_psc { 24 - etr_psc_operational = 0, 25 - etr_psc_semi_operational = 1, 26 - etr_psc_protocol_error = 4, 27 - etr_psc_no_symbols = 8, 28 - etr_psc_no_signal = 12, 29 - etr_psc_pps_mode = 13 30 - }; 31 - 32 - /* Logical port state returned by stetr */ 33 - enum etr_lpsc { 34 - etr_lpsc_operational_step = 0, 35 - etr_lpsc_operational_alt = 1, 36 - etr_lpsc_semi_operational = 2, 37 - etr_lpsc_protocol_error = 4, 38 - etr_lpsc_no_symbol_sync = 8, 39 - etr_lpsc_no_signal = 12, 40 - etr_lpsc_pps_mode = 13 41 - }; 42 - 43 - /* ETR status words */ 44 - struct etr_esw { 45 - struct etr_eacr eacr; /* attachment control register */ 46 - unsigned int y : 1; /* stepping mode */ 47 - unsigned int _pad0 : 5; /* must be 00000 */ 48 - unsigned int p : 1; /* stepping port number */ 49 - unsigned int q : 1; /* data port number */ 50 - unsigned int psc0 : 4; /* port 0 state code */ 51 - unsigned int psc1 : 4; /* port 1 state code */ 52 - } __attribute__ ((packed)); 53 - 54 - /* Second level data register status word */ 55 - struct etr_slsw { 56 - unsigned int vv1 : 1; /* copy of validity bit data frame 1 */ 57 - unsigned int vv2 : 1; /* copy of validity bit data frame 2 */ 58 - unsigned int vv3 : 1; /* copy of validity bit data frame 3 */ 59 - unsigned int vv4 : 1; /* copy of validity bit data frame 4 */ 60 - unsigned int _pad0 : 19; /* must by all zeroes */ 61 - unsigned int n : 1; /* EAF port number */ 62 - unsigned int v1 : 1; /* validity bit ETR data frame 1 */ 63 - unsigned int v2 : 1; /* validity bit ETR data frame 2 */ 64 - unsigned int v3 : 1; /* validity bit ETR data frame 3 */ 65 - unsigned int v4 : 1; /* validity bit ETR data frame 4 */ 66 - unsigned int _pad1 : 4; /* must be 0000 */ 67 - } __attribute__ ((packed)); 68 - 69 - /* ETR data frames */ 70 - struct etr_edf1 { 71 - unsigned int u : 1; /* untuned bit */ 72 - unsigned int _pad0 : 1; /* must be 0 */ 73 - unsigned int r : 1; /* service request bit */ 74 - unsigned int _pad1 : 4; /* must be 0000 */ 75 - unsigned int a : 1; /* time adjustment bit */ 76 - unsigned int net_id : 8; /* ETR network id */ 77 - unsigned int etr_id : 8; /* id of ETR which sends data frames */ 78 - unsigned int etr_pn : 8; /* port number of ETR output port */ 79 - } __attribute__ ((packed)); 80 - 81 - struct etr_edf2 { 82 - unsigned int etv : 32; /* Upper 32 bits of TOD. */ 83 - } __attribute__ ((packed)); 84 - 85 - struct etr_edf3 { 86 - unsigned int rc : 8; /* failure reason code */ 87 - unsigned int _pad0 : 3; /* must be 000 */ 88 - unsigned int c : 1; /* ETR coupled bit */ 89 - unsigned int tc : 4; /* ETR type code */ 90 - unsigned int blto : 8; /* biased local time offset */ 91 - /* (blto - 128) * 15 = minutes */ 92 - unsigned int buo : 8; /* biased utc offset */ 93 - /* (buo - 128) = leap seconds */ 94 - } __attribute__ ((packed)); 95 - 96 - struct etr_edf4 { 97 - unsigned int ed : 8; /* ETS device dependent data */ 98 - unsigned int _pad0 : 1; /* must be 0 */ 99 - unsigned int buc : 5; /* biased ut1 correction */ 100 - /* (buc - 16) * 0.1 seconds */ 101 - unsigned int em : 6; /* ETS error magnitude */ 102 - unsigned int dc : 6; /* ETS drift code */ 103 - unsigned int sc : 6; /* ETS steering code */ 104 - } __attribute__ ((packed)); 105 - 106 - /* 107 - * ETR attachment information block, two formats 108 - * format 1 has 4 reserved words with a size of 64 bytes 109 - * format 2 has 16 reserved words with a size of 96 bytes 110 - */ 111 - struct etr_aib { 112 - struct etr_esw esw; 113 - struct etr_slsw slsw; 114 - unsigned long long tsp; 115 - struct etr_edf1 edf1; 116 - struct etr_edf2 edf2; 117 - struct etr_edf3 edf3; 118 - struct etr_edf4 edf4; 119 - unsigned int reserved[16]; 120 - } __attribute__ ((packed,aligned(8))); 121 - 122 - /* ETR interruption parameter */ 123 - struct etr_irq_parm { 124 - unsigned int _pad0 : 8; 125 - unsigned int pc0 : 1; /* port 0 state change */ 126 - unsigned int pc1 : 1; /* port 1 state change */ 127 - unsigned int _pad1 : 3; 128 - unsigned int eai : 1; /* ETR alert indication */ 129 - unsigned int _pad2 : 18; 130 - } __attribute__ ((packed)); 131 - 132 - /* Inline assembly helper functions */ 133 - static inline int etr_setr(struct etr_eacr *ctrl) 134 - { 135 - int rc = -EOPNOTSUPP; 136 - 137 - asm volatile( 138 - " .insn s,0xb2160000,%1\n" 139 - "0: la %0,0\n" 140 - "1:\n" 141 - EX_TABLE(0b,1b) 142 - : "+d" (rc) : "Q" (*ctrl)); 143 - return rc; 144 - } 145 - 146 - /* Stores a format 1 aib with 64 bytes */ 147 - static inline int etr_stetr(struct etr_aib *aib) 148 - { 149 - int rc = -EOPNOTSUPP; 150 - 151 - asm volatile( 152 - " .insn s,0xb2170000,%1\n" 153 - "0: la %0,0\n" 154 - "1:\n" 155 - EX_TABLE(0b,1b) 156 - : "+d" (rc) : "Q" (*aib)); 157 - return rc; 158 - } 159 - 160 - /* Stores a format 2 aib with 96 bytes for specified port */ 161 - static inline int etr_steai(struct etr_aib *aib, unsigned int func) 162 - { 163 - register unsigned int reg0 asm("0") = func; 164 - int rc = -EOPNOTSUPP; 165 - 166 - asm volatile( 167 - " .insn s,0xb2b30000,%1\n" 168 - "0: la %0,0\n" 169 - "1:\n" 170 - EX_TABLE(0b,1b) 171 - : "+d" (rc) : "Q" (*aib), "d" (reg0)); 172 - return rc; 173 - } 174 - 175 - /* Function codes for the steai instruction. */ 176 - #define ETR_STEAI_STEPPING_PORT 0x10 177 - #define ETR_STEAI_ALTERNATE_PORT 0x11 178 - #define ETR_STEAI_PORT_0 0x12 179 - #define ETR_STEAI_PORT_1 0x13 180 - 181 - /* Functions needed by the machine check handler */ 182 - int etr_switch_to_local(void); 183 - int etr_sync_check(void); 184 - void etr_queue_work(void); 185 - 186 - /* notifier for syncs */ 187 - extern struct atomic_notifier_head s390_epoch_delta_notifier; 188 - 189 - /* STP interruption parameter */ 190 - struct stp_irq_parm { 191 - unsigned int _pad0 : 14; 192 - unsigned int tsc : 1; /* Timing status change */ 193 - unsigned int lac : 1; /* Link availability change */ 194 - unsigned int tcpc : 1; /* Time control parameter change */ 195 - unsigned int _pad2 : 15; 196 - } __attribute__ ((packed)); 197 - 198 - #define STP_OP_SYNC 1 199 - #define STP_OP_CTRL 3 200 - 201 - struct stp_sstpi { 202 - unsigned int rsvd0; 203 - unsigned int rsvd1 : 8; 204 - unsigned int stratum : 8; 205 - unsigned int vbits : 16; 206 - unsigned int leaps : 16; 207 - unsigned int tmd : 4; 208 - unsigned int ctn : 4; 209 - unsigned int rsvd2 : 3; 210 - unsigned int c : 1; 211 - unsigned int tst : 4; 212 - unsigned int tzo : 16; 213 - unsigned int dsto : 16; 214 - unsigned int ctrl : 16; 215 - unsigned int rsvd3 : 16; 216 - unsigned int tto; 217 - unsigned int rsvd4; 218 - unsigned int ctnid[3]; 219 - unsigned int rsvd5; 220 - unsigned int todoff[4]; 221 - unsigned int rsvd6[48]; 222 - } __attribute__ ((packed)); 223 - 224 - /* Functions needed by the machine check handler */ 225 - int stp_sync_check(void); 226 - int stp_island_check(void); 227 - void stp_queue_work(void); 228 - 229 - #endif /* __S390_ETR_H */
+51
arch/s390/include/asm/stp.h
··· 1 + /* 2 + * Copyright IBM Corp. 2006 3 + * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 4 + */ 5 + #ifndef __S390_STP_H 6 + #define __S390_STP_H 7 + 8 + /* notifier for syncs */ 9 + extern struct atomic_notifier_head s390_epoch_delta_notifier; 10 + 11 + /* STP interruption parameter */ 12 + struct stp_irq_parm { 13 + unsigned int _pad0 : 14; 14 + unsigned int tsc : 1; /* Timing status change */ 15 + unsigned int lac : 1; /* Link availability change */ 16 + unsigned int tcpc : 1; /* Time control parameter change */ 17 + unsigned int _pad2 : 15; 18 + } __attribute__ ((packed)); 19 + 20 + #define STP_OP_SYNC 1 21 + #define STP_OP_CTRL 3 22 + 23 + struct stp_sstpi { 24 + unsigned int rsvd0; 25 + unsigned int rsvd1 : 8; 26 + unsigned int stratum : 8; 27 + unsigned int vbits : 16; 28 + unsigned int leaps : 16; 29 + unsigned int tmd : 4; 30 + unsigned int ctn : 4; 31 + unsigned int rsvd2 : 3; 32 + unsigned int c : 1; 33 + unsigned int tst : 4; 34 + unsigned int tzo : 16; 35 + unsigned int dsto : 16; 36 + unsigned int ctrl : 16; 37 + unsigned int rsvd3 : 16; 38 + unsigned int tto; 39 + unsigned int rsvd4; 40 + unsigned int ctnid[3]; 41 + unsigned int rsvd5; 42 + unsigned int todoff[4]; 43 + unsigned int rsvd6[48]; 44 + } __attribute__ ((packed)); 45 + 46 + /* Functions needed by the machine check handler */ 47 + int stp_sync_check(void); 48 + int stp_island_check(void); 49 + void stp_queue_work(void); 50 + 51 + #endif /* __S390_STP_H */
+2 -11
arch/s390/kernel/nmi.c
··· 16 16 #include <linux/module.h> 17 17 #include <asm/lowcore.h> 18 18 #include <asm/smp.h> 19 - #include <asm/etr.h> 19 + #include <asm/stp.h> 20 20 #include <asm/cputime.h> 21 21 #include <asm/nmi.h> 22 22 #include <asm/crw.h> ··· 27 27 unsigned int kill_task : 1; 28 28 unsigned int channel_report : 1; 29 29 unsigned int warning : 1; 30 - unsigned int etr_queue : 1; 31 30 unsigned int stp_queue : 1; 32 31 unsigned long mcck_code; 33 32 }; ··· 81 82 if (xchg(&mchchk_wng_posted, 1) == 0) 82 83 kill_cad_pid(SIGPWR, 1); 83 84 } 84 - if (mcck.etr_queue) 85 - etr_queue_work(); 86 85 if (mcck.stp_queue) 87 86 stp_queue_work(); 88 87 if (mcck.kill_task) { ··· 238 241 239 242 #define ED_STP_ISLAND 6 /* External damage STP island check */ 240 243 #define ED_STP_SYNC 7 /* External damage STP sync check */ 241 - #define ED_ETR_SYNC 12 /* External damage ETR sync check */ 242 - #define ED_ETR_SWITCH 13 /* External damage ETR switch to local */ 243 244 244 245 /* 245 246 * machine check handler. ··· 320 325 } 321 326 if (mci.ed && mci.ec) { 322 327 /* External damage */ 323 - if (S390_lowcore.external_damage_code & (1U << ED_ETR_SYNC)) 324 - mcck->etr_queue |= etr_sync_check(); 325 - if (S390_lowcore.external_damage_code & (1U << ED_ETR_SWITCH)) 326 - mcck->etr_queue |= etr_switch_to_local(); 327 328 if (S390_lowcore.external_damage_code & (1U << ED_STP_SYNC)) 328 329 mcck->stp_queue |= stp_sync_check(); 329 330 if (S390_lowcore.external_damage_code & (1U << ED_STP_ISLAND)) 330 331 mcck->stp_queue |= stp_island_check(); 331 - if (mcck->etr_queue || mcck->stp_queue) 332 + if (mcck->stp_queue) 332 333 set_cpu_flag(CIF_MCCK_PENDING); 333 334 } 334 335 if (mci.se)
+1 -988
arch/s390/kernel/time.c
··· 46 46 #include <asm/irq.h> 47 47 #include <asm/irq_regs.h> 48 48 #include <asm/vtimer.h> 49 - #include <asm/etr.h> 49 + #include <asm/stp.h> 50 50 #include <asm/cio.h> 51 51 #include "entry.h" 52 52 ··· 189 189 set_clock_comparator(S390_lowcore.clock_comparator); 190 190 } 191 191 192 - static void etr_timing_alert(struct etr_irq_parm *); 193 192 static void stp_timing_alert(struct stp_irq_parm *); 194 193 195 194 static void timing_alert_interrupt(struct ext_code ext_code, 196 195 unsigned int param32, unsigned long param64) 197 196 { 198 197 inc_irq_stat(IRQEXT_TLA); 199 - if (param32 & 0x00c40000) 200 - etr_timing_alert((struct etr_irq_parm *) &param32); 201 198 if (param32 & 0x00038000) 202 199 stp_timing_alert((struct stp_irq_parm *) &param32); 203 200 } 204 201 205 - static void etr_reset(void); 206 202 static void stp_reset(void); 207 203 208 204 void read_persistent_clock64(struct timespec64 *ts) ··· 298 302 void __init time_init(void) 299 303 { 300 304 /* Reset time synchronization interfaces. */ 301 - etr_reset(); 302 305 stp_reset(); 303 306 304 307 /* request the clock comparator external interrupt */ ··· 444 449 time_sync_wq = create_singlethread_workqueue("timesync"); 445 450 } 446 451 447 - /* 448 - * External Time Reference (ETR) code. 449 - */ 450 - static int etr_port0_online; 451 - static int etr_port1_online; 452 - static int etr_steai_available; 453 - 454 - static int __init early_parse_etr(char *p) 455 - { 456 - if (strncmp(p, "off", 3) == 0) 457 - etr_port0_online = etr_port1_online = 0; 458 - else if (strncmp(p, "port0", 5) == 0) 459 - etr_port0_online = 1; 460 - else if (strncmp(p, "port1", 5) == 0) 461 - etr_port1_online = 1; 462 - else if (strncmp(p, "on", 2) == 0) 463 - etr_port0_online = etr_port1_online = 1; 464 - return 0; 465 - } 466 - early_param("etr", early_parse_etr); 467 - 468 - enum etr_event { 469 - ETR_EVENT_PORT0_CHANGE, 470 - ETR_EVENT_PORT1_CHANGE, 471 - ETR_EVENT_PORT_ALERT, 472 - ETR_EVENT_SYNC_CHECK, 473 - ETR_EVENT_SWITCH_LOCAL, 474 - ETR_EVENT_UPDATE, 475 - }; 476 - 477 - /* 478 - * Valid bit combinations of the eacr register are (x = don't care): 479 - * e0 e1 dp p0 p1 ea es sl 480 - * 0 0 x 0 0 0 0 0 initial, disabled state 481 - * 0 0 x 0 1 1 0 0 port 1 online 482 - * 0 0 x 1 0 1 0 0 port 0 online 483 - * 0 0 x 1 1 1 0 0 both ports online 484 - * 0 1 x 0 1 1 0 0 port 1 online and usable, ETR or PPS mode 485 - * 0 1 x 0 1 1 0 1 port 1 online, usable and ETR mode 486 - * 0 1 x 0 1 1 1 0 port 1 online, usable, PPS mode, in-sync 487 - * 0 1 x 0 1 1 1 1 port 1 online, usable, ETR mode, in-sync 488 - * 0 1 x 1 1 1 0 0 both ports online, port 1 usable 489 - * 0 1 x 1 1 1 1 0 both ports online, port 1 usable, PPS mode, in-sync 490 - * 0 1 x 1 1 1 1 1 both ports online, port 1 usable, ETR mode, in-sync 491 - * 1 0 x 1 0 1 0 0 port 0 online and usable, ETR or PPS mode 492 - * 1 0 x 1 0 1 0 1 port 0 online, usable and ETR mode 493 - * 1 0 x 1 0 1 1 0 port 0 online, usable, PPS mode, in-sync 494 - * 1 0 x 1 0 1 1 1 port 0 online, usable, ETR mode, in-sync 495 - * 1 0 x 1 1 1 0 0 both ports online, port 0 usable 496 - * 1 0 x 1 1 1 1 0 both ports online, port 0 usable, PPS mode, in-sync 497 - * 1 0 x 1 1 1 1 1 both ports online, port 0 usable, ETR mode, in-sync 498 - * 1 1 x 1 1 1 1 0 both ports online & usable, ETR, in-sync 499 - * 1 1 x 1 1 1 1 1 both ports online & usable, ETR, in-sync 500 - */ 501 - static struct etr_eacr etr_eacr; 502 - static u64 etr_tolec; /* time of last eacr update */ 503 - static struct etr_aib etr_port0; 504 - static int etr_port0_uptodate; 505 - static struct etr_aib etr_port1; 506 - static int etr_port1_uptodate; 507 - static unsigned long etr_events; 508 - static struct timer_list etr_timer; 509 - 510 - static void etr_timeout(unsigned long dummy); 511 - static void etr_work_fn(struct work_struct *work); 512 - static DEFINE_MUTEX(etr_work_mutex); 513 - static DECLARE_WORK(etr_work, etr_work_fn); 514 - 515 - /* 516 - * Reset ETR attachment. 517 - */ 518 - static void etr_reset(void) 519 - { 520 - etr_eacr = (struct etr_eacr) { 521 - .e0 = 0, .e1 = 0, ._pad0 = 4, .dp = 0, 522 - .p0 = 0, .p1 = 0, ._pad1 = 0, .ea = 0, 523 - .es = 0, .sl = 0 }; 524 - if (etr_setr(&etr_eacr) == 0) { 525 - etr_tolec = get_tod_clock(); 526 - set_bit(CLOCK_SYNC_HAS_ETR, &clock_sync_flags); 527 - if (etr_port0_online && etr_port1_online) 528 - set_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 529 - } else if (etr_port0_online || etr_port1_online) { 530 - pr_warn("The real or virtual hardware system does not provide an ETR interface\n"); 531 - etr_port0_online = etr_port1_online = 0; 532 - } 533 - } 534 - 535 - static int __init etr_init(void) 536 - { 537 - struct etr_aib aib; 538 - 539 - if (!test_bit(CLOCK_SYNC_HAS_ETR, &clock_sync_flags)) 540 - return 0; 541 - time_init_wq(); 542 - /* Check if this machine has the steai instruction. */ 543 - if (etr_steai(&aib, ETR_STEAI_STEPPING_PORT) == 0) 544 - etr_steai_available = 1; 545 - setup_timer(&etr_timer, etr_timeout, 0UL); 546 - if (etr_port0_online) { 547 - set_bit(ETR_EVENT_PORT0_CHANGE, &etr_events); 548 - queue_work(time_sync_wq, &etr_work); 549 - } 550 - if (etr_port1_online) { 551 - set_bit(ETR_EVENT_PORT1_CHANGE, &etr_events); 552 - queue_work(time_sync_wq, &etr_work); 553 - } 554 - return 0; 555 - } 556 - 557 - arch_initcall(etr_init); 558 - 559 - /* 560 - * Two sorts of ETR machine checks. The architecture reads: 561 - * "When a machine-check niterruption occurs and if a switch-to-local or 562 - * ETR-sync-check interrupt request is pending but disabled, this pending 563 - * disabled interruption request is indicated and is cleared". 564 - * Which means that we can get etr_switch_to_local events from the machine 565 - * check handler although the interruption condition is disabled. Lovely.. 566 - */ 567 - 568 - /* 569 - * Switch to local machine check. This is called when the last usable 570 - * ETR port goes inactive. After switch to local the clock is not in sync. 571 - */ 572 - int etr_switch_to_local(void) 573 - { 574 - if (!etr_eacr.sl) 575 - return 0; 576 - disable_sync_clock(NULL); 577 - if (!test_and_set_bit(ETR_EVENT_SWITCH_LOCAL, &etr_events)) { 578 - etr_eacr.es = etr_eacr.sl = 0; 579 - etr_setr(&etr_eacr); 580 - return 1; 581 - } 582 - return 0; 583 - } 584 - 585 - /* 586 - * ETR sync check machine check. This is called when the ETR OTE and the 587 - * local clock OTE are farther apart than the ETR sync check tolerance. 588 - * After a ETR sync check the clock is not in sync. The machine check 589 - * is broadcasted to all cpus at the same time. 590 - */ 591 - int etr_sync_check(void) 592 - { 593 - if (!etr_eacr.es) 594 - return 0; 595 - disable_sync_clock(NULL); 596 - if (!test_and_set_bit(ETR_EVENT_SYNC_CHECK, &etr_events)) { 597 - etr_eacr.es = 0; 598 - etr_setr(&etr_eacr); 599 - return 1; 600 - } 601 - return 0; 602 - } 603 - 604 - void etr_queue_work(void) 605 - { 606 - queue_work(time_sync_wq, &etr_work); 607 - } 608 - 609 - /* 610 - * ETR timing alert. There are two causes: 611 - * 1) port state change, check the usability of the port 612 - * 2) port alert, one of the ETR-data-validity bits (v1-v2 bits of the 613 - * sldr-status word) or ETR-data word 1 (edf1) or ETR-data word 3 (edf3) 614 - * or ETR-data word 4 (edf4) has changed. 615 - */ 616 - static void etr_timing_alert(struct etr_irq_parm *intparm) 617 - { 618 - if (intparm->pc0) 619 - /* ETR port 0 state change. */ 620 - set_bit(ETR_EVENT_PORT0_CHANGE, &etr_events); 621 - if (intparm->pc1) 622 - /* ETR port 1 state change. */ 623 - set_bit(ETR_EVENT_PORT1_CHANGE, &etr_events); 624 - if (intparm->eai) 625 - /* 626 - * ETR port alert on either port 0, 1 or both. 627 - * Both ports are not up-to-date now. 628 - */ 629 - set_bit(ETR_EVENT_PORT_ALERT, &etr_events); 630 - queue_work(time_sync_wq, &etr_work); 631 - } 632 - 633 - static void etr_timeout(unsigned long dummy) 634 - { 635 - set_bit(ETR_EVENT_UPDATE, &etr_events); 636 - queue_work(time_sync_wq, &etr_work); 637 - } 638 - 639 - /* 640 - * Check if the etr mode is pss. 641 - */ 642 - static inline int etr_mode_is_pps(struct etr_eacr eacr) 643 - { 644 - return eacr.es && !eacr.sl; 645 - } 646 - 647 - /* 648 - * Check if the etr mode is etr. 649 - */ 650 - static inline int etr_mode_is_etr(struct etr_eacr eacr) 651 - { 652 - return eacr.es && eacr.sl; 653 - } 654 - 655 - /* 656 - * Check if the port can be used for TOD synchronization. 657 - * For PPS mode the port has to receive OTEs. For ETR mode 658 - * the port has to receive OTEs, the ETR stepping bit has to 659 - * be zero and the validity bits for data frame 1, 2, and 3 660 - * have to be 1. 661 - */ 662 - static int etr_port_valid(struct etr_aib *aib, int port) 663 - { 664 - unsigned int psc; 665 - 666 - /* Check that this port is receiving OTEs. */ 667 - if (aib->tsp == 0) 668 - return 0; 669 - 670 - psc = port ? aib->esw.psc1 : aib->esw.psc0; 671 - if (psc == etr_lpsc_pps_mode) 672 - return 1; 673 - if (psc == etr_lpsc_operational_step) 674 - return !aib->esw.y && aib->slsw.v1 && 675 - aib->slsw.v2 && aib->slsw.v3; 676 - return 0; 677 - } 678 - 679 - /* 680 - * Check if two ports are on the same network. 681 - */ 682 - static int etr_compare_network(struct etr_aib *aib1, struct etr_aib *aib2) 683 - { 684 - // FIXME: any other fields we have to compare? 685 - return aib1->edf1.net_id == aib2->edf1.net_id; 686 - } 687 - 688 - /* 689 - * Wrapper for etr_stei that converts physical port states 690 - * to logical port states to be consistent with the output 691 - * of stetr (see etr_psc vs. etr_lpsc). 692 - */ 693 - static void etr_steai_cv(struct etr_aib *aib, unsigned int func) 694 - { 695 - BUG_ON(etr_steai(aib, func) != 0); 696 - /* Convert port state to logical port state. */ 697 - if (aib->esw.psc0 == 1) 698 - aib->esw.psc0 = 2; 699 - else if (aib->esw.psc0 == 0 && aib->esw.p == 0) 700 - aib->esw.psc0 = 1; 701 - if (aib->esw.psc1 == 1) 702 - aib->esw.psc1 = 2; 703 - else if (aib->esw.psc1 == 0 && aib->esw.p == 1) 704 - aib->esw.psc1 = 1; 705 - } 706 - 707 - /* 708 - * Check if the aib a2 is still connected to the same attachment as 709 - * aib a1, the etv values differ by one and a2 is valid. 710 - */ 711 - static int etr_aib_follows(struct etr_aib *a1, struct etr_aib *a2, int p) 712 - { 713 - int state_a1, state_a2; 714 - 715 - /* Paranoia check: e0/e1 should better be the same. */ 716 - if (a1->esw.eacr.e0 != a2->esw.eacr.e0 || 717 - a1->esw.eacr.e1 != a2->esw.eacr.e1) 718 - return 0; 719 - 720 - /* Still connected to the same etr ? */ 721 - state_a1 = p ? a1->esw.psc1 : a1->esw.psc0; 722 - state_a2 = p ? a2->esw.psc1 : a2->esw.psc0; 723 - if (state_a1 == etr_lpsc_operational_step) { 724 - if (state_a2 != etr_lpsc_operational_step || 725 - a1->edf1.net_id != a2->edf1.net_id || 726 - a1->edf1.etr_id != a2->edf1.etr_id || 727 - a1->edf1.etr_pn != a2->edf1.etr_pn) 728 - return 0; 729 - } else if (state_a2 != etr_lpsc_pps_mode) 730 - return 0; 731 - 732 - /* The ETV value of a2 needs to be ETV of a1 + 1. */ 733 - if (a1->edf2.etv + 1 != a2->edf2.etv) 734 - return 0; 735 - 736 - if (!etr_port_valid(a2, p)) 737 - return 0; 738 - 739 - return 1; 740 - } 741 - 742 452 struct clock_sync_data { 743 453 atomic_t cpus; 744 454 int in_sync; ··· 479 779 */ 480 780 fixup_clock_comparator(sync->fixup_cc); 481 781 } 482 - 483 - /* 484 - * Sync the TOD clock using the port referred to by aibp. This port 485 - * has to be enabled and the other port has to be disabled. The 486 - * last eacr update has to be more than 1.6 seconds in the past. 487 - */ 488 - static int etr_sync_clock(void *data) 489 - { 490 - static int first; 491 - unsigned long long clock, old_clock, clock_delta, delay, delta; 492 - struct clock_sync_data *etr_sync; 493 - struct etr_aib *sync_port, *aib; 494 - struct ptff_qto qto; 495 - int port; 496 - int rc; 497 - 498 - etr_sync = data; 499 - 500 - if (xchg(&first, 1) == 1) { 501 - /* Slave */ 502 - clock_sync_cpu(etr_sync); 503 - return 0; 504 - } 505 - 506 - /* Wait until all other cpus entered the sync function. */ 507 - while (atomic_read(&etr_sync->cpus) != 0) 508 - cpu_relax(); 509 - 510 - port = etr_sync->etr_port; 511 - aib = etr_sync->etr_aib; 512 - sync_port = (port == 0) ? &etr_port0 : &etr_port1; 513 - enable_sync_clock(); 514 - 515 - /* Set clock to next OTE. */ 516 - __ctl_set_bit(14, 21); 517 - __ctl_set_bit(0, 29); 518 - clock = ((unsigned long long) (aib->edf2.etv + 1)) << 32; 519 - old_clock = get_tod_clock(); 520 - if (set_tod_clock(clock) == 0) { 521 - __udelay(1); /* Wait for the clock to start. */ 522 - __ctl_clear_bit(0, 29); 523 - __ctl_clear_bit(14, 21); 524 - etr_stetr(aib); 525 - /* Adjust Linux timing variables. */ 526 - delay = (unsigned long long) 527 - (aib->edf2.etv - sync_port->edf2.etv) << 32; 528 - delta = adjust_time(old_clock, clock, delay); 529 - clock_delta = clock - old_clock; 530 - atomic_notifier_call_chain(&s390_epoch_delta_notifier, 0, 531 - &clock_delta); 532 - etr_sync->fixup_cc = delta; 533 - fixup_clock_comparator(delta); 534 - /* Verify that the clock is properly set. */ 535 - if (!etr_aib_follows(sync_port, aib, port)) { 536 - /* Didn't work. */ 537 - disable_sync_clock(NULL); 538 - etr_sync->in_sync = -EAGAIN; 539 - rc = -EAGAIN; 540 - } else { 541 - if (ptff_query(PTFF_QTO) && 542 - ptff(&qto, sizeof(qto), PTFF_QTO) == 0) 543 - /* Update LPAR offset */ 544 - lpar_offset = qto.tod_epoch_difference; 545 - etr_sync->in_sync = 1; 546 - rc = 0; 547 - } 548 - } else { 549 - /* Could not set the clock ?!? */ 550 - __ctl_clear_bit(0, 29); 551 - __ctl_clear_bit(14, 21); 552 - disable_sync_clock(NULL); 553 - etr_sync->in_sync = -EAGAIN; 554 - rc = -EAGAIN; 555 - } 556 - xchg(&first, 0); 557 - return rc; 558 - } 559 - 560 - static int etr_sync_clock_stop(struct etr_aib *aib, int port) 561 - { 562 - struct clock_sync_data etr_sync; 563 - struct etr_aib *sync_port; 564 - int follows; 565 - int rc; 566 - 567 - /* Check if the current aib is adjacent to the sync port aib. */ 568 - sync_port = (port == 0) ? &etr_port0 : &etr_port1; 569 - follows = etr_aib_follows(sync_port, aib, port); 570 - memcpy(sync_port, aib, sizeof(*aib)); 571 - if (!follows) 572 - return -EAGAIN; 573 - memset(&etr_sync, 0, sizeof(etr_sync)); 574 - etr_sync.etr_aib = aib; 575 - etr_sync.etr_port = port; 576 - get_online_cpus(); 577 - atomic_set(&etr_sync.cpus, num_online_cpus() - 1); 578 - rc = stop_machine(etr_sync_clock, &etr_sync, cpu_online_mask); 579 - put_online_cpus(); 580 - return rc; 581 - } 582 - 583 - /* 584 - * Handle the immediate effects of the different events. 585 - * The port change event is used for online/offline changes. 586 - */ 587 - static struct etr_eacr etr_handle_events(struct etr_eacr eacr) 588 - { 589 - if (test_and_clear_bit(ETR_EVENT_SYNC_CHECK, &etr_events)) 590 - eacr.es = 0; 591 - if (test_and_clear_bit(ETR_EVENT_SWITCH_LOCAL, &etr_events)) 592 - eacr.es = eacr.sl = 0; 593 - if (test_and_clear_bit(ETR_EVENT_PORT_ALERT, &etr_events)) 594 - etr_port0_uptodate = etr_port1_uptodate = 0; 595 - 596 - if (test_and_clear_bit(ETR_EVENT_PORT0_CHANGE, &etr_events)) { 597 - if (eacr.e0) 598 - /* 599 - * Port change of an enabled port. We have to 600 - * assume that this can have caused an stepping 601 - * port switch. 602 - */ 603 - etr_tolec = get_tod_clock(); 604 - eacr.p0 = etr_port0_online; 605 - if (!eacr.p0) 606 - eacr.e0 = 0; 607 - etr_port0_uptodate = 0; 608 - } 609 - if (test_and_clear_bit(ETR_EVENT_PORT1_CHANGE, &etr_events)) { 610 - if (eacr.e1) 611 - /* 612 - * Port change of an enabled port. We have to 613 - * assume that this can have caused an stepping 614 - * port switch. 615 - */ 616 - etr_tolec = get_tod_clock(); 617 - eacr.p1 = etr_port1_online; 618 - if (!eacr.p1) 619 - eacr.e1 = 0; 620 - etr_port1_uptodate = 0; 621 - } 622 - clear_bit(ETR_EVENT_UPDATE, &etr_events); 623 - return eacr; 624 - } 625 - 626 - /* 627 - * Set up a timer that expires after the etr_tolec + 1.6 seconds if 628 - * one of the ports needs an update. 629 - */ 630 - static void etr_set_tolec_timeout(unsigned long long now) 631 - { 632 - unsigned long micros; 633 - 634 - if ((!etr_eacr.p0 || etr_port0_uptodate) && 635 - (!etr_eacr.p1 || etr_port1_uptodate)) 636 - return; 637 - micros = (now > etr_tolec) ? ((now - etr_tolec) >> 12) : 0; 638 - micros = (micros > 1600000) ? 0 : 1600000 - micros; 639 - mod_timer(&etr_timer, jiffies + (micros * HZ) / 1000000 + 1); 640 - } 641 - 642 - /* 643 - * Set up a time that expires after 1/2 second. 644 - */ 645 - static void etr_set_sync_timeout(void) 646 - { 647 - mod_timer(&etr_timer, jiffies + HZ/2); 648 - } 649 - 650 - /* 651 - * Update the aib information for one or both ports. 652 - */ 653 - static struct etr_eacr etr_handle_update(struct etr_aib *aib, 654 - struct etr_eacr eacr) 655 - { 656 - /* With both ports disabled the aib information is useless. */ 657 - if (!eacr.e0 && !eacr.e1) 658 - return eacr; 659 - 660 - /* Update port0 or port1 with aib stored in etr_work_fn. */ 661 - if (aib->esw.q == 0) { 662 - /* Information for port 0 stored. */ 663 - if (eacr.p0 && !etr_port0_uptodate) { 664 - etr_port0 = *aib; 665 - if (etr_port0_online) 666 - etr_port0_uptodate = 1; 667 - } 668 - } else { 669 - /* Information for port 1 stored. */ 670 - if (eacr.p1 && !etr_port1_uptodate) { 671 - etr_port1 = *aib; 672 - if (etr_port0_online) 673 - etr_port1_uptodate = 1; 674 - } 675 - } 676 - 677 - /* 678 - * Do not try to get the alternate port aib if the clock 679 - * is not in sync yet. 680 - */ 681 - if (!eacr.es || !check_sync_clock()) 682 - return eacr; 683 - 684 - /* 685 - * If steai is available we can get the information about 686 - * the other port immediately. If only stetr is available the 687 - * data-port bit toggle has to be used. 688 - */ 689 - if (etr_steai_available) { 690 - if (eacr.p0 && !etr_port0_uptodate) { 691 - etr_steai_cv(&etr_port0, ETR_STEAI_PORT_0); 692 - etr_port0_uptodate = 1; 693 - } 694 - if (eacr.p1 && !etr_port1_uptodate) { 695 - etr_steai_cv(&etr_port1, ETR_STEAI_PORT_1); 696 - etr_port1_uptodate = 1; 697 - } 698 - } else { 699 - /* 700 - * One port was updated above, if the other 701 - * port is not uptodate toggle dp bit. 702 - */ 703 - if ((eacr.p0 && !etr_port0_uptodate) || 704 - (eacr.p1 && !etr_port1_uptodate)) 705 - eacr.dp ^= 1; 706 - else 707 - eacr.dp = 0; 708 - } 709 - return eacr; 710 - } 711 - 712 - /* 713 - * Write new etr control register if it differs from the current one. 714 - * Return 1 if etr_tolec has been updated as well. 715 - */ 716 - static void etr_update_eacr(struct etr_eacr eacr) 717 - { 718 - int dp_changed; 719 - 720 - if (memcmp(&etr_eacr, &eacr, sizeof(eacr)) == 0) 721 - /* No change, return. */ 722 - return; 723 - /* 724 - * The disable of an active port of the change of the data port 725 - * bit can/will cause a change in the data port. 726 - */ 727 - dp_changed = etr_eacr.e0 > eacr.e0 || etr_eacr.e1 > eacr.e1 || 728 - (etr_eacr.dp ^ eacr.dp) != 0; 729 - etr_eacr = eacr; 730 - etr_setr(&etr_eacr); 731 - if (dp_changed) 732 - etr_tolec = get_tod_clock(); 733 - } 734 - 735 - /* 736 - * ETR work. In this function you'll find the main logic. In 737 - * particular this is the only function that calls etr_update_eacr(), 738 - * it "controls" the etr control register. 739 - */ 740 - static void etr_work_fn(struct work_struct *work) 741 - { 742 - unsigned long long now; 743 - struct etr_eacr eacr; 744 - struct etr_aib aib; 745 - int sync_port; 746 - 747 - /* prevent multiple execution. */ 748 - mutex_lock(&etr_work_mutex); 749 - 750 - /* Create working copy of etr_eacr. */ 751 - eacr = etr_eacr; 752 - 753 - /* Check for the different events and their immediate effects. */ 754 - eacr = etr_handle_events(eacr); 755 - 756 - /* Check if ETR is supposed to be active. */ 757 - eacr.ea = eacr.p0 || eacr.p1; 758 - if (!eacr.ea) { 759 - /* Both ports offline. Reset everything. */ 760 - eacr.dp = eacr.es = eacr.sl = 0; 761 - on_each_cpu(disable_sync_clock, NULL, 1); 762 - del_timer_sync(&etr_timer); 763 - etr_update_eacr(eacr); 764 - goto out_unlock; 765 - } 766 - 767 - /* Store aib to get the current ETR status word. */ 768 - BUG_ON(etr_stetr(&aib) != 0); 769 - etr_port0.esw = etr_port1.esw = aib.esw; /* Copy status word. */ 770 - now = get_tod_clock(); 771 - 772 - /* 773 - * Update the port information if the last stepping port change 774 - * or data port change is older than 1.6 seconds. 775 - */ 776 - if (now >= etr_tolec + (1600000 << 12)) 777 - eacr = etr_handle_update(&aib, eacr); 778 - 779 - /* 780 - * Select ports to enable. The preferred synchronization mode is PPS. 781 - * If a port can be enabled depends on a number of things: 782 - * 1) The port needs to be online and uptodate. A port is not 783 - * disabled just because it is not uptodate, but it is only 784 - * enabled if it is uptodate. 785 - * 2) The port needs to have the same mode (pps / etr). 786 - * 3) The port needs to be usable -> etr_port_valid() == 1 787 - * 4) To enable the second port the clock needs to be in sync. 788 - * 5) If both ports are useable and are ETR ports, the network id 789 - * has to be the same. 790 - * The eacr.sl bit is used to indicate etr mode vs. pps mode. 791 - */ 792 - if (eacr.p0 && aib.esw.psc0 == etr_lpsc_pps_mode) { 793 - eacr.sl = 0; 794 - eacr.e0 = 1; 795 - if (!etr_mode_is_pps(etr_eacr)) 796 - eacr.es = 0; 797 - if (!eacr.es || !eacr.p1 || aib.esw.psc1 != etr_lpsc_pps_mode) 798 - eacr.e1 = 0; 799 - // FIXME: uptodate checks ? 800 - else if (etr_port0_uptodate && etr_port1_uptodate) 801 - eacr.e1 = 1; 802 - sync_port = (etr_port0_uptodate && 803 - etr_port_valid(&etr_port0, 0)) ? 0 : -1; 804 - } else if (eacr.p1 && aib.esw.psc1 == etr_lpsc_pps_mode) { 805 - eacr.sl = 0; 806 - eacr.e0 = 0; 807 - eacr.e1 = 1; 808 - if (!etr_mode_is_pps(etr_eacr)) 809 - eacr.es = 0; 810 - sync_port = (etr_port1_uptodate && 811 - etr_port_valid(&etr_port1, 1)) ? 1 : -1; 812 - } else if (eacr.p0 && aib.esw.psc0 == etr_lpsc_operational_step) { 813 - eacr.sl = 1; 814 - eacr.e0 = 1; 815 - if (!etr_mode_is_etr(etr_eacr)) 816 - eacr.es = 0; 817 - if (!eacr.es || !eacr.p1 || 818 - aib.esw.psc1 != etr_lpsc_operational_alt) 819 - eacr.e1 = 0; 820 - else if (etr_port0_uptodate && etr_port1_uptodate && 821 - etr_compare_network(&etr_port0, &etr_port1)) 822 - eacr.e1 = 1; 823 - sync_port = (etr_port0_uptodate && 824 - etr_port_valid(&etr_port0, 0)) ? 0 : -1; 825 - } else if (eacr.p1 && aib.esw.psc1 == etr_lpsc_operational_step) { 826 - eacr.sl = 1; 827 - eacr.e0 = 0; 828 - eacr.e1 = 1; 829 - if (!etr_mode_is_etr(etr_eacr)) 830 - eacr.es = 0; 831 - sync_port = (etr_port1_uptodate && 832 - etr_port_valid(&etr_port1, 1)) ? 1 : -1; 833 - } else { 834 - /* Both ports not usable. */ 835 - eacr.es = eacr.sl = 0; 836 - sync_port = -1; 837 - } 838 - 839 - /* 840 - * If the clock is in sync just update the eacr and return. 841 - * If there is no valid sync port wait for a port update. 842 - */ 843 - if ((eacr.es && check_sync_clock()) || sync_port < 0) { 844 - etr_update_eacr(eacr); 845 - etr_set_tolec_timeout(now); 846 - goto out_unlock; 847 - } 848 - 849 - /* 850 - * Prepare control register for clock syncing 851 - * (reset data port bit, set sync check control. 852 - */ 853 - eacr.dp = 0; 854 - eacr.es = 1; 855 - 856 - /* 857 - * Update eacr and try to synchronize the clock. If the update 858 - * of eacr caused a stepping port switch (or if we have to 859 - * assume that a stepping port switch has occurred) or the 860 - * clock syncing failed, reset the sync check control bit 861 - * and set up a timer to try again after 0.5 seconds 862 - */ 863 - etr_update_eacr(eacr); 864 - if (now < etr_tolec + (1600000 << 12) || 865 - etr_sync_clock_stop(&aib, sync_port) != 0) { 866 - /* Sync failed. Try again in 1/2 second. */ 867 - eacr.es = 0; 868 - etr_update_eacr(eacr); 869 - etr_set_sync_timeout(); 870 - } else 871 - etr_set_tolec_timeout(now); 872 - out_unlock: 873 - mutex_unlock(&etr_work_mutex); 874 - } 875 - 876 - /* 877 - * Sysfs interface functions 878 - */ 879 - static struct bus_type etr_subsys = { 880 - .name = "etr", 881 - .dev_name = "etr", 882 - }; 883 - 884 - static struct device etr_port0_dev = { 885 - .id = 0, 886 - .bus = &etr_subsys, 887 - }; 888 - 889 - static struct device etr_port1_dev = { 890 - .id = 1, 891 - .bus = &etr_subsys, 892 - }; 893 - 894 - /* 895 - * ETR subsys attributes 896 - */ 897 - static ssize_t etr_stepping_port_show(struct device *dev, 898 - struct device_attribute *attr, 899 - char *buf) 900 - { 901 - return sprintf(buf, "%i\n", etr_port0.esw.p); 902 - } 903 - 904 - static DEVICE_ATTR(stepping_port, 0400, etr_stepping_port_show, NULL); 905 - 906 - static ssize_t etr_stepping_mode_show(struct device *dev, 907 - struct device_attribute *attr, 908 - char *buf) 909 - { 910 - char *mode_str; 911 - 912 - if (etr_mode_is_pps(etr_eacr)) 913 - mode_str = "pps"; 914 - else if (etr_mode_is_etr(etr_eacr)) 915 - mode_str = "etr"; 916 - else 917 - mode_str = "local"; 918 - return sprintf(buf, "%s\n", mode_str); 919 - } 920 - 921 - static DEVICE_ATTR(stepping_mode, 0400, etr_stepping_mode_show, NULL); 922 - 923 - /* 924 - * ETR port attributes 925 - */ 926 - static inline struct etr_aib *etr_aib_from_dev(struct device *dev) 927 - { 928 - if (dev == &etr_port0_dev) 929 - return etr_port0_online ? &etr_port0 : NULL; 930 - else 931 - return etr_port1_online ? &etr_port1 : NULL; 932 - } 933 - 934 - static ssize_t etr_online_show(struct device *dev, 935 - struct device_attribute *attr, 936 - char *buf) 937 - { 938 - unsigned int online; 939 - 940 - online = (dev == &etr_port0_dev) ? etr_port0_online : etr_port1_online; 941 - return sprintf(buf, "%i\n", online); 942 - } 943 - 944 - static ssize_t etr_online_store(struct device *dev, 945 - struct device_attribute *attr, 946 - const char *buf, size_t count) 947 - { 948 - unsigned int value; 949 - 950 - value = simple_strtoul(buf, NULL, 0); 951 - if (value != 0 && value != 1) 952 - return -EINVAL; 953 - if (!test_bit(CLOCK_SYNC_HAS_ETR, &clock_sync_flags)) 954 - return -EOPNOTSUPP; 955 - mutex_lock(&clock_sync_mutex); 956 - if (dev == &etr_port0_dev) { 957 - if (etr_port0_online == value) 958 - goto out; /* Nothing to do. */ 959 - etr_port0_online = value; 960 - if (etr_port0_online && etr_port1_online) 961 - set_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 962 - else 963 - clear_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 964 - set_bit(ETR_EVENT_PORT0_CHANGE, &etr_events); 965 - queue_work(time_sync_wq, &etr_work); 966 - } else { 967 - if (etr_port1_online == value) 968 - goto out; /* Nothing to do. */ 969 - etr_port1_online = value; 970 - if (etr_port0_online && etr_port1_online) 971 - set_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 972 - else 973 - clear_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 974 - set_bit(ETR_EVENT_PORT1_CHANGE, &etr_events); 975 - queue_work(time_sync_wq, &etr_work); 976 - } 977 - out: 978 - mutex_unlock(&clock_sync_mutex); 979 - return count; 980 - } 981 - 982 - static DEVICE_ATTR(online, 0600, etr_online_show, etr_online_store); 983 - 984 - static ssize_t etr_stepping_control_show(struct device *dev, 985 - struct device_attribute *attr, 986 - char *buf) 987 - { 988 - return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ? 989 - etr_eacr.e0 : etr_eacr.e1); 990 - } 991 - 992 - static DEVICE_ATTR(stepping_control, 0400, etr_stepping_control_show, NULL); 993 - 994 - static ssize_t etr_mode_code_show(struct device *dev, 995 - struct device_attribute *attr, char *buf) 996 - { 997 - if (!etr_port0_online && !etr_port1_online) 998 - /* Status word is not uptodate if both ports are offline. */ 999 - return -ENODATA; 1000 - return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ? 1001 - etr_port0.esw.psc0 : etr_port0.esw.psc1); 1002 - } 1003 - 1004 - static DEVICE_ATTR(state_code, 0400, etr_mode_code_show, NULL); 1005 - 1006 - static ssize_t etr_untuned_show(struct device *dev, 1007 - struct device_attribute *attr, char *buf) 1008 - { 1009 - struct etr_aib *aib = etr_aib_from_dev(dev); 1010 - 1011 - if (!aib || !aib->slsw.v1) 1012 - return -ENODATA; 1013 - return sprintf(buf, "%i\n", aib->edf1.u); 1014 - } 1015 - 1016 - static DEVICE_ATTR(untuned, 0400, etr_untuned_show, NULL); 1017 - 1018 - static ssize_t etr_network_id_show(struct device *dev, 1019 - struct device_attribute *attr, char *buf) 1020 - { 1021 - struct etr_aib *aib = etr_aib_from_dev(dev); 1022 - 1023 - if (!aib || !aib->slsw.v1) 1024 - return -ENODATA; 1025 - return sprintf(buf, "%i\n", aib->edf1.net_id); 1026 - } 1027 - 1028 - static DEVICE_ATTR(network, 0400, etr_network_id_show, NULL); 1029 - 1030 - static ssize_t etr_id_show(struct device *dev, 1031 - struct device_attribute *attr, char *buf) 1032 - { 1033 - struct etr_aib *aib = etr_aib_from_dev(dev); 1034 - 1035 - if (!aib || !aib->slsw.v1) 1036 - return -ENODATA; 1037 - return sprintf(buf, "%i\n", aib->edf1.etr_id); 1038 - } 1039 - 1040 - static DEVICE_ATTR(id, 0400, etr_id_show, NULL); 1041 - 1042 - static ssize_t etr_port_number_show(struct device *dev, 1043 - struct device_attribute *attr, char *buf) 1044 - { 1045 - struct etr_aib *aib = etr_aib_from_dev(dev); 1046 - 1047 - if (!aib || !aib->slsw.v1) 1048 - return -ENODATA; 1049 - return sprintf(buf, "%i\n", aib->edf1.etr_pn); 1050 - } 1051 - 1052 - static DEVICE_ATTR(port, 0400, etr_port_number_show, NULL); 1053 - 1054 - static ssize_t etr_coupled_show(struct device *dev, 1055 - struct device_attribute *attr, char *buf) 1056 - { 1057 - struct etr_aib *aib = etr_aib_from_dev(dev); 1058 - 1059 - if (!aib || !aib->slsw.v3) 1060 - return -ENODATA; 1061 - return sprintf(buf, "%i\n", aib->edf3.c); 1062 - } 1063 - 1064 - static DEVICE_ATTR(coupled, 0400, etr_coupled_show, NULL); 1065 - 1066 - static ssize_t etr_local_time_show(struct device *dev, 1067 - struct device_attribute *attr, char *buf) 1068 - { 1069 - struct etr_aib *aib = etr_aib_from_dev(dev); 1070 - 1071 - if (!aib || !aib->slsw.v3) 1072 - return -ENODATA; 1073 - return sprintf(buf, "%i\n", aib->edf3.blto); 1074 - } 1075 - 1076 - static DEVICE_ATTR(local_time, 0400, etr_local_time_show, NULL); 1077 - 1078 - static ssize_t etr_utc_offset_show(struct device *dev, 1079 - struct device_attribute *attr, char *buf) 1080 - { 1081 - struct etr_aib *aib = etr_aib_from_dev(dev); 1082 - 1083 - if (!aib || !aib->slsw.v3) 1084 - return -ENODATA; 1085 - return sprintf(buf, "%i\n", aib->edf3.buo); 1086 - } 1087 - 1088 - static DEVICE_ATTR(utc_offset, 0400, etr_utc_offset_show, NULL); 1089 - 1090 - static struct device_attribute *etr_port_attributes[] = { 1091 - &dev_attr_online, 1092 - &dev_attr_stepping_control, 1093 - &dev_attr_state_code, 1094 - &dev_attr_untuned, 1095 - &dev_attr_network, 1096 - &dev_attr_id, 1097 - &dev_attr_port, 1098 - &dev_attr_coupled, 1099 - &dev_attr_local_time, 1100 - &dev_attr_utc_offset, 1101 - NULL 1102 - }; 1103 - 1104 - static int __init etr_register_port(struct device *dev) 1105 - { 1106 - struct device_attribute **attr; 1107 - int rc; 1108 - 1109 - rc = device_register(dev); 1110 - if (rc) 1111 - goto out; 1112 - for (attr = etr_port_attributes; *attr; attr++) { 1113 - rc = device_create_file(dev, *attr); 1114 - if (rc) 1115 - goto out_unreg; 1116 - } 1117 - return 0; 1118 - out_unreg: 1119 - for (; attr >= etr_port_attributes; attr--) 1120 - device_remove_file(dev, *attr); 1121 - device_unregister(dev); 1122 - out: 1123 - return rc; 1124 - } 1125 - 1126 - static void __init etr_unregister_port(struct device *dev) 1127 - { 1128 - struct device_attribute **attr; 1129 - 1130 - for (attr = etr_port_attributes; *attr; attr++) 1131 - device_remove_file(dev, *attr); 1132 - device_unregister(dev); 1133 - } 1134 - 1135 - static int __init etr_init_sysfs(void) 1136 - { 1137 - int rc; 1138 - 1139 - rc = subsys_system_register(&etr_subsys, NULL); 1140 - if (rc) 1141 - goto out; 1142 - rc = device_create_file(etr_subsys.dev_root, &dev_attr_stepping_port); 1143 - if (rc) 1144 - goto out_unreg_subsys; 1145 - rc = device_create_file(etr_subsys.dev_root, &dev_attr_stepping_mode); 1146 - if (rc) 1147 - goto out_remove_stepping_port; 1148 - rc = etr_register_port(&etr_port0_dev); 1149 - if (rc) 1150 - goto out_remove_stepping_mode; 1151 - rc = etr_register_port(&etr_port1_dev); 1152 - if (rc) 1153 - goto out_remove_port0; 1154 - return 0; 1155 - 1156 - out_remove_port0: 1157 - etr_unregister_port(&etr_port0_dev); 1158 - out_remove_stepping_mode: 1159 - device_remove_file(etr_subsys.dev_root, &dev_attr_stepping_mode); 1160 - out_remove_stepping_port: 1161 - device_remove_file(etr_subsys.dev_root, &dev_attr_stepping_port); 1162 - out_unreg_subsys: 1163 - bus_unregister(&etr_subsys); 1164 - out: 1165 - return rc; 1166 - } 1167 - 1168 - device_initcall(etr_init_sysfs); 1169 782 1170 783 /* 1171 784 * Server Time Protocol (STP) code.
+1 -1
arch/s390/kvm/kvm-s390.c
··· 28 28 #include <linux/vmalloc.h> 29 29 #include <asm/asm-offsets.h> 30 30 #include <asm/lowcore.h> 31 - #include <asm/etr.h> 31 + #include <asm/stp.h> 32 32 #include <asm/pgtable.h> 33 33 #include <asm/gmap.h> 34 34 #include <asm/nmi.h>