Received: by 10.213.65.68 with SMTP id h4csp3280916imn; Mon, 9 Apr 2018 18:09:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/OOgGawulEKvimO96NwYmJ/lfBFJ61kA/YD6zOpfwDyvQkVkEFo7a10qU+bZxdMftSea2j X-Received: by 2002:a17:902:714e:: with SMTP id u14-v6mr11128458plm.356.1523322594473; Mon, 09 Apr 2018 18:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523322594; cv=none; d=google.com; s=arc-20160816; b=AgBXS2nJLQIeOesHn+dmn/2ZGOxJgsj4OVZNgqI0wU4hAE/SlOOD9RUdTI73yQuMsh C4ppDxM3F0xt3fKiT5QDukl9W6NTuRRc+FI6l96GGUeerlEYutcI9XV7u5F56vpQeFCa hoKUJkjbgBeOqGT1x1eHNbiaJZGOme62yA9N/950jbnWUuDWlPUnAz+jMsI9kMPjTcpK cuNj8SQdAzKZ2JGKfinixmrMo7mzX5O1YP5oO1bZ8PkEUAnFlBJBtZ3ICdMefcCyLGNA Ti6VaPfUESvmo+iO4gzvVUc5zzL08mtOinuJKJBWbqBuiAHrhoUGI2fk7+8yZ0mx9PZV 6JQg== 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=14ioMAQnexDXxzK9cVUeOiAWan+95dUgrj9xoVWjElU=; b=SwGazIKdibBXsbeCPtu5YIjGbmLxapq26nQQDY2ZqYCYpU1m66RW57HlEfaiBWkoOE W1CVj5IGCK6fET/qrYu1/Fg/TYY7Gn5u49wX6V4NxN/2170xe1EEqrqN4Tbiajoy91r0 XmXRLzwUCCOHnU/xVbBlG/U0KJxtBi7RafejwsBjChGhNJ1ceEGuyEhcSPGl8bcGoUvP ZC1ODwzfMYhYe73rFWjyGtdz7vstB5c9qjr9cogBsORsSlIL6gxFgYkttskO8xckZ6ht Mhasp8zwgaAVgs01v+obQ6s/hg6gg4/XNXb47A+O4KQ5LQFVWeefPzv75fu1kK4klD8a LyUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o8U/eb7+; 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=QUARANTINE 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 h6-v6si1479162pln.61.2018.04.09.18.09.17; Mon, 09 Apr 2018 18:09:54 -0700 (PDT) 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=o8U/eb7+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752232AbeDJBGG (ORCPT + 99 others); Mon, 9 Apr 2018 21:06:06 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35441 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751667AbeDJBGF (ORCPT ); Mon, 9 Apr 2018 21:06:05 -0400 Received: by mail-pl0-f67.google.com with SMTP id 61-v6so6288028plb.2; Mon, 09 Apr 2018 18:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=14ioMAQnexDXxzK9cVUeOiAWan+95dUgrj9xoVWjElU=; b=o8U/eb7+bwYS+q/hGrPCgPbT+RxZSZlsMQszf0+e13QOz4I3ZcKmoy0aPE2v/u0vdl wywVq3W9Y3ww6fefEearSFQ3BmCjZ11at+l/cMHw1G/HmWrT7LGEGVoP4pKfbwYFrPNe MlaHBKXkigkrjmbveF7R73io7ltkoXZXApq/TXCBFgzDgmp9RowaupHy13j9M2myq28d B8QCQHEfAcUJe1F/feqhCDpsRsMHLgQJQuBDLzMDTwdABI7NvXjk+Gihfnuh1PVbb2Vy 01jgGqlSbQLZyoQZgEKBSeCNNE7jxPD75piWOh1ITO0T03Piez9DCrwCmLDrIi95pcBT tuQQ== 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=14ioMAQnexDXxzK9cVUeOiAWan+95dUgrj9xoVWjElU=; b=k4rQqrZf7t36TQnKSmtNWIJcAUBlaCLXiaKVxvVudAltLOTvPEWMocnlXzqnoRzn76 wnjp9LRSan0VDAOSVLqSd8hf+yEqgpmtwtpxJvt2w4cn9OB6MKp8zXTnblkp+VRgjA50 gBQB7m8PFjFNwZhV3bVZiDIxR7RgzvSpreq+ySHs1K0Py4BQIcIJqmFrst0fV7Ukfmzx 5GvDjh/6xUPmG71ZOJ0m9VySgX7IFPi0wVHj0TdyKw+GzOnPx4F1ZCKSFqd7Zx3v6TpL gAWA05BcPxlKslQBWqiAGAOVbfgj8xb0yxJU8SCPBdCE9t6F2cpXUfAuBJ8y64BjWSzF VScw== X-Gm-Message-State: AElRT7GtCommGTzos7VHqFlEa1aX1ReRVMGgPi1ViRrAYYZwOOf+NCZ3 EJv+VkG5eth/dKDzrbor0+k= X-Received: by 2002:a17:902:60cf:: with SMTP id k15-v6mr40748966pln.44.1523322364643; Mon, 09 Apr 2018 18:06:04 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:39e9:70fb:21a6:f4d2]) by smtp.gmail.com with ESMTPSA id h6sm2088273pgn.65.2018.04.09.18.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Apr 2018 18:06:04 -0700 (PDT) From: Jia-Ju Bai To: adaplas@gmail.com, b.zolnierkie@samsung.com Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] video: fbdev: savage: Replace mdelay with usleep_range in savage_init_hw Date: Tue, 10 Apr 2018 09:05:59 +0800 Message-Id: <1523322359-27598-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org savage_init_hw() is never called in atomic context. The call chains ending up at savage_init_hw() are: [1] savage_init_hw() <- savagefb_probe() [2] savage_init_hw() <- savagefb_resume() savagefb_probe() is only set as ".probe" in struct pci_driver. savagefb_resume) is only set as ".resume" in struct pci_driver. These functions are not called in atomic context. Despite never getting called from atomic context, savage_init_hw() calls mdelay() to busily wait. This is not necessary and can be replaced with usleep_range to avoid busy waiting. This is found by a static analysis tool named DCNS written by myself. And I also manually check it. Signed-off-by: Jia-Ju Bai --- drivers/video/fbdev/savage/savagefb_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index c204683..c09d742 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -1892,11 +1892,11 @@ static int savage_init_hw(struct savagefb_par *par) vga_out8(0x3d4, 0x66, par); cr66 = vga_in8(0x3d5, par); vga_out8(0x3d5, cr66 | 0x02, par); - mdelay(10); + usleep_range(10000, 11000); vga_out8(0x3d4, 0x66, par); vga_out8(0x3d5, cr66 & ~0x02, par); /* clear reset flag */ - mdelay(10); + usleep_range(10000, 11000); /* @@ -1906,11 +1906,11 @@ static int savage_init_hw(struct savagefb_par *par) vga_out8(0x3d4, 0x3f, par); cr3f = vga_in8(0x3d5, par); vga_out8(0x3d5, cr3f | 0x08, par); - mdelay(10); + usleep_range(10000, 11000); vga_out8(0x3d4, 0x3f, par); vga_out8(0x3d5, cr3f & ~0x08, par); /* clear reset flags */ - mdelay(10); + usleep_range(10000, 11000); /* Savage ramdac speeds */ par->numClocks = 4; -- 1.9.1