From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ulf Hansson Subject: Re: [PATCH] base: power: domain: Replace mdelay with msleep Date: Mon, 12 Feb 2018 13:40:52 +0100 Message-ID: References: <1516955899-31810-1-git-send-email-baijiaju1990@gmail.com> <1518431893.2744.1.camel@pengutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <1518431893.2744.1.camel@pengutronix.de> Sender: linux-kernel-owner@vger.kernel.org To: Lucas Stach Cc: Jia-Ju Bai , "Rafael J. Wysocki" , Kevin Hilman , Len Brown , Pavel Machek , Greg Kroah-Hartman , Linux PM , Linux Kernel Mailing List List-Id: linux-pm@vger.kernel.org On 12 February 2018 at 11:38, Lucas Stach wrote: > Am Freitag, den 09.02.2018, 14:58 +0100 schrieb Ulf Hansson: >> On 26 January 2018 at 09:38, Jia-Ju Bai >> wrote: >> > After checking all possible call chains to genpd_dev_pm_detach() >> > and >> > genpd_dev_pm_attach() here, >> > my tool finds that these functions are never called in atomic >> > context, >> > namely never in an interrupt handler or holding a spinlock. >> > Thus mdelay can be replaced with msleep to avoid busy wait. >> > >> > This is found by a static analysis tool named DCNS written by >> > myself. >> > >> > Signed-off-by: Jia-Ju Bai >> > --- >> > drivers/base/power/domain.c | 4 ++-- >> > 1 file changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/drivers/base/power/domain.c >> > b/drivers/base/power/domain.c >> > index 0c80bea..f84ac72 100644 >> > --- a/drivers/base/power/domain.c >> > +++ b/drivers/base/power/domain.c >> > @@ -2144,7 +2144,7 @@ static void genpd_dev_pm_detach(struct device >> > *dev, bool power_off) >> > if (ret != -EAGAIN) >> > break; >> > >> > - mdelay(i); >> > + msleep(i); >> >> This looks like a nice improvement, however moving to msleep() makes >> the call to cond_resched() below a bit superfluous. Perhaps remove >> that as well. > > At least for small values of i, msleep also has a high chance to > overshoot the desired sleep by a lot. It would be better to convert > them to usleep_range with an acceptable slack. Ack! [...] Kind regards Uffe