From patchwork Thu Nov 2 11:31:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Porte X-Patchwork-Id: 10038557 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 A6FBC603B5 for ; Thu, 2 Nov 2017 11:33:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98A8A28EDB for ; Thu, 2 Nov 2017 11:33:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BDA228EE0; Thu, 2 Nov 2017 11:33: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 DEE4728EDB for ; Thu, 2 Nov 2017 11:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750934AbdKBLdR (ORCPT ); Thu, 2 Nov 2017 07:33:17 -0400 Received: from mail-ve1eur01on0105.outbound.protection.outlook.com ([104.47.1.105]:3776 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750722AbdKBLdQ (ORCPT ); Thu, 2 Nov 2017 07:33:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+6L8M1rlYvUtm4L0J7NVZSuFUbePsSN7tsgJBC73qhs=; b=iS7ruev1YoDjWyCwFfA06ucPhCXYbfHnX5thRXZVfL4nyxQeTPYGU9AIZQwQjeMEZrAi1yry+D49X7ABlF+78If5lmXp9Gq8m2SpfkAH2rfQtJkAeeT5ZfEyJ7Tb0sW9077CMSm0D92k5fGe4FysW3cjWTzMXAvCIQvH96wubW8= Received: from HE1PR0701CA0046.eurprd07.prod.outlook.com (2603:10a6:3:9e::14) by AM4PR07MB1218.eurprd07.prod.outlook.com (2a01:111:e400:59ea::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.4; Thu, 2 Nov 2017 11:33:13 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by HE1PR0701CA0046.outlook.office365.com (2603:10a6:3:9e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.197.4 via Frontend Transport; Thu, 2 Nov 2017 11:33:12 +0000 Authentication-Results: spf=pass (sender IP is 131.228.2.241) smtp.mailfrom=nokia.com; nokia.com; dkim=none (message not signed) header.d=none; nokia.com; dmarc=pass action=none header.from=nokia.com; Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.241 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.241; helo=mailrelay.int.nokia.com; Received: from mailrelay.int.nokia.com (131.228.2.241) by VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.178.5 via Frontend Transport; Thu, 2 Nov 2017 11:33:12 +0000 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id vA2BWJQs008562 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 2 Nov 2017 13:32:19 +0200 Received: from localhost.localdomain ([172.27.221.159]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id vA2BWJPp008558; Thu, 2 Nov 2017 13:32:19 +0200 X-HPESVCS-Source-Ip: 172.27.221.159 From: Romain Porte To: CC: , , Romain Porte Subject: [PATCH] pmbus: added possibility to change timeout for device update Date: Thu, 2 Nov 2017 12:31:16 +0100 Message-ID: <20171102113116.14791-1-romain.porte@nokia.com> X-Mailer: git-send-email 2.11.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.241; IPV:CAL; SCL:-1; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(346002)(376002)(2980300002)(438002)(189002)(199003)(6916009)(6666003)(5660300001)(478600001)(77096006)(106002)(4326008)(68736007)(36756003)(22756006)(48376002)(50226002)(26826003)(107886003)(50466002)(1076002)(2906002)(49486002)(8936002)(5003940100001)(81166006)(81156014)(8676002)(50986999)(356003)(305945005)(106466001)(2351001)(33646002)(53936002)(189998001)(15650500001)(86362001)(575784001)(97736004)(316002)(54906003)(47776003)(16586007); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR07MB1218; H:mailrelay.int.nokia.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; VE1EUR03FT008; 1:eBqOy7k1O0pr3mKnrqCrxXjpRpew9PrFkiokAR8jzySrYdqoEAVwTTr2SNZPA0/rpAbS1kvWR//s3yH9yO4egup+tuPedHAe6CGi46duV6pz5IJqM8JX8S6upr6Zvwg+ MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4d775e7-74bf-42f9-7658-08d521e58054 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(4534020)(4602075)(4627115)(201703031133081)(201702281549075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IvPxKwTYtH7XEU=; 20:/MvGA9qV0gdc8aH/4t67+ErFSRzRXjwiGf5L0vrTCdEEZFoYA92VK8CIADlhBn/t0+NMMJLgEhvO37aVv8qID7ijzrWKcnMHpW7EaJfiqqdJ0t8yvjXqMvSa4+ap7r4a5xwUvCiJ5s3iPjjpabcGsel5Pz6snEgpqhIRoWiCtaWfQgiPmP9PZX9ScW39n+pVTr/dQi/zYljMrGhBc5eJiTvJsEoTgMjaHyzxpWtdaIJMJ5nR0aYFKk55KCaGizKDPnU5L5vt8Iwk+SEuhDPGY1c6foFoj82/d2m1euzthP6uPOZLws/TMfCZNfXyWTDXvrMV1rxkouk9XT8feRYKc0DU5u5fR29GdpViNcOguv7iD+PoRSdaXVw8fVLRnDjCrvyZHE8ga2k3Xgu/RS8LrAIN5JMaxXbj+n8JlOrP87oAAys1o//uLJG+8LpTvKmOqAYkNZJgiXje5lmh/Dw+ZHyr+oa7AVzvof3i9w/8emT4W1FnEW+5ulAHT96eiC0FjMArisyurYVN8uI1Hy8nPV5gzpq9lIKOdgaS1G64R/HXkVfnlXO1Ox6l57SIEzIMEzbD484bRoA7hOn9NqXnOfOl6B6aY0wC4FGMKIFmBU0= X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(3231020)(10201501046)(93006095)(93004095)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR07MB1218; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR07MB1218; X-Microsoft-Exchange-Diagnostics: 1; AM4PR07MB1218; 4:4d8tdBOG5xbrs2thqKFUzT2Ecoir0y/0+/W2xMm+IZPscTRMUc8FL9q1/yqv/liwuTIGkBnH1khPCcBSkB12kd72OtpSIwtrzTS5+4/2sprwNzuNQJb3+DVbKUgIGKvBGXbkzkKgpLulw02DzYXmkCIG3QkA0ZWpWATo9rloH6DW2vwcnDPrxApbSOx2dtCz4vXYdpw5PPdZy0XW/R2TZPB8CQf1yaQf7MdGfR2CJCHcIOfhFM21qrvVy3mDT5sZ9LCw6nOmCUIrGnm8BYQvz+sDvWgjG4HM7+9dPHh39JYYLdfOXp8GqIY6svr2z2mV X-Forefront-PRVS: 047999FF16 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR07MB1218; 23:hJZm1DkKBzOEsIYVRFL2bnLwQ374rTSmpDed5n6Ky?= =?us-ascii?Q?8b3/+1BPopBsOh1JOVgl0x+agb2Iq/abKvpXpAZfEb/qmJRDsrzpcSjZurbk?= =?us-ascii?Q?+A/23QAx4AF/jXMFMpdu1hIP85fG6KV846qU0I0sIGk5VtkPTRul7Dfmdee0?= =?us-ascii?Q?+HFqgVYQTEVDrG8rrPLcVhEkVkJ+oZCux1kQId6Slx5SFgAoZF909QopgikZ?= =?us-ascii?Q?PE+ZO764nfr6fYVNqtiZnlfF/6EFYqf6K/DtyGvW8GiF2GGAoKjzNT6htLQX?= =?us-ascii?Q?oLgYREhV936/GxQBnhR79z43gDGGp8Xugl0PTK4f+zzAhASH8qppPwW+FuY9?= =?us-ascii?Q?G8pbJo5nNv0oElY1Vi9vX5o4mI6W16D5LHiZqNPcMNW/BCxzDLTBNETNWHY8?= =?us-ascii?Q?P0HL8n4AiwiX7JQF+MqbzHFjoEr4AzkY2Hlu3Bk5L6DIZvLem9py0tr/EVkk?= =?us-ascii?Q?vh0eu2y4SI7rGZ4N4ZI0wPDgDhFpZ5OjYOOvdhka8YkzNsTCWfNs23z/l98s?= =?us-ascii?Q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X06+YfPkWJrL4Z3bS+lNlvfayurYVaE+kDivbm9/RTNcC32QCbE98A6SMROzA83k//4Q2M007qfWYNHR692zo=; 5:KkTh0aGDkQkgLr2CLUCBBz8c74+r0bowTmMpyRtBaGbOsy85B3nm9wPrVoXzXCGXseKhTWLjHmmqL9CZiIZyAzQXwYch3CcKXMuc9MdIaGNYgsld7nq8/X6BNIez21aaQaJuyBxIaLP9PVStMgjeyIQUBEzMom/Btg0TUg878kg=; 24:LgXSl7awM32APagbV52jDQn5p+z1sRw5b5/7IQecOoaAxyJB2RDXd26+BvnwS6QevjDGxiS1HjNwpoIPkVARJu+EDCHfavbOMRz9PFKdoQE=; 7:hz/86eLxrL7AEU5/cfooVNLNZKEuFtizoYu5sXEOeqEP0j4iWVEYz5sQUI3xVmHYuQq0Q8URHRk9/VcIxZJ1thEnKX2qoWKcdHWuOxleJuegxlJuV+xPzMlcifZSeYjw4Sc7NrLTPbQYpyNCdvnfDpl1WAEfSYOE7yh3UbLa0CX27ZLh4X2jw5jphlfof1BMDjdKrLMJuZ+eB+rcFxTs7OPCJT1Ipyy1l2ohVu7r8xwhJIU68Ir6xRVe0f1GYtI1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2017 11:33:12.4695 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d775e7-74bf-42f9-7658-08d521e58054 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.241]; Helo=[mailrelay.int.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR07MB1218 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP By default the time before really updating a device is hardcoded to one second in the pmbus_core.c file (HZ). This patch proposes a new configuration entry that allows to tune the timeout value before updating a device. It defaults to one second in order to stay compatible with the previous behavior, but can now be changed if needed. Performing faster than one second sensor reads in userspace is what motivates this patch. Reviewed-by: Alexander Sverdlin --- drivers/hwmon/pmbus/Kconfig | 15 +++++++++++++++ drivers/hwmon/pmbus/pmbus_core.c | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 40019325b517..5d865e3d0cb1 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -14,6 +14,21 @@ menuconfig PMBUS if PMBUS +config PMBUS_DEV_CACHE_MS + int "PMBus device read cache in milliseconds" + default 1000 + help + This options allows you to control how much time should a device + be stored in cache before being updated. If you attempt to read + a sensor value from the device before this cache time is elapsed, + then you will get a cached value and the driver will not update + the device values. + + This option is using jiffies under the hood and thus is not very + precise. Setting this option to more than zero will perform a delay + of at least one jiffie. Setting this option to zero will lead to + no delay, thus forcing to perform an update on every read. + config SENSORS_PMBUS tristate "Generic PMBus devices" default y diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 302f0aef59de..2df0bc5a46f1 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -414,9 +414,12 @@ static struct pmbus_data *pmbus_update_device(struct device *dev) struct pmbus_data *data = i2c_get_clientdata(client); const struct pmbus_driver_info *info = data->info; struct pmbus_sensor *sensor; + unsigned long timeout; mutex_lock(&data->update_lock); - if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { + timeout = data->last_updated + + (HZ * CONFIG_PMBUS_DEV_CACHE_MS + 999) / 1000; + if (time_after(jiffies, timeout) || !data->valid) { int i, j; for (i = 0; i < info->pages; i++) {