10 #define KMSG_COMPONENT "cio"
11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 #include <linux/module.h>
14 #include <linux/slab.h>
16 #include <linux/device.h>
19 #include <asm/chpid.h>
30 static void *sei_page;
31 static void *chsc_page;
98 spin_lock_irq(&chsc_page_lock);
100 ssd_area = chsc_page;
107 ccode = chsc(ssd_area);
115 CIO_MSG_EVENT(2,
"chsc: ssd failed for 0.%x.%04x (rc=%04x)\n",
132 for (i = 0; i < 8; i++) {
135 chp_id_init(&ssd->
chpid[i]);
142 spin_unlock_irq(&chsc_page_lock);
148 spin_lock_irq(sch->
lock);
152 spin_unlock_irq(sch->
lock);
157 spin_unlock_irq(sch->
lock);
179 static int s390_process_res_acc_new_sch(
struct subchannel_id schid,
void *data)
190 if (stsch_err(schid, &
schib))
199 static int __s390_process_res_acc(
struct subchannel *sch,
void *data)
201 spin_lock_irq(sch->
lock);
204 spin_unlock_irq(sch->
lock);
216 if (link->
fla != 0) {
230 s390_process_res_acc_new_sch, link);
234 __get_chpid_from_lir(
void *data)
252 if (!(lir->indesc[0]&0xc0000000))
255 if (!(lir->indesc[0]&0x10000000))
260 return (
u16) (lir->indesc[0]&0x000000ff);
289 if (sei_area->
rs != 4)
291 id = __get_chpid_from_lir(sei_area->
ccdf);
301 static void chsc_process_sei_res_acc(
struct chsc_sei_area *sei_area)
307 CIO_CRW_EVENT(4,
"chsc: resource accessibility event (rs=%02x, "
308 "rs_id=%04x)\n", sei_area->
rs, sei_area->
rsid);
309 if (sei_area->
rs != 4)
321 if ((sei_area->
vf & 0xc0) != 0) {
323 if ((sei_area->
vf & 0xc0) == 0xc0)
330 s390_process_res_acc(&link);
333 static void chsc_process_sei_chp_avail(
struct chsc_sei_area *sei_area)
340 CIO_CRW_EVENT(4,
"chsc: channel path availability information\n");
341 if (sei_area->
rs != 0)
343 data = sei_area->
ccdf;
346 if (!chp_test_bit(data, num))
352 chp = chpid_to_chp(
chpid);
369 static void chsc_process_sei_chp_config(
struct chsc_sei_area *sei_area)
374 char *
events[3] = {
"configure",
"deconfigure",
"cancel deconfigure"};
376 CIO_CRW_EVENT(4,
"chsc: channel-path-configuration notification\n");
377 if (sei_area->
rs != 0)
382 if (!chp_test_bit(data->
map, num))
385 pr_notice(
"Processing %s for channel path %x.%02x\n",
386 events[data->
op], chpid.
cssid, chpid.
id);
401 static void chsc_process_sei_scm_change(
struct chsc_sei_area *sei_area)
406 if (sei_area->
rs != 7)
412 " failed (rc=%d).\n", ret);
418 if (sei_area->
flags & 0x40) {
423 switch (sei_area->
cc) {
425 chsc_process_sei_link_incident(sei_area);
428 chsc_process_sei_res_acc(sei_area);
431 chsc_process_sei_chp_avail(sei_area);
434 chsc_process_sei_chp_config(sei_area);
437 chsc_process_sei_scm_change(sei_area);
446 static void chsc_process_crw(
struct crw *crw0,
struct crw *crw1,
int overflow)
455 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
466 memset(sei_area, 0,
sizeof(*sei_area));
467 sei_area->
request.length = 0x0010;
468 sei_area->
request.code = 0x000e;
472 if (sei_area->
response.code == 0x0001) {
474 chsc_process_sei(sei_area);
480 }
while (sei_area->
flags & 0x80);
501 static void __s390_subchannel_vary_chpid(
struct subchannel *sch,
502 struct chp_id chpid,
int on)
511 sch->
driver->chp_event(sch, &link,
513 spin_unlock_irqrestore(sch->
lock, flags);
516 static int s390_subchannel_vary_chpid_off(
struct subchannel *sch,
void *data)
520 __s390_subchannel_vary_chpid(sch, *chpid, 0);
524 static int s390_subchannel_vary_chpid_on(
struct subchannel *sch,
void *data)
528 __s390_subchannel_vary_chpid(sch, *chpid, 1);
537 if (stsch_err(schid, &
schib))
563 __s390_vary_chpid_on, &chpid);
598 for (--i; i >= 0; i--) {
627 spin_lock_irq(&chsc_page_lock);
629 secm_area = chsc_page;
630 secm_area->request.length = 0x0050;
631 secm_area->request.code = 0x0016;
634 secm_area->cub_addr1 = (
u64)(
unsigned long)css->
cub_addr1;
635 secm_area->cub_addr2 = (
u64)(
unsigned long)css->
cub_addr2;
637 secm_area->operation_code = enable ? 0 : 1;
639 ccode = chsc(secm_area);
645 switch (secm_area->response.code) {
655 secm_area->response.code);
657 spin_unlock_irq(&chsc_page_lock);
679 ret = chsc_add_cmg_attr(css);
685 chsc_remove_cmg_attr(css);
707 scpd_area->
request.length = 0x0010;
708 scpd_area->
request.code = 0x0002;
717 ccode = chsc(scpd_area);
738 scpd_area = chsc_page;
742 chsc_resp = (
void *)&scpd_area->
response;
743 memcpy(desc, &chsc_resp->
data,
sizeof(*desc));
745 spin_unlock_irqrestore(&chsc_page_lock, flags);
756 spin_lock_irq(&chsc_page_lock);
757 scpd_area = chsc_page;
761 chsc_resp = (
void *)&scpd_area->
response;
762 memcpy(desc, &chsc_resp->
data,
sizeof(*desc));
764 spin_unlock_irq(&chsc_page_lock);
777 mask = 0x80 >> (i + 3);
787 struct cmg_chars *cmg_chars;
816 spin_lock_irq(&chsc_page_lock);
818 scmc_area = chsc_page;
819 scmc_area->request.length = 0x0010;
820 scmc_area->request.code = 0x0022;
821 scmc_area->first_chpid = chp->
chpid.id;
822 scmc_area->last_chpid = chp->
chpid.id;
824 ccode = chsc(scmc_area);
833 scmc_area->response.code);
836 if (scmc_area->not_valid) {
841 chp->
cmg = scmc_area->cmg;
842 chp->
shared = scmc_area->shared;
843 if (chp->
cmg != 2 && chp->
cmg != 3) {
848 chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
849 (
struct cmg_chars *) &scmc_area->data);
851 spin_unlock_irq(&chsc_page_lock);
864 if (!sei_page || !chsc_page) {
897 u32 operation_data_area[252];
906 sda_area = chsc_page;
907 sda_area->request.length = 0x0400;
908 sda_area->request.code = 0x0031;
911 ret = chsc(sda_area);
917 switch (sda_area->response.code) {
926 operation_code, sda_area->response.code);
928 spin_unlock_irqrestore(&chsc_page_lock, flags);
946 u32 general_char[510];
950 spin_lock_irq(&chsc_page_lock);
952 scsc_area = chsc_page;
953 scsc_area->request.length = 0x0010;
954 scsc_area->request.code = 0x0010;
956 result = chsc(scsc_area);
970 scsc_area->response.code);
972 spin_unlock_irq(&chsc_page_lock);
985 unsigned int rsvd1 : 8;
986 unsigned int ctrl : 16;
987 unsigned int rsvd2[5];
989 unsigned int rsvd3[7];
995 rr->request.length = 0x0020;
996 rr->request.code = 0x0033;
1002 rc = (rr->response.code == 0x0001) ? 0 : -
EIO;
1010 unsigned int rsvd0[3];
1018 rr->request.length = 0x0010;
1019 rr->request.code = 0x0038;
1023 memcpy(result, &rr->data, size);
1024 return (rr->response.code == 0x0001) ? 0 : -
EIO;
1037 unsigned long flags;
1043 siosl_area = chsc_page;
1044 siosl_area->request.length = 0x0010;
1045 siosl_area->request.code = 0x0046;
1046 siosl_area->word1 = 0x80000000;
1047 siosl_area->sid =
schid;
1049 ccode = chsc(siosl_area);
1055 CIO_MSG_EVENT(2,
"chsc: chsc failed for 0.%x.%04x (ccode=%d)\n",
1061 CIO_MSG_EVENT(2,
"chsc: siosl failed for 0.%x.%04x (rc=%04x)\n",
1063 siosl_area->response.code);
1068 spin_unlock_irqrestore(&chsc_page_lock, flags);
1084 memset(scm_area, 0,
sizeof(*scm_area));
1085 scm_area->
request.length = 0x0020;
1086 scm_area->
request.code = 0x004C;
1089 ccode = chsc(scm_area);