linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linyu Yuan <quic_linyyuan@quicinc.com>
To: "Thinh Nguyen" <Thinh.Nguyen@synopsys.com>,
	정재훈 <jh0801.jung@samsung.com>
Cc: 'Felipe Balbi' <balbi@kernel.org>,
	'Greg Kroah-Hartman' <gregkh@linuxfoundation.org>,
	"'open list:USB XHCI DRIVER'" <linux-usb@vger.kernel.org>,
	'open list' <linux-kernel@vger.kernel.org>,
	'Seungchull Suh' <sc.suh@samsung.com>,
	'Daehwan Jung' <dh10.jung@samsung.com>
Subject: Re: [PATCH] usb: dwc3: Clear DWC3_EVENT_PENDING when count is 0
Date: Fri, 3 Feb 2023 10:18:57 +0800	[thread overview]
Message-ID: <1ffed097-af47-a179-3854-f7b238d8b6de@quicinc.com> (raw)
In-Reply-To: <20230202200650.cqntlk7m2krsafgd@synopsys.com>


On 2/3/2023 4:06 AM, Thinh Nguyen wrote:
> On Thu, Feb 02, 2023, Linyu Yuan wrote:
>> On 2/2/2023 2:57 AM, Thinh Nguyen wrote:
>>> On Tue, Jan 31, 2023, Linyu Yuan wrote:
>>>> hi Thinh,
>>>>
>>>>
>>>> regarding your suggestion, assume it is not PCIe type,  still have one
>>>> question,
>>>>
>>>>
>>>> -       if (evt->flags & DWC3_EVENT_PENDING)
>>>> +       if (evt->flags & DWC3_EVENT_PENDING) {
>>>> +               if (!evt->count) {
>>>> +                       u32 reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
>>>> +
>>>> +                       if (!(reg & DWC3_GEVNTSIZ_INTMASK))
>>>> +                               evt->flags &= ~DWC3_EVENT_PENDING;
>>>>
>>>> do we need to return IRQ_WAKE_THREAD  ?
>>> No, if evt->count is 0, but GEVNTCOUNT is > 0, the controller will
>>> generate interrupt. The evt->count will be updated and the events will
>>> be handled on the next interrupt.
>>
>> when will next interrupt happen ?
> Immediately after. You can test this by just return IRQ_HANDLED and not
> clear the GEVNTCOUNT to see its behavior.


if it immediately, it will be good.


정재훈  could you update a new patch which Thinh suggest.

maybe we didn't find the root cause of irq strom, but the change have no side effect.


>
>> as when enter here, i guess GEVENTCOUNT is already > 0, but we didn't read
>> it.
> GEVNTCOUNT is always updating as new events are generated. We only clear
> however many events we process, but that doesn't stop it from
> incrementing.


just consider if there is a case that next GEVNETCOUNT increase which 
happen long time later,

maybe think too much.


>
> BR,
> Thinh
>
>>
>>>> +               }
>>>>                   return IRQ_HANDLED;
>>>>
>>>> as here return IRQ HANDLED, how can we make sure a new IRQ will be handled
>>>> after previous IRQ thread clean PENDING flag ?
>>> If evt->count > 0, that means the bottom half is still running. So,
>>> leave it be. If evt->count == 0, then the cached events are processed,
>>> we're safe to clear the PENDING flag. New interrupt will be generated if
>>> GEVNTCOUNT is > 0.
>>>
>>>> +       }
>>>>
>>>>
>>>> also for non-PCIe controller, consider IRQ mask register working correctly,
>>>>
>>>> consider a case IRQ happen before IRQ thread exit,  here just return
>>>> IRQ_HANDLED.
>>>>
>>>> once IRQ thread exit, it will clean PENDING flag, so next IRQ event will run
>>>> normally.
>>>>
>>>> if 정재훈 saw PENDING flag is not cleared, does it mean IRQ thread have no
>>>> chance to exit ?
>>> The PENDING flag should be cleared eventually when the bottom half
>>> completes. I don't expect the interrupt storm to block the IRQ thread
>>> forever, but I can't guarantee the device behavor. 정재훈 can confirm.
>>> This change should resolve the interrupt storm.
>>>
>>> BR,
>>> Thinh

  reply	other threads:[~2023-02-03  2:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230102050839epcas2p4b9d09d926f9a14c3b8e8df2574d334c3@epcas2p4.samsung.com>
2023-01-02  5:08 ` [PATCH] usb: dwc3: Clear DWC3_EVENT_PENDING when count is 0 JaeHun Jung
2023-01-03 15:48   ` Felipe Balbi
2023-01-05  3:29   ` Linyu Yuan
2023-01-05  3:35     ` Linyu Yuan
2023-01-05  9:54       ` 정재훈
2023-01-06  3:13         ` Linyu Yuan
2023-01-09 18:28           ` Thinh Nguyen
2023-01-10  1:56             ` Linyu Yuan
2023-01-10  2:53               ` Thinh Nguyen
2023-01-10  3:05                 ` Linyu Yuan
2023-01-10  3:13                   ` Linyu Yuan
2023-01-10  7:38                     ` Linyu Yuan
2023-01-11  0:00                       ` Thinh Nguyen
2023-01-11  1:45                         ` Linyu Yuan
2023-01-11  2:27                           ` Thinh Nguyen
2023-01-31  6:38                             ` Linyu Yuan
2023-02-01 18:57                               ` Thinh Nguyen
2023-02-02  5:00                                 ` Linyu Yuan
2023-02-02 20:06                                   ` Thinh Nguyen
2023-02-03  2:18                                     ` Linyu Yuan [this message]
2023-01-09 18:35   ` Thinh Nguyen
2023-01-09 19:09     ` Thinh Nguyen

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=1ffed097-af47-a179-3854-f7b238d8b6de@quicinc.com \
    --to=quic_linyyuan@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=dh10.jung@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jh0801.jung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sc.suh@samsung.com \
    /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).