Skip to content

Commit

Permalink
Fix -EPIPE/-ENODATA errors after writing to sysfs entries in quick su…
Browse files Browse the repository at this point in the history
…ccession (#83)

* Add a 200ms sleep after sending ctrl reports to some devices
* Add D5 Next into the mix & convert to switch case

Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
  • Loading branch information
aleksamagicka authored Jul 18, 2023
1 parent 083a6d9 commit c04f3a5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions aquacomputer_d5next.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <linux/crc16.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/hid.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
Expand Down Expand Up @@ -833,6 +834,31 @@ static int aqc_send_ctrl_data(struct aqc_data *priv)
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 (for example, setting pwmX_enable and pwmX attributes at once).
*
* 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;
}

Expand Down

0 comments on commit c04f3a5

Please sign in to comment.