From: Peter Chen <peter.chen@kernel.org>
To: Jeaho Hwang <jhhwang@rtst.co.kr>
Cc: linux-usb@vger.kernel.org,
"변무광(Byeon Moo Kwang)/자동화연)Automation Platform연구팀"
<mkbyeon@lselectric.co.kr>, "Linux team" <team-linux@rtst.co.kr>
Subject: Re: Chipidea USB device goes infinite loop due to interrupt while hw_ep_prime
Date: Mon, 9 Aug 2021 09:40:51 +0800 [thread overview]
Message-ID: <20210809014051.GA7179@nchen> (raw)
In-Reply-To: <CAJk_X9gZ_dmQKeYJjkPZAQqdg==X=7s=XHtCg5cuu06z8Hd-GQ@mail.gmail.com>
On 21-08-04 12:11:31, Jeaho Hwang wrote:
> Thanks for the answer Peter. I still have two questions.
>
> 1) There's a busy loop in hw_ep_prime to wait for endpoint priming. Is
> it safe without timeout?
>
> 192 static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
> 193 {
> 194 int n = hw_ep_bit(num, dir);
> 195
> 196 /* Synchronize before ep prime */
> 197 wmb();
> 198
> 199 if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num)))
> 200 return -EAGAIN;
> 201
> 202 hw_write(ci, OP_ENDPTPRIME, ~0, BIT(n));
> 203
> 204 while (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
> 205 cpu_relax();
> 206 if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num)))
> 207 return -EAGAIN;
> 208
> 209 /* status shoult be tested according with manual but it doesn't work */
> 210 return 0;
> 211 }
You could add loop-timeout for it. Without timeout, it may lead issue,
I am not so sure.
>
> 2) We experienced an infinite loop in hw_ep_set_halt, which is called
> at isr_tr_complete_handler due to an error encountered that we
> reported in the previous mail. It seems that hw_write to set halt
> fails. Is it related to the interruption while hw_ep_prime is running?
> If we make a timeout for the loop and error return, are there any
> considerations for the caller functions?
>
> 223 static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value)
> 224 {
> 225 if (value != 0 && value != 1)
> 226 return -EINVAL;
> 227
> 228 do {
> 229 enum ci_hw_regs reg = OP_ENDPTCTRL + num;
> 230 u32 mask_xs = (dir == TX) ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
> 231 u32 mask_xr = (dir == TX) ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
> 232
> 233 /* data toggle - reserved for EP0 but it's in ESS */
> 234 hw_write(ci, reg, mask_xs|mask_xr,
> 235 value ? mask_xs : mask_xr);
> 236 } while (value != hw_ep_get_halt(ci, num, dir));
> 237
> 238 return 0;
> 239 }
If the error occurs for set halt, I think the transfer may stop, and it may
can't be recovered unless re-plug the cable. To not affect the whole system,
it is better to add loop-time mechanism.
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2021-08-09 1:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAJk_X9hBB_edByfEvueSyWgKjpYGZbS2rPLPCSpRrPr+icFz_Q@mail.gmail.com>
2021-08-04 1:32 ` Chipidea USB device goes infinite loop due to interrupt while hw_ep_prime Peter Chen
2021-08-04 2:03 ` Jeaho Hwang
2021-08-09 1:27 ` Peter Chen
2021-08-09 1:45 ` Jeaho Hwang
2021-08-09 6:31 ` Peter Chen
2021-08-04 3:11 ` Jeaho Hwang
2021-08-09 1:40 ` Peter Chen [this message]
2021-08-02 8:38 Jeaho Hwang
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=20210809014051.GA7179@nchen \
--to=peter.chen@kernel.org \
--cc=jhhwang@rtst.co.kr \
--cc=linux-usb@vger.kernel.org \
--cc=mkbyeon@lselectric.co.kr \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.