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);
148 * chsc_ssqd() - store subchannel QDIO data (SSQD)
149 * @schid: id of the subchannel on which SSQD is performed
150 * @ssqd: request and response block for SSQD
152 * Returns 0 on success.
154 int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd)
156 memset(ssqd, 0, sizeof(*ssqd));
157 ssqd->request.length = 0x0010;
158 ssqd->request.code = 0x0024;
159 ssqd->first_sch = schid.sch_no;
160 ssqd->last_sch = schid.sch_no;
161 ssqd->ssid = schid.ssid;
166 return chsc_error_from_response(ssqd->response.code);
168 EXPORT_SYMBOL_GPL(chsc_ssqd);
170 static int s390_subchannel_remove_chpid(struct subchannel *sch, void *data)
172 spin_lock_irq(sch->lock);
173 if (sch->driver && sch->driver->chp_event)
174 if (sch->driver->chp_event(sch, data, CHP_OFFLINE) != 0)
176 spin_unlock_irq(sch->lock);
181 spin_unlock_irq(sch->lock);
182 css_schedule_eval(sch->schid);
186 void chsc_chp_offline(struct chp_id chpid)
189 struct chp_link link;
191 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id);
192 CIO_TRACE_EVENT(2, dbf_txt);
194 if (chp_get_status(chpid) <= 0)
196 memset(&link, 0, sizeof(struct chp_link));
198 /* Wait until previous actions have settled. */
199 css_wait_for_slow_path();
200 for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link);
203 static int s390_process_res_acc_new_sch(struct subchannel_id schid, void *data)
207 * We don't know the device yet, but since a path
208 * may be available now to the device we'll have
209 * to do recognition again.
210 * Since we don't have any idea about which chpid
211 * that beast may be on we'll have to do a stsch
212 * on all devices, grr...
214 if (stsch_err(schid, &schib))
218 /* Put it on the slow path. */
219 css_schedule_eval(schid);
223 static int __s390_process_res_acc(struct subchannel *sch, void *data)
225 spin_lock_irq(sch->lock);
226 if (sch->driver && sch->driver->chp_event)
227 sch->driver->chp_event(sch, data, CHP_ONLINE);
228 spin_unlock_irq(sch->lock);
233 static void s390_process_res_acc(struct chp_link *link)
237 sprintf(dbf_txt, "accpr%x.%02x", link->chpid.cssid,
239 CIO_TRACE_EVENT( 2, dbf_txt);
240 if (link->fla != 0) {
241 sprintf(dbf_txt, "fla%x", link->fla);
242 CIO_TRACE_EVENT( 2, dbf_txt);
244 /* Wait until previous actions have settled. */
245 css_wait_for_slow_path();
247 * I/O resources may have become accessible.
248 * Scan through all subchannels that may be concerned and
249 * do a validation on those.
250 * The more information we have (info), the less scanning
251 * will we have to do.
253 for_each_subchannel_staged(__s390_process_res_acc,
254 s390_process_res_acc_new_sch, link);
258 __get_chpid_from_lir(void *data)
264 /* incident-node descriptor */
266 /* attached-node descriptor */
268 /* incident-specific information */
270 } __attribute__ ((packed)) *lir;
274 /* NULL link incident record */
276 if (!(lir->indesc[0]&0xc0000000))
277 /* node descriptor not valid */
279 if (!(lir->indesc[0]&0x10000000))
280 /* don't handle device-type nodes - FIXME */
282 /* Byte 3 contains the chpid. Could also be CTCA, but we don't care */
284 return (u16) (lir->indesc[0]&0x000000ff);
287 struct chsc_sei_nt0_area {
289 u8 vf; /* validity flags */
290 u8 rs; /* reporting source */
291 u8 cc; /* content code */
292 u16 fla; /* full link address */
293 u16 rsid; /* reporting source id */
296 /* ccdf has to be big enough for a link-incident record */
297 u8 ccdf[PAGE_SIZE - 24 - 16]; /* content-code dependent field */
300 struct chsc_sei_nt2_area {
301 u8 flags; /* p and v bit */
304 u8 cc; /* content code */
306 u8 ccdf[PAGE_SIZE - 24 - 56]; /* content-code dependent field */
309 #define CHSC_SEI_NT0 (1ULL << 63)
310 #define CHSC_SEI_NT2 (1ULL << 61)
313 struct chsc_header request;
315 u64 ntsm; /* notification type mask */
316 struct chsc_header response;
320 struct chsc_sei_nt0_area nt0_area;
321 struct chsc_sei_nt2_area nt2_area;
322 u8 nt_area[PAGE_SIZE - 24];
326 static void chsc_process_sei_link_incident(struct chsc_sei_nt0_area *sei_area)
331 CIO_CRW_EVENT(4, "chsc: link incident (rs=%02x, rs_id=%04x)\n",
332 sei_area->rs, sei_area->rsid);
333 if (sei_area->rs != 4)
335 id = __get_chpid_from_lir(sei_area->ccdf);
337 CIO_CRW_EVENT(4, "chsc: link incident - invalid LIR\n");
341 chsc_chp_offline(chpid);
345 static void chsc_process_sei_res_acc(struct chsc_sei_nt0_area *sei_area)
347 struct chp_link link;
351 CIO_CRW_EVENT(4, "chsc: resource accessibility event (rs=%02x, "
352 "rs_id=%04x)\n", sei_area->rs, sei_area->rsid);
353 if (sei_area->rs != 4)
356 chpid.id = sei_area->rsid;
357 /* allocate a new channel path structure, if needed */
358 status = chp_get_status(chpid);
363 memset(&link, 0, sizeof(struct chp_link));
365 if ((sei_area->vf & 0xc0) != 0) {
366 link.fla = sei_area->fla;
367 if ((sei_area->vf & 0xc0) == 0xc0)
368 /* full link address */
369 link.fla_mask = 0xffff;
372 link.fla_mask = 0xff00;
374 s390_process_res_acc(&link);
377 static void chsc_process_sei_chp_avail(struct chsc_sei_nt0_area *sei_area)
379 struct channel_path *chp;
384 CIO_CRW_EVENT(4, "chsc: channel path availability information\n");
385 if (sei_area->rs != 0)
387 data = sei_area->ccdf;
389 for (num = 0; num <= __MAX_CHPID; num++) {
390 if (!chp_test_bit(data, num))
394 CIO_CRW_EVENT(4, "Update information for channel path "
395 "%x.%02x\n", chpid.cssid, chpid.id);
396 chp = chpid_to_chp(chpid);
401 mutex_lock(&chp->lock);
402 chp_update_desc(chp);
403 mutex_unlock(&chp->lock);
407 struct chp_config_data {
413 static void chsc_process_sei_chp_config(struct chsc_sei_nt0_area *sei_area)
415 struct chp_config_data *data;
418 char *events[3] = {"configure", "deconfigure", "cancel deconfigure"};
420 CIO_CRW_EVENT(4, "chsc: channel-path-configuration notification\n");
421 if (sei_area->rs != 0)
423 data = (struct chp_config_data *) &(sei_area->ccdf);
425 for (num = 0; num <= __MAX_CHPID; num++) {
426 if (!chp_test_bit(data->map, num))
429 pr_notice("Processing %s for channel path %x.%02x\n",
430 events[data->op], chpid.cssid, chpid.id);
433 chp_cfg_schedule(chpid, 1);
436 chp_cfg_schedule(chpid, 0);
439 chp_cfg_cancel_deconfigure(chpid);
445 static void chsc_process_sei_scm_change(struct chsc_sei_nt0_area *sei_area)
449 CIO_CRW_EVENT(4, "chsc: scm change notification\n");
450 if (sei_area->rs != 7)
453 ret = scm_update_information();
455 CIO_CRW_EVENT(0, "chsc: updating change notification"
456 " failed (rc=%d).\n", ret);
459 static void chsc_process_sei_scm_avail(struct chsc_sei_nt0_area *sei_area)
463 CIO_CRW_EVENT(4, "chsc: scm available information\n");
464 if (sei_area->rs != 7)
467 ret = scm_process_availability_information();
469 CIO_CRW_EVENT(0, "chsc: process availability information"
470 " failed (rc=%d).\n", ret);
473 static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area)
475 switch (sei_area->cc) {
477 zpci_event_error(sei_area->ccdf);
480 zpci_event_availability(sei_area->ccdf);
483 CIO_CRW_EVENT(2, "chsc: sei nt2 unhandled cc=%d\n",
489 static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area)
491 /* which kind of information was stored? */
492 switch (sei_area->cc) {
493 case 1: /* link incident*/
494 chsc_process_sei_link_incident(sei_area);
496 case 2: /* i/o resource accessibility */
497 chsc_process_sei_res_acc(sei_area);
499 case 7: /* channel-path-availability information */
500 chsc_process_sei_chp_avail(sei_area);
502 case 8: /* channel-path-configuration notification */
503 chsc_process_sei_chp_config(sei_area);
505 case 12: /* scm change notification */
506 chsc_process_sei_scm_change(sei_area);
508 case 14: /* scm available notification */
509 chsc_process_sei_scm_avail(sei_area);
511 default: /* other stuff */
512 CIO_CRW_EVENT(2, "chsc: sei nt0 unhandled cc=%d\n",
517 /* Check if we might have lost some information. */
518 if (sei_area->flags & 0x40) {
519 CIO_CRW_EVENT(2, "chsc: event overflow\n");
520 css_schedule_eval_all();
524 static void chsc_process_event_information(struct chsc_sei *sei, u64 ntsm)
527 memset(sei, 0, sizeof(*sei));
528 sei->request.length = 0x0010;
529 sei->request.code = 0x000e;
535 if (sei->response.code != 0x0001) {
536 CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x)\n",
541 CIO_CRW_EVENT(2, "chsc: sei successful (nt=%d)\n", sei->nt);
544 chsc_process_sei_nt0(&sei->u.nt0_area);
547 chsc_process_sei_nt2(&sei->u.nt2_area);
550 CIO_CRW_EVENT(2, "chsc: unhandled nt: %d\n", sei->nt);
553 } while (sei->u.nt0_area.flags & 0x80);
557 * Handle channel subsystem related CRWs.
558 * Use store event information to find out what's going on.
560 * Note: Access to sei_page is serialized through machine check handler
561 * thread, so no need for locking.
563 static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow)
565 struct chsc_sei *sei = sei_page;
568 css_schedule_eval_all();
571 CIO_CRW_EVENT(2, "CRW reports slct=%d, oflw=%d, "
572 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
573 crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc,
574 crw0->erc, crw0->rsid);
576 CIO_TRACE_EVENT(2, "prcss");
577 chsc_process_event_information(sei, CHSC_SEI_NT0 | CHSC_SEI_NT2);
580 void chsc_chp_online(struct chp_id chpid)
583 struct chp_link link;
585 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id);
586 CIO_TRACE_EVENT(2, dbf_txt);
588 if (chp_get_status(chpid) != 0) {
589 memset(&link, 0, sizeof(struct chp_link));
591 /* Wait until previous actions have settled. */
592 css_wait_for_slow_path();
593 for_each_subchannel_staged(__s390_process_res_acc, NULL,
598 static void __s390_subchannel_vary_chpid(struct subchannel *sch,
599 struct chp_id chpid, int on)
602 struct chp_link link;
604 memset(&link, 0, sizeof(struct chp_link));
606 spin_lock_irqsave(sch->lock, flags);
607 if (sch->driver && sch->driver->chp_event)
608 sch->driver->chp_event(sch, &link,
609 on ? CHP_VARY_ON : CHP_VARY_OFF);
610 spin_unlock_irqrestore(sch->lock, flags);
613 static int s390_subchannel_vary_chpid_off(struct subchannel *sch, void *data)
615 struct chp_id *chpid = data;
617 __s390_subchannel_vary_chpid(sch, *chpid, 0);
621 static int s390_subchannel_vary_chpid_on(struct subchannel *sch, void *data)
623 struct chp_id *chpid = data;
625 __s390_subchannel_vary_chpid(sch, *chpid, 1);
630 __s390_vary_chpid_on(struct subchannel_id schid, void *data)
634 if (stsch_err(schid, &schib))
637 /* Put it on the slow path. */
638 css_schedule_eval(schid);
643 * chsc_chp_vary - propagate channel-path vary operation to subchannels
644 * @chpid: channl-path ID
645 * @on: non-zero for vary online, zero for vary offline
647 int chsc_chp_vary(struct chp_id chpid, int on)
649 struct channel_path *chp = chpid_to_chp(chpid);
651 /* Wait until previous actions have settled. */
652 css_wait_for_slow_path();
654 * Redo PathVerification on the devices the chpid connects to
657 /* Try to update the channel path description. */
658 chp_update_desc(chp);
659 for_each_subchannel_staged(s390_subchannel_vary_chpid_on,
660 __s390_vary_chpid_on, &chpid);
662 for_each_subchannel_staged(s390_subchannel_vary_chpid_off,
669 chsc_remove_cmg_attr(struct channel_subsystem *css)
673 for (i = 0; i <= __MAX_CHPID; i++) {
676 chp_remove_cmg_attr(css->chps[i]);
681 chsc_add_cmg_attr(struct channel_subsystem *css)
686 for (i = 0; i <= __MAX_CHPID; i++) {
689 ret = chp_add_cmg_attr(css->chps[i]);
695 for (--i; i >= 0; i--) {
698 chp_remove_cmg_attr(css->chps[i]);
703 int __chsc_do_secm(struct channel_subsystem *css, int enable)
706 struct chsc_header request;
707 u32 operation_code : 2;
716 struct chsc_header response;
721 } __attribute__ ((packed)) *secm_area;
724 spin_lock_irq(&chsc_page_lock);
725 memset(chsc_page, 0, PAGE_SIZE);
726 secm_area = chsc_page;
727 secm_area->request.length = 0x0050;
728 secm_area->request.code = 0x0016;
730 secm_area->key = PAGE_DEFAULT_KEY >> 4;
731 secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1;
732 secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2;
734 secm_area->operation_code = enable ? 0 : 1;
736 ccode = chsc(secm_area);
738 ret = (ccode == 3) ? -ENODEV : -EBUSY;
742 switch (secm_area->response.code) {
748 ret = chsc_error_from_response(secm_area->response.code);
751 CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n",
752 secm_area->response.code);
754 spin_unlock_irq(&chsc_page_lock);
759 chsc_secm(struct channel_subsystem *css, int enable)
763 if (enable && !css->cm_enabled) {
764 css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
765 css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
766 if (!css->cub_addr1 || !css->cub_addr2) {
767 free_page((unsigned long)css->cub_addr1);
768 free_page((unsigned long)css->cub_addr2);
772 ret = __chsc_do_secm(css, enable);
774 css->cm_enabled = enable;
775 if (css->cm_enabled) {
776 ret = chsc_add_cmg_attr(css);
778 __chsc_do_secm(css, 0);
782 chsc_remove_cmg_attr(css);
784 if (!css->cm_enabled) {
785 free_page((unsigned long)css->cub_addr1);
786 free_page((unsigned long)css->cub_addr2);
791 int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
792 int c, int m, void *page)
794 struct chsc_scpd *scpd_area;
797 if ((rfmt == 1) && !css_general_characteristics.fcs)
799 if ((rfmt == 2) && !css_general_characteristics.cib)
802 memset(page, 0, PAGE_SIZE);
804 scpd_area->request.length = 0x0010;
805 scpd_area->request.code = 0x0002;
806 scpd_area->cssid = chpid.cssid;
807 scpd_area->first_chpid = chpid.id;
808 scpd_area->last_chpid = chpid.id;
811 scpd_area->fmt = fmt;
812 scpd_area->rfmt = rfmt;
814 ccode = chsc(scpd_area);
816 return (ccode == 3) ? -ENODEV : -EBUSY;
818 ret = chsc_error_from_response(scpd_area->response.code);
820 CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
821 scpd_area->response.code);
824 EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc);
826 int chsc_determine_base_channel_path_desc(struct chp_id chpid,
827 struct channel_path_desc *desc)
829 struct chsc_response_struct *chsc_resp;
830 struct chsc_scpd *scpd_area;
834 spin_lock_irqsave(&chsc_page_lock, flags);
835 scpd_area = chsc_page;
836 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, scpd_area);
839 chsc_resp = (void *)&scpd_area->response;
840 memcpy(desc, &chsc_resp->data, sizeof(*desc));
842 spin_unlock_irqrestore(&chsc_page_lock, flags);
846 int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid,
847 struct channel_path_desc_fmt1 *desc)
849 struct chsc_response_struct *chsc_resp;
850 struct chsc_scpd *scpd_area;
854 spin_lock_irqsave(&chsc_page_lock, flags);
855 scpd_area = chsc_page;
856 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 1, 0, scpd_area);
859 chsc_resp = (void *)&scpd_area->response;
860 memcpy(desc, &chsc_resp->data, sizeof(*desc));
862 spin_unlock_irqrestore(&chsc_page_lock, flags);
867 chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
868 struct cmg_chars *chars)
870 struct cmg_chars *cmg_chars;
873 cmg_chars = chp->cmg_chars;
874 for (i = 0; i < NR_MEASUREMENT_CHARS; i++) {
875 mask = 0x80 >> (i + 3);
877 cmg_chars->values[i] = chars->values[i];
879 cmg_chars->values[i] = 0;
883 int chsc_get_channel_measurement_chars(struct channel_path *chp)
885 struct cmg_chars *cmg_chars;
889 struct chsc_header request;
895 struct chsc_header response;
906 u32 data[NR_MEASUREMENT_CHARS];
907 } __attribute__ ((packed)) *scmc_area;
909 chp->cmg_chars = NULL;
910 cmg_chars = kmalloc(sizeof(*cmg_chars), GFP_KERNEL);
914 spin_lock_irq(&chsc_page_lock);
915 memset(chsc_page, 0, PAGE_SIZE);
916 scmc_area = chsc_page;
917 scmc_area->request.length = 0x0010;
918 scmc_area->request.code = 0x0022;
919 scmc_area->first_chpid = chp->chpid.id;
920 scmc_area->last_chpid = chp->chpid.id;
922 ccode = chsc(scmc_area);
924 ret = (ccode == 3) ? -ENODEV : -EBUSY;
928 ret = chsc_error_from_response(scmc_area->response.code);
930 CIO_CRW_EVENT(2, "chsc: scmc failed (rc=%04x)\n",
931 scmc_area->response.code);
934 if (scmc_area->not_valid) {
939 chp->cmg = scmc_area->cmg;
940 chp->shared = scmc_area->shared;
941 if (chp->cmg != 2 && chp->cmg != 3) {
942 /* No cmg-dependent data. */
945 chp->cmg_chars = cmg_chars;
946 chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
947 (struct cmg_chars *) &scmc_area->data);
949 spin_unlock_irq(&chsc_page_lock);
956 int __init chsc_init(void)
960 sei_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
961 chsc_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
962 if (!sei_page || !chsc_page) {
966 ret = crw_register_handler(CRW_RSC_CSS, chsc_process_crw);
971 free_page((unsigned long)chsc_page);
972 free_page((unsigned long)sei_page);
976 void __init chsc_init_cleanup(void)
978 crw_unregister_handler(CRW_RSC_CSS);
979 free_page((unsigned long)chsc_page);
980 free_page((unsigned long)sei_page);
983 int chsc_enable_facility(int operation_code)
988 struct chsc_header request;
995 u32 operation_data_area[252];
996 struct chsc_header response;
1000 } __attribute__ ((packed)) *sda_area;
1002 spin_lock_irqsave(&chsc_page_lock, flags);
1003 memset(chsc_page, 0, PAGE_SIZE);
1004 sda_area = chsc_page;
1005 sda_area->request.length = 0x0400;
1006 sda_area->request.code = 0x0031;
1007 sda_area->operation_code = operation_code;
1009 ret = chsc(sda_area);
1011 ret = (ret == 3) ? -ENODEV : -EBUSY;
1015 switch (sda_area->response.code) {
1020 ret = chsc_error_from_response(sda_area->response.code);
1023 CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n",
1024 operation_code, sda_area->response.code);
1026 spin_unlock_irqrestore(&chsc_page_lock, flags);
1030 struct css_general_char css_general_characteristics;
1031 struct css_chsc_char css_chsc_characteristics;
1034 chsc_determine_css_characteristics(void)
1038 struct chsc_header request;
1042 struct chsc_header response;
1044 u32 general_char[510];
1046 } __attribute__ ((packed)) *scsc_area;
1048 spin_lock_irq(&chsc_page_lock);
1049 memset(chsc_page, 0, PAGE_SIZE);
1050 scsc_area = chsc_page;
1051 scsc_area->request.length = 0x0010;
1052 scsc_area->request.code = 0x0010;
1054 result = chsc(scsc_area);
1056 result = (result == 3) ? -ENODEV : -EBUSY;
1060 result = chsc_error_from_response(scsc_area->response.code);
1062 memcpy(&css_general_characteristics, scsc_area->general_char,
1063 sizeof(css_general_characteristics));
1064 memcpy(&css_chsc_characteristics, scsc_area->chsc_char,
1065 sizeof(css_chsc_characteristics));
1067 CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n",
1068 scsc_area->response.code);
1070 spin_unlock_irq(&chsc_page_lock);
1074 EXPORT_SYMBOL_GPL(css_general_characteristics);
1075 EXPORT_SYMBOL_GPL(css_chsc_characteristics);
1077 int chsc_sstpc(void *page, unsigned int op, u16 ctrl)
1080 struct chsc_header request;
1082 unsigned int op : 8;
1083 unsigned int rsvd1 : 8;
1084 unsigned int ctrl : 16;
1085 unsigned int rsvd2[5];
1086 struct chsc_header response;
1087 unsigned int rsvd3[7];
1088 } __attribute__ ((packed)) *rr;
1091 memset(page, 0, PAGE_SIZE);
1093 rr->request.length = 0x0020;
1094 rr->request.code = 0x0033;
1100 rc = (rr->response.code == 0x0001) ? 0 : -EIO;
1104 int chsc_sstpi(void *page, void *result, size_t size)
1107 struct chsc_header request;
1108 unsigned int rsvd0[3];
1109 struct chsc_header response;
1111 } __attribute__ ((packed)) *rr;
1114 memset(page, 0, PAGE_SIZE);
1116 rr->request.length = 0x0010;
1117 rr->request.code = 0x0038;
1121 memcpy(result, &rr->data, size);
1122 return (rr->response.code == 0x0001) ? 0 : -EIO;
1125 int chsc_siosl(struct subchannel_id schid)
1128 struct chsc_header request;
1130 struct subchannel_id sid;
1132 struct chsc_header response;
1134 } __attribute__ ((packed)) *siosl_area;
1135 unsigned long flags;
1139 spin_lock_irqsave(&chsc_page_lock, flags);
1140 memset(chsc_page, 0, PAGE_SIZE);
1141 siosl_area = chsc_page;
1142 siosl_area->request.length = 0x0010;
1143 siosl_area->request.code = 0x0046;
1144 siosl_area->word1 = 0x80000000;
1145 siosl_area->sid = schid;
1147 ccode = chsc(siosl_area);
1153 CIO_MSG_EVENT(2, "chsc: chsc failed for 0.%x.%04x (ccode=%d)\n",
1154 schid.ssid, schid.sch_no, ccode);
1157 rc = chsc_error_from_response(siosl_area->response.code);
1159 CIO_MSG_EVENT(2, "chsc: siosl failed for 0.%x.%04x (rc=%04x)\n",
1160 schid.ssid, schid.sch_no,
1161 siosl_area->response.code);
1163 CIO_MSG_EVENT(4, "chsc: siosl succeeded for 0.%x.%04x\n",
1164 schid.ssid, schid.sch_no);
1166 spin_unlock_irqrestore(&chsc_page_lock, flags);
1169 EXPORT_SYMBOL_GPL(chsc_siosl);
1172 * chsc_scm_info() - store SCM information (SSI)
1173 * @scm_area: request and response block for SSI
1174 * @token: continuation token
1176 * Returns 0 on success.
1178 int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token)
1182 memset(scm_area, 0, sizeof(*scm_area));
1183 scm_area->request.length = 0x0020;
1184 scm_area->request.code = 0x004C;
1185 scm_area->reqtok = token;
1187 ccode = chsc(scm_area);
1189 ret = (ccode == 3) ? -ENODEV : -EBUSY;
1192 ret = chsc_error_from_response(scm_area->response.code);
1194 CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n",
1195 scm_area->response.code);
1199 EXPORT_SYMBOL_GPL(chsc_scm_info);