mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: mathias.nyman@intel.com, Greg KH <gregkh@linuxfoundation.org>,
	USB <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [RFC] usb: host: xhci: Remove the watchdog timer and use command timer to watch stop endpoint command
Date: Thu, 1 Dec 2016 15:44:06 +0800	[thread overview]
Message-ID: <583FD4C6.7020306@linux.intel.com> (raw)
In-Reply-To: <CAMz4ku+hOiFGq7v6FbcN+NES9xZAm9TiXRQgE2gRxVKhVGrGkA@mail.gmail.com>

Hi,

On 12/01/2016 03:35 PM, Baolin Wang wrote:
> On 1 December 2016 at 14:35, Lu Baolu <baolu.lu@linux.intel.com> wrote:
>> Hi,
>>
>> On 12/01/2016 02:04 PM, Baolin Wang wrote:
>>> Hi Baolu,
>>>
>>> On 1 December 2016 at 13:45, Lu Baolu <baolu.lu@linux.intel.com> wrote:
>>>> Hi,
>>>>
>>>> On 11/30/2016 05:02 PM, Baolin Wang wrote:
>>>>> If the hardware never responds to the stop endpoint command, the
>>>>> URBs will never be completed, and we might hang the USB subsystem.
>>>>> The original watchdog timer is used to watch if one stop endpoint
>>>>> command is timeout, if timeout, then the watchdog timer will set
>>>>> XHCI_STATE_DYING, try to halt the xHCI host, and give back all
>>>>> pending URBs.
>>>>>
>>>>> But now we already have one command timer to control command timeout,
>>>>> thus we can also use the command timer to watch the stop endpoint
>>>>> command, instead of one duplicate watchdog timer which need to be
>>>>> removed.
>>>>>
>>>>> Meanwhile we don't need the 'stop_cmds_pending' flag to identy if
>>>>> this is the last stop endpoint command of one endpoint. Since we
>>>>> can make sure we only set one stop endpoint command for one endpoint
>>>>> by 'EP_HALT_PENDING' flag in xhci_urb_dequeue() function. Thus remove
>>>>> this flag.
>>>> I am afraid you can't do this. "stop_cmds_pending" was added
>>>> to fix the problem described in the comments that you want to
>>>> remove. But I didn't find any fix of this problem in your patch.
>>> Now we can not pending another stop endpoint command for the same one
>>> endpoint, since will check 'EP_HALT_PENDING' flag in
>>> xhci_urb_dequeue() function to avoid this. But after some
>>> investigation, I think I missed the stop endpoint command in
>>> xhci_stop_device() which did not check the 'EP_HALT_PENDING' flag,
>>> maybe need to add 'EP_HALT_PENDING' flag checking in
>>> xhci_stop_device() function. DId I miss something else? Thanks.
>> Consider below three threads running on different CPUs at the same time.
>>
>> Thread A: xhci_handle_cmd_stop_ep()  --- in interrupt handler
>> Thread B: xhci_stop_endpoint_command_timeout() --- timer expired
>> Thread C: xhci_urb_dequeue --- called by usb core
>>
>> They are serialized by xhci->lock. Let's consider below sequence:
>>
>> Thread A:
>>     - delete xhci->cmd_timer), but will fail due to Thread B.
>>     - clear EP_HALT_PENDING bit
>>
>> Thread B:
>>     - halt the host controller
>>
>> Thread C:
>>     - set EP_HALT_PENDING bit
>>     - enqueue another stop endpoint command
>>     - add the timer back
> Ah, thanks for you comments.
> If thread B halted the host, then the thread C xhci_urb_dequeue() will
> check host state failed, then just return and can not set another stop
> endpoint command.

Not so simple. Thread B will release xhci->lock before xhci_halt().

> But from your example, I think your meaning is we
> should not halt the host by thread B, since we have handled the stop
> endpoint command event.
>
> So I think we need to check the xhci command of this stop endpoint
> command in xhci_stop_endpoint_command_timeout(), if the xhci command
> of this stop endpoint command is not in the command list (which means
> the stop endpoint command event has been handled), then just return
> and do not halt the controller. Right?
>

I'd like suggest you to put this change into a separated patch.
It's actually a different topic from the main purpose of this patch.

Best regards,
Lu Baolu

  reply	other threads:[~2016-12-01  7:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  9:02 Baolin Wang
2016-11-30 14:09 ` Mathias Nyman
2016-12-01  4:54   ` Baolin Wang
2016-12-01 13:28     ` Mathias Nyman
2016-12-02  2:46       ` Baolin Wang
2016-12-01  5:45 ` Lu Baolu
2016-12-01  6:04   ` Baolin Wang
2016-12-01  6:09     ` Baolin Wang
2016-12-01  6:35     ` Lu Baolu
2016-12-01  7:35       ` Baolin Wang
2016-12-01  7:44         ` Lu Baolu [this message]
2016-12-01  8:03           ` Baolin Wang
2016-12-02  1:17             ` Lu Baolu
2016-12-02  2:48               ` Baolin Wang

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=583FD4C6.7020306@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.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

Powered by JetHome