Skip to content

Commit b25264f

Browse files
pawellcdnsgregkh
authored andcommitted
usb: cdnsp: Fix issue with Clear Feature Halt Endpoint
During handling Clear Halt Endpoint Feature request, driver invokes Reset Endpoint command. Because this command has some issue with transition endpoint from Running to Idle state the driver must stop the endpoint by using Stop Endpoint command. cc: <stable@vger.kernel.org> Fixes: 3d82904 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") Reviewed-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Pawel Laszczak <pawell@cadence.com> Link: https://lore.kernel.org/r/20221110063005.370656-1-pawell@cadence.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3aa07f7 commit b25264f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

drivers/usb/cdns3/cdnsp-gadget.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,11 @@ int cdnsp_halt_endpoint(struct cdnsp_device *pdev,
600600

601601
trace_cdnsp_ep_halt(value ? "Set" : "Clear");
602602

603-
if (value) {
604-
ret = cdnsp_cmd_stop_ep(pdev, pep);
605-
if (ret)
606-
return ret;
603+
ret = cdnsp_cmd_stop_ep(pdev, pep);
604+
if (ret)
605+
return ret;
607606

607+
if (value) {
608608
if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_STOPPED) {
609609
cdnsp_queue_halt_endpoint(pdev, pep->idx);
610610
cdnsp_ring_cmd_db(pdev);
@@ -613,10 +613,6 @@ int cdnsp_halt_endpoint(struct cdnsp_device *pdev,
613613

614614
pep->ep_state |= EP_HALTED;
615615
} else {
616-
/*
617-
* In device mode driver can call reset endpoint command
618-
* from any endpoint state.
619-
*/
620616
cdnsp_queue_reset_ep(pdev, pep->idx);
621617
cdnsp_ring_cmd_db(pdev);
622618
ret = cdnsp_wait_for_cmd_compl(pdev);

drivers/usb/cdns3/cdnsp-ring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,8 @@ int cdnsp_cmd_stop_ep(struct cdnsp_device *pdev, struct cdnsp_ep *pep)
20762076
u32 ep_state = GET_EP_CTX_STATE(pep->out_ctx);
20772077
int ret = 0;
20782078

2079-
if (ep_state == EP_STATE_STOPPED || ep_state == EP_STATE_DISABLED) {
2079+
if (ep_state == EP_STATE_STOPPED || ep_state == EP_STATE_DISABLED ||
2080+
ep_state == EP_STATE_HALTED) {
20802081
trace_cdnsp_ep_stopped_or_disabled(pep->out_ctx);
20812082
goto ep_stopped;
20822083
}

0 commit comments

Comments
 (0)