qdio_setup.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * qdio queue initialization
  3. *
  4. * Copyright IBM Corp. 2008
  5. * Author(s): Jan Glauber <jang@linux.vnet.ibm.com>
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/slab.h>
  9. #include <linux/export.h>
  10. #include <asm/qdio.h>
  11. #include "cio.h"
  12. #include "css.h"
  13. #include "device.h"
  14. #include "ioasm.h"
  15. #include "chsc.h"
  16. #include "qdio.h"
  17. #include "qdio_debug.h"
  18. #define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
  19. static struct kmem_cache *qdio_q_cache;
  20. static struct kmem_cache *qdio_aob_cache;
  21. struct qaob *qdio_allocate_aob(void)
  22. {
  23. return kmem_cache_zalloc(qdio_aob_cache, GFP_ATOMIC);
  24. }
  25. EXPORT_SYMBOL_GPL(qdio_allocate_aob);
  26. void qdio_release_aob(struct qaob *aob)
  27. {
  28. kmem_cache_free(qdio_aob_cache, aob);
  29. }
  30. EXPORT_SYMBOL_GPL(qdio_release_aob);
  31. /**
  32. * qdio_free_buffers() - free qdio buffers
  33. * @buf: array of pointers to qdio buffers
  34. * @count: number of qdio buffers to free
  35. */
  36. void qdio_free_buffers(struct qdio_buffer **buf, unsigned int count)
  37. {
  38. int pos;
  39. for (pos = 0; pos < count; pos += QBUFF_PER_PAGE)
  40. free_page((unsigned long) buf[pos]);
  41. }
  42. EXPORT_SYMBOL_GPL(qdio_free_buffers);
  43. /**
  44. * qdio_alloc_buffers() - allocate qdio buffers
  45. * @buf: array of pointers to qdio buffers
  46. * @count: number of qdio buffers to allocate
  47. */
  48. int qdio_alloc_buffers(struct qdio_buffer **buf, unsigned int count)
  49. {
  50. int pos;
  51. for (pos = 0; pos < count; pos += QBUFF_PER_PAGE) {
  52. buf[pos] = (void *) get_zeroed_page(GFP_KERNEL);
  53. if (!buf[pos]) {
  54. qdio_free_buffers(buf, count);
  55. return -ENOMEM;
  56. }
  57. }
  58. for (pos = 0; pos < count; pos++)
  59. if (pos % QBUFF_PER_PAGE)
  60. buf[pos] = buf[pos - 1] + 1;
  61. return 0;
  62. }
  63. EXPORT_SYMBOL_GPL(qdio_alloc_buffers);
  64. /**
  65. * qdio_reset_buffers() - reset qdio buffers
  66. * @buf: array of pointers to qdio buffers
  67. * @count: number of qdio buffers that will be zeroed
  68. */
  69. void qdio_reset_buffers(struct qdio_buffer **buf, unsigned int count)
  70. {
  71. int pos;
  72. for (pos = 0; pos < count; pos++)
  73. memset(buf[pos], 0, sizeof(struct qdio_buffer));
  74. }
  75. EXPORT_SYMBOL_GPL(qdio_reset_buffers);
  76. /*
  77. * qebsm is only available under 64bit but the adapter sets the feature
  78. * flag anyway, so we manually override it.
  79. */
  80. static inline int qebsm_possible(void)
  81. {
  82. return css_general_characteristics.qebsm;
  83. }
  84. /*
  85. * qib_param_field: pointer to 128 bytes or NULL, if no param field
  86. * nr_input_qs: pointer to nr_queues*128 words of data or NULL
  87. */
  88. static void set_impl_params(struct qdio_irq *irq_ptr,
  89. unsigned int qib_param_field_format,
  90. unsigned char *qib_param_field,
  91. unsigned long *input_slib_elements,
  92. unsigned long *output_slib_elements)
  93. {
  94. struct qdio_q *q;
  95. int i, j;
  96. if (!irq_ptr)
  97. return;
  98. irq_ptr->qib.pfmt = qib_param_field_format;
  99. if (qib_param_field)
  100. memcpy(irq_ptr->qib.parm, qib_param_field,
  101. QDIO_MAX_BUFFERS_PER_Q);
  102. if (!input_slib_elements)
  103. goto output;
  104. for_each_input_queue(irq_ptr, q, i) {
  105. for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
  106. q->slib->slibe[j].parms =
  107. input_slib_elements[i * QDIO_MAX_BUFFERS_PER_Q + j];
  108. }
  109. output:
  110. if (!output_slib_elements)
  111. return;
  112. for_each_output_queue(irq_ptr, q, i) {
  113. for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
  114. q->slib->slibe[j].parms =
  115. output_slib_elements[i * QDIO_MAX_BUFFERS_PER_Q + j];
  116. }
  117. }
  118. static int __qdio_allocate_qs(struct qdio_q **irq_ptr_qs, int nr_queues)
  119. {
  120. struct qdio_q *q;
  121. int i;
  122. for (i = 0; i < nr_queues; i++) {
  123. q = kmem_cache_zalloc(qdio_q_cache, GFP_KERNEL);
  124. if (!q)
  125. return -ENOMEM;
  126. q->slib = (struct slib *) __get_free_page(GFP_KERNEL);
  127. if (!q->slib) {
  128. kmem_cache_free(qdio_q_cache, q);
  129. return -ENOMEM;
  130. }
  131. irq_ptr_qs[i] = q;
  132. }
  133. return 0;
  134. }
  135. int qdio_allocate_qs(struct qdio_irq *irq_ptr, int nr_input_qs, int nr_output_qs)
  136. {
  137. int rc;
  138. rc = __qdio_allocate_qs(irq_ptr->input_qs, nr_input_qs);
  139. if (rc)
  140. return rc;
  141. rc = __qdio_allocate_qs(irq_ptr->output_qs, nr_output_qs);
  142. return rc;
  143. }
  144. static void setup_queues_misc(struct qdio_q *q, struct qdio_irq *irq_ptr,
  145. qdio_handler_t *handler, int i)
  146. {
  147. struct slib *slib = q->slib;
  148. /* queue must be cleared for qdio_establish */
  149. memset(q, 0, sizeof(*q));
  150. memset(slib, 0, PAGE_SIZE);
  151. q->slib = slib;
  152. q->irq_ptr = irq_ptr;
  153. q->mask = 1 << (31 - i);
  154. q->nr = i;
  155. q->handler = handler;
  156. }
  157. static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr,
  158. void **sbals_array, int i)
  159. {
  160. struct qdio_q *prev;
  161. int j;
  162. DBF_HEX(&q, sizeof(void *));
  163. q->sl = (struct sl *)((char *)q->slib + PAGE_SIZE / 2);
  164. /* fill in sbal */
  165. for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
  166. q->sbal[j] = *sbals_array++;
  167. /* fill in slib */
  168. if (i > 0) {
  169. prev = (q->is_input_q) ? irq_ptr->input_qs[i - 1]
  170. : irq_ptr->output_qs[i - 1];
  171. prev->slib->nsliba = (unsigned long)q->slib;
  172. }
  173. q->slib->sla = (unsigned long)q->sl;
  174. q->slib->slsba = (unsigned long)&q->slsb.val[0];
  175. /* fill in sl */
  176. for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
  177. q->sl->element[j].sbal = (unsigned long)q->sbal[j];
  178. }
  179. static void setup_queues(struct qdio_irq *irq_ptr,
  180. struct qdio_initialize *qdio_init)
  181. {
  182. struct qdio_q *q;
  183. void **input_sbal_array = qdio_init->input_sbal_addr_array;
  184. void **output_sbal_array = qdio_init->output_sbal_addr_array;
  185. struct qdio_outbuf_state *output_sbal_state_array =
  186. qdio_init->output_sbal_state_array;
  187. int i;
  188. for_each_input_queue(irq_ptr, q, i) {
  189. DBF_EVENT("inq:%1d", i);
  190. setup_queues_misc(q, irq_ptr, qdio_init->input_handler, i);
  191. q->is_input_q = 1;
  192. q->u.in.queue_start_poll = qdio_init->queue_start_poll_array ?
  193. qdio_init->queue_start_poll_array[i] : NULL;
  194. setup_storage_lists(q, irq_ptr, input_sbal_array, i);
  195. input_sbal_array += QDIO_MAX_BUFFERS_PER_Q;
  196. if (is_thinint_irq(irq_ptr)) {
  197. tasklet_init(&q->tasklet, tiqdio_inbound_processing,
  198. (unsigned long) q);
  199. } else {
  200. tasklet_init(&q->tasklet, qdio_inbound_processing,
  201. (unsigned long) q);
  202. }
  203. }
  204. for_each_output_queue(irq_ptr, q, i) {
  205. DBF_EVENT("outq:%1d", i);
  206. setup_queues_misc(q, irq_ptr, qdio_init->output_handler, i);
  207. q->u.out.sbal_state = output_sbal_state_array;
  208. output_sbal_state_array += QDIO_MAX_BUFFERS_PER_Q;
  209. q->is_input_q = 0;
  210. q->u.out.scan_threshold = qdio_init->scan_threshold;
  211. setup_storage_lists(q, irq_ptr, output_sbal_array, i);
  212. output_sbal_array += QDIO_MAX_BUFFERS_PER_Q;
  213. tasklet_init(&q->tasklet, qdio_outbound_processing,
  214. (unsigned long) q);
  215. setup_timer(&q->u.out.timer, (void(*)(unsigned long))
  216. &qdio_outbound_timer, (unsigned long)q);
  217. }
  218. }
  219. static void process_ac_flags(struct qdio_irq *irq_ptr, unsigned char qdioac)
  220. {
  221. if (qdioac & AC1_SIGA_INPUT_NEEDED)
  222. irq_ptr->siga_flag.input = 1;
  223. if (qdioac & AC1_SIGA_OUTPUT_NEEDED)
  224. irq_ptr->siga_flag.output = 1;
  225. if (qdioac & AC1_SIGA_SYNC_NEEDED)
  226. irq_ptr->siga_flag.sync = 1;
  227. if (!(qdioac & AC1_AUTOMATIC_SYNC_ON_THININT))
  228. irq_ptr->siga_flag.sync_after_ai = 1;
  229. if (!(qdioac & AC1_AUTOMATIC_SYNC_ON_OUT_PCI))
  230. irq_ptr->siga_flag.sync_out_after_pci = 1;
  231. }
  232. static void check_and_setup_qebsm(struct qdio_irq *irq_ptr,
  233. unsigned char qdioac, unsigned long token)
  234. {
  235. if (!(irq_ptr->qib.rflags & QIB_RFLAGS_ENABLE_QEBSM))
  236. goto no_qebsm;
  237. if (!(qdioac & AC1_SC_QEBSM_AVAILABLE) ||
  238. (!(qdioac & AC1_SC_QEBSM_ENABLED)))
  239. goto no_qebsm;
  240. irq_ptr->sch_token = token;
  241. DBF_EVENT("V=V:1");
  242. DBF_EVENT("%8lx", irq_ptr->sch_token);
  243. return;
  244. no_qebsm:
  245. irq_ptr->sch_token = 0;
  246. irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM;
  247. DBF_EVENT("noV=V");
  248. }
  249. /*
  250. * If there is a qdio_irq we use the chsc_page and store the information
  251. * in the qdio_irq, otherwise we copy it to the specified structure.
  252. */
  253. int qdio_setup_get_ssqd(struct qdio_irq *irq_ptr,
  254. struct subchannel_id *schid,
  255. struct qdio_ssqd_desc *data)
  256. {
  257. struct chsc_ssqd_area *ssqd;
  258. int rc;
  259. DBF_EVENT("getssqd:%4x", schid->sch_no);
  260. if (!irq_ptr) {
  261. ssqd = (struct chsc_ssqd_area *)__get_free_page(GFP_KERNEL);
  262. if (!ssqd)
  263. return -ENOMEM;
  264. } else {
  265. ssqd = (struct chsc_ssqd_area *)irq_ptr->chsc_page;
  266. }
  267. rc = chsc_ssqd(*schid, ssqd);
  268. if (rc)
  269. goto out;
  270. if (!(ssqd->qdio_ssqd.flags & CHSC_FLAG_QDIO_CAPABILITY) ||
  271. !(ssqd->qdio_ssqd.flags & CHSC_FLAG_VALIDITY) ||
  272. (ssqd->qdio_ssqd.sch != schid->sch_no))
  273. rc = -EINVAL;
  274. if (!rc)
  275. memcpy(data, &ssqd->qdio_ssqd, sizeof(*data));
  276. out:
  277. if (!irq_ptr)
  278. free_page((unsigned long)ssqd);
  279. return rc;
  280. }
  281. void qdio_setup_ssqd_info(struct qdio_irq *irq_ptr)
  282. {
  283. unsigned char qdioac;
  284. int rc;
  285. rc = qdio_setup_get_ssqd(irq_ptr, &irq_ptr->schid, &irq_ptr->ssqd_desc);
  286. if (rc) {
  287. DBF_ERROR("%4x ssqd ERR", irq_ptr->schid.sch_no);
  288. DBF_ERROR("rc:%x", rc);
  289. /* all flags set, worst case */
  290. qdioac = AC1_SIGA_INPUT_NEEDED | AC1_SIGA_OUTPUT_NEEDED |
  291. AC1_SIGA_SYNC_NEEDED;
  292. } else
  293. qdioac = irq_ptr->ssqd_desc.qdioac1;
  294. check_and_setup_qebsm(irq_ptr, qdioac, irq_ptr->ssqd_desc.sch_token);
  295. process_ac_flags(irq_ptr, qdioac);
  296. DBF_EVENT("ac 1:%2x 2:%4x", qdioac, irq_ptr->ssqd_desc.qdioac2);
  297. DBF_EVENT("3:%4x qib:%4x", irq_ptr->ssqd_desc.qdioac3, irq_ptr->qib.ac);
  298. }
  299. void qdio_release_memory(struct qdio_irq *irq_ptr)
  300. {
  301. struct qdio_q *q;
  302. int i;
  303. /*
  304. * Must check queue array manually since irq_ptr->nr_input_queues /
  305. * irq_ptr->nr_input_queues may not yet be set.
  306. */
  307. for (i = 0; i < QDIO_MAX_QUEUES_PER_IRQ; i++) {
  308. q = irq_ptr->input_qs[i];
  309. if (q) {
  310. free_page((unsigned long) q->slib);
  311. kmem_cache_free(qdio_q_cache, q);
  312. }
  313. }
  314. for (i = 0; i < QDIO_MAX_QUEUES_PER_IRQ; i++) {
  315. q = irq_ptr->output_qs[i];
  316. if (q) {
  317. if (q->u.out.use_cq) {
  318. int n;
  319. for (n = 0; n < QDIO_MAX_BUFFERS_PER_Q; ++n) {
  320. struct qaob *aob = q->u.out.aobs[n];
  321. if (aob) {
  322. qdio_release_aob(aob);
  323. q->u.out.aobs[n] = NULL;
  324. }
  325. }
  326. qdio_disable_async_operation(&q->u.out);
  327. }
  328. free_page((unsigned long) q->slib);
  329. kmem_cache_free(qdio_q_cache, q);
  330. }
  331. }
  332. free_page((unsigned long) irq_ptr->qdr);
  333. free_page(irq_ptr->chsc_page);
  334. free_page((unsigned long) irq_ptr);
  335. }
  336. static void __qdio_allocate_fill_qdr(struct qdio_irq *irq_ptr,
  337. struct qdio_q **irq_ptr_qs,
  338. int i, int nr)
  339. {
  340. irq_ptr->qdr->qdf0[i + nr].sliba =
  341. (unsigned long)irq_ptr_qs[i]->slib;
  342. irq_ptr->qdr->qdf0[i + nr].sla =
  343. (unsigned long)irq_ptr_qs[i]->sl;
  344. irq_ptr->qdr->qdf0[i + nr].slsba =
  345. (unsigned long)&irq_ptr_qs[i]->slsb.val[0];
  346. irq_ptr->qdr->qdf0[i + nr].akey = PAGE_DEFAULT_KEY >> 4;
  347. irq_ptr->qdr->qdf0[i + nr].bkey = PAGE_DEFAULT_KEY >> 4;
  348. irq_ptr->qdr->qdf0[i + nr].ckey = PAGE_DEFAULT_KEY >> 4;
  349. irq_ptr->qdr->qdf0[i + nr].dkey = PAGE_DEFAULT_KEY >> 4;
  350. }
  351. static void setup_qdr(struct qdio_irq *irq_ptr,
  352. struct qdio_initialize *qdio_init)
  353. {
  354. int i;
  355. irq_ptr->qdr->qfmt = qdio_init->q_format;
  356. irq_ptr->qdr->ac = qdio_init->qdr_ac;
  357. irq_ptr->qdr->iqdcnt = qdio_init->no_input_qs;
  358. irq_ptr->qdr->oqdcnt = qdio_init->no_output_qs;
  359. irq_ptr->qdr->iqdsz = sizeof(struct qdesfmt0) / 4; /* size in words */
  360. irq_ptr->qdr->oqdsz = sizeof(struct qdesfmt0) / 4;
  361. irq_ptr->qdr->qiba = (unsigned long)&irq_ptr->qib;
  362. irq_ptr->qdr->qkey = PAGE_DEFAULT_KEY >> 4;
  363. for (i = 0; i < qdio_init->no_input_qs; i++)
  364. __qdio_allocate_fill_qdr(irq_ptr, irq_ptr->input_qs, i, 0);
  365. for (i = 0; i < qdio_init->no_output_qs; i++)
  366. __qdio_allocate_fill_qdr(irq_ptr, irq_ptr->output_qs, i,
  367. qdio_init->no_input_qs);
  368. }
  369. static void setup_qib(struct qdio_irq *irq_ptr,
  370. struct qdio_initialize *init_data)
  371. {
  372. if (qebsm_possible())
  373. irq_ptr->qib.rflags |= QIB_RFLAGS_ENABLE_QEBSM;
  374. irq_ptr->qib.rflags |= init_data->qib_rflags;
  375. irq_ptr->qib.qfmt = init_data->q_format;
  376. if (init_data->no_input_qs)
  377. irq_ptr->qib.isliba =
  378. (unsigned long)(irq_ptr->input_qs[0]->slib);
  379. if (init_data->no_output_qs)
  380. irq_ptr->qib.osliba =
  381. (unsigned long)(irq_ptr->output_qs[0]->slib);
  382. memcpy(irq_ptr->qib.ebcnam, init_data->adapter_name, 8);
  383. }
  384. int qdio_setup_irq(struct qdio_initialize *init_data)
  385. {
  386. struct ciw *ciw;
  387. struct qdio_irq *irq_ptr = init_data->cdev->private->qdio_data;
  388. memset(&irq_ptr->qib, 0, sizeof(irq_ptr->qib));
  389. memset(&irq_ptr->siga_flag, 0, sizeof(irq_ptr->siga_flag));
  390. memset(&irq_ptr->ccw, 0, sizeof(irq_ptr->ccw));
  391. memset(&irq_ptr->ssqd_desc, 0, sizeof(irq_ptr->ssqd_desc));
  392. memset(&irq_ptr->perf_stat, 0, sizeof(irq_ptr->perf_stat));
  393. irq_ptr->debugfs_dev = irq_ptr->debugfs_perf = NULL;
  394. irq_ptr->sch_token = irq_ptr->state = irq_ptr->perf_stat_enabled = 0;
  395. /* wipes qib.ac, required by ar7063 */
  396. memset(irq_ptr->qdr, 0, sizeof(struct qdr));
  397. irq_ptr->int_parm = init_data->int_parm;
  398. irq_ptr->nr_input_qs = init_data->no_input_qs;
  399. irq_ptr->nr_output_qs = init_data->no_output_qs;
  400. irq_ptr->cdev = init_data->cdev;
  401. ccw_device_get_schid(irq_ptr->cdev, &irq_ptr->schid);
  402. setup_queues(irq_ptr, init_data);
  403. setup_qib(irq_ptr, init_data);
  404. qdio_setup_thinint(irq_ptr);
  405. set_impl_params(irq_ptr, init_data->qib_param_field_format,
  406. init_data->qib_param_field,
  407. init_data->input_slib_elements,
  408. init_data->output_slib_elements);
  409. /* fill input and output descriptors */
  410. setup_qdr(irq_ptr, init_data);
  411. /* qdr, qib, sls, slsbs, slibs, sbales are filled now */
  412. /* get qdio commands */
  413. ciw = ccw_device_get_ciw(init_data->cdev, CIW_TYPE_EQUEUE);
  414. if (!ciw) {
  415. DBF_ERROR("%4x NO EQ", irq_ptr->schid.sch_no);
  416. return -EINVAL;
  417. }
  418. irq_ptr->equeue = *ciw;
  419. ciw = ccw_device_get_ciw(init_data->cdev, CIW_TYPE_AQUEUE);
  420. if (!ciw) {
  421. DBF_ERROR("%4x NO AQ", irq_ptr->schid.sch_no);
  422. return -EINVAL;
  423. }
  424. irq_ptr->aqueue = *ciw;
  425. /* set new interrupt handler */
  426. irq_ptr->orig_handler = init_data->cdev->handler;
  427. init_data->cdev->handler = qdio_int_handler;
  428. return 0;
  429. }
  430. void qdio_print_subchannel_info(struct qdio_irq *irq_ptr,
  431. struct ccw_device *cdev)
  432. {
  433. char s[80];
  434. snprintf(s, 80, "qdio: %s %s on SC %x using "
  435. "AI:%d QEBSM:%d PRI:%d TDD:%d SIGA:%s%s%s%s%s\n",
  436. dev_name(&cdev->dev),
  437. (irq_ptr->qib.qfmt == QDIO_QETH_QFMT) ? "OSA" :
  438. ((irq_ptr->qib.qfmt == QDIO_ZFCP_QFMT) ? "ZFCP" : "HS"),
  439. irq_ptr->schid.sch_no,
  440. is_thinint_irq(irq_ptr),
  441. (irq_ptr->sch_token) ? 1 : 0,
  442. (irq_ptr->qib.ac & QIB_AC_OUTBOUND_PCI_SUPPORTED) ? 1 : 0,
  443. css_general_characteristics.aif_tdd,
  444. (irq_ptr->siga_flag.input) ? "R" : " ",
  445. (irq_ptr->siga_flag.output) ? "W" : " ",
  446. (irq_ptr->siga_flag.sync) ? "S" : " ",
  447. (irq_ptr->siga_flag.sync_after_ai) ? "A" : " ",
  448. (irq_ptr->siga_flag.sync_out_after_pci) ? "P" : " ");
  449. printk(KERN_INFO "%s", s);
  450. }
  451. int qdio_enable_async_operation(struct qdio_output_q *outq)
  452. {
  453. outq->aobs = kzalloc(sizeof(struct qaob *) * QDIO_MAX_BUFFERS_PER_Q,
  454. GFP_ATOMIC);
  455. if (!outq->aobs) {
  456. outq->use_cq = 0;
  457. return -ENOMEM;
  458. }
  459. outq->use_cq = 1;
  460. return 0;
  461. }
  462. void qdio_disable_async_operation(struct qdio_output_q *q)
  463. {
  464. kfree(q->aobs);
  465. q->aobs = NULL;
  466. q->use_cq = 0;
  467. }
  468. int __init qdio_setup_init(void)
  469. {
  470. int rc;
  471. qdio_q_cache = kmem_cache_create("qdio_q", sizeof(struct qdio_q),
  472. 256, 0, NULL);
  473. if (!qdio_q_cache)
  474. return -ENOMEM;
  475. qdio_aob_cache = kmem_cache_create("qdio_aob",
  476. sizeof(struct qaob),
  477. sizeof(struct qaob),
  478. 0,
  479. NULL);
  480. if (!qdio_aob_cache) {
  481. rc = -ENOMEM;
  482. goto free_qdio_q_cache;
  483. }
  484. /* Check for OSA/FCP thin interrupts (bit 67). */
  485. DBF_EVENT("thinint:%1d",
  486. (css_general_characteristics.aif_osa) ? 1 : 0);
  487. /* Check for QEBSM support in general (bit 58). */
  488. DBF_EVENT("cssQEBSM:%1d", (qebsm_possible()) ? 1 : 0);
  489. rc = 0;
  490. out:
  491. return rc;
  492. free_qdio_q_cache:
  493. kmem_cache_destroy(qdio_q_cache);
  494. goto out;
  495. }
  496. void qdio_setup_exit(void)
  497. {
  498. kmem_cache_destroy(qdio_aob_cache);
  499. kmem_cache_destroy(qdio_q_cache);
  500. }