• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/usb/host/

Lines Matching refs:qh

251 	struct uhci_qh *qh;
253 qh = dma_pool_alloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle);
254 if (!qh)
257 memset(qh, 0, sizeof(*qh));
258 qh->dma_handle = dma_handle;
260 qh->element = UHCI_PTR_TERM;
261 qh->link = UHCI_PTR_TERM;
263 INIT_LIST_HEAD(&qh->queue);
264 INIT_LIST_HEAD(&qh->node);
267 qh->type = hep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
268 if (qh->type != USB_ENDPOINT_XFER_ISOC) {
269 qh->dummy_td = uhci_alloc_td(uhci);
270 if (!qh->dummy_td) {
271 dma_pool_free(uhci->qh_pool, qh, dma_handle);
275 qh->state = QH_STATE_IDLE;
276 qh->hep = hep;
277 qh->udev = udev;
278 hep->hcpriv = qh;
280 if (qh->type == USB_ENDPOINT_XFER_INT ||
281 qh->type == USB_ENDPOINT_XFER_ISOC)
282 qh->load = usb_calc_bus_time(udev->speed,
284 qh->type == USB_ENDPOINT_XFER_ISOC,
289 qh->state = QH_STATE_ACTIVE;
290 qh->type = -1;
292 return qh;
295 static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
297 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev);
298 if (!list_empty(&qh->queue)) {
299 dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh);
303 list_del(&qh->node);
304 if (qh->udev) {
305 qh->hep->hcpriv = NULL;
306 if (qh->dummy_td)
307 uhci_free_td(uhci, qh->dummy_td);
309 dma_pool_free(uhci->qh_pool, qh, qh->dma_handle);
319 static int uhci_cleanup_queue(struct uhci_hcd *uhci, struct uhci_qh *qh,
330 if (qh->type == USB_ENDPOINT_XFER_ISOC) {
332 qh->unlink_frame);
339 if (qh->queue.next != &urbp->node) {
355 if (qh_element(qh) == UHCI_PTR_TERM)
357 qh->element = UHCI_PTR_TERM;
360 if (qh->type == USB_ENDPOINT_XFER_CONTROL)
366 qh->needs_fixup = 1;
367 qh->initial_toggle = uhci_toggle(td_token(td));
377 static void uhci_fixup_toggles(struct uhci_qh *qh, int skip_first)
381 unsigned int toggle = qh->initial_toggle;
387 urbp = list_entry(qh->queue.next, struct urb_priv, node);
391 else if (qh_element(qh) != UHCI_PTR_TERM)
397 urbp = list_prepare_entry(urbp, &qh->queue, node);
398 list_for_each_entry_continue(urbp, &qh->queue, node) {
419 pipe = list_entry(qh->queue.next, struct urb_priv, node)->urb->pipe;
420 usb_settoggle(qh->udev, usb_pipeendpoint(pipe),
422 qh->needs_fixup = 0;
428 static inline void link_iso(struct uhci_hcd *uhci, struct uhci_qh *qh)
430 list_add_tail(&qh->node, &uhci->skel_iso_qh->node);
439 static void link_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh)
443 list_add_tail(&qh->node, &uhci->skelqh[qh->skel]->node);
445 pqh = list_entry(qh->node.prev, struct uhci_qh, node);
446 qh->link = pqh->link;
448 pqh->link = LINK_TO_QH(qh);
455 static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
464 if (pqh->skel <= qh->skel)
467 list_add(&qh->node, &pqh->node);
470 qh->link = pqh->link;
472 link_to_new_qh = LINK_TO_QH(qh);
477 if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR)
484 static void uhci_activate_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
486 WARN_ON(list_empty(&qh->queue));
490 if (qh_element(qh) == UHCI_PTR_TERM) {
491 struct urb_priv *urbp = list_entry(qh->queue.next,
496 qh->element = LINK_TO_TD(td);
500 qh->wait_expired = 0;
501 qh->advance_jiffies = jiffies;
503 if (qh->state == QH_STATE_ACTIVE)
505 qh->state = QH_STATE_ACTIVE;
509 if (qh == uhci->next_qh)
510 uhci->next_qh = list_entry(qh->node.next, struct uhci_qh,
512 list_del(&qh->node);
514 if (qh->skel == SKEL_ISO)
515 link_iso(uhci, qh);
516 else if (qh->skel < SKEL_ASYNC)
517 link_interrupt(uhci, qh);
519 link_async(uhci, qh);
525 static void unlink_interrupt(struct uhci_hcd *uhci, struct uhci_qh *qh)
529 pqh = list_entry(qh->node.prev, struct uhci_qh, node);
530 pqh->link = qh->link;
537 static void unlink_async(struct uhci_hcd *uhci, struct uhci_qh *qh)
540 __le32 link_to_next_qh = qh->link;
542 pqh = list_entry(qh->node.prev, struct uhci_qh, node);
547 if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR)
555 static void uhci_unlink_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
557 if (qh->state == QH_STATE_UNLINKING)
559 WARN_ON(qh->state != QH_STATE_ACTIVE || !qh->udev);
560 qh->state = QH_STATE_UNLINKING;
563 if (qh->skel == SKEL_ISO)
565 else if (qh->skel < SKEL_ASYNC)
566 unlink_interrupt(uhci, qh);
568 unlink_async(uhci, qh);
571 qh->unlink_frame = uhci->frame_number;
578 if (qh == uhci->next_qh)
579 uhci->next_qh = list_entry(qh->node.next, struct uhci_qh,
581 list_move_tail(&qh->node, &uhci->skel_unlink_qh->node);
590 static void uhci_make_qh_idle(struct uhci_hcd *uhci, struct uhci_qh *qh)
592 WARN_ON(qh->state == QH_STATE_ACTIVE);
594 if (qh == uhci->next_qh)
595 uhci->next_qh = list_entry(qh->node.next, struct uhci_qh,
597 list_move(&qh->node, &uhci->idle_qh_list);
598 qh->state = QH_STATE_IDLE;
601 if (qh->post_td) {
602 uhci_free_td(uhci, qh->post_td);
603 qh->post_td = NULL;
624 * Set qh->phase to the optimal phase for a periodic transfer and
627 static int uhci_check_bandwidth(struct uhci_hcd *uhci, struct uhci_qh *qh)
633 if (qh->phase >= 0)
634 minimax_load = uhci_highest_load(uhci, qh->phase, qh->period);
637 int max_phase = min_t(int, MAX_PHASE, qh->period);
639 qh->phase = 0;
640 minimax_load = uhci_highest_load(uhci, qh->phase, qh->period);
642 load = uhci_highest_load(uhci, phase, qh->period);
645 qh->phase = phase;
651 if (minimax_load + qh->load > 900) {
654 qh->period, qh->phase, minimax_load, qh->load);
663 static void uhci_reserve_bandwidth(struct uhci_hcd *uhci, struct uhci_qh *qh)
666 int load = qh->load;
669 for (i = qh->phase; i < MAX_PHASE; i += qh->period) {
675 switch (qh->type) {
685 qh->bandwidth_reserved = 1;
688 "reserve", qh->udev->devnum,
689 qh->hep->desc.bEndpointAddress, p,
690 qh->period, qh->phase, load);
696 static void uhci_release_bandwidth(struct uhci_hcd *uhci, struct uhci_qh *qh)
699 int load = qh->load;
702 for (i = qh->phase; i < MAX_PHASE; i += qh->period) {
708 switch (qh->type) {
718 qh->bandwidth_reserved = 0;
721 "release", qh->udev->devnum,
722 qh->hep->desc.bEndpointAddress, p,
723 qh->period, qh->phase, load);
797 struct uhci_qh *qh)
801 int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize);
819 td = qh->dummy_td;
898 qh->dummy_td->status |= __constant_cpu_to_le32(TD_CTRL_ACTIVE);
899 qh->dummy_td = td;
912 if (qh->state != QH_STATE_ACTIVE)
913 qh->skel = skel;
920 uhci_remove_td_from_urbp(qh->dummy_td);
928 struct uhci_qh *qh)
932 int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize);
958 td = qh->dummy_td;
1030 qh->dummy_td->status |= __constant_cpu_to_le32(TD_CTRL_ACTIVE);
1031 qh->dummy_td = td;
1039 uhci_remove_td_from_urbp(qh->dummy_td);
1044 struct uhci_qh *qh)
1052 if (qh->state != QH_STATE_ACTIVE)
1053 qh->skel = SKEL_BULK;
1054 ret = uhci_submit_common(uhci, urb, qh);
1061 struct uhci_qh *qh)
1070 if (!qh->bandwidth_reserved) {
1080 qh->period = 1 << exponent;
1081 qh->skel = SKEL_INDEX(exponent);
1085 qh->phase = (qh->period / 2) & (MAX_PHASE - 1);
1086 ret = uhci_check_bandwidth(uhci, qh);
1089 } else if (qh->period > urb->interval)
1092 ret = uhci_submit_common(uhci, urb, qh);
1094 urb->interval = qh->period;
1095 if (!qh->bandwidth_reserved)
1096 uhci_reserve_bandwidth(uhci, qh);
1105 struct uhci_qh *qh, struct urb_priv *urbp)
1112 if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
1118 qh->element = LINK_TO_TD(td);
1127 qh->initial_toggle = uhci_toggle(td_token(qh->post_td)) ^ 1;
1128 uhci_fixup_toggles(qh, 1);
1131 td = qh->post_td;
1132 qh->element = td->link;
1154 struct uhci_qh *qh = urbp->qh;
1182 uhci_show_qh(uhci, urbp->qh, errbuf,
1200 if (qh->post_td)
1201 uhci_free_td(uhci, qh->post_td);
1202 qh->post_td = td;
1217 qh->element = UHCI_PTR_TERM;
1218 qh->is_stopped = 1;
1219 qh->needs_fixup = (qh->type != USB_ENDPOINT_XFER_CONTROL);
1220 qh->initial_toggle = uhci_toggle(td_token(td)) ^
1224 ret = uhci_fixup_short_transfer(uhci, qh, urbp);
1232 struct uhci_qh *qh)
1245 if (!qh->bandwidth_reserved) {
1246 qh->period = urb->interval;
1248 qh->phase = -1; /* Find the best phase */
1249 i = uhci_check_bandwidth(uhci, qh);
1259 urb->start_frame = frame + ((qh->phase - frame) &
1260 (qh->period - 1));
1265 qh->phase = urb->start_frame & (qh->period - 1);
1266 i = uhci_check_bandwidth(uhci, qh);
1271 } else if (qh->period != urb->interval) {
1275 if (list_empty(&qh->queue)) {
1276 frame = qh->iso_frame;
1280 lurb = list_entry(qh->queue.prev,
1320 frame += qh->period;
1323 if (list_empty(&qh->queue)) {
1324 qh->iso_packet_desc = &urb->iso_frame_desc[0];
1325 qh->iso_frame = urb->start_frame;
1326 qh->iso_status = 0;
1329 qh->skel = SKEL_ISO;
1330 if (!qh->bandwidth_reserved)
1331 uhci_reserve_bandwidth(uhci, qh);
1339 struct uhci_qh *qh = urbp->qh;
1346 if (uhci_frame_before_eq(uhci->cur_iso_frame, qh->iso_frame))
1349 uhci_remove_tds_from_frame(uhci, qh->iso_frame);
1360 qh->iso_packet_desc->actual_length = actlength;
1361 qh->iso_packet_desc->status = status;
1366 qh->iso_status = status;
1371 qh->iso_frame += qh->period;
1372 ++qh->iso_packet_desc;
1374 return qh->iso_status;
1385 struct uhci_qh *qh;
1399 qh = (struct uhci_qh *) hep->hcpriv;
1401 qh = uhci_alloc_qh(uhci, urb->dev, hep);
1402 if (!qh)
1405 urbp->qh = qh;
1407 switch (qh->type) {
1409 ret = uhci_submit_control(uhci, urb, qh);
1412 ret = uhci_submit_bulk(uhci, urb, qh);
1415 ret = uhci_submit_interrupt(uhci, urb, qh);
1419 ret = uhci_submit_isochronous(uhci, urb, qh);
1426 urbp->qh = qh;
1427 list_add_tail(&urbp->node, &qh->queue);
1433 if (qh->queue.next == &urbp->node && !qh->is_stopped) {
1434 uhci_activate_qh(uhci, qh);
1440 if (qh->state == QH_STATE_IDLE)
1441 uhci_make_qh_idle(uhci, qh); /* Reclaim unused QH */
1456 struct uhci_qh *qh;
1462 qh = urbp->qh;
1465 if (qh->type == USB_ENDPOINT_XFER_ISOC) {
1472 qh->unlink_frame = uhci->frame_number;
1475 uhci_unlink_qh(uhci, qh);
1485 static void uhci_giveback_urb(struct uhci_hcd *uhci, struct uhci_qh *qh,
1494 if (qh->type == USB_ENDPOINT_XFER_ISOC &&
1495 urbp->node.prev == &qh->queue &&
1496 urbp->node.next != &qh->queue) {
1500 qh->iso_packet_desc = &nurb->iso_frame_desc[0];
1501 qh->iso_frame = nurb->start_frame;
1502 qh->iso_status = 0;
1508 if (list_empty(&qh->queue) && qh->needs_fixup) {
1510 usb_pipeout(urb->pipe), qh->initial_toggle);
1511 qh->needs_fixup = 0;
1522 if (list_empty(&qh->queue)) {
1523 uhci_unlink_qh(uhci, qh);
1524 if (qh->bandwidth_reserved)
1525 uhci_release_bandwidth(uhci, qh);
1532 #define QH_FINISHED_UNLINKING(qh) \
1533 (qh->state == QH_STATE_UNLINKING && \
1534 uhci->frame_number + uhci->is_stopped != qh->unlink_frame)
1536 static void uhci_scan_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
1542 while (!list_empty(&qh->queue)) {
1543 urbp = list_entry(qh->queue.next, struct urb_priv, node);
1546 if (qh->type == USB_ENDPOINT_XFER_ISOC)
1563 if (QH_FINISHED_UNLINKING(qh))
1564 qh->is_stopped = 1;
1565 else if (!qh->is_stopped)
1569 uhci_giveback_urb(uhci, qh, urb);
1570 if (status < 0 && qh->type != USB_ENDPOINT_XFER_ISOC)
1576 if (QH_FINISHED_UNLINKING(qh))
1577 qh->is_stopped = 1;
1578 else if (!qh->is_stopped)
1583 list_for_each_entry(urbp, &qh->queue, node) {
1590 if (!uhci_cleanup_queue(uhci, qh, urb)) {
1591 qh->is_stopped = 0;
1594 uhci_giveback_urb(uhci, qh, urb);
1598 qh->is_stopped = 0;
1602 if (!list_empty(&qh->queue)) {
1603 if (qh->needs_fixup)
1604 uhci_fixup_toggles(qh, 0);
1609 urbp = list_entry(qh->queue.next, struct urb_priv, node);
1610 if (urbp->fsbr && qh->wait_expired) {
1617 uhci_activate_qh(uhci, qh);
1622 else if (QH_FINISHED_UNLINKING(qh))
1623 uhci_make_qh_idle(uhci, qh);
1631 * Early Intel controllers have a bug which causes qh->element sometimes
1636 static int uhci_advance_check(struct uhci_hcd *uhci, struct uhci_qh *qh)
1643 if (qh->type == USB_ENDPOINT_XFER_ISOC)
1654 if (qh->state != QH_STATE_ACTIVE) {
1659 urbp = list_entry(qh->queue.next, struct urb_priv, node);
1665 qh->wait_expired = 0;
1666 qh->advance_jiffies = jiffies;
1673 if (qh->wait_expired)
1676 if (time_after(jiffies, qh->advance_jiffies + QH_WAIT_TIMEOUT)) {
1678 if (qh->post_td && qh_element(qh) == LINK_TO_TD(qh->post_td)) {
1679 qh->element = qh->post_td->link;
1680 qh->advance_jiffies = jiffies;
1685 qh->wait_expired = 1;
1692 uhci_unlink_qh(uhci, qh);
1710 struct uhci_qh *qh;
1730 while ((qh = uhci->next_qh) != uhci->skelqh[i]) {
1731 uhci->next_qh = list_entry(qh->node.next,
1734 if (uhci_advance_check(uhci, qh)) {
1735 uhci_scan_qh(uhci, qh);
1736 if (qh->state == QH_STATE_ACTIVE) {
1738 list_entry(qh->queue.next, struct urb_priv, node));