linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <hofrat@osadl.org>
To: John Youn <johnyoun@synopsys.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Nicholas Mc Guire <hofrat@osadl.org>
Subject: [PATCH RFC] usb: dwc2: host: use msleep() for long delay
Date: Thu, 12 Jan 2017 16:16:35 +0100	[thread overview]
Message-ID: <1484234195-28589-1-git-send-email-hofrat@osadl.org> (raw)

ulseep_range() uses hrtimers and provides no advantage over msleep()
for larger delays. Fix up the 100ms delays here passing the adjusted "min"
value to msleep(). This helps reduce the load on the hrtimer subsystem.

Link: http://lkml.org/lkml/2017/1/11/377
Fixes: commit 2938fc63e0c2 ("usb: dwc2: Properly account for the force mode delays")
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Problem was found by cocinelle script.

Note that this originally was an msleep(25) then commit 2938fc63e0c2 
("usb: dwc2: Properly account for the force mode delays") changed this 
to usleep_range(100000,110000) with the comment in the function head:
<snip>
 After clearing the bits, wait up to 100 ms to account for any
 potential IDDIG filter delay...
<snip>
but without explaining why the API was switched to usleep_range() here
It does not look like there is any reason for using a high resolution 
timer here - the stated requirement is clearly satisfied by msleep(100)
as well. But it originally was usleep_range(150000, 160000) in
commit 09c96980dc72 ("usb: dwc2: Add functions to set and clear force mode")
so not sure if I am not overlooking some reason for the highrestimer here ?

This needs to be clarified by someone that knows the details and history
of this device/driver.

Patch was compile tested with: x86_64_defconfig + CONFIG_USB_DWC2

Patch is aginast 4.10-rc3 (localversion-next is next-20170112)

 drivers/usb/dwc2/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 11d8ae9..439a21b 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -455,7 +455,7 @@ void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
 	dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
 
 	if (dwc2_iddig_filter_enabled(hsotg))
-		usleep_range(100000, 110000);
+		msleep(100);
 }
 
 /*
-- 
2.1.4

             reply	other threads:[~2017-01-12 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12 15:16 Nicholas Mc Guire [this message]
2017-01-13  0:35 ` [PATCH RFC] usb: dwc2: host: use msleep() for long delay John Youn

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=1484234195-28589-1-git-send-email-hofrat@osadl.org \
    --to=hofrat@osadl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johnyoun@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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).