From patchwork Tue Apr 10 01:05:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10332175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2BED6037F for ; Tue, 10 Apr 2018 01:06:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D33A728773 for ; Tue, 10 Apr 2018 01:06:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C823928C80; Tue, 10 Apr 2018 01:06:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79B0C28773 for ; Tue, 10 Apr 2018 01:06:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752200AbeDJBGG (ORCPT ); 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-Google-Smtp-Source: AIpwx49LlgbzrMs3tY9QL9y8YwZMJ8G9b2LWQbLrlv8QF/OftLkyM0ExejhLjTVt1AJbt9nOp3EG2Q== 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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;