From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225j1+kZxBbeNqIsClYvj+sCkMZC+pvOSC/KYulGw1ZdMSiG85Kw0TeGf2Wxhc95NSyoepMy ARC-Seal: i=1; a=rsa-sha256; t=1516771983; cv=none; d=google.com; s=arc-20160816; b=GH9srSxgWmz6ntnez2Lu8sW0XWH7APsytD+PQwV64S7YwLm/YgWX1RxaiMyNkgqKve Ecu73ABpt10a0HwxtXMIHP0JTczCMd5mh5g9G+jIk74gxWvisNRehlvlTk9mTUtvDj5o BHNMHSSatURZj+Pzd3zbnNmQLQVY6jN/HXA4SL64rbxlz4/CetkeGI5KE0xa6wbES+Vn 0e3akc2jFf6VU9zCZKvJrLLCvUEXcpmY6XsQS7Frl+00QnneYGkNFrvOD7xzW1C0YUZI cEfogo0qQzUwJKLRb6wHS1DZ19ErUIOHyHKKMVfcMoaDaWaH3YaHSET9RtsR0mRdQFEW 7cWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=RaxIE9t6kiUg3Ze0E/X5ai44y442NZaEM0SWxh0sQyE=; b=DsdtJ8d3vqQzAOzcAxC5t9Lo4JzJYq9nawbG5wgoglh//QyU6fZICfip0wKkYUGo8V 1aYxgVgVX8bVi1+7HUZfA11G9sOVu7i2BYJlwzftVOfs9/rYJkU8CLhZYifwe+v4hl/j 2tCosGypt6mQ6yadOr3aMqVLQA4Z58t2cNRpI8ZUlUNwuWQ+DfsOClNonJZCR/I1WaCJ eVPWbTgisx235Dbs+x0Wzxfi0agOsotKoUw1RxJy3oVifFZKlA+t5Cd+19vDTpjvoBE3 Y/g2pR0Su4dtJtyruQYCSZTLv6oehku+THvVHqRGqTTV7/szs/JnAE8fwk3GKDJWxD7u yynA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of foo00@h08.hostsharing.net designates 176.9.242.62 as permitted sender) smtp.mailfrom=foo00@h08.hostsharing.net Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of foo00@h08.hostsharing.net designates 176.9.242.62 as permitted sender) smtp.mailfrom=foo00@h08.hostsharing.net 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) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590439431576706769?= X-GMAIL-MSGID: =?utf-8?q?1590450699430514124?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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 >