diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 20:54:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 20:54:03 -0500 |
commit | 81ec44a6c69342fec1b1140c60a604027e429f69 (patch) | |
tree | ee6bec8a94ef28e111bf766cf4b7a9366cb4f7c1 /drivers/s390/char | |
parent | 48a732dfaa77a4dfec803aa8f248373998704f76 (diff) | |
parent | e80cfc31d872b6b85b8966bce6ba80bee401a7dd (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 update from Martin Schwidefsky:
"The most prominent change in this patch set is the software dirty bit
patch for s390. It removes __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY and
the page_test_and_clear_dirty primitive which makes the common memory
management code a bit less obscure.
Heiko fixed most of the PCI related fallout, more often than not
missing GENERIC_HARDIRQS dependencies. Notable is one of the 3270
patches which adds an export to tty_io to be able to resize a tty.
The rest is the usual bunch of cleanups and bug fixes."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (42 commits)
s390/module: Add missing R_390_NONE relocation type
drivers/gpio: add missing GENERIC_HARDIRQ dependency
drivers/input: add couple of missing GENERIC_HARDIRQS dependencies
s390/cleanup: rename SPP to LPP
s390/mm: implement software dirty bits
s390/mm: Fix crst upgrade of mmap with MAP_FIXED
s390/linker skript: discard exit.data at runtime
drivers/media: add missing GENERIC_HARDIRQS dependency
s390/bpf,jit: add vlan tag support
drivers/net,AT91RM9200: add missing GENERIC_HARDIRQS dependency
iucv: fix kernel panic at reboot
s390/Kconfig: sort list of arch selected config options
phylib: remove !S390 dependeny from Kconfig
uio: remove !S390 dependency from Kconfig
dasd: fix sysfs cleanup in dasd_generic_remove
s390/pci: fix hotplug module init
s390/pci: cleanup clp page allocation
s390/pci: cleanup clp inline assembly
s390/perf: cpum_cf: fallback to software sampling events
s390/mm: provide PAGE_SHARED define
...
Diffstat (limited to 'drivers/s390/char')
-rw-r--r-- | drivers/s390/char/fs3270.c | 29 | ||||
-rw-r--r-- | drivers/s390/char/raw3270.c | 611 | ||||
-rw-r--r-- | drivers/s390/char/raw3270.h | 12 | ||||
-rw-r--r-- | drivers/s390/char/sclp.c | 4 | ||||
-rw-r--r-- | drivers/s390/char/sclp_cmd.c | 10 | ||||
-rw-r--r-- | drivers/s390/char/tty3270.c | 187 | ||||
-rw-r--r-- | drivers/s390/char/zcore.c | 64 |
7 files changed, 501 insertions, 416 deletions
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c index 911704571b9c..230697aac94b 100644 --- a/drivers/s390/char/fs3270.c +++ b/drivers/s390/char/fs3270.c | |||
@@ -443,7 +443,7 @@ fs3270_open(struct inode *inode, struct file *filp) | |||
443 | tty_kref_put(tty); | 443 | tty_kref_put(tty); |
444 | return -ENODEV; | 444 | return -ENODEV; |
445 | } | 445 | } |
446 | minor = tty->index + RAW3270_FIRSTMINOR; | 446 | minor = tty->index; |
447 | tty_kref_put(tty); | 447 | tty_kref_put(tty); |
448 | } | 448 | } |
449 | mutex_lock(&fs3270_mutex); | 449 | mutex_lock(&fs3270_mutex); |
@@ -524,6 +524,25 @@ static const struct file_operations fs3270_fops = { | |||
524 | .llseek = no_llseek, | 524 | .llseek = no_llseek, |
525 | }; | 525 | }; |
526 | 526 | ||
527 | void fs3270_create_cb(int minor) | ||
528 | { | ||
529 | __register_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub", &fs3270_fops); | ||
530 | device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, minor), | ||
531 | NULL, "3270/tub%d", minor); | ||
532 | } | ||
533 | |||
534 | void fs3270_destroy_cb(int minor) | ||
535 | { | ||
536 | device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, minor)); | ||
537 | __unregister_chrdev(IBM_FS3270_MAJOR, minor, 1, "tub"); | ||
538 | } | ||
539 | |||
540 | struct raw3270_notifier fs3270_notifier = | ||
541 | { | ||
542 | .create = fs3270_create_cb, | ||
543 | .destroy = fs3270_destroy_cb, | ||
544 | }; | ||
545 | |||
527 | /* | 546 | /* |
528 | * 3270 fullscreen driver initialization. | 547 | * 3270 fullscreen driver initialization. |
529 | */ | 548 | */ |
@@ -532,16 +551,20 @@ fs3270_init(void) | |||
532 | { | 551 | { |
533 | int rc; | 552 | int rc; |
534 | 553 | ||
535 | rc = register_chrdev(IBM_FS3270_MAJOR, "fs3270", &fs3270_fops); | 554 | rc = __register_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270", &fs3270_fops); |
536 | if (rc) | 555 | if (rc) |
537 | return rc; | 556 | return rc; |
557 | device_create(class3270, NULL, MKDEV(IBM_FS3270_MAJOR, 0), | ||
558 | NULL, "3270/tub"); | ||
559 | raw3270_register_notifier(&fs3270_notifier); | ||
538 | return 0; | 560 | return 0; |
539 | } | 561 | } |
540 | 562 | ||
541 | static void __exit | 563 | static void __exit |
542 | fs3270_exit(void) | 564 | fs3270_exit(void) |
543 | { | 565 | { |
544 | unregister_chrdev(IBM_FS3270_MAJOR, "fs3270"); | 566 | raw3270_unregister_notifier(&fs3270_notifier); |
567 | __unregister_chrdev(IBM_FS3270_MAJOR, 0, 1, "fs3270"); | ||
545 | } | 568 | } |
546 | 569 | ||
547 | MODULE_LICENSE("GPL"); | 570 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c index 9a6c140c5f07..4c9030a5b9f2 100644 --- a/drivers/s390/char/raw3270.c +++ b/drivers/s390/char/raw3270.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/device.h> | 28 | #include <linux/device.h> |
29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
30 | 30 | ||
31 | static struct class *class3270; | 31 | struct class *class3270; |
32 | 32 | ||
33 | /* The main 3270 data structure. */ | 33 | /* The main 3270 data structure. */ |
34 | struct raw3270 { | 34 | struct raw3270 { |
@@ -37,6 +37,7 @@ struct raw3270 { | |||
37 | int minor; | 37 | int minor; |
38 | 38 | ||
39 | short model, rows, cols; | 39 | short model, rows, cols; |
40 | unsigned int state; | ||
40 | unsigned long flags; | 41 | unsigned long flags; |
41 | 42 | ||
42 | struct list_head req_queue; /* Request queue. */ | 43 | struct list_head req_queue; /* Request queue. */ |
@@ -46,20 +47,26 @@ struct raw3270 { | |||
46 | struct timer_list timer; /* Device timer. */ | 47 | struct timer_list timer; /* Device timer. */ |
47 | 48 | ||
48 | unsigned char *ascebc; /* ascii -> ebcdic table */ | 49 | unsigned char *ascebc; /* ascii -> ebcdic table */ |
49 | struct device *clttydev; /* 3270-class tty device ptr */ | ||
50 | struct device *cltubdev; /* 3270-class tub device ptr */ | ||
51 | 50 | ||
52 | struct raw3270_request init_request; | 51 | struct raw3270_view init_view; |
52 | struct raw3270_request init_reset; | ||
53 | struct raw3270_request init_readpart; | ||
54 | struct raw3270_request init_readmod; | ||
53 | unsigned char init_data[256]; | 55 | unsigned char init_data[256]; |
54 | }; | 56 | }; |
55 | 57 | ||
58 | /* raw3270->state */ | ||
59 | #define RAW3270_STATE_INIT 0 /* Initial state */ | ||
60 | #define RAW3270_STATE_RESET 1 /* Reset command is pending */ | ||
61 | #define RAW3270_STATE_W4ATTN 2 /* Wait for attention interrupt */ | ||
62 | #define RAW3270_STATE_READMOD 3 /* Read partition is pending */ | ||
63 | #define RAW3270_STATE_READY 4 /* Device is usable by views */ | ||
64 | |||
56 | /* raw3270->flags */ | 65 | /* raw3270->flags */ |
57 | #define RAW3270_FLAGS_14BITADDR 0 /* 14-bit buffer addresses */ | 66 | #define RAW3270_FLAGS_14BITADDR 0 /* 14-bit buffer addresses */ |
58 | #define RAW3270_FLAGS_BUSY 1 /* Device busy, leave it alone */ | 67 | #define RAW3270_FLAGS_BUSY 1 /* Device busy, leave it alone */ |
59 | #define RAW3270_FLAGS_ATTN 2 /* Device sent an ATTN interrupt */ | 68 | #define RAW3270_FLAGS_CONSOLE 2 /* Device is the console. */ |
60 | #define RAW3270_FLAGS_READY 4 /* Device is useable by views */ | 69 | #define RAW3270_FLAGS_FROZEN 3 /* set if 3270 is frozen for suspend */ |
61 | #define RAW3270_FLAGS_CONSOLE 8 /* Device is the console. */ | ||
62 | #define RAW3270_FLAGS_FROZEN 16 /* set if 3270 is frozen for suspend */ | ||
63 | 70 | ||
64 | /* Semaphore to protect global data of raw3270 (devices, views, etc). */ | 71 | /* Semaphore to protect global data of raw3270 (devices, views, etc). */ |
65 | static DEFINE_MUTEX(raw3270_mutex); | 72 | static DEFINE_MUTEX(raw3270_mutex); |
@@ -97,6 +104,17 @@ static unsigned char raw3270_ebcgraf[64] = { | |||
97 | 0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f | 104 | 0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f |
98 | }; | 105 | }; |
99 | 106 | ||
107 | static inline int raw3270_state_ready(struct raw3270 *rp) | ||
108 | { | ||
109 | return rp->state == RAW3270_STATE_READY; | ||
110 | } | ||
111 | |||
112 | static inline int raw3270_state_final(struct raw3270 *rp) | ||
113 | { | ||
114 | return rp->state == RAW3270_STATE_INIT || | ||
115 | rp->state == RAW3270_STATE_READY; | ||
116 | } | ||
117 | |||
100 | void | 118 | void |
101 | raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr) | 119 | raw3270_buffer_address(struct raw3270 *rp, char *cp, unsigned short addr) |
102 | { | 120 | { |
@@ -214,7 +232,7 @@ raw3270_request_set_idal(struct raw3270_request *rq, struct idal_buffer *ib) | |||
214 | * Stop running ccw. | 232 | * Stop running ccw. |
215 | */ | 233 | */ |
216 | static int | 234 | static int |
217 | raw3270_halt_io_nolock(struct raw3270 *rp, struct raw3270_request *rq) | 235 | __raw3270_halt_io(struct raw3270 *rp, struct raw3270_request *rq) |
218 | { | 236 | { |
219 | int retries; | 237 | int retries; |
220 | int rc; | 238 | int rc; |
@@ -233,18 +251,6 @@ raw3270_halt_io_nolock(struct raw3270 *rp, struct raw3270_request *rq) | |||
233 | return rc; | 251 | return rc; |
234 | } | 252 | } |
235 | 253 | ||
236 | static int | ||
237 | raw3270_halt_io(struct raw3270 *rp, struct raw3270_request *rq) | ||
238 | { | ||
239 | unsigned long flags; | ||
240 | int rc; | ||
241 | |||
242 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | ||
243 | rc = raw3270_halt_io_nolock(rp, rq); | ||
244 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | ||
245 | return rc; | ||
246 | } | ||
247 | |||
248 | /* | 254 | /* |
249 | * Add the request to the request queue, try to start it if the | 255 | * Add the request to the request queue, try to start it if the |
250 | * 3270 device is idle. Return without waiting for end of i/o. | 256 | * 3270 device is idle. Return without waiting for end of i/o. |
@@ -281,8 +287,8 @@ raw3270_start(struct raw3270_view *view, struct raw3270_request *rq) | |||
281 | if (!rp || rp->view != view || | 287 | if (!rp || rp->view != view || |
282 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 288 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
283 | rc = -EACCES; | 289 | rc = -EACCES; |
284 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 290 | else if (!raw3270_state_ready(rp)) |
285 | rc = -ENODEV; | 291 | rc = -EBUSY; |
286 | else | 292 | else |
287 | rc = __raw3270_start(rp, view, rq); | 293 | rc = __raw3270_start(rp, view, rq); |
288 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); | 294 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); |
@@ -299,8 +305,8 @@ raw3270_start_locked(struct raw3270_view *view, struct raw3270_request *rq) | |||
299 | if (!rp || rp->view != view || | 305 | if (!rp || rp->view != view || |
300 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 306 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
301 | rc = -EACCES; | 307 | rc = -EACCES; |
302 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 308 | else if (!raw3270_state_ready(rp)) |
303 | rc = -ENODEV; | 309 | rc = -EBUSY; |
304 | else | 310 | else |
305 | rc = __raw3270_start(rp, view, rq); | 311 | rc = __raw3270_start(rp, view, rq); |
306 | return rc; | 312 | return rc; |
@@ -378,7 +384,7 @@ raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | |||
378 | case RAW3270_IO_STOP: | 384 | case RAW3270_IO_STOP: |
379 | if (!rq) | 385 | if (!rq) |
380 | break; | 386 | break; |
381 | raw3270_halt_io_nolock(rp, rq); | 387 | __raw3270_halt_io(rp, rq); |
382 | rq->rc = -EIO; | 388 | rq->rc = -EIO; |
383 | break; | 389 | break; |
384 | default: | 390 | default: |
@@ -413,9 +419,14 @@ raw3270_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | |||
413 | } | 419 | } |
414 | 420 | ||
415 | /* | 421 | /* |
416 | * Size sensing. | 422 | * To determine the size of the 3270 device we need to do: |
423 | * 1) send a 'read partition' data stream to the device | ||
424 | * 2) wait for the attn interrupt that precedes the query reply | ||
425 | * 3) do a read modified to get the query reply | ||
426 | * To make things worse we have to cope with intervention | ||
427 | * required (3270 device switched to 'stand-by') and command | ||
428 | * rejects (old devices that can't do 'read partition'). | ||
417 | */ | 429 | */ |
418 | |||
419 | struct raw3270_ua { /* Query Reply structure for Usable Area */ | 430 | struct raw3270_ua { /* Query Reply structure for Usable Area */ |
420 | struct { /* Usable Area Query Reply Base */ | 431 | struct { /* Usable Area Query Reply Base */ |
421 | short l; /* Length of this structured field */ | 432 | short l; /* Length of this structured field */ |
@@ -451,117 +462,21 @@ struct raw3270_ua { /* Query Reply structure for Usable Area */ | |||
451 | } __attribute__ ((packed)) aua; | 462 | } __attribute__ ((packed)) aua; |
452 | } __attribute__ ((packed)); | 463 | } __attribute__ ((packed)); |
453 | 464 | ||
454 | static struct diag210 raw3270_init_diag210; | ||
455 | static DEFINE_MUTEX(raw3270_init_mutex); | ||
456 | |||
457 | static int | ||
458 | raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq, | ||
459 | struct irb *irb) | ||
460 | { | ||
461 | /* | ||
462 | * Unit-Check Processing: | ||
463 | * Expect Command Reject or Intervention Required. | ||
464 | */ | ||
465 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
466 | /* Request finished abnormally. */ | ||
467 | if (irb->ecw[0] & SNS0_INTERVENTION_REQ) { | ||
468 | set_bit(RAW3270_FLAGS_BUSY, &view->dev->flags); | ||
469 | return RAW3270_IO_BUSY; | ||
470 | } | ||
471 | } | ||
472 | if (rq) { | ||
473 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
474 | if (irb->ecw[0] & SNS0_CMD_REJECT) | ||
475 | rq->rc = -EOPNOTSUPP; | ||
476 | else | ||
477 | rq->rc = -EIO; | ||
478 | } else | ||
479 | /* Request finished normally. Copy residual count. */ | ||
480 | rq->rescnt = irb->scsw.cmd.count; | ||
481 | } | ||
482 | if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { | ||
483 | set_bit(RAW3270_FLAGS_ATTN, &view->dev->flags); | ||
484 | wake_up(&raw3270_wait_queue); | ||
485 | } | ||
486 | return RAW3270_IO_DONE; | ||
487 | } | ||
488 | |||
489 | static struct raw3270_fn raw3270_init_fn = { | ||
490 | .intv = raw3270_init_irq | ||
491 | }; | ||
492 | |||
493 | static struct raw3270_view raw3270_init_view = { | ||
494 | .fn = &raw3270_init_fn | ||
495 | }; | ||
496 | |||
497 | /* | ||
498 | * raw3270_wait/raw3270_wait_interruptible/__raw3270_wakeup | ||
499 | * Wait for end of request. The request must have been started | ||
500 | * with raw3270_start, rc = 0. The device lock may NOT have been | ||
501 | * released between calling raw3270_start and raw3270_wait. | ||
502 | */ | ||
503 | static void | 465 | static void |
504 | raw3270_wake_init(struct raw3270_request *rq, void *data) | 466 | raw3270_size_device_vm(struct raw3270 *rp) |
505 | { | ||
506 | wake_up((wait_queue_head_t *) data); | ||
507 | } | ||
508 | |||
509 | /* | ||
510 | * Special wait function that can cope with console initialization. | ||
511 | */ | ||
512 | static int | ||
513 | raw3270_start_init(struct raw3270 *rp, struct raw3270_view *view, | ||
514 | struct raw3270_request *rq) | ||
515 | { | ||
516 | unsigned long flags; | ||
517 | int rc; | ||
518 | |||
519 | #ifdef CONFIG_TN3270_CONSOLE | ||
520 | if (raw3270_registered == 0) { | ||
521 | spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags); | ||
522 | rq->callback = NULL; | ||
523 | rc = __raw3270_start(rp, view, rq); | ||
524 | if (rc == 0) | ||
525 | while (!raw3270_request_final(rq)) { | ||
526 | wait_cons_dev(); | ||
527 | barrier(); | ||
528 | } | ||
529 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); | ||
530 | return rq->rc; | ||
531 | } | ||
532 | #endif | ||
533 | rq->callback = raw3270_wake_init; | ||
534 | rq->callback_data = &raw3270_wait_queue; | ||
535 | spin_lock_irqsave(get_ccwdev_lock(view->dev->cdev), flags); | ||
536 | rc = __raw3270_start(rp, view, rq); | ||
537 | spin_unlock_irqrestore(get_ccwdev_lock(view->dev->cdev), flags); | ||
538 | if (rc) | ||
539 | return rc; | ||
540 | /* Now wait for the completion. */ | ||
541 | rc = wait_event_interruptible(raw3270_wait_queue, | ||
542 | raw3270_request_final(rq)); | ||
543 | if (rc == -ERESTARTSYS) { /* Interrupted by a signal. */ | ||
544 | raw3270_halt_io(view->dev, rq); | ||
545 | /* No wait for the halt to complete. */ | ||
546 | wait_event(raw3270_wait_queue, raw3270_request_final(rq)); | ||
547 | return -ERESTARTSYS; | ||
548 | } | ||
549 | return rq->rc; | ||
550 | } | ||
551 | |||
552 | static int | ||
553 | __raw3270_size_device_vm(struct raw3270 *rp) | ||
554 | { | 467 | { |
555 | int rc, model; | 468 | int rc, model; |
556 | struct ccw_dev_id dev_id; | 469 | struct ccw_dev_id dev_id; |
470 | struct diag210 diag_data; | ||
557 | 471 | ||
558 | ccw_device_get_id(rp->cdev, &dev_id); | 472 | ccw_device_get_id(rp->cdev, &dev_id); |
559 | raw3270_init_diag210.vrdcdvno = dev_id.devno; | 473 | diag_data.vrdcdvno = dev_id.devno; |
560 | raw3270_init_diag210.vrdclen = sizeof(struct diag210); | 474 | diag_data.vrdclen = sizeof(struct diag210); |
561 | rc = diag210(&raw3270_init_diag210); | 475 | rc = diag210(&diag_data); |
562 | if (rc) | 476 | model = diag_data.vrdccrmd; |
563 | return rc; | 477 | /* Use default model 2 if the size could not be detected */ |
564 | model = raw3270_init_diag210.vrdccrmd; | 478 | if (rc || model < 2 || model > 5) |
479 | model = 2; | ||
565 | switch (model) { | 480 | switch (model) { |
566 | case 2: | 481 | case 2: |
567 | rp->model = model; | 482 | rp->model = model; |
@@ -583,77 +498,25 @@ __raw3270_size_device_vm(struct raw3270 *rp) | |||
583 | rp->rows = 27; | 498 | rp->rows = 27; |
584 | rp->cols = 132; | 499 | rp->cols = 132; |
585 | break; | 500 | break; |
586 | default: | ||
587 | rc = -EOPNOTSUPP; | ||
588 | break; | ||
589 | } | 501 | } |
590 | return rc; | ||
591 | } | 502 | } |
592 | 503 | ||
593 | static int | 504 | static void |
594 | __raw3270_size_device(struct raw3270 *rp) | 505 | raw3270_size_device(struct raw3270 *rp) |
595 | { | 506 | { |
596 | static const unsigned char wbuf[] = | ||
597 | { 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 }; | ||
598 | struct raw3270_ua *uap; | 507 | struct raw3270_ua *uap; |
599 | int rc; | ||
600 | 508 | ||
601 | /* | ||
602 | * To determine the size of the 3270 device we need to do: | ||
603 | * 1) send a 'read partition' data stream to the device | ||
604 | * 2) wait for the attn interrupt that precedes the query reply | ||
605 | * 3) do a read modified to get the query reply | ||
606 | * To make things worse we have to cope with intervention | ||
607 | * required (3270 device switched to 'stand-by') and command | ||
608 | * rejects (old devices that can't do 'read partition'). | ||
609 | */ | ||
610 | memset(&rp->init_request, 0, sizeof(rp->init_request)); | ||
611 | memset(&rp->init_data, 0, 256); | ||
612 | /* Store 'read partition' data stream to init_data */ | ||
613 | memcpy(&rp->init_data, wbuf, sizeof(wbuf)); | ||
614 | INIT_LIST_HEAD(&rp->init_request.list); | ||
615 | rp->init_request.ccw.cmd_code = TC_WRITESF; | ||
616 | rp->init_request.ccw.flags = CCW_FLAG_SLI; | ||
617 | rp->init_request.ccw.count = sizeof(wbuf); | ||
618 | rp->init_request.ccw.cda = (__u32) __pa(&rp->init_data); | ||
619 | |||
620 | rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request); | ||
621 | if (rc) | ||
622 | /* Check error cases: -ERESTARTSYS, -EIO and -EOPNOTSUPP */ | ||
623 | return rc; | ||
624 | |||
625 | /* Wait for attention interrupt. */ | ||
626 | #ifdef CONFIG_TN3270_CONSOLE | ||
627 | if (raw3270_registered == 0) { | ||
628 | unsigned long flags; | ||
629 | |||
630 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | ||
631 | while (!test_and_clear_bit(RAW3270_FLAGS_ATTN, &rp->flags)) | ||
632 | wait_cons_dev(); | ||
633 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | ||
634 | } else | ||
635 | #endif | ||
636 | rc = wait_event_interruptible(raw3270_wait_queue, | ||
637 | test_and_clear_bit(RAW3270_FLAGS_ATTN, &rp->flags)); | ||
638 | if (rc) | ||
639 | return rc; | ||
640 | |||
641 | /* | ||
642 | * The device accepted the 'read partition' command. Now | ||
643 | * set up a read ccw and issue it. | ||
644 | */ | ||
645 | rp->init_request.ccw.cmd_code = TC_READMOD; | ||
646 | rp->init_request.ccw.flags = CCW_FLAG_SLI; | ||
647 | rp->init_request.ccw.count = sizeof(rp->init_data); | ||
648 | rp->init_request.ccw.cda = (__u32) __pa(rp->init_data); | ||
649 | rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request); | ||
650 | if (rc) | ||
651 | return rc; | ||
652 | /* Got a Query Reply */ | 509 | /* Got a Query Reply */ |
653 | uap = (struct raw3270_ua *) (rp->init_data + 1); | 510 | uap = (struct raw3270_ua *) (rp->init_data + 1); |
654 | /* Paranoia check. */ | 511 | /* Paranoia check. */ |
655 | if (rp->init_data[0] != 0x88 || uap->uab.qcode != 0x81) | 512 | if (rp->init_readmod.rc || rp->init_data[0] != 0x88 || |
656 | return -EOPNOTSUPP; | 513 | uap->uab.qcode != 0x81) { |
514 | /* Couldn't detect size. Use default model 2. */ | ||
515 | rp->model = 2; | ||
516 | rp->rows = 24; | ||
517 | rp->cols = 80; | ||
518 | return; | ||
519 | } | ||
657 | /* Copy rows/columns of default Usable Area */ | 520 | /* Copy rows/columns of default Usable Area */ |
658 | rp->rows = uap->uab.h; | 521 | rp->rows = uap->uab.h; |
659 | rp->cols = uap->uab.w; | 522 | rp->cols = uap->uab.w; |
@@ -666,66 +529,131 @@ __raw3270_size_device(struct raw3270 *rp) | |||
666 | rp->rows = uap->aua.hauai; | 529 | rp->rows = uap->aua.hauai; |
667 | rp->cols = uap->aua.wauai; | 530 | rp->cols = uap->aua.wauai; |
668 | } | 531 | } |
669 | return 0; | 532 | /* Try to find a model. */ |
533 | rp->model = 0; | ||
534 | if (rp->rows == 24 && rp->cols == 80) | ||
535 | rp->model = 2; | ||
536 | if (rp->rows == 32 && rp->cols == 80) | ||
537 | rp->model = 3; | ||
538 | if (rp->rows == 43 && rp->cols == 80) | ||
539 | rp->model = 4; | ||
540 | if (rp->rows == 27 && rp->cols == 132) | ||
541 | rp->model = 5; | ||
670 | } | 542 | } |
671 | 543 | ||
672 | static int | 544 | static void |
673 | raw3270_size_device(struct raw3270 *rp) | 545 | raw3270_size_device_done(struct raw3270 *rp) |
674 | { | 546 | { |
675 | int rc; | 547 | struct raw3270_view *view; |
676 | 548 | ||
677 | mutex_lock(&raw3270_init_mutex); | ||
678 | rp->view = &raw3270_init_view; | ||
679 | raw3270_init_view.dev = rp; | ||
680 | if (MACHINE_IS_VM) | ||
681 | rc = __raw3270_size_device_vm(rp); | ||
682 | else | ||
683 | rc = __raw3270_size_device(rp); | ||
684 | raw3270_init_view.dev = NULL; | ||
685 | rp->view = NULL; | 549 | rp->view = NULL; |
686 | mutex_unlock(&raw3270_init_mutex); | 550 | rp->state = RAW3270_STATE_READY; |
687 | if (rc == 0) { /* Found something. */ | 551 | /* Notify views about new size */ |
688 | /* Try to find a model. */ | 552 | list_for_each_entry(view, &rp->view_list, list) |
689 | rp->model = 0; | 553 | if (view->fn->resize) |
690 | if (rp->rows == 24 && rp->cols == 80) | 554 | view->fn->resize(view, rp->model, rp->rows, rp->cols); |
691 | rp->model = 2; | 555 | /* Setup processing done, now activate a view */ |
692 | if (rp->rows == 32 && rp->cols == 80) | 556 | list_for_each_entry(view, &rp->view_list, list) { |
693 | rp->model = 3; | 557 | rp->view = view; |
694 | if (rp->rows == 43 && rp->cols == 80) | 558 | if (view->fn->activate(view) == 0) |
695 | rp->model = 4; | 559 | break; |
696 | if (rp->rows == 27 && rp->cols == 132) | 560 | rp->view = NULL; |
697 | rp->model = 5; | ||
698 | } else { | ||
699 | /* Couldn't detect size. Use default model 2. */ | ||
700 | rp->model = 2; | ||
701 | rp->rows = 24; | ||
702 | rp->cols = 80; | ||
703 | return 0; | ||
704 | } | 561 | } |
705 | return rc; | 562 | } |
563 | |||
564 | static void | ||
565 | raw3270_read_modified_cb(struct raw3270_request *rq, void *data) | ||
566 | { | ||
567 | struct raw3270 *rp = rq->view->dev; | ||
568 | |||
569 | raw3270_size_device(rp); | ||
570 | raw3270_size_device_done(rp); | ||
571 | } | ||
572 | |||
573 | static void | ||
574 | raw3270_read_modified(struct raw3270 *rp) | ||
575 | { | ||
576 | if (rp->state != RAW3270_STATE_W4ATTN) | ||
577 | return; | ||
578 | /* Use 'read modified' to get the result of a read partition. */ | ||
579 | memset(&rp->init_readmod, 0, sizeof(rp->init_readmod)); | ||
580 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | ||
581 | rp->init_readmod.ccw.cmd_code = TC_READMOD; | ||
582 | rp->init_readmod.ccw.flags = CCW_FLAG_SLI; | ||
583 | rp->init_readmod.ccw.count = sizeof(rp->init_data); | ||
584 | rp->init_readmod.ccw.cda = (__u32) __pa(rp->init_data); | ||
585 | rp->init_readmod.callback = raw3270_read_modified_cb; | ||
586 | rp->state = RAW3270_STATE_READMOD; | ||
587 | raw3270_start_irq(&rp->init_view, &rp->init_readmod); | ||
588 | } | ||
589 | |||
590 | static void | ||
591 | raw3270_writesf_readpart(struct raw3270 *rp) | ||
592 | { | ||
593 | static const unsigned char wbuf[] = | ||
594 | { 0x00, 0x07, 0x01, 0xff, 0x03, 0x00, 0x81 }; | ||
595 | |||
596 | /* Store 'read partition' data stream to init_data */ | ||
597 | memset(&rp->init_readpart, 0, sizeof(rp->init_readpart)); | ||
598 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | ||
599 | memcpy(&rp->init_data, wbuf, sizeof(wbuf)); | ||
600 | rp->init_readpart.ccw.cmd_code = TC_WRITESF; | ||
601 | rp->init_readpart.ccw.flags = CCW_FLAG_SLI; | ||
602 | rp->init_readpart.ccw.count = sizeof(wbuf); | ||
603 | rp->init_readpart.ccw.cda = (__u32) __pa(&rp->init_data); | ||
604 | rp->state = RAW3270_STATE_W4ATTN; | ||
605 | raw3270_start_irq(&rp->init_view, &rp->init_readpart); | ||
606 | } | ||
607 | |||
608 | /* | ||
609 | * Device reset | ||
610 | */ | ||
611 | static void | ||
612 | raw3270_reset_device_cb(struct raw3270_request *rq, void *data) | ||
613 | { | ||
614 | struct raw3270 *rp = rq->view->dev; | ||
615 | |||
616 | if (rp->state != RAW3270_STATE_RESET) | ||
617 | return; | ||
618 | if (rq && rq->rc) { | ||
619 | /* Reset command failed. */ | ||
620 | rp->state = RAW3270_STATE_INIT; | ||
621 | } else if (0 && MACHINE_IS_VM) { | ||
622 | raw3270_size_device_vm(rp); | ||
623 | raw3270_size_device_done(rp); | ||
624 | } else | ||
625 | raw3270_writesf_readpart(rp); | ||
706 | } | 626 | } |
707 | 627 | ||
708 | static int | 628 | static int |
709 | raw3270_reset_device(struct raw3270 *rp) | 629 | __raw3270_reset_device(struct raw3270 *rp) |
710 | { | 630 | { |
711 | int rc; | 631 | int rc; |
712 | 632 | ||
713 | mutex_lock(&raw3270_init_mutex); | 633 | /* Store reset data stream to init_data/init_reset */ |
714 | memset(&rp->init_request, 0, sizeof(rp->init_request)); | 634 | memset(&rp->init_reset, 0, sizeof(rp->init_reset)); |
715 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | 635 | memset(&rp->init_data, 0, sizeof(rp->init_data)); |
716 | /* Store reset data stream to init_data/init_request */ | ||
717 | rp->init_data[0] = TW_KR; | 636 | rp->init_data[0] = TW_KR; |
718 | INIT_LIST_HEAD(&rp->init_request.list); | 637 | rp->init_reset.ccw.cmd_code = TC_EWRITEA; |
719 | rp->init_request.ccw.cmd_code = TC_EWRITEA; | 638 | rp->init_reset.ccw.flags = CCW_FLAG_SLI; |
720 | rp->init_request.ccw.flags = CCW_FLAG_SLI; | 639 | rp->init_reset.ccw.count = 1; |
721 | rp->init_request.ccw.count = 1; | 640 | rp->init_reset.ccw.cda = (__u32) __pa(rp->init_data); |
722 | rp->init_request.ccw.cda = (__u32) __pa(rp->init_data); | 641 | rp->init_reset.callback = raw3270_reset_device_cb; |
723 | rp->view = &raw3270_init_view; | 642 | rc = __raw3270_start(rp, &rp->init_view, &rp->init_reset); |
724 | raw3270_init_view.dev = rp; | 643 | if (rc == 0 && rp->state == RAW3270_STATE_INIT) |
725 | rc = raw3270_start_init(rp, &raw3270_init_view, &rp->init_request); | 644 | rp->state = RAW3270_STATE_RESET; |
726 | raw3270_init_view.dev = NULL; | 645 | return rc; |
727 | rp->view = NULL; | 646 | } |
728 | mutex_unlock(&raw3270_init_mutex); | 647 | |
648 | static int | ||
649 | raw3270_reset_device(struct raw3270 *rp) | ||
650 | { | ||
651 | unsigned long flags; | ||
652 | int rc; | ||
653 | |||
654 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | ||
655 | rc = __raw3270_reset_device(rp); | ||
656 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | ||
729 | return rc; | 657 | return rc; |
730 | } | 658 | } |
731 | 659 | ||
@@ -739,13 +667,50 @@ raw3270_reset(struct raw3270_view *view) | |||
739 | if (!rp || rp->view != view || | 667 | if (!rp || rp->view != view || |
740 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 668 | test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
741 | rc = -EACCES; | 669 | rc = -EACCES; |
742 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 670 | else if (!raw3270_state_ready(rp)) |
743 | rc = -ENODEV; | 671 | rc = -EBUSY; |
744 | else | 672 | else |
745 | rc = raw3270_reset_device(view->dev); | 673 | rc = raw3270_reset_device(view->dev); |
746 | return rc; | 674 | return rc; |
747 | } | 675 | } |
748 | 676 | ||
677 | static int | ||
678 | raw3270_init_irq(struct raw3270_view *view, struct raw3270_request *rq, | ||
679 | struct irb *irb) | ||
680 | { | ||
681 | struct raw3270 *rp; | ||
682 | |||
683 | /* | ||
684 | * Unit-Check Processing: | ||
685 | * Expect Command Reject or Intervention Required. | ||
686 | */ | ||
687 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
688 | /* Request finished abnormally. */ | ||
689 | if (irb->ecw[0] & SNS0_INTERVENTION_REQ) { | ||
690 | set_bit(RAW3270_FLAGS_BUSY, &view->dev->flags); | ||
691 | return RAW3270_IO_BUSY; | ||
692 | } | ||
693 | } | ||
694 | if (rq) { | ||
695 | if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { | ||
696 | if (irb->ecw[0] & SNS0_CMD_REJECT) | ||
697 | rq->rc = -EOPNOTSUPP; | ||
698 | else | ||
699 | rq->rc = -EIO; | ||
700 | } | ||
701 | } | ||
702 | if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { | ||
703 | /* Queue read modified after attention interrupt */ | ||
704 | rp = view->dev; | ||
705 | raw3270_read_modified(rp); | ||
706 | } | ||
707 | return RAW3270_IO_DONE; | ||
708 | } | ||
709 | |||
710 | static struct raw3270_fn raw3270_init_fn = { | ||
711 | .intv = raw3270_init_irq | ||
712 | }; | ||
713 | |||
749 | /* | 714 | /* |
750 | * Setup new 3270 device. | 715 | * Setup new 3270 device. |
751 | */ | 716 | */ |
@@ -774,6 +739,10 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) | |||
774 | INIT_LIST_HEAD(&rp->req_queue); | 739 | INIT_LIST_HEAD(&rp->req_queue); |
775 | INIT_LIST_HEAD(&rp->view_list); | 740 | INIT_LIST_HEAD(&rp->view_list); |
776 | 741 | ||
742 | rp->init_view.dev = rp; | ||
743 | rp->init_view.fn = &raw3270_init_fn; | ||
744 | rp->view = &rp->init_view; | ||
745 | |||
777 | /* | 746 | /* |
778 | * Add device to list and find the smallest unused minor | 747 | * Add device to list and find the smallest unused minor |
779 | * number for it. Note: there is no device with minor 0, | 748 | * number for it. Note: there is no device with minor 0, |
@@ -812,6 +781,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc) | |||
812 | */ | 781 | */ |
813 | struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) | 782 | struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) |
814 | { | 783 | { |
784 | unsigned long flags; | ||
815 | struct raw3270 *rp; | 785 | struct raw3270 *rp; |
816 | char *ascebc; | 786 | char *ascebc; |
817 | int rc; | 787 | int rc; |
@@ -822,16 +792,15 @@ struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev) | |||
822 | if (rc) | 792 | if (rc) |
823 | return ERR_PTR(rc); | 793 | return ERR_PTR(rc); |
824 | set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags); | 794 | set_bit(RAW3270_FLAGS_CONSOLE, &rp->flags); |
825 | rc = raw3270_reset_device(rp); | 795 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
826 | if (rc) | 796 | do { |
827 | return ERR_PTR(rc); | 797 | __raw3270_reset_device(rp); |
828 | rc = raw3270_size_device(rp); | 798 | while (!raw3270_state_final(rp)) { |
829 | if (rc) | 799 | wait_cons_dev(); |
830 | return ERR_PTR(rc); | 800 | barrier(); |
831 | rc = raw3270_reset_device(rp); | 801 | } |
832 | if (rc) | 802 | } while (rp->state != RAW3270_STATE_READY); |
833 | return ERR_PTR(rc); | 803 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
834 | set_bit(RAW3270_FLAGS_READY, &rp->flags); | ||
835 | return rp; | 804 | return rp; |
836 | } | 805 | } |
837 | 806 | ||
@@ -893,13 +862,13 @@ raw3270_activate_view(struct raw3270_view *view) | |||
893 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 862 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
894 | if (rp->view == view) | 863 | if (rp->view == view) |
895 | rc = 0; | 864 | rc = 0; |
896 | else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) | 865 | else if (!raw3270_state_ready(rp)) |
897 | rc = -ENODEV; | 866 | rc = -EBUSY; |
898 | else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) | 867 | else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) |
899 | rc = -EACCES; | 868 | rc = -EACCES; |
900 | else { | 869 | else { |
901 | oldview = NULL; | 870 | oldview = NULL; |
902 | if (rp->view) { | 871 | if (rp->view && rp->view->fn->deactivate) { |
903 | oldview = rp->view; | 872 | oldview = rp->view; |
904 | oldview->fn->deactivate(oldview); | 873 | oldview->fn->deactivate(oldview); |
905 | } | 874 | } |
@@ -944,7 +913,7 @@ raw3270_deactivate_view(struct raw3270_view *view) | |||
944 | list_del_init(&view->list); | 913 | list_del_init(&view->list); |
945 | list_add_tail(&view->list, &rp->view_list); | 914 | list_add_tail(&view->list, &rp->view_list); |
946 | /* Try to activate another view. */ | 915 | /* Try to activate another view. */ |
947 | if (test_bit(RAW3270_FLAGS_READY, &rp->flags) && | 916 | if (raw3270_state_ready(rp) && |
948 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { | 917 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { |
949 | list_for_each_entry(view, &rp->view_list, list) { | 918 | list_for_each_entry(view, &rp->view_list, list) { |
950 | rp->view = view; | 919 | rp->view = view; |
@@ -975,18 +944,16 @@ raw3270_add_view(struct raw3270_view *view, struct raw3270_fn *fn, int minor) | |||
975 | if (rp->minor != minor) | 944 | if (rp->minor != minor) |
976 | continue; | 945 | continue; |
977 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 946 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
978 | if (test_bit(RAW3270_FLAGS_READY, &rp->flags)) { | 947 | atomic_set(&view->ref_count, 2); |
979 | atomic_set(&view->ref_count, 2); | 948 | view->dev = rp; |
980 | view->dev = rp; | 949 | view->fn = fn; |
981 | view->fn = fn; | 950 | view->model = rp->model; |
982 | view->model = rp->model; | 951 | view->rows = rp->rows; |
983 | view->rows = rp->rows; | 952 | view->cols = rp->cols; |
984 | view->cols = rp->cols; | 953 | view->ascebc = rp->ascebc; |
985 | view->ascebc = rp->ascebc; | 954 | spin_lock_init(&view->lock); |
986 | spin_lock_init(&view->lock); | 955 | list_add(&view->list, &rp->view_list); |
987 | list_add(&view->list, &rp->view_list); | 956 | rc = 0; |
988 | rc = 0; | ||
989 | } | ||
990 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | 957 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
991 | break; | 958 | break; |
992 | } | 959 | } |
@@ -1010,14 +977,11 @@ raw3270_find_view(struct raw3270_fn *fn, int minor) | |||
1010 | if (rp->minor != minor) | 977 | if (rp->minor != minor) |
1011 | continue; | 978 | continue; |
1012 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 979 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
1013 | if (test_bit(RAW3270_FLAGS_READY, &rp->flags)) { | 980 | list_for_each_entry(tmp, &rp->view_list, list) { |
1014 | view = ERR_PTR(-ENOENT); | 981 | if (tmp->fn == fn) { |
1015 | list_for_each_entry(tmp, &rp->view_list, list) { | 982 | raw3270_get_view(tmp); |
1016 | if (tmp->fn == fn) { | 983 | view = tmp; |
1017 | raw3270_get_view(tmp); | 984 | break; |
1018 | view = tmp; | ||
1019 | break; | ||
1020 | } | ||
1021 | } | 985 | } |
1022 | } | 986 | } |
1023 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | 987 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
@@ -1044,7 +1008,7 @@ raw3270_del_view(struct raw3270_view *view) | |||
1044 | rp->view = NULL; | 1008 | rp->view = NULL; |
1045 | } | 1009 | } |
1046 | list_del_init(&view->list); | 1010 | list_del_init(&view->list); |
1047 | if (!rp->view && test_bit(RAW3270_FLAGS_READY, &rp->flags) && | 1011 | if (!rp->view && raw3270_state_ready(rp) && |
1048 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { | 1012 | !test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) { |
1049 | /* Try to activate another view. */ | 1013 | /* Try to activate another view. */ |
1050 | list_for_each_entry(nv, &rp->view_list, list) { | 1014 | list_for_each_entry(nv, &rp->view_list, list) { |
@@ -1072,10 +1036,6 @@ raw3270_delete_device(struct raw3270 *rp) | |||
1072 | 1036 | ||
1073 | /* Remove from device chain. */ | 1037 | /* Remove from device chain. */ |
1074 | mutex_lock(&raw3270_mutex); | 1038 | mutex_lock(&raw3270_mutex); |
1075 | if (rp->clttydev && !IS_ERR(rp->clttydev)) | ||
1076 | device_destroy(class3270, MKDEV(IBM_TTY3270_MAJOR, rp->minor)); | ||
1077 | if (rp->cltubdev && !IS_ERR(rp->cltubdev)) | ||
1078 | device_destroy(class3270, MKDEV(IBM_FS3270_MAJOR, rp->minor)); | ||
1079 | list_del_init(&rp->list); | 1039 | list_del_init(&rp->list); |
1080 | mutex_unlock(&raw3270_mutex); | 1040 | mutex_unlock(&raw3270_mutex); |
1081 | 1041 | ||
@@ -1139,75 +1099,34 @@ static struct attribute_group raw3270_attr_group = { | |||
1139 | 1099 | ||
1140 | static int raw3270_create_attributes(struct raw3270 *rp) | 1100 | static int raw3270_create_attributes(struct raw3270 *rp) |
1141 | { | 1101 | { |
1142 | int rc; | 1102 | return sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); |
1143 | |||
1144 | rc = sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); | ||
1145 | if (rc) | ||
1146 | goto out; | ||
1147 | |||
1148 | rp->clttydev = device_create(class3270, &rp->cdev->dev, | ||
1149 | MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL, | ||
1150 | "tty%s", dev_name(&rp->cdev->dev)); | ||
1151 | if (IS_ERR(rp->clttydev)) { | ||
1152 | rc = PTR_ERR(rp->clttydev); | ||
1153 | goto out_ttydev; | ||
1154 | } | ||
1155 | |||
1156 | rp->cltubdev = device_create(class3270, &rp->cdev->dev, | ||
1157 | MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL, | ||
1158 | "tub%s", dev_name(&rp->cdev->dev)); | ||
1159 | if (!IS_ERR(rp->cltubdev)) | ||
1160 | goto out; | ||
1161 | |||
1162 | rc = PTR_ERR(rp->cltubdev); | ||
1163 | device_destroy(class3270, MKDEV(IBM_TTY3270_MAJOR, rp->minor)); | ||
1164 | |||
1165 | out_ttydev: | ||
1166 | sysfs_remove_group(&rp->cdev->dev.kobj, &raw3270_attr_group); | ||
1167 | out: | ||
1168 | return rc; | ||
1169 | } | 1103 | } |
1170 | 1104 | ||
1171 | /* | 1105 | /* |
1172 | * Notifier for device addition/removal | 1106 | * Notifier for device addition/removal |
1173 | */ | 1107 | */ |
1174 | struct raw3270_notifier { | ||
1175 | struct list_head list; | ||
1176 | void (*notifier)(int, int); | ||
1177 | }; | ||
1178 | |||
1179 | static LIST_HEAD(raw3270_notifier); | 1108 | static LIST_HEAD(raw3270_notifier); |
1180 | 1109 | ||
1181 | int raw3270_register_notifier(void (*notifier)(int, int)) | 1110 | int raw3270_register_notifier(struct raw3270_notifier *notifier) |
1182 | { | 1111 | { |
1183 | struct raw3270_notifier *np; | ||
1184 | struct raw3270 *rp; | 1112 | struct raw3270 *rp; |
1185 | 1113 | ||
1186 | np = kmalloc(sizeof(struct raw3270_notifier), GFP_KERNEL); | ||
1187 | if (!np) | ||
1188 | return -ENOMEM; | ||
1189 | np->notifier = notifier; | ||
1190 | mutex_lock(&raw3270_mutex); | 1114 | mutex_lock(&raw3270_mutex); |
1191 | list_add_tail(&np->list, &raw3270_notifier); | 1115 | list_add_tail(¬ifier->list, &raw3270_notifier); |
1192 | list_for_each_entry(rp, &raw3270_devices, list) { | 1116 | list_for_each_entry(rp, &raw3270_devices, list) |
1193 | get_device(&rp->cdev->dev); | 1117 | notifier->create(rp->minor); |
1194 | notifier(rp->minor, 1); | ||
1195 | } | ||
1196 | mutex_unlock(&raw3270_mutex); | 1118 | mutex_unlock(&raw3270_mutex); |
1197 | return 0; | 1119 | return 0; |
1198 | } | 1120 | } |
1199 | 1121 | ||
1200 | void raw3270_unregister_notifier(void (*notifier)(int, int)) | 1122 | void raw3270_unregister_notifier(struct raw3270_notifier *notifier) |
1201 | { | 1123 | { |
1202 | struct raw3270_notifier *np; | 1124 | struct raw3270 *rp; |
1203 | 1125 | ||
1204 | mutex_lock(&raw3270_mutex); | 1126 | mutex_lock(&raw3270_mutex); |
1205 | list_for_each_entry(np, &raw3270_notifier, list) | 1127 | list_for_each_entry(rp, &raw3270_devices, list) |
1206 | if (np->notifier == notifier) { | 1128 | notifier->destroy(rp->minor); |
1207 | list_del(&np->list); | 1129 | list_del(¬ifier->list); |
1208 | kfree(np); | ||
1209 | break; | ||
1210 | } | ||
1211 | mutex_unlock(&raw3270_mutex); | 1130 | mutex_unlock(&raw3270_mutex); |
1212 | } | 1131 | } |
1213 | 1132 | ||
@@ -1217,29 +1136,20 @@ void raw3270_unregister_notifier(void (*notifier)(int, int)) | |||
1217 | static int | 1136 | static int |
1218 | raw3270_set_online (struct ccw_device *cdev) | 1137 | raw3270_set_online (struct ccw_device *cdev) |
1219 | { | 1138 | { |
1220 | struct raw3270 *rp; | ||
1221 | struct raw3270_notifier *np; | 1139 | struct raw3270_notifier *np; |
1140 | struct raw3270 *rp; | ||
1222 | int rc; | 1141 | int rc; |
1223 | 1142 | ||
1224 | rp = raw3270_create_device(cdev); | 1143 | rp = raw3270_create_device(cdev); |
1225 | if (IS_ERR(rp)) | 1144 | if (IS_ERR(rp)) |
1226 | return PTR_ERR(rp); | 1145 | return PTR_ERR(rp); |
1227 | rc = raw3270_reset_device(rp); | ||
1228 | if (rc) | ||
1229 | goto failure; | ||
1230 | rc = raw3270_size_device(rp); | ||
1231 | if (rc) | ||
1232 | goto failure; | ||
1233 | rc = raw3270_reset_device(rp); | ||
1234 | if (rc) | ||
1235 | goto failure; | ||
1236 | rc = raw3270_create_attributes(rp); | 1146 | rc = raw3270_create_attributes(rp); |
1237 | if (rc) | 1147 | if (rc) |
1238 | goto failure; | 1148 | goto failure; |
1239 | set_bit(RAW3270_FLAGS_READY, &rp->flags); | 1149 | raw3270_reset_device(rp); |
1240 | mutex_lock(&raw3270_mutex); | 1150 | mutex_lock(&raw3270_mutex); |
1241 | list_for_each_entry(np, &raw3270_notifier, list) | 1151 | list_for_each_entry(np, &raw3270_notifier, list) |
1242 | np->notifier(rp->minor, 1); | 1152 | np->create(rp->minor); |
1243 | mutex_unlock(&raw3270_mutex); | 1153 | mutex_unlock(&raw3270_mutex); |
1244 | return 0; | 1154 | return 0; |
1245 | 1155 | ||
@@ -1268,14 +1178,14 @@ raw3270_remove (struct ccw_device *cdev) | |||
1268 | */ | 1178 | */ |
1269 | if (rp == NULL) | 1179 | if (rp == NULL) |
1270 | return; | 1180 | return; |
1271 | clear_bit(RAW3270_FLAGS_READY, &rp->flags); | ||
1272 | 1181 | ||
1273 | sysfs_remove_group(&cdev->dev.kobj, &raw3270_attr_group); | 1182 | sysfs_remove_group(&cdev->dev.kobj, &raw3270_attr_group); |
1274 | 1183 | ||
1275 | /* Deactivate current view and remove all views. */ | 1184 | /* Deactivate current view and remove all views. */ |
1276 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); | 1185 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
1277 | if (rp->view) { | 1186 | if (rp->view) { |
1278 | rp->view->fn->deactivate(rp->view); | 1187 | if (rp->view->fn->deactivate) |
1188 | rp->view->fn->deactivate(rp->view); | ||
1279 | rp->view = NULL; | 1189 | rp->view = NULL; |
1280 | } | 1190 | } |
1281 | while (!list_empty(&rp->view_list)) { | 1191 | while (!list_empty(&rp->view_list)) { |
@@ -1290,7 +1200,7 @@ raw3270_remove (struct ccw_device *cdev) | |||
1290 | 1200 | ||
1291 | mutex_lock(&raw3270_mutex); | 1201 | mutex_lock(&raw3270_mutex); |
1292 | list_for_each_entry(np, &raw3270_notifier, list) | 1202 | list_for_each_entry(np, &raw3270_notifier, list) |
1293 | np->notifier(rp->minor, 0); | 1203 | np->destroy(rp->minor); |
1294 | mutex_unlock(&raw3270_mutex); | 1204 | mutex_unlock(&raw3270_mutex); |
1295 | 1205 | ||
1296 | /* Reset 3270 device. */ | 1206 | /* Reset 3270 device. */ |
@@ -1324,7 +1234,7 @@ static int raw3270_pm_stop(struct ccw_device *cdev) | |||
1324 | if (!rp) | 1234 | if (!rp) |
1325 | return 0; | 1235 | return 0; |
1326 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 1236 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
1327 | if (rp->view) | 1237 | if (rp->view && rp->view->fn->deactivate) |
1328 | rp->view->fn->deactivate(rp->view); | 1238 | rp->view->fn->deactivate(rp->view); |
1329 | if (!test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags)) { | 1239 | if (!test_bit(RAW3270_FLAGS_CONSOLE, &rp->flags)) { |
1330 | /* | 1240 | /* |
@@ -1351,7 +1261,7 @@ static int raw3270_pm_start(struct ccw_device *cdev) | |||
1351 | return 0; | 1261 | return 0; |
1352 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); | 1262 | spin_lock_irqsave(get_ccwdev_lock(rp->cdev), flags); |
1353 | clear_bit(RAW3270_FLAGS_FROZEN, &rp->flags); | 1263 | clear_bit(RAW3270_FLAGS_FROZEN, &rp->flags); |
1354 | if (rp->view) | 1264 | if (rp->view && rp->view->fn->activate) |
1355 | rp->view->fn->activate(rp->view); | 1265 | rp->view->fn->activate(rp->view); |
1356 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); | 1266 | spin_unlock_irqrestore(get_ccwdev_lock(rp->cdev), flags); |
1357 | return 0; | 1267 | return 0; |
@@ -1434,6 +1344,7 @@ MODULE_LICENSE("GPL"); | |||
1434 | module_init(raw3270_init); | 1344 | module_init(raw3270_init); |
1435 | module_exit(raw3270_exit); | 1345 | module_exit(raw3270_exit); |
1436 | 1346 | ||
1347 | EXPORT_SYMBOL(class3270); | ||
1437 | EXPORT_SYMBOL(raw3270_request_alloc); | 1348 | EXPORT_SYMBOL(raw3270_request_alloc); |
1438 | EXPORT_SYMBOL(raw3270_request_free); | 1349 | EXPORT_SYMBOL(raw3270_request_free); |
1439 | EXPORT_SYMBOL(raw3270_request_reset); | 1350 | EXPORT_SYMBOL(raw3270_request_reset); |
diff --git a/drivers/s390/char/raw3270.h b/drivers/s390/char/raw3270.h index ed34eb2199cc..7b73ff8c1bd7 100644 --- a/drivers/s390/char/raw3270.h +++ b/drivers/s390/char/raw3270.h | |||
@@ -91,6 +91,7 @@ struct raw3270_iocb { | |||
91 | 91 | ||
92 | struct raw3270; | 92 | struct raw3270; |
93 | struct raw3270_view; | 93 | struct raw3270_view; |
94 | extern struct class *class3270; | ||
94 | 95 | ||
95 | /* 3270 CCW request */ | 96 | /* 3270 CCW request */ |
96 | struct raw3270_request { | 97 | struct raw3270_request { |
@@ -140,6 +141,7 @@ struct raw3270_fn { | |||
140 | struct raw3270_request *, struct irb *); | 141 | struct raw3270_request *, struct irb *); |
141 | void (*release)(struct raw3270_view *); | 142 | void (*release)(struct raw3270_view *); |
142 | void (*free)(struct raw3270_view *); | 143 | void (*free)(struct raw3270_view *); |
144 | void (*resize)(struct raw3270_view *, int, int, int); | ||
143 | }; | 145 | }; |
144 | 146 | ||
145 | /* | 147 | /* |
@@ -192,8 +194,14 @@ struct raw3270 *raw3270_setup_console(struct ccw_device *cdev); | |||
192 | void raw3270_wait_cons_dev(struct raw3270 *); | 194 | void raw3270_wait_cons_dev(struct raw3270 *); |
193 | 195 | ||
194 | /* Notifier for device addition/removal */ | 196 | /* Notifier for device addition/removal */ |
195 | int raw3270_register_notifier(void (*notifier)(int, int)); | 197 | struct raw3270_notifier { |
196 | void raw3270_unregister_notifier(void (*notifier)(int, int)); | 198 | struct list_head list; |
199 | void (*create)(int minor); | ||
200 | void (*destroy)(int minor); | ||
201 | }; | ||
202 | |||
203 | int raw3270_register_notifier(struct raw3270_notifier *); | ||
204 | void raw3270_unregister_notifier(struct raw3270_notifier *); | ||
197 | void raw3270_pm_unfreeze(struct raw3270_view *); | 205 | void raw3270_pm_unfreeze(struct raw3270_view *); |
198 | 206 | ||
199 | /* | 207 | /* |
diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c index 12c16a65dd25..bd6871bf545a 100644 --- a/drivers/s390/char/sclp.c +++ b/drivers/s390/char/sclp.c | |||
@@ -450,7 +450,7 @@ sclp_sync_wait(void) | |||
450 | timeout = 0; | 450 | timeout = 0; |
451 | if (timer_pending(&sclp_request_timer)) { | 451 | if (timer_pending(&sclp_request_timer)) { |
452 | /* Get timeout TOD value */ | 452 | /* Get timeout TOD value */ |
453 | timeout = get_clock() + | 453 | timeout = get_tod_clock() + |
454 | sclp_tod_from_jiffies(sclp_request_timer.expires - | 454 | sclp_tod_from_jiffies(sclp_request_timer.expires - |
455 | jiffies); | 455 | jiffies); |
456 | } | 456 | } |
@@ -472,7 +472,7 @@ sclp_sync_wait(void) | |||
472 | while (sclp_running_state != sclp_running_state_idle) { | 472 | while (sclp_running_state != sclp_running_state_idle) { |
473 | /* Check for expired request timer */ | 473 | /* Check for expired request timer */ |
474 | if (timer_pending(&sclp_request_timer) && | 474 | if (timer_pending(&sclp_request_timer) && |
475 | get_clock() > timeout && | 475 | get_tod_clock() > timeout && |
476 | del_timer(&sclp_request_timer)) | 476 | del_timer(&sclp_request_timer)) |
477 | sclp_request_timer.function(sclp_request_timer.data); | 477 | sclp_request_timer.function(sclp_request_timer.data); |
478 | cpu_relax(); | 478 | cpu_relax(); |
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c index c44d13f607bc..30a2255389e5 100644 --- a/drivers/s390/char/sclp_cmd.c +++ b/drivers/s390/char/sclp_cmd.c | |||
@@ -56,7 +56,6 @@ static int __initdata early_read_info_sccb_valid; | |||
56 | 56 | ||
57 | u64 sclp_facilities; | 57 | u64 sclp_facilities; |
58 | static u8 sclp_fac84; | 58 | static u8 sclp_fac84; |
59 | static u8 sclp_fac85; | ||
60 | static unsigned long long rzm; | 59 | static unsigned long long rzm; |
61 | static unsigned long long rnmax; | 60 | static unsigned long long rnmax; |
62 | 61 | ||
@@ -131,7 +130,8 @@ void __init sclp_facilities_detect(void) | |||
131 | sccb = &early_read_info_sccb; | 130 | sccb = &early_read_info_sccb; |
132 | sclp_facilities = sccb->facilities; | 131 | sclp_facilities = sccb->facilities; |
133 | sclp_fac84 = sccb->fac84; | 132 | sclp_fac84 = sccb->fac84; |
134 | sclp_fac85 = sccb->fac85; | 133 | if (sccb->fac85 & 0x02) |
134 | S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; | ||
135 | rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2; | 135 | rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2; |
136 | rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2; | 136 | rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2; |
137 | rzm <<= 20; | 137 | rzm <<= 20; |
@@ -171,12 +171,6 @@ unsigned long long sclp_get_rzm(void) | |||
171 | return rzm; | 171 | return rzm; |
172 | } | 172 | } |
173 | 173 | ||
174 | u8 sclp_get_fac85(void) | ||
175 | { | ||
176 | return sclp_fac85; | ||
177 | } | ||
178 | EXPORT_SYMBOL_GPL(sclp_get_fac85); | ||
179 | |||
180 | /* | 174 | /* |
181 | * This function will be called after sclp_facilities_detect(), which gets | 175 | * This function will be called after sclp_facilities_detect(), which gets |
182 | * called from early.c code. Therefore the sccb should have valid contents. | 176 | * called from early.c code. Therefore the sccb should have valid contents. |
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 3860e796b65f..b907dba24025 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/console.h> | 16 | #include <linux/console.h> |
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/workqueue.h> | ||
18 | 19 | ||
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/bootmem.h> | 21 | #include <linux/bootmem.h> |
@@ -80,6 +81,8 @@ struct tty3270 { | |||
80 | unsigned int highlight; /* Blink/reverse/underscore */ | 81 | unsigned int highlight; /* Blink/reverse/underscore */ |
81 | unsigned int f_color; /* Foreground color */ | 82 | unsigned int f_color; /* Foreground color */ |
82 | struct tty3270_line *screen; | 83 | struct tty3270_line *screen; |
84 | unsigned int n_model, n_cols, n_rows; /* New model & size */ | ||
85 | struct work_struct resize_work; | ||
83 | 86 | ||
84 | /* Input stuff. */ | 87 | /* Input stuff. */ |
85 | struct string *prompt; /* Output string for input area. */ | 88 | struct string *prompt; /* Output string for input area. */ |
@@ -115,6 +118,7 @@ struct tty3270 { | |||
115 | #define TTY_UPDATE_ALL 16 /* Recreate screen. */ | 118 | #define TTY_UPDATE_ALL 16 /* Recreate screen. */ |
116 | 119 | ||
117 | static void tty3270_update(struct tty3270 *); | 120 | static void tty3270_update(struct tty3270 *); |
121 | static void tty3270_resize_work(struct work_struct *work); | ||
118 | 122 | ||
119 | /* | 123 | /* |
120 | * Setup timeout for a device. On timeout trigger an update. | 124 | * Setup timeout for a device. On timeout trigger an update. |
@@ -683,12 +687,6 @@ tty3270_alloc_view(void) | |||
683 | INIT_LIST_HEAD(&tp->update); | 687 | INIT_LIST_HEAD(&tp->update); |
684 | INIT_LIST_HEAD(&tp->rcl_lines); | 688 | INIT_LIST_HEAD(&tp->rcl_lines); |
685 | tp->rcl_max = 20; | 689 | tp->rcl_max = 20; |
686 | tty_port_init(&tp->port); | ||
687 | setup_timer(&tp->timer, (void (*)(unsigned long)) tty3270_update, | ||
688 | (unsigned long) tp); | ||
689 | tasklet_init(&tp->readlet, | ||
690 | (void (*)(unsigned long)) tty3270_read_tasklet, | ||
691 | (unsigned long) tp->read); | ||
692 | 690 | ||
693 | for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) { | 691 | for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) { |
694 | tp->freemem_pages[pages] = (void *) | 692 | tp->freemem_pages[pages] = (void *) |
@@ -710,6 +708,15 @@ tty3270_alloc_view(void) | |||
710 | tp->kbd = kbd_alloc(); | 708 | tp->kbd = kbd_alloc(); |
711 | if (!tp->kbd) | 709 | if (!tp->kbd) |
712 | goto out_reset; | 710 | goto out_reset; |
711 | |||
712 | tty_port_init(&tp->port); | ||
713 | setup_timer(&tp->timer, (void (*)(unsigned long)) tty3270_update, | ||
714 | (unsigned long) tp); | ||
715 | tasklet_init(&tp->readlet, | ||
716 | (void (*)(unsigned long)) tty3270_read_tasklet, | ||
717 | (unsigned long) tp->read); | ||
718 | INIT_WORK(&tp->resize_work, tty3270_resize_work); | ||
719 | |||
713 | return tp; | 720 | return tp; |
714 | 721 | ||
715 | out_reset: | 722 | out_reset: |
@@ -752,42 +759,96 @@ tty3270_free_view(struct tty3270 *tp) | |||
752 | /* | 759 | /* |
753 | * Allocate tty3270 screen. | 760 | * Allocate tty3270 screen. |
754 | */ | 761 | */ |
755 | static int | 762 | static struct tty3270_line * |
756 | tty3270_alloc_screen(struct tty3270 *tp) | 763 | tty3270_alloc_screen(unsigned int rows, unsigned int cols) |
757 | { | 764 | { |
765 | struct tty3270_line *screen; | ||
758 | unsigned long size; | 766 | unsigned long size; |
759 | int lines; | 767 | int lines; |
760 | 768 | ||
761 | size = sizeof(struct tty3270_line) * (tp->view.rows - 2); | 769 | size = sizeof(struct tty3270_line) * (rows - 2); |
762 | tp->screen = kzalloc(size, GFP_KERNEL); | 770 | screen = kzalloc(size, GFP_KERNEL); |
763 | if (!tp->screen) | 771 | if (!screen) |
764 | goto out_err; | 772 | goto out_err; |
765 | for (lines = 0; lines < tp->view.rows - 2; lines++) { | 773 | for (lines = 0; lines < rows - 2; lines++) { |
766 | size = sizeof(struct tty3270_cell) * tp->view.cols; | 774 | size = sizeof(struct tty3270_cell) * cols; |
767 | tp->screen[lines].cells = kzalloc(size, GFP_KERNEL); | 775 | screen[lines].cells = kzalloc(size, GFP_KERNEL); |
768 | if (!tp->screen[lines].cells) | 776 | if (!screen[lines].cells) |
769 | goto out_screen; | 777 | goto out_screen; |
770 | } | 778 | } |
771 | return 0; | 779 | return screen; |
772 | out_screen: | 780 | out_screen: |
773 | while (lines--) | 781 | while (lines--) |
774 | kfree(tp->screen[lines].cells); | 782 | kfree(screen[lines].cells); |
775 | kfree(tp->screen); | 783 | kfree(screen); |
776 | out_err: | 784 | out_err: |
777 | return -ENOMEM; | 785 | return ERR_PTR(-ENOMEM); |
778 | } | 786 | } |
779 | 787 | ||
780 | /* | 788 | /* |
781 | * Free tty3270 screen. | 789 | * Free tty3270 screen. |
782 | */ | 790 | */ |
783 | static void | 791 | static void |
784 | tty3270_free_screen(struct tty3270 *tp) | 792 | tty3270_free_screen(struct tty3270_line *screen, unsigned int rows) |
785 | { | 793 | { |
786 | int lines; | 794 | int lines; |
787 | 795 | ||
788 | for (lines = 0; lines < tp->view.rows - 2; lines++) | 796 | for (lines = 0; lines < rows - 2; lines++) |
789 | kfree(tp->screen[lines].cells); | 797 | kfree(screen[lines].cells); |
790 | kfree(tp->screen); | 798 | kfree(screen); |
799 | } | ||
800 | |||
801 | /* | ||
802 | * Resize tty3270 screen | ||
803 | */ | ||
804 | static void tty3270_resize_work(struct work_struct *work) | ||
805 | { | ||
806 | struct tty3270 *tp = container_of(work, struct tty3270, resize_work); | ||
807 | struct tty3270_line *screen, *oscreen; | ||
808 | struct tty_struct *tty; | ||
809 | unsigned int orows; | ||
810 | struct winsize ws; | ||
811 | |||
812 | screen = tty3270_alloc_screen(tp->n_rows, tp->n_cols); | ||
813 | if (!screen) | ||
814 | return; | ||
815 | /* Switch to new output size */ | ||
816 | spin_lock_bh(&tp->view.lock); | ||
817 | oscreen = tp->screen; | ||
818 | orows = tp->view.rows; | ||
819 | tp->view.model = tp->n_model; | ||
820 | tp->view.rows = tp->n_rows; | ||
821 | tp->view.cols = tp->n_cols; | ||
822 | tp->screen = screen; | ||
823 | free_string(&tp->freemem, tp->prompt); | ||
824 | free_string(&tp->freemem, tp->status); | ||
825 | tty3270_create_prompt(tp); | ||
826 | tty3270_create_status(tp); | ||
827 | tp->nr_up = 0; | ||
828 | while (tp->nr_lines < tp->view.rows - 2) | ||
829 | tty3270_blank_line(tp); | ||
830 | tp->update_flags = TTY_UPDATE_ALL; | ||
831 | spin_unlock_bh(&tp->view.lock); | ||
832 | tty3270_free_screen(oscreen, orows); | ||
833 | tty3270_set_timer(tp, 1); | ||
834 | /* Informat tty layer about new size */ | ||
835 | tty = tty_port_tty_get(&tp->port); | ||
836 | if (!tty) | ||
837 | return; | ||
838 | ws.ws_row = tp->view.rows - 2; | ||
839 | ws.ws_col = tp->view.cols; | ||
840 | tty_do_resize(tty, &ws); | ||
841 | } | ||
842 | |||
843 | static void | ||
844 | tty3270_resize(struct raw3270_view *view, int model, int rows, int cols) | ||
845 | { | ||
846 | struct tty3270 *tp = container_of(view, struct tty3270, view); | ||
847 | |||
848 | tp->n_model = model; | ||
849 | tp->n_rows = rows; | ||
850 | tp->n_cols = cols; | ||
851 | schedule_work(&tp->resize_work); | ||
791 | } | 852 | } |
792 | 853 | ||
793 | /* | 854 | /* |
@@ -815,7 +876,8 @@ static void | |||
815 | tty3270_free(struct raw3270_view *view) | 876 | tty3270_free(struct raw3270_view *view) |
816 | { | 877 | { |
817 | struct tty3270 *tp = container_of(view, struct tty3270, view); | 878 | struct tty3270 *tp = container_of(view, struct tty3270, view); |
818 | tty3270_free_screen(tp); | 879 | |
880 | tty3270_free_screen(tp->screen, tp->view.rows); | ||
819 | tty3270_free_view(tp); | 881 | tty3270_free_view(tp); |
820 | } | 882 | } |
821 | 883 | ||
@@ -827,9 +889,8 @@ tty3270_del_views(void) | |||
827 | { | 889 | { |
828 | int i; | 890 | int i; |
829 | 891 | ||
830 | for (i = 0; i < tty3270_max_index; i++) { | 892 | for (i = RAW3270_FIRSTMINOR; i <= tty3270_max_index; i++) { |
831 | struct raw3270_view *view = | 893 | struct raw3270_view *view = raw3270_find_view(&tty3270_fn, i); |
832 | raw3270_find_view(&tty3270_fn, i + RAW3270_FIRSTMINOR); | ||
833 | if (!IS_ERR(view)) | 894 | if (!IS_ERR(view)) |
834 | raw3270_del_view(view); | 895 | raw3270_del_view(view); |
835 | } | 896 | } |
@@ -840,7 +901,8 @@ static struct raw3270_fn tty3270_fn = { | |||
840 | .deactivate = tty3270_deactivate, | 901 | .deactivate = tty3270_deactivate, |
841 | .intv = (void *) tty3270_irq, | 902 | .intv = (void *) tty3270_irq, |
842 | .release = tty3270_release, | 903 | .release = tty3270_release, |
843 | .free = tty3270_free | 904 | .free = tty3270_free, |
905 | .resize = tty3270_resize | ||
844 | }; | 906 | }; |
845 | 907 | ||
846 | /* | 908 | /* |
@@ -853,8 +915,7 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) | |||
853 | int i, rc; | 915 | int i, rc; |
854 | 916 | ||
855 | /* Check if the tty3270 is already there. */ | 917 | /* Check if the tty3270 is already there. */ |
856 | view = raw3270_find_view(&tty3270_fn, | 918 | view = raw3270_find_view(&tty3270_fn, tty->index); |
857 | tty->index + RAW3270_FIRSTMINOR); | ||
858 | if (!IS_ERR(view)) { | 919 | if (!IS_ERR(view)) { |
859 | tp = container_of(view, struct tty3270, view); | 920 | tp = container_of(view, struct tty3270, view); |
860 | tty->driver_data = tp; | 921 | tty->driver_data = tp; |
@@ -866,29 +927,26 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) | |||
866 | tp->inattr = TF_INPUT; | 927 | tp->inattr = TF_INPUT; |
867 | return tty_port_install(&tp->port, driver, tty); | 928 | return tty_port_install(&tp->port, driver, tty); |
868 | } | 929 | } |
869 | if (tty3270_max_index < tty->index + 1) | 930 | if (tty3270_max_index < tty->index) |
870 | tty3270_max_index = tty->index + 1; | 931 | tty3270_max_index = tty->index; |
871 | |||
872 | /* Quick exit if there is no device for tty->index. */ | ||
873 | if (PTR_ERR(view) == -ENODEV) | ||
874 | return -ENODEV; | ||
875 | 932 | ||
876 | /* Allocate tty3270 structure on first open. */ | 933 | /* Allocate tty3270 structure on first open. */ |
877 | tp = tty3270_alloc_view(); | 934 | tp = tty3270_alloc_view(); |
878 | if (IS_ERR(tp)) | 935 | if (IS_ERR(tp)) |
879 | return PTR_ERR(tp); | 936 | return PTR_ERR(tp); |
880 | 937 | ||
881 | rc = raw3270_add_view(&tp->view, &tty3270_fn, | 938 | rc = raw3270_add_view(&tp->view, &tty3270_fn, tty->index); |
882 | tty->index + RAW3270_FIRSTMINOR); | ||
883 | if (rc) { | 939 | if (rc) { |
884 | tty3270_free_view(tp); | 940 | tty3270_free_view(tp); |
885 | return rc; | 941 | return rc; |
886 | } | 942 | } |
887 | 943 | ||
888 | rc = tty3270_alloc_screen(tp); | 944 | tp->screen = tty3270_alloc_screen(tp->view.cols, tp->view.rows); |
889 | if (rc) { | 945 | if (IS_ERR(tp->screen)) { |
946 | rc = PTR_ERR(tp->screen); | ||
890 | raw3270_put_view(&tp->view); | 947 | raw3270_put_view(&tp->view); |
891 | raw3270_del_view(&tp->view); | 948 | raw3270_del_view(&tp->view); |
949 | tty3270_free_view(tp); | ||
892 | return rc; | 950 | return rc; |
893 | } | 951 | } |
894 | 952 | ||
@@ -926,6 +984,20 @@ static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) | |||
926 | } | 984 | } |
927 | 985 | ||
928 | /* | 986 | /* |
987 | * This routine is called whenever a 3270 tty is opened. | ||
988 | */ | ||
989 | static int | ||
990 | tty3270_open(struct tty_struct *tty, struct file *filp) | ||
991 | { | ||
992 | struct tty3270 *tp = tty->driver_data; | ||
993 | struct tty_port *port = &tp->port; | ||
994 | |||
995 | port->count++; | ||
996 | tty_port_tty_set(port, tty); | ||
997 | return 0; | ||
998 | } | ||
999 | |||
1000 | /* | ||
929 | * This routine is called when the 3270 tty is closed. We wait | 1001 | * This routine is called when the 3270 tty is closed. We wait |
930 | * for the remaining request to be completed. Then we clean up. | 1002 | * for the remaining request to be completed. Then we clean up. |
931 | */ | 1003 | */ |
@@ -1753,6 +1825,7 @@ static long tty3270_compat_ioctl(struct tty_struct *tty, | |||
1753 | static const struct tty_operations tty3270_ops = { | 1825 | static const struct tty_operations tty3270_ops = { |
1754 | .install = tty3270_install, | 1826 | .install = tty3270_install, |
1755 | .cleanup = tty3270_cleanup, | 1827 | .cleanup = tty3270_cleanup, |
1828 | .open = tty3270_open, | ||
1756 | .close = tty3270_close, | 1829 | .close = tty3270_close, |
1757 | .write = tty3270_write, | 1830 | .write = tty3270_write, |
1758 | .put_char = tty3270_put_char, | 1831 | .put_char = tty3270_put_char, |
@@ -1771,6 +1844,22 @@ static const struct tty_operations tty3270_ops = { | |||
1771 | .set_termios = tty3270_set_termios | 1844 | .set_termios = tty3270_set_termios |
1772 | }; | 1845 | }; |
1773 | 1846 | ||
1847 | void tty3270_create_cb(int minor) | ||
1848 | { | ||
1849 | tty_register_device(tty3270_driver, minor, NULL); | ||
1850 | } | ||
1851 | |||
1852 | void tty3270_destroy_cb(int minor) | ||
1853 | { | ||
1854 | tty_unregister_device(tty3270_driver, minor); | ||
1855 | } | ||
1856 | |||
1857 | struct raw3270_notifier tty3270_notifier = | ||
1858 | { | ||
1859 | .create = tty3270_create_cb, | ||
1860 | .destroy = tty3270_destroy_cb, | ||
1861 | }; | ||
1862 | |||
1774 | /* | 1863 | /* |
1775 | * 3270 tty registration code called from tty_init(). | 1864 | * 3270 tty registration code called from tty_init(). |
1776 | * Most kernel services (incl. kmalloc) are available at this poimt. | 1865 | * Most kernel services (incl. kmalloc) are available at this poimt. |
@@ -1780,23 +1869,25 @@ static int __init tty3270_init(void) | |||
1780 | struct tty_driver *driver; | 1869 | struct tty_driver *driver; |
1781 | int ret; | 1870 | int ret; |
1782 | 1871 | ||
1783 | driver = alloc_tty_driver(RAW3270_MAXDEVS); | 1872 | driver = tty_alloc_driver(RAW3270_MAXDEVS, |
1784 | if (!driver) | 1873 | TTY_DRIVER_REAL_RAW | |
1785 | return -ENOMEM; | 1874 | TTY_DRIVER_DYNAMIC_DEV | |
1875 | TTY_DRIVER_RESET_TERMIOS); | ||
1876 | if (IS_ERR(driver)) | ||
1877 | return PTR_ERR(driver); | ||
1786 | 1878 | ||
1787 | /* | 1879 | /* |
1788 | * Initialize the tty_driver structure | 1880 | * Initialize the tty_driver structure |
1789 | * Entries in tty3270_driver that are NOT initialized: | 1881 | * Entries in tty3270_driver that are NOT initialized: |
1790 | * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc | 1882 | * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc |
1791 | */ | 1883 | */ |
1792 | driver->driver_name = "ttyTUB"; | 1884 | driver->driver_name = "tty3270"; |
1793 | driver->name = "ttyTUB"; | 1885 | driver->name = "3270/tty"; |
1794 | driver->major = IBM_TTY3270_MAJOR; | 1886 | driver->major = IBM_TTY3270_MAJOR; |
1795 | driver->minor_start = RAW3270_FIRSTMINOR; | 1887 | driver->minor_start = 0; |
1796 | driver->type = TTY_DRIVER_TYPE_SYSTEM; | 1888 | driver->type = TTY_DRIVER_TYPE_SYSTEM; |
1797 | driver->subtype = SYSTEM_TYPE_TTY; | 1889 | driver->subtype = SYSTEM_TYPE_TTY; |
1798 | driver->init_termios = tty_std_termios; | 1890 | driver->init_termios = tty_std_termios; |
1799 | driver->flags = TTY_DRIVER_RESET_TERMIOS; | ||
1800 | tty_set_operations(driver, &tty3270_ops); | 1891 | tty_set_operations(driver, &tty3270_ops); |
1801 | ret = tty_register_driver(driver); | 1892 | ret = tty_register_driver(driver); |
1802 | if (ret) { | 1893 | if (ret) { |
@@ -1804,6 +1895,7 @@ static int __init tty3270_init(void) | |||
1804 | return ret; | 1895 | return ret; |
1805 | } | 1896 | } |
1806 | tty3270_driver = driver; | 1897 | tty3270_driver = driver; |
1898 | raw3270_register_notifier(&tty3270_notifier); | ||
1807 | return 0; | 1899 | return 0; |
1808 | } | 1900 | } |
1809 | 1901 | ||
@@ -1812,6 +1904,7 @@ tty3270_exit(void) | |||
1812 | { | 1904 | { |
1813 | struct tty_driver *driver; | 1905 | struct tty_driver *driver; |
1814 | 1906 | ||
1907 | raw3270_unregister_notifier(&tty3270_notifier); | ||
1815 | driver = tty3270_driver; | 1908 | driver = tty3270_driver; |
1816 | tty3270_driver = NULL; | 1909 | tty3270_driver = NULL; |
1817 | tty_unregister_driver(driver); | 1910 | tty_unregister_driver(driver); |
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c index e3b9308b0fe3..1d61a01576d2 100644 --- a/drivers/s390/char/zcore.c +++ b/drivers/s390/char/zcore.c | |||
@@ -62,6 +62,7 @@ static struct dentry *zcore_dir; | |||
62 | static struct dentry *zcore_file; | 62 | static struct dentry *zcore_file; |
63 | static struct dentry *zcore_memmap_file; | 63 | static struct dentry *zcore_memmap_file; |
64 | static struct dentry *zcore_reipl_file; | 64 | static struct dentry *zcore_reipl_file; |
65 | static struct dentry *zcore_hsa_file; | ||
65 | static struct ipl_parameter_block *ipl_block; | 66 | static struct ipl_parameter_block *ipl_block; |
66 | 67 | ||
67 | /* | 68 | /* |
@@ -77,6 +78,8 @@ static int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode) | |||
77 | int offs, blk_num; | 78 | int offs, blk_num; |
78 | static char buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); | 79 | static char buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); |
79 | 80 | ||
81 | if (!hsa_available) | ||
82 | return -ENODATA; | ||
80 | if (count == 0) | 83 | if (count == 0) |
81 | return 0; | 84 | return 0; |
82 | 85 | ||
@@ -278,6 +281,15 @@ next: | |||
278 | } | 281 | } |
279 | 282 | ||
280 | /* | 283 | /* |
284 | * Release the HSA | ||
285 | */ | ||
286 | static void release_hsa(void) | ||
287 | { | ||
288 | diag308(DIAG308_REL_HSA, NULL); | ||
289 | hsa_available = 0; | ||
290 | } | ||
291 | |||
292 | /* | ||
281 | * Read routine for zcore character device | 293 | * Read routine for zcore character device |
282 | * First 4K are dump header | 294 | * First 4K are dump header |
283 | * Next 32MB are HSA Memory | 295 | * Next 32MB are HSA Memory |
@@ -363,8 +375,8 @@ static int zcore_open(struct inode *inode, struct file *filp) | |||
363 | 375 | ||
364 | static int zcore_release(struct inode *inode, struct file *filep) | 376 | static int zcore_release(struct inode *inode, struct file *filep) |
365 | { | 377 | { |
366 | diag308(DIAG308_REL_HSA, NULL); | 378 | if (hsa_available) |
367 | hsa_available = 0; | 379 | release_hsa(); |
368 | return 0; | 380 | return 0; |
369 | } | 381 | } |
370 | 382 | ||
@@ -474,6 +486,41 @@ static const struct file_operations zcore_reipl_fops = { | |||
474 | .llseek = no_llseek, | 486 | .llseek = no_llseek, |
475 | }; | 487 | }; |
476 | 488 | ||
489 | static ssize_t zcore_hsa_read(struct file *filp, char __user *buf, | ||
490 | size_t count, loff_t *ppos) | ||
491 | { | ||
492 | static char str[18]; | ||
493 | |||
494 | if (hsa_available) | ||
495 | snprintf(str, sizeof(str), "%lx\n", ZFCPDUMP_HSA_SIZE); | ||
496 | else | ||
497 | snprintf(str, sizeof(str), "0\n"); | ||
498 | return simple_read_from_buffer(buf, count, ppos, str, strlen(str)); | ||
499 | } | ||
500 | |||
501 | static ssize_t zcore_hsa_write(struct file *filp, const char __user *buf, | ||
502 | size_t count, loff_t *ppos) | ||
503 | { | ||
504 | char value; | ||
505 | |||
506 | if (*ppos != 0) | ||
507 | return -EPIPE; | ||
508 | if (copy_from_user(&value, buf, 1)) | ||
509 | return -EFAULT; | ||
510 | if (value != '0') | ||
511 | return -EINVAL; | ||
512 | release_hsa(); | ||
513 | return count; | ||
514 | } | ||
515 | |||
516 | static const struct file_operations zcore_hsa_fops = { | ||
517 | .owner = THIS_MODULE, | ||
518 | .write = zcore_hsa_write, | ||
519 | .read = zcore_hsa_read, | ||
520 | .open = nonseekable_open, | ||
521 | .llseek = no_llseek, | ||
522 | }; | ||
523 | |||
477 | #ifdef CONFIG_32BIT | 524 | #ifdef CONFIG_32BIT |
478 | 525 | ||
479 | static void __init set_lc_mask(struct save_area *map) | 526 | static void __init set_lc_mask(struct save_area *map) |
@@ -590,7 +637,7 @@ static int __init zcore_header_init(int arch, struct zcore_header *hdr) | |||
590 | hdr->rmem_size = memory; | 637 | hdr->rmem_size = memory; |
591 | hdr->mem_end = sys_info.mem_size; | 638 | hdr->mem_end = sys_info.mem_size; |
592 | hdr->num_pages = memory / PAGE_SIZE; | 639 | hdr->num_pages = memory / PAGE_SIZE; |
593 | hdr->tod = get_clock(); | 640 | hdr->tod = get_tod_clock(); |
594 | get_cpu_id(&hdr->cpu_id); | 641 | get_cpu_id(&hdr->cpu_id); |
595 | for (i = 0; zfcpdump_save_areas[i]; i++) { | 642 | for (i = 0; zfcpdump_save_areas[i]; i++) { |
596 | prefix = zfcpdump_save_areas[i]->pref_reg; | 643 | prefix = zfcpdump_save_areas[i]->pref_reg; |
@@ -658,6 +705,7 @@ static int __init zcore_init(void) | |||
658 | rc = check_sdias(); | 705 | rc = check_sdias(); |
659 | if (rc) | 706 | if (rc) |
660 | goto fail; | 707 | goto fail; |
708 | hsa_available = 1; | ||
661 | 709 | ||
662 | rc = memcpy_hsa_kernel(&arch, __LC_AR_MODE_ID, 1); | 710 | rc = memcpy_hsa_kernel(&arch, __LC_AR_MODE_ID, 1); |
663 | if (rc) | 711 | if (rc) |
@@ -714,9 +762,16 @@ static int __init zcore_init(void) | |||
714 | rc = -ENOMEM; | 762 | rc = -ENOMEM; |
715 | goto fail_memmap_file; | 763 | goto fail_memmap_file; |
716 | } | 764 | } |
717 | hsa_available = 1; | 765 | zcore_hsa_file = debugfs_create_file("hsa", S_IRUSR|S_IWUSR, zcore_dir, |
766 | NULL, &zcore_hsa_fops); | ||
767 | if (!zcore_hsa_file) { | ||
768 | rc = -ENOMEM; | ||
769 | goto fail_reipl_file; | ||
770 | } | ||
718 | return 0; | 771 | return 0; |
719 | 772 | ||
773 | fail_reipl_file: | ||
774 | debugfs_remove(zcore_reipl_file); | ||
720 | fail_memmap_file: | 775 | fail_memmap_file: |
721 | debugfs_remove(zcore_memmap_file); | 776 | debugfs_remove(zcore_memmap_file); |
722 | fail_file: | 777 | fail_file: |
@@ -733,6 +788,7 @@ static void __exit zcore_exit(void) | |||
733 | debug_unregister(zcore_dbf); | 788 | debug_unregister(zcore_dbf); |
734 | sclp_sdias_exit(); | 789 | sclp_sdias_exit(); |
735 | free_page((unsigned long) ipl_block); | 790 | free_page((unsigned long) ipl_block); |
791 | debugfs_remove(zcore_hsa_file); | ||
736 | debugfs_remove(zcore_reipl_file); | 792 | debugfs_remove(zcore_reipl_file); |
737 | debugfs_remove(zcore_memmap_file); | 793 | debugfs_remove(zcore_memmap_file); |
738 | debugfs_remove(zcore_file); | 794 | debugfs_remove(zcore_file); |