Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/s390/cio/qdio_main.c |
| 3 | * |
| 4 | * Linux for s390 qdio support, buffer handling, qdio API and module support. |
| 5 | * |
| 6 | * Copyright 2000,2008 IBM Corp. |
| 7 | * Author(s): Utz Bacher <utz.bacher@de.ibm.com> |
| 8 | * Jan Glauber <jang@linux.vnet.ibm.com> |
| 9 | * 2.6 cio integration by Cornelia Huck <cornelia.huck@de.ibm.com> |
| 10 | */ |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/timer.h> |
| 15 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/gfp.h> |
Jan Glauber | 30d77c3 | 2011-01-05 12:47:29 +0100 | [diff] [blame] | 17 | #include <linux/kernel_stat.h> |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 18 | #include <asm/atomic.h> |
| 19 | #include <asm/debug.h> |
| 20 | #include <asm/qdio.h> |
| 21 | |
| 22 | #include "cio.h" |
| 23 | #include "css.h" |
| 24 | #include "device.h" |
| 25 | #include "qdio.h" |
| 26 | #include "qdio_debug.h" |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 27 | |
| 28 | MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>,"\ |
| 29 | "Jan Glauber <jang@linux.vnet.ibm.com>"); |
| 30 | MODULE_DESCRIPTION("QDIO base support"); |
| 31 | MODULE_LICENSE("GPL"); |
| 32 | |
| 33 | static inline int do_siga_sync(struct subchannel_id schid, |
| 34 | unsigned int out_mask, unsigned int in_mask) |
| 35 | { |
| 36 | register unsigned long __fc asm ("0") = 2; |
| 37 | register struct subchannel_id __schid asm ("1") = schid; |
| 38 | register unsigned long out asm ("2") = out_mask; |
| 39 | register unsigned long in asm ("3") = in_mask; |
| 40 | int cc; |
| 41 | |
| 42 | asm volatile( |
| 43 | " siga 0\n" |
| 44 | " ipm %0\n" |
| 45 | " srl %0,28\n" |
| 46 | : "=d" (cc) |
| 47 | : "d" (__fc), "d" (__schid), "d" (out), "d" (in) : "cc"); |
| 48 | return cc; |
| 49 | } |
| 50 | |
| 51 | static inline int do_siga_input(struct subchannel_id schid, unsigned int mask) |
| 52 | { |
| 53 | register unsigned long __fc asm ("0") = 1; |
| 54 | register struct subchannel_id __schid asm ("1") = schid; |
| 55 | register unsigned long __mask asm ("2") = mask; |
| 56 | int cc; |
| 57 | |
| 58 | asm volatile( |
| 59 | " siga 0\n" |
| 60 | " ipm %0\n" |
| 61 | " srl %0,28\n" |
| 62 | : "=d" (cc) |
| 63 | : "d" (__fc), "d" (__schid), "d" (__mask) : "cc", "memory"); |
| 64 | return cc; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * do_siga_output - perform SIGA-w/wt function |
| 69 | * @schid: subchannel id or in case of QEBSM the subchannel token |
| 70 | * @mask: which output queues to process |
| 71 | * @bb: busy bit indicator, set only if SIGA-w/wt could not access a buffer |
| 72 | * @fc: function code to perform |
| 73 | * |
| 74 | * Returns cc or QDIO_ERROR_SIGA_ACCESS_EXCEPTION. |
| 75 | * Note: For IQDC unicast queues only the highest priority queue is processed. |
| 76 | */ |
| 77 | static inline int do_siga_output(unsigned long schid, unsigned long mask, |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 78 | unsigned int *bb, unsigned int fc) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 79 | { |
| 80 | register unsigned long __fc asm("0") = fc; |
| 81 | register unsigned long __schid asm("1") = schid; |
| 82 | register unsigned long __mask asm("2") = mask; |
| 83 | int cc = QDIO_ERROR_SIGA_ACCESS_EXCEPTION; |
| 84 | |
| 85 | asm volatile( |
| 86 | " siga 0\n" |
| 87 | "0: ipm %0\n" |
| 88 | " srl %0,28\n" |
| 89 | "1:\n" |
| 90 | EX_TABLE(0b, 1b) |
| 91 | : "+d" (cc), "+d" (__fc), "+d" (__schid), "+d" (__mask) |
| 92 | : : "cc", "memory"); |
| 93 | *bb = ((unsigned int) __fc) >> 31; |
| 94 | return cc; |
| 95 | } |
| 96 | |
| 97 | static inline int qdio_check_ccq(struct qdio_q *q, unsigned int ccq) |
| 98 | { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 99 | /* all done or next buffer state different */ |
| 100 | if (ccq == 0 || ccq == 32) |
| 101 | return 0; |
| 102 | /* not all buffers processed */ |
| 103 | if (ccq == 96 || ccq == 97) |
| 104 | return 1; |
| 105 | /* notify devices immediately */ |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 106 | DBF_ERROR("%4x ccq:%3d", SCH_NO(q), ccq); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 107 | return -EIO; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * qdio_do_eqbs - extract buffer states for QEBSM |
| 112 | * @q: queue to manipulate |
| 113 | * @state: state of the extracted buffers |
| 114 | * @start: buffer number to start at |
| 115 | * @count: count of buffers to examine |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 116 | * @auto_ack: automatically acknowledge buffers |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 117 | * |
Coly Li | 73ac36e | 2009-01-07 18:09:16 -0800 | [diff] [blame] | 118 | * Returns the number of successfully extracted equal buffer states. |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 119 | * Stops processing if a state is different from the last buffers state. |
| 120 | */ |
| 121 | static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state, |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 122 | int start, int count, int auto_ack) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 123 | { |
| 124 | unsigned int ccq = 0; |
| 125 | int tmp_count = count, tmp_start = start; |
| 126 | int nr = q->nr; |
| 127 | int rc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 128 | |
| 129 | BUG_ON(!q->irq_ptr->sch_token); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 130 | qperf_inc(q, eqbs); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 131 | |
| 132 | if (!q->is_input_q) |
| 133 | nr += q->irq_ptr->nr_input_qs; |
| 134 | again: |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 135 | ccq = do_eqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count, |
| 136 | auto_ack); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 137 | rc = qdio_check_ccq(q, ccq); |
| 138 | |
| 139 | /* At least one buffer was processed, return and extract the remaining |
| 140 | * buffers later. |
| 141 | */ |
Jan Glauber | 23589d0 | 2008-12-25 13:38:44 +0100 | [diff] [blame] | 142 | if ((ccq == 96) && (count != tmp_count)) { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 143 | qperf_inc(q, eqbs_partial); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 144 | return (count - tmp_count); |
Jan Glauber | 23589d0 | 2008-12-25 13:38:44 +0100 | [diff] [blame] | 145 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 146 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 147 | if (rc == 1) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 148 | DBF_DEV_EVENT(DBF_WARN, q->irq_ptr, "EQBS again:%2d", ccq); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 149 | goto again; |
| 150 | } |
| 151 | |
| 152 | if (rc < 0) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 153 | DBF_ERROR("%4x EQBS ERROR", SCH_NO(q)); |
| 154 | DBF_ERROR("%3d%3d%2d", count, tmp_count, nr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 155 | q->handler(q->irq_ptr->cdev, |
| 156 | QDIO_ERROR_ACTIVATE_CHECK_CONDITION, |
| 157 | 0, -1, -1, q->irq_ptr->int_parm); |
| 158 | return 0; |
| 159 | } |
| 160 | return count - tmp_count; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * qdio_do_sqbs - set buffer states for QEBSM |
| 165 | * @q: queue to manipulate |
| 166 | * @state: new state of the buffers |
| 167 | * @start: first buffer number to change |
| 168 | * @count: how many buffers to change |
| 169 | * |
| 170 | * Returns the number of successfully changed buffers. |
| 171 | * Does retrying until the specified count of buffer states is set or an |
| 172 | * error occurs. |
| 173 | */ |
| 174 | static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start, |
| 175 | int count) |
| 176 | { |
| 177 | unsigned int ccq = 0; |
| 178 | int tmp_count = count, tmp_start = start; |
| 179 | int nr = q->nr; |
| 180 | int rc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 181 | |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 182 | if (!count) |
| 183 | return 0; |
| 184 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 185 | BUG_ON(!q->irq_ptr->sch_token); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 186 | qperf_inc(q, sqbs); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 187 | |
| 188 | if (!q->is_input_q) |
| 189 | nr += q->irq_ptr->nr_input_qs; |
| 190 | again: |
| 191 | ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count); |
| 192 | rc = qdio_check_ccq(q, ccq); |
| 193 | if (rc == 1) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 194 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "SQBS again:%2d", ccq); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 195 | qperf_inc(q, sqbs_partial); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 196 | goto again; |
| 197 | } |
| 198 | if (rc < 0) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 199 | DBF_ERROR("%4x SQBS ERROR", SCH_NO(q)); |
| 200 | DBF_ERROR("%3d%3d%2d", count, tmp_count, nr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 201 | q->handler(q->irq_ptr->cdev, |
| 202 | QDIO_ERROR_ACTIVATE_CHECK_CONDITION, |
| 203 | 0, -1, -1, q->irq_ptr->int_parm); |
| 204 | return 0; |
| 205 | } |
| 206 | WARN_ON(tmp_count); |
| 207 | return count - tmp_count; |
| 208 | } |
| 209 | |
| 210 | /* returns number of examined buffers and their common state in *state */ |
| 211 | static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr, |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 212 | unsigned char *state, unsigned int count, |
| 213 | int auto_ack) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 214 | { |
| 215 | unsigned char __state = 0; |
| 216 | int i; |
| 217 | |
| 218 | BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK); |
| 219 | BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q); |
| 220 | |
| 221 | if (is_qebsm(q)) |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 222 | return qdio_do_eqbs(q, state, bufnr, count, auto_ack); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 223 | |
| 224 | for (i = 0; i < count; i++) { |
| 225 | if (!__state) |
| 226 | __state = q->slsb.val[bufnr]; |
| 227 | else if (q->slsb.val[bufnr] != __state) |
| 228 | break; |
| 229 | bufnr = next_buf(bufnr); |
| 230 | } |
| 231 | *state = __state; |
| 232 | return i; |
| 233 | } |
| 234 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 235 | static inline int get_buf_state(struct qdio_q *q, unsigned int bufnr, |
| 236 | unsigned char *state, int auto_ack) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 237 | { |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 238 | return get_buf_states(q, bufnr, state, 1, auto_ack); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* wrap-around safe setting of slsb states, returns number of changed buffers */ |
| 242 | static inline int set_buf_states(struct qdio_q *q, int bufnr, |
| 243 | unsigned char state, int count) |
| 244 | { |
| 245 | int i; |
| 246 | |
| 247 | BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK); |
| 248 | BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q); |
| 249 | |
| 250 | if (is_qebsm(q)) |
| 251 | return qdio_do_sqbs(q, state, bufnr, count); |
| 252 | |
| 253 | for (i = 0; i < count; i++) { |
| 254 | xchg(&q->slsb.val[bufnr], state); |
| 255 | bufnr = next_buf(bufnr); |
| 256 | } |
| 257 | return count; |
| 258 | } |
| 259 | |
| 260 | static inline int set_buf_state(struct qdio_q *q, int bufnr, |
| 261 | unsigned char state) |
| 262 | { |
| 263 | return set_buf_states(q, bufnr, state, 1); |
| 264 | } |
| 265 | |
| 266 | /* set slsb states to initial state */ |
| 267 | void qdio_init_buf_states(struct qdio_irq *irq_ptr) |
| 268 | { |
| 269 | struct qdio_q *q; |
| 270 | int i; |
| 271 | |
| 272 | for_each_input_queue(irq_ptr, q, i) |
| 273 | set_buf_states(q, 0, SLSB_P_INPUT_NOT_INIT, |
| 274 | QDIO_MAX_BUFFERS_PER_Q); |
| 275 | for_each_output_queue(irq_ptr, q, i) |
| 276 | set_buf_states(q, 0, SLSB_P_OUTPUT_NOT_INIT, |
| 277 | QDIO_MAX_BUFFERS_PER_Q); |
| 278 | } |
| 279 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 280 | static inline int qdio_siga_sync(struct qdio_q *q, unsigned int output, |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 281 | unsigned int input) |
| 282 | { |
| 283 | int cc; |
| 284 | |
| 285 | if (!need_siga_sync(q)) |
| 286 | return 0; |
| 287 | |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 288 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-s:%1d", q->nr); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 289 | qperf_inc(q, siga_sync); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 290 | |
| 291 | cc = do_siga_sync(q->irq_ptr->schid, output, input); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 292 | if (cc) |
| 293 | DBF_ERROR("%4x SIGA-S:%2d", SCH_NO(q), cc); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 294 | return cc; |
| 295 | } |
| 296 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 297 | static inline int qdio_siga_sync_q(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 298 | { |
| 299 | if (q->is_input_q) |
| 300 | return qdio_siga_sync(q, 0, q->mask); |
| 301 | else |
| 302 | return qdio_siga_sync(q, q->mask, 0); |
| 303 | } |
| 304 | |
| 305 | static inline int qdio_siga_sync_out(struct qdio_q *q) |
| 306 | { |
| 307 | return qdio_siga_sync(q, ~0U, 0); |
| 308 | } |
| 309 | |
| 310 | static inline int qdio_siga_sync_all(struct qdio_q *q) |
| 311 | { |
| 312 | return qdio_siga_sync(q, ~0U, ~0U); |
| 313 | } |
| 314 | |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 315 | static int qdio_siga_output(struct qdio_q *q, unsigned int *busy_bit) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 316 | { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 317 | unsigned long schid; |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 318 | unsigned int fc = 0; |
| 319 | u64 start_time = 0; |
| 320 | int cc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 321 | |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 322 | if (q->u.out.use_enh_siga) |
Klaus-Dieter Wacker | 7a0f475 | 2008-10-10 21:33:18 +0200 | [diff] [blame] | 323 | fc = 3; |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 324 | |
| 325 | if (is_qebsm(q)) { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 326 | schid = q->irq_ptr->sch_token; |
| 327 | fc |= 0x80; |
| 328 | } |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 329 | else |
| 330 | schid = *((u32 *)&q->irq_ptr->schid); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 331 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 332 | again: |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 333 | cc = do_siga_output(schid, q->mask, busy_bit, fc); |
Jan Glauber | 58eb27c | 2008-08-21 19:46:34 +0200 | [diff] [blame] | 334 | |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 335 | /* hipersocket busy condition */ |
| 336 | if (*busy_bit) { |
| 337 | WARN_ON(queue_type(q) != QDIO_IQDIO_QFMT || cc != 2); |
| 338 | |
| 339 | if (!start_time) { |
Jan Glauber | 3a601bf | 2010-05-17 10:00:17 +0200 | [diff] [blame] | 340 | start_time = get_clock(); |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 341 | goto again; |
| 342 | } |
Jan Glauber | 3a601bf | 2010-05-17 10:00:17 +0200 | [diff] [blame] | 343 | if ((get_clock() - start_time) < QDIO_BUSY_BIT_PATIENCE) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 344 | goto again; |
| 345 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 346 | return cc; |
| 347 | } |
| 348 | |
| 349 | static inline int qdio_siga_input(struct qdio_q *q) |
| 350 | { |
| 351 | int cc; |
| 352 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 353 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-r:%1d", q->nr); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 354 | qperf_inc(q, siga_read); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 355 | |
| 356 | cc = do_siga_input(q->irq_ptr->schid, q->mask); |
| 357 | if (cc) |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 358 | DBF_ERROR("%4x SIGA-R:%2d", SCH_NO(q), cc); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 359 | return cc; |
| 360 | } |
| 361 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 362 | static inline void qdio_sync_after_thinint(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 363 | { |
| 364 | if (pci_out_supported(q)) { |
| 365 | if (need_siga_sync_thinint(q)) |
| 366 | qdio_siga_sync_all(q); |
| 367 | else if (need_siga_sync_out_thinint(q)) |
| 368 | qdio_siga_sync_out(q); |
| 369 | } else |
| 370 | qdio_siga_sync_q(q); |
| 371 | } |
| 372 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 373 | int debug_get_buf_state(struct qdio_q *q, unsigned int bufnr, |
| 374 | unsigned char *state) |
| 375 | { |
| 376 | qdio_siga_sync_q(q); |
| 377 | return get_buf_states(q, bufnr, state, 1, 0); |
| 378 | } |
| 379 | |
| 380 | static inline void qdio_stop_polling(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 381 | { |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 382 | if (!q->u.in.polling) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 383 | return; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 384 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 385 | q->u.in.polling = 0; |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 386 | qperf_inc(q, stop_polling); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 387 | |
| 388 | /* show the card that we are not polling anymore */ |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 389 | if (is_qebsm(q)) { |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 390 | set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 391 | q->u.in.ack_count); |
| 392 | q->u.in.ack_count = 0; |
| 393 | } else |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 394 | set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 395 | } |
| 396 | |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 397 | static inline void account_sbals(struct qdio_q *q, int count) |
| 398 | { |
| 399 | int pos = 0; |
| 400 | |
| 401 | q->q_stats.nr_sbal_total += count; |
| 402 | if (count == QDIO_MAX_BUFFERS_MASK) { |
| 403 | q->q_stats.nr_sbals[7]++; |
| 404 | return; |
| 405 | } |
| 406 | while (count >>= 1) |
| 407 | pos++; |
| 408 | q->q_stats.nr_sbals[pos]++; |
| 409 | } |
| 410 | |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 411 | static void announce_buffer_error(struct qdio_q *q, int count) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 412 | { |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 413 | q->qdio_error |= QDIO_ERROR_SLSB_STATE; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 414 | |
| 415 | /* special handling for no target buffer empty */ |
| 416 | if ((!q->is_input_q && |
| 417 | (q->sbal[q->first_to_check]->element[15].flags & 0xff) == 0x10)) { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 418 | qperf_inc(q, target_full); |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 419 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "OUTFULL FTC:%02x", |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 420 | q->first_to_check); |
| 421 | return; |
| 422 | } |
| 423 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 424 | DBF_ERROR("%4x BUF ERROR", SCH_NO(q)); |
| 425 | DBF_ERROR((q->is_input_q) ? "IN:%2d" : "OUT:%2d", q->nr); |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 426 | DBF_ERROR("FTC:%3d C:%3d", q->first_to_check, count); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 427 | DBF_ERROR("F14:%2x F15:%2x", |
| 428 | q->sbal[q->first_to_check]->element[14].flags & 0xff, |
| 429 | q->sbal[q->first_to_check]->element[15].flags & 0xff); |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 430 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 431 | |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 432 | static inline void inbound_primed(struct qdio_q *q, int count) |
| 433 | { |
| 434 | int new; |
| 435 | |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 436 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in prim: %02x", count); |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 437 | |
| 438 | /* for QEBSM the ACK was already set by EQBS */ |
| 439 | if (is_qebsm(q)) { |
| 440 | if (!q->u.in.polling) { |
| 441 | q->u.in.polling = 1; |
| 442 | q->u.in.ack_count = count; |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 443 | q->u.in.ack_start = q->first_to_check; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 444 | return; |
| 445 | } |
| 446 | |
| 447 | /* delete the previous ACK's */ |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 448 | set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 449 | q->u.in.ack_count); |
| 450 | q->u.in.ack_count = count; |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 451 | q->u.in.ack_start = q->first_to_check; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 452 | return; |
| 453 | } |
| 454 | |
| 455 | /* |
| 456 | * ACK the newest buffer. The ACK will be removed in qdio_stop_polling |
| 457 | * or by the next inbound run. |
| 458 | */ |
| 459 | new = add_buf(q->first_to_check, count - 1); |
| 460 | if (q->u.in.polling) { |
| 461 | /* reset the previous ACK but first set the new one */ |
| 462 | set_buf_state(q, new, SLSB_P_INPUT_ACK); |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 463 | set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT); |
Jan Glauber | 3fdf1e1 | 2009-03-26 15:24:28 +0100 | [diff] [blame] | 464 | } else { |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 465 | q->u.in.polling = 1; |
Jan Glauber | 3fdf1e1 | 2009-03-26 15:24:28 +0100 | [diff] [blame] | 466 | set_buf_state(q, new, SLSB_P_INPUT_ACK); |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 467 | } |
| 468 | |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 469 | q->u.in.ack_start = new; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 470 | count--; |
| 471 | if (!count) |
| 472 | return; |
Jan Glauber | 6541f7b | 2009-09-22 22:58:40 +0200 | [diff] [blame] | 473 | /* need to change ALL buffers to get more interrupts */ |
| 474 | set_buf_states(q, q->first_to_check, SLSB_P_INPUT_NOT_INIT, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | static int get_inbound_buffer_frontier(struct qdio_q *q) |
| 478 | { |
| 479 | int count, stop; |
| 480 | unsigned char state; |
| 481 | |
| 482 | /* |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 483 | * Don't check 128 buffers, as otherwise qdio_inbound_q_moved |
| 484 | * would return 0. |
| 485 | */ |
| 486 | count = min(atomic_read(&q->nr_buf_used), QDIO_MAX_BUFFERS_MASK); |
| 487 | stop = add_buf(q->first_to_check, count); |
| 488 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 489 | if (q->first_to_check == stop) |
| 490 | goto out; |
| 491 | |
Jan Glauber | 36e3e72 | 2009-06-22 12:08:12 +0200 | [diff] [blame] | 492 | /* |
| 493 | * No siga sync here, as a PCI or we after a thin interrupt |
| 494 | * already sync'ed the queues. |
| 495 | */ |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 496 | count = get_buf_states(q, q->first_to_check, &state, count, 1); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 497 | if (!count) |
| 498 | goto out; |
| 499 | |
| 500 | switch (state) { |
| 501 | case SLSB_P_INPUT_PRIMED: |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 502 | inbound_primed(q, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 503 | q->first_to_check = add_buf(q->first_to_check, count); |
Jan Glauber | 8bcd9b0 | 2009-12-18 17:43:26 +0100 | [diff] [blame] | 504 | if (atomic_sub(count, &q->nr_buf_used) == 0) |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 505 | qperf_inc(q, inbound_queue_full); |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 506 | if (q->irq_ptr->perf_stat_enabled) |
| 507 | account_sbals(q, count); |
Jan Glauber | 36e3e72 | 2009-06-22 12:08:12 +0200 | [diff] [blame] | 508 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 509 | case SLSB_P_INPUT_ERROR: |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 510 | announce_buffer_error(q, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 511 | /* process the buffer, the upper layer will take care of it */ |
| 512 | q->first_to_check = add_buf(q->first_to_check, count); |
| 513 | atomic_sub(count, &q->nr_buf_used); |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 514 | if (q->irq_ptr->perf_stat_enabled) |
| 515 | account_sbals_error(q, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 516 | break; |
| 517 | case SLSB_CU_INPUT_EMPTY: |
| 518 | case SLSB_P_INPUT_NOT_INIT: |
| 519 | case SLSB_P_INPUT_ACK: |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 520 | if (q->irq_ptr->perf_stat_enabled) |
| 521 | q->q_stats.nr_sbal_nop++; |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 522 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in nop"); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 523 | break; |
| 524 | default: |
| 525 | BUG(); |
| 526 | } |
| 527 | out: |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 528 | return q->first_to_check; |
| 529 | } |
| 530 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 531 | static int qdio_inbound_q_moved(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 532 | { |
| 533 | int bufnr; |
| 534 | |
| 535 | bufnr = get_inbound_buffer_frontier(q); |
| 536 | |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 537 | if ((bufnr != q->last_move) || q->qdio_error) { |
| 538 | q->last_move = bufnr; |
Martin Schwidefsky | 27d7160 | 2010-02-26 22:37:38 +0100 | [diff] [blame] | 539 | if (!is_thinint_irq(q->irq_ptr) && MACHINE_IS_LPAR) |
Jan Glauber | 3a601bf | 2010-05-17 10:00:17 +0200 | [diff] [blame] | 540 | q->u.in.timestamp = get_clock(); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 541 | return 1; |
| 542 | } else |
| 543 | return 0; |
| 544 | } |
| 545 | |
Jan Glauber | 9a2c160 | 2009-06-22 12:08:11 +0200 | [diff] [blame] | 546 | static inline int qdio_inbound_q_done(struct qdio_q *q) |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 547 | { |
| 548 | unsigned char state = 0; |
| 549 | |
| 550 | if (!atomic_read(&q->nr_buf_used)) |
| 551 | return 1; |
| 552 | |
| 553 | qdio_siga_sync_q(q); |
| 554 | get_buf_state(q, q->first_to_check, &state, 0); |
| 555 | |
Ursula Braun | 4c52228 | 2010-02-09 09:46:07 +0100 | [diff] [blame] | 556 | if (state == SLSB_P_INPUT_PRIMED || state == SLSB_P_INPUT_ERROR) |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 557 | /* more work coming */ |
| 558 | return 0; |
Jan Glauber | 9a2c160 | 2009-06-22 12:08:11 +0200 | [diff] [blame] | 559 | |
| 560 | if (is_thinint_irq(q->irq_ptr)) |
| 561 | return 1; |
| 562 | |
| 563 | /* don't poll under z/VM */ |
| 564 | if (MACHINE_IS_VM) |
| 565 | return 1; |
| 566 | |
| 567 | /* |
| 568 | * At this point we know, that inbound first_to_check |
| 569 | * has (probably) not moved (see qdio_inbound_processing). |
| 570 | */ |
Jan Glauber | 3a601bf | 2010-05-17 10:00:17 +0200 | [diff] [blame] | 571 | if (get_clock() > q->u.in.timestamp + QDIO_INPUT_THRESHOLD) { |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 572 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "in done:%02x", |
Jan Glauber | 9a2c160 | 2009-06-22 12:08:11 +0200 | [diff] [blame] | 573 | q->first_to_check); |
| 574 | return 1; |
| 575 | } else |
| 576 | return 0; |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | static void qdio_kick_handler(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 580 | { |
Jan Glauber | 9c8a08d | 2009-03-26 15:24:32 +0100 | [diff] [blame] | 581 | int start = q->first_to_kick; |
| 582 | int end = q->first_to_check; |
| 583 | int count; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 584 | |
| 585 | if (unlikely(q->irq_ptr->state != QDIO_IRQ_STATE_ACTIVE)) |
| 586 | return; |
| 587 | |
Jan Glauber | 9c8a08d | 2009-03-26 15:24:32 +0100 | [diff] [blame] | 588 | count = sub_buf(end, start); |
| 589 | |
| 590 | if (q->is_input_q) { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 591 | qperf_inc(q, inbound_handler); |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 592 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "kih s:%02x c:%02x", start, count); |
Ursula Braun | bd6e8a1 | 2010-03-08 12:25:18 +0100 | [diff] [blame] | 593 | } else { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 594 | qperf_inc(q, outbound_handler); |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 595 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "koh: s:%02x c:%02x", |
| 596 | start, count); |
Ursula Braun | bd6e8a1 | 2010-03-08 12:25:18 +0100 | [diff] [blame] | 597 | } |
Jan Glauber | 9c8a08d | 2009-03-26 15:24:32 +0100 | [diff] [blame] | 598 | |
| 599 | q->handler(q->irq_ptr->cdev, q->qdio_error, q->nr, start, count, |
| 600 | q->irq_ptr->int_parm); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 601 | |
| 602 | /* for the next time */ |
Jan Glauber | 9c8a08d | 2009-03-26 15:24:32 +0100 | [diff] [blame] | 603 | q->first_to_kick = end; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 604 | q->qdio_error = 0; |
| 605 | } |
| 606 | |
| 607 | static void __qdio_inbound_processing(struct qdio_q *q) |
| 608 | { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 609 | qperf_inc(q, tasklet_inbound); |
Jan Glauber | f3eb20f | 2010-05-17 10:00:15 +0200 | [diff] [blame] | 610 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 611 | if (!qdio_inbound_q_moved(q)) |
| 612 | return; |
| 613 | |
Jan Glauber | 9c8a08d | 2009-03-26 15:24:32 +0100 | [diff] [blame] | 614 | qdio_kick_handler(q); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 615 | |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 616 | if (!qdio_inbound_q_done(q)) { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 617 | /* means poll time is not yet over */ |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 618 | qperf_inc(q, tasklet_inbound_resched); |
Jan Glauber | f3eb20f | 2010-05-17 10:00:15 +0200 | [diff] [blame] | 619 | if (likely(q->irq_ptr->state != QDIO_IRQ_STATE_STOPPED)) { |
| 620 | tasklet_schedule(&q->tasklet); |
| 621 | return; |
| 622 | } |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 623 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 624 | |
| 625 | qdio_stop_polling(q); |
| 626 | /* |
| 627 | * We need to check again to not lose initiative after |
| 628 | * resetting the ACK state. |
| 629 | */ |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 630 | if (!qdio_inbound_q_done(q)) { |
| 631 | qperf_inc(q, tasklet_inbound_resched2); |
Jan Glauber | f3eb20f | 2010-05-17 10:00:15 +0200 | [diff] [blame] | 632 | if (likely(q->irq_ptr->state != QDIO_IRQ_STATE_STOPPED)) |
| 633 | tasklet_schedule(&q->tasklet); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 634 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 635 | } |
| 636 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 637 | void qdio_inbound_processing(unsigned long data) |
| 638 | { |
| 639 | struct qdio_q *q = (struct qdio_q *)data; |
| 640 | __qdio_inbound_processing(q); |
| 641 | } |
| 642 | |
| 643 | static int get_outbound_buffer_frontier(struct qdio_q *q) |
| 644 | { |
| 645 | int count, stop; |
| 646 | unsigned char state; |
| 647 | |
| 648 | if (((queue_type(q) != QDIO_IQDIO_QFMT) && !pci_out_supported(q)) || |
| 649 | (queue_type(q) == QDIO_IQDIO_QFMT && multicast_outbound(q))) |
| 650 | qdio_siga_sync_q(q); |
| 651 | |
| 652 | /* |
| 653 | * Don't check 128 buffers, as otherwise qdio_inbound_q_moved |
| 654 | * would return 0. |
| 655 | */ |
| 656 | count = min(atomic_read(&q->nr_buf_used), QDIO_MAX_BUFFERS_MASK); |
| 657 | stop = add_buf(q->first_to_check, count); |
| 658 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 659 | if (q->first_to_check == stop) |
| 660 | return q->first_to_check; |
| 661 | |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 662 | count = get_buf_states(q, q->first_to_check, &state, count, 0); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 663 | if (!count) |
| 664 | return q->first_to_check; |
| 665 | |
| 666 | switch (state) { |
| 667 | case SLSB_P_OUTPUT_EMPTY: |
| 668 | /* the adapter got it */ |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 669 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "out empty:%1d %02x", q->nr, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 670 | |
| 671 | atomic_sub(count, &q->nr_buf_used); |
| 672 | q->first_to_check = add_buf(q->first_to_check, count); |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 673 | if (q->irq_ptr->perf_stat_enabled) |
| 674 | account_sbals(q, count); |
Jan Glauber | 36e3e72 | 2009-06-22 12:08:12 +0200 | [diff] [blame] | 675 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 676 | case SLSB_P_OUTPUT_ERROR: |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 677 | announce_buffer_error(q, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 678 | /* process the buffer, the upper layer will take care of it */ |
| 679 | q->first_to_check = add_buf(q->first_to_check, count); |
| 680 | atomic_sub(count, &q->nr_buf_used); |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 681 | if (q->irq_ptr->perf_stat_enabled) |
| 682 | account_sbals_error(q, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 683 | break; |
| 684 | case SLSB_CU_OUTPUT_PRIMED: |
| 685 | /* the adapter has not fetched the output yet */ |
Jan Glauber | d307297 | 2010-02-26 22:37:36 +0100 | [diff] [blame] | 686 | if (q->irq_ptr->perf_stat_enabled) |
| 687 | q->q_stats.nr_sbal_nop++; |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 688 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "out primed:%1d", q->nr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 689 | break; |
| 690 | case SLSB_P_OUTPUT_NOT_INIT: |
| 691 | case SLSB_P_OUTPUT_HALTED: |
| 692 | break; |
| 693 | default: |
| 694 | BUG(); |
| 695 | } |
| 696 | return q->first_to_check; |
| 697 | } |
| 698 | |
| 699 | /* all buffers processed? */ |
| 700 | static inline int qdio_outbound_q_done(struct qdio_q *q) |
| 701 | { |
| 702 | return atomic_read(&q->nr_buf_used) == 0; |
| 703 | } |
| 704 | |
| 705 | static inline int qdio_outbound_q_moved(struct qdio_q *q) |
| 706 | { |
| 707 | int bufnr; |
| 708 | |
| 709 | bufnr = get_outbound_buffer_frontier(q); |
| 710 | |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 711 | if ((bufnr != q->last_move) || q->qdio_error) { |
| 712 | q->last_move = bufnr; |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 713 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "out moved:%1d", q->nr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 714 | return 1; |
| 715 | } else |
| 716 | return 0; |
| 717 | } |
| 718 | |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 719 | static int qdio_kick_outbound_q(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 720 | { |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 721 | unsigned int busy_bit; |
| 722 | int cc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 723 | |
| 724 | if (!need_siga_out(q)) |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 725 | return 0; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 726 | |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 727 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-w:%1d", q->nr); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 728 | qperf_inc(q, siga_write); |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 729 | |
| 730 | cc = qdio_siga_output(q, &busy_bit); |
| 731 | switch (cc) { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 732 | case 0: |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 733 | break; |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 734 | case 2: |
| 735 | if (busy_bit) { |
| 736 | DBF_ERROR("%4x cc2 REP:%1d", SCH_NO(q), q->nr); |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 737 | cc |= QDIO_ERROR_SIGA_BUSY; |
| 738 | } else |
| 739 | DBF_DEV_EVENT(DBF_INFO, q->irq_ptr, "siga-w cc2:%1d", q->nr); |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 740 | break; |
| 741 | case 1: |
| 742 | case 3: |
| 743 | DBF_ERROR("%4x SIGA-W:%1d", SCH_NO(q), cc); |
Jan Glauber | 7a0b4cb | 2008-12-25 13:38:48 +0100 | [diff] [blame] | 744 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 745 | } |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 746 | return cc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 747 | } |
| 748 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 749 | static void __qdio_outbound_processing(struct qdio_q *q) |
| 750 | { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 751 | qperf_inc(q, tasklet_outbound); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 752 | BUG_ON(atomic_read(&q->nr_buf_used) < 0); |
| 753 | |
| 754 | if (qdio_outbound_q_moved(q)) |
Jan Glauber | 9c8a08d | 2009-03-26 15:24:32 +0100 | [diff] [blame] | 755 | qdio_kick_handler(q); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 756 | |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 757 | if (queue_type(q) == QDIO_ZFCP_QFMT) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 758 | if (!pci_out_supported(q) && !qdio_outbound_q_done(q)) |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 759 | goto sched; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 760 | |
| 761 | /* bail out for HiperSockets unicast queues */ |
| 762 | if (queue_type(q) == QDIO_IQDIO_QFMT && !multicast_outbound(q)) |
| 763 | return; |
| 764 | |
Ursula Braun | 4bcb3a3 | 2008-10-10 21:33:04 +0200 | [diff] [blame] | 765 | if ((queue_type(q) == QDIO_IQDIO_QFMT) && |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 766 | (atomic_read(&q->nr_buf_used)) > QDIO_IQDIO_POLL_LVL) |
| 767 | goto sched; |
Ursula Braun | 4bcb3a3 | 2008-10-10 21:33:04 +0200 | [diff] [blame] | 768 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 769 | if (q->u.out.pci_out_enabled) |
| 770 | return; |
| 771 | |
| 772 | /* |
| 773 | * Now we know that queue type is either qeth without pci enabled |
| 774 | * or HiperSockets multicast. Make sure buffer switch from PRIMED to |
| 775 | * EMPTY is noticed and outbound_handler is called after some time. |
| 776 | */ |
| 777 | if (qdio_outbound_q_done(q)) |
| 778 | del_timer(&q->u.out.timer); |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 779 | else |
| 780 | if (!timer_pending(&q->u.out.timer)) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 781 | mod_timer(&q->u.out.timer, jiffies + 10 * HZ); |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 782 | return; |
| 783 | |
| 784 | sched: |
| 785 | if (unlikely(q->irq_ptr->state == QDIO_IRQ_STATE_STOPPED)) |
| 786 | return; |
| 787 | tasklet_schedule(&q->tasklet); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | /* outbound tasklet */ |
| 791 | void qdio_outbound_processing(unsigned long data) |
| 792 | { |
| 793 | struct qdio_q *q = (struct qdio_q *)data; |
| 794 | __qdio_outbound_processing(q); |
| 795 | } |
| 796 | |
| 797 | void qdio_outbound_timer(unsigned long data) |
| 798 | { |
| 799 | struct qdio_q *q = (struct qdio_q *)data; |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 800 | |
| 801 | if (unlikely(q->irq_ptr->state == QDIO_IRQ_STATE_STOPPED)) |
| 802 | return; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 803 | tasklet_schedule(&q->tasklet); |
| 804 | } |
| 805 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 806 | static inline void qdio_check_outbound_after_thinint(struct qdio_q *q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 807 | { |
| 808 | struct qdio_q *out; |
| 809 | int i; |
| 810 | |
| 811 | if (!pci_out_supported(q)) |
| 812 | return; |
| 813 | |
| 814 | for_each_output_queue(q->irq_ptr, out, i) |
| 815 | if (!qdio_outbound_q_done(out)) |
| 816 | tasklet_schedule(&out->tasklet); |
| 817 | } |
| 818 | |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 819 | static void __tiqdio_inbound_processing(struct qdio_q *q) |
| 820 | { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 821 | qperf_inc(q, tasklet_inbound); |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 822 | qdio_sync_after_thinint(q); |
| 823 | |
| 824 | /* |
| 825 | * The interrupt could be caused by a PCI request. Check the |
| 826 | * PCI capable outbound queues. |
| 827 | */ |
| 828 | qdio_check_outbound_after_thinint(q); |
| 829 | |
| 830 | if (!qdio_inbound_q_moved(q)) |
| 831 | return; |
| 832 | |
| 833 | qdio_kick_handler(q); |
| 834 | |
Jan Glauber | 9a2c160 | 2009-06-22 12:08:11 +0200 | [diff] [blame] | 835 | if (!qdio_inbound_q_done(q)) { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 836 | qperf_inc(q, tasklet_inbound_resched); |
Jan Glauber | e2910bc | 2009-09-11 10:28:19 +0200 | [diff] [blame] | 837 | if (likely(q->irq_ptr->state != QDIO_IRQ_STATE_STOPPED)) { |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 838 | tasklet_schedule(&q->tasklet); |
Jan Glauber | e2910bc | 2009-09-11 10:28:19 +0200 | [diff] [blame] | 839 | return; |
| 840 | } |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | qdio_stop_polling(q); |
| 844 | /* |
| 845 | * We need to check again to not lose initiative after |
| 846 | * resetting the ACK state. |
| 847 | */ |
Jan Glauber | 9a2c160 | 2009-06-22 12:08:11 +0200 | [diff] [blame] | 848 | if (!qdio_inbound_q_done(q)) { |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 849 | qperf_inc(q, tasklet_inbound_resched2); |
Jan Glauber | 60b5df2 | 2009-06-22 12:08:10 +0200 | [diff] [blame] | 850 | if (likely(q->irq_ptr->state != QDIO_IRQ_STATE_STOPPED)) |
| 851 | tasklet_schedule(&q->tasklet); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | void tiqdio_inbound_processing(unsigned long data) |
| 856 | { |
| 857 | struct qdio_q *q = (struct qdio_q *)data; |
| 858 | __tiqdio_inbound_processing(q); |
| 859 | } |
| 860 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 861 | static inline void qdio_set_state(struct qdio_irq *irq_ptr, |
| 862 | enum qdio_irq_states state) |
| 863 | { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 864 | DBF_DEV_EVENT(DBF_INFO, irq_ptr, "newstate: %1d", state); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 865 | |
| 866 | irq_ptr->state = state; |
| 867 | mb(); |
| 868 | } |
| 869 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 870 | static void qdio_irq_check_sense(struct qdio_irq *irq_ptr, struct irb *irb) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 871 | { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 872 | if (irb->esw.esw0.erw.cons) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 873 | DBF_ERROR("%4x sense:", irq_ptr->schid.sch_no); |
| 874 | DBF_ERROR_HEX(irb, 64); |
| 875 | DBF_ERROR_HEX(irb->ecw, 64); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 876 | } |
| 877 | } |
| 878 | |
| 879 | /* PCI interrupt handler */ |
| 880 | static void qdio_int_handler_pci(struct qdio_irq *irq_ptr) |
| 881 | { |
| 882 | int i; |
| 883 | struct qdio_q *q; |
| 884 | |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 885 | if (unlikely(irq_ptr->state == QDIO_IRQ_STATE_STOPPED)) |
| 886 | return; |
| 887 | |
Jan Glauber | d36deae | 2010-09-07 21:14:39 +0000 | [diff] [blame] | 888 | for_each_input_queue(irq_ptr, q, i) { |
| 889 | if (q->u.in.queue_start_poll) { |
| 890 | /* skip if polling is enabled or already in work */ |
| 891 | if (test_and_set_bit(QDIO_QUEUE_IRQS_DISABLED, |
| 892 | &q->u.in.queue_irq_state)) { |
| 893 | qperf_inc(q, int_discarded); |
| 894 | continue; |
| 895 | } |
| 896 | q->u.in.queue_start_poll(q->irq_ptr->cdev, q->nr, |
| 897 | q->irq_ptr->int_parm); |
| 898 | } else |
| 899 | tasklet_schedule(&q->tasklet); |
| 900 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 901 | |
| 902 | if (!(irq_ptr->qib.ac & QIB_AC_OUTBOUND_PCI_SUPPORTED)) |
| 903 | return; |
| 904 | |
| 905 | for_each_output_queue(irq_ptr, q, i) { |
| 906 | if (qdio_outbound_q_done(q)) |
| 907 | continue; |
| 908 | |
| 909 | if (!siga_syncs_out_pci(q)) |
| 910 | qdio_siga_sync_q(q); |
| 911 | |
| 912 | tasklet_schedule(&q->tasklet); |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | static void qdio_handle_activate_check(struct ccw_device *cdev, |
| 917 | unsigned long intparm, int cstat, int dstat) |
| 918 | { |
| 919 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
| 920 | struct qdio_q *q; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 921 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 922 | DBF_ERROR("%4x ACT CHECK", irq_ptr->schid.sch_no); |
| 923 | DBF_ERROR("intp :%lx", intparm); |
| 924 | DBF_ERROR("ds: %2x cs:%2x", dstat, cstat); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 925 | |
| 926 | if (irq_ptr->nr_input_qs) { |
| 927 | q = irq_ptr->input_qs[0]; |
| 928 | } else if (irq_ptr->nr_output_qs) { |
| 929 | q = irq_ptr->output_qs[0]; |
| 930 | } else { |
| 931 | dump_stack(); |
| 932 | goto no_handler; |
| 933 | } |
| 934 | q->handler(q->irq_ptr->cdev, QDIO_ERROR_ACTIVATE_CHECK_CONDITION, |
| 935 | 0, -1, -1, irq_ptr->int_parm); |
| 936 | no_handler: |
| 937 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED); |
| 938 | } |
| 939 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 940 | static void qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, |
| 941 | int dstat) |
| 942 | { |
| 943 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 944 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 945 | DBF_DEV_EVENT(DBF_INFO, irq_ptr, "qest irq"); |
Jan Glauber | 4c57542 | 2009-06-12 10:26:28 +0200 | [diff] [blame] | 946 | |
| 947 | if (cstat) |
| 948 | goto error; |
| 949 | if (dstat & ~(DEV_STAT_DEV_END | DEV_STAT_CHN_END)) |
| 950 | goto error; |
| 951 | if (!(dstat & DEV_STAT_DEV_END)) |
| 952 | goto error; |
| 953 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ESTABLISHED); |
| 954 | return; |
| 955 | |
| 956 | error: |
| 957 | DBF_ERROR("%4x EQ:error", irq_ptr->schid.sch_no); |
| 958 | DBF_ERROR("ds: %2x cs:%2x", dstat, cstat); |
| 959 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | /* qdio interrupt handler */ |
| 963 | void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm, |
| 964 | struct irb *irb) |
| 965 | { |
| 966 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
| 967 | int cstat, dstat; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 968 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 969 | if (!intparm || !irq_ptr) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 970 | DBF_ERROR("qint:%4x", cdev->private->schid.sch_no); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 971 | return; |
| 972 | } |
| 973 | |
Jan Glauber | 30d77c3 | 2011-01-05 12:47:29 +0100 | [diff] [blame] | 974 | kstat_cpu(smp_processor_id()).irqs[IOINT_QDI]++; |
Jan Glauber | 09a308f | 2010-05-17 10:00:14 +0200 | [diff] [blame] | 975 | if (irq_ptr->perf_stat_enabled) |
| 976 | irq_ptr->perf_stat.qdio_int++; |
| 977 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 978 | if (IS_ERR(irb)) { |
| 979 | switch (PTR_ERR(irb)) { |
| 980 | case -EIO: |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 981 | DBF_ERROR("%4x IO error", irq_ptr->schid.sch_no); |
Jan Glauber | 75cb71f | 2009-04-14 15:36:22 +0200 | [diff] [blame] | 982 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); |
| 983 | wake_up(&cdev->private->wait_q); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 984 | return; |
| 985 | default: |
| 986 | WARN_ON(1); |
| 987 | return; |
| 988 | } |
| 989 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 990 | qdio_irq_check_sense(irq_ptr, irb); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 991 | cstat = irb->scsw.cmd.cstat; |
| 992 | dstat = irb->scsw.cmd.dstat; |
| 993 | |
| 994 | switch (irq_ptr->state) { |
| 995 | case QDIO_IRQ_STATE_INACTIVE: |
| 996 | qdio_establish_handle_irq(cdev, cstat, dstat); |
| 997 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 998 | case QDIO_IRQ_STATE_CLEANUP: |
| 999 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); |
| 1000 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1001 | case QDIO_IRQ_STATE_ESTABLISHED: |
| 1002 | case QDIO_IRQ_STATE_ACTIVE: |
| 1003 | if (cstat & SCHN_STAT_PCI) { |
| 1004 | qdio_int_handler_pci(irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1005 | return; |
| 1006 | } |
Jan Glauber | 4c57542 | 2009-06-12 10:26:28 +0200 | [diff] [blame] | 1007 | if (cstat || dstat) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1008 | qdio_handle_activate_check(cdev, intparm, cstat, |
| 1009 | dstat); |
Jan Glauber | 4c57542 | 2009-06-12 10:26:28 +0200 | [diff] [blame] | 1010 | break; |
Jan Glauber | 959153d | 2010-02-09 09:46:08 +0100 | [diff] [blame] | 1011 | case QDIO_IRQ_STATE_STOPPED: |
| 1012 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1013 | default: |
| 1014 | WARN_ON(1); |
| 1015 | } |
| 1016 | wake_up(&cdev->private->wait_q); |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * qdio_get_ssqd_desc - get qdio subchannel description |
| 1021 | * @cdev: ccw device to get description for |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 1022 | * @data: where to store the ssqd |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1023 | * |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 1024 | * Returns 0 or an error code. The results of the chsc are stored in the |
| 1025 | * specified structure. |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1026 | */ |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 1027 | int qdio_get_ssqd_desc(struct ccw_device *cdev, |
| 1028 | struct qdio_ssqd_desc *data) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1029 | { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1030 | |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 1031 | if (!cdev || !cdev->private) |
| 1032 | return -EINVAL; |
| 1033 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1034 | DBF_EVENT("get ssqd:%4x", cdev->private->schid.sch_no); |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 1035 | return qdio_setup_get_ssqd(NULL, &cdev->private->schid, data); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1036 | } |
| 1037 | EXPORT_SYMBOL_GPL(qdio_get_ssqd_desc); |
| 1038 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1039 | static void qdio_shutdown_queues(struct ccw_device *cdev) |
| 1040 | { |
| 1041 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
| 1042 | struct qdio_q *q; |
| 1043 | int i; |
| 1044 | |
| 1045 | for_each_input_queue(irq_ptr, q, i) |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 1046 | tasklet_kill(&q->tasklet); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1047 | |
| 1048 | for_each_output_queue(irq_ptr, q, i) { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1049 | del_timer(&q->u.out.timer); |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 1050 | tasklet_kill(&q->tasklet); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * qdio_shutdown - shut down a qdio subchannel |
| 1056 | * @cdev: associated ccw device |
| 1057 | * @how: use halt or clear to shutdown |
| 1058 | */ |
| 1059 | int qdio_shutdown(struct ccw_device *cdev, int how) |
| 1060 | { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1061 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1062 | int rc; |
| 1063 | unsigned long flags; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1064 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1065 | if (!irq_ptr) |
| 1066 | return -ENODEV; |
| 1067 | |
Jan Glauber | b454740 | 2009-03-26 15:24:24 +0100 | [diff] [blame] | 1068 | BUG_ON(irqs_disabled()); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1069 | DBF_EVENT("qshutdown:%4x", cdev->private->schid.sch_no); |
| 1070 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1071 | mutex_lock(&irq_ptr->setup_mutex); |
| 1072 | /* |
| 1073 | * Subchannel was already shot down. We cannot prevent being called |
| 1074 | * twice since cio may trigger a shutdown asynchronously. |
| 1075 | */ |
| 1076 | if (irq_ptr->state == QDIO_IRQ_STATE_INACTIVE) { |
| 1077 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1078 | return 0; |
| 1079 | } |
| 1080 | |
Jan Glauber | c38f960 | 2009-03-26 15:24:26 +0100 | [diff] [blame] | 1081 | /* |
| 1082 | * Indicate that the device is going down. Scheduling the queue |
| 1083 | * tasklets is forbidden from here on. |
| 1084 | */ |
| 1085 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED); |
| 1086 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1087 | tiqdio_remove_input_queues(irq_ptr); |
| 1088 | qdio_shutdown_queues(cdev); |
| 1089 | qdio_shutdown_debug_entries(irq_ptr, cdev); |
| 1090 | |
| 1091 | /* cleanup subchannel */ |
| 1092 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 1093 | |
| 1094 | if (how & QDIO_FLAG_CLEANUP_USING_CLEAR) |
| 1095 | rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP); |
| 1096 | else |
| 1097 | /* default behaviour is halt */ |
| 1098 | rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP); |
| 1099 | if (rc) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1100 | DBF_ERROR("%4x SHUTD ERR", irq_ptr->schid.sch_no); |
| 1101 | DBF_ERROR("rc:%4d", rc); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1102 | goto no_cleanup; |
| 1103 | } |
| 1104 | |
| 1105 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP); |
| 1106 | spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1107 | wait_event_interruptible_timeout(cdev->private->wait_q, |
| 1108 | irq_ptr->state == QDIO_IRQ_STATE_INACTIVE || |
| 1109 | irq_ptr->state == QDIO_IRQ_STATE_ERR, |
| 1110 | 10 * HZ); |
| 1111 | spin_lock_irqsave(get_ccwdev_lock(cdev), flags); |
| 1112 | |
| 1113 | no_cleanup: |
| 1114 | qdio_shutdown_thinint(irq_ptr); |
| 1115 | |
| 1116 | /* restore interrupt handler */ |
| 1117 | if ((void *)cdev->handler == (void *)qdio_int_handler) |
| 1118 | cdev->handler = irq_ptr->orig_handler; |
| 1119 | spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags); |
| 1120 | |
| 1121 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); |
| 1122 | mutex_unlock(&irq_ptr->setup_mutex); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1123 | if (rc) |
| 1124 | return rc; |
| 1125 | return 0; |
| 1126 | } |
| 1127 | EXPORT_SYMBOL_GPL(qdio_shutdown); |
| 1128 | |
| 1129 | /** |
| 1130 | * qdio_free - free data structures for a qdio subchannel |
| 1131 | * @cdev: associated ccw device |
| 1132 | */ |
| 1133 | int qdio_free(struct ccw_device *cdev) |
| 1134 | { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1135 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1136 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1137 | if (!irq_ptr) |
| 1138 | return -ENODEV; |
| 1139 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1140 | DBF_EVENT("qfree:%4x", cdev->private->schid.sch_no); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1141 | mutex_lock(&irq_ptr->setup_mutex); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1142 | |
| 1143 | if (irq_ptr->debug_area != NULL) { |
| 1144 | debug_unregister(irq_ptr->debug_area); |
| 1145 | irq_ptr->debug_area = NULL; |
| 1146 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1147 | cdev->private->qdio_data = NULL; |
| 1148 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1149 | |
| 1150 | qdio_release_memory(irq_ptr); |
| 1151 | return 0; |
| 1152 | } |
| 1153 | EXPORT_SYMBOL_GPL(qdio_free); |
| 1154 | |
| 1155 | /** |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1156 | * qdio_allocate - allocate qdio queues and associated data |
| 1157 | * @init_data: initialization data |
| 1158 | */ |
| 1159 | int qdio_allocate(struct qdio_initialize *init_data) |
| 1160 | { |
| 1161 | struct qdio_irq *irq_ptr; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1162 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1163 | DBF_EVENT("qallocate:%4x", init_data->cdev->private->schid.sch_no); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1164 | |
| 1165 | if ((init_data->no_input_qs && !init_data->input_handler) || |
| 1166 | (init_data->no_output_qs && !init_data->output_handler)) |
| 1167 | return -EINVAL; |
| 1168 | |
| 1169 | if ((init_data->no_input_qs > QDIO_MAX_QUEUES_PER_IRQ) || |
| 1170 | (init_data->no_output_qs > QDIO_MAX_QUEUES_PER_IRQ)) |
| 1171 | return -EINVAL; |
| 1172 | |
| 1173 | if ((!init_data->input_sbal_addr_array) || |
| 1174 | (!init_data->output_sbal_addr_array)) |
| 1175 | return -EINVAL; |
| 1176 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1177 | /* irq_ptr must be in GFP_DMA since it contains ccw1.cda */ |
| 1178 | irq_ptr = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); |
| 1179 | if (!irq_ptr) |
| 1180 | goto out_err; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1181 | |
| 1182 | mutex_init(&irq_ptr->setup_mutex); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1183 | qdio_allocate_dbf(init_data, irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1184 | |
| 1185 | /* |
| 1186 | * Allocate a page for the chsc calls in qdio_establish. |
| 1187 | * Must be pre-allocated since a zfcp recovery will call |
| 1188 | * qdio_establish. In case of low memory and swap on a zfcp disk |
| 1189 | * we may not be able to allocate memory otherwise. |
| 1190 | */ |
| 1191 | irq_ptr->chsc_page = get_zeroed_page(GFP_KERNEL); |
| 1192 | if (!irq_ptr->chsc_page) |
| 1193 | goto out_rel; |
| 1194 | |
| 1195 | /* qdr is used in ccw1.cda which is u32 */ |
Jan Glauber | 3b8e300 | 2008-08-01 16:39:17 +0200 | [diff] [blame] | 1196 | irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1197 | if (!irq_ptr->qdr) |
| 1198 | goto out_rel; |
| 1199 | WARN_ON((unsigned long)irq_ptr->qdr & 0xfff); |
| 1200 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1201 | if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs, |
| 1202 | init_data->no_output_qs)) |
| 1203 | goto out_rel; |
| 1204 | |
| 1205 | init_data->cdev->private->qdio_data = irq_ptr; |
| 1206 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); |
| 1207 | return 0; |
| 1208 | out_rel: |
| 1209 | qdio_release_memory(irq_ptr); |
| 1210 | out_err: |
| 1211 | return -ENOMEM; |
| 1212 | } |
| 1213 | EXPORT_SYMBOL_GPL(qdio_allocate); |
| 1214 | |
| 1215 | /** |
| 1216 | * qdio_establish - establish queues on a qdio subchannel |
| 1217 | * @init_data: initialization data |
| 1218 | */ |
| 1219 | int qdio_establish(struct qdio_initialize *init_data) |
| 1220 | { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1221 | struct qdio_irq *irq_ptr; |
| 1222 | struct ccw_device *cdev = init_data->cdev; |
| 1223 | unsigned long saveflags; |
| 1224 | int rc; |
| 1225 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1226 | DBF_EVENT("qestablish:%4x", cdev->private->schid.sch_no); |
Jan Glauber | 58eb27c | 2008-08-21 19:46:34 +0200 | [diff] [blame] | 1227 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1228 | irq_ptr = cdev->private->qdio_data; |
| 1229 | if (!irq_ptr) |
| 1230 | return -ENODEV; |
| 1231 | |
| 1232 | if (cdev->private->state != DEV_STATE_ONLINE) |
| 1233 | return -EINVAL; |
| 1234 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1235 | mutex_lock(&irq_ptr->setup_mutex); |
| 1236 | qdio_setup_irq(init_data); |
| 1237 | |
| 1238 | rc = qdio_establish_thinint(irq_ptr); |
| 1239 | if (rc) { |
| 1240 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1241 | qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR); |
| 1242 | return rc; |
| 1243 | } |
| 1244 | |
| 1245 | /* establish q */ |
| 1246 | irq_ptr->ccw.cmd_code = irq_ptr->equeue.cmd; |
| 1247 | irq_ptr->ccw.flags = CCW_FLAG_SLI; |
| 1248 | irq_ptr->ccw.count = irq_ptr->equeue.count; |
| 1249 | irq_ptr->ccw.cda = (u32)((addr_t)irq_ptr->qdr); |
| 1250 | |
| 1251 | spin_lock_irqsave(get_ccwdev_lock(cdev), saveflags); |
| 1252 | ccw_device_set_options_mask(cdev, 0); |
| 1253 | |
| 1254 | rc = ccw_device_start(cdev, &irq_ptr->ccw, QDIO_DOING_ESTABLISH, 0, 0); |
| 1255 | if (rc) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1256 | DBF_ERROR("%4x est IO ERR", irq_ptr->schid.sch_no); |
| 1257 | DBF_ERROR("rc:%4x", rc); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1258 | } |
| 1259 | spin_unlock_irqrestore(get_ccwdev_lock(cdev), saveflags); |
| 1260 | |
| 1261 | if (rc) { |
| 1262 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1263 | qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR); |
| 1264 | return rc; |
| 1265 | } |
| 1266 | |
| 1267 | wait_event_interruptible_timeout(cdev->private->wait_q, |
| 1268 | irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED || |
| 1269 | irq_ptr->state == QDIO_IRQ_STATE_ERR, HZ); |
| 1270 | |
| 1271 | if (irq_ptr->state != QDIO_IRQ_STATE_ESTABLISHED) { |
| 1272 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1273 | qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR); |
| 1274 | return -EIO; |
| 1275 | } |
| 1276 | |
| 1277 | qdio_setup_ssqd_info(irq_ptr); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1278 | DBF_EVENT("qDmmwc:%2x", irq_ptr->ssqd_desc.mmwc); |
| 1279 | DBF_EVENT("qib ac:%4x", irq_ptr->qib.ac); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1280 | |
| 1281 | /* qebsm is now setup if available, initialize buffer states */ |
| 1282 | qdio_init_buf_states(irq_ptr); |
| 1283 | |
| 1284 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1285 | qdio_print_subchannel_info(irq_ptr, cdev); |
| 1286 | qdio_setup_debug_entries(irq_ptr, cdev); |
| 1287 | return 0; |
| 1288 | } |
| 1289 | EXPORT_SYMBOL_GPL(qdio_establish); |
| 1290 | |
| 1291 | /** |
| 1292 | * qdio_activate - activate queues on a qdio subchannel |
| 1293 | * @cdev: associated cdev |
| 1294 | */ |
| 1295 | int qdio_activate(struct ccw_device *cdev) |
| 1296 | { |
| 1297 | struct qdio_irq *irq_ptr; |
| 1298 | int rc; |
| 1299 | unsigned long saveflags; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1300 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1301 | DBF_EVENT("qactivate:%4x", cdev->private->schid.sch_no); |
Jan Glauber | 58eb27c | 2008-08-21 19:46:34 +0200 | [diff] [blame] | 1302 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1303 | irq_ptr = cdev->private->qdio_data; |
| 1304 | if (!irq_ptr) |
| 1305 | return -ENODEV; |
| 1306 | |
| 1307 | if (cdev->private->state != DEV_STATE_ONLINE) |
| 1308 | return -EINVAL; |
| 1309 | |
| 1310 | mutex_lock(&irq_ptr->setup_mutex); |
| 1311 | if (irq_ptr->state == QDIO_IRQ_STATE_INACTIVE) { |
| 1312 | rc = -EBUSY; |
| 1313 | goto out; |
| 1314 | } |
| 1315 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1316 | irq_ptr->ccw.cmd_code = irq_ptr->aqueue.cmd; |
| 1317 | irq_ptr->ccw.flags = CCW_FLAG_SLI; |
| 1318 | irq_ptr->ccw.count = irq_ptr->aqueue.count; |
| 1319 | irq_ptr->ccw.cda = 0; |
| 1320 | |
| 1321 | spin_lock_irqsave(get_ccwdev_lock(cdev), saveflags); |
| 1322 | ccw_device_set_options(cdev, CCWDEV_REPORT_ALL); |
| 1323 | |
| 1324 | rc = ccw_device_start(cdev, &irq_ptr->ccw, QDIO_DOING_ACTIVATE, |
| 1325 | 0, DOIO_DENY_PREFETCH); |
| 1326 | if (rc) { |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 1327 | DBF_ERROR("%4x act IO ERR", irq_ptr->schid.sch_no); |
| 1328 | DBF_ERROR("rc:%4x", rc); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1329 | } |
| 1330 | spin_unlock_irqrestore(get_ccwdev_lock(cdev), saveflags); |
| 1331 | |
| 1332 | if (rc) |
| 1333 | goto out; |
| 1334 | |
| 1335 | if (is_thinint_irq(irq_ptr)) |
| 1336 | tiqdio_add_input_queues(irq_ptr); |
| 1337 | |
| 1338 | /* wait for subchannel to become active */ |
| 1339 | msleep(5); |
| 1340 | |
| 1341 | switch (irq_ptr->state) { |
| 1342 | case QDIO_IRQ_STATE_STOPPED: |
| 1343 | case QDIO_IRQ_STATE_ERR: |
Jan Glauber | e4c14e2 | 2009-03-26 15:24:25 +0100 | [diff] [blame] | 1344 | rc = -EIO; |
| 1345 | break; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1346 | default: |
| 1347 | qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ACTIVE); |
| 1348 | rc = 0; |
| 1349 | } |
| 1350 | out: |
| 1351 | mutex_unlock(&irq_ptr->setup_mutex); |
| 1352 | return rc; |
| 1353 | } |
| 1354 | EXPORT_SYMBOL_GPL(qdio_activate); |
| 1355 | |
| 1356 | static inline int buf_in_between(int bufnr, int start, int count) |
| 1357 | { |
| 1358 | int end = add_buf(start, count); |
| 1359 | |
| 1360 | if (end > start) { |
| 1361 | if (bufnr >= start && bufnr < end) |
| 1362 | return 1; |
| 1363 | else |
| 1364 | return 0; |
| 1365 | } |
| 1366 | |
| 1367 | /* wrap-around case */ |
| 1368 | if ((bufnr >= start && bufnr <= QDIO_MAX_BUFFERS_PER_Q) || |
| 1369 | (bufnr < end)) |
| 1370 | return 1; |
| 1371 | else |
| 1372 | return 0; |
| 1373 | } |
| 1374 | |
| 1375 | /** |
| 1376 | * handle_inbound - reset processed input buffers |
| 1377 | * @q: queue containing the buffers |
| 1378 | * @callflags: flags |
| 1379 | * @bufnr: first buffer to process |
| 1380 | * @count: how many buffers are emptied |
| 1381 | */ |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1382 | static int handle_inbound(struct qdio_q *q, unsigned int callflags, |
| 1383 | int bufnr, int count) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1384 | { |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1385 | int used, diff; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1386 | |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 1387 | qperf_inc(q, inbound_call); |
| 1388 | |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1389 | if (!q->u.in.polling) |
| 1390 | goto set; |
| 1391 | |
| 1392 | /* protect against stop polling setting an ACK for an emptied slsb */ |
| 1393 | if (count == QDIO_MAX_BUFFERS_PER_Q) { |
| 1394 | /* overwriting everything, just delete polling status */ |
| 1395 | q->u.in.polling = 0; |
| 1396 | q->u.in.ack_count = 0; |
| 1397 | goto set; |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 1398 | } else if (buf_in_between(q->u.in.ack_start, bufnr, count)) { |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1399 | if (is_qebsm(q)) { |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 1400 | /* partial overwrite, just update ack_start */ |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1401 | diff = add_buf(bufnr, count); |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 1402 | diff = sub_buf(diff, q->u.in.ack_start); |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1403 | q->u.in.ack_count -= diff; |
| 1404 | if (q->u.in.ack_count <= 0) { |
| 1405 | q->u.in.polling = 0; |
| 1406 | q->u.in.ack_count = 0; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1407 | goto set; |
| 1408 | } |
Jan Glauber | e85dea0 | 2009-03-26 15:24:29 +0100 | [diff] [blame] | 1409 | q->u.in.ack_start = add_buf(q->u.in.ack_start, diff); |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1410 | } |
| 1411 | else |
| 1412 | /* the only ACK will be deleted, so stop polling */ |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1413 | q->u.in.polling = 0; |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1414 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1415 | |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1416 | set: |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1417 | count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1418 | |
| 1419 | used = atomic_add_return(count, &q->nr_buf_used) - count; |
| 1420 | BUG_ON(used + count > QDIO_MAX_BUFFERS_PER_Q); |
| 1421 | |
| 1422 | /* no need to signal as long as the adapter had free buffers */ |
| 1423 | if (used) |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1424 | return 0; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1425 | |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1426 | if (need_siga_in(q)) |
| 1427 | return qdio_siga_input(q); |
| 1428 | return 0; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | /** |
| 1432 | * handle_outbound - process filled outbound buffers |
| 1433 | * @q: queue containing the buffers |
| 1434 | * @callflags: flags |
| 1435 | * @bufnr: first buffer to process |
| 1436 | * @count: how many buffers are filled |
| 1437 | */ |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1438 | static int handle_outbound(struct qdio_q *q, unsigned int callflags, |
| 1439 | int bufnr, int count) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1440 | { |
| 1441 | unsigned char state; |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1442 | int used, rc = 0; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1443 | |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 1444 | qperf_inc(q, outbound_call); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1445 | |
| 1446 | count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count); |
| 1447 | used = atomic_add_return(count, &q->nr_buf_used); |
| 1448 | BUG_ON(used > QDIO_MAX_BUFFERS_PER_Q); |
| 1449 | |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 1450 | if (callflags & QDIO_FLAG_PCI_OUT) { |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1451 | q->u.out.pci_out_enabled = 1; |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 1452 | qperf_inc(q, pci_request_int); |
| 1453 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1454 | else |
| 1455 | q->u.out.pci_out_enabled = 0; |
| 1456 | |
| 1457 | if (queue_type(q) == QDIO_IQDIO_QFMT) { |
| 1458 | if (multicast_outbound(q)) |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1459 | rc = qdio_kick_outbound_q(q); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1460 | else |
Klaus-Dieter Wacker | 7a0f475 | 2008-10-10 21:33:18 +0200 | [diff] [blame] | 1461 | if ((q->irq_ptr->ssqd_desc.mmwc > 1) && |
| 1462 | (count > 1) && |
| 1463 | (count <= q->irq_ptr->ssqd_desc.mmwc)) { |
| 1464 | /* exploit enhanced SIGA */ |
| 1465 | q->u.out.use_enh_siga = 1; |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1466 | rc = qdio_kick_outbound_q(q); |
Klaus-Dieter Wacker | 7a0f475 | 2008-10-10 21:33:18 +0200 | [diff] [blame] | 1467 | } else { |
| 1468 | /* |
| 1469 | * One siga-w per buffer required for unicast |
| 1470 | * HiperSockets. |
| 1471 | */ |
| 1472 | q->u.out.use_enh_siga = 0; |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1473 | while (count--) { |
| 1474 | rc = qdio_kick_outbound_q(q); |
| 1475 | if (rc) |
| 1476 | goto out; |
| 1477 | } |
Klaus-Dieter Wacker | 7a0f475 | 2008-10-10 21:33:18 +0200 | [diff] [blame] | 1478 | } |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1479 | goto out; |
| 1480 | } |
| 1481 | |
| 1482 | if (need_siga_sync(q)) { |
| 1483 | qdio_siga_sync_q(q); |
| 1484 | goto out; |
| 1485 | } |
| 1486 | |
| 1487 | /* try to fast requeue buffers */ |
Jan Glauber | 50f769d | 2008-12-25 13:38:47 +0100 | [diff] [blame] | 1488 | get_buf_state(q, prev_buf(bufnr), &state, 0); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1489 | if (state != SLSB_CU_OUTPUT_PRIMED) |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1490 | rc = qdio_kick_outbound_q(q); |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 1491 | else |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 1492 | qperf_inc(q, fast_requeue); |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 1493 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1494 | out: |
Jan Glauber | 3d6c76f | 2011-01-05 12:47:50 +0100 | [diff] [blame^] | 1495 | /* in case of SIGA errors we must process the error immediately */ |
| 1496 | if (used >= q->u.out.scan_threshold || rc) |
| 1497 | tasklet_schedule(&q->tasklet); |
| 1498 | else |
| 1499 | /* free the SBALs in case of no further traffic */ |
| 1500 | if (!timer_pending(&q->u.out.timer)) |
| 1501 | mod_timer(&q->u.out.timer, jiffies + HZ); |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1502 | return rc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | /** |
| 1506 | * do_QDIO - process input or output buffers |
| 1507 | * @cdev: associated ccw_device for the qdio subchannel |
| 1508 | * @callflags: input or output and special flags from the program |
| 1509 | * @q_nr: queue number |
| 1510 | * @bufnr: buffer number |
| 1511 | * @count: how many buffers to process |
| 1512 | */ |
| 1513 | int do_QDIO(struct ccw_device *cdev, unsigned int callflags, |
Jan Glauber | 6618241 | 2009-06-22 12:08:15 +0200 | [diff] [blame] | 1514 | int q_nr, unsigned int bufnr, unsigned int count) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1515 | { |
| 1516 | struct qdio_irq *irq_ptr; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1517 | |
Jan Glauber | 6618241 | 2009-06-22 12:08:15 +0200 | [diff] [blame] | 1518 | if (bufnr >= QDIO_MAX_BUFFERS_PER_Q || count > QDIO_MAX_BUFFERS_PER_Q) |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1519 | return -EINVAL; |
| 1520 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1521 | irq_ptr = cdev->private->qdio_data; |
| 1522 | if (!irq_ptr) |
| 1523 | return -ENODEV; |
| 1524 | |
Jan Glauber | 1d7e150 | 2009-09-22 22:58:39 +0200 | [diff] [blame] | 1525 | DBF_DEV_EVENT(DBF_INFO, irq_ptr, |
| 1526 | "do%02x b:%02x c:%02x", callflags, bufnr, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1527 | |
| 1528 | if (irq_ptr->state != QDIO_IRQ_STATE_ACTIVE) |
| 1529 | return -EBUSY; |
| 1530 | |
| 1531 | if (callflags & QDIO_FLAG_SYNC_INPUT) |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1532 | return handle_inbound(irq_ptr->input_qs[q_nr], |
| 1533 | callflags, bufnr, count); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1534 | else if (callflags & QDIO_FLAG_SYNC_OUTPUT) |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 1535 | return handle_outbound(irq_ptr->output_qs[q_nr], |
| 1536 | callflags, bufnr, count); |
| 1537 | return -EINVAL; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1538 | } |
| 1539 | EXPORT_SYMBOL_GPL(do_QDIO); |
| 1540 | |
Jan Glauber | d36deae | 2010-09-07 21:14:39 +0000 | [diff] [blame] | 1541 | /** |
| 1542 | * qdio_start_irq - process input buffers |
| 1543 | * @cdev: associated ccw_device for the qdio subchannel |
| 1544 | * @nr: input queue number |
| 1545 | * |
| 1546 | * Return codes |
| 1547 | * 0 - success |
| 1548 | * 1 - irqs not started since new data is available |
| 1549 | */ |
| 1550 | int qdio_start_irq(struct ccw_device *cdev, int nr) |
| 1551 | { |
| 1552 | struct qdio_q *q; |
| 1553 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
| 1554 | |
| 1555 | if (!irq_ptr) |
| 1556 | return -ENODEV; |
| 1557 | q = irq_ptr->input_qs[nr]; |
| 1558 | |
| 1559 | WARN_ON(queue_irqs_enabled(q)); |
| 1560 | |
Jan Glauber | 4f32518 | 2011-01-05 12:47:49 +0100 | [diff] [blame] | 1561 | if (!shared_ind(q->irq_ptr->dsci)) |
Jan Glauber | d36deae | 2010-09-07 21:14:39 +0000 | [diff] [blame] | 1562 | xchg(q->irq_ptr->dsci, 0); |
| 1563 | |
| 1564 | qdio_stop_polling(q); |
| 1565 | clear_bit(QDIO_QUEUE_IRQS_DISABLED, &q->u.in.queue_irq_state); |
| 1566 | |
| 1567 | /* |
| 1568 | * We need to check again to not lose initiative after |
| 1569 | * resetting the ACK state. |
| 1570 | */ |
Jan Glauber | 4f32518 | 2011-01-05 12:47:49 +0100 | [diff] [blame] | 1571 | if (!shared_ind(q->irq_ptr->dsci) && *q->irq_ptr->dsci) |
Jan Glauber | d36deae | 2010-09-07 21:14:39 +0000 | [diff] [blame] | 1572 | goto rescan; |
| 1573 | if (!qdio_inbound_q_done(q)) |
| 1574 | goto rescan; |
| 1575 | return 0; |
| 1576 | |
| 1577 | rescan: |
| 1578 | if (test_and_set_bit(QDIO_QUEUE_IRQS_DISABLED, |
| 1579 | &q->u.in.queue_irq_state)) |
| 1580 | return 0; |
| 1581 | else |
| 1582 | return 1; |
| 1583 | |
| 1584 | } |
| 1585 | EXPORT_SYMBOL(qdio_start_irq); |
| 1586 | |
| 1587 | /** |
| 1588 | * qdio_get_next_buffers - process input buffers |
| 1589 | * @cdev: associated ccw_device for the qdio subchannel |
| 1590 | * @nr: input queue number |
| 1591 | * @bufnr: first filled buffer number |
| 1592 | * @error: buffers are in error state |
| 1593 | * |
| 1594 | * Return codes |
| 1595 | * < 0 - error |
| 1596 | * = 0 - no new buffers found |
| 1597 | * > 0 - number of processed buffers |
| 1598 | */ |
| 1599 | int qdio_get_next_buffers(struct ccw_device *cdev, int nr, int *bufnr, |
| 1600 | int *error) |
| 1601 | { |
| 1602 | struct qdio_q *q; |
| 1603 | int start, end; |
| 1604 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
| 1605 | |
| 1606 | if (!irq_ptr) |
| 1607 | return -ENODEV; |
| 1608 | q = irq_ptr->input_qs[nr]; |
| 1609 | WARN_ON(queue_irqs_enabled(q)); |
| 1610 | |
| 1611 | qdio_sync_after_thinint(q); |
| 1612 | |
| 1613 | /* |
| 1614 | * The interrupt could be caused by a PCI request. Check the |
| 1615 | * PCI capable outbound queues. |
| 1616 | */ |
| 1617 | qdio_check_outbound_after_thinint(q); |
| 1618 | |
| 1619 | if (!qdio_inbound_q_moved(q)) |
| 1620 | return 0; |
| 1621 | |
| 1622 | /* Note: upper-layer MUST stop processing immediately here ... */ |
| 1623 | if (unlikely(q->irq_ptr->state != QDIO_IRQ_STATE_ACTIVE)) |
| 1624 | return -EIO; |
| 1625 | |
| 1626 | start = q->first_to_kick; |
| 1627 | end = q->first_to_check; |
| 1628 | *bufnr = start; |
| 1629 | *error = q->qdio_error; |
| 1630 | |
| 1631 | /* for the next time */ |
| 1632 | q->first_to_kick = end; |
| 1633 | q->qdio_error = 0; |
| 1634 | return sub_buf(end, start); |
| 1635 | } |
| 1636 | EXPORT_SYMBOL(qdio_get_next_buffers); |
| 1637 | |
| 1638 | /** |
| 1639 | * qdio_stop_irq - disable interrupt processing for the device |
| 1640 | * @cdev: associated ccw_device for the qdio subchannel |
| 1641 | * @nr: input queue number |
| 1642 | * |
| 1643 | * Return codes |
| 1644 | * 0 - interrupts were already disabled |
| 1645 | * 1 - interrupts successfully disabled |
| 1646 | */ |
| 1647 | int qdio_stop_irq(struct ccw_device *cdev, int nr) |
| 1648 | { |
| 1649 | struct qdio_q *q; |
| 1650 | struct qdio_irq *irq_ptr = cdev->private->qdio_data; |
| 1651 | |
| 1652 | if (!irq_ptr) |
| 1653 | return -ENODEV; |
| 1654 | q = irq_ptr->input_qs[nr]; |
| 1655 | |
| 1656 | if (test_and_set_bit(QDIO_QUEUE_IRQS_DISABLED, |
| 1657 | &q->u.in.queue_irq_state)) |
| 1658 | return 0; |
| 1659 | else |
| 1660 | return 1; |
| 1661 | } |
| 1662 | EXPORT_SYMBOL(qdio_stop_irq); |
| 1663 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1664 | static int __init init_QDIO(void) |
| 1665 | { |
| 1666 | int rc; |
| 1667 | |
| 1668 | rc = qdio_setup_init(); |
| 1669 | if (rc) |
| 1670 | return rc; |
| 1671 | rc = tiqdio_allocate_memory(); |
| 1672 | if (rc) |
| 1673 | goto out_cache; |
| 1674 | rc = qdio_debug_init(); |
| 1675 | if (rc) |
| 1676 | goto out_ti; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1677 | rc = tiqdio_register_thinints(); |
| 1678 | if (rc) |
Jan Glauber | 6486cda | 2010-01-04 09:05:42 +0100 | [diff] [blame] | 1679 | goto out_debug; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1680 | return 0; |
| 1681 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1682 | out_debug: |
| 1683 | qdio_debug_exit(); |
| 1684 | out_ti: |
| 1685 | tiqdio_free_memory(); |
| 1686 | out_cache: |
| 1687 | qdio_setup_exit(); |
| 1688 | return rc; |
| 1689 | } |
| 1690 | |
| 1691 | static void __exit exit_QDIO(void) |
| 1692 | { |
| 1693 | tiqdio_unregister_thinints(); |
| 1694 | tiqdio_free_memory(); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1695 | qdio_debug_exit(); |
| 1696 | qdio_setup_exit(); |
| 1697 | } |
| 1698 | |
| 1699 | module_init(init_QDIO); |
| 1700 | module_exit(exit_QDIO); |