Commit 2d3f1398 authored by Douglas Anderson's avatar Douglas Anderson Committed by Felipe Balbi

usb: dwc2: host: Split code out to make dwc2_do_reserve()

This no-op change splits code out of dwc2_schedule_periodic() into a
dwc2_do_reserve() function.  This makes it a little easier to follow the
logic.
Acked-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent b951c6c7
......@@ -244,6 +244,70 @@ static int dwc2_find_uframe(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
return ret;
}
/**
* dwc2_do_reserve() - Make a periodic reservation
*
* Try to allocate space in the periodic schedule. Depending on parameters
* this might use the microframe scheduler or the dumb scheduler.
*
* @hsotg: The HCD state structure for the DWC OTG controller
* @qh: QH for the periodic transfer.
*
* Returns: 0 upon success; error upon failure.
*/
static int dwc2_do_reserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
{
int status;
if (hsotg->core_params->uframe_sched > 0) {
int frame = -1;
status = dwc2_find_uframe(hsotg, qh);
if (status == 0)
frame = 7;
else if (status > 0)
frame = status - 1;
/* Set the new frame up */
if (frame >= 0) {
qh->next_active_frame &= ~0x7;
qh->next_active_frame |= (frame & 7);
dwc2_sch_dbg(hsotg,
"QH=%p sched_p nxt=%04x, uf=%d\n",
qh, qh->next_active_frame, frame);
}
if (status > 0)
status = 0;
} else {
status = dwc2_periodic_channel_available(hsotg);
if (status) {
dev_info(hsotg->dev,
"%s: No host channel available for periodic transfer\n",
__func__);
return status;
}
status = dwc2_check_periodic_bandwidth(hsotg, qh);
}
if (status) {
dev_dbg(hsotg->dev,
"%s: Insufficient periodic bandwidth for periodic transfer\n",
__func__);
return status;
}
if (hsotg->core_params->uframe_sched <= 0)
/* Reserve periodic channel */
hsotg->periodic_channels++;
/* Update claimed usecs per (micro)frame */
hsotg->periodic_usecs += qh->host_us;
return 0;
}
/**
* dwc2_do_unreserve() - Actually release the periodic reservation
*
......@@ -393,53 +457,11 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
* that case.
*/
if (!qh->unreserve_pending) {
if (hsotg->core_params->uframe_sched > 0) {
int frame = -1;
status = dwc2_find_uframe(hsotg, qh);
if (status == 0)
frame = 7;
else if (status > 0)
frame = status - 1;
/* Set the new frame up */
if (frame >= 0) {
qh->next_active_frame &= ~0x7;
qh->next_active_frame |= (frame & 7);
dwc2_sch_dbg(hsotg,
"QH=%p sched_p nxt=%04x, uf=%d\n",
qh, qh->next_active_frame, frame);
}
if (status > 0)
status = 0;
} else {
status = dwc2_periodic_channel_available(hsotg);
if (status) {
dev_info(hsotg->dev,
"%s: No host channel available for periodic transfer\n",
__func__);
return status;
}
status = dwc2_check_periodic_bandwidth(hsotg, qh);
}
if (status) {
dev_dbg(hsotg->dev,
"%s: Insufficient periodic bandwidth for periodic transfer\n",
__func__);
status = dwc2_do_reserve(hsotg, qh);
if (status)
return status;
}
if (hsotg->core_params->uframe_sched <= 0)
/* Reserve periodic channel */
hsotg->periodic_channels++;
/* Update claimed usecs per (micro)frame */
hsotg->periodic_usecs += qh->host_us;
}
qh->unreserve_pending = 0;
if (hsotg->core_params->dma_desc_enable > 0)
......@@ -450,7 +472,7 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
list_add_tail(&qh->qh_list_entry,
&hsotg->periodic_sched_inactive);
return status;
return 0;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment