Commit acb7df23 authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb()

commit 19ec3123 upstream.

Let's call dwc3_ep0_prepare_one_trb() explicitly
because there are occasions where we will need more
than one TRB to handle an EP0 transfer.

A follow-up patch will fix one bug related to
multiple-TRB Data Phases when it comes to
mapping/unmapping requests for DMA.
Reported-by: default avatarJanusz Dziedzic <januszx.dziedzic@linux.intel.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ecd4ad9a
...@@ -85,8 +85,7 @@ static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum, ...@@ -85,8 +85,7 @@ static void dwc3_ep0_prepare_one_trb(struct dwc3 *dwc, u8 epnum,
trace_dwc3_prepare_trb(dep, trb); trace_dwc3_prepare_trb(dep, trb);
} }
static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum)
u32 len, u32 type, bool chain)
{ {
struct dwc3_gadget_ep_cmd_params params; struct dwc3_gadget_ep_cmd_params params;
struct dwc3_ep *dep; struct dwc3_ep *dep;
...@@ -98,8 +97,6 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, ...@@ -98,8 +97,6 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma,
return 0; return 0;
} }
dwc3_ep0_prepare_one_trb(dwc, epnum, buf_dma, len, type, chain);
memset(&params, 0, sizeof(params)); memset(&params, 0, sizeof(params));
params.param0 = upper_32_bits(dwc->ep0_trb_addr); params.param0 = upper_32_bits(dwc->ep0_trb_addr);
params.param1 = lower_32_bits(dwc->ep0_trb_addr); params.param1 = lower_32_bits(dwc->ep0_trb_addr);
...@@ -317,8 +314,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) ...@@ -317,8 +314,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
{ {
int ret; int ret;
ret = dwc3_ep0_start_trans(dwc, 0, dwc->ctrl_req_addr, 8, dwc3_ep0_prepare_one_trb(dwc, 0, dwc->ctrl_req_addr, 8,
DWC3_TRBCTL_CONTROL_SETUP, false); DWC3_TRBCTL_CONTROL_SETUP, false);
ret = dwc3_ep0_start_trans(dwc, 0);
WARN_ON(ret < 0); WARN_ON(ret < 0);
} }
...@@ -877,9 +875,9 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, ...@@ -877,9 +875,9 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
dwc->ep0_next_event = DWC3_EP0_COMPLETE; dwc->ep0_next_event = DWC3_EP0_COMPLETE;
ret = dwc3_ep0_start_trans(dwc, epnum, dwc3_ep0_prepare_one_trb(dwc, epnum, dwc->ctrl_req_addr,
dwc->ctrl_req_addr, 0, 0, DWC3_TRBCTL_CONTROL_DATA, false);
DWC3_TRBCTL_CONTROL_DATA, false); ret = dwc3_ep0_start_trans(dwc, epnum);
WARN_ON(ret < 0); WARN_ON(ret < 0);
} }
} }
...@@ -961,9 +959,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ...@@ -961,9 +959,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
req->direction = !!dep->number; req->direction = !!dep->number;
if (req->request.length == 0) { if (req->request.length == 0) {
ret = dwc3_ep0_start_trans(dwc, dep->number, dwc3_ep0_prepare_one_trb(dwc, dep->number,
dwc->ctrl_req_addr, 0, dwc->ctrl_req_addr, 0,
DWC3_TRBCTL_CONTROL_DATA, false); DWC3_TRBCTL_CONTROL_DATA, false);
ret = dwc3_ep0_start_trans(dwc, dep->number);
} else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) } else if (!IS_ALIGNED(req->request.length, dep->endpoint.maxpacket)
&& (dep->number == 0)) { && (dep->number == 0)) {
u32 transfer_size = 0; u32 transfer_size = 0;
...@@ -981,7 +980,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ...@@ -981,7 +980,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
if (req->request.length > DWC3_EP0_BOUNCE_SIZE) { if (req->request.length > DWC3_EP0_BOUNCE_SIZE) {
transfer_size = ALIGN(req->request.length - maxpacket, transfer_size = ALIGN(req->request.length - maxpacket,
maxpacket); maxpacket);
ret = dwc3_ep0_start_trans(dwc, dep->number, dwc3_ep0_prepare_one_trb(dwc, dep->number,
req->request.dma, req->request.dma,
transfer_size, transfer_size,
DWC3_TRBCTL_CONTROL_DATA, DWC3_TRBCTL_CONTROL_DATA,
...@@ -993,9 +992,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ...@@ -993,9 +992,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
dwc->ep0_bounced = true; dwc->ep0_bounced = true;
ret = dwc3_ep0_start_trans(dwc, dep->number, dwc3_ep0_prepare_one_trb(dwc, dep->number,
dwc->ep0_bounce_addr, transfer_size, dwc->ep0_bounce_addr, transfer_size,
DWC3_TRBCTL_CONTROL_DATA, false); DWC3_TRBCTL_CONTROL_DATA, false);
ret = dwc3_ep0_start_trans(dwc, dep->number);
} else { } else {
ret = usb_gadget_map_request(&dwc->gadget, &req->request, ret = usb_gadget_map_request(&dwc->gadget, &req->request,
dep->number); dep->number);
...@@ -1004,9 +1004,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, ...@@ -1004,9 +1004,10 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
return; return;
} }
ret = dwc3_ep0_start_trans(dwc, dep->number, req->request.dma, dwc3_ep0_prepare_one_trb(dwc, dep->number, req->request.dma,
req->request.length, DWC3_TRBCTL_CONTROL_DATA, req->request.length, DWC3_TRBCTL_CONTROL_DATA,
false); false);
ret = dwc3_ep0_start_trans(dwc, dep->number);
} }
WARN_ON(ret < 0); WARN_ON(ret < 0);
...@@ -1020,8 +1021,9 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) ...@@ -1020,8 +1021,9 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3 type = dwc->three_stage_setup ? DWC3_TRBCTL_CONTROL_STATUS3
: DWC3_TRBCTL_CONTROL_STATUS2; : DWC3_TRBCTL_CONTROL_STATUS2;
return dwc3_ep0_start_trans(dwc, dep->number, dwc3_ep0_prepare_one_trb(dwc, dep->number,
dwc->ctrl_req_addr, 0, type, false); dwc->ctrl_req_addr, 0, type, false);
return dwc3_ep0_start_trans(dwc, dep->number);
} }
static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
......
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