2 * S/390 common I/O routines -- channel subsystem call
4 * Copyright IBM Corp. 1999,2012
5 * Author(s): Ingo Adlung (adlung@de.ibm.com)
6 * Cornelia Huck (cornelia.huck@de.ibm.com)
7 * Arnd Bergmann (arndb@de.ibm.com)
10 #define KMSG_COMPONENT "cio"
11 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <linux/pci.h>
20 #include <asm/chpid.h>
26 #include "cio_debug.h"
31 static void *sei_page;
32 static void *chsc_page;
33 static DEFINE_SPINLOCK(chsc_page_lock);
36 * chsc_error_from_response() - convert a chsc response to an error
37 * @response: chsc response code
39 * Returns an appropriate Linux error code for @response.
41 int chsc_error_from_response(int response)
65 EXPORT_SYMBOL_GPL(chsc_error_from_response);
67 struct chsc_ssd_area {
68 struct chsc_header request;
72 u16 f_sch; /* first subchannel */
74 u16 l_sch; /* last subchannel */
76 struct chsc_header response;
80 u8 st : 3; /* subchannel type */
82 u8 unit_addr; /* unit address */
83 u16 devno; /* device number */
86 u16 sch; /* subchannel */
87 u8 chpid[8]; /* chpids 0-7 */
88 u16 fla[8]; /* full link addresses 0-7 */
89 } __attribute__ ((packed));
91 int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd)
93 struct chsc_ssd_area *ssd_area;
99 spin_lock_irq(&chsc_page_lock);
100 memset(chsc_page, 0, PAGE_SIZE);
101 ssd_area = chsc_page;
102 ssd_area->request.length = 0x0010;
103 ssd_area->request.code = 0x0004;
104 ssd_area->ssid = schid.ssid;
105 ssd_area->f_sch = schid.sch_no;
106 ssd_area->l_sch = schid.sch_no;
108 ccode = chsc(ssd_area);
109 /* Check response. */
111 ret = (ccode == 3) ? -ENODEV : -EBUSY;
114 ret = chsc_error_from_response(ssd_area->response.code);
116 CIO_MSG_EVENT(2, "chsc: ssd failed for 0.%x.%04x (rc=%04x)\n",
117 schid.ssid, schid.sch_no,
118 ssd_area->response.code);
121 if (!ssd_area->sch_valid) {
127 memset(ssd, 0, sizeof(struct chsc_ssd_info));
128 if ((ssd_area->st != SUBCHANNEL_TYPE_IO) &&
129 (ssd_area->st != SUBCHANNEL_TYPE_MSG))
131 ssd->path_mask = ssd_area->path_mask;
132 ssd->fla_valid_mask = ssd_area->fla_valid_mask;
133 for (i = 0; i < 8; i++) {
135 if (ssd_area->path_mask & mask) {
136 chp_id_init(&ssd->chpid[i]);
137 ssd->chpid[i].id = ssd_area->chpid[i];
139 if (ssd_area->fla_valid_mask & mask)
140 ssd->fla[i] = ssd_area->fla[i];
143 spin_unlock_irq(&chsc_page_lock);
147 static int s390_subchannel_remove_chpid(struct subchannel *sch, void *data)
149 spin_lock_irq(sch->lock);
150 if (sch->driver && sch->driver->chp_event)
151 if (sch->driver->chp_event(sch, data, CHP_OFFLINE) != 0)
153 spin_unlock_irq(sch->lock);
158 spin_unlock_irq(sch->lock);
159 css_schedule_eval(sch->schid);
163 void chsc_chp_offline(struct chp_id chpid)
166 struct chp_link link;
168 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id);
169 CIO_TRACE_EVENT(2, dbf_txt);
171 if (chp_get_status(chpid) <= 0)
173 memset(&link, 0, sizeof(struct chp_link));
175 /* Wait until previous actions have settled. */
176 css_wait_for_slow_path();
177 for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link);
180 static int s390_process_res_acc_new_sch(struct subchannel_id schid, void *data)
184 * We don't know the device yet, but since a path
185 * may be available now to the device we'll have
186 * to do recognition again.
187 * Since we don't have any idea about which chpid
188 * that beast may be on we'll have to do a stsch
189 * on all devices, grr...
191 if (stsch_err(schid, &schib))
195 /* Put it on the slow path. */
196 css_schedule_eval(schid);
200 static int __s390_process_res_acc(struct subchannel *sch, void *data)
202 spin_lock_irq(sch->lock);
203 if (sch->driver && sch->driver->chp_event)
204 sch->driver->chp_event(sch, data, CHP_ONLINE);
205 spin_unlock_irq(sch->lock);
210 static void s390_process_res_acc(struct chp_link *link)
214 sprintf(dbf_txt, "accpr%x.%02x", link->chpid.cssid,
216 CIO_TRACE_EVENT( 2, dbf_txt);
217 if (link->fla != 0) {
218 sprintf(dbf_txt, "fla%x", link->fla);
219 CIO_TRACE_EVENT( 2, dbf_txt);
221 /* Wait until previous actions have settled. */
222 css_wait_for_slow_path();
224 * I/O resources may have become accessible.
225 * Scan through all subchannels that may be concerned and
226 * do a validation on those.
227 * The more information we have (info), the less scanning
228 * will we have to do.
230 for_each_subchannel_staged(__s390_process_res_acc,
231 s390_process_res_acc_new_sch, link);
235 __get_chpid_from_lir(void *data)
241 /* incident-node descriptor */
243 /* attached-node descriptor */
245 /* incident-specific information */
247 } __attribute__ ((packed)) *lir;
251 /* NULL link incident record */
253 if (!(lir->indesc[0]&0xc0000000))
254 /* node descriptor not valid */
256 if (!(lir->indesc[0]&0x10000000))
257 /* don't handle device-type nodes - FIXME */
259 /* Byte 3 contains the chpid. Could also be CTCA, but we don't care */
261 return (u16) (lir->indesc[0]&0x000000ff);
264 struct chsc_sei_nt0_area {
266 u8 vf; /* validity flags */
267 u8 rs; /* reporting source */
268 u8 cc; /* content code */
269 u16 fla; /* full link address */
270 u16 rsid; /* reporting source id */
273 /* ccdf has to be big enough for a link-incident record */
274 u8 ccdf[PAGE_SIZE - 24 - 16]; /* content-code dependent field */
277 struct chsc_sei_nt2_area {
278 u8 flags; /* p and v bit */
281 u8 cc; /* content code */
283 u8 ccdf[PAGE_SIZE - 24 - 56]; /* content-code dependent field */
286 #define CHSC_SEI_NT0 (1ULL << 63)
287 #define CHSC_SEI_NT2 (1ULL << 61)
290 struct chsc_header request;
292 u64 ntsm; /* notification type mask */
293 struct chsc_header response;
297 struct chsc_sei_nt0_area nt0_area;
298 struct chsc_sei_nt2_area nt2_area;
299 u8 nt_area[PAGE_SIZE - 24];
303 static void chsc_process_sei_link_incident(struct chsc_sei_nt0_area *sei_area)
308 CIO_CRW_EVENT(4, "chsc: link incident (rs=%02x, rs_id=%04x)\n",
309 sei_area->rs, sei_area->rsid);
310 if (sei_area->rs != 4)
312 id = __get_chpid_from_lir(sei_area->ccdf);
314 CIO_CRW_EVENT(4, "chsc: link incident - invalid LIR\n");
318 chsc_chp_offline(chpid);
322 static void chsc_process_sei_res_acc(struct chsc_sei_nt0_area *sei_area)
324 struct chp_link link;
328 CIO_CRW_EVENT(4, "chsc: resource accessibility event (rs=%02x, "
329 "rs_id=%04x)\n", sei_area->rs, sei_area->rsid);
330 if (sei_area->rs != 4)
333 chpid.id = sei_area->rsid;
334 /* allocate a new channel path structure, if needed */
335 status = chp_get_status(chpid);
340 memset(&link, 0, sizeof(struct chp_link));
342 if ((sei_area->vf & 0xc0) != 0) {
343 link.fla = sei_area->fla;
344 if ((sei_area->vf & 0xc0) == 0xc0)
345 /* full link address */
346 link.fla_mask = 0xffff;
349 link.fla_mask = 0xff00;
351 s390_process_res_acc(&link);
354 static void chsc_process_sei_chp_avail(struct chsc_sei_nt0_area *sei_area)
356 struct channel_path *chp;
361 CIO_CRW_EVENT(4, "chsc: channel path availability information\n");
362 if (sei_area->rs != 0)
364 data = sei_area->ccdf;
366 for (num = 0; num <= __MAX_CHPID; num++) {
367 if (!chp_test_bit(data, num))
371 CIO_CRW_EVENT(4, "Update information for channel path "
372 "%x.%02x\n", chpid.cssid, chpid.id);
373 chp = chpid_to_chp(chpid);
378 mutex_lock(&chp->lock);
379 chsc_determine_base_channel_path_desc(chpid, &chp->desc);
380 mutex_unlock(&chp->lock);
384 struct chp_config_data {
390 static void chsc_process_sei_chp_config(struct chsc_sei_nt0_area *sei_area)
392 struct chp_config_data *data;
395 char *events[3] = {"configure", "deconfigure", "cancel deconfigure"};
397 CIO_CRW_EVENT(4, "chsc: channel-path-configuration notification\n");
398 if (sei_area->rs != 0)
400 data = (struct chp_config_data *) &(sei_area->ccdf);
402 for (num = 0; num <= __MAX_CHPID; num++) {
403 if (!chp_test_bit(data->map, num))
406 pr_notice("Processing %s for channel path %x.%02x\n",
407 events[data->op], chpid.cssid, chpid.id);
410 chp_cfg_schedule(chpid, 1);
413 chp_cfg_schedule(chpid, 0);
416 chp_cfg_cancel_deconfigure(chpid);
422 static void chsc_process_sei_scm_change(struct chsc_sei_nt0_area *sei_area)
426 CIO_CRW_EVENT(4, "chsc: scm change notification\n");
427 if (sei_area->rs != 7)
430 ret = scm_update_information();
432 CIO_CRW_EVENT(0, "chsc: updating change notification"
433 " failed (rc=%d).\n", ret);
436 static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area)
439 switch (sei_area->cc) {
441 zpci_event_error(sei_area->ccdf);
444 zpci_event_availability(sei_area->ccdf);
447 CIO_CRW_EVENT(2, "chsc: unhandled sei content code %d\n",
454 static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area)
456 /* which kind of information was stored? */
457 switch (sei_area->cc) {
458 case 1: /* link incident*/
459 chsc_process_sei_link_incident(sei_area);
461 case 2: /* i/o resource accessibility */
462 chsc_process_sei_res_acc(sei_area);
464 case 7: /* channel-path-availability information */
465 chsc_process_sei_chp_avail(sei_area);
467 case 8: /* channel-path-configuration notification */
468 chsc_process_sei_chp_config(sei_area);
470 case 12: /* scm change notification */
471 chsc_process_sei_scm_change(sei_area);
473 default: /* other stuff */
474 CIO_CRW_EVENT(4, "chsc: unhandled sei content code %d\n",
480 static int __chsc_process_crw(struct chsc_sei *sei, u64 ntsm)
483 memset(sei, 0, sizeof(*sei));
484 sei->request.length = 0x0010;
485 sei->request.code = 0x000e;
491 if (sei->response.code == 0x0001) {
492 CIO_CRW_EVENT(2, "chsc: sei successful\n");
494 /* Check if we might have lost some information. */
495 if (sei->u.nt0_area.flags & 0x40) {
496 CIO_CRW_EVENT(2, "chsc: event overflow\n");
497 css_schedule_eval_all();
502 chsc_process_sei_nt0(&sei->u.nt0_area);
505 chsc_process_sei_nt2(&sei->u.nt2_area);
508 CIO_CRW_EVENT(2, "chsc: unhandled nt=%d\n",
513 CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x)\n",
517 } while (sei->u.nt0_area.flags & 0x80);
522 static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow)
524 struct chsc_sei *sei;
527 css_schedule_eval_all();
530 CIO_CRW_EVENT(2, "CRW reports slct=%d, oflw=%d, "
531 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
532 crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc,
533 crw0->erc, crw0->rsid);
536 /* Access to sei_page is serialized through machine check handler
537 * thread, so no need for locking. */
540 CIO_TRACE_EVENT(2, "prcss");
541 __chsc_process_crw(sei, CHSC_SEI_NT0 | CHSC_SEI_NT2);
544 void chsc_chp_online(struct chp_id chpid)
547 struct chp_link link;
549 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id);
550 CIO_TRACE_EVENT(2, dbf_txt);
552 if (chp_get_status(chpid) != 0) {
553 memset(&link, 0, sizeof(struct chp_link));
555 /* Wait until previous actions have settled. */
556 css_wait_for_slow_path();
557 for_each_subchannel_staged(__s390_process_res_acc, NULL,
562 static void __s390_subchannel_vary_chpid(struct subchannel *sch,
563 struct chp_id chpid, int on)
566 struct chp_link link;
568 memset(&link, 0, sizeof(struct chp_link));
570 spin_lock_irqsave(sch->lock, flags);
571 if (sch->driver && sch->driver->chp_event)
572 sch->driver->chp_event(sch, &link,
573 on ? CHP_VARY_ON : CHP_VARY_OFF);
574 spin_unlock_irqrestore(sch->lock, flags);
577 static int s390_subchannel_vary_chpid_off(struct subchannel *sch, void *data)
579 struct chp_id *chpid = data;
581 __s390_subchannel_vary_chpid(sch, *chpid, 0);
585 static int s390_subchannel_vary_chpid_on(struct subchannel *sch, void *data)
587 struct chp_id *chpid = data;
589 __s390_subchannel_vary_chpid(sch, *chpid, 1);
594 __s390_vary_chpid_on(struct subchannel_id schid, void *data)
598 if (stsch_err(schid, &schib))
601 /* Put it on the slow path. */
602 css_schedule_eval(schid);
607 * chsc_chp_vary - propagate channel-path vary operation to subchannels
608 * @chpid: channl-path ID
609 * @on: non-zero for vary online, zero for vary offline
611 int chsc_chp_vary(struct chp_id chpid, int on)
613 struct channel_path *chp = chpid_to_chp(chpid);
615 /* Wait until previous actions have settled. */
616 css_wait_for_slow_path();
618 * Redo PathVerification on the devices the chpid connects to
621 /* Try to update the channel path descritor. */
622 chsc_determine_base_channel_path_desc(chpid, &chp->desc);
623 for_each_subchannel_staged(s390_subchannel_vary_chpid_on,
624 __s390_vary_chpid_on, &chpid);
626 for_each_subchannel_staged(s390_subchannel_vary_chpid_off,
633 chsc_remove_cmg_attr(struct channel_subsystem *css)
637 for (i = 0; i <= __MAX_CHPID; i++) {
640 chp_remove_cmg_attr(css->chps[i]);
645 chsc_add_cmg_attr(struct channel_subsystem *css)
650 for (i = 0; i <= __MAX_CHPID; i++) {
653 ret = chp_add_cmg_attr(css->chps[i]);
659 for (--i; i >= 0; i--) {
662 chp_remove_cmg_attr(css->chps[i]);
667 int __chsc_do_secm(struct channel_subsystem *css, int enable)
670 struct chsc_header request;
671 u32 operation_code : 2;
680 struct chsc_header response;
685 } __attribute__ ((packed)) *secm_area;
688 spin_lock_irq(&chsc_page_lock);
689 memset(chsc_page, 0, PAGE_SIZE);
690 secm_area = chsc_page;
691 secm_area->request.length = 0x0050;
692 secm_area->request.code = 0x0016;
694 secm_area->key = PAGE_DEFAULT_KEY >> 4;
695 secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1;
696 secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2;
698 secm_area->operation_code = enable ? 0 : 1;
700 ccode = chsc(secm_area);
702 ret = (ccode == 3) ? -ENODEV : -EBUSY;
706 switch (secm_area->response.code) {
712 ret = chsc_error_from_response(secm_area->response.code);
715 CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n",
716 secm_area->response.code);
718 spin_unlock_irq(&chsc_page_lock);
723 chsc_secm(struct channel_subsystem *css, int enable)
727 if (enable && !css->cm_enabled) {
728 css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
729 css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
730 if (!css->cub_addr1 || !css->cub_addr2) {
731 free_page((unsigned long)css->cub_addr1);
732 free_page((unsigned long)css->cub_addr2);
736 ret = __chsc_do_secm(css, enable);
738 css->cm_enabled = enable;
739 if (css->cm_enabled) {
740 ret = chsc_add_cmg_attr(css);
742 __chsc_do_secm(css, 0);
746 chsc_remove_cmg_attr(css);
748 if (!css->cm_enabled) {
749 free_page((unsigned long)css->cub_addr1);
750 free_page((unsigned long)css->cub_addr2);
755 int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
756 int c, int m, void *page)
758 struct chsc_scpd *scpd_area;
761 if ((rfmt == 1) && !css_general_characteristics.fcs)
763 if ((rfmt == 2) && !css_general_characteristics.cib)
766 memset(page, 0, PAGE_SIZE);
768 scpd_area->request.length = 0x0010;
769 scpd_area->request.code = 0x0002;
770 scpd_area->cssid = chpid.cssid;
771 scpd_area->first_chpid = chpid.id;
772 scpd_area->last_chpid = chpid.id;
775 scpd_area->fmt = fmt;
776 scpd_area->rfmt = rfmt;
778 ccode = chsc(scpd_area);
780 return (ccode == 3) ? -ENODEV : -EBUSY;
782 ret = chsc_error_from_response(scpd_area->response.code);
784 CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
785 scpd_area->response.code);
788 EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc);
790 int chsc_determine_base_channel_path_desc(struct chp_id chpid,
791 struct channel_path_desc *desc)
793 struct chsc_response_struct *chsc_resp;
794 struct chsc_scpd *scpd_area;
798 spin_lock_irqsave(&chsc_page_lock, flags);
799 scpd_area = chsc_page;
800 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, scpd_area);
803 chsc_resp = (void *)&scpd_area->response;
804 memcpy(desc, &chsc_resp->data, sizeof(*desc));
806 spin_unlock_irqrestore(&chsc_page_lock, flags);
810 int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid,
811 struct channel_path_desc_fmt1 *desc)
813 struct chsc_response_struct *chsc_resp;
814 struct chsc_scpd *scpd_area;
817 spin_lock_irq(&chsc_page_lock);
818 scpd_area = chsc_page;
819 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 1, 0, scpd_area);
822 chsc_resp = (void *)&scpd_area->response;
823 memcpy(desc, &chsc_resp->data, sizeof(*desc));
825 spin_unlock_irq(&chsc_page_lock);
830 chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
831 struct cmg_chars *chars)
833 struct cmg_chars *cmg_chars;
836 cmg_chars = chp->cmg_chars;
837 for (i = 0; i < NR_MEASUREMENT_CHARS; i++) {
838 mask = 0x80 >> (i + 3);
840 cmg_chars->values[i] = chars->values[i];
842 cmg_chars->values[i] = 0;
846 int chsc_get_channel_measurement_chars(struct channel_path *chp)
848 struct cmg_chars *cmg_chars;
852 struct chsc_header request;
858 struct chsc_header response;
869 u32 data[NR_MEASUREMENT_CHARS];
870 } __attribute__ ((packed)) *scmc_area;
872 chp->cmg_chars = NULL;
873 cmg_chars = kmalloc(sizeof(*cmg_chars), GFP_KERNEL);
877 spin_lock_irq(&chsc_page_lock);
878 memset(chsc_page, 0, PAGE_SIZE);
879 scmc_area = chsc_page;
880 scmc_area->request.length = 0x0010;
881 scmc_area->request.code = 0x0022;
882 scmc_area->first_chpid = chp->chpid.id;
883 scmc_area->last_chpid = chp->chpid.id;
885 ccode = chsc(scmc_area);
887 ret = (ccode == 3) ? -ENODEV : -EBUSY;
891 ret = chsc_error_from_response(scmc_area->response.code);
893 CIO_CRW_EVENT(2, "chsc: scmc failed (rc=%04x)\n",
894 scmc_area->response.code);
897 if (scmc_area->not_valid) {
902 chp->cmg = scmc_area->cmg;
903 chp->shared = scmc_area->shared;
904 if (chp->cmg != 2 && chp->cmg != 3) {
905 /* No cmg-dependent data. */
908 chp->cmg_chars = cmg_chars;
909 chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
910 (struct cmg_chars *) &scmc_area->data);
912 spin_unlock_irq(&chsc_page_lock);
919 int __init chsc_init(void)
923 sei_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
924 chsc_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
925 if (!sei_page || !chsc_page) {
929 ret = crw_register_handler(CRW_RSC_CSS, chsc_process_crw);
934 free_page((unsigned long)chsc_page);
935 free_page((unsigned long)sei_page);
939 void __init chsc_init_cleanup(void)
941 crw_unregister_handler(CRW_RSC_CSS);
942 free_page((unsigned long)chsc_page);
943 free_page((unsigned long)sei_page);
946 int chsc_enable_facility(int operation_code)
951 struct chsc_header request;
958 u32 operation_data_area[252];
959 struct chsc_header response;
963 } __attribute__ ((packed)) *sda_area;
965 spin_lock_irqsave(&chsc_page_lock, flags);
966 memset(chsc_page, 0, PAGE_SIZE);
967 sda_area = chsc_page;
968 sda_area->request.length = 0x0400;
969 sda_area->request.code = 0x0031;
970 sda_area->operation_code = operation_code;
972 ret = chsc(sda_area);
974 ret = (ret == 3) ? -ENODEV : -EBUSY;
978 switch (sda_area->response.code) {
983 ret = chsc_error_from_response(sda_area->response.code);
986 CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n",
987 operation_code, sda_area->response.code);
989 spin_unlock_irqrestore(&chsc_page_lock, flags);
993 struct css_general_char css_general_characteristics;
994 struct css_chsc_char css_chsc_characteristics;
997 chsc_determine_css_characteristics(void)
1001 struct chsc_header request;
1005 struct chsc_header response;
1007 u32 general_char[510];
1009 } __attribute__ ((packed)) *scsc_area;
1011 spin_lock_irq(&chsc_page_lock);
1012 memset(chsc_page, 0, PAGE_SIZE);
1013 scsc_area = chsc_page;
1014 scsc_area->request.length = 0x0010;
1015 scsc_area->request.code = 0x0010;
1017 result = chsc(scsc_area);
1019 result = (result == 3) ? -ENODEV : -EBUSY;
1023 result = chsc_error_from_response(scsc_area->response.code);
1025 memcpy(&css_general_characteristics, scsc_area->general_char,
1026 sizeof(css_general_characteristics));
1027 memcpy(&css_chsc_characteristics, scsc_area->chsc_char,
1028 sizeof(css_chsc_characteristics));
1030 CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n",
1031 scsc_area->response.code);
1033 spin_unlock_irq(&chsc_page_lock);
1037 EXPORT_SYMBOL_GPL(css_general_characteristics);
1038 EXPORT_SYMBOL_GPL(css_chsc_characteristics);
1040 int chsc_sstpc(void *page, unsigned int op, u16 ctrl)
1043 struct chsc_header request;
1045 unsigned int op : 8;
1046 unsigned int rsvd1 : 8;
1047 unsigned int ctrl : 16;
1048 unsigned int rsvd2[5];
1049 struct chsc_header response;
1050 unsigned int rsvd3[7];
1051 } __attribute__ ((packed)) *rr;
1054 memset(page, 0, PAGE_SIZE);
1056 rr->request.length = 0x0020;
1057 rr->request.code = 0x0033;
1063 rc = (rr->response.code == 0x0001) ? 0 : -EIO;
1067 int chsc_sstpi(void *page, void *result, size_t size)
1070 struct chsc_header request;
1071 unsigned int rsvd0[3];
1072 struct chsc_header response;
1074 } __attribute__ ((packed)) *rr;
1077 memset(page, 0, PAGE_SIZE);
1079 rr->request.length = 0x0010;
1080 rr->request.code = 0x0038;
1084 memcpy(result, &rr->data, size);
1085 return (rr->response.code == 0x0001) ? 0 : -EIO;
1088 int chsc_siosl(struct subchannel_id schid)
1091 struct chsc_header request;
1093 struct subchannel_id sid;
1095 struct chsc_header response;
1097 } __attribute__ ((packed)) *siosl_area;
1098 unsigned long flags;
1102 spin_lock_irqsave(&chsc_page_lock, flags);
1103 memset(chsc_page, 0, PAGE_SIZE);
1104 siosl_area = chsc_page;
1105 siosl_area->request.length = 0x0010;
1106 siosl_area->request.code = 0x0046;
1107 siosl_area->word1 = 0x80000000;
1108 siosl_area->sid = schid;
1110 ccode = chsc(siosl_area);
1116 CIO_MSG_EVENT(2, "chsc: chsc failed for 0.%x.%04x (ccode=%d)\n",
1117 schid.ssid, schid.sch_no, ccode);
1120 rc = chsc_error_from_response(siosl_area->response.code);
1122 CIO_MSG_EVENT(2, "chsc: siosl failed for 0.%x.%04x (rc=%04x)\n",
1123 schid.ssid, schid.sch_no,
1124 siosl_area->response.code);
1126 CIO_MSG_EVENT(4, "chsc: siosl succeeded for 0.%x.%04x\n",
1127 schid.ssid, schid.sch_no);
1129 spin_unlock_irqrestore(&chsc_page_lock, flags);
1132 EXPORT_SYMBOL_GPL(chsc_siosl);
1135 * chsc_scm_info() - store SCM information (SSI)
1136 * @scm_area: request and response block for SSI
1137 * @token: continuation token
1139 * Returns 0 on success.
1141 int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token)
1145 memset(scm_area, 0, sizeof(*scm_area));
1146 scm_area->request.length = 0x0020;
1147 scm_area->request.code = 0x004C;
1148 scm_area->reqtok = token;
1150 ccode = chsc(scm_area);
1152 ret = (ccode == 3) ? -ENODEV : -EBUSY;
1155 ret = chsc_error_from_response(scm_area->response.code);
1157 CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n",
1158 scm_area->response.code);
1162 EXPORT_SYMBOL_GPL(chsc_scm_info);