ehci-q.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. /*
  2. * Copyright (C) 2001-2004 by David Brownell
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. /* this file is part of ehci-hcd.c */
  19. /*-------------------------------------------------------------------------*/
  20. /*
  21. * EHCI hardware queue manipulation ... the core. QH/QTD manipulation.
  22. *
  23. * Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd"
  24. * entries describing USB transactions, max 16-20kB/entry (with 4kB-aligned
  25. * buffers needed for the larger number). We use one QH per endpoint, queue
  26. * multiple urbs (all three types) per endpoint. URBs may need several qtds.
  27. *
  28. * ISO traffic uses "ISO TD" (itd, and sitd) records, and (along with
  29. * interrupts) needs careful scheduling. Performance improvements can be
  30. * an ongoing challenge. That's in "ehci-sched.c".
  31. *
  32. * USB 1.1 devices are handled (a) by "companion" OHCI or UHCI root hubs,
  33. * or otherwise through transaction translators (TTs) in USB 2.0 hubs using
  34. * (b) special fields in qh entries or (c) split iso entries. TTs will
  35. * buffer low/full speed data so the host collects it at high speed.
  36. */
  37. /*-------------------------------------------------------------------------*/
  38. /* fill a qtd, returning how much of the buffer we were able to queue up */
  39. static int
  40. qtd_fill(struct ehci_hcd *ehci, struct ehci_qtd *qtd, dma_addr_t buf,
  41. size_t len, int token, int maxpacket)
  42. {
  43. int i, count;
  44. u64 addr = buf;
  45. /* one buffer entry per 4K ... first might be short or unaligned */
  46. qtd->hw_buf[0] = cpu_to_hc32(ehci, (u32)addr);
  47. qtd->hw_buf_hi[0] = cpu_to_hc32(ehci, (u32)(addr >> 32));
  48. count = 0x1000 - (buf & 0x0fff); /* rest of that page */
  49. if (likely (len < count)) /* ... iff needed */
  50. count = len;
  51. else {
  52. buf += 0x1000;
  53. buf &= ~0x0fff;
  54. /* per-qtd limit: from 16K to 20K (best alignment) */
  55. for (i = 1; count < len && i < 5; i++) {
  56. addr = buf;
  57. qtd->hw_buf[i] = cpu_to_hc32(ehci, (u32)addr);
  58. qtd->hw_buf_hi[i] = cpu_to_hc32(ehci,
  59. (u32)(addr >> 32));
  60. buf += 0x1000;
  61. if ((count + 0x1000) < len)
  62. count += 0x1000;
  63. else
  64. count = len;
  65. }
  66. /* short packets may only terminate transfers */
  67. if (count != len)
  68. count -= (count % maxpacket);
  69. }
  70. qtd->hw_token = cpu_to_hc32(ehci, (count << 16) | token);
  71. qtd->length = count;
  72. return count;
  73. }
  74. /*-------------------------------------------------------------------------*/
  75. static inline void
  76. qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd)
  77. {
  78. /* writes to an active overlay are unsafe */
  79. BUG_ON(qh->qh_state != QH_STATE_IDLE);
  80. qh->hw_qtd_next = QTD_NEXT(ehci, qtd->qtd_dma);
  81. qh->hw_alt_next = EHCI_LIST_END(ehci);
  82. /* Except for control endpoints, we make hardware maintain data
  83. * toggle (like OHCI) ... here (re)initialize the toggle in the QH,
  84. * and set the pseudo-toggle in udev. Only usb_clear_halt() will
  85. * ever clear it.
  86. */
  87. if (!(qh->hw_info1 & cpu_to_hc32(ehci, 1 << 14))) {
  88. unsigned is_out, epnum;
  89. is_out = !(qtd->hw_token & cpu_to_hc32(ehci, 1 << 8));
  90. epnum = (hc32_to_cpup(ehci, &qh->hw_info1) >> 8) & 0x0f;
  91. if (unlikely (!usb_gettoggle (qh->dev, epnum, is_out))) {
  92. qh->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE);
  93. usb_settoggle (qh->dev, epnum, is_out, 1);
  94. }
  95. }
  96. /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */
  97. wmb ();
  98. qh->hw_token &= cpu_to_hc32(ehci, QTD_TOGGLE | QTD_STS_PING);
  99. }
  100. /* if it weren't for a common silicon quirk (writing the dummy into the qh
  101. * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
  102. * recovery (including urb dequeue) would need software changes to a QH...
  103. */
  104. static void
  105. qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
  106. {
  107. struct ehci_qtd *qtd;
  108. if (list_empty (&qh->qtd_list))
  109. qtd = qh->dummy;
  110. else {
  111. qtd = list_entry (qh->qtd_list.next,
  112. struct ehci_qtd, qtd_list);
  113. /* first qtd may already be partially processed */
  114. if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw_current)
  115. qtd = NULL;
  116. }
  117. if (qtd)
  118. qh_update (ehci, qh, qtd);
  119. }
  120. /*-------------------------------------------------------------------------*/
  121. static int qtd_copy_status (
  122. struct ehci_hcd *ehci,
  123. struct urb *urb,
  124. size_t length,
  125. u32 token
  126. )
  127. {
  128. int status = -EINPROGRESS;
  129. /* count IN/OUT bytes, not SETUP (even short packets) */
  130. if (likely (QTD_PID (token) != 2))
  131. urb->actual_length += length - QTD_LENGTH (token);
  132. /* don't modify error codes */
  133. if (unlikely(urb->unlinked))
  134. return status;
  135. /* force cleanup after short read; not always an error */
  136. if (unlikely (IS_SHORT_READ (token)))
  137. status = -EREMOTEIO;
  138. /* serious "can't proceed" faults reported by the hardware */
  139. if (token & QTD_STS_HALT) {
  140. if (token & QTD_STS_BABBLE) {
  141. /* FIXME "must" disable babbling device's port too */
  142. status = -EOVERFLOW;
  143. } else if (token & QTD_STS_MMF) {
  144. /* fs/ls interrupt xfer missed the complete-split */
  145. status = -EPROTO;
  146. } else if (token & QTD_STS_DBE) {
  147. status = (QTD_PID (token) == 1) /* IN ? */
  148. ? -ENOSR /* hc couldn't read data */
  149. : -ECOMM; /* hc couldn't write data */
  150. } else if (token & QTD_STS_XACT) {
  151. /* timeout, bad crc, wrong PID, etc; retried */
  152. if (QTD_CERR (token))
  153. status = -EPIPE;
  154. else {
  155. ehci_dbg (ehci, "devpath %s ep%d%s 3strikes\n",
  156. urb->dev->devpath,
  157. usb_pipeendpoint (urb->pipe),
  158. usb_pipein (urb->pipe) ? "in" : "out");
  159. status = -EPROTO;
  160. }
  161. /* CERR nonzero + no errors + halt --> stall */
  162. } else if (QTD_CERR (token))
  163. status = -EPIPE;
  164. else /* unknown */
  165. status = -EPROTO;
  166. ehci_vdbg (ehci,
  167. "dev%d ep%d%s qtd token %08x --> status %d\n",
  168. usb_pipedevice (urb->pipe),
  169. usb_pipeendpoint (urb->pipe),
  170. usb_pipein (urb->pipe) ? "in" : "out",
  171. token, status);
  172. /* if async CSPLIT failed, try cleaning out the TT buffer */
  173. if (status != -EPIPE
  174. && urb->dev->tt
  175. && !usb_pipeint(urb->pipe)
  176. && ((token & QTD_STS_MMF) != 0
  177. || QTD_CERR(token) == 0)
  178. && (!ehci_is_TDI(ehci)
  179. || urb->dev->tt->hub !=
  180. ehci_to_hcd(ehci)->self.root_hub)) {
  181. #ifdef DEBUG
  182. struct usb_device *tt = urb->dev->tt->hub;
  183. dev_dbg (&tt->dev,
  184. "clear tt buffer port %d, a%d ep%d t%08x\n",
  185. urb->dev->ttport, urb->dev->devnum,
  186. usb_pipeendpoint (urb->pipe), token);
  187. #endif /* DEBUG */
  188. /* REVISIT ARC-derived cores don't clear the root
  189. * hub TT buffer in this way...
  190. */
  191. usb_hub_tt_clear_buffer (urb->dev, urb->pipe);
  192. }
  193. }
  194. return status;
  195. }
  196. static void
  197. ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status)
  198. __releases(ehci->lock)
  199. __acquires(ehci->lock)
  200. {
  201. if (likely (urb->hcpriv != NULL)) {
  202. struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv;
  203. /* S-mask in a QH means it's an interrupt urb */
  204. if ((qh->hw_info2 & cpu_to_hc32(ehci, QH_SMASK)) != 0) {
  205. /* ... update hc-wide periodic stats (for usbfs) */
  206. ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
  207. }
  208. qh_put (qh);
  209. }
  210. if (unlikely(urb->unlinked)) {
  211. COUNT(ehci->stats.unlink);
  212. } else {
  213. /* report non-error and short read status as zero */
  214. if (status == -EINPROGRESS || status == -EREMOTEIO)
  215. status = 0;
  216. COUNT(ehci->stats.complete);
  217. }
  218. #ifdef EHCI_URB_TRACE
  219. ehci_dbg (ehci,
  220. "%s %s urb %p ep%d%s status %d len %d/%d\n",
  221. __func__, urb->dev->devpath, urb,
  222. usb_pipeendpoint (urb->pipe),
  223. usb_pipein (urb->pipe) ? "in" : "out",
  224. status,
  225. urb->actual_length, urb->transfer_buffer_length);
  226. #endif
  227. /* complete() can reenter this HCD */
  228. usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb);
  229. spin_unlock (&ehci->lock);
  230. usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status);
  231. spin_lock (&ehci->lock);
  232. }
  233. static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh);
  234. static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh);
  235. static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh);
  236. static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh);
  237. /*
  238. * Process and free completed qtds for a qh, returning URBs to drivers.
  239. * Chases up to qh->hw_current. Returns number of completions called,
  240. * indicating how much "real" work we did.
  241. */
  242. static unsigned
  243. qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
  244. {
  245. struct ehci_qtd *last = NULL, *end = qh->dummy;
  246. struct list_head *entry, *tmp;
  247. int last_status = -EINPROGRESS;
  248. int stopped;
  249. unsigned count = 0;
  250. u8 state;
  251. __le32 halt = HALT_BIT(ehci);
  252. if (unlikely (list_empty (&qh->qtd_list)))
  253. return count;
  254. /* completions (or tasks on other cpus) must never clobber HALT
  255. * till we've gone through and cleaned everything up, even when
  256. * they add urbs to this qh's queue or mark them for unlinking.
  257. *
  258. * NOTE: unlinking expects to be done in queue order.
  259. */
  260. state = qh->qh_state;
  261. qh->qh_state = QH_STATE_COMPLETING;
  262. stopped = (state == QH_STATE_IDLE);
  263. /* remove de-activated QTDs from front of queue.
  264. * after faults (including short reads), cleanup this urb
  265. * then let the queue advance.
  266. * if queue is stopped, handles unlinks.
  267. */
  268. list_for_each_safe (entry, tmp, &qh->qtd_list) {
  269. struct ehci_qtd *qtd;
  270. struct urb *urb;
  271. u32 token = 0;
  272. qtd = list_entry (entry, struct ehci_qtd, qtd_list);
  273. urb = qtd->urb;
  274. /* clean up any state from previous QTD ...*/
  275. if (last) {
  276. if (likely (last->urb != urb)) {
  277. ehci_urb_done(ehci, last->urb, last_status);
  278. count++;
  279. last_status = -EINPROGRESS;
  280. }
  281. ehci_qtd_free (ehci, last);
  282. last = NULL;
  283. }
  284. /* ignore urbs submitted during completions we reported */
  285. if (qtd == end)
  286. break;
  287. /* hardware copies qtd out of qh overlay */
  288. rmb ();
  289. token = hc32_to_cpu(ehci, qtd->hw_token);
  290. /* always clean up qtds the hc de-activated */
  291. retry_xacterr:
  292. if ((token & QTD_STS_ACTIVE) == 0) {
  293. /* on STALL, error, and short reads this urb must
  294. * complete and all its qtds must be recycled.
  295. */
  296. if ((token & QTD_STS_HALT) != 0) {
  297. /* retry transaction errors until we
  298. * reach the software xacterr limit
  299. */
  300. if ((token & QTD_STS_XACT) &&
  301. QTD_CERR(token) == 0 &&
  302. --qh->xacterrs > 0 &&
  303. !urb->unlinked) {
  304. ehci_dbg(ehci,
  305. "detected XactErr len %zu/%zu retry %d\n",
  306. qtd->length - QTD_LENGTH(token), qtd->length,
  307. QH_XACTERR_MAX - qh->xacterrs);
  308. /* reset the token in the qtd and the
  309. * qh overlay (which still contains
  310. * the qtd) so that we pick up from
  311. * where we left off
  312. */
  313. token &= ~QTD_STS_HALT;
  314. token |= QTD_STS_ACTIVE |
  315. (EHCI_TUNE_CERR << 10);
  316. qtd->hw_token = cpu_to_hc32(ehci,
  317. token);
  318. wmb();
  319. qh->hw_token = cpu_to_hc32(ehci, token);
  320. goto retry_xacterr;
  321. }
  322. stopped = 1;
  323. /* magic dummy for some short reads; qh won't advance.
  324. * that silicon quirk can kick in with this dummy too.
  325. *
  326. * other short reads won't stop the queue, including
  327. * control transfers (status stage handles that) or
  328. * most other single-qtd reads ... the queue stops if
  329. * URB_SHORT_NOT_OK was set so the driver submitting
  330. * the urbs could clean it up.
  331. */
  332. } else if (IS_SHORT_READ (token)
  333. && !(qtd->hw_alt_next
  334. & EHCI_LIST_END(ehci))) {
  335. stopped = 1;
  336. goto halt;
  337. }
  338. /* stop scanning when we reach qtds the hc is using */
  339. } else if (likely (!stopped
  340. && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) {
  341. break;
  342. /* scan the whole queue for unlinks whenever it stops */
  343. } else {
  344. stopped = 1;
  345. /* cancel everything if we halt, suspend, etc */
  346. if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state))
  347. last_status = -ESHUTDOWN;
  348. /* this qtd is active; skip it unless a previous qtd
  349. * for its urb faulted, or its urb was canceled.
  350. */
  351. else if (last_status == -EINPROGRESS && !urb->unlinked)
  352. continue;
  353. /* qh unlinked; token in overlay may be most current */
  354. if (state == QH_STATE_IDLE
  355. && cpu_to_hc32(ehci, qtd->qtd_dma)
  356. == qh->hw_current)
  357. token = hc32_to_cpu(ehci, qh->hw_token);
  358. /* force halt for unlinked or blocked qh, so we'll
  359. * patch the qh later and so that completions can't
  360. * activate it while we "know" it's stopped.
  361. */
  362. if ((halt & qh->hw_token) == 0) {
  363. halt:
  364. qh->hw_token |= halt;
  365. wmb ();
  366. }
  367. }
  368. /* unless we already know the urb's status, collect qtd status
  369. * and update count of bytes transferred. in common short read
  370. * cases with only one data qtd (including control transfers),
  371. * queue processing won't halt. but with two or more qtds (for
  372. * example, with a 32 KB transfer), when the first qtd gets a
  373. * short read the second must be removed by hand.
  374. */
  375. if (last_status == -EINPROGRESS) {
  376. last_status = qtd_copy_status(ehci, urb,
  377. qtd->length, token);
  378. if (last_status == -EREMOTEIO
  379. && (qtd->hw_alt_next
  380. & EHCI_LIST_END(ehci)))
  381. last_status = -EINPROGRESS;
  382. }
  383. /* if we're removing something not at the queue head,
  384. * patch the hardware queue pointer.
  385. */
  386. if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
  387. last = list_entry (qtd->qtd_list.prev,
  388. struct ehci_qtd, qtd_list);
  389. last->hw_next = qtd->hw_next;
  390. }
  391. /* remove qtd; it's recycled after possible urb completion */
  392. list_del (&qtd->qtd_list);
  393. last = qtd;
  394. /* reinit the xacterr counter for the next qtd */
  395. qh->xacterrs = QH_XACTERR_MAX;
  396. }
  397. /* last urb's completion might still need calling */
  398. if (likely (last != NULL)) {
  399. ehci_urb_done(ehci, last->urb, last_status);
  400. count++;
  401. ehci_qtd_free (ehci, last);
  402. }
  403. /* restore original state; caller must unlink or relink */
  404. qh->qh_state = state;
  405. /* be sure the hardware's done with the qh before refreshing
  406. * it after fault cleanup, or recovering from silicon wrongly
  407. * overlaying the dummy qtd (which reduces DMA chatter).
  408. */
  409. if (stopped != 0 || qh->hw_qtd_next == EHCI_LIST_END(ehci)) {
  410. switch (state) {
  411. case QH_STATE_IDLE:
  412. qh_refresh(ehci, qh);
  413. break;
  414. case QH_STATE_LINKED:
  415. /* We won't refresh a QH that's linked (after the HC
  416. * stopped the queue). That avoids a race:
  417. * - HC reads first part of QH;
  418. * - CPU updates that first part and the token;
  419. * - HC reads rest of that QH, including token
  420. * Result: HC gets an inconsistent image, and then
  421. * DMAs to/from the wrong memory (corrupting it).
  422. *
  423. * That should be rare for interrupt transfers,
  424. * except maybe high bandwidth ...
  425. */
  426. if ((cpu_to_hc32(ehci, QH_SMASK)
  427. & qh->hw_info2) != 0) {
  428. intr_deschedule (ehci, qh);
  429. (void) qh_schedule (ehci, qh);
  430. } else
  431. unlink_async (ehci, qh);
  432. break;
  433. /* otherwise, unlink already started */
  434. }
  435. }
  436. return count;
  437. }
  438. /*-------------------------------------------------------------------------*/
  439. // high bandwidth multiplier, as encoded in highspeed endpoint descriptors
  440. #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
  441. // ... and packet size, for any kind of endpoint descriptor
  442. #define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
  443. /*
  444. * reverse of qh_urb_transaction: free a list of TDs.
  445. * used for cleanup after errors, before HC sees an URB's TDs.
  446. */
  447. static void qtd_list_free (
  448. struct ehci_hcd *ehci,
  449. struct urb *urb,
  450. struct list_head *qtd_list
  451. ) {
  452. struct list_head *entry, *temp;
  453. list_for_each_safe (entry, temp, qtd_list) {
  454. struct ehci_qtd *qtd;
  455. qtd = list_entry (entry, struct ehci_qtd, qtd_list);
  456. list_del (&qtd->qtd_list);
  457. ehci_qtd_free (ehci, qtd);
  458. }
  459. }
  460. /*
  461. * create a list of filled qtds for this URB; won't link into qh.
  462. */
  463. static struct list_head *
  464. qh_urb_transaction (
  465. struct ehci_hcd *ehci,
  466. struct urb *urb,
  467. struct list_head *head,
  468. gfp_t flags
  469. ) {
  470. struct ehci_qtd *qtd, *qtd_prev;
  471. dma_addr_t buf;
  472. int len, maxpacket;
  473. int is_input;
  474. u32 token;
  475. /*
  476. * URBs map to sequences of QTDs: one logical transaction
  477. */
  478. qtd = ehci_qtd_alloc (ehci, flags);
  479. if (unlikely (!qtd))
  480. return NULL;
  481. list_add_tail (&qtd->qtd_list, head);
  482. qtd->urb = urb;
  483. token = QTD_STS_ACTIVE;
  484. token |= (EHCI_TUNE_CERR << 10);
  485. /* for split transactions, SplitXState initialized to zero */
  486. len = urb->transfer_buffer_length;
  487. is_input = usb_pipein (urb->pipe);
  488. if (usb_pipecontrol (urb->pipe)) {
  489. /* SETUP pid */
  490. qtd_fill(ehci, qtd, urb->setup_dma,
  491. sizeof (struct usb_ctrlrequest),
  492. token | (2 /* "setup" */ << 8), 8);
  493. /* ... and always at least one more pid */
  494. token ^= QTD_TOGGLE;
  495. qtd_prev = qtd;
  496. qtd = ehci_qtd_alloc (ehci, flags);
  497. if (unlikely (!qtd))
  498. goto cleanup;
  499. qtd->urb = urb;
  500. qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma);
  501. list_add_tail (&qtd->qtd_list, head);
  502. /* for zero length DATA stages, STATUS is always IN */
  503. if (len == 0)
  504. token |= (1 /* "in" */ << 8);
  505. }
  506. /*
  507. * data transfer stage: buffer setup
  508. */
  509. buf = urb->transfer_dma;
  510. if (is_input)
  511. token |= (1 /* "in" */ << 8);
  512. /* else it's already initted to "out" pid (0 << 8) */
  513. maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input));
  514. /*
  515. * buffer gets wrapped in one or more qtds;
  516. * last one may be "short" (including zero len)
  517. * and may serve as a control status ack
  518. */
  519. for (;;) {
  520. int this_qtd_len;
  521. this_qtd_len = qtd_fill(ehci, qtd, buf, len, token, maxpacket);
  522. len -= this_qtd_len;
  523. buf += this_qtd_len;
  524. /*
  525. * short reads advance to a "magic" dummy instead of the next
  526. * qtd ... that forces the queue to stop, for manual cleanup.
  527. * (this will usually be overridden later.)
  528. */
  529. if (is_input)
  530. qtd->hw_alt_next = ehci->async->hw_alt_next;
  531. /* qh makes control packets use qtd toggle; maybe switch it */
  532. if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0)
  533. token ^= QTD_TOGGLE;
  534. if (likely (len <= 0))
  535. break;
  536. qtd_prev = qtd;
  537. qtd = ehci_qtd_alloc (ehci, flags);
  538. if (unlikely (!qtd))
  539. goto cleanup;
  540. qtd->urb = urb;
  541. qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma);
  542. list_add_tail (&qtd->qtd_list, head);
  543. }
  544. /*
  545. * unless the caller requires manual cleanup after short reads,
  546. * have the alt_next mechanism keep the queue running after the
  547. * last data qtd (the only one, for control and most other cases).
  548. */
  549. if (likely ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0
  550. || usb_pipecontrol (urb->pipe)))
  551. qtd->hw_alt_next = EHCI_LIST_END(ehci);
  552. /*
  553. * control requests may need a terminating data "status" ack;
  554. * bulk ones may need a terminating short packet (zero length).
  555. */
  556. if (likely (urb->transfer_buffer_length != 0)) {
  557. int one_more = 0;
  558. if (usb_pipecontrol (urb->pipe)) {
  559. one_more = 1;
  560. token ^= 0x0100; /* "in" <--> "out" */
  561. token |= QTD_TOGGLE; /* force DATA1 */
  562. } else if (usb_pipebulk (urb->pipe)
  563. && (urb->transfer_flags & URB_ZERO_PACKET)
  564. && !(urb->transfer_buffer_length % maxpacket)) {
  565. one_more = 1;
  566. }
  567. if (one_more) {
  568. qtd_prev = qtd;
  569. qtd = ehci_qtd_alloc (ehci, flags);
  570. if (unlikely (!qtd))
  571. goto cleanup;
  572. qtd->urb = urb;
  573. qtd_prev->hw_next = QTD_NEXT(ehci, qtd->qtd_dma);
  574. list_add_tail (&qtd->qtd_list, head);
  575. /* never any data in such packets */
  576. qtd_fill(ehci, qtd, 0, 0, token, 0);
  577. }
  578. }
  579. /* by default, enable interrupt on urb completion */
  580. if (likely (!(urb->transfer_flags & URB_NO_INTERRUPT)))
  581. qtd->hw_token |= cpu_to_hc32(ehci, QTD_IOC);
  582. return head;
  583. cleanup:
  584. qtd_list_free (ehci, urb, head);
  585. return NULL;
  586. }
  587. /*-------------------------------------------------------------------------*/
  588. // Would be best to create all qh's from config descriptors,
  589. // when each interface/altsetting is established. Unlink
  590. // any previous qh and cancel its urbs first; endpoints are
  591. // implicitly reset then (data toggle too).
  592. // That'd mean updating how usbcore talks to HCDs. (2.7?)
  593. /*
  594. * Each QH holds a qtd list; a QH is used for everything except iso.
  595. *
  596. * For interrupt urbs, the scheduler must set the microframe scheduling
  597. * mask(s) each time the QH gets scheduled. For highspeed, that's
  598. * just one microframe in the s-mask. For split interrupt transactions
  599. * there are additional complications: c-mask, maybe FSTNs.
  600. */
  601. static struct ehci_qh *
  602. qh_make (
  603. struct ehci_hcd *ehci,
  604. struct urb *urb,
  605. gfp_t flags
  606. ) {
  607. struct ehci_qh *qh = ehci_qh_alloc (ehci, flags);
  608. u32 info1 = 0, info2 = 0;
  609. int is_input, type;
  610. int maxp = 0;
  611. struct usb_tt *tt = urb->dev->tt;
  612. if (!qh)
  613. return qh;
  614. /*
  615. * init endpoint/device data for this QH
  616. */
  617. info1 |= usb_pipeendpoint (urb->pipe) << 8;
  618. info1 |= usb_pipedevice (urb->pipe) << 0;
  619. is_input = usb_pipein (urb->pipe);
  620. type = usb_pipetype (urb->pipe);
  621. maxp = usb_maxpacket (urb->dev, urb->pipe, !is_input);
  622. /* 1024 byte maxpacket is a hardware ceiling. High bandwidth
  623. * acts like up to 3KB, but is built from smaller packets.
  624. */
  625. if (max_packet(maxp) > 1024) {
  626. ehci_dbg(ehci, "bogus qh maxpacket %d\n", max_packet(maxp));
  627. goto done;
  628. }
  629. /* Compute interrupt scheduling parameters just once, and save.
  630. * - allowing for high bandwidth, how many nsec/uframe are used?
  631. * - split transactions need a second CSPLIT uframe; same question
  632. * - splits also need a schedule gap (for full/low speed I/O)
  633. * - qh has a polling interval
  634. *
  635. * For control/bulk requests, the HC or TT handles these.
  636. */
  637. if (type == PIPE_INTERRUPT) {
  638. qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
  639. is_input, 0,
  640. hb_mult(maxp) * max_packet(maxp)));
  641. qh->start = NO_FRAME;
  642. if (urb->dev->speed == USB_SPEED_HIGH) {
  643. qh->c_usecs = 0;
  644. qh->gap_uf = 0;
  645. qh->period = urb->interval >> 3;
  646. if (qh->period == 0 && urb->interval != 1) {
  647. /* NOTE interval 2 or 4 uframes could work.
  648. * But interval 1 scheduling is simpler, and
  649. * includes high bandwidth.
  650. */
  651. dbg ("intr period %d uframes, NYET!",
  652. urb->interval);
  653. goto done;
  654. }
  655. } else {
  656. int think_time;
  657. /* gap is f(FS/LS transfer times) */
  658. qh->gap_uf = 1 + usb_calc_bus_time (urb->dev->speed,
  659. is_input, 0, maxp) / (125 * 1000);
  660. /* FIXME this just approximates SPLIT/CSPLIT times */
  661. if (is_input) { // SPLIT, gap, CSPLIT+DATA
  662. qh->c_usecs = qh->usecs + HS_USECS (0);
  663. qh->usecs = HS_USECS (1);
  664. } else { // SPLIT+DATA, gap, CSPLIT
  665. qh->usecs += HS_USECS (1);
  666. qh->c_usecs = HS_USECS (0);
  667. }
  668. think_time = tt ? tt->think_time : 0;
  669. qh->tt_usecs = NS_TO_US (think_time +
  670. usb_calc_bus_time (urb->dev->speed,
  671. is_input, 0, max_packet (maxp)));
  672. qh->period = urb->interval;
  673. }
  674. }
  675. /* support for tt scheduling, and access to toggles */
  676. qh->dev = urb->dev;
  677. /* using TT? */
  678. switch (urb->dev->speed) {
  679. case USB_SPEED_LOW:
  680. info1 |= (1 << 12); /* EPS "low" */
  681. /* FALL THROUGH */
  682. case USB_SPEED_FULL:
  683. /* EPS 0 means "full" */
  684. if (type != PIPE_INTERRUPT)
  685. info1 |= (EHCI_TUNE_RL_TT << 28);
  686. if (type == PIPE_CONTROL) {
  687. info1 |= (1 << 27); /* for TT */
  688. info1 |= 1 << 14; /* toggle from qtd */
  689. }
  690. info1 |= maxp << 16;
  691. info2 |= (EHCI_TUNE_MULT_TT << 30);
  692. /* Some Freescale processors have an erratum in which the
  693. * port number in the queue head was 0..N-1 instead of 1..N.
  694. */
  695. if (ehci_has_fsl_portno_bug(ehci))
  696. info2 |= (urb->dev->ttport-1) << 23;
  697. else
  698. info2 |= urb->dev->ttport << 23;
  699. /* set the address of the TT; for TDI's integrated
  700. * root hub tt, leave it zeroed.
  701. */
  702. if (tt && tt->hub != ehci_to_hcd(ehci)->self.root_hub)
  703. info2 |= tt->hub->devnum << 16;
  704. /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */
  705. break;
  706. case USB_SPEED_HIGH: /* no TT involved */
  707. info1 |= (2 << 12); /* EPS "high" */
  708. if (type == PIPE_CONTROL) {
  709. info1 |= (EHCI_TUNE_RL_HS << 28);
  710. info1 |= 64 << 16; /* usb2 fixed maxpacket */
  711. info1 |= 1 << 14; /* toggle from qtd */
  712. info2 |= (EHCI_TUNE_MULT_HS << 30);
  713. } else if (type == PIPE_BULK) {
  714. info1 |= (EHCI_TUNE_RL_HS << 28);
  715. /* The USB spec says that high speed bulk endpoints
  716. * always use 512 byte maxpacket. But some device
  717. * vendors decided to ignore that, and MSFT is happy
  718. * to help them do so. So now people expect to use
  719. * such nonconformant devices with Linux too; sigh.
  720. */
  721. info1 |= max_packet(maxp) << 16;
  722. info2 |= (EHCI_TUNE_MULT_HS << 30);
  723. } else { /* PIPE_INTERRUPT */
  724. info1 |= max_packet (maxp) << 16;
  725. info2 |= hb_mult (maxp) << 30;
  726. }
  727. break;
  728. default:
  729. dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed);
  730. done:
  731. qh_put (qh);
  732. return NULL;
  733. }
  734. /* NOTE: if (PIPE_INTERRUPT) { scheduler sets s-mask } */
  735. /* init as live, toggle clear, advance to dummy */
  736. qh->qh_state = QH_STATE_IDLE;
  737. qh->hw_info1 = cpu_to_hc32(ehci, info1);
  738. qh->hw_info2 = cpu_to_hc32(ehci, info2);
  739. usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1);
  740. qh_refresh (ehci, qh);
  741. return qh;
  742. }
  743. /*-------------------------------------------------------------------------*/
  744. /* move qh (and its qtds) onto async queue; maybe enable queue. */
  745. static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
  746. {
  747. __hc32 dma = QH_NEXT(ehci, qh->qh_dma);
  748. struct ehci_qh *head;
  749. /* (re)start the async schedule? */
  750. head = ehci->async;
  751. timer_action_done (ehci, TIMER_ASYNC_OFF);
  752. if (!head->qh_next.qh) {
  753. u32 cmd = ehci_readl(ehci, &ehci->regs->command);
  754. if (!(cmd & CMD_ASE)) {
  755. /* in case a clear of CMD_ASE didn't take yet */
  756. (void)handshake(ehci, &ehci->regs->status,
  757. STS_ASS, 0, 150);
  758. cmd |= CMD_ASE | CMD_RUN;
  759. ehci_writel(ehci, cmd, &ehci->regs->command);
  760. ehci_to_hcd(ehci)->state = HC_STATE_RUNNING;
  761. /* posted write need not be known to HC yet ... */
  762. }
  763. }
  764. /* clear halt and/or toggle; and maybe recover from silicon quirk */
  765. if (qh->qh_state == QH_STATE_IDLE)
  766. qh_refresh (ehci, qh);
  767. /* splice right after start */
  768. qh->qh_next = head->qh_next;
  769. qh->hw_next = head->hw_next;
  770. wmb ();
  771. head->qh_next.qh = qh;
  772. head->hw_next = dma;
  773. qh->xacterrs = QH_XACTERR_MAX;
  774. qh->qh_state = QH_STATE_LINKED;
  775. /* qtd completions reported later by interrupt */
  776. }
  777. /*-------------------------------------------------------------------------*/
  778. /*
  779. * For control/bulk/interrupt, return QH with these TDs appended.
  780. * Allocates and initializes the QH if necessary.
  781. * Returns null if it can't allocate a QH it needs to.
  782. * If the QH has TDs (urbs) already, that's great.
  783. */
  784. static struct ehci_qh *qh_append_tds (
  785. struct ehci_hcd *ehci,
  786. struct urb *urb,
  787. struct list_head *qtd_list,
  788. int epnum,
  789. void **ptr
  790. )
  791. {
  792. struct ehci_qh *qh = NULL;
  793. __hc32 qh_addr_mask = cpu_to_hc32(ehci, 0x7f);
  794. qh = (struct ehci_qh *) *ptr;
  795. if (unlikely (qh == NULL)) {
  796. /* can't sleep here, we have ehci->lock... */
  797. qh = qh_make (ehci, urb, GFP_ATOMIC);
  798. *ptr = qh;
  799. }
  800. if (likely (qh != NULL)) {
  801. struct ehci_qtd *qtd;
  802. if (unlikely (list_empty (qtd_list)))
  803. qtd = NULL;
  804. else
  805. qtd = list_entry (qtd_list->next, struct ehci_qtd,
  806. qtd_list);
  807. /* control qh may need patching ... */
  808. if (unlikely (epnum == 0)) {
  809. /* usb_reset_device() briefly reverts to address 0 */
  810. if (usb_pipedevice (urb->pipe) == 0)
  811. qh->hw_info1 &= ~qh_addr_mask;
  812. }
  813. /* just one way to queue requests: swap with the dummy qtd.
  814. * only hc or qh_refresh() ever modify the overlay.
  815. */
  816. if (likely (qtd != NULL)) {
  817. struct ehci_qtd *dummy;
  818. dma_addr_t dma;
  819. __hc32 token;
  820. /* to avoid racing the HC, use the dummy td instead of
  821. * the first td of our list (becomes new dummy). both
  822. * tds stay deactivated until we're done, when the
  823. * HC is allowed to fetch the old dummy (4.10.2).
  824. */
  825. token = qtd->hw_token;
  826. qtd->hw_token = HALT_BIT(ehci);
  827. wmb ();
  828. dummy = qh->dummy;
  829. dma = dummy->qtd_dma;
  830. *dummy = *qtd;
  831. dummy->qtd_dma = dma;
  832. list_del (&qtd->qtd_list);
  833. list_add (&dummy->qtd_list, qtd_list);
  834. list_splice_tail(qtd_list, &qh->qtd_list);
  835. ehci_qtd_init(ehci, qtd, qtd->qtd_dma);
  836. qh->dummy = qtd;
  837. /* hc must see the new dummy at list end */
  838. dma = qtd->qtd_dma;
  839. qtd = list_entry (qh->qtd_list.prev,
  840. struct ehci_qtd, qtd_list);
  841. qtd->hw_next = QTD_NEXT(ehci, dma);
  842. /* let the hc process these next qtds */
  843. wmb ();
  844. dummy->hw_token = token;
  845. urb->hcpriv = qh_get (qh);
  846. }
  847. }
  848. return qh;
  849. }
  850. /*-------------------------------------------------------------------------*/
  851. static int
  852. submit_async (
  853. struct ehci_hcd *ehci,
  854. struct urb *urb,
  855. struct list_head *qtd_list,
  856. gfp_t mem_flags
  857. ) {
  858. struct ehci_qtd *qtd;
  859. int epnum;
  860. unsigned long flags;
  861. struct ehci_qh *qh = NULL;
  862. int rc;
  863. qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list);
  864. epnum = urb->ep->desc.bEndpointAddress;
  865. #ifdef EHCI_URB_TRACE
  866. ehci_dbg (ehci,
  867. "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
  868. __func__, urb->dev->devpath, urb,
  869. epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out",
  870. urb->transfer_buffer_length,
  871. qtd, urb->ep->hcpriv);
  872. #endif
  873. spin_lock_irqsave (&ehci->lock, flags);
  874. if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
  875. &ehci_to_hcd(ehci)->flags))) {
  876. rc = -ESHUTDOWN;
  877. goto done;
  878. }
  879. rc = usb_hcd_link_urb_to_ep(ehci_to_hcd(ehci), urb);
  880. if (unlikely(rc))
  881. goto done;
  882. qh = qh_append_tds(ehci, urb, qtd_list, epnum, &urb->ep->hcpriv);
  883. if (unlikely(qh == NULL)) {
  884. usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb);
  885. rc = -ENOMEM;
  886. goto done;
  887. }
  888. /* Control/bulk operations through TTs don't need scheduling,
  889. * the HC and TT handle it when the TT has a buffer ready.
  890. */
  891. if (likely (qh->qh_state == QH_STATE_IDLE))
  892. qh_link_async (ehci, qh_get (qh));
  893. done:
  894. spin_unlock_irqrestore (&ehci->lock, flags);
  895. if (unlikely (qh == NULL))
  896. qtd_list_free (ehci, urb, qtd_list);
  897. return rc;
  898. }
  899. /*-------------------------------------------------------------------------*/
  900. /* the async qh for the qtds being reclaimed are now unlinked from the HC */
  901. static void end_unlink_async (struct ehci_hcd *ehci)
  902. {
  903. struct ehci_qh *qh = ehci->reclaim;
  904. struct ehci_qh *next;
  905. iaa_watchdog_done(ehci);
  906. // qh->hw_next = cpu_to_hc32(qh->qh_dma);
  907. qh->qh_state = QH_STATE_IDLE;
  908. qh->qh_next.qh = NULL;
  909. qh_put (qh); // refcount from reclaim
  910. /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
  911. next = qh->reclaim;
  912. ehci->reclaim = next;
  913. qh->reclaim = NULL;
  914. qh_completions (ehci, qh);
  915. if (!list_empty (&qh->qtd_list)
  916. && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
  917. qh_link_async (ehci, qh);
  918. else {
  919. qh_put (qh); // refcount from async list
  920. /* it's not free to turn the async schedule on/off; leave it
  921. * active but idle for a while once it empties.
  922. */
  923. if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state)
  924. && ehci->async->qh_next.qh == NULL)
  925. timer_action (ehci, TIMER_ASYNC_OFF);
  926. }
  927. if (next) {
  928. ehci->reclaim = NULL;
  929. start_unlink_async (ehci, next);
  930. }
  931. }
  932. /* makes sure the async qh will become idle */
  933. /* caller must own ehci->lock */
  934. static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
  935. {
  936. int cmd = ehci_readl(ehci, &ehci->regs->command);
  937. struct ehci_qh *prev;
  938. #ifdef DEBUG
  939. assert_spin_locked(&ehci->lock);
  940. if (ehci->reclaim
  941. || (qh->qh_state != QH_STATE_LINKED
  942. && qh->qh_state != QH_STATE_UNLINK_WAIT)
  943. )
  944. BUG ();
  945. #endif
  946. /* stop async schedule right now? */
  947. if (unlikely (qh == ehci->async)) {
  948. /* can't get here without STS_ASS set */
  949. if (ehci_to_hcd(ehci)->state != HC_STATE_HALT
  950. && !ehci->reclaim) {
  951. /* ... and CMD_IAAD clear */
  952. ehci_writel(ehci, cmd & ~CMD_ASE,
  953. &ehci->regs->command);
  954. wmb ();
  955. // handshake later, if we need to
  956. timer_action_done (ehci, TIMER_ASYNC_OFF);
  957. }
  958. return;
  959. }
  960. qh->qh_state = QH_STATE_UNLINK;
  961. ehci->reclaim = qh = qh_get (qh);
  962. prev = ehci->async;
  963. while (prev->qh_next.qh != qh)
  964. prev = prev->qh_next.qh;
  965. prev->hw_next = qh->hw_next;
  966. prev->qh_next = qh->qh_next;
  967. wmb ();
  968. /* If the controller isn't running, we don't have to wait for it */
  969. if (unlikely(!HC_IS_RUNNING(ehci_to_hcd(ehci)->state))) {
  970. /* if (unlikely (qh->reclaim != 0))
  971. * this will recurse, probably not much
  972. */
  973. end_unlink_async (ehci);
  974. return;
  975. }
  976. cmd |= CMD_IAAD;
  977. ehci_writel(ehci, cmd, &ehci->regs->command);
  978. (void)ehci_readl(ehci, &ehci->regs->command);
  979. iaa_watchdog_start(ehci);
  980. }
  981. /*-------------------------------------------------------------------------*/
  982. static void scan_async (struct ehci_hcd *ehci)
  983. {
  984. struct ehci_qh *qh;
  985. enum ehci_timer_action action = TIMER_IO_WATCHDOG;
  986. ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index);
  987. timer_action_done (ehci, TIMER_ASYNC_SHRINK);
  988. rescan:
  989. qh = ehci->async->qh_next.qh;
  990. if (likely (qh != NULL)) {
  991. do {
  992. /* clean any finished work for this qh */
  993. if (!list_empty (&qh->qtd_list)
  994. && qh->stamp != ehci->stamp) {
  995. int temp;
  996. /* unlinks could happen here; completion
  997. * reporting drops the lock. rescan using
  998. * the latest schedule, but don't rescan
  999. * qhs we already finished (no looping).
  1000. */
  1001. qh = qh_get (qh);
  1002. qh->stamp = ehci->stamp;
  1003. temp = qh_completions (ehci, qh);
  1004. qh_put (qh);
  1005. if (temp != 0) {
  1006. goto rescan;
  1007. }
  1008. }
  1009. /* unlink idle entries, reducing DMA usage as well
  1010. * as HCD schedule-scanning costs. delay for any qh
  1011. * we just scanned, there's a not-unusual case that it
  1012. * doesn't stay idle for long.
  1013. * (plus, avoids some kind of re-activation race.)
  1014. */
  1015. if (list_empty(&qh->qtd_list)
  1016. && qh->qh_state == QH_STATE_LINKED) {
  1017. if (!ehci->reclaim
  1018. && ((ehci->stamp - qh->stamp) & 0x1fff)
  1019. >= (EHCI_SHRINK_FRAMES * 8))
  1020. start_unlink_async(ehci, qh);
  1021. else
  1022. action = TIMER_ASYNC_SHRINK;
  1023. }
  1024. qh = qh->qh_next.qh;
  1025. } while (qh);
  1026. }
  1027. if (action == TIMER_ASYNC_SHRINK)
  1028. timer_action (ehci, TIMER_ASYNC_SHRINK);
  1029. }