Received: by 10.223.176.5 with SMTP id f5csp704312wra; Fri, 9 Feb 2018 05:59:54 -0800 (PST) X-Google-Smtp-Source: AH8x225iP+xvY0kK2TsJjNSvnwOyBb/qFu35sainso1Tt2TSzEEuofYLlqWG2fUxVKauNH+pRBCI X-Received: by 10.98.33.82 with SMTP id h79mr2930218pfh.139.1518184794476; Fri, 09 Feb 2018 05:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518184794; cv=none; d=google.com; s=arc-20160816; b=flwvPa5u+7KVBTohQo2oeUoGj+PeNLgQtr5UdQ/a5Q6Y1nkozerNmx98XK3iSl28MM b1S6PSG40C3sB8AhkIzCZsFRMKJlByAv9rzph90FE6pMStQ3uK6kRhR/CqozinjNpfMx yp2yrEF0XHW4tVp1g4KLveJ+nEo63dM8QTbhaFXBYz/aZVtiSUYHW6Kn51Y65RqEXjCc ACpUMSN1OAkbJSPQhnaT6aanQmEe2m/ZGcc2PR5C2yHiIACusOYgSC/sJFRpQfgk2muS cd9887362t59A9E0XolufkySmoE8QD26nXndzc6UTOTWfPjsMRHDs1RaVuJHy6ludm4z XALQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=yHjv6q/LB0SCExse0vKCNZlmF5eLadKBQ8oomnluWck=; b=f2iX0KdzCc2AjlhUd0hwoK/leC/DZ0aTuCBe30hcGKpBQJ9DzZuALoKulyyNK2xF3W xNtBMKP3A3l6GVaW8RIeFHv0Y7pDKNUUKbImXMsmHe4CimvHjDDEN7cepfOqZjmS9ikl wIpcGVOF1NZrUmBNhG8KSmcCKpyXnu7RKXy8DBnEJw0p5C+2F0urDt63f8BJGtNhpJsI b8uGJKCifD1a6fR+ewFNqteQdp8fTk9IxAhw+KTNtIA9qN24gwKDSINwhTPtoPnbr6m5 zXo+hOuU2+GyWJ5PucotEXVWUZLM/wHehRL8kHYx+117Z3HPSJtb8Pt9pr6y0BNrAxjQ 2PsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N14ahWjS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si477539pgh.536.2018.02.09.05.59.40; Fri, 09 Feb 2018 05:59:54 -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; dkim=pass header.i=@linaro.org header.s=google header.b=N14ahWjS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753571AbeBIN6Y (ORCPT + 99 others); Fri, 9 Feb 2018 08:58:24 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:42156 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753087AbeBIN6W (ORCPT ); Fri, 9 Feb 2018 08:58:22 -0500 Received: by mail-io0-f193.google.com with SMTP id g14so3514311iob.9 for ; Fri, 09 Feb 2018 05:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=yHjv6q/LB0SCExse0vKCNZlmF5eLadKBQ8oomnluWck=; b=N14ahWjSITGOQ43f3FU1X81Cd7k5W+VeG1XnJQ5RT94BLlMxsM2yoUUQNypOXC8QNP 9+w0k2cq6J7wsf2k6oyXXwgVJL3LZfQqUodTtTe91YqwCWsV9m1c9TTqVCziucYt5ogK JWcupeweMeXktjWrTHjmLVtmdvkPi+R3a5Vg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=yHjv6q/LB0SCExse0vKCNZlmF5eLadKBQ8oomnluWck=; b=SUcl6LRhWs3x4Jy+BpfHQzrpeii95kDiSw84Pq0NegV+0FvOyILpmnZhn9tS2fvei3 o3gj7Qo8xydDZ1a/3hfhrL+3Ar0l+a0W9V4HAszouKBGNjO1XTMlAQ2pr/HFMbpDiD6T XF4Wn6DkKMn1u+4Ajh6i8X/oiFeqGyK1tCJI+F+SXxOCu3K2wvTXrEufXxxkkYNZGObV 7Cad+4qS3qxPyBeu/8Rm2FnGGCrOWH/+7Gd4nb2o7GxpO5x5l+Edf3mwzXngOsffimX4 v3QW+pGgKu+U/Yj79AzkW0OZzuCCIq4AfjYzaX2YnZFsd6Cz5K1XCChBuf3DPhdlyFZT cikA== X-Gm-Message-State: APf1xPBHq1BEvsdrawJ4yRplzNz1t6JGxnVdYQ6oGrepqfn0aKQW2fBv Nuu+Oq4NXfulNJJes9o90TjmiJSgbQks3TXgtSyO6g== X-Received: by 10.107.199.67 with SMTP id x64mr3020873iof.169.1518184702027; Fri, 09 Feb 2018 05:58:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.91.65 with HTTP; Fri, 9 Feb 2018 05:58:21 -0800 (PST) In-Reply-To: <1516955899-31810-1-git-send-email-baijiaju1990@gmail.com> References: <1516955899-31810-1-git-send-email-baijiaju1990@gmail.com> From: Ulf Hansson Date: Fri, 9 Feb 2018 14:58:21 +0100 Message-ID: Subject: Re: [PATCH] base: power: domain: Replace mdelay with msleep To: Jia-Ju Bai Cc: "Rafael J. Wysocki" , Kevin Hilman , Len Brown , Pavel Machek , Greg Kroah-Hartman , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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