You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
UPSTREAM: usb: dwc3: gadget: move cmd_endtransfer to extra function
This patch adds the extra function __dwc3_stop_active_transfer to
consolidate the same codepath.
Change-Id: I59d031db6eb52487f443fc6eef11214ca2d95234
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20220306211251.2281335-3-m.grzeschik@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit e192cc7b52)
This commit is contained in:
committed by
Tao Huang
parent
415b0d9d14
commit
0ec00e864a
@@ -1797,6 +1797,40 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)
|
||||
return DWC3_DSTS_SOFFN(reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* __dwc3_stop_active_transfer - stop the current active transfer
|
||||
* @dep: isoc endpoint
|
||||
* @force: set forcerm bit in the command
|
||||
* @interrupt: command complete interrupt after End Transfer command
|
||||
*
|
||||
* When setting force, the ForceRM bit will be set. In that case
|
||||
* the controller won't update the TRB progress on command
|
||||
* completion. It also won't clear the HWO bit in the TRB.
|
||||
* The command will also not complete immediately in that case.
|
||||
*/
|
||||
static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool interrupt)
|
||||
{
|
||||
struct dwc3_gadget_ep_cmd_params params;
|
||||
u32 cmd;
|
||||
int ret;
|
||||
|
||||
cmd = DWC3_DEPCMD_ENDTRANSFER;
|
||||
cmd |= force ? DWC3_DEPCMD_HIPRI_FORCERM : 0;
|
||||
cmd |= interrupt ? DWC3_DEPCMD_CMDIOC : 0;
|
||||
cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
||||
WARN_ON_ONCE(ret);
|
||||
dep->resource_index = 0;
|
||||
|
||||
if (!interrupt)
|
||||
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
|
||||
else if (!ret)
|
||||
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* dwc3_gadget_start_isoc_quirk - workaround invalid frame number
|
||||
* @dep: isoc endpoint
|
||||
@@ -1972,21 +2006,8 @@ static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
|
||||
* status, issue END_TRANSFER command and retry on the next XferNotReady
|
||||
* event.
|
||||
*/
|
||||
if (ret == -EAGAIN) {
|
||||
struct dwc3_gadget_ep_cmd_params params;
|
||||
u32 cmd;
|
||||
|
||||
cmd = DWC3_DEPCMD_ENDTRANSFER |
|
||||
DWC3_DEPCMD_CMDIOC |
|
||||
DWC3_DEPCMD_PARAM(dep->resource_index);
|
||||
|
||||
dep->resource_index = 0;
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
|
||||
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
||||
if (!ret)
|
||||
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
|
||||
}
|
||||
if (ret == -EAGAIN)
|
||||
ret = __dwc3_stop_active_transfer(dep, false, true);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -3855,10 +3876,6 @@ static void dwc3_reset_gadget(struct dwc3 *dwc)
|
||||
void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
|
||||
bool interrupt)
|
||||
{
|
||||
struct dwc3_gadget_ep_cmd_params params;
|
||||
u32 cmd;
|
||||
int ret;
|
||||
|
||||
if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) ||
|
||||
(dep->flags & DWC3_EP_DELAY_STOP) ||
|
||||
(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
|
||||
@@ -3891,19 +3908,7 @@ void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
|
||||
* This mode is NOT available on the DWC_usb31 IP.
|
||||
*/
|
||||
|
||||
cmd = DWC3_DEPCMD_ENDTRANSFER;
|
||||
cmd |= force ? DWC3_DEPCMD_HIPRI_FORCERM : 0;
|
||||
cmd |= interrupt ? DWC3_DEPCMD_CMDIOC : 0;
|
||||
cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
||||
WARN_ON_ONCE(ret);
|
||||
dep->resource_index = 0;
|
||||
|
||||
if (!interrupt)
|
||||
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
|
||||
else
|
||||
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
|
||||
__dwc3_stop_active_transfer(dep, force, interrupt);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dwc3_stop_active_transfer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user