usb: dwc3: gadget: split scatterlist and linear handlers
instead of having one big loop, let's split it down into two smaller handlers: one for linear buffers and one for scatterlist. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Родитель
d5044a04b5
Коммит
d36929538f
|
@ -2271,6 +2271,45 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep *dep,
|
||||||
|
struct dwc3_request *req, const struct dwc3_event_depevt *event,
|
||||||
|
int status)
|
||||||
|
{
|
||||||
|
struct dwc3_trb *trb = &dep->trb_pool[dep->trb_dequeue];
|
||||||
|
struct scatterlist *sg = req->sg;
|
||||||
|
struct scatterlist *s;
|
||||||
|
unsigned int pending = req->num_pending_sgs;
|
||||||
|
unsigned int i;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
for_each_sg(sg, s, pending, i) {
|
||||||
|
trb = &dep->trb_pool[dep->trb_dequeue];
|
||||||
|
|
||||||
|
if (trb->ctrl & DWC3_TRB_CTRL_HWO)
|
||||||
|
break;
|
||||||
|
|
||||||
|
req->sg = sg_next(s);
|
||||||
|
req->num_pending_sgs--;
|
||||||
|
|
||||||
|
ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req,
|
||||||
|
trb, event, status, true);
|
||||||
|
if (ret)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep,
|
||||||
|
struct dwc3_request *req, const struct dwc3_event_depevt *event,
|
||||||
|
int status)
|
||||||
|
{
|
||||||
|
struct dwc3_trb *trb = &dep->trb_pool[dep->trb_dequeue];
|
||||||
|
|
||||||
|
return dwc3_gadget_ep_reclaim_completed_trb(dep, req, trb,
|
||||||
|
event, status, false);
|
||||||
|
}
|
||||||
|
|
||||||
static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep,
|
static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep,
|
||||||
const struct dwc3_event_depevt *event, int status)
|
const struct dwc3_event_depevt *event, int status)
|
||||||
{
|
{
|
||||||
|
@ -2284,32 +2323,12 @@ static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep,
|
||||||
|
|
||||||
length = req->request.length;
|
length = req->request.length;
|
||||||
chain = req->num_pending_sgs > 0;
|
chain = req->num_pending_sgs > 0;
|
||||||
if (chain) {
|
if (chain)
|
||||||
struct scatterlist *sg = req->sg;
|
ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event,
|
||||||
struct scatterlist *s;
|
status);
|
||||||
unsigned int pending = req->num_pending_sgs;
|
else
|
||||||
unsigned int i;
|
ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
|
||||||
|
status);
|
||||||
for_each_sg(sg, s, pending, i) {
|
|
||||||
trb = &dep->trb_pool[dep->trb_dequeue];
|
|
||||||
|
|
||||||
if (trb->ctrl & DWC3_TRB_CTRL_HWO)
|
|
||||||
break;
|
|
||||||
|
|
||||||
req->sg = sg_next(s);
|
|
||||||
req->num_pending_sgs--;
|
|
||||||
|
|
||||||
ret = dwc3_gadget_ep_reclaim_completed_trb(dep,
|
|
||||||
req, trb, event, status,
|
|
||||||
chain);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trb = &dep->trb_pool[dep->trb_dequeue];
|
|
||||||
ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req,
|
|
||||||
trb, event, status, chain);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req->unaligned || req->zero) {
|
if (req->unaligned || req->zero) {
|
||||||
trb = &dep->trb_pool[dep->trb_dequeue];
|
trb = &dep->trb_pool[dep->trb_dequeue];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче