stream_id, short_not_ok, no_interrupt, is_last);
}
-static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
+static int dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
struct dwc3_request *req)
{
struct scatterlist *sg = req->start_sg;
unsigned int rem = length % maxp;
unsigned int remaining = req->request.num_mapped_sgs
- req->num_queued_sgs;
+ unsigned int num_trbs = req->num_trbs;
/*
* If we resume preparing the request, then get the remaining length of
if ((i == remaining - 1) || !length)
chain = false;
+ if (!dwc3_calc_trbs_left(dep))
+ break;
+
if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
/* prepare normal TRB */
if (req->request.length) {
+ if (dwc3_calc_trbs_left(dep) < 2)
+ goto out;
+
req->needs_extra_trb = true;
dwc3_prepare_one_trb(dep, req, trb_length,
true, i, false);
} else if (req->request.zero && req->request.length &&
!usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
!rem && !chain) {
+
+ if (dwc3_calc_trbs_left(dep) < 2)
+ goto out;
+
req->needs_extra_trb = true;
/* Prepare normal TRB */
if (!dwc3_calc_trbs_left(dep))
break;
}
+
+out:
+ return req->num_trbs - num_trbs;
}
-static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
+static int dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
struct dwc3_request *req)
{
unsigned int length = req->request.length;
unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
unsigned int rem = length % maxp;
+ unsigned int num_trbs = req->num_trbs;
+
+ if (!dwc3_calc_trbs_left(dep))
+ goto out;
if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) {
/* prepare normal TRB */
if (req->request.length) {
+ if (dwc3_calc_trbs_left(dep) < 2)
+ goto out;
+
req->needs_extra_trb = true;
dwc3_prepare_one_trb(dep, req, length, true, 0, false);
}
} else if (req->request.zero && req->request.length &&
!usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
(IS_ALIGNED(req->request.length, maxp))) {
+
+ if (dwc3_calc_trbs_left(dep) < 2)
+ goto out;
+
req->needs_extra_trb = true;
/* prepare normal TRB */
dwc3_prepare_one_trb(dep, req, req->direction ? 0 : maxp,
false, 1, true);
} else {
+ if (!dwc3_calc_trbs_left(dep))
+ goto out;
+
dwc3_prepare_one_trb(dep, req, length, false, 0, false);
}
+
+out:
+ return req->num_trbs - num_trbs;
}
/*