Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp325448rdb; Tue, 5 Dec 2023 06:35:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqwcc+7C+28n0LQgGOmuOWEQgLcpUwS4+FP2x1/qUEZRJFWvOaJr4RfcUIQlzg62dnJBN/ X-Received: by 2002:a05:6a20:e599:b0:18f:97c:3863 with SMTP id ng25-20020a056a20e59900b0018f097c3863mr1785753pzb.61.1701786934676; Tue, 05 Dec 2023 06:35:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701786934; cv=none; d=google.com; s=arc-20160816; b=kLR949KqIeb8ymYFHkCS6EL1zXC/EdPGYM8SwniGKF6xUsVDUjWmq8/3uK1msEZgfJ oOGcXG3FMCCH7UMPAwQ4eSFZiFv+2HAiOWd8b2rRyAFrjFpnMNIz0VTVqHtUeqx7f9hI s5sb0L1ol67DlVGwVTCdq5eiMuxF2eyK7wFOSnwFaQM3i1qyGbG4iUCo3+ji2x1Ar2/A GHlRYWWBjFjMNc/7S7ic0T0QF43LJn1jYGAJansEkKe3eKCizOWJ+CR8SXEPskzPDXZJ 8M9O9MhMNqwqd33O96qEKfxZbxKYhIh2iupdkErznTc218r6YvmEqjWqs70J26Hib+Le 3yGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:sender:dkim-signature; bh=bUDszzbQ/6RYO4w6lDEStppG88rzplEEUuYKJ+6NhV0=; fh=5gJIsc+ZJvUHuxV3zWdyam9nYfP3WQMEisJmpjrpGfk=; b=rfMVPR+wpsFGM/0pnOPhHUcZFtI7JUl1/8tksgxCDeIpQlRL7APimQDih1de+d2pHC 4TIKQ6cw0C6FPTFwwU38j/EjDU3GHYw+EoSfUmLHEm9rsRFbgUO2rfSJ+UlwTdsQyMKh Dlvm/JK1GrhDhIuaGkkvXKNYsg4AdVVb7yq8COK+gTvKf3lbLAmlPEqFWENeGNSWOirl notgwcpjRYyf9JUY3pxSQ21XumxzB4KfVWPi/GBEJdmyo7m1sGjrkE5jVtpaPR/xpweg WLt0qm9QUzleggaJHj/11c/4RQnFl+kjGiZ2wZs6YpcLFqA82fQ8JDGr/+xgSPx1Ufr4 AhKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S5jl9xF9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u10-20020a056a00124a00b006ce60375df5si2352996pfi.296.2023.12.05.06.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:35:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S5jl9xF9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9E6058061382; Tue, 5 Dec 2023 06:35:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345945AbjLEOfR (ORCPT + 99 others); Tue, 5 Dec 2023 09:35:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345881AbjLEOfP (ORCPT ); Tue, 5 Dec 2023 09:35:15 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52595120; Tue, 5 Dec 2023 06:35:22 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6cb55001124so5089899b3a.0; Tue, 05 Dec 2023 06:35:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701786922; x=1702391722; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=bUDszzbQ/6RYO4w6lDEStppG88rzplEEUuYKJ+6NhV0=; b=S5jl9xF9ncUHLNCw7389Stai9DjfIYCalItUDrL1r3WYEwGH+lPKt7yGV1ikdbw3Wv JgwEFmlGC0GgY3ngFKV1dMZPjmDKDxeDMVoEbhxE7ljEtlyRlo45jwmGpbRU7gOS7GvO xa/e7gcBLACAr0F6VGXxQbCUGo9t5cxX46UcvK+k6uEvEJ0ajb9H1rOGeOSJjTstUjmP G4hfxFV1ImZGaprM8Zdh6NkU4mBbIVi4BPc3PoH/KB7hyOgSCU+D5H+ImG78AsHnKrAS eNIGvw7zDM2oR0ZRnF3xhHFX5Stp2Cf0zhqUDYyesfjuvBbqZbwL5FGaPDPt4NTGIg2b 6kSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701786922; x=1702391722; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bUDszzbQ/6RYO4w6lDEStppG88rzplEEUuYKJ+6NhV0=; b=waop5bjQgRxJsO80bucAOEGBsVi/DNvXfxMrBZQg0GgNzBhMDZBbIceR5XKx/jifgj o3sE5EHxG85U/Lpgu2FAbFoISKa+/WoFaMXN0XAiWcID3afG205NsI5zpnyHR1KTuTt1 nDfEdulITYFNDAjNldRIqt6tnBLPm9j2rA1EOoUsTHggZnV0pZjkUpWZjs5fv3UpkwMh A+bnNUTlQcKzZzhipNXMjAkAaMBzqSwrqcSsyaTnBYiYG3/KYGF8bDB3croB8csd84rx 5tWjZVFnzogmdricJjGsPBIFBBBbi5UeWkrNllBFLp05AijCz/pK+Z7R36j9VzzLOrBU +alQ== X-Gm-Message-State: AOJu0Ywq5c2EYvHzQqix3KsFtDygyxhZTXdujBwIi+8+RTU51WUXWnKs pYA+8U9d4xkmxU8bX8RX7S8= X-Received: by 2002:a05:6a00:1c9c:b0:6ce:3b75:4998 with SMTP id y28-20020a056a001c9c00b006ce3b754998mr1543867pfw.16.1701786921676; Tue, 05 Dec 2023 06:35:21 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f17-20020a056a001ad100b006cbe1bb5e3asm9462299pfv.138.2023.12.05.06.35.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Dec 2023 06:35:21 -0800 (PST) Sender: Guenter Roeck Message-ID: <34638d1a-55c2-4dfe-ab9b-d8591a32b950@roeck-us.net> Date: Tue, 5 Dec 2023 06:35:19 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] hwmon: Add driver for Gigabyte AORUS Waterforce AIO coolers Content-Language: en-US To: Aleksa Savic Cc: linux-hwmon@vger.kernel.org, Jean Delvare , Jonathan Corbet , "open list:DOCUMENTATION" , open list References: <20231203120651.371429-1-savicaleksa83@gmail.com> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQ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+G6jocnQQX JqvvP09whbqrABEBAAHCwWUEGAECAA8CGwwFAlVcpi8FCRmg08MACgkQyx8mb86fmYHNRQ/+ J0OZsBYP4leJvQF8lx9zif+v4ZY/6C9tTcUv/KNAE5leyrD4IKbnV4PnbrVhjq861it/zRQW cFpWQszZyWRwNPWUUz7ejmm9lAwPbr8xWT4qMSA43VKQ7ZCeTQJ4TC8kjqtcbw41SjkjrcTG wF52zFO4bOWyovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 05 Dec 2023 06:35:31 -0800 (PST) On 12/5/23 06:22, Aleksa Savic wrote: > On 2023-12-03 18:36:35 GMT+01:00, Guenter Roeck wrote: >> On Sun, Dec 03, 2023 at 01:06:48PM +0100, Aleksa Savic wrote: >>> This driver exposes hardware sensors of the Gigabyte AORUS Waterforce >>> all-in-one CPU liquid coolers, which communicate through a proprietary >>> USB HID protocol. Report offsets were initially discovered in [1] and >>> confirmed by me on a Waterforce X240 by observing the sent reports from >>> the official software. >>> >>> Available sensors are pump and fan speed in RPM, as well as coolant >>> temperature. Also available through debugfs is the firmware version. >>> >>> Attaching a fan is optional and allows it to be controlled from the >>> device. If it's not connected, the fan-related sensors will report >>> zeroes. >>> >>> The addressable RGB LEDs and LCD screen are not supported in this >>> driver and should be controlled through userspace tools. >>> >>> [1]: https://github.com/liquidctl/liquidctl/issues/167 >>> >>> Signed-off-by: Aleksa Savic >>> --- ... >>> +static int waterforce_get_status(struct waterforce_data *priv) >>> +{ >>> + int ret = 0; >>> + >>> + if (!mutex_lock_interruptible(&priv->status_report_request_mutex)) { >>> + if (!time_after(jiffies, priv->updated + msecs_to_jiffies(STATUS_VALIDITY))) { >>> + /* Data is up to date */ >>> + goto unlock_and_return; >>> + } >> >> What is the point of this check ? The calling code already checks it. >> Checking it twice, once inside and once outside the lock, seems >> excessive. >> > > If there are multiple readers here, only the first one should request the status, > so when others enter the mutex they can exit early if the data is there. > Please change the code to only check once from within the mutex. Guenter