2 * drivers/s390/char/sclp.c
3 * core function to access sclp interface
6 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Peschke <mpeschke@de.ibm.com>
8 * Martin Schwidefsky <schwidefsky@de.ibm.com>
11 #include <linux/module.h>
12 #include <linux/err.h>
13 #include <linux/spinlock.h>
14 #include <linux/interrupt.h>
15 #include <linux/timer.h>
16 #include <linux/reboot.h>
17 #include <linux/jiffies.h>
18 #include <asm/types.h>
19 #include <asm/s390_ext.h>
23 #define SCLP_HEADER "sclp: "
25 /* Structure for register_early_external_interrupt. */
26 static ext_int_info_t ext_int_info_hwc;
28 /* Lock to protect internal data consistency. */
29 static DEFINE_SPINLOCK(sclp_lock);
31 /* Mask of events that we can receive from the sclp interface. */
32 static sccb_mask_t sclp_receive_mask;
34 /* Mask of events that we can send to the sclp interface. */
35 static sccb_mask_t sclp_send_mask;
37 /* List of registered event listeners and senders. */
38 static struct list_head sclp_reg_list;
40 /* List of queued requests. */
41 static struct list_head sclp_req_queue;
43 /* Data for read and and init requests. */
44 static struct sclp_req sclp_read_req;
45 static struct sclp_req sclp_init_req;
46 static char sclp_read_sccb[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
47 static char sclp_init_sccb[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
49 /* Timer for request retries. */
50 static struct timer_list sclp_request_timer;
52 /* Internal state: is the driver initialized? */
53 static volatile enum sclp_init_state_t {
54 sclp_init_state_uninitialized,
55 sclp_init_state_initializing,
56 sclp_init_state_initialized
57 } sclp_init_state = sclp_init_state_uninitialized;
59 /* Internal state: is a request active at the sclp? */
60 static volatile enum sclp_running_state_t {
61 sclp_running_state_idle,
62 sclp_running_state_running
63 } sclp_running_state = sclp_running_state_idle;
65 /* Internal state: is a read request pending? */
66 static volatile enum sclp_reading_state_t {
67 sclp_reading_state_idle,
68 sclp_reading_state_reading
69 } sclp_reading_state = sclp_reading_state_idle;
71 /* Internal state: is the driver currently serving requests? */
72 static volatile enum sclp_activation_state_t {
73 sclp_activation_state_active,
74 sclp_activation_state_deactivating,
75 sclp_activation_state_inactive,
76 sclp_activation_state_activating
77 } sclp_activation_state = sclp_activation_state_active;
79 /* Internal state: is an init mask request pending? */
80 static volatile enum sclp_mask_state_t {
82 sclp_mask_state_initializing
83 } sclp_mask_state = sclp_mask_state_idle;
85 /* Maximum retry counts */
86 #define SCLP_INIT_RETRY 3
87 #define SCLP_MASK_RETRY 3
89 /* Timeout intervals in seconds.*/
90 #define SCLP_BUSY_INTERVAL 10
91 #define SCLP_RETRY_INTERVAL 15
93 static void sclp_process_queue(void);
94 static int sclp_init_mask(int calculate);
95 static int sclp_init(void);
97 /* Perform service call. Return 0 on success, non-zero otherwise. */
99 service_call(sclp_cmdw_t command, void *sccb)
104 " .insn rre,0xb2200000,%1,%2\n" /* servc %1,%2 */
107 : "=&d" (cc) : "d" (command), "a" (__pa(sccb))
116 /* Request timeout handler. Restart the request queue. If DATA is non-zero,
117 * force restart of running request. */
119 sclp_request_timeout(unsigned long data)
124 spin_lock_irqsave(&sclp_lock, flags);
125 sclp_running_state = sclp_running_state_idle;
126 spin_unlock_irqrestore(&sclp_lock, flags);
128 sclp_process_queue();
131 /* Set up request retry timer. Called while sclp_lock is locked. */
133 __sclp_set_request_timer(unsigned long time, void (*function)(unsigned long),
136 del_timer(&sclp_request_timer);
137 sclp_request_timer.function = function;
138 sclp_request_timer.data = data;
139 sclp_request_timer.expires = jiffies + time;
140 add_timer(&sclp_request_timer);
143 /* Try to start a request. Return zero if the request was successfully
144 * started or if it will be started at a later time. Return non-zero otherwise.
145 * Called while sclp_lock is locked. */
147 __sclp_start_request(struct sclp_req *req)
151 if (sclp_running_state != sclp_running_state_idle)
153 del_timer(&sclp_request_timer);
154 rc = service_call(req->command, req->sccb);
158 /* Sucessfully started request */
159 req->status = SCLP_REQ_RUNNING;
160 sclp_running_state = sclp_running_state_running;
161 __sclp_set_request_timer(SCLP_RETRY_INTERVAL * HZ,
162 sclp_request_timeout, 1);
164 } else if (rc == -EBUSY) {
165 /* Try again later */
166 __sclp_set_request_timer(SCLP_BUSY_INTERVAL * HZ,
167 sclp_request_timeout, 0);
171 req->status = SCLP_REQ_FAILED;
175 /* Try to start queued requests. */
177 sclp_process_queue(void)
179 struct sclp_req *req;
183 spin_lock_irqsave(&sclp_lock, flags);
184 if (sclp_running_state != sclp_running_state_idle) {
185 spin_unlock_irqrestore(&sclp_lock, flags);
188 del_timer(&sclp_request_timer);
189 while (!list_empty(&sclp_req_queue)) {
190 req = list_entry(sclp_req_queue.next, struct sclp_req, list);
191 rc = __sclp_start_request(req);
194 /* Request failed. */
195 list_del(&req->list);
197 spin_unlock_irqrestore(&sclp_lock, flags);
198 req->callback(req, req->callback_data);
199 spin_lock_irqsave(&sclp_lock, flags);
202 spin_unlock_irqrestore(&sclp_lock, flags);
205 /* Queue a new request. Return zero on success, non-zero otherwise. */
207 sclp_add_request(struct sclp_req *req)
212 spin_lock_irqsave(&sclp_lock, flags);
213 if ((sclp_init_state != sclp_init_state_initialized ||
214 sclp_activation_state != sclp_activation_state_active) &&
215 req != &sclp_init_req) {
216 spin_unlock_irqrestore(&sclp_lock, flags);
219 req->status = SCLP_REQ_QUEUED;
220 req->start_count = 0;
221 list_add_tail(&req->list, &sclp_req_queue);
223 /* Start if request is first in list */
224 if (req->list.prev == &sclp_req_queue) {
225 rc = __sclp_start_request(req);
227 list_del(&req->list);
229 spin_unlock_irqrestore(&sclp_lock, flags);
233 EXPORT_SYMBOL(sclp_add_request);
235 /* Dispatch events found in request buffer to registered listeners. Return 0
236 * if all events were dispatched, non-zero otherwise. */
238 sclp_dispatch_evbufs(struct sccb_header *sccb)
241 struct evbuf_header *evbuf;
243 struct sclp_register *reg;
247 spin_lock_irqsave(&sclp_lock, flags);
249 for (offset = sizeof(struct sccb_header); offset < sccb->length;
250 offset += evbuf->length) {
251 /* Search for event handler */
252 evbuf = (struct evbuf_header *) ((addr_t) sccb + offset);
254 list_for_each(l, &sclp_reg_list) {
255 reg = list_entry(l, struct sclp_register, list);
256 if (reg->receive_mask & (1 << (32 - evbuf->type)))
261 if (reg && reg->receiver_fn) {
262 spin_unlock_irqrestore(&sclp_lock, flags);
263 reg->receiver_fn(evbuf);
264 spin_lock_irqsave(&sclp_lock, flags);
265 } else if (reg == NULL)
268 spin_unlock_irqrestore(&sclp_lock, flags);
272 /* Read event data request callback. */
274 sclp_read_cb(struct sclp_req *req, void *data)
277 struct sccb_header *sccb;
279 sccb = (struct sccb_header *) req->sccb;
280 if (req->status == SCLP_REQ_DONE && (sccb->response_code == 0x20 ||
281 sccb->response_code == 0x220))
282 sclp_dispatch_evbufs(sccb);
283 spin_lock_irqsave(&sclp_lock, flags);
284 sclp_reading_state = sclp_reading_state_idle;
285 spin_unlock_irqrestore(&sclp_lock, flags);
288 /* Prepare read event data request. Called while sclp_lock is locked. */
290 __sclp_make_read_req(void)
292 struct sccb_header *sccb;
294 sccb = (struct sccb_header *) sclp_read_sccb;
296 memset(&sclp_read_req, 0, sizeof(struct sclp_req));
297 sclp_read_req.command = SCLP_CMDW_READDATA;
298 sclp_read_req.status = SCLP_REQ_QUEUED;
299 sclp_read_req.start_count = 0;
300 sclp_read_req.callback = sclp_read_cb;
301 sclp_read_req.sccb = sccb;
302 sccb->length = PAGE_SIZE;
303 sccb->function_code = 0;
304 sccb->control_mask[2] = 0x80;
307 /* Search request list for request with matching sccb. Return request if found,
308 * NULL otherwise. Called while sclp_lock is locked. */
309 static inline struct sclp_req *
310 __sclp_find_req(u32 sccb)
313 struct sclp_req *req;
315 list_for_each(l, &sclp_req_queue) {
316 req = list_entry(l, struct sclp_req, list);
317 if (sccb == (u32) (addr_t) req->sccb)
323 /* Handler for external interruption. Perform request post-processing.
324 * Prepare read event data request if necessary. Start processing of next
325 * request on queue. */
327 sclp_interrupt_handler(struct pt_regs *regs, __u16 code)
329 struct sclp_req *req;
333 spin_lock(&sclp_lock);
334 finished_sccb = S390_lowcore.ext_params & 0xfffffff8;
335 evbuf_pending = S390_lowcore.ext_params & 0x3;
337 req = __sclp_find_req(finished_sccb);
339 /* Request post-processing */
340 list_del(&req->list);
341 req->status = SCLP_REQ_DONE;
343 spin_unlock(&sclp_lock);
344 req->callback(req, req->callback_data);
345 spin_lock(&sclp_lock);
348 sclp_running_state = sclp_running_state_idle;
350 if (evbuf_pending && sclp_receive_mask != 0 &&
351 sclp_reading_state == sclp_reading_state_idle &&
352 sclp_activation_state == sclp_activation_state_active ) {
353 sclp_reading_state = sclp_reading_state_reading;
354 __sclp_make_read_req();
355 /* Add request to head of queue */
356 list_add(&sclp_read_req.list, &sclp_req_queue);
358 spin_unlock(&sclp_lock);
359 sclp_process_queue();
362 /* Convert interval in jiffies to TOD ticks. */
364 sclp_tod_from_jiffies(unsigned long jiffies)
366 return (u64) (jiffies / HZ) << 32;
369 /* Wait until a currently running request finished. Note: while this function
370 * is running, no timers are served on the calling CPU. */
375 unsigned long cr0, cr0_sync;
378 /* We'll be disabling timer interrupts, so we need a custom timeout
381 if (timer_pending(&sclp_request_timer)) {
382 /* Get timeout TOD value */
383 timeout = get_clock() +
384 sclp_tod_from_jiffies(sclp_request_timer.expires -
387 local_irq_save(flags);
388 /* Prevent bottom half from executing once we force interrupts open */
390 /* Enable service-signal interruption, disable timer interrupts */
392 __ctl_store(cr0, 0, 0);
394 cr0_sync |= 0x00000200;
395 cr0_sync &= 0xFFFFF3AC;
396 __ctl_load(cr0_sync, 0, 0);
397 __raw_local_irq_stosm(0x01);
398 /* Loop until driver state indicates finished request */
399 while (sclp_running_state != sclp_running_state_idle) {
400 /* Check for expired request timer */
401 if (timer_pending(&sclp_request_timer) &&
402 get_clock() > timeout &&
403 del_timer(&sclp_request_timer))
404 sclp_request_timer.function(sclp_request_timer.data);
409 __ctl_load(cr0, 0, 0);
411 local_irq_restore(flags);
414 EXPORT_SYMBOL(sclp_sync_wait);
416 /* Dispatch changes in send and receive mask to registered listeners. */
418 sclp_dispatch_state_change(void)
421 struct sclp_register *reg;
423 sccb_mask_t receive_mask;
424 sccb_mask_t send_mask;
427 spin_lock_irqsave(&sclp_lock, flags);
429 list_for_each(l, &sclp_reg_list) {
430 reg = list_entry(l, struct sclp_register, list);
431 receive_mask = reg->receive_mask & sclp_receive_mask;
432 send_mask = reg->send_mask & sclp_send_mask;
433 if (reg->sclp_receive_mask != receive_mask ||
434 reg->sclp_send_mask != send_mask) {
435 reg->sclp_receive_mask = receive_mask;
436 reg->sclp_send_mask = send_mask;
441 spin_unlock_irqrestore(&sclp_lock, flags);
442 if (reg && reg->state_change_fn)
443 reg->state_change_fn(reg);
447 struct sclp_statechangebuf {
448 struct evbuf_header header;
449 u8 validity_sclp_active_facility_mask : 1;
450 u8 validity_sclp_receive_mask : 1;
451 u8 validity_sclp_send_mask : 1;
452 u8 validity_read_data_function_mask : 1;
455 u64 sclp_active_facility_mask;
456 sccb_mask_t sclp_receive_mask;
457 sccb_mask_t sclp_send_mask;
458 u32 read_data_function_mask;
459 } __attribute__((packed));
462 /* State change event callback. Inform listeners of changes. */
464 sclp_state_change_cb(struct evbuf_header *evbuf)
467 struct sclp_statechangebuf *scbuf;
469 scbuf = (struct sclp_statechangebuf *) evbuf;
470 if (scbuf->mask_length != sizeof(sccb_mask_t))
472 spin_lock_irqsave(&sclp_lock, flags);
473 if (scbuf->validity_sclp_receive_mask)
474 sclp_receive_mask = scbuf->sclp_receive_mask;
475 if (scbuf->validity_sclp_send_mask)
476 sclp_send_mask = scbuf->sclp_send_mask;
477 spin_unlock_irqrestore(&sclp_lock, flags);
478 sclp_dispatch_state_change();
481 static struct sclp_register sclp_state_change_event = {
482 .receive_mask = EvTyp_StateChange_Mask,
483 .receiver_fn = sclp_state_change_cb
486 /* Calculate receive and send mask of currently registered listeners.
487 * Called while sclp_lock is locked. */
489 __sclp_get_mask(sccb_mask_t *receive_mask, sccb_mask_t *send_mask)
492 struct sclp_register *t;
496 list_for_each(l, &sclp_reg_list) {
497 t = list_entry(l, struct sclp_register, list);
498 *receive_mask |= t->receive_mask;
499 *send_mask |= t->send_mask;
503 /* Register event listener. Return 0 on success, non-zero otherwise. */
505 sclp_register(struct sclp_register *reg)
508 sccb_mask_t receive_mask;
509 sccb_mask_t send_mask;
515 spin_lock_irqsave(&sclp_lock, flags);
516 /* Check event mask for collisions */
517 __sclp_get_mask(&receive_mask, &send_mask);
518 if (reg->receive_mask & receive_mask || reg->send_mask & send_mask) {
519 spin_unlock_irqrestore(&sclp_lock, flags);
522 /* Trigger initial state change callback */
523 reg->sclp_receive_mask = 0;
524 reg->sclp_send_mask = 0;
525 list_add(®->list, &sclp_reg_list);
526 spin_unlock_irqrestore(&sclp_lock, flags);
527 rc = sclp_init_mask(1);
529 spin_lock_irqsave(&sclp_lock, flags);
530 list_del(®->list);
531 spin_unlock_irqrestore(&sclp_lock, flags);
536 EXPORT_SYMBOL(sclp_register);
538 /* Unregister event listener. */
540 sclp_unregister(struct sclp_register *reg)
544 spin_lock_irqsave(&sclp_lock, flags);
545 list_del(®->list);
546 spin_unlock_irqrestore(&sclp_lock, flags);
550 EXPORT_SYMBOL(sclp_unregister);
552 /* Remove event buffers which are marked processed. Return the number of
553 * remaining event buffers. */
555 sclp_remove_processed(struct sccb_header *sccb)
557 struct evbuf_header *evbuf;
561 evbuf = (struct evbuf_header *) (sccb + 1);
563 remaining = sccb->length - sizeof(struct sccb_header);
564 while (remaining > 0) {
565 remaining -= evbuf->length;
566 if (evbuf->flags & 0x80) {
567 sccb->length -= evbuf->length;
568 memcpy(evbuf, (void *) ((addr_t) evbuf + evbuf->length),
572 evbuf = (struct evbuf_header *)
573 ((addr_t) evbuf + evbuf->length);
579 EXPORT_SYMBOL(sclp_remove_processed);
582 struct sccb_header header;
585 sccb_mask_t receive_mask;
586 sccb_mask_t send_mask;
587 sccb_mask_t sclp_send_mask;
588 sccb_mask_t sclp_receive_mask;
589 } __attribute__((packed));
591 /* Prepare init mask request. Called while sclp_lock is locked. */
593 __sclp_make_init_req(u32 receive_mask, u32 send_mask)
595 struct init_sccb *sccb;
597 sccb = (struct init_sccb *) sclp_init_sccb;
599 memset(&sclp_init_req, 0, sizeof(struct sclp_req));
600 sclp_init_req.command = SCLP_CMDW_WRITEMASK;
601 sclp_init_req.status = SCLP_REQ_FILLED;
602 sclp_init_req.start_count = 0;
603 sclp_init_req.callback = NULL;
604 sclp_init_req.callback_data = NULL;
605 sclp_init_req.sccb = sccb;
606 sccb->header.length = sizeof(struct init_sccb);
607 sccb->mask_length = sizeof(sccb_mask_t);
608 sccb->receive_mask = receive_mask;
609 sccb->send_mask = send_mask;
610 sccb->sclp_receive_mask = 0;
611 sccb->sclp_send_mask = 0;
614 /* Start init mask request. If calculate is non-zero, calculate the mask as
615 * requested by registered listeners. Use zero mask otherwise. Return 0 on
616 * success, non-zero otherwise. */
618 sclp_init_mask(int calculate)
621 struct init_sccb *sccb = (struct init_sccb *) sclp_init_sccb;
622 sccb_mask_t receive_mask;
623 sccb_mask_t send_mask;
628 spin_lock_irqsave(&sclp_lock, flags);
629 /* Check if interface is in appropriate state */
630 if (sclp_mask_state != sclp_mask_state_idle) {
631 spin_unlock_irqrestore(&sclp_lock, flags);
634 if (sclp_activation_state == sclp_activation_state_inactive) {
635 spin_unlock_irqrestore(&sclp_lock, flags);
638 sclp_mask_state = sclp_mask_state_initializing;
641 __sclp_get_mask(&receive_mask, &send_mask);
647 for (retry = 0; retry <= SCLP_MASK_RETRY; retry++) {
648 /* Prepare request */
649 __sclp_make_init_req(receive_mask, send_mask);
650 spin_unlock_irqrestore(&sclp_lock, flags);
651 if (sclp_add_request(&sclp_init_req)) {
652 /* Try again later */
653 wait = jiffies + SCLP_BUSY_INTERVAL * HZ;
654 while (time_before(jiffies, wait))
656 spin_lock_irqsave(&sclp_lock, flags);
659 while (sclp_init_req.status != SCLP_REQ_DONE &&
660 sclp_init_req.status != SCLP_REQ_FAILED)
662 spin_lock_irqsave(&sclp_lock, flags);
663 if (sclp_init_req.status == SCLP_REQ_DONE &&
664 sccb->header.response_code == 0x20) {
665 /* Successful request */
667 sclp_receive_mask = sccb->sclp_receive_mask;
668 sclp_send_mask = sccb->sclp_send_mask;
670 sclp_receive_mask = 0;
673 spin_unlock_irqrestore(&sclp_lock, flags);
674 sclp_dispatch_state_change();
675 spin_lock_irqsave(&sclp_lock, flags);
680 sclp_mask_state = sclp_mask_state_idle;
681 spin_unlock_irqrestore(&sclp_lock, flags);
685 /* Deactivate SCLP interface. On success, new requests will be rejected,
686 * events will no longer be dispatched. Return 0 on success, non-zero
689 sclp_deactivate(void)
694 spin_lock_irqsave(&sclp_lock, flags);
695 /* Deactivate can only be called when active */
696 if (sclp_activation_state != sclp_activation_state_active) {
697 spin_unlock_irqrestore(&sclp_lock, flags);
700 sclp_activation_state = sclp_activation_state_deactivating;
701 spin_unlock_irqrestore(&sclp_lock, flags);
702 rc = sclp_init_mask(0);
703 spin_lock_irqsave(&sclp_lock, flags);
705 sclp_activation_state = sclp_activation_state_inactive;
707 sclp_activation_state = sclp_activation_state_active;
708 spin_unlock_irqrestore(&sclp_lock, flags);
712 EXPORT_SYMBOL(sclp_deactivate);
714 /* Reactivate SCLP interface after sclp_deactivate. On success, new
715 * requests will be accepted, events will be dispatched again. Return 0 on
716 * success, non-zero otherwise. */
718 sclp_reactivate(void)
723 spin_lock_irqsave(&sclp_lock, flags);
724 /* Reactivate can only be called when inactive */
725 if (sclp_activation_state != sclp_activation_state_inactive) {
726 spin_unlock_irqrestore(&sclp_lock, flags);
729 sclp_activation_state = sclp_activation_state_activating;
730 spin_unlock_irqrestore(&sclp_lock, flags);
731 rc = sclp_init_mask(1);
732 spin_lock_irqsave(&sclp_lock, flags);
734 sclp_activation_state = sclp_activation_state_active;
736 sclp_activation_state = sclp_activation_state_inactive;
737 spin_unlock_irqrestore(&sclp_lock, flags);
741 EXPORT_SYMBOL(sclp_reactivate);
743 /* Handler for external interruption used during initialization. Modify
744 * request state to done. */
746 sclp_check_handler(struct pt_regs *regs, __u16 code)
750 finished_sccb = S390_lowcore.ext_params & 0xfffffff8;
751 /* Is this the interrupt we are waiting for? */
752 if (finished_sccb == 0)
754 if (finished_sccb != (u32) (addr_t) sclp_init_sccb) {
755 printk(KERN_WARNING SCLP_HEADER "unsolicited interrupt "
756 "for buffer at 0x%x\n", finished_sccb);
759 spin_lock(&sclp_lock);
760 if (sclp_running_state == sclp_running_state_running) {
761 sclp_init_req.status = SCLP_REQ_DONE;
762 sclp_running_state = sclp_running_state_idle;
764 spin_unlock(&sclp_lock);
767 /* Initial init mask request timed out. Modify request state to failed. */
769 sclp_check_timeout(unsigned long data)
773 spin_lock_irqsave(&sclp_lock, flags);
774 if (sclp_running_state == sclp_running_state_running) {
775 sclp_init_req.status = SCLP_REQ_FAILED;
776 sclp_running_state = sclp_running_state_idle;
778 spin_unlock_irqrestore(&sclp_lock, flags);
781 /* Perform a check of the SCLP interface. Return zero if the interface is
782 * available and there are no pending requests from a previous instance.
783 * Return non-zero otherwise. */
785 sclp_check_interface(void)
787 struct init_sccb *sccb;
792 spin_lock_irqsave(&sclp_lock, flags);
793 /* Prepare init mask command */
794 rc = register_early_external_interrupt(0x2401, sclp_check_handler,
797 spin_unlock_irqrestore(&sclp_lock, flags);
800 for (retry = 0; retry <= SCLP_INIT_RETRY; retry++) {
801 __sclp_make_init_req(0, 0);
802 sccb = (struct init_sccb *) sclp_init_req.sccb;
803 rc = service_call(sclp_init_req.command, sccb);
806 sclp_init_req.status = SCLP_REQ_RUNNING;
807 sclp_running_state = sclp_running_state_running;
808 __sclp_set_request_timer(SCLP_RETRY_INTERVAL * HZ,
809 sclp_check_timeout, 0);
810 spin_unlock_irqrestore(&sclp_lock, flags);
811 /* Enable service-signal interruption - needs to happen
812 * with IRQs enabled. */
814 /* Wait for signal from interrupt or timeout */
816 /* Disable service-signal interruption - needs to happen
817 * with IRQs enabled. */
819 spin_lock_irqsave(&sclp_lock, flags);
820 del_timer(&sclp_request_timer);
821 if (sclp_init_req.status == SCLP_REQ_DONE &&
822 sccb->header.response_code == 0x20) {
828 unregister_early_external_interrupt(0x2401, sclp_check_handler,
830 spin_unlock_irqrestore(&sclp_lock, flags);
834 /* Reboot event handler. Reset send and receive mask to prevent pending SCLP
835 * events from interfering with rebooted system. */
837 sclp_reboot_event(struct notifier_block *this, unsigned long event, void *ptr)
843 static struct notifier_block sclp_reboot_notifier = {
844 .notifier_call = sclp_reboot_event
847 /* Initialize SCLP driver. Return zero if driver is operational, non-zero
855 if (!MACHINE_HAS_SCLP)
857 spin_lock_irqsave(&sclp_lock, flags);
858 /* Check for previous or running initialization */
859 if (sclp_init_state != sclp_init_state_uninitialized) {
860 spin_unlock_irqrestore(&sclp_lock, flags);
863 sclp_init_state = sclp_init_state_initializing;
864 /* Set up variables */
865 INIT_LIST_HEAD(&sclp_req_queue);
866 INIT_LIST_HEAD(&sclp_reg_list);
867 list_add(&sclp_state_change_event.list, &sclp_reg_list);
868 init_timer(&sclp_request_timer);
869 /* Check interface */
870 spin_unlock_irqrestore(&sclp_lock, flags);
871 rc = sclp_check_interface();
872 spin_lock_irqsave(&sclp_lock, flags);
874 sclp_init_state = sclp_init_state_uninitialized;
875 spin_unlock_irqrestore(&sclp_lock, flags);
878 /* Register reboot handler */
879 rc = register_reboot_notifier(&sclp_reboot_notifier);
881 sclp_init_state = sclp_init_state_uninitialized;
882 spin_unlock_irqrestore(&sclp_lock, flags);
885 /* Register interrupt handler */
886 rc = register_early_external_interrupt(0x2401, sclp_interrupt_handler,
889 unregister_reboot_notifier(&sclp_reboot_notifier);
890 sclp_init_state = sclp_init_state_uninitialized;
891 spin_unlock_irqrestore(&sclp_lock, flags);
894 sclp_init_state = sclp_init_state_initialized;
895 spin_unlock_irqrestore(&sclp_lock, flags);
896 /* Enable service-signal external interruption - needs to happen with