Received: by 10.223.185.116 with SMTP id b49csp2147843wrg; Mon, 12 Feb 2018 05:14:41 -0800 (PST) X-Google-Smtp-Source: AH8x224gW8WcIs4QNGriILH86zcoM6UUfPiVyXbl11DRq1CmATA7QGNRCwLXMGJSqWWrew9bcrog X-Received: by 10.98.24.80 with SMTP id 77mr11623182pfy.145.1518441281333; Mon, 12 Feb 2018 05:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441281; cv=none; d=google.com; s=arc-20160816; b=OfqESgOKcUxf9L83HsEuNXWv9V4WA8bU0oWEb4+UL56vwDMxiBrojotAN+3a/Aie50 RvSA4+31QO6GHoSybDig9kl3KgA/ulIfjBWJ3FUNHLYi3PuowgXhvCXX8ND3PDytOPZm QeTwYsBw+Oeg4EfR4CUL2xjawQFEcPOsY1IG1duc2nipzzGNBCnHh/yzvu4bHdbVxYOh bz0/MwYjR2Gt+DlPYzdXwc+luewPAw2Ou9SEmxls40xUlwU+N5YrAW+p/vOiJRdfdLCt jeI8Mb1i+3EOnWO/SNMeRxkutAo27mURn3pESDTmJRF2lsK55QA7Oq87D7/Fbbpscizt BRdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=90JOzHh9LTnC2Zov/ZadPtGXAS2HAoNaX3wMq3ISpLk=; b=Bfx26eMOiNd6Kcm3rzbkHdpAlcRIbFUsKzrJRNvVVL6aF/DuRL3nY5VfXQn4+hI7pn mzuBG4fo9z7n0CRyZt5yaMjatgjOJkLhHD9MO4Qk/fyreAyHw6t5vlAn5hZT8GLWnzup 66ygvlR+75FlQbvE01BfNr3fAWwBjZ2q2RIAg5zzRPXipqrDbNIqHWnu7UDPky53Am5G QSYM1yHfKood+kUagb2t6VCUDjD+a6gdBaJONzJhWjSWXBtXMeq3gT/bzUe1cZmjVxmX dWYD8ELzx5oRtei+DOfPsLWMbofZo+eWyEsN1BGYhrZBe22y+w83uLsQeBOuY3a2QX5W 2U7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72-v6si4034748ple.299.2018.02.12.05.14.26; Mon, 12 Feb 2018 05:14:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933406AbeBLKi1 (ORCPT + 99 others); Mon, 12 Feb 2018 05:38:27 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:39363 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932629AbeBLKi0 (ORCPT ); Mon, 12 Feb 2018 05:38:26 -0500 Received: from weser.hi.pengutronix.de ([2001:67c:670:100:fa0f:41ff:fe58:4010]) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1elBV5-00084N-Va; Mon, 12 Feb 2018 11:38:19 +0100 Message-ID: <1518431893.2744.1.camel@pengutronix.de> Subject: Re: [PATCH] base: power: domain: Replace mdelay with msleep From: Lucas Stach To: Ulf Hansson , Jia-Ju Bai Cc: "Rafael J. Wysocki" , Kevin Hilman , Len Brown , Pavel Machek , Greg Kroah-Hartman , Linux PM , Linux Kernel Mailing List Date: Mon, 12 Feb 2018 11:38:13 +0100 In-Reply-To: References: <1516955899-31810-1-git-send-email-baijiaju1990@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:fa0f:41ff:fe58:4010 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Lucas > >                 cond_resched(); > >         } > > > > @@ -2231,7 +2231,7 @@ int genpd_dev_pm_attach(struct device *dev) > >                 if (ret != -EAGAIN) > >                         break; > > > > -               mdelay(i); > > +               msleep(i); > > Ditto. > > >                 cond_resched(); > >         } > >         mutex_unlock(&gpd_list_lock); > > -- > > 1.7.9.5 > > > > Kind regards > Uffe