device_pgid.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. /*
  2. * CCW device PGID and path verification I/O handling.
  3. *
  4. * Copyright IBM Corp. 2002, 2009
  5. * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
  6. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  7. * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/string.h>
  11. #include <linux/types.h>
  12. #include <linux/errno.h>
  13. #include <linux/bitops.h>
  14. #include <asm/ccwdev.h>
  15. #include <asm/cio.h>
  16. #include "cio.h"
  17. #include "cio_debug.h"
  18. #include "device.h"
  19. #include "io_sch.h"
  20. #define PGID_RETRIES 256
  21. #define PGID_TIMEOUT (10 * HZ)
  22. static void verify_start(struct ccw_device *cdev);
  23. /*
  24. * Process path verification data and report result.
  25. */
  26. static void verify_done(struct ccw_device *cdev, int rc)
  27. {
  28. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  29. struct ccw_dev_id *id = &cdev->private->dev_id;
  30. int mpath = cdev->private->flags.mpath;
  31. int pgroup = cdev->private->flags.pgroup;
  32. if (rc)
  33. goto out;
  34. /* Ensure consistent multipathing state at device and channel. */
  35. if (sch->config.mp != mpath) {
  36. sch->config.mp = mpath;
  37. rc = cio_commit_config(sch);
  38. }
  39. out:
  40. CIO_MSG_EVENT(2, "vrfy: device 0.%x.%04x: rc=%d pgroup=%d mpath=%d "
  41. "vpm=%02x\n", id->ssid, id->devno, rc, pgroup, mpath,
  42. sch->vpm);
  43. ccw_device_verify_done(cdev, rc);
  44. }
  45. /*
  46. * Create channel program to perform a NOOP.
  47. */
  48. static void nop_build_cp(struct ccw_device *cdev)
  49. {
  50. struct ccw_request *req = &cdev->private->req;
  51. struct ccw1 *cp = cdev->private->iccws;
  52. cp->cmd_code = CCW_CMD_NOOP;
  53. cp->cda = 0;
  54. cp->count = 0;
  55. cp->flags = CCW_FLAG_SLI;
  56. req->cp = cp;
  57. }
  58. /*
  59. * Perform NOOP on a single path.
  60. */
  61. static void nop_do(struct ccw_device *cdev)
  62. {
  63. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  64. struct ccw_request *req = &cdev->private->req;
  65. req->lpm = lpm_adjust(req->lpm, sch->schib.pmcw.pam & sch->opm &
  66. ~cdev->private->path_noirq_mask);
  67. if (!req->lpm)
  68. goto out_nopath;
  69. nop_build_cp(cdev);
  70. ccw_request_start(cdev);
  71. return;
  72. out_nopath:
  73. verify_done(cdev, sch->vpm ? 0 : -EACCES);
  74. }
  75. /*
  76. * Adjust NOOP I/O status.
  77. */
  78. static enum io_status nop_filter(struct ccw_device *cdev, void *data,
  79. struct irb *irb, enum io_status status)
  80. {
  81. /* Only subchannel status might indicate a path error. */
  82. if (status == IO_STATUS_ERROR && irb->scsw.cmd.cstat == 0)
  83. return IO_DONE;
  84. return status;
  85. }
  86. /*
  87. * Process NOOP request result for a single path.
  88. */
  89. static void nop_callback(struct ccw_device *cdev, void *data, int rc)
  90. {
  91. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  92. struct ccw_request *req = &cdev->private->req;
  93. switch (rc) {
  94. case 0:
  95. sch->vpm |= req->lpm;
  96. break;
  97. case -ETIME:
  98. cdev->private->path_noirq_mask |= req->lpm;
  99. break;
  100. case -EACCES:
  101. cdev->private->path_notoper_mask |= req->lpm;
  102. break;
  103. default:
  104. goto err;
  105. }
  106. /* Continue on the next path. */
  107. req->lpm >>= 1;
  108. nop_do(cdev);
  109. return;
  110. err:
  111. verify_done(cdev, rc);
  112. }
  113. /*
  114. * Create channel program to perform SET PGID on a single path.
  115. */
  116. static void spid_build_cp(struct ccw_device *cdev, u8 fn)
  117. {
  118. struct ccw_request *req = &cdev->private->req;
  119. struct ccw1 *cp = cdev->private->iccws;
  120. int i = 8 - ffs(req->lpm);
  121. struct pgid *pgid = &cdev->private->pgid[i];
  122. pgid->inf.fc = fn;
  123. cp->cmd_code = CCW_CMD_SET_PGID;
  124. cp->cda = (u32) (addr_t) pgid;
  125. cp->count = sizeof(*pgid);
  126. cp->flags = CCW_FLAG_SLI;
  127. req->cp = cp;
  128. }
  129. static void pgid_wipeout_callback(struct ccw_device *cdev, void *data, int rc)
  130. {
  131. if (rc) {
  132. /* We don't know the path groups' state. Abort. */
  133. verify_done(cdev, rc);
  134. return;
  135. }
  136. /*
  137. * Path groups have been reset. Restart path verification but
  138. * leave paths in path_noirq_mask out.
  139. */
  140. cdev->private->flags.pgid_unknown = 0;
  141. verify_start(cdev);
  142. }
  143. /*
  144. * Reset pathgroups and restart path verification, leave unusable paths out.
  145. */
  146. static void pgid_wipeout_start(struct ccw_device *cdev)
  147. {
  148. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  149. struct ccw_dev_id *id = &cdev->private->dev_id;
  150. struct ccw_request *req = &cdev->private->req;
  151. u8 fn;
  152. CIO_MSG_EVENT(2, "wipe: device 0.%x.%04x: pvm=%02x nim=%02x\n",
  153. id->ssid, id->devno, cdev->private->pgid_valid_mask,
  154. cdev->private->path_noirq_mask);
  155. /* Initialize request data. */
  156. memset(req, 0, sizeof(*req));
  157. req->timeout = PGID_TIMEOUT;
  158. req->maxretries = PGID_RETRIES;
  159. req->lpm = sch->schib.pmcw.pam;
  160. req->callback = pgid_wipeout_callback;
  161. fn = SPID_FUNC_DISBAND;
  162. if (cdev->private->flags.mpath)
  163. fn |= SPID_FUNC_MULTI_PATH;
  164. spid_build_cp(cdev, fn);
  165. ccw_request_start(cdev);
  166. }
  167. /*
  168. * Perform establish/resign SET PGID on a single path.
  169. */
  170. static void spid_do(struct ccw_device *cdev)
  171. {
  172. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  173. struct ccw_request *req = &cdev->private->req;
  174. u8 fn;
  175. /* Use next available path that is not already in correct state. */
  176. req->lpm = lpm_adjust(req->lpm, cdev->private->pgid_todo_mask);
  177. if (!req->lpm)
  178. goto out_nopath;
  179. /* Channel program setup. */
  180. if (req->lpm & sch->opm)
  181. fn = SPID_FUNC_ESTABLISH;
  182. else
  183. fn = SPID_FUNC_RESIGN;
  184. if (cdev->private->flags.mpath)
  185. fn |= SPID_FUNC_MULTI_PATH;
  186. spid_build_cp(cdev, fn);
  187. ccw_request_start(cdev);
  188. return;
  189. out_nopath:
  190. if (cdev->private->flags.pgid_unknown) {
  191. /* At least one SPID could be partially done. */
  192. pgid_wipeout_start(cdev);
  193. return;
  194. }
  195. verify_done(cdev, sch->vpm ? 0 : -EACCES);
  196. }
  197. /*
  198. * Process SET PGID request result for a single path.
  199. */
  200. static void spid_callback(struct ccw_device *cdev, void *data, int rc)
  201. {
  202. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  203. struct ccw_request *req = &cdev->private->req;
  204. switch (rc) {
  205. case 0:
  206. sch->vpm |= req->lpm & sch->opm;
  207. break;
  208. case -ETIME:
  209. cdev->private->flags.pgid_unknown = 1;
  210. cdev->private->path_noirq_mask |= req->lpm;
  211. break;
  212. case -EACCES:
  213. cdev->private->path_notoper_mask |= req->lpm;
  214. break;
  215. case -EOPNOTSUPP:
  216. if (cdev->private->flags.mpath) {
  217. /* Try without multipathing. */
  218. cdev->private->flags.mpath = 0;
  219. goto out_restart;
  220. }
  221. /* Try without pathgrouping. */
  222. cdev->private->flags.pgroup = 0;
  223. goto out_restart;
  224. default:
  225. goto err;
  226. }
  227. req->lpm >>= 1;
  228. spid_do(cdev);
  229. return;
  230. out_restart:
  231. verify_start(cdev);
  232. return;
  233. err:
  234. verify_done(cdev, rc);
  235. }
  236. static void spid_start(struct ccw_device *cdev)
  237. {
  238. struct ccw_request *req = &cdev->private->req;
  239. /* Initialize request data. */
  240. memset(req, 0, sizeof(*req));
  241. req->timeout = PGID_TIMEOUT;
  242. req->maxretries = PGID_RETRIES;
  243. req->lpm = 0x80;
  244. req->singlepath = 1;
  245. req->callback = spid_callback;
  246. spid_do(cdev);
  247. }
  248. static int pgid_is_reset(struct pgid *p)
  249. {
  250. char *c;
  251. for (c = (char *)p + 1; c < (char *)(p + 1); c++) {
  252. if (*c != 0)
  253. return 0;
  254. }
  255. return 1;
  256. }
  257. static int pgid_cmp(struct pgid *p1, struct pgid *p2)
  258. {
  259. return memcmp((char *) p1 + 1, (char *) p2 + 1,
  260. sizeof(struct pgid) - 1);
  261. }
  262. /*
  263. * Determine pathgroup state from PGID data.
  264. */
  265. static void pgid_analyze(struct ccw_device *cdev, struct pgid **p,
  266. int *mismatch, u8 *reserved, u8 *reset)
  267. {
  268. struct pgid *pgid = &cdev->private->pgid[0];
  269. struct pgid *first = NULL;
  270. int lpm;
  271. int i;
  272. *mismatch = 0;
  273. *reserved = 0;
  274. *reset = 0;
  275. for (i = 0, lpm = 0x80; i < 8; i++, pgid++, lpm >>= 1) {
  276. if ((cdev->private->pgid_valid_mask & lpm) == 0)
  277. continue;
  278. if (pgid->inf.ps.state2 == SNID_STATE2_RESVD_ELSE)
  279. *reserved |= lpm;
  280. if (pgid_is_reset(pgid)) {
  281. *reset |= lpm;
  282. continue;
  283. }
  284. if (!first) {
  285. first = pgid;
  286. continue;
  287. }
  288. if (pgid_cmp(pgid, first) != 0)
  289. *mismatch = 1;
  290. }
  291. if (!first)
  292. first = &channel_subsystems[0]->global_pgid;
  293. *p = first;
  294. }
  295. static u8 pgid_to_donepm(struct ccw_device *cdev)
  296. {
  297. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  298. struct pgid *pgid;
  299. int i;
  300. int lpm;
  301. u8 donepm = 0;
  302. /* Set bits for paths which are already in the target state. */
  303. for (i = 0; i < 8; i++) {
  304. lpm = 0x80 >> i;
  305. if ((cdev->private->pgid_valid_mask & lpm) == 0)
  306. continue;
  307. pgid = &cdev->private->pgid[i];
  308. if (sch->opm & lpm) {
  309. if (pgid->inf.ps.state1 != SNID_STATE1_GROUPED)
  310. continue;
  311. } else {
  312. if (pgid->inf.ps.state1 != SNID_STATE1_UNGROUPED)
  313. continue;
  314. }
  315. if (cdev->private->flags.mpath) {
  316. if (pgid->inf.ps.state3 != SNID_STATE3_MULTI_PATH)
  317. continue;
  318. } else {
  319. if (pgid->inf.ps.state3 != SNID_STATE3_SINGLE_PATH)
  320. continue;
  321. }
  322. donepm |= lpm;
  323. }
  324. return donepm;
  325. }
  326. static void pgid_fill(struct ccw_device *cdev, struct pgid *pgid)
  327. {
  328. int i;
  329. for (i = 0; i < 8; i++)
  330. memcpy(&cdev->private->pgid[i], pgid, sizeof(struct pgid));
  331. }
  332. /*
  333. * Process SENSE PGID data and report result.
  334. */
  335. static void snid_done(struct ccw_device *cdev, int rc)
  336. {
  337. struct ccw_dev_id *id = &cdev->private->dev_id;
  338. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  339. struct pgid *pgid;
  340. int mismatch = 0;
  341. u8 reserved = 0;
  342. u8 reset = 0;
  343. u8 donepm;
  344. if (rc)
  345. goto out;
  346. pgid_analyze(cdev, &pgid, &mismatch, &reserved, &reset);
  347. if (reserved == cdev->private->pgid_valid_mask)
  348. rc = -EUSERS;
  349. else if (mismatch)
  350. rc = -EOPNOTSUPP;
  351. else {
  352. donepm = pgid_to_donepm(cdev);
  353. sch->vpm = donepm & sch->opm;
  354. cdev->private->pgid_reset_mask |= reset;
  355. cdev->private->pgid_todo_mask &=
  356. ~(donepm | cdev->private->path_noirq_mask);
  357. pgid_fill(cdev, pgid);
  358. }
  359. out:
  360. CIO_MSG_EVENT(2, "snid: device 0.%x.%04x: rc=%d pvm=%02x vpm=%02x "
  361. "todo=%02x mism=%d rsvd=%02x reset=%02x\n", id->ssid,
  362. id->devno, rc, cdev->private->pgid_valid_mask, sch->vpm,
  363. cdev->private->pgid_todo_mask, mismatch, reserved, reset);
  364. switch (rc) {
  365. case 0:
  366. if (cdev->private->flags.pgid_unknown) {
  367. pgid_wipeout_start(cdev);
  368. return;
  369. }
  370. /* Anything left to do? */
  371. if (cdev->private->pgid_todo_mask == 0) {
  372. verify_done(cdev, sch->vpm == 0 ? -EACCES : 0);
  373. return;
  374. }
  375. /* Perform path-grouping. */
  376. spid_start(cdev);
  377. break;
  378. case -EOPNOTSUPP:
  379. /* Path-grouping not supported. */
  380. cdev->private->flags.pgroup = 0;
  381. cdev->private->flags.mpath = 0;
  382. verify_start(cdev);
  383. break;
  384. default:
  385. verify_done(cdev, rc);
  386. }
  387. }
  388. /*
  389. * Create channel program to perform a SENSE PGID on a single path.
  390. */
  391. static void snid_build_cp(struct ccw_device *cdev)
  392. {
  393. struct ccw_request *req = &cdev->private->req;
  394. struct ccw1 *cp = cdev->private->iccws;
  395. int i = 8 - ffs(req->lpm);
  396. /* Channel program setup. */
  397. cp->cmd_code = CCW_CMD_SENSE_PGID;
  398. cp->cda = (u32) (addr_t) &cdev->private->pgid[i];
  399. cp->count = sizeof(struct pgid);
  400. cp->flags = CCW_FLAG_SLI;
  401. req->cp = cp;
  402. }
  403. /*
  404. * Perform SENSE PGID on a single path.
  405. */
  406. static void snid_do(struct ccw_device *cdev)
  407. {
  408. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  409. struct ccw_request *req = &cdev->private->req;
  410. int ret;
  411. req->lpm = lpm_adjust(req->lpm, sch->schib.pmcw.pam &
  412. ~cdev->private->path_noirq_mask);
  413. if (!req->lpm)
  414. goto out_nopath;
  415. snid_build_cp(cdev);
  416. ccw_request_start(cdev);
  417. return;
  418. out_nopath:
  419. if (cdev->private->pgid_valid_mask)
  420. ret = 0;
  421. else if (cdev->private->path_noirq_mask)
  422. ret = -ETIME;
  423. else
  424. ret = -EACCES;
  425. snid_done(cdev, ret);
  426. }
  427. /*
  428. * Process SENSE PGID request result for single path.
  429. */
  430. static void snid_callback(struct ccw_device *cdev, void *data, int rc)
  431. {
  432. struct ccw_request *req = &cdev->private->req;
  433. switch (rc) {
  434. case 0:
  435. cdev->private->pgid_valid_mask |= req->lpm;
  436. break;
  437. case -ETIME:
  438. cdev->private->flags.pgid_unknown = 1;
  439. cdev->private->path_noirq_mask |= req->lpm;
  440. break;
  441. case -EACCES:
  442. cdev->private->path_notoper_mask |= req->lpm;
  443. break;
  444. default:
  445. goto err;
  446. }
  447. /* Continue on the next path. */
  448. req->lpm >>= 1;
  449. snid_do(cdev);
  450. return;
  451. err:
  452. snid_done(cdev, rc);
  453. }
  454. /*
  455. * Perform path verification.
  456. */
  457. static void verify_start(struct ccw_device *cdev)
  458. {
  459. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  460. struct ccw_request *req = &cdev->private->req;
  461. struct ccw_dev_id *devid = &cdev->private->dev_id;
  462. sch->vpm = 0;
  463. sch->lpm = sch->schib.pmcw.pam;
  464. /* Initialize PGID data. */
  465. memset(cdev->private->pgid, 0, sizeof(cdev->private->pgid));
  466. cdev->private->pgid_valid_mask = 0;
  467. cdev->private->pgid_todo_mask = sch->schib.pmcw.pam;
  468. cdev->private->path_notoper_mask = 0;
  469. /* Initialize request data. */
  470. memset(req, 0, sizeof(*req));
  471. req->timeout = PGID_TIMEOUT;
  472. req->maxretries = PGID_RETRIES;
  473. req->lpm = 0x80;
  474. req->singlepath = 1;
  475. if (cdev->private->flags.pgroup) {
  476. CIO_TRACE_EVENT(4, "snid");
  477. CIO_HEX_EVENT(4, devid, sizeof(*devid));
  478. req->callback = snid_callback;
  479. snid_do(cdev);
  480. } else {
  481. CIO_TRACE_EVENT(4, "nop");
  482. CIO_HEX_EVENT(4, devid, sizeof(*devid));
  483. req->filter = nop_filter;
  484. req->callback = nop_callback;
  485. nop_do(cdev);
  486. }
  487. }
  488. /**
  489. * ccw_device_verify_start - perform path verification
  490. * @cdev: ccw device
  491. *
  492. * Perform an I/O on each available channel path to @cdev to determine which
  493. * paths are operational. The resulting path mask is stored in sch->vpm.
  494. * If device options specify pathgrouping, establish a pathgroup for the
  495. * operational paths. When finished, call ccw_device_verify_done with a
  496. * return code specifying the result.
  497. */
  498. void ccw_device_verify_start(struct ccw_device *cdev)
  499. {
  500. CIO_TRACE_EVENT(4, "vrfy");
  501. CIO_HEX_EVENT(4, &cdev->private->dev_id, sizeof(cdev->private->dev_id));
  502. /*
  503. * Initialize pathgroup and multipath state with target values.
  504. * They may change in the course of path verification.
  505. */
  506. cdev->private->flags.pgroup = cdev->private->options.pgroup;
  507. cdev->private->flags.mpath = cdev->private->options.mpath;
  508. cdev->private->flags.doverify = 0;
  509. cdev->private->path_noirq_mask = 0;
  510. verify_start(cdev);
  511. }
  512. /*
  513. * Process disband SET PGID request result.
  514. */
  515. static void disband_callback(struct ccw_device *cdev, void *data, int rc)
  516. {
  517. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  518. struct ccw_dev_id *id = &cdev->private->dev_id;
  519. if (rc)
  520. goto out;
  521. /* Ensure consistent multipathing state at device and channel. */
  522. cdev->private->flags.mpath = 0;
  523. if (sch->config.mp) {
  524. sch->config.mp = 0;
  525. rc = cio_commit_config(sch);
  526. }
  527. out:
  528. CIO_MSG_EVENT(0, "disb: device 0.%x.%04x: rc=%d\n", id->ssid, id->devno,
  529. rc);
  530. ccw_device_disband_done(cdev, rc);
  531. }
  532. /**
  533. * ccw_device_disband_start - disband pathgroup
  534. * @cdev: ccw device
  535. *
  536. * Execute a SET PGID channel program on @cdev to disband a previously
  537. * established pathgroup. When finished, call ccw_device_disband_done with
  538. * a return code specifying the result.
  539. */
  540. void ccw_device_disband_start(struct ccw_device *cdev)
  541. {
  542. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  543. struct ccw_request *req = &cdev->private->req;
  544. u8 fn;
  545. CIO_TRACE_EVENT(4, "disb");
  546. CIO_HEX_EVENT(4, &cdev->private->dev_id, sizeof(cdev->private->dev_id));
  547. /* Request setup. */
  548. memset(req, 0, sizeof(*req));
  549. req->timeout = PGID_TIMEOUT;
  550. req->maxretries = PGID_RETRIES;
  551. req->lpm = sch->schib.pmcw.pam & sch->opm;
  552. req->singlepath = 1;
  553. req->callback = disband_callback;
  554. fn = SPID_FUNC_DISBAND;
  555. if (cdev->private->flags.mpath)
  556. fn |= SPID_FUNC_MULTI_PATH;
  557. spid_build_cp(cdev, fn);
  558. ccw_request_start(cdev);
  559. }
  560. static void stlck_build_cp(struct ccw_device *cdev, void *buf1, void *buf2)
  561. {
  562. struct ccw_request *req = &cdev->private->req;
  563. struct ccw1 *cp = cdev->private->iccws;
  564. cp[0].cmd_code = CCW_CMD_STLCK;
  565. cp[0].cda = (u32) (addr_t) buf1;
  566. cp[0].count = 32;
  567. cp[0].flags = CCW_FLAG_CC;
  568. cp[1].cmd_code = CCW_CMD_RELEASE;
  569. cp[1].cda = (u32) (addr_t) buf2;
  570. cp[1].count = 32;
  571. cp[1].flags = 0;
  572. req->cp = cp;
  573. }
  574. static void stlck_callback(struct ccw_device *cdev, void *data, int rc)
  575. {
  576. ccw_device_stlck_done(cdev, data, rc);
  577. }
  578. /**
  579. * ccw_device_stlck_start - perform unconditional release
  580. * @cdev: ccw device
  581. * @data: data pointer to be passed to ccw_device_stlck_done
  582. * @buf1: data pointer used in channel program
  583. * @buf2: data pointer used in channel program
  584. *
  585. * Execute a channel program on @cdev to release an existing PGID reservation.
  586. * When finished, call ccw_device_stlck_done with a return code specifying the
  587. * result.
  588. */
  589. void ccw_device_stlck_start(struct ccw_device *cdev, void *data, void *buf1,
  590. void *buf2)
  591. {
  592. struct subchannel *sch = to_subchannel(cdev->dev.parent);
  593. struct ccw_request *req = &cdev->private->req;
  594. CIO_TRACE_EVENT(4, "stlck");
  595. CIO_HEX_EVENT(4, &cdev->private->dev_id, sizeof(cdev->private->dev_id));
  596. /* Request setup. */
  597. memset(req, 0, sizeof(*req));
  598. req->timeout = PGID_TIMEOUT;
  599. req->maxretries = PGID_RETRIES;
  600. req->lpm = sch->schib.pmcw.pam & sch->opm;
  601. req->data = data;
  602. req->callback = stlck_callback;
  603. stlck_build_cp(cdev, buf1, buf2);
  604. ccw_request_start(cdev);
  605. }