aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/mm/extmem.c106
-rw-r--r--drivers/s390/block/dcssblk.c72
2 files changed, 76 insertions, 102 deletions
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
index 580fc64cc73..5c845712960 100644
--- a/arch/s390/mm/extmem.c
+++ b/arch/s390/mm/extmem.c
@@ -7,6 +7,9 @@
7 * (C) IBM Corporation 2002-2004 7 * (C) IBM Corporation 2002-2004
8 */ 8 */
9 9
10#define KMSG_COMPONENT "extmem"
11#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12
10#include <linux/kernel.h> 13#include <linux/kernel.h>
11#include <linux/string.h> 14#include <linux/string.h>
12#include <linux/spinlock.h> 15#include <linux/spinlock.h>
@@ -24,19 +27,6 @@
24#include <asm/cpcmd.h> 27#include <asm/cpcmd.h>
25#include <asm/setup.h> 28#include <asm/setup.h>
26 29
27#define DCSS_DEBUG /* Debug messages on/off */
28
29#define DCSS_NAME "extmem"
30#ifdef DCSS_DEBUG
31#define PRINT_DEBUG(x...) printk(KERN_DEBUG DCSS_NAME " debug:" x)
32#else
33#define PRINT_DEBUG(x...) do {} while (0)
34#endif
35#define PRINT_INFO(x...) printk(KERN_INFO DCSS_NAME " info:" x)
36#define PRINT_WARN(x...) printk(KERN_WARNING DCSS_NAME " warning:" x)
37#define PRINT_ERR(x...) printk(KERN_ERR DCSS_NAME " error:" x)
38
39
40#define DCSS_LOADSHR 0x00 30#define DCSS_LOADSHR 0x00
41#define DCSS_LOADNSR 0x04 31#define DCSS_LOADNSR 0x04
42#define DCSS_PURGESEG 0x08 32#define DCSS_PURGESEG 0x08
@@ -286,7 +276,7 @@ query_segment_type (struct dcss_segment *seg)
286 goto out_free; 276 goto out_free;
287 } 277 }
288 if (diag_cc > 1) { 278 if (diag_cc > 1) {
289 PRINT_WARN ("segment_type: diag returned error %ld\n", vmrc); 279 pr_warning("Querying a DCSS type failed with rc=%ld\n", vmrc);
290 rc = dcss_diag_translate_rc (vmrc); 280 rc = dcss_diag_translate_rc (vmrc);
291 goto out_free; 281 goto out_free;
292 } 282 }
@@ -368,7 +358,6 @@ query_segment_type (struct dcss_segment *seg)
368 * -EIO : could not perform query diagnose 358 * -EIO : could not perform query diagnose
369 * -ENOENT : no such segment 359 * -ENOENT : no such segment
370 * -ENOTSUPP: multi-part segment cannot be used with linux 360 * -ENOTSUPP: multi-part segment cannot be used with linux
371 * -ENOSPC : segment cannot be used (overlaps with storage)
372 * -ENOMEM : out of memory 361 * -ENOMEM : out of memory
373 * 0 .. 6 : type of segment as defined in include/asm-s390/extmem.h 362 * 0 .. 6 : type of segment as defined in include/asm-s390/extmem.h
374 */ 363 */
@@ -480,9 +469,8 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
480 goto out_resource; 469 goto out_resource;
481 } 470 }
482 if (diag_cc > 1) { 471 if (diag_cc > 1) {
483 PRINT_WARN ("segment_load: could not load segment %s - " 472 pr_warning("Loading DCSS %s failed with rc=%ld\n", name,
484 "diag returned error (%ld)\n", 473 end_addr);
485 name, end_addr);
486 rc = dcss_diag_translate_rc(end_addr); 474 rc = dcss_diag_translate_rc(end_addr);
487 dcss_diag(&purgeseg_scode, seg->dcss_name, 475 dcss_diag(&purgeseg_scode, seg->dcss_name,
488 &dummy, &dummy); 476 &dummy, &dummy);
@@ -496,15 +484,13 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
496 *addr = seg->start_addr; 484 *addr = seg->start_addr;
497 *end = seg->end; 485 *end = seg->end;
498 if (do_nonshared) 486 if (do_nonshared)
499 PRINT_INFO ("segment_load: loaded segment %s range %p .. %p " 487 pr_info("DCSS %s of range %p to %p and type %s loaded as "
500 "type %s in non-shared mode\n", name, 488 "exclusive-writable\n", name, (void*) seg->start_addr,
501 (void*)seg->start_addr, (void*)seg->end, 489 (void*) seg->end, segtype_string[seg->vm_segtype]);
502 segtype_string[seg->vm_segtype]);
503 else { 490 else {
504 PRINT_INFO ("segment_load: loaded segment %s range %p .. %p " 491 pr_info("DCSS %s of range %p to %p and type %s loaded in "
505 "type %s in shared mode\n", name, 492 "shared access mode\n", name, (void*) seg->start_addr,
506 (void*)seg->start_addr, (void*)seg->end, 493 (void*) seg->end, segtype_string[seg->vm_segtype]);
507 segtype_string[seg->vm_segtype]);
508 } 494 }
509 goto out; 495 goto out;
510 out_resource: 496 out_resource:
@@ -593,14 +579,14 @@ segment_modify_shared (char *name, int do_nonshared)
593 goto out_unlock; 579 goto out_unlock;
594 } 580 }
595 if (do_nonshared == seg->do_nonshared) { 581 if (do_nonshared == seg->do_nonshared) {
596 PRINT_INFO ("segment_modify_shared: not reloading segment %s" 582 pr_info("DCSS %s is already in the requested access "
597 " - already in requested mode\n",name); 583 "mode\n", name);
598 rc = 0; 584 rc = 0;
599 goto out_unlock; 585 goto out_unlock;
600 } 586 }
601 if (atomic_read (&seg->ref_count) != 1) { 587 if (atomic_read (&seg->ref_count) != 1) {
602 PRINT_WARN ("segment_modify_shared: not reloading segment %s - " 588 pr_warning("DCSS %s is in use and cannot be reloaded\n",
603 "segment is in use by other driver(s)\n",name); 589 name);
604 rc = -EAGAIN; 590 rc = -EAGAIN;
605 goto out_unlock; 591 goto out_unlock;
606 } 592 }
@@ -613,8 +599,8 @@ segment_modify_shared (char *name, int do_nonshared)
613 seg->res->flags |= IORESOURCE_READONLY; 599 seg->res->flags |= IORESOURCE_READONLY;
614 600
615 if (request_resource(&iomem_resource, seg->res)) { 601 if (request_resource(&iomem_resource, seg->res)) {
616 PRINT_WARN("segment_modify_shared: could not reload segment %s" 602 pr_warning("DCSS %s overlaps with used memory resources "
617 " - overlapping resources\n", name); 603 "and cannot be reloaded\n", name);
618 rc = -EBUSY; 604 rc = -EBUSY;
619 kfree(seg->res); 605 kfree(seg->res);
620 goto out_del_mem; 606 goto out_del_mem;
@@ -632,9 +618,8 @@ segment_modify_shared (char *name, int do_nonshared)
632 goto out_del_res; 618 goto out_del_res;
633 } 619 }
634 if (diag_cc > 1) { 620 if (diag_cc > 1) {
635 PRINT_WARN ("segment_modify_shared: could not reload segment %s" 621 pr_warning("Reloading DCSS %s failed with rc=%ld\n", name,
636 " - diag returned error (%ld)\n", 622 end_addr);
637 name, end_addr);
638 rc = dcss_diag_translate_rc(end_addr); 623 rc = dcss_diag_translate_rc(end_addr);
639 goto out_del_res; 624 goto out_del_res;
640 } 625 }
@@ -673,8 +658,7 @@ segment_unload(char *name)
673 mutex_lock(&dcss_lock); 658 mutex_lock(&dcss_lock);
674 seg = segment_by_name (name); 659 seg = segment_by_name (name);
675 if (seg == NULL) { 660 if (seg == NULL) {
676 PRINT_ERR ("could not find segment %s in segment_unload, " 661 pr_err("Unloading unknown DCSS %s failed\n", name);
677 "please report to linux390@de.ibm.com\n",name);
678 goto out_unlock; 662 goto out_unlock;
679 } 663 }
680 if (atomic_dec_return(&seg->ref_count) != 0) 664 if (atomic_dec_return(&seg->ref_count) != 0)
@@ -709,8 +693,7 @@ segment_save(char *name)
709 seg = segment_by_name (name); 693 seg = segment_by_name (name);
710 694
711 if (seg == NULL) { 695 if (seg == NULL) {
712 PRINT_ERR("could not find segment %s in segment_save, please " 696 pr_err("Saving unknown DCSS %s failed\n", name);
713 "report to linux390@de.ibm.com\n", name);
714 goto out; 697 goto out;
715 } 698 }
716 699
@@ -727,14 +710,14 @@ segment_save(char *name)
727 response = 0; 710 response = 0;
728 cpcmd(cmd1, NULL, 0, &response); 711 cpcmd(cmd1, NULL, 0, &response);
729 if (response) { 712 if (response) {
730 PRINT_ERR("segment_save: DEFSEG failed with response code %i\n", 713 pr_err("Saving a DCSS failed with DEFSEG response code "
731 response); 714 "%i\n", response);
732 goto out; 715 goto out;
733 } 716 }
734 cpcmd(cmd2, NULL, 0, &response); 717 cpcmd(cmd2, NULL, 0, &response);
735 if (response) { 718 if (response) {
736 PRINT_ERR("segment_save: SAVESEG failed with response code %i\n", 719 pr_err("Saving a DCSS failed with SAVESEG response code "
737 response); 720 "%i\n", response);
738 goto out; 721 goto out;
739 } 722 }
740out: 723out:
@@ -749,44 +732,41 @@ void segment_warning(int rc, char *seg_name)
749{ 732{
750 switch (rc) { 733 switch (rc) {
751 case -ENOENT: 734 case -ENOENT:
752 PRINT_WARN("cannot load/query segment %s, " 735 pr_err("DCSS %s cannot be loaded or queried\n", seg_name);
753 "does not exist\n", seg_name);
754 break; 736 break;
755 case -ENOSYS: 737 case -ENOSYS:
756 PRINT_WARN("cannot load/query segment %s, " 738 pr_err("DCSS %s cannot be loaded or queried without "
757 "not running on VM\n", seg_name); 739 "z/VM\n", seg_name);
758 break; 740 break;
759 case -EIO: 741 case -EIO:
760 PRINT_WARN("cannot load/query segment %s, " 742 pr_err("Loading or querying DCSS %s resulted in a "
761 "hardware error\n", seg_name); 743 "hardware error\n", seg_name);
762 break; 744 break;
763 case -ENOTSUPP: 745 case -ENOTSUPP:
764 PRINT_WARN("cannot load/query segment %s, " 746 pr_err("DCSS %s has multiple page ranges and cannot be "
765 "is a multi-part segment\n", seg_name); 747 "loaded or queried\n", seg_name);
766 break; 748 break;
767 case -ENOSPC: 749 case -ENOSPC:
768 PRINT_WARN("cannot load/query segment %s, " 750 pr_err("DCSS %s overlaps with used storage and cannot "
769 "overlaps with storage\n", seg_name); 751 "be loaded\n", seg_name);
770 break; 752 break;
771 case -EBUSY: 753 case -EBUSY:
772 PRINT_WARN("cannot load/query segment %s, " 754 pr_err("%s needs used memory resources and cannot be "
773 "overlaps with already loaded dcss\n", seg_name); 755 "loaded or queried\n", seg_name);
774 break; 756 break;
775 case -EPERM: 757 case -EPERM:
776 PRINT_WARN("cannot load/query segment %s, " 758 pr_err("DCSS %s is already loaded in a different access "
777 "already loaded in incompatible mode\n", seg_name); 759 "mode\n", seg_name);
778 break; 760 break;
779 case -ENOMEM: 761 case -ENOMEM:
780 PRINT_WARN("cannot load/query segment %s, " 762 pr_err("There is not enough memory to load or query "
781 "out of memory\n", seg_name); 763 "DCSS %s\n", seg_name);
782 break; 764 break;
783 case -ERANGE: 765 case -ERANGE:
784 PRINT_WARN("cannot load/query segment %s, " 766 pr_err("DCSS %s exceeds the kernel mapping range (%lu) "
785 "exceeds kernel mapping range\n", seg_name); 767 "and cannot be loaded\n", seg_name, VMEM_MAX_PHYS);
786 break; 768 break;
787 default: 769 default:
788 PRINT_WARN("cannot load/query segment %s, "
789 "return value %i\n", seg_name, rc);
790 break; 770 break;
791 } 771 }
792} 772}
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index b1b204c448e..26ffc6ab441 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -4,6 +4,9 @@
4 * Authors: Carsten Otte, Stefan Weinhuber, Gerald Schaefer 4 * Authors: Carsten Otte, Stefan Weinhuber, Gerald Schaefer
5 */ 5 */
6 6
7#define KMSG_COMPONENT "dcssblk"
8#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
9
7#include <linux/module.h> 10#include <linux/module.h>
8#include <linux/moduleparam.h> 11#include <linux/moduleparam.h>
9#include <linux/ctype.h> 12#include <linux/ctype.h>
@@ -17,21 +20,11 @@
17#include <linux/interrupt.h> 20#include <linux/interrupt.h>
18#include <asm/s390_rdev.h> 21#include <asm/s390_rdev.h>
19 22
20//#define DCSSBLK_DEBUG /* Debug messages on/off */
21#define DCSSBLK_NAME "dcssblk" 23#define DCSSBLK_NAME "dcssblk"
22#define DCSSBLK_MINORS_PER_DISK 1 24#define DCSSBLK_MINORS_PER_DISK 1
23#define DCSSBLK_PARM_LEN 400 25#define DCSSBLK_PARM_LEN 400
24#define DCSS_BUS_ID_SIZE 20 26#define DCSS_BUS_ID_SIZE 20
25 27
26#ifdef DCSSBLK_DEBUG
27#define PRINT_DEBUG(x...) printk(KERN_DEBUG DCSSBLK_NAME " debug: " x)
28#else
29#define PRINT_DEBUG(x...) do {} while (0)
30#endif
31#define PRINT_INFO(x...) printk(KERN_INFO DCSSBLK_NAME " info: " x)
32#define PRINT_WARN(x...) printk(KERN_WARNING DCSSBLK_NAME " warning: " x)
33#define PRINT_ERR(x...) printk(KERN_ERR DCSSBLK_NAME " error: " x)
34
35static int dcssblk_open(struct block_device *bdev, fmode_t mode); 28static int dcssblk_open(struct block_device *bdev, fmode_t mode);
36static int dcssblk_release(struct gendisk *disk, fmode_t mode); 29static int dcssblk_release(struct gendisk *disk, fmode_t mode);
37static int dcssblk_make_request(struct request_queue *q, struct bio *bio); 30static int dcssblk_make_request(struct request_queue *q, struct bio *bio);
@@ -262,10 +255,9 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info)
262 /* check continuity */ 255 /* check continuity */
263 for (i = 0; i < dev_info->num_of_segments - 1; i++) { 256 for (i = 0; i < dev_info->num_of_segments - 1; i++) {
264 if ((sort_list[i].end + 1) != sort_list[i+1].start) { 257 if ((sort_list[i].end + 1) != sort_list[i+1].start) {
265 PRINT_ERR("Segment %s is not contiguous with " 258 pr_err("Adjacent DCSSs %s and %s are not "
266 "segment %s\n", 259 "contiguous\n", sort_list[i].segment_name,
267 sort_list[i].segment_name, 260 sort_list[i+1].segment_name);
268 sort_list[i+1].segment_name);
269 rc = -EINVAL; 261 rc = -EINVAL;
270 goto out; 262 goto out;
271 } 263 }
@@ -276,10 +268,10 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info)
276 !(sort_list[i+1].segment_type & 268 !(sort_list[i+1].segment_type &
277 SEGMENT_EXCLUSIVE) || 269 SEGMENT_EXCLUSIVE) ||
278 (sort_list[i+1].segment_type == SEG_TYPE_ER)) { 270 (sort_list[i+1].segment_type == SEG_TYPE_ER)) {
279 PRINT_ERR("Segment %s has different type from " 271 pr_err("DCSS %s and DCSS %s have "
280 "segment %s\n", 272 "incompatible types\n",
281 sort_list[i].segment_name, 273 sort_list[i].segment_name,
282 sort_list[i+1].segment_name); 274 sort_list[i+1].segment_name);
283 rc = -EINVAL; 275 rc = -EINVAL;
284 goto out; 276 goto out;
285 } 277 }
@@ -381,8 +373,9 @@ dcssblk_shared_store(struct device *dev, struct device_attribute *attr, const ch
381 } else if (inbuf[0] == '0') { 373 } else if (inbuf[0] == '0') {
382 /* reload segments in exclusive mode */ 374 /* reload segments in exclusive mode */
383 if (dev_info->segment_type == SEG_TYPE_SC) { 375 if (dev_info->segment_type == SEG_TYPE_SC) {
384 PRINT_ERR("Segment type SC (%s) cannot be loaded in " 376 pr_err("DCSS %s is of type SC and cannot be "
385 "non-shared mode\n", dev_info->segment_name); 377 "loaded as exclusive-writable\n",
378 dev_info->segment_name);
386 rc = -EINVAL; 379 rc = -EINVAL;
387 goto out; 380 goto out;
388 } 381 }
@@ -405,9 +398,8 @@ dcssblk_shared_store(struct device *dev, struct device_attribute *attr, const ch
405 goto out; 398 goto out;
406 399
407removeseg: 400removeseg:
408 PRINT_ERR("Could not reload segment(s) of the device %s, removing " 401 pr_err("DCSS device %s is removed after a failed access mode "
409 "segment(s) now!\n", 402 "change\n", dev_info->segment_name);
410 dev_info->segment_name);
411 temp = entry; 403 temp = entry;
412 list_for_each_entry(entry, &dev_info->seg_list, lh) { 404 list_for_each_entry(entry, &dev_info->seg_list, lh) {
413 if (entry != temp) 405 if (entry != temp)
@@ -455,17 +447,17 @@ dcssblk_save_store(struct device *dev, struct device_attribute *attr, const char
455 if (inbuf[0] == '1') { 447 if (inbuf[0] == '1') {
456 if (atomic_read(&dev_info->use_count) == 0) { 448 if (atomic_read(&dev_info->use_count) == 0) {
457 // device is idle => we save immediately 449 // device is idle => we save immediately
458 PRINT_INFO("Saving segment(s) of the device %s\n", 450 pr_info("All DCSSs that map to device %s are "
459 dev_info->segment_name); 451 "saved\n", dev_info->segment_name);
460 list_for_each_entry(entry, &dev_info->seg_list, lh) { 452 list_for_each_entry(entry, &dev_info->seg_list, lh) {
461 segment_save(entry->segment_name); 453 segment_save(entry->segment_name);
462 } 454 }
463 } else { 455 } else {
464 // device is busy => we save it when it becomes 456 // device is busy => we save it when it becomes
465 // idle in dcssblk_release 457 // idle in dcssblk_release
466 PRINT_INFO("Device %s is currently busy, segment(s) " 458 pr_info("Device %s is in use, its DCSSs will be "
467 "will be saved when it becomes idle...\n", 459 "saved when it becomes idle\n",
468 dev_info->segment_name); 460 dev_info->segment_name);
469 dev_info->save_pending = 1; 461 dev_info->save_pending = 1;
470 } 462 }
471 } else if (inbuf[0] == '0') { 463 } else if (inbuf[0] == '0') {
@@ -473,9 +465,9 @@ dcssblk_save_store(struct device *dev, struct device_attribute *attr, const char
473 // device is busy & the user wants to undo his save 465 // device is busy & the user wants to undo his save
474 // request 466 // request
475 dev_info->save_pending = 0; 467 dev_info->save_pending = 0;
476 PRINT_INFO("Pending save for segment(s) of the device " 468 pr_info("A pending save request for device %s "
477 "%s deactivated\n", 469 "has been canceled\n",
478 dev_info->segment_name); 470 dev_info->segment_name);
479 } 471 }
480 } else { 472 } else {
481 up_write(&dcssblk_devices_sem); 473 up_write(&dcssblk_devices_sem);
@@ -615,9 +607,8 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
615 607
616 seg_byte_size = (dev_info->end - dev_info->start + 1); 608 seg_byte_size = (dev_info->end - dev_info->start + 1);
617 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors 609 set_capacity(dev_info->gd, seg_byte_size >> 9); // size in sectors
618 PRINT_INFO("Loaded segment(s) %s, size = %lu Byte, " 610 pr_info("Loaded %s with total size %lu bytes and capacity %lu "
619 "capacity = %lu (512 Byte) sectors\n", local_buf, 611 "sectors\n", local_buf, seg_byte_size, seg_byte_size >> 9);
620 seg_byte_size, seg_byte_size >> 9);
621 612
622 dev_info->save_pending = 0; 613 dev_info->save_pending = 0;
623 dev_info->is_shared = 1; 614 dev_info->is_shared = 1;
@@ -745,13 +736,15 @@ dcssblk_remove_store(struct device *dev, struct device_attribute *attr, const ch
745 dev_info = dcssblk_get_device_by_name(local_buf); 736 dev_info = dcssblk_get_device_by_name(local_buf);
746 if (dev_info == NULL) { 737 if (dev_info == NULL) {
747 up_write(&dcssblk_devices_sem); 738 up_write(&dcssblk_devices_sem);
748 PRINT_WARN("Device %s is not loaded!\n", local_buf); 739 pr_warning("Device %s cannot be removed because it is not a "
740 "known device\n", local_buf);
749 rc = -ENODEV; 741 rc = -ENODEV;
750 goto out_buf; 742 goto out_buf;
751 } 743 }
752 if (atomic_read(&dev_info->use_count) != 0) { 744 if (atomic_read(&dev_info->use_count) != 0) {
753 up_write(&dcssblk_devices_sem); 745 up_write(&dcssblk_devices_sem);
754 PRINT_WARN("Device %s is in use!\n", local_buf); 746 pr_warning("Device %s cannot be removed while it is in "
747 "use\n", local_buf);
755 rc = -EBUSY; 748 rc = -EBUSY;
756 goto out_buf; 749 goto out_buf;
757 } 750 }
@@ -808,8 +801,8 @@ dcssblk_release(struct gendisk *disk, fmode_t mode)
808 down_write(&dcssblk_devices_sem); 801 down_write(&dcssblk_devices_sem);
809 if (atomic_dec_and_test(&dev_info->use_count) 802 if (atomic_dec_and_test(&dev_info->use_count)
810 && (dev_info->save_pending)) { 803 && (dev_info->save_pending)) {
811 PRINT_INFO("Device %s became idle and is being saved now\n", 804 pr_info("Device %s has become idle and is being saved "
812 dev_info->segment_name); 805 "now\n", dev_info->segment_name);
813 list_for_each_entry(entry, &dev_info->seg_list, lh) { 806 list_for_each_entry(entry, &dev_info->seg_list, lh) {
814 segment_save(entry->segment_name); 807 segment_save(entry->segment_name);
815 } 808 }
@@ -852,7 +845,8 @@ dcssblk_make_request(struct request_queue *q, struct bio *bio)
852 case SEG_TYPE_SC: 845 case SEG_TYPE_SC:
853 /* cannot write to these segments */ 846 /* cannot write to these segments */
854 if (bio_data_dir(bio) == WRITE) { 847 if (bio_data_dir(bio) == WRITE) {
855 PRINT_WARN("rejecting write to ro device %s\n", 848 pr_warning("Writing to %s failed because it "
849 "is a read-only device\n",
856 dev_name(&dev_info->dev)); 850 dev_name(&dev_info->dev));
857 goto fail; 851 goto fail;
858 } 852 }