* [PATCH] usb: chipidea: add loop timeout for hw_ep_set_halt()
@ 2021-08-09 11:20 Jeaho Hwang
2021-08-13 7:08 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Jeaho Hwang @ 2021-08-09 11:20 UTC (permalink / raw)
To: Peter Chen, Greg Kroah-Hartman, linux-usb, linux-kernel
If ctrl EP priming is failed (very rare case in standard linux),
hw_ep_set_halt goes infinite loop. 50 was enough for zynq7000.
Signed-off-by: Jeaho Hwang <jhhwang@rtst.co.kr>
---
drivers/usb/chipidea/udc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index d0cd1de1b6c7..92ca0b7e4310 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -210,6 +210,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
return 0;
}
+/*will it be enough?*/
+#define HW_EP_SET_HALT_COUNT_MAX 100
+
/**
* hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute
* without interruption)
@@ -222,6 +225,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
*/
static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value)
{
+ int count = HW_EP_SET_HALT_COUNT_MAX;
if (value != 0 && value != 1)
return -EINVAL;
@@ -233,9 +237,9 @@ static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value)
/* data toggle - reserved for EP0 but it's in ESS */
hw_write(ci, reg, mask_xs|mask_xr,
value ? mask_xs : mask_xr);
- } while (value != hw_ep_get_halt(ci, num, dir));
+ } while (value != hw_ep_get_halt(ci, num, dir) && --count > 0);
- return 0;
+ return count ? 0 : -EAGAIN;
}
/**
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: chipidea: add loop timeout for hw_ep_set_halt()
2021-08-09 11:20 [PATCH] usb: chipidea: add loop timeout for hw_ep_set_halt() Jeaho Hwang
@ 2021-08-13 7:08 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-13 7:08 UTC (permalink / raw)
To: Jeaho Hwang; +Cc: Peter Chen, linux-usb, linux-kernel
On Mon, Aug 09, 2021 at 08:20:48PM +0900, Jeaho Hwang wrote:
> If ctrl EP priming is failed (very rare case in standard linux),
> hw_ep_set_halt goes infinite loop. 50 was enough for zynq7000.
>
> Signed-off-by: Jeaho Hwang <jhhwang@rtst.co.kr>
> ---
> drivers/usb/chipidea/udc.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index d0cd1de1b6c7..92ca0b7e4310 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -210,6 +210,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
> return 0;
> }
>
> +/*will it be enough?*/
Please use ' ' characters in your comments.
And can you answer this, please do not add a question in a comment, be
sure about this.
> +#define HW_EP_SET_HALT_COUNT_MAX 100
> +
> /**
> * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute
> * without interruption)
> @@ -222,6 +225,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
> */
> static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value)
> {
> + int count = HW_EP_SET_HALT_COUNT_MAX;
> if (value != 0 && value != 1)
Please use checkpatch.pl when submitting patches :(
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-13 7:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 11:20 [PATCH] usb: chipidea: add loop timeout for hw_ep_set_halt() Jeaho Hwang
2021-08-13 7:08 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).