Received: by 10.223.176.46 with SMTP id f43csp1944464wra; Thu, 25 Jan 2018 02:30:07 -0800 (PST) X-Google-Smtp-Source: AH8x225HSRcoPF3l0YFBRdvb+mvCAdzur56NJqDXA46gt3rPlBQKN2dVyXMhUSz1kietki5mGJcJ X-Received: by 10.98.207.6 with SMTP id b6mr15957629pfg.187.1516876207586; Thu, 25 Jan 2018 02:30:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516876207; cv=none; d=google.com; s=arc-20160816; b=VWo60K/ORJBA0eBCrbus2DUWz/Va7ykbe5Rz/mbc7iXEbnGAaSU1+zPU9JPnoz1DLS WT7TXI+xEwnfRwnxN4a9+DUdZCSMhuAyDYnLEZ7Y6r7GKtLkF3Qug7pvOF7QWMSm+Gy7 oFWWbMtfFr1jrNdwSXCGOsAw3XjMtGzYubvHJHXltIknxKX64vqz28pdvC/lxUbc+Dq3 +Lf2/xVdUyUgoHHGNTvzqJNEAtE7/RFE6OFvKiNp7/UsZM/wHdqI44o6MzxMpTxaxOTN VDOPivwqB638mDcSnwBM4wHbXFZuES1sIu61ITl7TMk6tCqCWIM3YWhrZbcF6wLH+IA8 0cgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=H8Y3VLbtfFj/uYogwv6scd0P2C39S45lr5gfvFvyffc=; b=Hpn23rkCmSvc0mwTw+0L+4ghfqeGzJ7XXyEvweDreNbhAucgyID/vVTvEgGCbSiSLe ZGCjWCZ38Vm2XSuoqMvba1XvQzLaBxjNDm5fGE1zVaPVgT0B4/jsljME0Hq9asUaHrGw 0NA4sKdGv1lvRZmIAui7avgX6hGNf0l2vbALvSip57jlrzRqk1ig5alEpn3dWNc/n7jy 2QvVW+APEPqJO5QqjDK4s4sTj7YOFy2ggKQH6S9UEezbKZd91gj8DiB5Qjf5vRQ2hs1I GdwvOx1/aIMbS7oAoS8xDjeG5r006N+y1xX+hFYln/tRywVJDBle/22uhkMLnxyWgnZ8 G/LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EZbjUPs8; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12si1400728pgq.425.2018.01.25.02.29.53; Thu, 25 Jan 2018 02:30:07 -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=@gmail.com header.s=20161025 header.b=EZbjUPs8; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751353AbeAYK2d (ORCPT + 99 others); Thu, 25 Jan 2018 05:28:33 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:38673 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbeAYK23 (ORCPT ); Thu, 25 Jan 2018 05:28:29 -0500 Received: by mail-it0-f65.google.com with SMTP id w14so8782253itc.3; Thu, 25 Jan 2018 02:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=H8Y3VLbtfFj/uYogwv6scd0P2C39S45lr5gfvFvyffc=; b=EZbjUPs8s0wLfE2Imm9kWQaoujA/842HGNcqoJW2iawk7/TEul/MY/PddA9X8NsSkO agb4avCkGsCynNn65/PbnK56mTu5QwHpy14VILWmL0tx6q/BWCdPabch4+3UllA+zu9k E1+38+dhrKGqcKN07WPGAgxnPVKPGt7MUhAB6cx3zFNlgPEMCQLfOHejM/wB6qFl1kHB IsZbzVSY2QCQf16oMY8889BkzgoQzbaPa1vd+6vJm9BWdV7yOCxRpBz2/THN5QEcaUzB dh8hFEkJW8Yf1fyy1GqF2ctM1m+QkKTMe3oaMFb/HLm8abHan9YaS/G7xRJ1eymHIDvj zkTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=H8Y3VLbtfFj/uYogwv6scd0P2C39S45lr5gfvFvyffc=; b=q60z53zZy0BM4sz+4UIywfqKLLtWkO9+Q0aSA2jbT7hfvwtGE4isWdDgLh3JoSCYlp Gk1eubPs6k/kc1MbwEJ+ukLs6297UqhqiYCshNFP2rfpzljDvM8XfPfnIyn6+4iDL0rR mHv0bkKjfW7jD8aN/6jST1RsuNQ5IsO5QyLCED/7GC9qXi/pfE01KGTopJEYnoUGNH0/ Rks6DuYqQJR/zs2S/KS+DFjd6jVDHFufZwoKdRF+bbF9Fms/oMIO3Holigf85vc6AD58 8eaqnCbdahbOKYSaBSC9Qth3+enJcfuKKICdJa2weD2NOfhZT7vP1KEHz08uP+ND/6t7 LAnA== X-Gm-Message-State: AKwxytdl+WK0wKvt8T7xDE5vnakm37gMl/ORjfR7War871yEMlCSguyp qROBomZ1x5woU2kFhh1smTc= X-Received: by 10.36.55.200 with SMTP id r191mr12832520itr.44.1516876109166; Thu, 25 Jan 2018 02:28:29 -0800 (PST) Received: from bai-oslab.tsinghua.edu.cn ([2402:f000:1:4413:9980:256a:8e6d:5903]) by smtp.gmail.com with ESMTPSA id m71sm1650602iom.70.2018.01.25.02.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 02:28:28 -0800 (PST) From: Jia-Ju Bai To: b.zolnierkie@samsung.com, tj@kernel.org Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] ata: pata_it821x: Replace mdelay with usleep_range in it821x_firmware_command Date: Thu, 25 Jan 2018 18:32:59 +0800 Message-Id: <1516876379-12834-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After checking all possible call chains to it821x_firmware_command here, my tool finds that it821x_firmware_command is never called in atomic context, namely never in an interrupt handler or holding a spinlock. And it821x_firmware_command calls kmalloc(GFP_KERNEL), so it proves again that it821x_firmware_command can call functions which can sleep. Thus mdelay can be replaced with usleep_range to avoid busy wait. This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai --- drivers/ata/pata_it821x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index 7a21edf..8468b30 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c @@ -683,7 +683,7 @@ static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len) ioread16_rep(ap->ioaddr.data_addr, buf, len/2); return (u8 *)buf; } - mdelay(1); + usleep_range(500, 1000); } kfree(buf); printk(KERN_ERR "it821x_firmware_command: timeout\n"); -- 1.7.9.5