qdio_main.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  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>
  16. #include <asm/atomic.h>
  17. #include <asm/debug.h>
  18. #include <asm/qdio.h>
  19. #include "cio.h"
  20. #include "css.h"
  21. #include "device.h"
  22. #include "qdio.h"
  23. #include "qdio_debug.h"
  24. #include "qdio_perf.h"
  25. MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>,"\
  26. "Jan Glauber <jang@linux.vnet.ibm.com>");
  27. MODULE_DESCRIPTION("QDIO base support");
  28. MODULE_LICENSE("GPL");
  29. static inline int do_siga_sync(struct subchannel_id schid,
  30. unsigned int out_mask, unsigned int in_mask)
  31. {
  32. register unsigned long __fc asm ("0") = 2;
  33. register struct subchannel_id __schid asm ("1") = schid;
  34. register unsigned long out asm ("2") = out_mask;
  35. register unsigned long in asm ("3") = in_mask;
  36. int cc;
  37. asm volatile(
  38. " siga 0\n"
  39. " ipm %0\n"
  40. " srl %0,28\n"
  41. : "=d" (cc)
  42. : "d" (__fc), "d" (__schid), "d" (out), "d" (in) : "cc");
  43. return cc;
  44. }
  45. static inline int do_siga_input(struct subchannel_id schid, unsigned int mask)
  46. {
  47. register unsigned long __fc asm ("0") = 1;
  48. register struct subchannel_id __schid asm ("1") = schid;
  49. register unsigned long __mask asm ("2") = mask;
  50. int cc;
  51. asm volatile(
  52. " siga 0\n"
  53. " ipm %0\n"
  54. " srl %0,28\n"
  55. : "=d" (cc)
  56. : "d" (__fc), "d" (__schid), "d" (__mask) : "cc", "memory");
  57. return cc;
  58. }
  59. /**
  60. * do_siga_output - perform SIGA-w/wt function
  61. * @schid: subchannel id or in case of QEBSM the subchannel token
  62. * @mask: which output queues to process
  63. * @bb: busy bit indicator, set only if SIGA-w/wt could not access a buffer
  64. * @fc: function code to perform
  65. *
  66. * Returns cc or QDIO_ERROR_SIGA_ACCESS_EXCEPTION.
  67. * Note: For IQDC unicast queues only the highest priority queue is processed.
  68. */
  69. static inline int do_siga_output(unsigned long schid, unsigned long mask,
  70. u32 *bb, unsigned int fc)
  71. {
  72. register unsigned long __fc asm("0") = fc;
  73. register unsigned long __schid asm("1") = schid;
  74. register unsigned long __mask asm("2") = mask;
  75. int cc = QDIO_ERROR_SIGA_ACCESS_EXCEPTION;
  76. asm volatile(
  77. " siga 0\n"
  78. "0: ipm %0\n"
  79. " srl %0,28\n"
  80. "1:\n"
  81. EX_TABLE(0b, 1b)
  82. : "+d" (cc), "+d" (__fc), "+d" (__schid), "+d" (__mask)
  83. : : "cc", "memory");
  84. *bb = ((unsigned int) __fc) >> 31;
  85. return cc;
  86. }
  87. static inline int qdio_check_ccq(struct qdio_q *q, unsigned int ccq)
  88. {
  89. char dbf_text[15];
  90. /* all done or next buffer state different */
  91. if (ccq == 0 || ccq == 32)
  92. return 0;
  93. /* not all buffers processed */
  94. if (ccq == 96 || ccq == 97)
  95. return 1;
  96. /* notify devices immediately */
  97. sprintf(dbf_text, "%d", ccq);
  98. QDIO_DBF_TEXT2(1, trace, dbf_text);
  99. return -EIO;
  100. }
  101. /**
  102. * qdio_do_eqbs - extract buffer states for QEBSM
  103. * @q: queue to manipulate
  104. * @state: state of the extracted buffers
  105. * @start: buffer number to start at
  106. * @count: count of buffers to examine
  107. *
  108. * Returns the number of successfull extracted equal buffer states.
  109. * Stops processing if a state is different from the last buffers state.
  110. */
  111. static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
  112. int start, int count)
  113. {
  114. unsigned int ccq = 0;
  115. int tmp_count = count, tmp_start = start;
  116. int nr = q->nr;
  117. int rc;
  118. char dbf_text[15];
  119. BUG_ON(!q->irq_ptr->sch_token);
  120. qdio_perf_stat_inc(&perf_stats.debug_eqbs_all);
  121. if (!q->is_input_q)
  122. nr += q->irq_ptr->nr_input_qs;
  123. again:
  124. ccq = do_eqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count);
  125. rc = qdio_check_ccq(q, ccq);
  126. /* At least one buffer was processed, return and extract the remaining
  127. * buffers later.
  128. */
  129. if ((ccq == 96) && (count != tmp_count)) {
  130. qdio_perf_stat_inc(&perf_stats.debug_eqbs_incomplete);
  131. return (count - tmp_count);
  132. }
  133. if (rc == 1) {
  134. QDIO_DBF_TEXT5(1, trace, "eqAGAIN");
  135. goto again;
  136. }
  137. if (rc < 0) {
  138. QDIO_DBF_TEXT2(1, trace, "eqberr");
  139. sprintf(dbf_text, "%2x,%2x,%d,%d", count, tmp_count, ccq, nr);
  140. QDIO_DBF_TEXT2(1, trace, dbf_text);
  141. q->handler(q->irq_ptr->cdev,
  142. QDIO_ERROR_ACTIVATE_CHECK_CONDITION,
  143. 0, -1, -1, q->irq_ptr->int_parm);
  144. return 0;
  145. }
  146. return count - tmp_count;
  147. }
  148. /**
  149. * qdio_do_sqbs - set buffer states for QEBSM
  150. * @q: queue to manipulate
  151. * @state: new state of the buffers
  152. * @start: first buffer number to change
  153. * @count: how many buffers to change
  154. *
  155. * Returns the number of successfully changed buffers.
  156. * Does retrying until the specified count of buffer states is set or an
  157. * error occurs.
  158. */
  159. static int qdio_do_sqbs(struct qdio_q *q, unsigned char state, int start,
  160. int count)
  161. {
  162. unsigned int ccq = 0;
  163. int tmp_count = count, tmp_start = start;
  164. int nr = q->nr;
  165. int rc;
  166. char dbf_text[15];
  167. BUG_ON(!q->irq_ptr->sch_token);
  168. qdio_perf_stat_inc(&perf_stats.debug_sqbs_all);
  169. if (!q->is_input_q)
  170. nr += q->irq_ptr->nr_input_qs;
  171. again:
  172. ccq = do_sqbs(q->irq_ptr->sch_token, state, nr, &tmp_start, &tmp_count);
  173. rc = qdio_check_ccq(q, ccq);
  174. if (rc == 1) {
  175. QDIO_DBF_TEXT5(1, trace, "sqAGAIN");
  176. qdio_perf_stat_inc(&perf_stats.debug_sqbs_incomplete);
  177. goto again;
  178. }
  179. if (rc < 0) {
  180. QDIO_DBF_TEXT3(1, trace, "sqberr");
  181. sprintf(dbf_text, "%2x,%2x", count, tmp_count);
  182. QDIO_DBF_TEXT3(1, trace, dbf_text);
  183. sprintf(dbf_text, "%d,%d", ccq, nr);
  184. QDIO_DBF_TEXT3(1, trace, dbf_text);
  185. q->handler(q->irq_ptr->cdev,
  186. QDIO_ERROR_ACTIVATE_CHECK_CONDITION,
  187. 0, -1, -1, q->irq_ptr->int_parm);
  188. return 0;
  189. }
  190. WARN_ON(tmp_count);
  191. return count - tmp_count;
  192. }
  193. /* returns number of examined buffers and their common state in *state */
  194. static inline int get_buf_states(struct qdio_q *q, unsigned int bufnr,
  195. unsigned char *state, unsigned int count)
  196. {
  197. unsigned char __state = 0;
  198. int i;
  199. BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK);
  200. BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q);
  201. if (is_qebsm(q))
  202. return qdio_do_eqbs(q, state, bufnr, count);
  203. for (i = 0; i < count; i++) {
  204. if (!__state)
  205. __state = q->slsb.val[bufnr];
  206. else if (q->slsb.val[bufnr] != __state)
  207. break;
  208. bufnr = next_buf(bufnr);
  209. }
  210. *state = __state;
  211. return i;
  212. }
  213. inline int get_buf_state(struct qdio_q *q, unsigned int bufnr,
  214. unsigned char *state)
  215. {
  216. return get_buf_states(q, bufnr, state, 1);
  217. }
  218. /* wrap-around safe setting of slsb states, returns number of changed buffers */
  219. static inline int set_buf_states(struct qdio_q *q, int bufnr,
  220. unsigned char state, int count)
  221. {
  222. int i;
  223. BUG_ON(bufnr > QDIO_MAX_BUFFERS_MASK);
  224. BUG_ON(count > QDIO_MAX_BUFFERS_PER_Q);
  225. if (is_qebsm(q))
  226. return qdio_do_sqbs(q, state, bufnr, count);
  227. for (i = 0; i < count; i++) {
  228. xchg(&q->slsb.val[bufnr], state);
  229. bufnr = next_buf(bufnr);
  230. }
  231. return count;
  232. }
  233. static inline int set_buf_state(struct qdio_q *q, int bufnr,
  234. unsigned char state)
  235. {
  236. return set_buf_states(q, bufnr, state, 1);
  237. }
  238. /* set slsb states to initial state */
  239. void qdio_init_buf_states(struct qdio_irq *irq_ptr)
  240. {
  241. struct qdio_q *q;
  242. int i;
  243. for_each_input_queue(irq_ptr, q, i)
  244. set_buf_states(q, 0, SLSB_P_INPUT_NOT_INIT,
  245. QDIO_MAX_BUFFERS_PER_Q);
  246. for_each_output_queue(irq_ptr, q, i)
  247. set_buf_states(q, 0, SLSB_P_OUTPUT_NOT_INIT,
  248. QDIO_MAX_BUFFERS_PER_Q);
  249. }
  250. static int qdio_siga_sync(struct qdio_q *q, unsigned int output,
  251. unsigned int input)
  252. {
  253. int cc;
  254. if (!need_siga_sync(q))
  255. return 0;
  256. qdio_perf_stat_inc(&perf_stats.siga_sync);
  257. cc = do_siga_sync(q->irq_ptr->schid, output, input);
  258. if (cc) {
  259. QDIO_DBF_TEXT4(0, trace, "sigasync");
  260. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  261. QDIO_DBF_HEX3(0, trace, &cc, sizeof(int *));
  262. }
  263. return cc;
  264. }
  265. inline int qdio_siga_sync_q(struct qdio_q *q)
  266. {
  267. if (q->is_input_q)
  268. return qdio_siga_sync(q, 0, q->mask);
  269. else
  270. return qdio_siga_sync(q, q->mask, 0);
  271. }
  272. static inline int qdio_siga_sync_out(struct qdio_q *q)
  273. {
  274. return qdio_siga_sync(q, ~0U, 0);
  275. }
  276. static inline int qdio_siga_sync_all(struct qdio_q *q)
  277. {
  278. return qdio_siga_sync(q, ~0U, ~0U);
  279. }
  280. static inline int qdio_do_siga_output(struct qdio_q *q, unsigned int *busy_bit)
  281. {
  282. unsigned int fc = 0;
  283. unsigned long schid;
  284. if (q->u.out.use_enh_siga) {
  285. fc = 3;
  286. }
  287. if (!is_qebsm(q))
  288. schid = *((u32 *)&q->irq_ptr->schid);
  289. else {
  290. schid = q->irq_ptr->sch_token;
  291. fc |= 0x80;
  292. }
  293. return do_siga_output(schid, q->mask, busy_bit, fc);
  294. }
  295. static int qdio_siga_output(struct qdio_q *q)
  296. {
  297. int cc;
  298. u32 busy_bit;
  299. u64 start_time = 0;
  300. char dbf_text[15];
  301. QDIO_DBF_TEXT5(0, trace, "sigaout");
  302. QDIO_DBF_HEX5(0, trace, &q, sizeof(void *));
  303. qdio_perf_stat_inc(&perf_stats.siga_out);
  304. again:
  305. cc = qdio_do_siga_output(q, &busy_bit);
  306. if (queue_type(q) == QDIO_IQDIO_QFMT && cc == 2 && busy_bit) {
  307. sprintf(dbf_text, "bb%4x%2x", q->irq_ptr->schid.sch_no, q->nr);
  308. QDIO_DBF_TEXT3(0, trace, dbf_text);
  309. if (!start_time)
  310. start_time = get_usecs();
  311. else if ((get_usecs() - start_time) < QDIO_BUSY_BIT_PATIENCE)
  312. goto again;
  313. }
  314. if (cc == 2 && busy_bit)
  315. cc |= QDIO_ERROR_SIGA_BUSY;
  316. if (cc)
  317. QDIO_DBF_HEX3(0, trace, &cc, sizeof(int *));
  318. return cc;
  319. }
  320. static inline int qdio_siga_input(struct qdio_q *q)
  321. {
  322. int cc;
  323. QDIO_DBF_TEXT4(0, trace, "sigain");
  324. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  325. qdio_perf_stat_inc(&perf_stats.siga_in);
  326. cc = do_siga_input(q->irq_ptr->schid, q->mask);
  327. if (cc)
  328. QDIO_DBF_HEX3(0, trace, &cc, sizeof(int *));
  329. return cc;
  330. }
  331. /* called from thinint inbound handler */
  332. void qdio_sync_after_thinint(struct qdio_q *q)
  333. {
  334. if (pci_out_supported(q)) {
  335. if (need_siga_sync_thinint(q))
  336. qdio_siga_sync_all(q);
  337. else if (need_siga_sync_out_thinint(q))
  338. qdio_siga_sync_out(q);
  339. } else
  340. qdio_siga_sync_q(q);
  341. }
  342. inline void qdio_stop_polling(struct qdio_q *q)
  343. {
  344. spin_lock_bh(&q->u.in.lock);
  345. if (!q->u.in.polling) {
  346. spin_unlock_bh(&q->u.in.lock);
  347. return;
  348. }
  349. q->u.in.polling = 0;
  350. qdio_perf_stat_inc(&perf_stats.debug_stop_polling);
  351. /* show the card that we are not polling anymore */
  352. set_buf_state(q, q->last_move_ftc, SLSB_P_INPUT_NOT_INIT);
  353. spin_unlock_bh(&q->u.in.lock);
  354. }
  355. static void announce_buffer_error(struct qdio_q *q)
  356. {
  357. char dbf_text[15];
  358. if (q->is_input_q)
  359. QDIO_DBF_TEXT3(1, trace, "inperr");
  360. else
  361. QDIO_DBF_TEXT3(0, trace, "outperr");
  362. sprintf(dbf_text, "%x-%x-%x", q->first_to_check,
  363. q->sbal[q->first_to_check]->element[14].flags,
  364. q->sbal[q->first_to_check]->element[15].flags);
  365. QDIO_DBF_TEXT3(1, trace, dbf_text);
  366. QDIO_DBF_HEX2(1, trace, q->sbal[q->first_to_check], 256);
  367. q->qdio_error = QDIO_ERROR_SLSB_STATE;
  368. }
  369. static int get_inbound_buffer_frontier(struct qdio_q *q)
  370. {
  371. int count, stop;
  372. unsigned char state;
  373. /*
  374. * If we still poll don't update last_move_ftc, keep the
  375. * previously ACK buffer there.
  376. */
  377. if (!q->u.in.polling)
  378. q->last_move_ftc = q->first_to_check;
  379. /*
  380. * Don't check 128 buffers, as otherwise qdio_inbound_q_moved
  381. * would return 0.
  382. */
  383. count = min(atomic_read(&q->nr_buf_used), QDIO_MAX_BUFFERS_MASK);
  384. stop = add_buf(q->first_to_check, count);
  385. /*
  386. * No siga sync here, as a PCI or we after a thin interrupt
  387. * will sync the queues.
  388. */
  389. /* need to set count to 1 for non-qebsm */
  390. if (!is_qebsm(q))
  391. count = 1;
  392. check_next:
  393. if (q->first_to_check == stop)
  394. goto out;
  395. count = get_buf_states(q, q->first_to_check, &state, count);
  396. if (!count)
  397. goto out;
  398. switch (state) {
  399. case SLSB_P_INPUT_PRIMED:
  400. QDIO_DBF_TEXT5(0, trace, "inptprim");
  401. /*
  402. * Only ACK the first buffer. The ACK will be removed in
  403. * qdio_stop_polling.
  404. */
  405. if (q->u.in.polling)
  406. state = SLSB_P_INPUT_NOT_INIT;
  407. else {
  408. q->u.in.polling = 1;
  409. state = SLSB_P_INPUT_ACK;
  410. }
  411. set_buf_state(q, q->first_to_check, state);
  412. /*
  413. * Need to change all PRIMED buffers to NOT_INIT, otherwise
  414. * we're loosing initiative in the thinint code.
  415. */
  416. if (count > 1)
  417. set_buf_states(q, next_buf(q->first_to_check),
  418. SLSB_P_INPUT_NOT_INIT, count - 1);
  419. /*
  420. * No siga-sync needed for non-qebsm here, as the inbound queue
  421. * will be synced on the next siga-r, resp.
  422. * tiqdio_is_inbound_q_done will do the siga-sync.
  423. */
  424. q->first_to_check = add_buf(q->first_to_check, count);
  425. atomic_sub(count, &q->nr_buf_used);
  426. goto check_next;
  427. case SLSB_P_INPUT_ERROR:
  428. announce_buffer_error(q);
  429. /* process the buffer, the upper layer will take care of it */
  430. q->first_to_check = add_buf(q->first_to_check, count);
  431. atomic_sub(count, &q->nr_buf_used);
  432. break;
  433. case SLSB_CU_INPUT_EMPTY:
  434. case SLSB_P_INPUT_NOT_INIT:
  435. case SLSB_P_INPUT_ACK:
  436. QDIO_DBF_TEXT5(0, trace, "inpnipro");
  437. break;
  438. default:
  439. BUG();
  440. }
  441. out:
  442. QDIO_DBF_HEX4(0, trace, &q->first_to_check, sizeof(int));
  443. return q->first_to_check;
  444. }
  445. int qdio_inbound_q_moved(struct qdio_q *q)
  446. {
  447. int bufnr;
  448. bufnr = get_inbound_buffer_frontier(q);
  449. if ((bufnr != q->last_move_ftc) || q->qdio_error) {
  450. if (!need_siga_sync(q) && !pci_out_supported(q))
  451. q->u.in.timestamp = get_usecs();
  452. QDIO_DBF_TEXT4(0, trace, "inhasmvd");
  453. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  454. return 1;
  455. } else
  456. return 0;
  457. }
  458. static int qdio_inbound_q_done(struct qdio_q *q)
  459. {
  460. unsigned char state = 0;
  461. #ifdef CONFIG_QDIO_DEBUG
  462. char dbf_text[15];
  463. #endif
  464. if (!atomic_read(&q->nr_buf_used))
  465. return 1;
  466. /*
  467. * We need that one for synchronization with the adapter, as it
  468. * does a kind of PCI avoidance.
  469. */
  470. qdio_siga_sync_q(q);
  471. get_buf_state(q, q->first_to_check, &state);
  472. if (state == SLSB_P_INPUT_PRIMED)
  473. /* we got something to do */
  474. return 0;
  475. /* on VM, we don't poll, so the q is always done here */
  476. if (need_siga_sync(q) || pci_out_supported(q))
  477. return 1;
  478. /*
  479. * At this point we know, that inbound first_to_check
  480. * has (probably) not moved (see qdio_inbound_processing).
  481. */
  482. if (get_usecs() > q->u.in.timestamp + QDIO_INPUT_THRESHOLD) {
  483. #ifdef CONFIG_QDIO_DEBUG
  484. QDIO_DBF_TEXT4(0, trace, "inqisdon");
  485. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  486. sprintf(dbf_text, "pf%02x", q->first_to_check);
  487. QDIO_DBF_TEXT4(0, trace, dbf_text);
  488. #endif /* CONFIG_QDIO_DEBUG */
  489. return 1;
  490. } else {
  491. #ifdef CONFIG_QDIO_DEBUG
  492. QDIO_DBF_TEXT4(0, trace, "inqisntd");
  493. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  494. sprintf(dbf_text, "pf%02x", q->first_to_check);
  495. QDIO_DBF_TEXT4(0, trace, dbf_text);
  496. #endif /* CONFIG_QDIO_DEBUG */
  497. return 0;
  498. }
  499. }
  500. void qdio_kick_inbound_handler(struct qdio_q *q)
  501. {
  502. int count, start, end;
  503. #ifdef CONFIG_QDIO_DEBUG
  504. char dbf_text[15];
  505. #endif
  506. qdio_perf_stat_inc(&perf_stats.inbound_handler);
  507. start = q->first_to_kick;
  508. end = q->first_to_check;
  509. if (end >= start)
  510. count = end - start;
  511. else
  512. count = end + QDIO_MAX_BUFFERS_PER_Q - start;
  513. #ifdef CONFIG_QDIO_DEBUG
  514. sprintf(dbf_text, "s=%2xc=%2x", start, count);
  515. QDIO_DBF_TEXT4(0, trace, dbf_text);
  516. #endif /* CONFIG_QDIO_DEBUG */
  517. if (unlikely(q->irq_ptr->state != QDIO_IRQ_STATE_ACTIVE))
  518. return;
  519. q->handler(q->irq_ptr->cdev, q->qdio_error, q->nr,
  520. start, count, q->irq_ptr->int_parm);
  521. /* for the next time */
  522. q->first_to_kick = q->first_to_check;
  523. q->qdio_error = 0;
  524. }
  525. static void __qdio_inbound_processing(struct qdio_q *q)
  526. {
  527. qdio_perf_stat_inc(&perf_stats.tasklet_inbound);
  528. again:
  529. if (!qdio_inbound_q_moved(q))
  530. return;
  531. qdio_kick_inbound_handler(q);
  532. if (!qdio_inbound_q_done(q))
  533. /* means poll time is not yet over */
  534. goto again;
  535. qdio_stop_polling(q);
  536. /*
  537. * We need to check again to not lose initiative after
  538. * resetting the ACK state.
  539. */
  540. if (!qdio_inbound_q_done(q))
  541. goto again;
  542. }
  543. /* inbound tasklet */
  544. void qdio_inbound_processing(unsigned long data)
  545. {
  546. struct qdio_q *q = (struct qdio_q *)data;
  547. __qdio_inbound_processing(q);
  548. }
  549. static int get_outbound_buffer_frontier(struct qdio_q *q)
  550. {
  551. int count, stop;
  552. unsigned char state;
  553. if (((queue_type(q) != QDIO_IQDIO_QFMT) && !pci_out_supported(q)) ||
  554. (queue_type(q) == QDIO_IQDIO_QFMT && multicast_outbound(q)))
  555. qdio_siga_sync_q(q);
  556. /*
  557. * Don't check 128 buffers, as otherwise qdio_inbound_q_moved
  558. * would return 0.
  559. */
  560. count = min(atomic_read(&q->nr_buf_used), QDIO_MAX_BUFFERS_MASK);
  561. stop = add_buf(q->first_to_check, count);
  562. /* need to set count to 1 for non-qebsm */
  563. if (!is_qebsm(q))
  564. count = 1;
  565. check_next:
  566. if (q->first_to_check == stop)
  567. return q->first_to_check;
  568. count = get_buf_states(q, q->first_to_check, &state, count);
  569. if (!count)
  570. return q->first_to_check;
  571. switch (state) {
  572. case SLSB_P_OUTPUT_EMPTY:
  573. /* the adapter got it */
  574. QDIO_DBF_TEXT5(0, trace, "outpempt");
  575. atomic_sub(count, &q->nr_buf_used);
  576. q->first_to_check = add_buf(q->first_to_check, count);
  577. /*
  578. * We fetch all buffer states at once. get_buf_states may
  579. * return count < stop. For QEBSM we do not loop.
  580. */
  581. if (is_qebsm(q))
  582. break;
  583. goto check_next;
  584. case SLSB_P_OUTPUT_ERROR:
  585. announce_buffer_error(q);
  586. /* process the buffer, the upper layer will take care of it */
  587. q->first_to_check = add_buf(q->first_to_check, count);
  588. atomic_sub(count, &q->nr_buf_used);
  589. break;
  590. case SLSB_CU_OUTPUT_PRIMED:
  591. /* the adapter has not fetched the output yet */
  592. QDIO_DBF_TEXT5(0, trace, "outpprim");
  593. break;
  594. case SLSB_P_OUTPUT_NOT_INIT:
  595. case SLSB_P_OUTPUT_HALTED:
  596. break;
  597. default:
  598. BUG();
  599. }
  600. return q->first_to_check;
  601. }
  602. /* all buffers processed? */
  603. static inline int qdio_outbound_q_done(struct qdio_q *q)
  604. {
  605. return atomic_read(&q->nr_buf_used) == 0;
  606. }
  607. static inline int qdio_outbound_q_moved(struct qdio_q *q)
  608. {
  609. int bufnr;
  610. bufnr = get_outbound_buffer_frontier(q);
  611. if ((bufnr != q->last_move_ftc) || q->qdio_error) {
  612. q->last_move_ftc = bufnr;
  613. QDIO_DBF_TEXT4(0, trace, "oqhasmvd");
  614. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  615. return 1;
  616. } else
  617. return 0;
  618. }
  619. /*
  620. * VM could present us cc=2 and busy bit set on SIGA-write
  621. * during reconfiguration of their Guest LAN (only in iqdio mode,
  622. * otherwise qdio is asynchronous and cc=2 and busy bit there will take
  623. * the queues down immediately).
  624. *
  625. * Therefore qdio_siga_output will try for a short time constantly,
  626. * if such a condition occurs. If it doesn't change, it will
  627. * increase the busy_siga_counter and save the timestamp, and
  628. * schedule the queue for later processing. qdio_outbound_processing
  629. * will check out the counter. If non-zero, it will call qdio_kick_outbound_q
  630. * as often as the value of the counter. This will attempt further SIGA
  631. * instructions. For each successful SIGA, the counter is
  632. * decreased, for failing SIGAs the counter remains the same, after
  633. * all. After some time of no movement, qdio_kick_outbound_q will
  634. * finally fail and reflect corresponding error codes to call
  635. * the upper layer module and have it take the queues down.
  636. *
  637. * Note that this is a change from the original HiperSockets design
  638. * (saying cc=2 and busy bit means take the queues down), but in
  639. * these days Guest LAN didn't exist... excessive cc=2 with busy bit
  640. * conditions will still take the queues down, but the threshold is
  641. * higher due to the Guest LAN environment.
  642. *
  643. * Called from outbound tasklet and do_QDIO handler.
  644. */
  645. static void qdio_kick_outbound_q(struct qdio_q *q)
  646. {
  647. int rc;
  648. #ifdef CONFIG_QDIO_DEBUG
  649. char dbf_text[15];
  650. QDIO_DBF_TEXT5(0, trace, "kickoutq");
  651. QDIO_DBF_HEX5(0, trace, &q, sizeof(void *));
  652. #endif /* CONFIG_QDIO_DEBUG */
  653. if (!need_siga_out(q))
  654. return;
  655. rc = qdio_siga_output(q);
  656. switch (rc) {
  657. case 0:
  658. /* TODO: improve error handling for CC=0 case */
  659. #ifdef CONFIG_QDIO_DEBUG
  660. if (q->u.out.timestamp) {
  661. QDIO_DBF_TEXT3(0, trace, "cc2reslv");
  662. sprintf(dbf_text, "%4x%2x%2x", q->irq_ptr->schid.sch_no,
  663. q->nr,
  664. atomic_read(&q->u.out.busy_siga_counter));
  665. QDIO_DBF_TEXT3(0, trace, dbf_text);
  666. }
  667. #endif /* CONFIG_QDIO_DEBUG */
  668. /* went smooth this time, reset timestamp */
  669. q->u.out.timestamp = 0;
  670. break;
  671. /* cc=2 and busy bit */
  672. case (2 | QDIO_ERROR_SIGA_BUSY):
  673. atomic_inc(&q->u.out.busy_siga_counter);
  674. /* if the last siga was successful, save timestamp here */
  675. if (!q->u.out.timestamp)
  676. q->u.out.timestamp = get_usecs();
  677. /* if we're in time, don't touch qdio_error */
  678. if (get_usecs() - q->u.out.timestamp < QDIO_BUSY_BIT_GIVE_UP) {
  679. tasklet_schedule(&q->tasklet);
  680. break;
  681. }
  682. QDIO_DBF_TEXT2(0, trace, "cc2REPRT");
  683. #ifdef CONFIG_QDIO_DEBUG
  684. sprintf(dbf_text, "%4x%2x%2x", q->irq_ptr->schid.sch_no, q->nr,
  685. atomic_read(&q->u.out.busy_siga_counter));
  686. QDIO_DBF_TEXT3(0, trace, dbf_text);
  687. #endif /* CONFIG_QDIO_DEBUG */
  688. default:
  689. /* for plain cc=1, 2 or 3 */
  690. q->qdio_error = rc;
  691. }
  692. }
  693. static void qdio_kick_outbound_handler(struct qdio_q *q)
  694. {
  695. int start, end, count;
  696. #ifdef CONFIG_QDIO_DEBUG
  697. char dbf_text[15];
  698. #endif
  699. start = q->first_to_kick;
  700. end = q->last_move_ftc;
  701. if (end >= start)
  702. count = end - start;
  703. else
  704. count = end + QDIO_MAX_BUFFERS_PER_Q - start;
  705. #ifdef CONFIG_QDIO_DEBUG
  706. QDIO_DBF_TEXT4(0, trace, "kickouth");
  707. QDIO_DBF_HEX4(0, trace, &q, sizeof(void *));
  708. sprintf(dbf_text, "s=%2xc=%2x", start, count);
  709. QDIO_DBF_TEXT4(0, trace, dbf_text);
  710. #endif /* CONFIG_QDIO_DEBUG */
  711. if (unlikely(q->irq_ptr->state != QDIO_IRQ_STATE_ACTIVE))
  712. return;
  713. q->handler(q->irq_ptr->cdev, q->qdio_error, q->nr, start, count,
  714. q->irq_ptr->int_parm);
  715. /* for the next time: */
  716. q->first_to_kick = q->last_move_ftc;
  717. q->qdio_error = 0;
  718. }
  719. static void __qdio_outbound_processing(struct qdio_q *q)
  720. {
  721. int siga_attempts;
  722. qdio_perf_stat_inc(&perf_stats.tasklet_outbound);
  723. /* see comment in qdio_kick_outbound_q */
  724. siga_attempts = atomic_read(&q->u.out.busy_siga_counter);
  725. while (siga_attempts--) {
  726. atomic_dec(&q->u.out.busy_siga_counter);
  727. qdio_kick_outbound_q(q);
  728. }
  729. BUG_ON(atomic_read(&q->nr_buf_used) < 0);
  730. if (qdio_outbound_q_moved(q))
  731. qdio_kick_outbound_handler(q);
  732. if (queue_type(q) == QDIO_ZFCP_QFMT) {
  733. if (!pci_out_supported(q) && !qdio_outbound_q_done(q))
  734. tasklet_schedule(&q->tasklet);
  735. return;
  736. }
  737. /* bail out for HiperSockets unicast queues */
  738. if (queue_type(q) == QDIO_IQDIO_QFMT && !multicast_outbound(q))
  739. return;
  740. if ((queue_type(q) == QDIO_IQDIO_QFMT) &&
  741. (atomic_read(&q->nr_buf_used)) > QDIO_IQDIO_POLL_LVL) {
  742. tasklet_schedule(&q->tasklet);
  743. return;
  744. }
  745. if (q->u.out.pci_out_enabled)
  746. return;
  747. /*
  748. * Now we know that queue type is either qeth without pci enabled
  749. * or HiperSockets multicast. Make sure buffer switch from PRIMED to
  750. * EMPTY is noticed and outbound_handler is called after some time.
  751. */
  752. if (qdio_outbound_q_done(q))
  753. del_timer(&q->u.out.timer);
  754. else {
  755. if (!timer_pending(&q->u.out.timer)) {
  756. mod_timer(&q->u.out.timer, jiffies + 10 * HZ);
  757. qdio_perf_stat_inc(&perf_stats.debug_tl_out_timer);
  758. }
  759. }
  760. }
  761. /* outbound tasklet */
  762. void qdio_outbound_processing(unsigned long data)
  763. {
  764. struct qdio_q *q = (struct qdio_q *)data;
  765. __qdio_outbound_processing(q);
  766. }
  767. void qdio_outbound_timer(unsigned long data)
  768. {
  769. struct qdio_q *q = (struct qdio_q *)data;
  770. tasklet_schedule(&q->tasklet);
  771. }
  772. /* called from thinint inbound tasklet */
  773. void qdio_check_outbound_after_thinint(struct qdio_q *q)
  774. {
  775. struct qdio_q *out;
  776. int i;
  777. if (!pci_out_supported(q))
  778. return;
  779. for_each_output_queue(q->irq_ptr, out, i)
  780. if (!qdio_outbound_q_done(out))
  781. tasklet_schedule(&out->tasklet);
  782. }
  783. static inline void qdio_set_state(struct qdio_irq *irq_ptr,
  784. enum qdio_irq_states state)
  785. {
  786. #ifdef CONFIG_QDIO_DEBUG
  787. char dbf_text[15];
  788. QDIO_DBF_TEXT5(0, trace, "newstate");
  789. sprintf(dbf_text, "%4x%4x", irq_ptr->schid.sch_no, state);
  790. QDIO_DBF_TEXT5(0, trace, dbf_text);
  791. #endif /* CONFIG_QDIO_DEBUG */
  792. irq_ptr->state = state;
  793. mb();
  794. }
  795. static void qdio_irq_check_sense(struct subchannel_id schid, struct irb *irb)
  796. {
  797. char dbf_text[15];
  798. if (irb->esw.esw0.erw.cons) {
  799. sprintf(dbf_text, "sens%4x", schid.sch_no);
  800. QDIO_DBF_TEXT2(1, trace, dbf_text);
  801. QDIO_DBF_HEX0(0, trace, irb, 64);
  802. QDIO_DBF_HEX0(0, trace, irb->ecw, 64);
  803. }
  804. }
  805. /* PCI interrupt handler */
  806. static void qdio_int_handler_pci(struct qdio_irq *irq_ptr)
  807. {
  808. int i;
  809. struct qdio_q *q;
  810. qdio_perf_stat_inc(&perf_stats.pci_int);
  811. for_each_input_queue(irq_ptr, q, i)
  812. tasklet_schedule(&q->tasklet);
  813. if (!(irq_ptr->qib.ac & QIB_AC_OUTBOUND_PCI_SUPPORTED))
  814. return;
  815. for_each_output_queue(irq_ptr, q, i) {
  816. if (qdio_outbound_q_done(q))
  817. continue;
  818. if (!siga_syncs_out_pci(q))
  819. qdio_siga_sync_q(q);
  820. tasklet_schedule(&q->tasklet);
  821. }
  822. }
  823. static void qdio_handle_activate_check(struct ccw_device *cdev,
  824. unsigned long intparm, int cstat, int dstat)
  825. {
  826. struct qdio_irq *irq_ptr = cdev->private->qdio_data;
  827. struct qdio_q *q;
  828. char dbf_text[15];
  829. QDIO_DBF_TEXT2(1, trace, "ick2");
  830. sprintf(dbf_text, "%s", dev_name(&cdev->dev));
  831. QDIO_DBF_TEXT2(1, trace, dbf_text);
  832. QDIO_DBF_HEX2(0, trace, &intparm, sizeof(int));
  833. QDIO_DBF_HEX2(0, trace, &dstat, sizeof(int));
  834. QDIO_DBF_HEX2(0, trace, &cstat, sizeof(int));
  835. if (irq_ptr->nr_input_qs) {
  836. q = irq_ptr->input_qs[0];
  837. } else if (irq_ptr->nr_output_qs) {
  838. q = irq_ptr->output_qs[0];
  839. } else {
  840. dump_stack();
  841. goto no_handler;
  842. }
  843. q->handler(q->irq_ptr->cdev, QDIO_ERROR_ACTIVATE_CHECK_CONDITION,
  844. 0, -1, -1, irq_ptr->int_parm);
  845. no_handler:
  846. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED);
  847. }
  848. static void qdio_call_shutdown(struct work_struct *work)
  849. {
  850. struct ccw_device_private *priv;
  851. struct ccw_device *cdev;
  852. priv = container_of(work, struct ccw_device_private, kick_work);
  853. cdev = priv->cdev;
  854. qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
  855. put_device(&cdev->dev);
  856. }
  857. static void qdio_int_error(struct ccw_device *cdev)
  858. {
  859. struct qdio_irq *irq_ptr = cdev->private->qdio_data;
  860. switch (irq_ptr->state) {
  861. case QDIO_IRQ_STATE_INACTIVE:
  862. case QDIO_IRQ_STATE_CLEANUP:
  863. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
  864. break;
  865. case QDIO_IRQ_STATE_ESTABLISHED:
  866. case QDIO_IRQ_STATE_ACTIVE:
  867. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED);
  868. if (get_device(&cdev->dev)) {
  869. /* Can't call shutdown from interrupt context. */
  870. PREPARE_WORK(&cdev->private->kick_work,
  871. qdio_call_shutdown);
  872. queue_work(ccw_device_work, &cdev->private->kick_work);
  873. }
  874. break;
  875. default:
  876. WARN_ON(1);
  877. }
  878. wake_up(&cdev->private->wait_q);
  879. }
  880. static int qdio_establish_check_errors(struct ccw_device *cdev, int cstat,
  881. int dstat)
  882. {
  883. struct qdio_irq *irq_ptr = cdev->private->qdio_data;
  884. if (cstat || (dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
  885. QDIO_DBF_TEXT2(1, setup, "eq:ckcon");
  886. goto error;
  887. }
  888. if (!(dstat & DEV_STAT_DEV_END)) {
  889. QDIO_DBF_TEXT2(1, setup, "eq:no de");
  890. goto error;
  891. }
  892. if (dstat & ~(DEV_STAT_CHN_END | DEV_STAT_DEV_END)) {
  893. QDIO_DBF_TEXT2(1, setup, "eq:badio");
  894. goto error;
  895. }
  896. return 0;
  897. error:
  898. QDIO_DBF_HEX2(0, trace, &cstat, sizeof(int));
  899. QDIO_DBF_HEX2(0, trace, &dstat, sizeof(int));
  900. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
  901. return 1;
  902. }
  903. static void qdio_establish_handle_irq(struct ccw_device *cdev, int cstat,
  904. int dstat)
  905. {
  906. struct qdio_irq *irq_ptr = cdev->private->qdio_data;
  907. char dbf_text[15];
  908. sprintf(dbf_text, "qehi%4x", cdev->private->schid.sch_no);
  909. QDIO_DBF_TEXT0(0, setup, dbf_text);
  910. QDIO_DBF_TEXT0(0, trace, dbf_text);
  911. if (!qdio_establish_check_errors(cdev, cstat, dstat))
  912. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ESTABLISHED);
  913. }
  914. /* qdio interrupt handler */
  915. void qdio_int_handler(struct ccw_device *cdev, unsigned long intparm,
  916. struct irb *irb)
  917. {
  918. struct qdio_irq *irq_ptr = cdev->private->qdio_data;
  919. int cstat, dstat;
  920. char dbf_text[15];
  921. qdio_perf_stat_inc(&perf_stats.qdio_int);
  922. if (!intparm || !irq_ptr) {
  923. sprintf(dbf_text, "qihd%4x", cdev->private->schid.sch_no);
  924. QDIO_DBF_TEXT2(1, setup, dbf_text);
  925. return;
  926. }
  927. if (IS_ERR(irb)) {
  928. switch (PTR_ERR(irb)) {
  929. case -EIO:
  930. sprintf(dbf_text, "ierr%4x", irq_ptr->schid.sch_no);
  931. QDIO_DBF_TEXT2(1, setup, dbf_text);
  932. return;
  933. case -ETIMEDOUT:
  934. sprintf(dbf_text, "qtoh%4x", irq_ptr->schid.sch_no);
  935. QDIO_DBF_TEXT2(1, setup, dbf_text);
  936. qdio_int_error(cdev);
  937. return;
  938. default:
  939. WARN_ON(1);
  940. return;
  941. }
  942. }
  943. qdio_irq_check_sense(irq_ptr->schid, irb);
  944. cstat = irb->scsw.cmd.cstat;
  945. dstat = irb->scsw.cmd.dstat;
  946. switch (irq_ptr->state) {
  947. case QDIO_IRQ_STATE_INACTIVE:
  948. qdio_establish_handle_irq(cdev, cstat, dstat);
  949. break;
  950. case QDIO_IRQ_STATE_CLEANUP:
  951. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
  952. break;
  953. case QDIO_IRQ_STATE_ESTABLISHED:
  954. case QDIO_IRQ_STATE_ACTIVE:
  955. if (cstat & SCHN_STAT_PCI) {
  956. qdio_int_handler_pci(irq_ptr);
  957. /* no state change so no need to wake up wait_q */
  958. return;
  959. }
  960. if ((cstat & ~SCHN_STAT_PCI) || dstat) {
  961. qdio_handle_activate_check(cdev, intparm, cstat,
  962. dstat);
  963. break;
  964. }
  965. default:
  966. WARN_ON(1);
  967. }
  968. wake_up(&cdev->private->wait_q);
  969. }
  970. /**
  971. * qdio_get_ssqd_desc - get qdio subchannel description
  972. * @cdev: ccw device to get description for
  973. * @data: where to store the ssqd
  974. *
  975. * Returns 0 or an error code. The results of the chsc are stored in the
  976. * specified structure.
  977. */
  978. int qdio_get_ssqd_desc(struct ccw_device *cdev,
  979. struct qdio_ssqd_desc *data)
  980. {
  981. char dbf_text[15];
  982. if (!cdev || !cdev->private)
  983. return -EINVAL;
  984. sprintf(dbf_text, "qssq%4x", cdev->private->schid.sch_no);
  985. QDIO_DBF_TEXT0(0, setup, dbf_text);
  986. return qdio_setup_get_ssqd(NULL, &cdev->private->schid, data);
  987. }
  988. EXPORT_SYMBOL_GPL(qdio_get_ssqd_desc);
  989. /**
  990. * qdio_cleanup - shutdown queues and free data structures
  991. * @cdev: associated ccw device
  992. * @how: use halt or clear to shutdown
  993. *
  994. * This function calls qdio_shutdown() for @cdev with method @how
  995. * and on success qdio_free() for @cdev.
  996. */
  997. int qdio_cleanup(struct ccw_device *cdev, int how)
  998. {
  999. struct qdio_irq *irq_ptr;
  1000. char dbf_text[15];
  1001. int rc;
  1002. sprintf(dbf_text, "qcln%4x", cdev->private->schid.sch_no);
  1003. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1004. irq_ptr = cdev->private->qdio_data;
  1005. if (!irq_ptr)
  1006. return -ENODEV;
  1007. rc = qdio_shutdown(cdev, how);
  1008. if (rc == 0)
  1009. rc = qdio_free(cdev);
  1010. return rc;
  1011. }
  1012. EXPORT_SYMBOL_GPL(qdio_cleanup);
  1013. static void qdio_shutdown_queues(struct ccw_device *cdev)
  1014. {
  1015. struct qdio_irq *irq_ptr = cdev->private->qdio_data;
  1016. struct qdio_q *q;
  1017. int i;
  1018. for_each_input_queue(irq_ptr, q, i)
  1019. tasklet_disable(&q->tasklet);
  1020. for_each_output_queue(irq_ptr, q, i) {
  1021. tasklet_disable(&q->tasklet);
  1022. del_timer(&q->u.out.timer);
  1023. }
  1024. }
  1025. /**
  1026. * qdio_shutdown - shut down a qdio subchannel
  1027. * @cdev: associated ccw device
  1028. * @how: use halt or clear to shutdown
  1029. */
  1030. int qdio_shutdown(struct ccw_device *cdev, int how)
  1031. {
  1032. struct qdio_irq *irq_ptr;
  1033. int rc;
  1034. unsigned long flags;
  1035. char dbf_text[15];
  1036. sprintf(dbf_text, "qshu%4x", cdev->private->schid.sch_no);
  1037. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1038. irq_ptr = cdev->private->qdio_data;
  1039. if (!irq_ptr)
  1040. return -ENODEV;
  1041. mutex_lock(&irq_ptr->setup_mutex);
  1042. /*
  1043. * Subchannel was already shot down. We cannot prevent being called
  1044. * twice since cio may trigger a shutdown asynchronously.
  1045. */
  1046. if (irq_ptr->state == QDIO_IRQ_STATE_INACTIVE) {
  1047. mutex_unlock(&irq_ptr->setup_mutex);
  1048. return 0;
  1049. }
  1050. tiqdio_remove_input_queues(irq_ptr);
  1051. qdio_shutdown_queues(cdev);
  1052. qdio_shutdown_debug_entries(irq_ptr, cdev);
  1053. /* cleanup subchannel */
  1054. spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
  1055. if (how & QDIO_FLAG_CLEANUP_USING_CLEAR)
  1056. rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
  1057. else
  1058. /* default behaviour is halt */
  1059. rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
  1060. if (rc) {
  1061. sprintf(dbf_text, "sher%4x", irq_ptr->schid.sch_no);
  1062. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1063. sprintf(dbf_text, "rc=%d", rc);
  1064. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1065. goto no_cleanup;
  1066. }
  1067. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
  1068. spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
  1069. wait_event_interruptible_timeout(cdev->private->wait_q,
  1070. irq_ptr->state == QDIO_IRQ_STATE_INACTIVE ||
  1071. irq_ptr->state == QDIO_IRQ_STATE_ERR,
  1072. 10 * HZ);
  1073. spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
  1074. no_cleanup:
  1075. qdio_shutdown_thinint(irq_ptr);
  1076. /* restore interrupt handler */
  1077. if ((void *)cdev->handler == (void *)qdio_int_handler)
  1078. cdev->handler = irq_ptr->orig_handler;
  1079. spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
  1080. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
  1081. mutex_unlock(&irq_ptr->setup_mutex);
  1082. if (rc)
  1083. return rc;
  1084. return 0;
  1085. }
  1086. EXPORT_SYMBOL_GPL(qdio_shutdown);
  1087. /**
  1088. * qdio_free - free data structures for a qdio subchannel
  1089. * @cdev: associated ccw device
  1090. */
  1091. int qdio_free(struct ccw_device *cdev)
  1092. {
  1093. struct qdio_irq *irq_ptr;
  1094. char dbf_text[15];
  1095. sprintf(dbf_text, "qfre%4x", cdev->private->schid.sch_no);
  1096. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1097. irq_ptr = cdev->private->qdio_data;
  1098. if (!irq_ptr)
  1099. return -ENODEV;
  1100. mutex_lock(&irq_ptr->setup_mutex);
  1101. cdev->private->qdio_data = NULL;
  1102. mutex_unlock(&irq_ptr->setup_mutex);
  1103. qdio_release_memory(irq_ptr);
  1104. return 0;
  1105. }
  1106. EXPORT_SYMBOL_GPL(qdio_free);
  1107. /**
  1108. * qdio_initialize - allocate and establish queues for a qdio subchannel
  1109. * @init_data: initialization data
  1110. *
  1111. * This function first allocates queues via qdio_allocate() and on success
  1112. * establishes them via qdio_establish().
  1113. */
  1114. int qdio_initialize(struct qdio_initialize *init_data)
  1115. {
  1116. int rc;
  1117. char dbf_text[15];
  1118. sprintf(dbf_text, "qini%4x", init_data->cdev->private->schid.sch_no);
  1119. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1120. rc = qdio_allocate(init_data);
  1121. if (rc)
  1122. return rc;
  1123. rc = qdio_establish(init_data);
  1124. if (rc)
  1125. qdio_free(init_data->cdev);
  1126. return rc;
  1127. }
  1128. EXPORT_SYMBOL_GPL(qdio_initialize);
  1129. /**
  1130. * qdio_allocate - allocate qdio queues and associated data
  1131. * @init_data: initialization data
  1132. */
  1133. int qdio_allocate(struct qdio_initialize *init_data)
  1134. {
  1135. struct qdio_irq *irq_ptr;
  1136. char dbf_text[15];
  1137. sprintf(dbf_text, "qalc%4x", init_data->cdev->private->schid.sch_no);
  1138. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1139. if ((init_data->no_input_qs && !init_data->input_handler) ||
  1140. (init_data->no_output_qs && !init_data->output_handler))
  1141. return -EINVAL;
  1142. if ((init_data->no_input_qs > QDIO_MAX_QUEUES_PER_IRQ) ||
  1143. (init_data->no_output_qs > QDIO_MAX_QUEUES_PER_IRQ))
  1144. return -EINVAL;
  1145. if ((!init_data->input_sbal_addr_array) ||
  1146. (!init_data->output_sbal_addr_array))
  1147. return -EINVAL;
  1148. qdio_allocate_do_dbf(init_data);
  1149. /* irq_ptr must be in GFP_DMA since it contains ccw1.cda */
  1150. irq_ptr = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  1151. if (!irq_ptr)
  1152. goto out_err;
  1153. QDIO_DBF_TEXT0(0, setup, "irq_ptr:");
  1154. QDIO_DBF_HEX0(0, setup, &irq_ptr, sizeof(void *));
  1155. mutex_init(&irq_ptr->setup_mutex);
  1156. /*
  1157. * Allocate a page for the chsc calls in qdio_establish.
  1158. * Must be pre-allocated since a zfcp recovery will call
  1159. * qdio_establish. In case of low memory and swap on a zfcp disk
  1160. * we may not be able to allocate memory otherwise.
  1161. */
  1162. irq_ptr->chsc_page = get_zeroed_page(GFP_KERNEL);
  1163. if (!irq_ptr->chsc_page)
  1164. goto out_rel;
  1165. /* qdr is used in ccw1.cda which is u32 */
  1166. irq_ptr->qdr = (struct qdr *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
  1167. if (!irq_ptr->qdr)
  1168. goto out_rel;
  1169. WARN_ON((unsigned long)irq_ptr->qdr & 0xfff);
  1170. QDIO_DBF_TEXT0(0, setup, "qdr:");
  1171. QDIO_DBF_HEX0(0, setup, &irq_ptr->qdr, sizeof(void *));
  1172. if (qdio_allocate_qs(irq_ptr, init_data->no_input_qs,
  1173. init_data->no_output_qs))
  1174. goto out_rel;
  1175. init_data->cdev->private->qdio_data = irq_ptr;
  1176. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
  1177. return 0;
  1178. out_rel:
  1179. qdio_release_memory(irq_ptr);
  1180. out_err:
  1181. return -ENOMEM;
  1182. }
  1183. EXPORT_SYMBOL_GPL(qdio_allocate);
  1184. /**
  1185. * qdio_establish - establish queues on a qdio subchannel
  1186. * @init_data: initialization data
  1187. */
  1188. int qdio_establish(struct qdio_initialize *init_data)
  1189. {
  1190. char dbf_text[20];
  1191. struct qdio_irq *irq_ptr;
  1192. struct ccw_device *cdev = init_data->cdev;
  1193. unsigned long saveflags;
  1194. int rc;
  1195. sprintf(dbf_text, "qest%4x", cdev->private->schid.sch_no);
  1196. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1197. irq_ptr = cdev->private->qdio_data;
  1198. if (!irq_ptr)
  1199. return -ENODEV;
  1200. if (cdev->private->state != DEV_STATE_ONLINE)
  1201. return -EINVAL;
  1202. mutex_lock(&irq_ptr->setup_mutex);
  1203. qdio_setup_irq(init_data);
  1204. rc = qdio_establish_thinint(irq_ptr);
  1205. if (rc) {
  1206. mutex_unlock(&irq_ptr->setup_mutex);
  1207. qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
  1208. return rc;
  1209. }
  1210. /* establish q */
  1211. irq_ptr->ccw.cmd_code = irq_ptr->equeue.cmd;
  1212. irq_ptr->ccw.flags = CCW_FLAG_SLI;
  1213. irq_ptr->ccw.count = irq_ptr->equeue.count;
  1214. irq_ptr->ccw.cda = (u32)((addr_t)irq_ptr->qdr);
  1215. spin_lock_irqsave(get_ccwdev_lock(cdev), saveflags);
  1216. ccw_device_set_options_mask(cdev, 0);
  1217. rc = ccw_device_start(cdev, &irq_ptr->ccw, QDIO_DOING_ESTABLISH, 0, 0);
  1218. if (rc) {
  1219. sprintf(dbf_text, "eq:io%4x", irq_ptr->schid.sch_no);
  1220. QDIO_DBF_TEXT2(1, setup, dbf_text);
  1221. sprintf(dbf_text, "eq:rc%4x", rc);
  1222. QDIO_DBF_TEXT2(1, setup, dbf_text);
  1223. }
  1224. spin_unlock_irqrestore(get_ccwdev_lock(cdev), saveflags);
  1225. if (rc) {
  1226. mutex_unlock(&irq_ptr->setup_mutex);
  1227. qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
  1228. return rc;
  1229. }
  1230. wait_event_interruptible_timeout(cdev->private->wait_q,
  1231. irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED ||
  1232. irq_ptr->state == QDIO_IRQ_STATE_ERR, HZ);
  1233. if (irq_ptr->state != QDIO_IRQ_STATE_ESTABLISHED) {
  1234. mutex_unlock(&irq_ptr->setup_mutex);
  1235. qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
  1236. return -EIO;
  1237. }
  1238. qdio_setup_ssqd_info(irq_ptr);
  1239. sprintf(dbf_text, "qDmmwc%2x", irq_ptr->ssqd_desc.mmwc);
  1240. QDIO_DBF_TEXT2(0, setup, dbf_text);
  1241. sprintf(dbf_text, "qib ac%2x", irq_ptr->qib.ac);
  1242. QDIO_DBF_TEXT2(0, setup, dbf_text);
  1243. /* qebsm is now setup if available, initialize buffer states */
  1244. qdio_init_buf_states(irq_ptr);
  1245. mutex_unlock(&irq_ptr->setup_mutex);
  1246. qdio_print_subchannel_info(irq_ptr, cdev);
  1247. qdio_setup_debug_entries(irq_ptr, cdev);
  1248. return 0;
  1249. }
  1250. EXPORT_SYMBOL_GPL(qdio_establish);
  1251. /**
  1252. * qdio_activate - activate queues on a qdio subchannel
  1253. * @cdev: associated cdev
  1254. */
  1255. int qdio_activate(struct ccw_device *cdev)
  1256. {
  1257. struct qdio_irq *irq_ptr;
  1258. int rc;
  1259. unsigned long saveflags;
  1260. char dbf_text[20];
  1261. sprintf(dbf_text, "qact%4x", cdev->private->schid.sch_no);
  1262. QDIO_DBF_TEXT0(0, setup, dbf_text);
  1263. irq_ptr = cdev->private->qdio_data;
  1264. if (!irq_ptr)
  1265. return -ENODEV;
  1266. if (cdev->private->state != DEV_STATE_ONLINE)
  1267. return -EINVAL;
  1268. mutex_lock(&irq_ptr->setup_mutex);
  1269. if (irq_ptr->state == QDIO_IRQ_STATE_INACTIVE) {
  1270. rc = -EBUSY;
  1271. goto out;
  1272. }
  1273. irq_ptr->ccw.cmd_code = irq_ptr->aqueue.cmd;
  1274. irq_ptr->ccw.flags = CCW_FLAG_SLI;
  1275. irq_ptr->ccw.count = irq_ptr->aqueue.count;
  1276. irq_ptr->ccw.cda = 0;
  1277. spin_lock_irqsave(get_ccwdev_lock(cdev), saveflags);
  1278. ccw_device_set_options(cdev, CCWDEV_REPORT_ALL);
  1279. rc = ccw_device_start(cdev, &irq_ptr->ccw, QDIO_DOING_ACTIVATE,
  1280. 0, DOIO_DENY_PREFETCH);
  1281. if (rc) {
  1282. sprintf(dbf_text, "aq:io%4x", irq_ptr->schid.sch_no);
  1283. QDIO_DBF_TEXT2(1, setup, dbf_text);
  1284. sprintf(dbf_text, "aq:rc%4x", rc);
  1285. QDIO_DBF_TEXT2(1, setup, dbf_text);
  1286. }
  1287. spin_unlock_irqrestore(get_ccwdev_lock(cdev), saveflags);
  1288. if (rc)
  1289. goto out;
  1290. if (is_thinint_irq(irq_ptr))
  1291. tiqdio_add_input_queues(irq_ptr);
  1292. /* wait for subchannel to become active */
  1293. msleep(5);
  1294. switch (irq_ptr->state) {
  1295. case QDIO_IRQ_STATE_STOPPED:
  1296. case QDIO_IRQ_STATE_ERR:
  1297. mutex_unlock(&irq_ptr->setup_mutex);
  1298. qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
  1299. return -EIO;
  1300. default:
  1301. qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ACTIVE);
  1302. rc = 0;
  1303. }
  1304. out:
  1305. mutex_unlock(&irq_ptr->setup_mutex);
  1306. return rc;
  1307. }
  1308. EXPORT_SYMBOL_GPL(qdio_activate);
  1309. static inline int buf_in_between(int bufnr, int start, int count)
  1310. {
  1311. int end = add_buf(start, count);
  1312. if (end > start) {
  1313. if (bufnr >= start && bufnr < end)
  1314. return 1;
  1315. else
  1316. return 0;
  1317. }
  1318. /* wrap-around case */
  1319. if ((bufnr >= start && bufnr <= QDIO_MAX_BUFFERS_PER_Q) ||
  1320. (bufnr < end))
  1321. return 1;
  1322. else
  1323. return 0;
  1324. }
  1325. /**
  1326. * handle_inbound - reset processed input buffers
  1327. * @q: queue containing the buffers
  1328. * @callflags: flags
  1329. * @bufnr: first buffer to process
  1330. * @count: how many buffers are emptied
  1331. */
  1332. static void handle_inbound(struct qdio_q *q, unsigned int callflags,
  1333. int bufnr, int count)
  1334. {
  1335. unsigned long flags;
  1336. int used, rc;
  1337. /*
  1338. * do_QDIO could run in parallel with the queue tasklet so the
  1339. * upper-layer programm could empty the ACK'ed buffer here.
  1340. * If that happens we must clear the polling flag, otherwise
  1341. * qdio_stop_polling() could set the buffer to NOT_INIT after
  1342. * it was set to EMPTY which would kill us.
  1343. */
  1344. spin_lock_irqsave(&q->u.in.lock, flags);
  1345. if (q->u.in.polling)
  1346. if (buf_in_between(q->last_move_ftc, bufnr, count))
  1347. q->u.in.polling = 0;
  1348. count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count);
  1349. spin_unlock_irqrestore(&q->u.in.lock, flags);
  1350. used = atomic_add_return(count, &q->nr_buf_used) - count;
  1351. BUG_ON(used + count > QDIO_MAX_BUFFERS_PER_Q);
  1352. /* no need to signal as long as the adapter had free buffers */
  1353. if (used)
  1354. return;
  1355. if (need_siga_in(q)) {
  1356. rc = qdio_siga_input(q);
  1357. if (rc)
  1358. q->qdio_error = rc;
  1359. }
  1360. }
  1361. /**
  1362. * handle_outbound - process filled outbound buffers
  1363. * @q: queue containing the buffers
  1364. * @callflags: flags
  1365. * @bufnr: first buffer to process
  1366. * @count: how many buffers are filled
  1367. */
  1368. static void handle_outbound(struct qdio_q *q, unsigned int callflags,
  1369. int bufnr, int count)
  1370. {
  1371. unsigned char state;
  1372. int used;
  1373. qdio_perf_stat_inc(&perf_stats.outbound_handler);
  1374. count = set_buf_states(q, bufnr, SLSB_CU_OUTPUT_PRIMED, count);
  1375. used = atomic_add_return(count, &q->nr_buf_used);
  1376. BUG_ON(used > QDIO_MAX_BUFFERS_PER_Q);
  1377. if (callflags & QDIO_FLAG_PCI_OUT)
  1378. q->u.out.pci_out_enabled = 1;
  1379. else
  1380. q->u.out.pci_out_enabled = 0;
  1381. if (queue_type(q) == QDIO_IQDIO_QFMT) {
  1382. if (multicast_outbound(q))
  1383. qdio_kick_outbound_q(q);
  1384. else
  1385. if ((q->irq_ptr->ssqd_desc.mmwc > 1) &&
  1386. (count > 1) &&
  1387. (count <= q->irq_ptr->ssqd_desc.mmwc)) {
  1388. /* exploit enhanced SIGA */
  1389. q->u.out.use_enh_siga = 1;
  1390. qdio_kick_outbound_q(q);
  1391. } else {
  1392. /*
  1393. * One siga-w per buffer required for unicast
  1394. * HiperSockets.
  1395. */
  1396. q->u.out.use_enh_siga = 0;
  1397. while (count--)
  1398. qdio_kick_outbound_q(q);
  1399. }
  1400. goto out;
  1401. }
  1402. if (need_siga_sync(q)) {
  1403. qdio_siga_sync_q(q);
  1404. goto out;
  1405. }
  1406. /* try to fast requeue buffers */
  1407. get_buf_state(q, prev_buf(bufnr), &state);
  1408. if (state != SLSB_CU_OUTPUT_PRIMED)
  1409. qdio_kick_outbound_q(q);
  1410. else {
  1411. QDIO_DBF_TEXT5(0, trace, "fast-req");
  1412. qdio_perf_stat_inc(&perf_stats.fast_requeue);
  1413. }
  1414. out:
  1415. /* Fixme: could wait forever if called from process context */
  1416. tasklet_schedule(&q->tasklet);
  1417. }
  1418. /**
  1419. * do_QDIO - process input or output buffers
  1420. * @cdev: associated ccw_device for the qdio subchannel
  1421. * @callflags: input or output and special flags from the program
  1422. * @q_nr: queue number
  1423. * @bufnr: buffer number
  1424. * @count: how many buffers to process
  1425. */
  1426. int do_QDIO(struct ccw_device *cdev, unsigned int callflags,
  1427. int q_nr, int bufnr, int count)
  1428. {
  1429. struct qdio_irq *irq_ptr;
  1430. #ifdef CONFIG_QDIO_DEBUG
  1431. char dbf_text[20];
  1432. sprintf(dbf_text, "doQD%4x", cdev->private->schid.sch_no);
  1433. QDIO_DBF_TEXT3(0, trace, dbf_text);
  1434. #endif /* CONFIG_QDIO_DEBUG */
  1435. if ((bufnr > QDIO_MAX_BUFFERS_PER_Q) ||
  1436. (count > QDIO_MAX_BUFFERS_PER_Q) ||
  1437. (q_nr > QDIO_MAX_QUEUES_PER_IRQ))
  1438. return -EINVAL;
  1439. if (!count)
  1440. return 0;
  1441. irq_ptr = cdev->private->qdio_data;
  1442. if (!irq_ptr)
  1443. return -ENODEV;
  1444. #ifdef CONFIG_QDIO_DEBUG
  1445. if (callflags & QDIO_FLAG_SYNC_INPUT)
  1446. QDIO_DBF_HEX3(0, trace, &irq_ptr->input_qs[q_nr],
  1447. sizeof(void *));
  1448. else
  1449. QDIO_DBF_HEX3(0, trace, &irq_ptr->output_qs[q_nr],
  1450. sizeof(void *));
  1451. sprintf(dbf_text, "flag%04x", callflags);
  1452. QDIO_DBF_TEXT3(0, trace, dbf_text);
  1453. sprintf(dbf_text, "qi%02xct%02x", bufnr, count);
  1454. QDIO_DBF_TEXT3(0, trace, dbf_text);
  1455. #endif /* CONFIG_QDIO_DEBUG */
  1456. if (irq_ptr->state != QDIO_IRQ_STATE_ACTIVE)
  1457. return -EBUSY;
  1458. if (callflags & QDIO_FLAG_SYNC_INPUT)
  1459. handle_inbound(irq_ptr->input_qs[q_nr],
  1460. callflags, bufnr, count);
  1461. else if (callflags & QDIO_FLAG_SYNC_OUTPUT)
  1462. handle_outbound(irq_ptr->output_qs[q_nr],
  1463. callflags, bufnr, count);
  1464. else {
  1465. QDIO_DBF_TEXT3(1, trace, "doQD:inv");
  1466. return -EINVAL;
  1467. }
  1468. return 0;
  1469. }
  1470. EXPORT_SYMBOL_GPL(do_QDIO);
  1471. static int __init init_QDIO(void)
  1472. {
  1473. int rc;
  1474. rc = qdio_setup_init();
  1475. if (rc)
  1476. return rc;
  1477. rc = tiqdio_allocate_memory();
  1478. if (rc)
  1479. goto out_cache;
  1480. rc = qdio_debug_init();
  1481. if (rc)
  1482. goto out_ti;
  1483. rc = qdio_setup_perf_stats();
  1484. if (rc)
  1485. goto out_debug;
  1486. rc = tiqdio_register_thinints();
  1487. if (rc)
  1488. goto out_perf;
  1489. return 0;
  1490. out_perf:
  1491. qdio_remove_perf_stats();
  1492. out_debug:
  1493. qdio_debug_exit();
  1494. out_ti:
  1495. tiqdio_free_memory();
  1496. out_cache:
  1497. qdio_setup_exit();
  1498. return rc;
  1499. }
  1500. static void __exit exit_QDIO(void)
  1501. {
  1502. tiqdio_unregister_thinints();
  1503. tiqdio_free_memory();
  1504. qdio_remove_perf_stats();
  1505. qdio_debug_exit();
  1506. qdio_setup_exit();
  1507. }
  1508. module_init(init_QDIO);
  1509. module_exit(exit_QDIO);