linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jeaho Hwang <jhhwang@rtst.co.kr>
Cc: Peter Chen <peter.chen@kernel.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	team-linux@rtst.co.kr, mkbyeon@lselectric.co.kr,
	khchoib@lselectric.co.kr
Subject: Re: [PATCH v2] usb: chipidea: add loop timeout for hw_ep_set_halt()
Date: Thu, 26 Aug 2021 13:17:30 +0200	[thread overview]
Message-ID: <YSd4Sp25RtT1b+rm@kroah.com> (raw)
In-Reply-To: <20210817064353.GA669425@ubuntu>

On Tue, Aug 17, 2021 at 03:43:53PM +0900, Jeaho Hwang wrote:
> If ctrl EP priming is failed (very rare case in standard linux),
> hw_ep_set_halt goes infinite loop. waiting 100 times was enough
> for zynq7000.
> 
> Signed-off-by: Jeaho Hwang <jhhwang@rtst.co.kr>
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 8834ca613721..d73fadb18f32 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -209,6 +209,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
>  	return 0;
>  }
>  
> +/* enough for zynq7000 evaluation board */
> +#define HW_EP_SET_HALT_COUNT_MAX 100
> +
>  /**
>   * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute
>   *                 without interruption)
> @@ -221,6 +224,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)

You need a blank line after "int count..."


>  		return -EINVAL;
>  
> @@ -232,9 +236,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;

Please spell this out:
	if (count)
		return 0;
	return -EAGAIN;

And will the caller properly handle this?

thanks,

greg k-h

      parent reply	other threads:[~2021-08-26 11:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  6:43 [PATCH v2] usb: chipidea: add loop timeout for hw_ep_set_halt() Jeaho Hwang
2021-08-24  8:31 ` Jeaho Hwang
2021-08-26 23:07   ` Peter Chen
2021-08-27  1:35     ` Jeaho Hwang
2021-08-28  1:38       ` Peter Chen
2021-08-28  3:10         ` Jeaho Hwang
2021-08-26 11:17 ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSd4Sp25RtT1b+rm@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jhhwang@rtst.co.kr \
    --cc=khchoib@lselectric.co.kr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mkbyeon@lselectric.co.kr \
    --cc=peter.chen@kernel.org \
    --cc=team-linux@rtst.co.kr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).