summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/dwc2/dwc2_hcdqueue.c
diff options
context:
space:
mode:
authorjmatthew <jmatthew@openbsd.org>2015-06-28 11:48:18 +0000
committerjmatthew <jmatthew@openbsd.org>2015-06-28 11:48:18 +0000
commitc95c98b710cf80fbfde2d24d5100c7e638f69cac (patch)
tree22b6e6ac2f7d683cf72be879ea007def03b2c5bd /sys/dev/usb/dwc2/dwc2_hcdqueue.c
parentLDT is gone and not coming back (diff)
downloadwireguard-openbsd-c95c98b710cf80fbfde2d24d5100c7e638f69cac.tar.xz
wireguard-openbsd-c95c98b710cf80fbfde2d24d5100c7e638f69cac.zip
Convert list_head lists into TAILQs and LISTs and fix up header includes
so we can build dwc2 without extra stuff. tested by several edgerouter lite owners, ok jasper@
Diffstat (limited to 'sys/dev/usb/dwc2/dwc2_hcdqueue.c')
-rw-r--r--sys/dev/usb/dwc2/dwc2_hcdqueue.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/sys/dev/usb/dwc2/dwc2_hcdqueue.c b/sys/dev/usb/dwc2/dwc2_hcdqueue.c
index 7eb8162cba1..31bd3826254 100644
--- a/sys/dev/usb/dwc2/dwc2_hcdqueue.c
+++ b/sys/dev/usb/dwc2/dwc2_hcdqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dwc2_hcdqueue.c,v 1.6 2015/02/12 06:46:23 uebayasi Exp $ */
+/* $OpenBSD: dwc2_hcdqueue.c,v 1.7 2015/06/28 11:48:18 jmatthew Exp $ */
/* $NetBSD: dwc2_hcdqueue.c,v 1.11 2014/09/03 10:00:08 skrll Exp $ */
/*
@@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: dwc2_hcdqueue.c,v 1.11 2014/09/03 10:00:08 skrll Exp
#endif
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/types.h>
#include <sys/malloc.h>
#include <sys/pool.h>
@@ -59,8 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: dwc2_hcdqueue.c,v 1.11 2014/09/03 10:00:08 skrll Exp
#include <dev/usb/usbdivar.h>
#include <dev/usb/usb_mem.h>
-#include <dev/usb/dwc2/linux/kernel.h>
-
#include <dev/usb/dwc2/dwc2.h>
#include <dev/usb/dwc2/dwc2var.h>
@@ -91,8 +90,8 @@ STATIC void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
qh->data_toggle = DWC2_HC_PID_DATA0;
qh->maxp = dwc2_hcd_get_mps(&urb->pipe_info);
- INIT_LIST_HEAD(&qh->qtd_list);
- INIT_LIST_HEAD(&qh->qh_list_entry);
+ TAILQ_INIT(&qh->qtd_list);
+ qh->linked = 0;
/* FS/LS Endpoint on HS Hub, NOT virtual root hub */
dev_speed = dwc2_host_get_speed(hsotg, urb->priv);
@@ -540,11 +539,11 @@ STATIC int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
if (hsotg->core_params->dma_desc_enable > 0)
/* Don't rely on SOF and start in ready schedule */
- list_add_tail(&qh->qh_list_entry, &hsotg->periodic_sched_ready);
+ TAILQ_INSERT_TAIL(&hsotg->periodic_sched_ready, qh, qh_list_entry);
else
/* Always start in inactive schedule */
- list_add_tail(&qh->qh_list_entry,
- &hsotg->periodic_sched_inactive);
+ TAILQ_INSERT_TAIL(&hsotg->periodic_sched_inactive, qh, qh_list_entry);
+ qh->linked = 1;
if (hsotg->core_params->uframe_sched <= 0)
/* Reserve periodic channel */
@@ -568,7 +567,7 @@ STATIC void dwc2_deschedule_periodic(struct dwc2_hsotg *hsotg,
{
int i;
- list_del_init(&qh->qh_list_entry);
+ qh->linked = 0;
/* Update claimed usecs per (micro)frame */
hsotg->periodic_usecs -= qh->usecs;
@@ -602,15 +601,16 @@ int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
if (dbg_qh(qh))
dev_vdbg(hsotg->dev, "%s()\n", __func__);
- if (!list_empty(&qh->qh_list_entry))
+ if (qh->linked != 0) {
/* QH already in a schedule */
return 0;
+ }
/* Add the new QH to the appropriate schedule */
if (dwc2_qh_is_non_per(qh)) {
/* Always start in inactive schedule */
- list_add_tail(&qh->qh_list_entry,
- &hsotg->non_periodic_sched_inactive);
+ TAILQ_INSERT_TAIL(&hsotg->non_periodic_sched_inactive, qh, qh_list_entry);
+ qh->linked = 1;
return 0;
}
status = dwc2_schedule_periodic(hsotg, qh);
@@ -639,15 +639,26 @@ void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
dev_vdbg(hsotg->dev, "%s()\n", __func__);
- if (list_empty(&qh->qh_list_entry))
+ if (qh->linked == 0) {
/* QH is not in a schedule */
return;
+ }
if (dwc2_qh_is_non_per(qh)) {
- if (hsotg->non_periodic_qh_ptr == &qh->qh_list_entry)
+ if (hsotg->non_periodic_qh_ptr == qh) {
hsotg->non_periodic_qh_ptr =
- hsotg->non_periodic_qh_ptr->next;
- list_del_init(&qh->qh_list_entry);
+ TAILQ_NEXT(qh, qh_list_entry);
+ }
+
+ if (qh->channel) {
+ TAILQ_REMOVE(&hsotg->non_periodic_sched_active, qh, qh_list_entry);
+ } else {
+ TAILQ_REMOVE(&hsotg->non_periodic_sched_inactive, qh, qh_list_entry);
+ }
+ qh->linked = 0;
+
+ if (hsotg->non_periodic_qh_ptr == NULL)
+ hsotg->non_periodic_qh_ptr = TAILQ_FIRST(&hsotg->non_periodic_sched_active);
return;
}
dwc2_deschedule_periodic(hsotg, qh);
@@ -717,7 +728,7 @@ void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
if (dwc2_qh_is_non_per(qh)) {
dwc2_hcd_qh_unlink(hsotg, qh);
- if (!list_empty(&qh->qtd_list))
+ if (!TAILQ_EMPTY(&qh->qtd_list))
/* Add back to inactive non-periodic schedule */
dwc2_hcd_qh_add(hsotg, qh);
return;
@@ -735,7 +746,7 @@ void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
qh->sched_frame = frame_number;
}
- if (list_empty(&qh->qtd_list)) {
+ if (TAILQ_EMPTY(&qh->qtd_list)) {
dwc2_hcd_qh_unlink(hsotg, qh);
return;
}
@@ -743,13 +754,15 @@ void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
* Remove from periodic_sched_queued and move to
* appropriate queue
*/
+ TAILQ_REMOVE(&hsotg->periodic_sched_queued, qh, qh_list_entry);
if ((hsotg->core_params->uframe_sched > 0 &&
dwc2_frame_num_le(qh->sched_frame, frame_number)) ||
(hsotg->core_params->uframe_sched <= 0 &&
- qh->sched_frame == frame_number))
- list_move(&qh->qh_list_entry, &hsotg->periodic_sched_ready);
- else
- list_move(&qh->qh_list_entry, &hsotg->periodic_sched_inactive);
+ qh->sched_frame == frame_number)) {
+ TAILQ_INSERT_TAIL(&hsotg->periodic_sched_ready, qh, qh_list_entry);
+ } else {
+ TAILQ_INSERT_TAIL(&hsotg->periodic_sched_inactive, qh, qh_list_entry);
+ }
}
/**
@@ -821,7 +834,7 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd,
goto fail;
qtd->qh = *qh;
- list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list);
+ TAILQ_INSERT_TAIL(&(*qh)->qtd_list, qtd, qtd_list_entry);
return 0;
@@ -834,8 +847,7 @@ fail:
dwc2_hcd_qh_unlink(hsotg, qh_tmp);
/* Free each QTD in the QH's QTD list */
- list_for_each_entry_safe(qtd2, qtd2_tmp, &qh_tmp->qtd_list,
- qtd_list_entry)
+ TAILQ_FOREACH_SAFE(qtd2, &qh_tmp->qtd_list, qtd_list_entry, qtd2_tmp)
dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh_tmp);
dwc2_hcd_qh_free(hsotg, qh_tmp);
@@ -850,7 +862,7 @@ void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg,
{
struct dwc2_softc *sc = hsotg->hsotg_sc;
- list_del_init(&qtd->qtd_list_entry);
+ TAILQ_REMOVE(&qh->qtd_list, qtd, qtd_list_entry);
pool_put(&sc->sc_qtdpool, qtd);
}