aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/cio/chsc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/cio/chsc.c')
-rw-r--r--drivers/s390/cio/chsc.c473
1 files changed, 38 insertions, 435 deletions
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index b329851f7b55..d99f525eac08 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -21,54 +21,11 @@
21#include "cio_debug.h" 21#include "cio_debug.h"
22#include "ioasm.h" 22#include "ioasm.h"
23#include "chpid.h" 23#include "chpid.h"
24#include "chp.h"
24#include "chsc.h" 25#include "chsc.h"
25 26
26static void *sei_page; 27static void *sei_page;
27 28
28static int new_channel_path(struct chp_id chpid);
29
30static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
31{
32 return css[chpid.cssid]->chps[chpid.id];
33}
34
35static void set_chp_logically_online(struct chp_id chpid, int onoff)
36{
37 chpid_to_chp(chpid)->state = onoff;
38}
39
40static int get_chp_status(struct chp_id chpid)
41{
42 return (chpid_to_chp(chpid) ? chpid_to_chp(chpid)->state : -ENODEV);
43}
44
45void chsc_validate_chpids(struct subchannel *sch)
46{
47 int mask, chp;
48 struct chp_id chpid;
49
50 chp_id_init(&chpid);
51 for (chp = 0; chp <= 7; chp++) {
52 mask = 0x80 >> chp;
53 chpid.id = sch->schib.pmcw.chpid[chp];
54 if (!get_chp_status(chpid))
55 /* disable using this path */
56 sch->opm &= ~mask;
57 }
58}
59
60void chpid_is_actually_online(struct chp_id chpid)
61{
62 int state;
63
64 state = get_chp_status(chpid);
65 if (state < 0) {
66 need_rescan = 1;
67 queue_work(slow_path_wq, &slow_path_work);
68 } else
69 WARN_ON(!state);
70}
71
72/* FIXME: this is _always_ called for every subchannel. shouldn't we 29/* FIXME: this is _always_ called for every subchannel. shouldn't we
73 * process more than one at a time? */ 30 * process more than one at a time? */
74static int 31static int
@@ -214,8 +171,8 @@ css_get_ssd_info(struct subchannel *sch)
214 mask = 0x80 >> j; 171 mask = 0x80 >> j;
215 chpid.id = sch->ssd_info.chpid[j]; 172 chpid.id = sch->ssd_info.chpid[j];
216 if ((sch->schib.pmcw.pim & mask) && 173 if ((sch->schib.pmcw.pim & mask) &&
217 (get_chp_status(chpid) < 0)) 174 !chp_is_registered(chpid))
218 new_channel_path(chpid); 175 chp_new(chpid);
219 } 176 }
220 } 177 }
221 return ret; 178 return ret;
@@ -227,7 +184,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
227 int j; 184 int j;
228 int mask; 185 int mask;
229 struct subchannel *sch; 186 struct subchannel *sch;
230 struct channel_path *chpid; 187 struct chp_id *chpid;
231 struct schib schib; 188 struct schib schib;
232 189
233 sch = to_subchannel(dev); 190 sch = to_subchannel(dev);
@@ -235,7 +192,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
235 for (j = 0; j < 8; j++) { 192 for (j = 0; j < 8; j++) {
236 mask = 0x80 >> j; 193 mask = 0x80 >> j;
237 if ((sch->schib.pmcw.pim & mask) && 194 if ((sch->schib.pmcw.pim & mask) &&
238 (sch->schib.pmcw.chpid[j] == chpid->chpid.id)) 195 (sch->schib.pmcw.chpid[j] == chpid->id))
239 break; 196 break;
240 } 197 }
241 if (j >= 8) 198 if (j >= 8)
@@ -285,51 +242,48 @@ out_unreg:
285 return 0; 242 return 0;
286} 243}
287 244
288static void s390_set_chpid_offline(struct chp_id chpid) 245void chsc_chp_offline(struct chp_id chpid)
289{ 246{
290 char dbf_txt[15]; 247 char dbf_txt[15];
291 struct device *dev;
292 248
293 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id); 249 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id);
294 CIO_TRACE_EVENT(2, dbf_txt); 250 CIO_TRACE_EVENT(2, dbf_txt);
295 251
296 if (get_chp_status(chpid) <= 0) 252 if (chp_get_status(chpid) <= 0)
297 return; 253 return;
298 dev = get_device(&(chpid_to_chp(chpid)->dev)); 254 bus_for_each_dev(&css_bus_type, NULL, &chpid,
299 bus_for_each_dev(&css_bus_type, NULL, to_channelpath(dev),
300 s390_subchannel_remove_chpid); 255 s390_subchannel_remove_chpid);
301 256
302 if (need_rescan || css_slow_subchannels_exist()) 257 if (need_rescan || css_slow_subchannels_exist())
303 queue_work(slow_path_wq, &slow_path_work); 258 queue_work(slow_path_wq, &slow_path_work);
304 put_device(dev);
305} 259}
306 260
307struct res_acc_data { 261struct res_acc_data {
308 struct channel_path *chp; 262 struct chp_id chpid;
309 u32 fla_mask; 263 u32 fla_mask;
310 u16 fla; 264 u16 fla;
311}; 265};
312 266
313static int 267static int s390_process_res_acc_sch(struct res_acc_data *res_data,
314s390_process_res_acc_sch(struct res_acc_data *res_data, struct subchannel *sch) 268 struct subchannel *sch)
315{ 269{
316 int found; 270 int found;
317 int chp; 271 int chp;
318 int ccode; 272 int ccode;
319 273
320 found = 0; 274 found = 0;
321 for (chp = 0; chp <= 7; chp++) 275 for (chp = 0; chp <= 7; chp++)
322 /* 276 /*
323 * check if chpid is in information updated by ssd 277 * check if chpid is in information updated by ssd
324 */ 278 */
325 if (sch->ssd_info.valid && 279 if (sch->ssd_info.valid &&
326 sch->ssd_info.chpid[chp] == res_data->chp->chpid.id && 280 sch->ssd_info.chpid[chp] == res_data->chpid.id &&
327 (sch->ssd_info.fla[chp] & res_data->fla_mask) 281 (sch->ssd_info.fla[chp] & res_data->fla_mask)
328 == res_data->fla) { 282 == res_data->fla) {
329 found = 1; 283 found = 1;
330 break; 284 break;
331 } 285 }
332 286
333 if (found == 0) 287 if (found == 0)
334 return 0; 288 return 0;
335 289
@@ -416,8 +370,8 @@ s390_process_res_acc (struct res_acc_data *res_data)
416 int rc; 370 int rc;
417 char dbf_txt[15]; 371 char dbf_txt[15];
418 372
419 sprintf(dbf_txt, "accpr%x.%02x", res_data->chp->chpid.cssid, 373 sprintf(dbf_txt, "accpr%x.%02x", res_data->chpid.cssid,
420 res_data->chp->chpid.id); 374 res_data->chpid.id);
421 CIO_TRACE_EVENT( 2, dbf_txt); 375 CIO_TRACE_EVENT( 2, dbf_txt);
422 if (res_data->fla != 0) { 376 if (res_data->fla != 0) {
423 sprintf(dbf_txt, "fla%x", res_data->fla); 377 sprintf(dbf_txt, "fla%x", res_data->fla);
@@ -503,7 +457,7 @@ static int chsc_process_sei_link_incident(struct chsc_sei_area *sei_area)
503 else { 457 else {
504 chp_id_init(&chpid); 458 chp_id_init(&chpid);
505 chpid.id = id; 459 chpid.id = id;
506 s390_set_chpid_offline(chpid); 460 chsc_chp_offline(chpid);
507 } 461 }
508 462
509 return 0; 463 return 0;
@@ -512,7 +466,6 @@ static int chsc_process_sei_link_incident(struct chsc_sei_area *sei_area)
512static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area) 466static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area)
513{ 467{
514 struct res_acc_data res_data; 468 struct res_acc_data res_data;
515 struct device *dev;
516 struct chp_id chpid; 469 struct chp_id chpid;
517 int status; 470 int status;
518 int rc; 471 int rc;
@@ -524,14 +477,13 @@ static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area)
524 chp_id_init(&chpid); 477 chp_id_init(&chpid);
525 chpid.id = sei_area->rsid; 478 chpid.id = sei_area->rsid;
526 /* allocate a new channel path structure, if needed */ 479 /* allocate a new channel path structure, if needed */
527 status = get_chp_status(chpid); 480 status = chp_get_status(chpid);
528 if (status < 0) 481 if (status < 0)
529 new_channel_path(chpid); 482 chp_new(chpid);
530 else if (!status) 483 else if (!status)
531 return 0; 484 return 0;
532 dev = get_device(&(chpid_to_chp(chpid)->dev));
533 memset(&res_data, 0, sizeof(struct res_acc_data)); 485 memset(&res_data, 0, sizeof(struct res_acc_data));
534 res_data.chp = to_channelpath(dev); 486 res_data.chpid = chpid;
535 if ((sei_area->vf & 0xc0) != 0) { 487 if ((sei_area->vf & 0xc0) != 0) {
536 res_data.fla = sei_area->fla; 488 res_data.fla = sei_area->fla;
537 if ((sei_area->vf & 0xc0) == 0xc0) 489 if ((sei_area->vf & 0xc0) == 0xc0)
@@ -542,7 +494,6 @@ static int chsc_process_sei_res_acc(struct chsc_sei_area *sei_area)
542 res_data.fla_mask = 0xff00; 494 res_data.fla_mask = 0xff00;
543 } 495 }
544 rc = s390_process_res_acc(&res_data); 496 rc = s390_process_res_acc(&res_data);
545 put_device(dev);
546 497
547 return rc; 498 return rc;
548} 499}
@@ -634,10 +585,10 @@ static int
634__chp_add(struct subchannel_id schid, void *data) 585__chp_add(struct subchannel_id schid, void *data)
635{ 586{
636 int i, mask; 587 int i, mask;
637 struct channel_path *chp; 588 struct chp_id *chpid;
638 struct subchannel *sch; 589 struct subchannel *sch;
639 590
640 chp = data; 591 chpid = data;
641 sch = get_subchannel_by_schid(schid); 592 sch = get_subchannel_by_schid(schid);
642 if (!sch) 593 if (!sch)
643 /* Check if the subchannel is now available. */ 594 /* Check if the subchannel is now available. */
@@ -646,7 +597,7 @@ __chp_add(struct subchannel_id schid, void *data)
646 for (i=0; i<8; i++) { 597 for (i=0; i<8; i++) {
647 mask = 0x80 >> i; 598 mask = 0x80 >> i;
648 if ((sch->schib.pmcw.pim & mask) && 599 if ((sch->schib.pmcw.pim & mask) &&
649 (sch->schib.pmcw.chpid[i] == chp->chpid.id)) { 600 (sch->schib.pmcw.chpid[i] == chpid->id)) {
650 if (stsch(sch->schid, &sch->schib) != 0) { 601 if (stsch(sch->schid, &sch->schib) != 0) {
651 /* Endgame. */ 602 /* Endgame. */
652 spin_unlock_irq(sch->lock); 603 spin_unlock_irq(sch->lock);
@@ -672,52 +623,24 @@ __chp_add(struct subchannel_id schid, void *data)
672 return 0; 623 return 0;
673} 624}
674 625
675static int chp_add(struct chp_id chpid) 626int chsc_chp_online(struct chp_id chpid)
676{ 627{
677 int rc; 628 int rc;
678 char dbf_txt[15]; 629 char dbf_txt[15];
679 struct device *dev;
680 630
681 if (!get_chp_status(chpid))
682 return 0; /* no need to do the rest */
683
684 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id); 631 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id);
685 CIO_TRACE_EVENT(2, dbf_txt); 632 CIO_TRACE_EVENT(2, dbf_txt);
686 633
687 dev = get_device(&(chpid_to_chp(chpid)->dev)); 634 if (chp_get_status(chpid) == 0)
688 rc = for_each_subchannel(__chp_add, to_channelpath(dev)); 635 return 0;
636 rc = for_each_subchannel(__chp_add, &chpid);
689 if (css_slow_subchannels_exist()) 637 if (css_slow_subchannels_exist())
690 rc = -EAGAIN; 638 rc = -EAGAIN;
691 if (rc != -EAGAIN) 639 if (rc != -EAGAIN)
692 rc = 0; 640 rc = 0;
693 put_device(dev);
694 return rc; 641 return rc;
695} 642}
696 643
697/*
698 * Handling of crw machine checks with channel path source.
699 */
700int chp_process_crw(int id, int on)
701{
702 struct chp_id chpid;
703
704 chp_id_init(&chpid);
705 chpid.id = id;
706 if (on == 0) {
707 /* Path has gone. We use the link incident routine.*/
708 s390_set_chpid_offline(chpid);
709 return 0; /* De-register is async anyway. */
710 }
711 /*
712 * Path has come. Allocate a new channel path structure,
713 * if needed.
714 */
715 if (get_chp_status(chpid) < 0)
716 new_channel_path(chpid);
717 /* Avoid the extra overhead in process_rec_acc. */
718 return chp_add(chpid);
719}
720
721static int check_for_io_on_path(struct subchannel *sch, int index) 644static int check_for_io_on_path(struct subchannel *sch, int index)
722{ 645{
723 int cc; 646 int cc;
@@ -844,34 +767,13 @@ __s390_vary_chpid_on(struct subchannel_id schid, void *data)
844 return 0; 767 return 0;
845} 768}
846 769
847/* 770/**
848 * Function: s390_vary_chpid 771 * chsc_chp_vary - propagate channel-path vary operation to subchannels
849 * Varies the specified chpid online or offline 772 * @chpid: channl-path ID
773 * @on: non-zero for vary online, zero for vary offline
850 */ 774 */
851static int s390_vary_chpid(struct chp_id chpid, int on) 775int chsc_chp_vary(struct chp_id chpid, int on)
852{ 776{
853 char dbf_text[15];
854 int status;
855
856 sprintf(dbf_text, on?"varyon%x.%02x":"varyoff%x.%02x", chpid.cssid,
857 chpid.id);
858 CIO_TRACE_EVENT( 2, dbf_text);
859
860 status = get_chp_status(chpid);
861 if (status < 0) {
862 printk(KERN_ERR "Can't vary unknown chpid %x.%02x\n",
863 chpid.cssid, chpid.id);
864 return -EINVAL;
865 }
866
867 if (!on && !status) {
868 printk(KERN_ERR "chpid %x.%02x is already offline\n",
869 chpid.cssid, chpid.id);
870 return -EINVAL;
871 }
872
873 set_chp_logically_online(chpid, on);
874
875 /* 777 /*
876 * Redo PathVerification on the devices the chpid connects to 778 * Redo PathVerification on the devices the chpid connects to
877 */ 779 */
@@ -887,112 +789,6 @@ static int s390_vary_chpid(struct chp_id chpid, int on)
887 return 0; 789 return 0;
888} 790}
889 791
890/*
891 * Channel measurement related functions
892 */
893static ssize_t
894chp_measurement_chars_read(struct kobject *kobj, char *buf, loff_t off,
895 size_t count)
896{
897 struct channel_path *chp;
898 unsigned int size;
899
900 chp = to_channelpath(container_of(kobj, struct device, kobj));
901 if (!chp->cmg_chars)
902 return 0;
903
904 size = sizeof(struct cmg_chars);
905
906 if (off > size)
907 return 0;
908 if (off + count > size)
909 count = size - off;
910 memcpy(buf, chp->cmg_chars + off, count);
911 return count;
912}
913
914static struct bin_attribute chp_measurement_chars_attr = {
915 .attr = {
916 .name = "measurement_chars",
917 .mode = S_IRUSR,
918 .owner = THIS_MODULE,
919 },
920 .size = sizeof(struct cmg_chars),
921 .read = chp_measurement_chars_read,
922};
923
924static void chp_measurement_copy_block(struct cmg_entry *buf,
925 struct channel_subsystem *css, struct chp_id chpid)
926{
927 void *area;
928 struct cmg_entry *entry, reference_buf;
929 int idx;
930
931 if (chpid.id < 128) {
932 area = css->cub_addr1;
933 idx = chpid.id;
934 } else {
935 area = css->cub_addr2;
936 idx = chpid.id - 128;
937 }
938 entry = area + (idx * sizeof(struct cmg_entry));
939 do {
940 memcpy(buf, entry, sizeof(*entry));
941 memcpy(&reference_buf, entry, sizeof(*entry));
942 } while (reference_buf.values[0] != buf->values[0]);
943}
944
945static ssize_t
946chp_measurement_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
947{
948 struct channel_path *chp;
949 struct channel_subsystem *css;
950 unsigned int size;
951
952 chp = to_channelpath(container_of(kobj, struct device, kobj));
953 css = to_css(chp->dev.parent);
954
955 size = sizeof(struct cmg_entry);
956
957 /* Only allow single reads. */
958 if (off || count < size)
959 return 0;
960 chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->chpid);
961 count = size;
962 return count;
963}
964
965static struct bin_attribute chp_measurement_attr = {
966 .attr = {
967 .name = "measurement",
968 .mode = S_IRUSR,
969 .owner = THIS_MODULE,
970 },
971 .size = sizeof(struct cmg_entry),
972 .read = chp_measurement_read,
973};
974
975static void
976chsc_remove_chp_cmg_attr(struct channel_path *chp)
977{
978 device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
979 device_remove_bin_file(&chp->dev, &chp_measurement_attr);
980}
981
982static int
983chsc_add_chp_cmg_attr(struct channel_path *chp)
984{
985 int ret;
986
987 ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
988 if (ret)
989 return ret;
990 ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
991 if (ret)
992 device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
993 return ret;
994}
995
996static void 792static void
997chsc_remove_cmg_attr(struct channel_subsystem *css) 793chsc_remove_cmg_attr(struct channel_subsystem *css)
998{ 794{
@@ -1001,7 +797,7 @@ chsc_remove_cmg_attr(struct channel_subsystem *css)
1001 for (i = 0; i <= __MAX_CHPID; i++) { 797 for (i = 0; i <= __MAX_CHPID; i++) {
1002 if (!css->chps[i]) 798 if (!css->chps[i])
1003 continue; 799 continue;
1004 chsc_remove_chp_cmg_attr(css->chps[i]); 800 chp_remove_cmg_attr(css->chps[i]);
1005 } 801 }
1006} 802}
1007 803
@@ -1014,7 +810,7 @@ chsc_add_cmg_attr(struct channel_subsystem *css)
1014 for (i = 0; i <= __MAX_CHPID; i++) { 810 for (i = 0; i <= __MAX_CHPID; i++) {
1015 if (!css->chps[i]) 811 if (!css->chps[i])
1016 continue; 812 continue;
1017 ret = chsc_add_chp_cmg_attr(css->chps[i]); 813 ret = chp_add_cmg_attr(css->chps[i]);
1018 if (ret) 814 if (ret)
1019 goto cleanup; 815 goto cleanup;
1020 } 816 }
@@ -1023,12 +819,11 @@ cleanup:
1023 for (--i; i >= 0; i--) { 819 for (--i; i >= 0; i--) {
1024 if (!css->chps[i]) 820 if (!css->chps[i])
1025 continue; 821 continue;
1026 chsc_remove_chp_cmg_attr(css->chps[i]); 822 chp_remove_cmg_attr(css->chps[i]);
1027 } 823 }
1028 return ret; 824 return ret;
1029} 825}
1030 826
1031
1032static int 827static int
1033__chsc_do_secm(struct channel_subsystem *css, int enable, void *page) 828__chsc_do_secm(struct channel_subsystem *css, int enable, void *page)
1034{ 829{
@@ -1143,108 +938,8 @@ chsc_secm(struct channel_subsystem *css, int enable)
1143 return ret; 938 return ret;
1144} 939}
1145 940
1146/* 941int chsc_determine_channel_path_description(struct chp_id chpid,
1147 * Files for the channel path entries. 942 struct channel_path_desc *desc)
1148 */
1149static ssize_t
1150chp_status_show(struct device *dev, struct device_attribute *attr, char *buf)
1151{
1152 struct channel_path *chp = container_of(dev, struct channel_path, dev);
1153
1154 if (!chp)
1155 return 0;
1156 return (get_chp_status(chp->chpid) ? sprintf(buf, "online\n") :
1157 sprintf(buf, "offline\n"));
1158}
1159
1160static ssize_t
1161chp_status_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1162{
1163 struct channel_path *cp = container_of(dev, struct channel_path, dev);
1164 char cmd[10];
1165 int num_args;
1166 int error;
1167
1168 num_args = sscanf(buf, "%5s", cmd);
1169 if (!num_args)
1170 return count;
1171
1172 if (!strnicmp(cmd, "on", 2) || !strcmp(cmd, "1"))
1173 error = s390_vary_chpid(cp->chpid, 1);
1174 else if (!strnicmp(cmd, "off", 3) || !strcmp(cmd, "0"))
1175 error = s390_vary_chpid(cp->chpid, 0);
1176 else
1177 error = -EINVAL;
1178
1179 return error < 0 ? error : count;
1180
1181}
1182
1183static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write);
1184
1185static ssize_t
1186chp_type_show(struct device *dev, struct device_attribute *attr, char *buf)
1187{
1188 struct channel_path *chp = container_of(dev, struct channel_path, dev);
1189
1190 if (!chp)
1191 return 0;
1192 return sprintf(buf, "%x\n", chp->desc.desc);
1193}
1194
1195static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
1196
1197static ssize_t
1198chp_cmg_show(struct device *dev, struct device_attribute *attr, char *buf)
1199{
1200 struct channel_path *chp = to_channelpath(dev);
1201
1202 if (!chp)
1203 return 0;
1204 if (chp->cmg == -1) /* channel measurements not available */
1205 return sprintf(buf, "unknown\n");
1206 return sprintf(buf, "%x\n", chp->cmg);
1207}
1208
1209static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
1210
1211static ssize_t
1212chp_shared_show(struct device *dev, struct device_attribute *attr, char *buf)
1213{
1214 struct channel_path *chp = to_channelpath(dev);
1215
1216 if (!chp)
1217 return 0;
1218 if (chp->shared == -1) /* channel measurements not available */
1219 return sprintf(buf, "unknown\n");
1220 return sprintf(buf, "%x\n", chp->shared);
1221}
1222
1223static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
1224
1225static struct attribute * chp_attrs[] = {
1226 &dev_attr_status.attr,
1227 &dev_attr_type.attr,
1228 &dev_attr_cmg.attr,
1229 &dev_attr_shared.attr,
1230 NULL,
1231};
1232
1233static struct attribute_group chp_attr_group = {
1234 .attrs = chp_attrs,
1235};
1236
1237static void
1238chp_release(struct device *dev)
1239{
1240 struct channel_path *cp;
1241
1242 cp = container_of(dev, struct channel_path, dev);
1243 kfree(cp);
1244}
1245
1246static int chsc_determine_channel_path_description(struct chp_id chpid,
1247 struct channel_path_desc *desc)
1248{ 943{
1249 int ccode, ret; 944 int ccode, ret;
1250 945
@@ -1331,8 +1026,7 @@ chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
1331 } 1026 }
1332} 1027}
1333 1028
1334static int 1029int chsc_get_channel_measurement_chars(struct channel_path *chp)
1335chsc_get_channel_measurement_chars(struct channel_path *chp)
1336{ 1030{
1337 int ccode, ret; 1031 int ccode, ret;
1338 1032
@@ -1407,97 +1101,6 @@ out:
1407 return ret; 1101 return ret;
1408} 1102}
1409 1103
1410/*
1411 * Entries for chpids on the system bus.
1412 * This replaces /proc/chpids.
1413 */
1414static int new_channel_path(struct chp_id chpid)
1415{
1416 struct channel_path *chp;
1417 int ret;
1418
1419 chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
1420 if (!chp)
1421 return -ENOMEM;
1422
1423 /* fill in status, etc. */
1424 chp->chpid = chpid;
1425 chp->state = 1;
1426 chp->dev.parent = &css[chpid.cssid]->device;
1427 chp->dev.release = chp_release;
1428 snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp%x.%02x", chpid.cssid,
1429 chpid.id);
1430
1431 /* Obtain channel path description and fill it in. */
1432 ret = chsc_determine_channel_path_description(chpid, &chp->desc);
1433 if (ret)
1434 goto out_free;
1435 /* Get channel-measurement characteristics. */
1436 if (css_characteristics_avail && css_chsc_characteristics.scmc
1437 && css_chsc_characteristics.secm) {
1438 ret = chsc_get_channel_measurement_chars(chp);
1439 if (ret)
1440 goto out_free;
1441 } else {
1442 static int msg_done;
1443
1444 if (!msg_done) {
1445 printk(KERN_WARNING "cio: Channel measurements not "
1446 "available, continuing.\n");
1447 msg_done = 1;
1448 }
1449 chp->cmg = -1;
1450 }
1451
1452 /* make it known to the system */
1453 ret = device_register(&chp->dev);
1454 if (ret) {
1455 printk(KERN_WARNING "%s: could not register %x.%02x\n",
1456 __func__, chpid.cssid, chpid.id);
1457 goto out_free;
1458 }
1459 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
1460 if (ret) {
1461 device_unregister(&chp->dev);
1462 goto out_free;
1463 }
1464 mutex_lock(&css[chpid.cssid]->mutex);
1465 if (css[chpid.cssid]->cm_enabled) {
1466 ret = chsc_add_chp_cmg_attr(chp);
1467 if (ret) {
1468 sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
1469 device_unregister(&chp->dev);
1470 mutex_unlock(&css[chpid.cssid]->mutex);
1471 goto out_free;
1472 }
1473 }
1474 css[chpid.cssid]->chps[chpid.id] = chp;
1475 mutex_unlock(&css[chpid.cssid]->mutex);
1476 return ret;
1477out_free:
1478 kfree(chp);
1479 return ret;
1480}
1481
1482void *
1483chsc_get_chp_desc(struct subchannel *sch, int chp_no)
1484{
1485 struct channel_path *chp;
1486 struct channel_path_desc *desc;
1487 struct chp_id chpid;
1488
1489 chp_id_init(&chpid);
1490 chpid.id = sch->schib.pmcw.chpid[chp_no];
1491 chp = chpid_to_chp(chpid);
1492 if (!chp)
1493 return NULL;
1494 desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL);
1495 if (!desc)
1496 return NULL;
1497 memcpy(desc, &chp->desc, sizeof(struct channel_path_desc));
1498 return desc;
1499}
1500
1501static int __init 1104static int __init
1502chsc_alloc_sei_area(void) 1105chsc_alloc_sei_area(void)
1503{ 1106{