Message ID | 20230729112732.5516-1-savicaleksa83@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp985190vqg; Sat, 29 Jul 2023 04:55:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6gNZ2HJiQgzWi2hj//kRfO8K/mVBfLMJSEz5ba1bl2EDRGR35Ac9Ra8N7oxRidhELK/z1 X-Received: by 2002:a05:6a00:1797:b0:682:4e4c:48bc with SMTP id s23-20020a056a00179700b006824e4c48bcmr6096256pfg.21.1690631750661; Sat, 29 Jul 2023 04:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690631750; cv=none; d=google.com; s=arc-20160816; b=HSE85ZY+rznCxLY/586HRLYhK7e1UXLvIcZlBTxxXda5Oc7COpPieWw1g3R3nVjBmc CwSSbStXA9J02Z3e51jxR+ZwZDsSojby29UBUVo4nOfy+oeqAB/YoToaL8qAtwG3iSvR 1Hx2gJW6kcIOVJzQ9pm71LpxG8KqSIQihxZcNmhh6mFLIbNFP7vuPOO2ohm202IrWblx Eq2ia1GOI0e0neMmUT+Ejp72+HLroR4YzjzJDWDtBNLUpPNOwJtCFx1nplGK1gwwIaEK KZfpOWkcDnQgPds0O4az4anDBNPV0X6sqmeOQloQz1xUgHMKlXIXMRu3FztveLX/yGB0 GW2g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UsODLhPmgXVzJMgYwd6g25n/YmJLuT+zLYrhO4QA/Dk=; fh=cQJG9ncmUHEi5k8VvGL8cvRcAY6ILGkce8QR4cRkijg=; b=iJsY3t+vctRGLbQBig9fPa0pA6aFxj+pgK6qiIJesZPxXJb07uxJDjKAL/EB9KcEvD r2Wtifg7DPgeSeEYQ15NwJ3e3v2Airx63yKUxT3L/yR36fRAPBjrd7YJZkdf5LIqoZvv 4ZiqY8OHvns7dJGgIPwsmva+22HlsMh7IhwIhx4ZAZcp++8xr2KvgZwEHL/odn3Gr67Z 9lwdB9ZbfObVq2Xm24+V/H/hHNN5KkmUczgapZMR69C2fu9pXCPMGuEux5oNdMpXkDTZ VkCOQqGAdEYsDMbgbjr3PAswjPhQFDWIG2x+Ch+GmQxpysdbiPBLUjJ27qBhM1T96sST HHQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ctVlHDDZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a056a001a4900b006546d0d5832si4675489pfv.183.2023.07.29.04.55.37; Sat, 29 Jul 2023 04:55:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ctVlHDDZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231206AbjG2L3T (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Sat, 29 Jul 2023 07:29:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjG2L3S (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 29 Jul 2023 07:29:18 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2205A180; Sat, 29 Jul 2023 04:29:17 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99bf3f59905so190487666b.3; Sat, 29 Jul 2023 04:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690630155; x=1691234955; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UsODLhPmgXVzJMgYwd6g25n/YmJLuT+zLYrhO4QA/Dk=; b=ctVlHDDZIRb0LmQKF+fmi2vn0h3fiDXr3nVc38arl4b6xcfsKdDaER0AX1kG/kjZ9k /QuGPJgQaLzwI7KrSAZyQ2jQY2zOxSqjKfWn+y1/S6YNsJoMzwyWnxpBAsxjVtLQ9xnf qQuNqY8XldkkIeEnFAeJBmnIlfJV0zyB8TcNkawsTOmdixmgvCbXsOLqB/5KfqNMrFo5 0cajCJ2KYXyZfMLRofImzRtHqtjQQLYY69rUb+k6KAdoWBEOclH0QejZMAPytBTXky3C icIuksx75bThiFLLW6ymc/MsV+IX2NgGaWwkbOZ9FpOGF9KXWmftqn3ZeHIRaURRK5Uj rYGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690630155; x=1691234955; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UsODLhPmgXVzJMgYwd6g25n/YmJLuT+zLYrhO4QA/Dk=; b=L90chpigk5OzYuh91Lm16hsUmaq7hfiF0bEwWDflFxZ5U4ojtPCZ3AgRs5Yveug4kU lPCen23/VeyXnUtaPegwDU8xjb4AKC+TLmlK4+iEW/6RZyO2yiIC1vmdRdheezJznM4m QZR9xX4eZl2MOv52Bh8S7kiOMgdl6KKu3UCtjfycE0KfvmoCtWKpUXar5Ec/hNrOrQAF yj/Lq0EjAhcwVZl/yhpLKhGABqDDK0fKdE6Anj8LzaoCkMXJbudqvb4kGQZEuiH2Z4uZ QzX9069Z3Fq8DKaWLzkSzw6x4bdX4qhKUche+FHUOLjYhZVmE/I32b4wHDVSMKVI83Xc aNSQ== X-Gm-Message-State: ABy/qLauEFzOX3scJz3wblNson6iSaflzhmcN22PtJILwvwXeVMgKsYh e04H7CRnOwOrXar/AEGaLNo3DTrnCsFrjA== X-Received: by 2002:a17:906:cc58:b0:993:f2c2:7512 with SMTP id mm24-20020a170906cc5800b00993f2c27512mr2334003ejb.33.1690630154992; Sat, 29 Jul 2023 04:29:14 -0700 (PDT) Received: from fedora.. (cable-178-148-234-71.dynamic.sbb.rs. [178.148.234.71]) by smtp.gmail.com with ESMTPSA id y26-20020a170906071a00b009737b8d47b6sm3149645ejb.203.2023.07.29.04.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Jul 2023 04:29:14 -0700 (PDT) From: Aleksa Savic <savicaleksa83@gmail.com> To: linux-hwmon@vger.kernel.org Cc: Aleksa Savic <savicaleksa83@gmail.com>, stable@vger.kernel.org, Jack Doan <me@jackdoan.com>, Jean Delvare <jdelvare@suse.com>, Guenter Roeck <linux@roeck-us.net>, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (aquacomputer_d5next) Add selective 200ms delay after sending ctrl report Date: Sat, 29 Jul 2023 13:27:32 +0200 Message-ID: <20230729112732.5516-1-savicaleksa83@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772755878399227706 X-GMAIL-MSGID: 1772755878399227706 |
Series |
hwmon: (aquacomputer_d5next) Add selective 200ms delay after sending ctrl report
|
|
Commit Message
Aleksa Savic
July 29, 2023, 11:27 a.m. UTC
Add a 200ms delay after sending a ctrl report to Quadro,
Octo, D5 Next and Aquaero to give them enough time to
process the request and save the data to memory. Otherwise,
under heavier userspace loads where multiple sysfs entries
are usually set in quick succession, a new ctrl report could
be requested from the device while it's still processing the
previous one and fail with -EPIPE.
Reported by a user on Github [1] and tested by both of us.
[1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/issues/82
Cc: stable@vger.kernel.org
Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
---
drivers/hwmon/aquacomputer_d5next.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
Comments
Hi Aleksa, kernel test robot noticed the following build errors: [auto build test ERROR on groeck-staging/hwmon-next] [also build test ERROR on linus/master v6.5-rc3 next-20230728] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Aleksa-Savic/hwmon-aquacomputer_d5next-Add-selective-200ms-delay-after-sending-ctrl-report/20230729-193038 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20230729112732.5516-1-savicaleksa83%40gmail.com patch subject: [PATCH] hwmon: (aquacomputer_d5next) Add selective 200ms delay after sending ctrl report config: arm-randconfig-r005-20230729 (https://download.01.org/0day-ci/archive/20230729/202307292011.c34ZumSF-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230729/202307292011.c34ZumSF-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307292011.c34ZumSF-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/hwmon/aquacomputer_d5next.c: In function 'aqc_send_ctrl_data': >> drivers/hwmon/aquacomputer_d5next.c:674:17: error: implicit declaration of function 'msleep' [-Werror=implicit-function-declaration] 674 | msleep(200); | ^~~~~~ cc1: some warnings being treated as errors vim +/msleep +674 drivers/hwmon/aquacomputer_d5next.c 627 628 /* Expects the mutex to be locked */ 629 static int aqc_send_ctrl_data(struct aqc_data *priv) 630 { 631 int ret; 632 u16 checksum; 633 634 /* Checksum is not needed for Aquaero */ 635 if (priv->kind != aquaero) { 636 /* Init and xorout value for CRC-16/USB is 0xffff */ 637 checksum = crc16(0xffff, priv->buffer + priv->checksum_start, 638 priv->checksum_length); 639 checksum ^= 0xffff; 640 641 /* Place the new checksum at the end of the report */ 642 put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset); 643 } 644 645 /* Send the patched up report back to the device */ 646 ret = hid_hw_raw_request(priv->hdev, priv->ctrl_report_id, priv->buffer, priv->buffer_size, 647 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 648 if (ret < 0) 649 return ret; 650 651 /* The official software sends this report after every change, so do it here as well */ 652 ret = hid_hw_raw_request(priv->hdev, priv->secondary_ctrl_report_id, 653 priv->secondary_ctrl_report, priv->secondary_ctrl_report_size, 654 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 655 if (ret < 0) 656 return ret; 657 658 /* 659 * Wait 200ms before returning to make sure that the device actually processed both reports 660 * and saved ctrl data to memory. Otherwise, an aqc_get_ctrl_data() call made shortly after 661 * may fail with -EPIPE because the device is still busy and can't provide data. This can 662 * happen when userspace tools, such as fancontrol or liquidctl, write to sysfs entries in 663 * quick succession. 664 * 665 * 200ms was found to be the sweet spot between fixing the issue and not significantly 666 * prolonging the call. Quadro, Octo, D5 Next and Aquaero are currently known to be 667 * affected. 668 */ 669 switch (priv->kind) { 670 case quadro: 671 case octo: 672 case d5next: 673 case aquaero: > 674 msleep(200); 675 break; 676 default: 677 break; 678 } 679 680 return ret; 681 } 682
On 7/29/23 04:27, Aleksa Savic wrote: > Add a 200ms delay after sending a ctrl report to Quadro, > Octo, D5 Next and Aquaero to give them enough time to > process the request and save the data to memory. Otherwise, > under heavier userspace loads where multiple sysfs entries > are usually set in quick succession, a new ctrl report could > be requested from the device while it's still processing the > previous one and fail with -EPIPE. > > Reported by a user on Github [1] and tested by both of us. > > [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/issues/82 > > Cc: stable@vger.kernel.org > Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> > --- > drivers/hwmon/aquacomputer_d5next.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c > index a997dbcb563f..9cb55d51185a 100644 > --- a/drivers/hwmon/aquacomputer_d5next.c > +++ b/drivers/hwmon/aquacomputer_d5next.c > @@ -652,6 +652,31 @@ static int aqc_send_ctrl_data(struct aqc_data *priv) > ret = hid_hw_raw_request(priv->hdev, priv->secondary_ctrl_report_id, > priv->secondary_ctrl_report, priv->secondary_ctrl_report_size, > HID_FEATURE_REPORT, HID_REQ_SET_REPORT); > + if (ret < 0) > + return ret; > + > + /* > + * Wait 200ms before returning to make sure that the device actually processed both reports > + * and saved ctrl data to memory. Otherwise, an aqc_get_ctrl_data() call made shortly after > + * may fail with -EPIPE because the device is still busy and can't provide data. This can > + * happen when userspace tools, such as fancontrol or liquidctl, write to sysfs entries in > + * quick succession. > + * > + * 200ms was found to be the sweet spot between fixing the issue and not significantly > + * prolonging the call. Quadro, Octo, D5 Next and Aquaero are currently known to be > + * affected. > + */ > + switch (priv->kind) { > + case quadro: > + case octo: > + case d5next: > + case aquaero: > + msleep(200); > + break; > + default: > + break; > + } > + > return ret; > } > This would force writes to sleep even if there is no subsequent operation. Please make this conditional by saving the most recent access time and wait on the subsequent operation. I would also suggest to store the wait time in struct aqc_data to avoid the switch statement in the data path. An example for a driver doing something similar is drivers/hwmon/pmbus/zl6100.c. Thanks, Guenter
On 2023-07-29 15:44:32 GMT+02:00, Guenter Roeck wrote: > On 7/29/23 04:27, Aleksa Savic wrote: >> Add a 200ms delay after sending a ctrl report to Quadro, >> Octo, D5 Next and Aquaero to give them enough time to >> process the request and save the data to memory. Otherwise, >> under heavier userspace loads where multiple sysfs entries >> are usually set in quick succession, a new ctrl report could >> be requested from the device while it's still processing the >> previous one and fail with -EPIPE. >> >> Reported by a user on Github [1] and tested by both of us. >> >> [1] https://github.com/aleksamagicka/aquacomputer_d5next-hwmon/issues/82 >> >> Cc: stable@vger.kernel.org >> Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com> >> --- >> drivers/hwmon/aquacomputer_d5next.c | 25 +++++++++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> >> diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c >> index a997dbcb563f..9cb55d51185a 100644 >> --- a/drivers/hwmon/aquacomputer_d5next.c >> +++ b/drivers/hwmon/aquacomputer_d5next.c >> @@ -652,6 +652,31 @@ static int aqc_send_ctrl_data(struct aqc_data *priv) >> ret = hid_hw_raw_request(priv->hdev, priv->secondary_ctrl_report_id, >> priv->secondary_ctrl_report, priv->secondary_ctrl_report_size, >> HID_FEATURE_REPORT, HID_REQ_SET_REPORT); >> + if (ret < 0) >> + return ret; >> + >> + /* >> + * Wait 200ms before returning to make sure that the device actually processed both reports >> + * and saved ctrl data to memory. Otherwise, an aqc_get_ctrl_data() call made shortly after >> + * may fail with -EPIPE because the device is still busy and can't provide data. This can >> + * happen when userspace tools, such as fancontrol or liquidctl, write to sysfs entries in >> + * quick succession. >> + * >> + * 200ms was found to be the sweet spot between fixing the issue and not significantly >> + * prolonging the call. Quadro, Octo, D5 Next and Aquaero are currently known to be >> + * affected. >> + */ >> + switch (priv->kind) { >> + case quadro: >> + case octo: >> + case d5next: >> + case aquaero: >> + msleep(200); >> + break; >> + default: >> + break; >> + } >> + >> return ret; >> } >> > > This would force writes to sleep even if there is no subsequent operation. > Please make this conditional by saving the most recent access time and wait > on the subsequent operation. I would also suggest to store the wait time > in struct aqc_data to avoid the switch statement in the data path. An example > for a driver doing something similar is drivers/hwmon/pmbus/zl6100.c. > > Thanks, > Guenter > Thanks, will take a look at it. Please ignore v2 of this patch in this case. Aleksa
diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index a997dbcb563f..9cb55d51185a 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -652,6 +652,31 @@ static int aqc_send_ctrl_data(struct aqc_data *priv) ret = hid_hw_raw_request(priv->hdev, priv->secondary_ctrl_report_id, priv->secondary_ctrl_report, priv->secondary_ctrl_report_size, HID_FEATURE_REPORT, HID_REQ_SET_REPORT); + if (ret < 0) + return ret; + + /* + * Wait 200ms before returning to make sure that the device actually processed both reports + * and saved ctrl data to memory. Otherwise, an aqc_get_ctrl_data() call made shortly after + * may fail with -EPIPE because the device is still busy and can't provide data. This can + * happen when userspace tools, such as fancontrol or liquidctl, write to sysfs entries in + * quick succession. + * + * 200ms was found to be the sweet spot between fixing the issue and not significantly + * prolonging the call. Quadro, Octo, D5 Next and Aquaero are currently known to be + * affected. + */ + switch (priv->kind) { + case quadro: + case octo: + case d5next: + case aquaero: + msleep(200); + break; + default: + break; + } + return ret; }