Received: by 10.223.176.46 with SMTP id f43csp314042wra; Tue, 23 Jan 2018 21:42:37 -0800 (PST) X-Google-Smtp-Source: AH8x225c7tj75Bz6fuznowY2eAT/vVj4yd6k+Uq11aIIU66s1YKYnjCjTvj0NyyIdqMYoGHyoy1y X-Received: by 10.99.37.129 with SMTP id l123mr5428540pgl.30.1516772557722; Tue, 23 Jan 2018 21:42:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516772557; cv=none; d=google.com; s=arc-20160816; b=Oou5rPDyCO1fXknvyHyVn/Hnbv3HNNkKGUMFAprt97bNkIA0lEHT8asmpX2HVZ5KPY lUT4cJVwmBDyGPMssj0YYrcFJACeliLShv1qguN6XTCIZwp+7bLvy3FObxIZ6aB33abj pt2lo0+SpahFSy9eqPqNNl8DGJJoZhN/ifavysPCMQmQxLpvTCzeJvWj1t7hveyvV3iy XNLT58MDs1oivtPNUcXeihDV5VPHP9/1rI52N9qxMyZUb+zBYOa3bjgdjnd7w83vyWow 0U8DamyXMOonoJRhKB/5vyumpMsvk9rEf+AbPkjFtW5DVgBe+6+g94gRpei1NWMZCf0O N1HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=RaxIE9t6kiUg3Ze0E/X5ai44y442NZaEM0SWxh0sQyE=; b=Aqwqbj1ndMWzknc9cEGzVR4aDJ7Y0oRj0BdBeFqdxAWak+R9AyV/C9sfUtEJqkdCDG P11w/TYcRWChDofaBL/Gfrb06K0mv8dVYyOocQpW+kPDAHAhhm4PpD9bL2+3M29/Ho53 J2hIY3HbifQmcZJJq0QDHPkXV4GdE/1K4QG1JoILo4SaSTvolkb190swQJJSTmwBf9mz qwDBVsOljOgBfATMEQR/0VzIAkR/bCw+oU3e6U0TEVRRRZHUZmhjevSPghRCbpcSpLdo WJIv8Zx7AN/CVMtIr0xoq4TCGDVODusewWeWPWb0LV9gYOjYhmyV/AGZb8UgmMk1vD+M lMjA== 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 q9-v6si579562plk.730.2018.01.23.21.42.24; Tue, 23 Jan 2018 21:42:37 -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 S1752386AbeAXFlx (ORCPT + 99 others); Wed, 24 Jan 2018 00:41:53 -0500 Received: from bmailout3.hostsharing.net ([176.9.242.62]:51953 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751462AbeAXFlw (ORCPT ); Wed, 24 Jan 2018 00:41:52 -0500 X-Greylist: delayed 528 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Jan 2018 00:41:51 EST Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id ED0A2100B07BD; Wed, 24 Jan 2018 06:33:06 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 863BB4993; Wed, 24 Jan 2018 06:33:01 +0100 (CET) Date: Wed, 24 Jan 2018 06:33:01 +0100 From: Lukas Wunner To: Jia-Ju Bai Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, paulo.r.zanoni@intel.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel: x86: early-quirks: Replace mdelay with usleep_range in apple_airport_reset Message-ID: <20180124053301.GA30540@wunner.de> References: <1516761502-18360-1-git-send-email-baijiaju1990@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516761502-18360-1-git-send-email-baijiaju1990@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 24, 2018 at 10:38:22AM +0800, Jia-Ju Bai wrote: > The function apple_airport_reset is not called in atomic context. > Thus mdelay can be replaced with usleep_range, to avoid busy wait. > > This is reported by a static analysis tool named DCNS written by myself. No, usleep_range() is built on hrtimers and at this point in the boot sequence we haven't called hrtimers_init() yet. Look at init/main.c:start_kernel() and note that setup_arch() (which calls early_quirks()) is called way before hrtimers_init(). Please amend your static checker to consider every call to mdelay() that occurs before hrtimers_init() a false positive, or manually verify each patch for this constraint before submission. I'll test your patch later today on my MacBook Pro but I suspect it'll cause a boot crash or hang. In any case the choice of mdelay() here was deliberate. Thanks, Lukas > > Signed-off-by: Jia-Ju Bai > --- > arch/x86/kernel/early-quirks.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c > index 1e82f78..559e81a 100644 > --- a/arch/x86/kernel/early-quirks.c > +++ b/arch/x86/kernel/early-quirks.c > @@ -604,7 +604,7 @@ static void __init apple_airport_reset(int bus, int slot, int func) > if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) { > pmcsr &= ~PCI_PM_CTRL_STATE_MASK; > write_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL, pmcsr); > - mdelay(10); > + usleep_range(10000, 11000); > > pmcsr = read_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL); > if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) { > -- > 1.7.9.5 >