LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
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>,
	linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Chipidea USB device goes infinite loop due to interrupt while hw_ep_prime
Date: Mon, 9 Aug 2021 09:27:47 +0800	[thread overview]
Message-ID: <20210809012747.GA6814@nchen> (raw)
In-Reply-To: <CAJk_X9gwa+4CZRemKqW7XZzxd438EQHA-Ngp4MdmPVgHM0Q5fg@mail.gmail.com>

On 21-08-04 11:03:44, Jeaho Hwang wrote:
> Hi. linux-usb and linux-rt experts.
> >
> > On 21-08-02 17:35:01, Jeaho Hwang wrote:
> > > Hi.
> > >
> > > We found an infinite loop inside the function hw_ep_set_halt
> > > (drivers/usb/chipidea/udc.c) if a cablle is repeatedly
> > > connnected/disconnected while ping through RNDIS with chipidea USB device.
> > >
> > > Using ftrace tracing, we found that hw_ep_set_halt is called due to error
> > > return of hw_ep_prime(drivers/usb/chipidea/udc.c:202) which is called from
> > > isr_tr_complete_handler -> isr_setup_status_phase -> _ep_queue.
> > >
> > > The comment of function hw_ep_prime says (execute without interruption) but
> > > timer interrupt is occurred while hw_ep_prime is executing. We believe that
> > > the interrupt causes an error return of hw_ep_prime. We tried to protect
> > > hw_ep_prime from irqs and then no case of the infinite loop is occurred.
> > >
> > > I want ask if it is appropriate way that turning off irq inside (threaded)
> > > irq handlers. And should we explicitly turn off irqs before calling
> > > hw_ep_prime?
> > >
> >
> > Jeaho, do you use RT-Linux or standard Linux? The function hw_ep_prime is
> > only called at udc_irq which is registered as top-half irq handlers.
> > Why the timer interrupt is occurred when hw_ep_prime is executing?
> 
> We use preempt_RT so timer interrupt could be occurred. Now I found
> out that forced threaded irq handler disables local irq on standard
> linux so It is a linux-rt issue. Then should I make patch which
> disables local irqs during hw_ep_prime for RT kernel and suggest it to
> linux-rt maintainers?
> 
> Thanks for a kind answer Peter.
> 

No, that will lead to deadlock since the normal request queue API function
ep_queue disables irq which also calls into hw_ep_prime.

For RT kernel, you may try to disable local irq at isr_setup_status_phase.

-- 

Thanks,
Peter Chen


  reply	other threads:[~2021-08-09  1:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJk_X9hBB_edByfEvueSyWgKjpYGZbS2rPLPCSpRrPr+icFz_Q@mail.gmail.com>
     [not found] ` <20210804013252.GA16420@nchen>
2021-08-04  2:03   ` Jeaho Hwang
2021-08-09  1:27     ` Peter Chen [this message]
2021-08-09  1:45       ` Jeaho Hwang
2021-08-09  6:31         ` Peter Chen

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=20210809012747.GA6814@nchen \
    --to=peter.chen@kernel.org \
    --cc=jhhwang@rtst.co.kr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mkbyeon@lselectric.co.kr \
    --cc=team-linux@rtst.co.kr \
    --subject='Re: Chipidea USB device goes infinite loop due to interrupt while hw_ep_prime' \
    /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

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).