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