Received: by 10.213.65.68 with SMTP id h4csp4053246imn; Tue, 10 Apr 2018 08:32:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx49NGYzvoqWhZEfaD979029kvLnLP9krFPPc3PXEEYjxovBcAPPZ1P7EE6CBZLsTZxlrs2f1 X-Received: by 2002:a17:902:464:: with SMTP id 91-v6mr958823ple.126.1523374342578; Tue, 10 Apr 2018 08:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523374342; cv=none; d=google.com; s=arc-20160816; b=EcYlsi5JBFk1MRBVo6/TmtQTPr3ieaffj6cKLDj+qJhd8WeOYy0nVZMCfLvLco88ye 4vxdyCQPgmJjgOJFw2AYRrSrbm6UCdGqbn/L/5fRiyIbnVu3HdPVyTS9wIPqlBrYkPt+ y6Ao8hU9j3nBYlLy+uTDwSaeDtzWOOyhryHeYzhpxx6/9O6JcVEDLmnyDpbYp+GLC+lI 9SaDUmofVFbaN0oyHaNwJGIYC9rbGrO8b8FJjrADMvq/BgMMb79llCmxut/Xec3rl4HZ fq/oGmZi4/FDTbs5r9c0f9VSDjn6ylifGTvM0jCIab/HZXK8jBq78tJvVXWeBISfG4LS wJNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=XzJ7b+hWeuL/378NtbJHsP0muf7nI2XHQJSwvCsx80I=; b=M44+zeHMPtGgwbjcDWI5B43+0REHt/gsK8sRv4psuRGYJ41k3HM7Ouc9HYmpCqjh2K REqrD42m25OZgYrzXiwNUfHBEd5uoKQCr4YB6NYRv5E8dXAK2MrFQruOQb44yTcfh0L1 sm2mluiyYoe1RcVTxpfeyMrIHuXMeHUR2itWcLJdjRPcxDD8Xalu/cmTYOmpEW8VfC7H VH9ILV1/mjXtDgFypEyIKp/lkJ8QXAWKeCjsyoXk4ZwxMaLEpipbyxppHU7WkvLwbXjx OBJadT0LO+o1h8VnFH/yqQFL+84y55Ze/6zrN2J7by5R4TvFE+mff2km0y/lGqH3CZ35 PUVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ugw9YnTj; 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 t2-v6si559799plo.235.2018.04.10.08.31.44; Tue, 10 Apr 2018 08:32:22 -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=ugw9YnTj; 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 S1754402AbeDJPZS (ORCPT + 99 others); Tue, 10 Apr 2018 11:25:18 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:41004 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118AbeDJPZQ (ORCPT ); Tue, 10 Apr 2018 11:25:16 -0400 Received: by mail-qk0-f193.google.com with SMTP id s78so13788670qkl.8; Tue, 10 Apr 2018 08:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XzJ7b+hWeuL/378NtbJHsP0muf7nI2XHQJSwvCsx80I=; b=ugw9YnTjoj37kjwgrANwJFpxLC1eh3sJQy+RhNTcWXnfQqCtmz94f+jjNU+OcdViny +3FVIjZ9bpWzO7a2oBGBrNuAKi8N9qf+1wXP+7IkhTpTOwLZdPBqiJFCWURDyEL7hrRJ HzJVgaoMr0elduvXZ9cRC0mxasO6+zhJ78QelFK75p73+VDpGkWjoSVkeNJwEWZlsqxO IOQIljWQz+M12oZhhs2jxN8rF/IWV2bsmCu4pJ1ZhTXLxTkzLzD9Ew69HlDkKWFjiATz 3ok0iOiJrO7POzFhuOb6dnTpXX9PjOLgOeOfwN1bRZE+rKutmHDVeExqGxa7RAfmTnL/ eFVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=XzJ7b+hWeuL/378NtbJHsP0muf7nI2XHQJSwvCsx80I=; b=R55bYumvy3OdXaHydPPm6v48Ym/7ymNp/da7DiMkpsSmhcYxi2P2lINRmpMC0P1Ewj G9Yv7tj4fVpIwxa0yohYQ2KktSAaSjVxF1RxT3enKic1iL1foplyqgMU7uGiywGw1AI5 NSq+7qqrApqnzXY1nrXPQwaPkCKwpdyCaWPa/yuIk503lz2QMjeSZJj+I6lQeMsJI9rQ 1t/jvCJQEZmJ/yMEzS99fv57az2JiryTcYGfpHr6wKK1yHcNiASh5feS0/igKCRsvC2l llCl9T73/VwOJ4Z+Q0UquFBJCDz+YWADQk5XnnylY84xD1AtxPuUAjcKn6FKTh3123Ty dJzQ== X-Gm-Message-State: ALQs6tAofjrNXDA7JXV0EakTMvUsuGqeDit0ffcOQ1ks3d3xytMr8C+h aZZSXuT/r2q1cTQALbF642sX4s4cM5/Z8ROPlJ4= X-Received: by 10.55.93.71 with SMTP id r68mr1314676qkb.70.1523373916004; Tue, 10 Apr 2018 08:25:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.137.74 with HTTP; Tue, 10 Apr 2018 08:25:15 -0700 (PDT) In-Reply-To: <1523365076-31461-1-git-send-email-baijiaju1990@gmail.com> References: <1523365076-31461-1-git-send-email-baijiaju1990@gmail.com> From: Andy Shevchenko Date: Tue, 10 Apr 2018 18:25:15 +0300 Message-ID: Subject: Re: [PATCH] platform: x86: intel_scu_ipc: Replace mdelay with usleep_range in intel_scu_ipc_i2c_cntrl To: Jia-Ju Bai Cc: Darren Hart , Andy Shevchenko , Platform Driver , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 10, 2018 at 3:57 PM, Jia-Ju Bai wrote: > intel_scu_ipc_i2c_cntrl() calls mutex_lock(), which indicates > this function is not called in atomic context. > > Despite never getting called from atomic context, > intel_scu_ipc_i2c_cntrl() 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. I'm not sure we even need that delay at all. Anyway, pushed to my review and testing queue, thanks! > > Signed-off-by: Jia-Ju Bai > --- > drivers/platform/x86/intel_scu_ipc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c > index 2c85f75..75c8fef 100644 > --- a/drivers/platform/x86/intel_scu_ipc.c > +++ b/drivers/platform/x86/intel_scu_ipc.c > @@ -584,11 +584,11 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data) > if (cmd == IPC_I2C_READ) { > writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR); > /* Write not getting updated without delay */ > - mdelay(1); > + usleep_range(1000, 2000); > *data = readl(scu->i2c_base + I2C_DATA_ADDR); > } else if (cmd == IPC_I2C_WRITE) { > writel(*data, scu->i2c_base + I2C_DATA_ADDR); > - mdelay(1); > + usleep_range(1000, 2000); > writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR); > } else { > dev_err(scu->dev, > -- > 1.9.1 > -- With Best Regards, Andy Shevchenko