Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp649095pxj; Tue, 18 May 2021 11:01:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr9IpJf46wJJassyrx+4T3C1g93uBwAE00L4Ej6XOLTdZ8n3gYJqd42ZPkPyPu0p+9CFzj X-Received: by 2002:a92:cda4:: with SMTP id g4mr3551734ild.47.1621360865872; Tue, 18 May 2021 11:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621360865; cv=none; d=google.com; s=arc-20160816; b=k1sxEfMd7B/SwjDJl2mhAT/ww0QIEAh7Kus9UdqimLDA8Vg6ycDrJl0WjNzYeAMrTX ntiJVn6d2h/3T80s9wCvd5RB9HsMWWY7kCme+QGzcsYX83kG1kKThUvUb+XKHXHh//9i 4uCOGMNXzSrkn09/T0J/JWLxmPAor3WUQOpyiz6pwgKviPzKpTzvOT2RmSWi+xy7d8HP IqAFAa3x9vR2X/Ng6EYeqXuTofwr+wJSmy3G4YR4aEuXCgsdbSarrPkxZnGSks0YDhTx irln5nhUbZ0GewOEPP7fV+ahtPOSHzxWP66ZcuaW6q3KJfxG8r/YskjKa4Gm1aZ3v9Ia 1J3Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bJnt0vhJEXeN1we5GYcUSDzrJRW56C8Nn7gs68x8d5E=; b=nSiEdL+v1xkTEvuy7uz6jGsl8qq8k0tyRDbWCehz0FLJV81H6xLMdVfaL2spBzhE6T Hd2SHk+wph7zejci7yKbR/9Yg7sHmhWXnATsfYC6bKGAJNF6uKkVH1khpEaEYIYbyTWB 7i9sDPYuNPrQvttdS7H0Ae/n3H66HQLcOy1G6SmO8atkpcN3G8z+7UEVcVfqFUkD9N3T Sm7ZkE8lZwTzJHK5aT4uVOdnxp/5mDqxNcplUZouZ5J2d+LXU5D0AiZqJjoVStH5DpsP cc7Gy1JNeOWJtOe0A//wNn6n0RV/TIGLy/v73mzUqWaQY/Ae7Ub21kZAexR8h5CgWADO fgBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Aw1Vs/Hj"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si6591954ios.29.2021.05.18.11.00.53; Tue, 18 May 2021 11:01:05 -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=@linuxfoundation.org header.s=korg header.b="Aw1Vs/Hj"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346965AbhEQQKu (ORCPT + 99 others); Mon, 17 May 2021 12:10:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:36422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244795AbhEQPqe (ORCPT ); Mon, 17 May 2021 11:46:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AD8261D37; Mon, 17 May 2021 14:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262668; bh=ul2gkWt1vw7JHcttjIMb90ekm5j7F/zNNfbIo1yuQDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aw1Vs/HjfL/HjVFzvNOmW6+u+JxsXuxBmoJNtbkGNUfPHhgpXju5VmwNaktWcpvpi /BaXGKiMYbKKFq9WTnPaiJkiDA7K+cly8E7zqXnYqZCSc99ePP8i23I/0cVQv2v1KE yaWYpB3XCuJqI6Gv5Tz+QXUXGXWoVr9HwrSmolms= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eddie James , Guenter Roeck , Sasha Levin Subject: [PATCH 5.10 227/289] hwmon: (occ) Fix poll rate limiting Date: Mon, 17 May 2021 16:02:32 +0200 Message-Id: <20210517140312.809041298@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eddie James [ Upstream commit 5216dff22dc2bbbbe6f00335f9fd2879670e753b ] The poll rate limiter time was initialized at zero. This breaks the comparison in time_after if jiffies is large. Switch to storing the next update time rather than the previous time, and initialize the time when the device is probed. Fixes: c10e753d43eb ("hwmon (occ): Add sensor types and versions") Signed-off-by: Eddie James Link: https://lore.kernel.org/r/20210429151336.18980-1-eajames@linux.ibm.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/occ/common.c | 5 +++-- drivers/hwmon/occ/common.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index a71777990d49..d052502dc2c0 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -209,9 +209,9 @@ int occ_update_response(struct occ *occ) return rc; /* limit the maximum rate of polling the OCC */ - if (time_after(jiffies, occ->last_update + OCC_UPDATE_FREQUENCY)) { + if (time_after(jiffies, occ->next_update)) { rc = occ_poll(occ); - occ->last_update = jiffies; + occ->next_update = jiffies + OCC_UPDATE_FREQUENCY; } else { rc = occ->last_error; } @@ -1089,6 +1089,7 @@ int occ_setup(struct occ *occ, const char *name) return rc; } + occ->next_update = jiffies + OCC_UPDATE_FREQUENCY; occ_parse_poll_response(occ); rc = occ_setup_sensor_attrs(occ); diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index 67e6968b8978..e6df719770e8 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -99,7 +99,7 @@ struct occ { u8 poll_cmd_data; /* to perform OCC poll command */ int (*send_cmd)(struct occ *occ, u8 *cmd); - unsigned long last_update; + unsigned long next_update; struct mutex lock; /* lock OCC access */ struct device *hwmon; -- 2.30.2