chsc.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. /*
  2. * S/390 common I/O routines -- channel subsystem call
  3. *
  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)
  8. */
  9. #define KMSG_COMPONENT "cio"
  10. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  11. #include <linux/module.h>
  12. #include <linux/slab.h>
  13. #include <linux/init.h>
  14. #include <linux/device.h>
  15. #include <linux/mutex.h>
  16. #include <linux/pci.h>
  17. #include <asm/cio.h>
  18. #include <asm/chpid.h>
  19. #include <asm/chsc.h>
  20. #include <asm/crw.h>
  21. #include <asm/isc.h>
  22. #include <asm/ebcdic.h>
  23. #include "css.h"
  24. #include "cio.h"
  25. #include "cio_debug.h"
  26. #include "ioasm.h"
  27. #include "chp.h"
  28. #include "chsc.h"
  29. static void *sei_page;
  30. static void *chsc_page;
  31. static DEFINE_SPINLOCK(chsc_page_lock);
  32. /**
  33. * chsc_error_from_response() - convert a chsc response to an error
  34. * @response: chsc response code
  35. *
  36. * Returns an appropriate Linux error code for @response.
  37. */
  38. int chsc_error_from_response(int response)
  39. {
  40. switch (response) {
  41. case 0x0001:
  42. return 0;
  43. case 0x0002:
  44. case 0x0003:
  45. case 0x0006:
  46. case 0x0007:
  47. case 0x0008:
  48. case 0x000a:
  49. case 0x0104:
  50. return -EINVAL;
  51. case 0x0004:
  52. return -EOPNOTSUPP;
  53. case 0x000b:
  54. case 0x0107: /* "Channel busy" for the op 0x003d */
  55. return -EBUSY;
  56. case 0x0100:
  57. case 0x0102:
  58. return -ENOMEM;
  59. default:
  60. return -EIO;
  61. }
  62. }
  63. EXPORT_SYMBOL_GPL(chsc_error_from_response);
  64. struct chsc_ssd_area {
  65. struct chsc_header request;
  66. u16 :10;
  67. u16 ssid:2;
  68. u16 :4;
  69. u16 f_sch; /* first subchannel */
  70. u16 :16;
  71. u16 l_sch; /* last subchannel */
  72. u32 :32;
  73. struct chsc_header response;
  74. u32 :32;
  75. u8 sch_valid : 1;
  76. u8 dev_valid : 1;
  77. u8 st : 3; /* subchannel type */
  78. u8 zeroes : 3;
  79. u8 unit_addr; /* unit address */
  80. u16 devno; /* device number */
  81. u8 path_mask;
  82. u8 fla_valid_mask;
  83. u16 sch; /* subchannel */
  84. u8 chpid[8]; /* chpids 0-7 */
  85. u16 fla[8]; /* full link addresses 0-7 */
  86. } __attribute__ ((packed));
  87. int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd)
  88. {
  89. struct chsc_ssd_area *ssd_area;
  90. unsigned long flags;
  91. int ccode;
  92. int ret;
  93. int i;
  94. int mask;
  95. spin_lock_irqsave(&chsc_page_lock, flags);
  96. memset(chsc_page, 0, PAGE_SIZE);
  97. ssd_area = chsc_page;
  98. ssd_area->request.length = 0x0010;
  99. ssd_area->request.code = 0x0004;
  100. ssd_area->ssid = schid.ssid;
  101. ssd_area->f_sch = schid.sch_no;
  102. ssd_area->l_sch = schid.sch_no;
  103. ccode = chsc(ssd_area);
  104. /* Check response. */
  105. if (ccode > 0) {
  106. ret = (ccode == 3) ? -ENODEV : -EBUSY;
  107. goto out;
  108. }
  109. ret = chsc_error_from_response(ssd_area->response.code);
  110. if (ret != 0) {
  111. CIO_MSG_EVENT(2, "chsc: ssd failed for 0.%x.%04x (rc=%04x)\n",
  112. schid.ssid, schid.sch_no,
  113. ssd_area->response.code);
  114. goto out;
  115. }
  116. if (!ssd_area->sch_valid) {
  117. ret = -ENODEV;
  118. goto out;
  119. }
  120. /* Copy data */
  121. ret = 0;
  122. memset(ssd, 0, sizeof(struct chsc_ssd_info));
  123. if ((ssd_area->st != SUBCHANNEL_TYPE_IO) &&
  124. (ssd_area->st != SUBCHANNEL_TYPE_MSG))
  125. goto out;
  126. ssd->path_mask = ssd_area->path_mask;
  127. ssd->fla_valid_mask = ssd_area->fla_valid_mask;
  128. for (i = 0; i < 8; i++) {
  129. mask = 0x80 >> i;
  130. if (ssd_area->path_mask & mask) {
  131. chp_id_init(&ssd->chpid[i]);
  132. ssd->chpid[i].id = ssd_area->chpid[i];
  133. }
  134. if (ssd_area->fla_valid_mask & mask)
  135. ssd->fla[i] = ssd_area->fla[i];
  136. }
  137. out:
  138. spin_unlock_irqrestore(&chsc_page_lock, flags);
  139. return ret;
  140. }
  141. /**
  142. * chsc_ssqd() - store subchannel QDIO data (SSQD)
  143. * @schid: id of the subchannel on which SSQD is performed
  144. * @ssqd: request and response block for SSQD
  145. *
  146. * Returns 0 on success.
  147. */
  148. int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd)
  149. {
  150. memset(ssqd, 0, sizeof(*ssqd));
  151. ssqd->request.length = 0x0010;
  152. ssqd->request.code = 0x0024;
  153. ssqd->first_sch = schid.sch_no;
  154. ssqd->last_sch = schid.sch_no;
  155. ssqd->ssid = schid.ssid;
  156. if (chsc(ssqd))
  157. return -EIO;
  158. return chsc_error_from_response(ssqd->response.code);
  159. }
  160. EXPORT_SYMBOL_GPL(chsc_ssqd);
  161. /**
  162. * chsc_sadc() - set adapter device controls (SADC)
  163. * @schid: id of the subchannel on which SADC is performed
  164. * @scssc: request and response block for SADC
  165. * @summary_indicator_addr: summary indicator address
  166. * @subchannel_indicator_addr: subchannel indicator address
  167. *
  168. * Returns 0 on success.
  169. */
  170. int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc,
  171. u64 summary_indicator_addr, u64 subchannel_indicator_addr)
  172. {
  173. memset(scssc, 0, sizeof(*scssc));
  174. scssc->request.length = 0x0fe0;
  175. scssc->request.code = 0x0021;
  176. scssc->operation_code = 0;
  177. scssc->summary_indicator_addr = summary_indicator_addr;
  178. scssc->subchannel_indicator_addr = subchannel_indicator_addr;
  179. scssc->ks = PAGE_DEFAULT_KEY >> 4;
  180. scssc->kc = PAGE_DEFAULT_KEY >> 4;
  181. scssc->isc = QDIO_AIRQ_ISC;
  182. scssc->schid = schid;
  183. /* enable the time delay disablement facility */
  184. if (css_general_characteristics.aif_tdd)
  185. scssc->word_with_d_bit = 0x10000000;
  186. if (chsc(scssc))
  187. return -EIO;
  188. return chsc_error_from_response(scssc->response.code);
  189. }
  190. EXPORT_SYMBOL_GPL(chsc_sadc);
  191. static int s390_subchannel_remove_chpid(struct subchannel *sch, void *data)
  192. {
  193. spin_lock_irq(sch->lock);
  194. if (sch->driver && sch->driver->chp_event)
  195. if (sch->driver->chp_event(sch, data, CHP_OFFLINE) != 0)
  196. goto out_unreg;
  197. spin_unlock_irq(sch->lock);
  198. return 0;
  199. out_unreg:
  200. sch->lpm = 0;
  201. spin_unlock_irq(sch->lock);
  202. css_schedule_eval(sch->schid);
  203. return 0;
  204. }
  205. void chsc_chp_offline(struct chp_id chpid)
  206. {
  207. struct channel_path *chp = chpid_to_chp(chpid);
  208. struct chp_link link;
  209. char dbf_txt[15];
  210. sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id);
  211. CIO_TRACE_EVENT(2, dbf_txt);
  212. if (chp_get_status(chpid) <= 0)
  213. return;
  214. memset(&link, 0, sizeof(struct chp_link));
  215. link.chpid = chpid;
  216. /* Wait until previous actions have settled. */
  217. css_wait_for_slow_path();
  218. mutex_lock(&chp->lock);
  219. chp_update_desc(chp);
  220. mutex_unlock(&chp->lock);
  221. for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link);
  222. }
  223. static int __s390_process_res_acc(struct subchannel *sch, void *data)
  224. {
  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);
  229. return 0;
  230. }
  231. static void s390_process_res_acc(struct chp_link *link)
  232. {
  233. char dbf_txt[15];
  234. sprintf(dbf_txt, "accpr%x.%02x", link->chpid.cssid,
  235. link->chpid.id);
  236. CIO_TRACE_EVENT( 2, dbf_txt);
  237. if (link->fla != 0) {
  238. sprintf(dbf_txt, "fla%x", link->fla);
  239. CIO_TRACE_EVENT( 2, dbf_txt);
  240. }
  241. /* Wait until previous actions have settled. */
  242. css_wait_for_slow_path();
  243. /*
  244. * I/O resources may have become accessible.
  245. * Scan through all subchannels that may be concerned and
  246. * do a validation on those.
  247. * The more information we have (info), the less scanning
  248. * will we have to do.
  249. */
  250. for_each_subchannel_staged(__s390_process_res_acc, NULL, link);
  251. css_schedule_reprobe();
  252. }
  253. struct chsc_sei_nt0_area {
  254. u8 flags;
  255. u8 vf; /* validity flags */
  256. u8 rs; /* reporting source */
  257. u8 cc; /* content code */
  258. u16 fla; /* full link address */
  259. u16 rsid; /* reporting source id */
  260. u32 reserved1;
  261. u32 reserved2;
  262. /* ccdf has to be big enough for a link-incident record */
  263. u8 ccdf[PAGE_SIZE - 24 - 16]; /* content-code dependent field */
  264. } __packed;
  265. struct chsc_sei_nt2_area {
  266. u8 flags; /* p and v bit */
  267. u8 reserved1;
  268. u8 reserved2;
  269. u8 cc; /* content code */
  270. u32 reserved3[13];
  271. u8 ccdf[PAGE_SIZE - 24 - 56]; /* content-code dependent field */
  272. } __packed;
  273. #define CHSC_SEI_NT0 (1ULL << 63)
  274. #define CHSC_SEI_NT2 (1ULL << 61)
  275. struct chsc_sei {
  276. struct chsc_header request;
  277. u32 reserved1;
  278. u64 ntsm; /* notification type mask */
  279. struct chsc_header response;
  280. u32 :24;
  281. u8 nt;
  282. union {
  283. struct chsc_sei_nt0_area nt0_area;
  284. struct chsc_sei_nt2_area nt2_area;
  285. u8 nt_area[PAGE_SIZE - 24];
  286. } u;
  287. } __packed;
  288. /*
  289. * Node Descriptor as defined in SA22-7204, "Common I/O-Device Commands"
  290. */
  291. #define ND_VALIDITY_VALID 0
  292. #define ND_VALIDITY_OUTDATED 1
  293. #define ND_VALIDITY_INVALID 2
  294. struct node_descriptor {
  295. /* Flags. */
  296. union {
  297. struct {
  298. u32 validity:3;
  299. u32 reserved:5;
  300. } __packed;
  301. u8 byte0;
  302. } __packed;
  303. /* Node parameters. */
  304. u32 params:24;
  305. /* Node ID. */
  306. char type[6];
  307. char model[3];
  308. char manufacturer[3];
  309. char plant[2];
  310. char seq[12];
  311. u16 tag;
  312. } __packed;
  313. /*
  314. * Link Incident Record as defined in SA22-7202, "ESCON I/O Interface"
  315. */
  316. #define LIR_IQ_CLASS_INFO 0
  317. #define LIR_IQ_CLASS_DEGRADED 1
  318. #define LIR_IQ_CLASS_NOT_OPERATIONAL 2
  319. struct lir {
  320. struct {
  321. u32 null:1;
  322. u32 reserved:3;
  323. u32 class:2;
  324. u32 reserved2:2;
  325. } __packed iq;
  326. u32 ic:8;
  327. u32 reserved:16;
  328. struct node_descriptor incident_node;
  329. struct node_descriptor attached_node;
  330. u8 reserved2[32];
  331. } __packed;
  332. #define PARAMS_LEN 10 /* PARAMS=xx,xxxxxx */
  333. #define NODEID_LEN 35 /* NODEID=tttttt/mdl,mmm.ppssssssssssss,xxxx */
  334. /* Copy EBCIDC text, convert to ASCII and optionally add delimiter. */
  335. static char *store_ebcdic(char *dest, const char *src, unsigned long len,
  336. char delim)
  337. {
  338. memcpy(dest, src, len);
  339. EBCASC(dest, len);
  340. if (delim)
  341. dest[len++] = delim;
  342. return dest + len;
  343. }
  344. /* Format node ID and parameters for output in LIR log message. */
  345. static void format_node_data(char *params, char *id, struct node_descriptor *nd)
  346. {
  347. memset(params, 0, PARAMS_LEN);
  348. memset(id, 0, NODEID_LEN);
  349. if (nd->validity != ND_VALIDITY_VALID) {
  350. strncpy(params, "n/a", PARAMS_LEN - 1);
  351. strncpy(id, "n/a", NODEID_LEN - 1);
  352. return;
  353. }
  354. /* PARAMS=xx,xxxxxx */
  355. snprintf(params, PARAMS_LEN, "%02x,%06x", nd->byte0, nd->params);
  356. /* NODEID=tttttt/mdl,mmm.ppssssssssssss,xxxx */
  357. id = store_ebcdic(id, nd->type, sizeof(nd->type), '/');
  358. id = store_ebcdic(id, nd->model, sizeof(nd->model), ',');
  359. id = store_ebcdic(id, nd->manufacturer, sizeof(nd->manufacturer), '.');
  360. id = store_ebcdic(id, nd->plant, sizeof(nd->plant), 0);
  361. id = store_ebcdic(id, nd->seq, sizeof(nd->seq), ',');
  362. sprintf(id, "%04X", nd->tag);
  363. }
  364. static void chsc_process_sei_link_incident(struct chsc_sei_nt0_area *sei_area)
  365. {
  366. struct lir *lir = (struct lir *) &sei_area->ccdf;
  367. char iuparams[PARAMS_LEN], iunodeid[NODEID_LEN], auparams[PARAMS_LEN],
  368. aunodeid[NODEID_LEN];
  369. CIO_CRW_EVENT(4, "chsc: link incident (rs=%02x, rs_id=%04x, iq=%02x)\n",
  370. sei_area->rs, sei_area->rsid, sei_area->ccdf[0]);
  371. /* Ignore NULL Link Incident Records. */
  372. if (lir->iq.null)
  373. return;
  374. /* Inform user that a link requires maintenance actions because it has
  375. * become degraded or not operational. Note that this log message is
  376. * the primary intention behind a Link Incident Record. */
  377. format_node_data(iuparams, iunodeid, &lir->incident_node);
  378. format_node_data(auparams, aunodeid, &lir->attached_node);
  379. switch (lir->iq.class) {
  380. case LIR_IQ_CLASS_DEGRADED:
  381. pr_warn("Link degraded: RS=%02x RSID=%04x IC=%02x "
  382. "IUPARAMS=%s IUNODEID=%s AUPARAMS=%s AUNODEID=%s\n",
  383. sei_area->rs, sei_area->rsid, lir->ic, iuparams,
  384. iunodeid, auparams, aunodeid);
  385. break;
  386. case LIR_IQ_CLASS_NOT_OPERATIONAL:
  387. pr_err("Link stopped: RS=%02x RSID=%04x IC=%02x "
  388. "IUPARAMS=%s IUNODEID=%s AUPARAMS=%s AUNODEID=%s\n",
  389. sei_area->rs, sei_area->rsid, lir->ic, iuparams,
  390. iunodeid, auparams, aunodeid);
  391. break;
  392. default:
  393. break;
  394. }
  395. }
  396. static void chsc_process_sei_res_acc(struct chsc_sei_nt0_area *sei_area)
  397. {
  398. struct channel_path *chp;
  399. struct chp_link link;
  400. struct chp_id chpid;
  401. int status;
  402. CIO_CRW_EVENT(4, "chsc: resource accessibility event (rs=%02x, "
  403. "rs_id=%04x)\n", sei_area->rs, sei_area->rsid);
  404. if (sei_area->rs != 4)
  405. return;
  406. chp_id_init(&chpid);
  407. chpid.id = sei_area->rsid;
  408. /* allocate a new channel path structure, if needed */
  409. status = chp_get_status(chpid);
  410. if (!status)
  411. return;
  412. if (status < 0) {
  413. chp_new(chpid);
  414. } else {
  415. chp = chpid_to_chp(chpid);
  416. mutex_lock(&chp->lock);
  417. chp_update_desc(chp);
  418. mutex_unlock(&chp->lock);
  419. }
  420. memset(&link, 0, sizeof(struct chp_link));
  421. link.chpid = chpid;
  422. if ((sei_area->vf & 0xc0) != 0) {
  423. link.fla = sei_area->fla;
  424. if ((sei_area->vf & 0xc0) == 0xc0)
  425. /* full link address */
  426. link.fla_mask = 0xffff;
  427. else
  428. /* link address */
  429. link.fla_mask = 0xff00;
  430. }
  431. s390_process_res_acc(&link);
  432. }
  433. static void chsc_process_sei_chp_avail(struct chsc_sei_nt0_area *sei_area)
  434. {
  435. struct channel_path *chp;
  436. struct chp_id chpid;
  437. u8 *data;
  438. int num;
  439. CIO_CRW_EVENT(4, "chsc: channel path availability information\n");
  440. if (sei_area->rs != 0)
  441. return;
  442. data = sei_area->ccdf;
  443. chp_id_init(&chpid);
  444. for (num = 0; num <= __MAX_CHPID; num++) {
  445. if (!chp_test_bit(data, num))
  446. continue;
  447. chpid.id = num;
  448. CIO_CRW_EVENT(4, "Update information for channel path "
  449. "%x.%02x\n", chpid.cssid, chpid.id);
  450. chp = chpid_to_chp(chpid);
  451. if (!chp) {
  452. chp_new(chpid);
  453. continue;
  454. }
  455. mutex_lock(&chp->lock);
  456. chp_update_desc(chp);
  457. mutex_unlock(&chp->lock);
  458. }
  459. }
  460. struct chp_config_data {
  461. u8 map[32];
  462. u8 op;
  463. u8 pc;
  464. };
  465. static void chsc_process_sei_chp_config(struct chsc_sei_nt0_area *sei_area)
  466. {
  467. struct chp_config_data *data;
  468. struct chp_id chpid;
  469. int num;
  470. char *events[3] = {"configure", "deconfigure", "cancel deconfigure"};
  471. CIO_CRW_EVENT(4, "chsc: channel-path-configuration notification\n");
  472. if (sei_area->rs != 0)
  473. return;
  474. data = (struct chp_config_data *) &(sei_area->ccdf);
  475. chp_id_init(&chpid);
  476. for (num = 0; num <= __MAX_CHPID; num++) {
  477. if (!chp_test_bit(data->map, num))
  478. continue;
  479. chpid.id = num;
  480. pr_notice("Processing %s for channel path %x.%02x\n",
  481. events[data->op], chpid.cssid, chpid.id);
  482. switch (data->op) {
  483. case 0:
  484. chp_cfg_schedule(chpid, 1);
  485. break;
  486. case 1:
  487. chp_cfg_schedule(chpid, 0);
  488. break;
  489. case 2:
  490. chp_cfg_cancel_deconfigure(chpid);
  491. break;
  492. }
  493. }
  494. }
  495. static void chsc_process_sei_scm_change(struct chsc_sei_nt0_area *sei_area)
  496. {
  497. int ret;
  498. CIO_CRW_EVENT(4, "chsc: scm change notification\n");
  499. if (sei_area->rs != 7)
  500. return;
  501. ret = scm_update_information();
  502. if (ret)
  503. CIO_CRW_EVENT(0, "chsc: updating change notification"
  504. " failed (rc=%d).\n", ret);
  505. }
  506. static void chsc_process_sei_scm_avail(struct chsc_sei_nt0_area *sei_area)
  507. {
  508. int ret;
  509. CIO_CRW_EVENT(4, "chsc: scm available information\n");
  510. if (sei_area->rs != 7)
  511. return;
  512. ret = scm_process_availability_information();
  513. if (ret)
  514. CIO_CRW_EVENT(0, "chsc: process availability information"
  515. " failed (rc=%d).\n", ret);
  516. }
  517. static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area)
  518. {
  519. switch (sei_area->cc) {
  520. case 1:
  521. zpci_event_error(sei_area->ccdf);
  522. break;
  523. case 2:
  524. zpci_event_availability(sei_area->ccdf);
  525. break;
  526. default:
  527. CIO_CRW_EVENT(2, "chsc: sei nt2 unhandled cc=%d\n",
  528. sei_area->cc);
  529. break;
  530. }
  531. }
  532. static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area)
  533. {
  534. /* which kind of information was stored? */
  535. switch (sei_area->cc) {
  536. case 1: /* link incident*/
  537. chsc_process_sei_link_incident(sei_area);
  538. break;
  539. case 2: /* i/o resource accessibility */
  540. chsc_process_sei_res_acc(sei_area);
  541. break;
  542. case 7: /* channel-path-availability information */
  543. chsc_process_sei_chp_avail(sei_area);
  544. break;
  545. case 8: /* channel-path-configuration notification */
  546. chsc_process_sei_chp_config(sei_area);
  547. break;
  548. case 12: /* scm change notification */
  549. chsc_process_sei_scm_change(sei_area);
  550. break;
  551. case 14: /* scm available notification */
  552. chsc_process_sei_scm_avail(sei_area);
  553. break;
  554. default: /* other stuff */
  555. CIO_CRW_EVENT(2, "chsc: sei nt0 unhandled cc=%d\n",
  556. sei_area->cc);
  557. break;
  558. }
  559. /* Check if we might have lost some information. */
  560. if (sei_area->flags & 0x40) {
  561. CIO_CRW_EVENT(2, "chsc: event overflow\n");
  562. css_schedule_eval_all();
  563. }
  564. }
  565. static void chsc_process_event_information(struct chsc_sei *sei, u64 ntsm)
  566. {
  567. static int ntsm_unsupported;
  568. while (true) {
  569. memset(sei, 0, sizeof(*sei));
  570. sei->request.length = 0x0010;
  571. sei->request.code = 0x000e;
  572. if (!ntsm_unsupported)
  573. sei->ntsm = ntsm;
  574. if (chsc(sei))
  575. break;
  576. if (sei->response.code != 0x0001) {
  577. CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x, ntsm=%llx)\n",
  578. sei->response.code, sei->ntsm);
  579. if (sei->response.code == 3 && sei->ntsm) {
  580. /* Fallback for old firmware. */
  581. ntsm_unsupported = 1;
  582. continue;
  583. }
  584. break;
  585. }
  586. CIO_CRW_EVENT(2, "chsc: sei successful (nt=%d)\n", sei->nt);
  587. switch (sei->nt) {
  588. case 0:
  589. chsc_process_sei_nt0(&sei->u.nt0_area);
  590. break;
  591. case 2:
  592. chsc_process_sei_nt2(&sei->u.nt2_area);
  593. break;
  594. default:
  595. CIO_CRW_EVENT(2, "chsc: unhandled nt: %d\n", sei->nt);
  596. break;
  597. }
  598. if (!(sei->u.nt0_area.flags & 0x80))
  599. break;
  600. }
  601. }
  602. /*
  603. * Handle channel subsystem related CRWs.
  604. * Use store event information to find out what's going on.
  605. *
  606. * Note: Access to sei_page is serialized through machine check handler
  607. * thread, so no need for locking.
  608. */
  609. static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow)
  610. {
  611. struct chsc_sei *sei = sei_page;
  612. if (overflow) {
  613. css_schedule_eval_all();
  614. return;
  615. }
  616. CIO_CRW_EVENT(2, "CRW reports slct=%d, oflw=%d, "
  617. "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
  618. crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc,
  619. crw0->erc, crw0->rsid);
  620. CIO_TRACE_EVENT(2, "prcss");
  621. chsc_process_event_information(sei, CHSC_SEI_NT0 | CHSC_SEI_NT2);
  622. }
  623. void chsc_chp_online(struct chp_id chpid)
  624. {
  625. struct channel_path *chp = chpid_to_chp(chpid);
  626. struct chp_link link;
  627. char dbf_txt[15];
  628. sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id);
  629. CIO_TRACE_EVENT(2, dbf_txt);
  630. if (chp_get_status(chpid) != 0) {
  631. memset(&link, 0, sizeof(struct chp_link));
  632. link.chpid = chpid;
  633. /* Wait until previous actions have settled. */
  634. css_wait_for_slow_path();
  635. mutex_lock(&chp->lock);
  636. chp_update_desc(chp);
  637. mutex_unlock(&chp->lock);
  638. for_each_subchannel_staged(__s390_process_res_acc, NULL,
  639. &link);
  640. css_schedule_reprobe();
  641. }
  642. }
  643. static void __s390_subchannel_vary_chpid(struct subchannel *sch,
  644. struct chp_id chpid, int on)
  645. {
  646. unsigned long flags;
  647. struct chp_link link;
  648. memset(&link, 0, sizeof(struct chp_link));
  649. link.chpid = chpid;
  650. spin_lock_irqsave(sch->lock, flags);
  651. if (sch->driver && sch->driver->chp_event)
  652. sch->driver->chp_event(sch, &link,
  653. on ? CHP_VARY_ON : CHP_VARY_OFF);
  654. spin_unlock_irqrestore(sch->lock, flags);
  655. }
  656. static int s390_subchannel_vary_chpid_off(struct subchannel *sch, void *data)
  657. {
  658. struct chp_id *chpid = data;
  659. __s390_subchannel_vary_chpid(sch, *chpid, 0);
  660. return 0;
  661. }
  662. static int s390_subchannel_vary_chpid_on(struct subchannel *sch, void *data)
  663. {
  664. struct chp_id *chpid = data;
  665. __s390_subchannel_vary_chpid(sch, *chpid, 1);
  666. return 0;
  667. }
  668. /**
  669. * chsc_chp_vary - propagate channel-path vary operation to subchannels
  670. * @chpid: channl-path ID
  671. * @on: non-zero for vary online, zero for vary offline
  672. */
  673. int chsc_chp_vary(struct chp_id chpid, int on)
  674. {
  675. struct channel_path *chp = chpid_to_chp(chpid);
  676. /* Wait until previous actions have settled. */
  677. css_wait_for_slow_path();
  678. /*
  679. * Redo PathVerification on the devices the chpid connects to
  680. */
  681. if (on) {
  682. /* Try to update the channel path description. */
  683. chp_update_desc(chp);
  684. for_each_subchannel_staged(s390_subchannel_vary_chpid_on,
  685. NULL, &chpid);
  686. css_schedule_reprobe();
  687. } else
  688. for_each_subchannel_staged(s390_subchannel_vary_chpid_off,
  689. NULL, &chpid);
  690. return 0;
  691. }
  692. static void
  693. chsc_remove_cmg_attr(struct channel_subsystem *css)
  694. {
  695. int i;
  696. for (i = 0; i <= __MAX_CHPID; i++) {
  697. if (!css->chps[i])
  698. continue;
  699. chp_remove_cmg_attr(css->chps[i]);
  700. }
  701. }
  702. static int
  703. chsc_add_cmg_attr(struct channel_subsystem *css)
  704. {
  705. int i, ret;
  706. ret = 0;
  707. for (i = 0; i <= __MAX_CHPID; i++) {
  708. if (!css->chps[i])
  709. continue;
  710. ret = chp_add_cmg_attr(css->chps[i]);
  711. if (ret)
  712. goto cleanup;
  713. }
  714. return ret;
  715. cleanup:
  716. for (--i; i >= 0; i--) {
  717. if (!css->chps[i])
  718. continue;
  719. chp_remove_cmg_attr(css->chps[i]);
  720. }
  721. return ret;
  722. }
  723. int __chsc_do_secm(struct channel_subsystem *css, int enable)
  724. {
  725. struct {
  726. struct chsc_header request;
  727. u32 operation_code : 2;
  728. u32 : 30;
  729. u32 key : 4;
  730. u32 : 28;
  731. u32 zeroes1;
  732. u32 cub_addr1;
  733. u32 zeroes2;
  734. u32 cub_addr2;
  735. u32 reserved[13];
  736. struct chsc_header response;
  737. u32 status : 8;
  738. u32 : 4;
  739. u32 fmt : 4;
  740. u32 : 16;
  741. } __attribute__ ((packed)) *secm_area;
  742. unsigned long flags;
  743. int ret, ccode;
  744. spin_lock_irqsave(&chsc_page_lock, flags);
  745. memset(chsc_page, 0, PAGE_SIZE);
  746. secm_area = chsc_page;
  747. secm_area->request.length = 0x0050;
  748. secm_area->request.code = 0x0016;
  749. secm_area->key = PAGE_DEFAULT_KEY >> 4;
  750. secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1;
  751. secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2;
  752. secm_area->operation_code = enable ? 0 : 1;
  753. ccode = chsc(secm_area);
  754. if (ccode > 0) {
  755. ret = (ccode == 3) ? -ENODEV : -EBUSY;
  756. goto out;
  757. }
  758. switch (secm_area->response.code) {
  759. case 0x0102:
  760. case 0x0103:
  761. ret = -EINVAL;
  762. break;
  763. default:
  764. ret = chsc_error_from_response(secm_area->response.code);
  765. }
  766. if (ret != 0)
  767. CIO_CRW_EVENT(2, "chsc: secm failed (rc=%04x)\n",
  768. secm_area->response.code);
  769. out:
  770. spin_unlock_irqrestore(&chsc_page_lock, flags);
  771. return ret;
  772. }
  773. int
  774. chsc_secm(struct channel_subsystem *css, int enable)
  775. {
  776. int ret;
  777. if (enable && !css->cm_enabled) {
  778. css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
  779. css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
  780. if (!css->cub_addr1 || !css->cub_addr2) {
  781. free_page((unsigned long)css->cub_addr1);
  782. free_page((unsigned long)css->cub_addr2);
  783. return -ENOMEM;
  784. }
  785. }
  786. ret = __chsc_do_secm(css, enable);
  787. if (!ret) {
  788. css->cm_enabled = enable;
  789. if (css->cm_enabled) {
  790. ret = chsc_add_cmg_attr(css);
  791. if (ret) {
  792. __chsc_do_secm(css, 0);
  793. css->cm_enabled = 0;
  794. }
  795. } else
  796. chsc_remove_cmg_attr(css);
  797. }
  798. if (!css->cm_enabled) {
  799. free_page((unsigned long)css->cub_addr1);
  800. free_page((unsigned long)css->cub_addr2);
  801. }
  802. return ret;
  803. }
  804. int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
  805. int c, int m, void *page)
  806. {
  807. struct chsc_scpd *scpd_area;
  808. int ccode, ret;
  809. if ((rfmt == 1) && !css_general_characteristics.fcs)
  810. return -EINVAL;
  811. if ((rfmt == 2) && !css_general_characteristics.cib)
  812. return -EINVAL;
  813. memset(page, 0, PAGE_SIZE);
  814. scpd_area = page;
  815. scpd_area->request.length = 0x0010;
  816. scpd_area->request.code = 0x0002;
  817. scpd_area->cssid = chpid.cssid;
  818. scpd_area->first_chpid = chpid.id;
  819. scpd_area->last_chpid = chpid.id;
  820. scpd_area->m = m;
  821. scpd_area->c = c;
  822. scpd_area->fmt = fmt;
  823. scpd_area->rfmt = rfmt;
  824. ccode = chsc(scpd_area);
  825. if (ccode > 0)
  826. return (ccode == 3) ? -ENODEV : -EBUSY;
  827. ret = chsc_error_from_response(scpd_area->response.code);
  828. if (ret)
  829. CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
  830. scpd_area->response.code);
  831. return ret;
  832. }
  833. EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc);
  834. int chsc_determine_base_channel_path_desc(struct chp_id chpid,
  835. struct channel_path_desc *desc)
  836. {
  837. struct chsc_response_struct *chsc_resp;
  838. struct chsc_scpd *scpd_area;
  839. unsigned long flags;
  840. int ret;
  841. spin_lock_irqsave(&chsc_page_lock, flags);
  842. scpd_area = chsc_page;
  843. ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, scpd_area);
  844. if (ret)
  845. goto out;
  846. chsc_resp = (void *)&scpd_area->response;
  847. memcpy(desc, &chsc_resp->data, sizeof(*desc));
  848. out:
  849. spin_unlock_irqrestore(&chsc_page_lock, flags);
  850. return ret;
  851. }
  852. int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid,
  853. struct channel_path_desc_fmt1 *desc)
  854. {
  855. struct chsc_response_struct *chsc_resp;
  856. struct chsc_scpd *scpd_area;
  857. unsigned long flags;
  858. int ret;
  859. spin_lock_irqsave(&chsc_page_lock, flags);
  860. scpd_area = chsc_page;
  861. ret = chsc_determine_channel_path_desc(chpid, 0, 0, 1, 0, scpd_area);
  862. if (ret)
  863. goto out;
  864. chsc_resp = (void *)&scpd_area->response;
  865. memcpy(desc, &chsc_resp->data, sizeof(*desc));
  866. out:
  867. spin_unlock_irqrestore(&chsc_page_lock, flags);
  868. return ret;
  869. }
  870. static void
  871. chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
  872. struct cmg_chars *chars)
  873. {
  874. int i, mask;
  875. for (i = 0; i < NR_MEASUREMENT_CHARS; i++) {
  876. mask = 0x80 >> (i + 3);
  877. if (cmcv & mask)
  878. chp->cmg_chars.values[i] = chars->values[i];
  879. else
  880. chp->cmg_chars.values[i] = 0;
  881. }
  882. }
  883. int chsc_get_channel_measurement_chars(struct channel_path *chp)
  884. {
  885. unsigned long flags;
  886. int ccode, ret;
  887. struct {
  888. struct chsc_header request;
  889. u32 : 24;
  890. u32 first_chpid : 8;
  891. u32 : 24;
  892. u32 last_chpid : 8;
  893. u32 zeroes1;
  894. struct chsc_header response;
  895. u32 zeroes2;
  896. u32 not_valid : 1;
  897. u32 shared : 1;
  898. u32 : 22;
  899. u32 chpid : 8;
  900. u32 cmcv : 5;
  901. u32 : 11;
  902. u32 cmgq : 8;
  903. u32 cmg : 8;
  904. u32 zeroes3;
  905. u32 data[NR_MEASUREMENT_CHARS];
  906. } __attribute__ ((packed)) *scmc_area;
  907. chp->shared = -1;
  908. chp->cmg = -1;
  909. if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm)
  910. return 0;
  911. spin_lock_irqsave(&chsc_page_lock, flags);
  912. memset(chsc_page, 0, PAGE_SIZE);
  913. scmc_area = chsc_page;
  914. scmc_area->request.length = 0x0010;
  915. scmc_area->request.code = 0x0022;
  916. scmc_area->first_chpid = chp->chpid.id;
  917. scmc_area->last_chpid = chp->chpid.id;
  918. ccode = chsc(scmc_area);
  919. if (ccode > 0) {
  920. ret = (ccode == 3) ? -ENODEV : -EBUSY;
  921. goto out;
  922. }
  923. ret = chsc_error_from_response(scmc_area->response.code);
  924. if (ret) {
  925. CIO_CRW_EVENT(2, "chsc: scmc failed (rc=%04x)\n",
  926. scmc_area->response.code);
  927. goto out;
  928. }
  929. if (scmc_area->not_valid)
  930. goto out;
  931. chp->cmg = scmc_area->cmg;
  932. chp->shared = scmc_area->shared;
  933. if (chp->cmg != 2 && chp->cmg != 3) {
  934. /* No cmg-dependent data. */
  935. goto out;
  936. }
  937. chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
  938. (struct cmg_chars *) &scmc_area->data);
  939. out:
  940. spin_unlock_irqrestore(&chsc_page_lock, flags);
  941. return ret;
  942. }
  943. int __init chsc_init(void)
  944. {
  945. int ret;
  946. sei_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
  947. chsc_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
  948. if (!sei_page || !chsc_page) {
  949. ret = -ENOMEM;
  950. goto out_err;
  951. }
  952. ret = crw_register_handler(CRW_RSC_CSS, chsc_process_crw);
  953. if (ret)
  954. goto out_err;
  955. return ret;
  956. out_err:
  957. free_page((unsigned long)chsc_page);
  958. free_page((unsigned long)sei_page);
  959. return ret;
  960. }
  961. void __init chsc_init_cleanup(void)
  962. {
  963. crw_unregister_handler(CRW_RSC_CSS);
  964. free_page((unsigned long)chsc_page);
  965. free_page((unsigned long)sei_page);
  966. }
  967. int __chsc_enable_facility(struct chsc_sda_area *sda_area, int operation_code)
  968. {
  969. int ret;
  970. sda_area->request.length = 0x0400;
  971. sda_area->request.code = 0x0031;
  972. sda_area->operation_code = operation_code;
  973. ret = chsc(sda_area);
  974. if (ret > 0) {
  975. ret = (ret == 3) ? -ENODEV : -EBUSY;
  976. goto out;
  977. }
  978. switch (sda_area->response.code) {
  979. case 0x0101:
  980. ret = -EOPNOTSUPP;
  981. break;
  982. default:
  983. ret = chsc_error_from_response(sda_area->response.code);
  984. }
  985. out:
  986. return ret;
  987. }
  988. int chsc_enable_facility(int operation_code)
  989. {
  990. struct chsc_sda_area *sda_area;
  991. unsigned long flags;
  992. int ret;
  993. spin_lock_irqsave(&chsc_page_lock, flags);
  994. memset(chsc_page, 0, PAGE_SIZE);
  995. sda_area = chsc_page;
  996. ret = __chsc_enable_facility(sda_area, operation_code);
  997. if (ret != 0)
  998. CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n",
  999. operation_code, sda_area->response.code);
  1000. spin_unlock_irqrestore(&chsc_page_lock, flags);
  1001. return ret;
  1002. }
  1003. struct css_general_char css_general_characteristics;
  1004. struct css_chsc_char css_chsc_characteristics;
  1005. int __init
  1006. chsc_determine_css_characteristics(void)
  1007. {
  1008. unsigned long flags;
  1009. int result;
  1010. struct {
  1011. struct chsc_header request;
  1012. u32 reserved1;
  1013. u32 reserved2;
  1014. u32 reserved3;
  1015. struct chsc_header response;
  1016. u32 reserved4;
  1017. u32 general_char[510];
  1018. u32 chsc_char[508];
  1019. } __attribute__ ((packed)) *scsc_area;
  1020. spin_lock_irqsave(&chsc_page_lock, flags);
  1021. memset(chsc_page, 0, PAGE_SIZE);
  1022. scsc_area = chsc_page;
  1023. scsc_area->request.length = 0x0010;
  1024. scsc_area->request.code = 0x0010;
  1025. result = chsc(scsc_area);
  1026. if (result) {
  1027. result = (result == 3) ? -ENODEV : -EBUSY;
  1028. goto exit;
  1029. }
  1030. result = chsc_error_from_response(scsc_area->response.code);
  1031. if (result == 0) {
  1032. memcpy(&css_general_characteristics, scsc_area->general_char,
  1033. sizeof(css_general_characteristics));
  1034. memcpy(&css_chsc_characteristics, scsc_area->chsc_char,
  1035. sizeof(css_chsc_characteristics));
  1036. } else
  1037. CIO_CRW_EVENT(2, "chsc: scsc failed (rc=%04x)\n",
  1038. scsc_area->response.code);
  1039. exit:
  1040. spin_unlock_irqrestore(&chsc_page_lock, flags);
  1041. return result;
  1042. }
  1043. EXPORT_SYMBOL_GPL(css_general_characteristics);
  1044. EXPORT_SYMBOL_GPL(css_chsc_characteristics);
  1045. int chsc_sstpc(void *page, unsigned int op, u16 ctrl)
  1046. {
  1047. struct {
  1048. struct chsc_header request;
  1049. unsigned int rsvd0;
  1050. unsigned int op : 8;
  1051. unsigned int rsvd1 : 8;
  1052. unsigned int ctrl : 16;
  1053. unsigned int rsvd2[5];
  1054. struct chsc_header response;
  1055. unsigned int rsvd3[7];
  1056. } __attribute__ ((packed)) *rr;
  1057. int rc;
  1058. memset(page, 0, PAGE_SIZE);
  1059. rr = page;
  1060. rr->request.length = 0x0020;
  1061. rr->request.code = 0x0033;
  1062. rr->op = op;
  1063. rr->ctrl = ctrl;
  1064. rc = chsc(rr);
  1065. if (rc)
  1066. return -EIO;
  1067. rc = (rr->response.code == 0x0001) ? 0 : -EIO;
  1068. return rc;
  1069. }
  1070. int chsc_sstpi(void *page, void *result, size_t size)
  1071. {
  1072. struct {
  1073. struct chsc_header request;
  1074. unsigned int rsvd0[3];
  1075. struct chsc_header response;
  1076. char data[size];
  1077. } __attribute__ ((packed)) *rr;
  1078. int rc;
  1079. memset(page, 0, PAGE_SIZE);
  1080. rr = page;
  1081. rr->request.length = 0x0010;
  1082. rr->request.code = 0x0038;
  1083. rc = chsc(rr);
  1084. if (rc)
  1085. return -EIO;
  1086. memcpy(result, &rr->data, size);
  1087. return (rr->response.code == 0x0001) ? 0 : -EIO;
  1088. }
  1089. int chsc_siosl(struct subchannel_id schid)
  1090. {
  1091. struct {
  1092. struct chsc_header request;
  1093. u32 word1;
  1094. struct subchannel_id sid;
  1095. u32 word3;
  1096. struct chsc_header response;
  1097. u32 word[11];
  1098. } __attribute__ ((packed)) *siosl_area;
  1099. unsigned long flags;
  1100. int ccode;
  1101. int rc;
  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;
  1109. ccode = chsc(siosl_area);
  1110. if (ccode > 0) {
  1111. if (ccode == 3)
  1112. rc = -ENODEV;
  1113. else
  1114. rc = -EBUSY;
  1115. CIO_MSG_EVENT(2, "chsc: chsc failed for 0.%x.%04x (ccode=%d)\n",
  1116. schid.ssid, schid.sch_no, ccode);
  1117. goto out;
  1118. }
  1119. rc = chsc_error_from_response(siosl_area->response.code);
  1120. if (rc)
  1121. CIO_MSG_EVENT(2, "chsc: siosl failed for 0.%x.%04x (rc=%04x)\n",
  1122. schid.ssid, schid.sch_no,
  1123. siosl_area->response.code);
  1124. else
  1125. CIO_MSG_EVENT(4, "chsc: siosl succeeded for 0.%x.%04x\n",
  1126. schid.ssid, schid.sch_no);
  1127. out:
  1128. spin_unlock_irqrestore(&chsc_page_lock, flags);
  1129. return rc;
  1130. }
  1131. EXPORT_SYMBOL_GPL(chsc_siosl);
  1132. /**
  1133. * chsc_scm_info() - store SCM information (SSI)
  1134. * @scm_area: request and response block for SSI
  1135. * @token: continuation token
  1136. *
  1137. * Returns 0 on success.
  1138. */
  1139. int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token)
  1140. {
  1141. int ccode, ret;
  1142. memset(scm_area, 0, sizeof(*scm_area));
  1143. scm_area->request.length = 0x0020;
  1144. scm_area->request.code = 0x004C;
  1145. scm_area->reqtok = token;
  1146. ccode = chsc(scm_area);
  1147. if (ccode > 0) {
  1148. ret = (ccode == 3) ? -ENODEV : -EBUSY;
  1149. goto out;
  1150. }
  1151. ret = chsc_error_from_response(scm_area->response.code);
  1152. if (ret != 0)
  1153. CIO_MSG_EVENT(2, "chsc: scm info failed (rc=%04x)\n",
  1154. scm_area->response.code);
  1155. out:
  1156. return ret;
  1157. }
  1158. EXPORT_SYMBOL_GPL(chsc_scm_info);
  1159. /**
  1160. * chsc_pnso_brinfo() - Perform Network-Subchannel Operation, Bridge Info.
  1161. * @schid: id of the subchannel on which PNSO is performed
  1162. * @brinfo_area: request and response block for the operation
  1163. * @resume_token: resume token for multiblock response
  1164. * @cnc: Boolean change-notification control
  1165. *
  1166. * brinfo_area must be allocated by the caller with get_zeroed_page(GFP_KERNEL)
  1167. *
  1168. * Returns 0 on success.
  1169. */
  1170. int chsc_pnso_brinfo(struct subchannel_id schid,
  1171. struct chsc_pnso_area *brinfo_area,
  1172. struct chsc_brinfo_resume_token resume_token,
  1173. int cnc)
  1174. {
  1175. memset(brinfo_area, 0, sizeof(*brinfo_area));
  1176. brinfo_area->request.length = 0x0030;
  1177. brinfo_area->request.code = 0x003d; /* network-subchannel operation */
  1178. brinfo_area->m = schid.m;
  1179. brinfo_area->ssid = schid.ssid;
  1180. brinfo_area->sch = schid.sch_no;
  1181. brinfo_area->cssid = schid.cssid;
  1182. brinfo_area->oc = 0; /* Store-network-bridging-information list */
  1183. brinfo_area->resume_token = resume_token;
  1184. brinfo_area->n = (cnc != 0);
  1185. if (chsc(brinfo_area))
  1186. return -EIO;
  1187. return chsc_error_from_response(brinfo_area->response.code);
  1188. }
  1189. EXPORT_SYMBOL_GPL(chsc_pnso_brinfo);