public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ZhenHua <zhen-hual@hp.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	tom.vaden@hp.com
Subject: Re: [PATCH 1/1] driver,usb: Fix a warning in uhci-hcd driver
Date: Fri, 26 Apr 2013 09:10:55 +0800	[thread overview]
Message-ID: <5179D41F.7070706@hp.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1304251039210.1185-100000@iolanthe.rowland.org>


On 04/25/2013 10:54 PM, Alan Stern wrote:
> On Thu, 25 Apr 2013, ZhenHua wrote:
>
>>>>> +#define UHCI_SUSPENDRH_RETRY_MAX      10
>>>>> +#define UHCI_SUSPENDRH_RETRY_DELAY    100
>>> Why is the delay set to 100 us?  Isn't that excessively large?  How
>>> long does it take for this controller to go into suspend?
>> This controller will take about 200~400 us, but I am not sure how long
>> other devices will take.
>> I set interval to 100 us,  so it will save more time.
> A 400-us delay is fairly long.  It would be better to avoid it
The device needs about 200~400 us to get stopped, not OS.
For other devices, it will not wait.
> entirely.
>
>>> Why are these variables u16?  Why not int?
>> uhci_readw will return u16.
> That's not a good reason, since u16 fits perfectly well inside an
> int.  But never mind...
>
>>> Anyway, a better approach would be not to add a delay loop at all.
>>> Instead, change this test:
>>>
>>> 	if (!auto_stop && !(uhci_readw(uhci, USBSTS) & USBSTS_HCH)) {
>>> 		uhci->rh_state = UHCI_RH_SUSPENDING;
>>> 		spin_unlock_irq(&uhci->lock);
>>> 		msleep(1);
>>> 		spin_lock_irq(&uhci->lock);
>>> 		if (uhci->dead)
>>> 			return;
>>> 	}
>>>
>>> When the iLo controller is present, make the "if" statement always
>>> succeed.  Then you'll get a whole 1-ms delay.
>> This will cause more operation and more time for other devices.
> Actually what I wrote was wrong anyway.  I forgot that when auto_stop
> is set, the routine is not allowed to sleep.
>
> A better way to solve your problem is to change uhci_hub_status_data().
> In the UHCI_RH_RUNNING_NODEVS case, change the line that says
>
> 		else if (time_after_eq(jiffies, uhci->auto_stop_time))
>
> to
>
> 		else if (time_after_eq(jiffies, uhci->auto_stop_time) &&
> 				!uhci->no_auto_stops)
>
> where uhci->no_auto_stops is a new bitflag that you set inside
> uhci_pci_init() if you detect that the controller is an iLo virtual
> UHCI controller.
>
> This way there will always be a 1-ms delay, so the slow controller will
> suspend successfully.  And other types of host controllers won't be
> affected, because the no_auto_stops flag won't get set for them.
>
> Alan Stern
>

I  think it is a good idea, and the logic of the code may be more 
clear.  I will do some test on my system.

Thanks
Zhen-Hua


  reply	other threads:[~2013-04-26  1:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23  7:15 [PATCH 1/1] driver,usb: Fix a warning in uhci-hcd driver Li, Zhen-Hua
2013-04-23 14:07 ` Greg KH
2013-04-23 15:10   ` Alan Stern
2013-04-25  1:22     ` ZhenHua
2013-04-25 14:54       ` Alan Stern
2013-04-26  1:10         ` ZhenHua [this message]
2013-04-23 23:55   ` ZhenHua
2013-04-24  1:57     ` Greg KH
2013-04-24  2:05       ` ZhenHua
  -- strict thread matches above, loose matches on Subject: below --
2013-04-25  7:11 Li, Zhen-Hua
2013-04-25  7:12 ` ZhenHua
2013-04-25 14:33   ` Alan Stern
2013-04-25 14:56     ` Alan Stern
2013-04-26  7:38 Li, Zhen-Hua
2013-04-26  7:50 ` ZhenHua
2013-04-26  8:10   ` ZhenHua
2013-04-26 16:51   ` Alan Stern
2013-04-27  0:16     ` ZhenHua
2013-04-27 15:14       ` Alan Stern
2013-04-28  1:51         ` ZhenHua
2013-04-28 18:55           ` Alan Stern
2013-05-06  1:43             ` Li, Zhen-Hua (USL-China)

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=5179D41F.7070706@hp.com \
    --to=zhen-hual@hp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tom.vaden@hp.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