diff options
author | Douglas Anderson <dianders@chromium.org> | 2016-01-28 21:20:06 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@kernel.org> | 2016-03-04 08:14:43 -0500 |
commit | 2d3f139810cd5d491d8dc8c3332c9d32b9b8e1f1 (patch) | |
tree | f304aefe7510011ba556f462244a31a446cac15c | |
parent | b951c6c7f875d2c72c6e16a4d5fa810cbb33ae32 (diff) |
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: John Youn <johnyoun@synopsys.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
-rw-r--r-- | drivers/usb/dwc2/hcd_queue.c | 112 |
1 files changed, 67 insertions, 45 deletions
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 8a2067bc1e62..9ce407e5017d 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c | |||
@@ -245,6 +245,70 @@ static int dwc2_find_uframe(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
245 | } | 245 | } |
246 | 246 | ||
247 | /** | 247 | /** |
248 | * dwc2_do_reserve() - Make a periodic reservation | ||
249 | * | ||
250 | * Try to allocate space in the periodic schedule. Depending on parameters | ||
251 | * this might use the microframe scheduler or the dumb scheduler. | ||
252 | * | ||
253 | * @hsotg: The HCD state structure for the DWC OTG controller | ||
254 | * @qh: QH for the periodic transfer. | ||
255 | * | ||
256 | * Returns: 0 upon success; error upon failure. | ||
257 | */ | ||
258 | static int dwc2_do_reserve(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | ||
259 | { | ||
260 | int status; | ||
261 | |||
262 | if (hsotg->core_params->uframe_sched > 0) { | ||
263 | int frame = -1; | ||
264 | |||
265 | status = dwc2_find_uframe(hsotg, qh); | ||
266 | if (status == 0) | ||
267 | frame = 7; | ||
268 | else if (status > 0) | ||
269 | frame = status - 1; | ||
270 | |||
271 | /* Set the new frame up */ | ||
272 | if (frame >= 0) { | ||
273 | qh->next_active_frame &= ~0x7; | ||
274 | qh->next_active_frame |= (frame & 7); | ||
275 | dwc2_sch_dbg(hsotg, | ||
276 | "QH=%p sched_p nxt=%04x, uf=%d\n", | ||
277 | qh, qh->next_active_frame, frame); | ||
278 | } | ||
279 | |||
280 | if (status > 0) | ||
281 | status = 0; | ||
282 | } else { | ||
283 | status = dwc2_periodic_channel_available(hsotg); | ||
284 | if (status) { | ||
285 | dev_info(hsotg->dev, | ||
286 | "%s: No host channel available for periodic transfer\n", | ||
287 | __func__); | ||
288 | return status; | ||
289 | } | ||
290 | |||
291 | status = dwc2_check_periodic_bandwidth(hsotg, qh); | ||
292 | } | ||
293 | |||
294 | if (status) { | ||
295 | dev_dbg(hsotg->dev, | ||
296 | "%s: Insufficient periodic bandwidth for periodic transfer\n", | ||
297 | __func__); | ||
298 | return status; | ||
299 | } | ||
300 | |||
301 | if (hsotg->core_params->uframe_sched <= 0) | ||
302 | /* Reserve periodic channel */ | ||
303 | hsotg->periodic_channels++; | ||
304 | |||
305 | /* Update claimed usecs per (micro)frame */ | ||
306 | hsotg->periodic_usecs += qh->host_us; | ||
307 | |||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | /** | ||
248 | * dwc2_do_unreserve() - Actually release the periodic reservation | 312 | * dwc2_do_unreserve() - Actually release the periodic reservation |
249 | * | 313 | * |
250 | * This function actually releases the periodic bandwidth that was reserved | 314 | * This function actually releases the periodic bandwidth that was reserved |
@@ -393,51 +457,9 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
393 | * that case. | 457 | * that case. |
394 | */ | 458 | */ |
395 | if (!qh->unreserve_pending) { | 459 | if (!qh->unreserve_pending) { |
396 | if (hsotg->core_params->uframe_sched > 0) { | 460 | status = dwc2_do_reserve(hsotg, qh); |
397 | int frame = -1; | 461 | if (status) |
398 | |||
399 | status = dwc2_find_uframe(hsotg, qh); | ||
400 | if (status == 0) | ||
401 | frame = 7; | ||
402 | else if (status > 0) | ||
403 | frame = status - 1; | ||
404 | |||
405 | /* Set the new frame up */ | ||
406 | if (frame >= 0) { | ||
407 | qh->next_active_frame &= ~0x7; | ||
408 | qh->next_active_frame |= (frame & 7); | ||
409 | dwc2_sch_dbg(hsotg, | ||
410 | "QH=%p sched_p nxt=%04x, uf=%d\n", | ||
411 | qh, qh->next_active_frame, frame); | ||
412 | } | ||
413 | |||
414 | if (status > 0) | ||
415 | status = 0; | ||
416 | } else { | ||
417 | status = dwc2_periodic_channel_available(hsotg); | ||
418 | if (status) { | ||
419 | dev_info(hsotg->dev, | ||
420 | "%s: No host channel available for periodic transfer\n", | ||
421 | __func__); | ||
422 | return status; | ||
423 | } | ||
424 | |||
425 | status = dwc2_check_periodic_bandwidth(hsotg, qh); | ||
426 | } | ||
427 | |||
428 | if (status) { | ||
429 | dev_dbg(hsotg->dev, | ||
430 | "%s: Insufficient periodic bandwidth for periodic transfer\n", | ||
431 | __func__); | ||
432 | return status; | 462 | return status; |
433 | } | ||
434 | |||
435 | if (hsotg->core_params->uframe_sched <= 0) | ||
436 | /* Reserve periodic channel */ | ||
437 | hsotg->periodic_channels++; | ||
438 | |||
439 | /* Update claimed usecs per (micro)frame */ | ||
440 | hsotg->periodic_usecs += qh->host_us; | ||
441 | } | 463 | } |
442 | 464 | ||
443 | qh->unreserve_pending = 0; | 465 | qh->unreserve_pending = 0; |
@@ -450,7 +472,7 @@ static int dwc2_schedule_periodic(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) | |||
450 | list_add_tail(&qh->qh_list_entry, | 472 | list_add_tail(&qh->qh_list_entry, |
451 | &hsotg->periodic_sched_inactive); | 473 | &hsotg->periodic_sched_inactive); |
452 | 474 | ||
453 | return status; | 475 | return 0; |
454 | } | 476 | } |
455 | 477 | ||
456 | /** | 478 | /** |