Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp317424pxx; Thu, 29 Oct 2020 03:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBof83Nk4tV48MSyQq7IvtUCPuHlEUjBMXL75+uwDK1c69IeDXGkJKrI0uhWp31NUnWpOS X-Received: by 2002:a17:906:f185:: with SMTP id gs5mr3263072ejb.107.1603967357963; Thu, 29 Oct 2020 03:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603967357; cv=none; d=google.com; s=arc-20160816; b=M2m3ygjNkVDbu4MVnz1wpoipFdiYlrSZSAO+lIByYWSz/9AMZI8sC5Pp3d7UixEafZ ko2kRyKVZTN7ALUaAEjkbGtgUs58MBcGuLGETO7+nEZoMG+6hL51PyqaOViOkrZCb/P7 JODsPIowBYYdm7cKtGmFugxaCzYCpfAPMlc/ptOmfS8ff8d+cIw973thT/SJsFALycMc 7ZrIWRpYs9A+e6BMEpzy33Y4ul3UFlLXzRHjpEWuhwzonfjPybCrgeavcfwTHaoqews3 RgUIYraN84tkEcDpr+HSkFgb05u9CX1butAxOf7+iKvZIfg9bhKRZnb9WaME98D6s3Je JDww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lI4GkUdPt6+xJMMHVAdO8QPYkUptmzNDzoT3r6qvrto=; b=0rlWMRxRbsQXf88r7DQhQiKP23npEoqvH0XiDiizcnIGK8uv723e2uHV/ENDGCuIcg hMjw18uL4L0Qs/HMi85CLVuZaF5N2cRjhxiwQ8zPv/AMOsFSR4unNuUJb1H4eex+BJA6 W8cxuhXQWV44+wJ5wxidjYRkS0h8F/c22SkxsYWvehLFLlFQEfQ7XwRaSs8feLGEH3wM kNqrDXyWozixxIJZ4k0N3fihf7biAh109XowxhfMvvs2t9DgNn738MVfLxEiFDr5IHZr XvtnuVBGA75BJ3WfXFDWeSiJSuBRB4Ag3hGnO+dQh8BoDbe6m/3rSI80dZIZgkMTQ1Uh RZqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l2m8wDS8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id e10si1485746ejl.139.2020.10.29.03.28.54; Thu, 29 Oct 2020 03:29:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l2m8wDS8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726547AbgJ2K11 (ORCPT + 99 others); Thu, 29 Oct 2020 06:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbgJ2K1Z (ORCPT ); Thu, 29 Oct 2020 06:27:25 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C589AC0613CF; Thu, 29 Oct 2020 03:27:25 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x23so1085295plr.6; Thu, 29 Oct 2020 03:27:25 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=lI4GkUdPt6+xJMMHVAdO8QPYkUptmzNDzoT3r6qvrto=; b=l2m8wDS8nK7lfpHMZaVHn793wNtqTGp3iQ/MzBg3FTNzGqJPPFnjwMZyxhZCyu9Pde gvAOsO7jSKCOaYWQWnAql2/OZXZ7bKvXS08zdhfn+EgMwQeMDQS6EbwDawhYYSBdFZpV cKHMsaprUTQfdZG7hPtlDLVtRxCoQx6MwH1J/8nPiuhkA42jo0Fj8eg0dJeEc0UW70ZX n2W08r0I5j+Mefd6l34JpPdU6BQid83BNTbrlBIf5ZlFsD16ga+Wc+Xn1drfX3FWiuUu sKVX2r9sUsATnGLMeE/1DrPw5Qnbys/WaIpmVP1OY00hE5kCYV9xpJgQHfYk0HS1Kk/Q 79DA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lI4GkUdPt6+xJMMHVAdO8QPYkUptmzNDzoT3r6qvrto=; b=izT6vZm8EcVJXP/gsKOtsOgXDz9H7A8TbzlyjLJIbSFKAu5Ol6Tx91zKxFHsw4LbSP Abv0SgtorV9mz0MqQI6yhmUuWBDzniW3srtFjN3AaBENkWhs21h9w/IcBcQsi1AbhxPj Z+XEYzZ8+0ZlDCWzjg3fpn7/+SaZ/C1pzNYcamiYJb7dGAn+7964mm2f3qgOVCCLoSgy e3jjqqd+53x9RYYwL2VVmc5Gcu8nDTDMOocG9RyD8F1IxlswQ0CfXSA8iuDGkS0oD6nm WFzBqETRJU+jc0BjAKGgCdh7/TkkqAOoapXKFiJytaA4Ld+IVJpkONdcKXvONQEC7ZSk eDHQ== X-Gm-Message-State: AOAM533E+3gFxj7WVNFWvJsFN8mjXOm8CoBpcIqU04lyt5X2NvVXb2bh j6yGK1o3HRmMzn6G2I94W3K/4sy0OAY= X-Received: by 2002:a17:902:ee09:b029:d5:288d:fce4 with SMTP id z9-20020a170902ee09b02900d5288dfce4mr3327147plb.45.1603967245408; Thu, 29 Oct 2020 03:27:25 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id cv6sm2485768pjb.2.2020.10.29.03.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 03:27:24 -0700 (PDT) From: Chunyan Zhang To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Chunyan Zhang , Chunyan Zhang , Lingling Xu , Jingchao Ye , Xiaoqing Wu Subject: [PATCH v2 3/3] watchdog: sprd: change to use usleep_range() instead of busy loop Date: Thu, 29 Oct 2020 18:27:16 +0800 Message-Id: <20201029102716.4347-1-zhang.lyra@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201029023933.24548-4-zhang.lyra@gmail.com> References: <20201029023933.24548-4-zhang.lyra@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chunyan Zhang After changing to check busy bit for the previous loading operation instead of the current one, for most of cases, the busy bit is not set for the first time of read, so there's no need to check so frequently, so this patch use usleep_range() to replace cpu_relax() to avoid busy loop. Also this patch change the max times to 11 which would be enough, since according to the specification, the busy bit would be set after a new loading operation and last 2 or 3 RTC clock cycles (about 60us~92us). Fixes: 477603467009 ("watchdog: Add Spreadtrum watchdog driver") Original-by: Lingling Xu Signed-off-by: Chunyan Zhang --- drivers/watchdog/sprd_wdt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/sprd_wdt.c b/drivers/watchdog/sprd_wdt.c index b9b1daa9e2a4..4e689b6ff141 100644 --- a/drivers/watchdog/sprd_wdt.c +++ b/drivers/watchdog/sprd_wdt.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -53,7 +54,7 @@ #define SPRD_WDT_CNT_HIGH_SHIFT 16 #define SPRD_WDT_LOW_VALUE_MASK GENMASK(15, 0) -#define SPRD_WDT_LOAD_TIMEOUT 1000 +#define SPRD_WDT_LOAD_TIMEOUT 11 struct sprd_wdt { void __iomem *base; @@ -109,15 +110,17 @@ static int sprd_wdt_load_value(struct sprd_wdt *wdt, u32 timeout, u32 prtmr_step = pretimeout * SPRD_WDT_CNT_STEP; /* - * Waiting the load value operation done, - * it needs two or three RTC clock cycles. + * Checking busy bit to make sure the previous loading operation is + * done. According to the specification, the busy bit would be set + * after a new loading operation and last 2 or 3 RTC clock + * cycles (about 60us~92us). */ do { val = readl_relaxed(wdt->base + SPRD_WDT_INT_RAW); if (!(val & SPRD_WDT_LD_BUSY_BIT)) break; - cpu_relax(); + usleep_range(10, 100); } while (delay_cnt++ < SPRD_WDT_LOAD_TIMEOUT); if (delay_cnt >= SPRD_WDT_LOAD_TIMEOUT) -- 2.20.1