qdio_main.c 43 KB

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