* [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout
@ 2026-11-24 1:50 Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel
*** AI-assistance disclosure ***
This cover letter and the six patches below were prepared with the help
of an LLM coding assistant. The author reviewed every line, ran every
gate quoted in this letter himself, and takes full responsibility for
the content.
This series adds support for the Awinic AW86937 LRA haptic IC on top of
the existing AW86927/AW86938 driver, fixes two register definitions that
are wrong on the AW8693x parts, and stops playback over suspend/shutdown.
Patch 1 fixes the 7 V boost reference value that the AW86938 support
introduced (0x11 programs 9 V, not 7 V). Patch 2 widens the AW86938
boost mode mask: the field is two bits wide at 6:5, so the existing
one-bit mask leaves bit 6 untouched when the driver selects bypass.
Patch 3 documents the awinic,aw86937 compatible as another member of the
AW86927 fallback group; detection stays on the chip ID, so no new
of_device_id entry is added. Patch 4 adds the chip ID and init path.
Patch 5 handles the AW8693x register layout differences (auto-boost bit,
two-bit boost mode, VBAT mode and the two-step stop handshake). Patch 6
stops playback, drains the work item and parks the part in reset over
suspend and shutdown, and registers the reset action with the device so
that unbind and probe failure unwind leave the chip asserted.
What changed in v2
==================
Only the two review points from the previous posting (2026-10-27) are
taken; patch 1, 4 and 5 are unchanged, 2, 3 and 6 differ exactly as
follows:
- patch 2 (new in v2): the boost mode mask is now GENMASK(6, 5)
instead of GENMASK(5, 5), so the two-bit boost mode field is
programmed as a whole.
- patch 6: aw86927_reset() is registered with
devm_add_action_or_reset() right after the reset GPIO has been
acquired, so unbind and a probe failure after that point leave the
part asserted.
- patch 3: carries Krzysztof's Acked-by from the previous posting; the
binding change itself is unchanged.
The AW86937 has no hardware in hand: the register data comes from the
vendor driver and the part datasheet, and the commit message does not
claim otherwise.
Qianhui Xu (6):
Input: aw86927 - fix the 7 V boost reference for AW86938
Input: aw86927 - widen the AW86938 boost mode mask
dt-bindings: input: awinic,aw86927: document the AW86937 variant
Input: aw86927 - add support for Awinic AW86937
Input: aw86927 - handle the AW8693X play and boost register layout
Input: aw86927 - stop playback over suspend and on shutdown
.../bindings/input/awinic,aw86927.yaml | 1 +
drivers/input/misc/aw86927.c | 154 +++++++++++++++---
2 files changed, 131 insertions(+), 24 deletions(-)
Changes since v2: only 6/6 changed, to address Sashiko's review of v2 (2026-11-17).
- "race in aw86927_close() and unbind queues play_work after stop" [High]:
the devres action now drains the work item before asserting reset. An
inhibited device skips input_close_device() on unbind and the memless
effect timer can queue the work again, so the worker must not reach the
regmap after the device is gone. aw86927_shutdown() calls the same
helper instead of draining the work itself.
- "commit message and comment mismatch on suspend/shutdown" [Low]: the
message now says that suspend parks the chip in standby without
asserting reset and that shutdown asserts reset without a separate stop,
which is what the code has been doing since v2.
Gate for this version: W=1 compile of drivers/input/misc/aw86927.o on
v7.4-rc3 (aebb727447), 0 warnings / 0 errors; checkpatch --strict 0E/0W/0C
on all six patches.
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
@ 2026-11-24 1:50 ` Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 2/6] Input: aw86927 - widen the AW86938 boost mode mask Qianhui Xu
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel
AW86938_PLAYCFG1_BST_7000MV names 7 V, but the register encodes the boost
voltage as ((mV - 6000) / 2 * 0x8313) >> 22 + 5, so the value used since
AW86938 support was added, 0x11, selects 9 V. Program 0x09 for 7 V, the
value the vendor driver uses for these actuators.
Found while adding the AW86937 variant, which shares the register layout
and the same wrong value.
Fixes: df53055c540f ("Input: aw86927 - add support for Awinic AW86938")
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
drivers/input/misc/aw86927.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 0657c52b4c79..6d09e5e96b2a 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -47,7 +47,7 @@
#define AW86938_PLAYCFG1_BST_MODE_MASK GENMASK(5, 5)
#define AW86938_PLAYCFG1_BST_MODE_BYPASS 0
#define AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK GENMASK(4, 0)
-#define AW86938_PLAYCFG1_BST_7000MV 0x11
+#define AW86938_PLAYCFG1_BST_7000MV 0x09
#define AW86927_PLAYCFG2_REG 0x07
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/6] Input: aw86927 - widen the AW86938 boost mode mask
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
@ 2026-11-24 1:50 ` Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant Qianhui Xu
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel
The boost mode of the AW86938 and AW86937 is a two-bit field at bits 6:5
of PLAYCFG1, but the mask is defined as GENMASK(5, 5). When the driver
selects bypass mode it only clears bit 5 and leaves bit 6 at whatever the
bootloader left in the register, so the part may keep a boost mode that
the driver did not ask for. Widen the mask so that both bits are
programmed.
Fixes: df53055c540f ("Input: aw86927 - add support for Awinic AW86938")
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
drivers/input/misc/aw86927.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 6d09e5e96b2a..b9b7315a5dbe 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -44,7 +44,7 @@
#define AW86927_PLAYCFG1_BST_8500MV 0x50
#define AW86938_PLAYCFG1_REG 0x06
-#define AW86938_PLAYCFG1_BST_MODE_MASK GENMASK(5, 5)
+#define AW86938_PLAYCFG1_BST_MODE_MASK GENMASK(6, 5)
#define AW86938_PLAYCFG1_BST_MODE_BYPASS 0
#define AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK GENMASK(4, 0)
#define AW86938_PLAYCFG1_BST_7000MV 0x09
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 2/6] Input: aw86927 - widen the AW86938 boost mode mask Qianhui Xu
@ 2026-11-24 1:50 ` Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 4/6] Input: aw86927 - add support for Awinic AW86937 Qianhui Xu
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel,
Krzysztof Kozlowski
The AW86937 is a sibling of the AW86938 with the same register layout and
a distinct CHIPID. It is described the same way as the AW86938, with the
AW86927 compatible as fallback; software tells the parts apart by reading
the CHIPID registers.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
Documentation/devicetree/bindings/input/awinic,aw86927.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/input/awinic,aw86927.yaml b/Documentation/devicetree/bindings/input/awinic,aw86927.yaml
index bd74b81488f6..42b8f5f9e8e5 100644
--- a/Documentation/devicetree/bindings/input/awinic,aw86927.yaml
+++ b/Documentation/devicetree/bindings/input/awinic,aw86927.yaml
@@ -15,6 +15,7 @@ properties:
- const: awinic,aw86927
- items:
- enum:
+ - awinic,aw86937
- awinic,aw86938
- const: awinic,aw86927
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/6] Input: aw86927 - add support for Awinic AW86937
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
` (2 preceding siblings ...)
2026-11-24 1:50 ` [PATCH v3 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant Qianhui Xu
@ 2026-11-24 1:50 ` Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 5/6] Input: aw86927 - handle the AW8693X play and boost register layout Qianhui Xu
2026-11-24 1:50 ` [PATCH v3] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel
The AW86937 reports CHIPID 0x9370 and is register compatible with the
AW86938 as far as the boost setup is concerned, so it joins that branch of
the haptic initialisation. Detection stays by CHIPID, so the existing
AW86927 compatible keeps working as fallback.
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
drivers/input/misc/aw86927.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index b9b7315a5dbe..699c92a1ce8c 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -146,6 +146,7 @@
#define AW86927_CHIPIDH_REG 0x57
#define AW86927_CHIPIDL_REG 0x58
#define AW86927_CHIPID 0x9270
+#define AW86937_CHIPID 0x9370
#define AW86938_CHIPID 0x9380
#define AW86927_TMCFG_REG 0x5b
@@ -182,6 +183,7 @@ enum aw86927_work_mode {
enum aw86927_model {
AW86927,
+ AW86937,
AW86938,
};
@@ -588,6 +590,7 @@ static int aw86927_haptic_init(struct aw86927_data *haptics)
if (err)
return err;
break;
+ case AW86937:
case AW86938:
err = regmap_update_bits(haptics->regmap,
AW86938_PLAYCFG1_REG,
@@ -750,6 +753,9 @@ static int aw86927_detect(struct aw86927_data *haptics)
case AW86927_CHIPID:
haptics->model = AW86927;
break;
+ case AW86937_CHIPID:
+ haptics->model = AW86937;
+ break;
case AW86938_CHIPID:
haptics->model = AW86938;
break;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 5/6] Input: aw86927 - handle the AW8693X play and boost register layout
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
` (3 preceding siblings ...)
2026-11-24 1:50 ` [PATCH v3 4/6] Input: aw86927 - add support for Awinic AW86937 Qianhui Xu
@ 2026-11-24 1:50 ` Qianhui Xu
2026-11-24 1:50 ` [PATCH v3] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel
AW86937 and AW86938 keep the same register map as the AW86927 but move
two bits and invert the stop handshake:
- auto boost lives in bit 2 of PLAYCFG3 instead of bit 4, and the boost
mode in PLAYCFG1 is a two-bit field at bit 5 instead of bit 7;
- the VBAT mode bit taps the battery voltage instead of the software
tracked value;
- stopping is a two-step sequence: select PLAY_MODE_STOP in PLAYCFG3 and
then issue GO in PLAYCFG4, as the dedicated STOP bit does not exist
for these parts. A standby timeout after that is a real failure, so
return it instead of forcing the state machine.
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
drivers/input/misc/aw86927.c | 65 +++++++++++++++++++++++++++---------
1 file changed, 49 insertions(+), 16 deletions(-)
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 699c92a1ce8c..1dbcba798831 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -49,6 +49,14 @@
#define AW86938_PLAYCFG1_BST_VOUT_VREFSET_MASK GENMASK(4, 0)
#define AW86938_PLAYCFG1_BST_7000MV 0x09
+/*
+ * The AW8693x parts move auto-boost to bit 2 of PLAYCFG3 and stop playback
+ * by selecting the dedicated stop mode and then issuing a GO, unlike the
+ * AW86927 which has an explicit STOP bit in PLAYCFG4.
+ */
+#define AW8693X_PLAYCFG3_AUTO_BST_MASK BIT(2)
+#define AW8693X_PLAYCFG3_PLAY_MODE_STOP 3
+
#define AW86927_PLAYCFG2_REG 0x07
#define AW86927_PLAYCFG3_REG 0x08
@@ -290,9 +298,14 @@ static int aw86927_play_mode(struct aw86927_data *haptics, u8 play_mode)
err = regmap_update_bits(haptics->regmap,
AW86927_PLAYCFG1_REG,
- AW86927_PLAYCFG1_BST_MODE_MASK,
+ haptics->model == AW86927 ?
+ AW86927_PLAYCFG1_BST_MODE_MASK :
+ AW86938_PLAYCFG1_BST_MODE_MASK,
+ haptics->model == AW86927 ?
FIELD_PREP(AW86927_PLAYCFG1_BST_MODE_MASK,
- AW86927_PLAYCFG1_BST_MODE_BYPASS));
+ AW86927_PLAYCFG1_BST_MODE_BYPASS) :
+ FIELD_PREP(AW86938_PLAYCFG1_BST_MODE_MASK,
+ AW86938_PLAYCFG1_BST_MODE_BYPASS));
if (err)
return err;
@@ -300,7 +313,8 @@ static int aw86927_play_mode(struct aw86927_data *haptics, u8 play_mode)
AW86927_VBATCTRL_REG,
AW86927_VBATCTRL_VBAT_MODE_MASK,
FIELD_PREP(AW86927_VBATCTRL_VBAT_MODE_MASK,
- AW86927_VBATCTRL_VBAT_MODE_SW));
+ haptics->model == AW86927 ?
+ AW86927_VBATCTRL_VBAT_MODE_SW : 1));
if (err)
return err;
@@ -312,23 +326,38 @@ static int aw86927_play_mode(struct aw86927_data *haptics, u8 play_mode)
static int aw86927_stop(struct aw86927_data *haptics)
{
+ bool aw8693x = haptics->model != AW86927;
int err;
- err = regmap_write(haptics->regmap, AW86927_PLAYCFG4_REG, AW86927_PLAYCFG4_STOP);
+ if (aw8693x) {
+ err = regmap_update_bits(haptics->regmap, AW86927_PLAYCFG3_REG,
+ AW86927_PLAYCFG3_PLAY_MODE_MASK,
+ AW8693X_PLAYCFG3_PLAY_MODE_STOP);
+ if (err)
+ return err;
+ }
+
+ err = regmap_write(haptics->regmap, AW86927_PLAYCFG4_REG,
+ aw8693x ? AW86927_PLAYCFG4_GO : AW86927_PLAYCFG4_STOP);
if (err) {
dev_err(haptics->dev, "Failed to stop playback: %d\n", err);
return err;
}
err = aw86927_wait_enter_standby(haptics);
- if (err) {
- dev_err(haptics->dev, "Failed to enter standby, trying to force it\n");
- err = aw86927_play_mode(haptics, AW86927_STANDBY_MODE);
- if (err)
- return err;
- }
+ if (!err)
+ return 0;
- return 0;
+ /*
+ * The AW8693x reliably reaches standby through the stop mode above, so a
+ * timeout there is fatal; the AW86927 sometimes needs the nudge.
+ */
+ if (aw8693x)
+ return err;
+
+ dev_err(haptics->dev, "Failed to enter standby, trying to force it\n");
+
+ return aw86927_play_mode(haptics, AW86927_STANDBY_MODE);
}
static int aw86927_haptics_play(struct input_dev *dev, void *data, struct ff_effect *effect)
@@ -364,9 +393,13 @@ static int aw86927_play_sine(struct aw86927_data *haptics)
return err;
err = regmap_update_bits(haptics->regmap, AW86927_PLAYCFG3_REG,
- AW86927_PLAYCFG3_AUTO_BST_MASK,
+ haptics->model == AW86927 ?
+ AW86927_PLAYCFG3_AUTO_BST_MASK :
+ AW8693X_PLAYCFG3_AUTO_BST_MASK,
+ haptics->model == AW86927 ?
FIELD_PREP(AW86927_PLAYCFG3_AUTO_BST_MASK,
- AW86927_PLAYCFG3_AUTO_BST_ENABLE));
+ AW86927_PLAYCFG3_AUTO_BST_ENABLE) :
+ AW8693X_PLAYCFG3_AUTO_BST_MASK);
if (err)
return err;
@@ -604,9 +637,9 @@ static int aw86927_haptic_init(struct aw86927_data *haptics)
err = regmap_update_bits(haptics->regmap,
AW86927_PLAYCFG3_REG,
- AW86927_PLAYCFG3_AUTO_BST_MASK,
- FIELD_PREP(AW86927_PLAYCFG3_AUTO_BST_MASK,
- AW86927_PLAYCFG3_AUTO_BST_DISABLE));
+ haptics->model == AW86927 ?
+ AW86927_PLAYCFG3_AUTO_BST_MASK :
+ AW8693X_PLAYCFG3_AUTO_BST_MASK, 0);
if (err)
return err;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3] Input: aw86927 - stop playback over suspend and on shutdown
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
` (4 preceding siblings ...)
2026-11-24 1:50 ` [PATCH v3 5/6] Input: aw86927 - handle the AW8693X play and boost register layout Qianhui Xu
@ 2026-11-24 1:50 ` Qianhui Xu
2026-11-24 2:03 ` sashiko-bot
5 siblings, 1 reply; 8+ messages in thread
From: Qianhui Xu @ 2026-11-24 1:50 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh, krzk+dt, conor+dt, devicetree, linux-input, linux-kernel
Playback is not stopped across system sleep or shutdown: an effect
that is
being played when the system suspends keeps the chip driving the
actuator,
and nothing holds the chip in reset on shutdown or unbind.
Park the chip in standby on suspend (resume leaves it in reset, as probe
does), assert reset on shutdown, and drain the work item in a devres
action
so it runs on unbind as well: the memless effect timer can queue the
work
again when input_close_device() is skipped for an inhibited device, and
the
work must not reach the regmap after the device is gone.
Changes since v2:
- [sashiko, 2026-11-17, High] "race in aw86927_close() and unbind
queues
play_work after stop": the devres action now drains the work item
before
asserting reset, so an effect timer that re-queued the work
(inhibited
device, or a flush interrupted by a signal) cannot reach the regmap
after
the device is gone. aw86927_shutdown() calls the same helper.
- [sashiko, same report, Low] "commit message and comment mismatch on
suspend/shutdown": the message now states that suspend parks the
chip in
standby without asserting reset and shutdown asserts reset without a
separate stop, which is what the code does.
---
drivers/input/misc/aw86927.c | 85 +++++++++++++++++++++++++++++++++---
1 file changed, 79 insertions(+), 6 deletions(-)
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index 42ae123808b6..a84cada8f570 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -15,6 +15,7 @@
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/types.h>
@@ -204,6 +205,7 @@ struct aw86927_data {
struct i2c_client *client;
struct regmap *regmap;
struct gpio_desc *reset_gpio;
+ bool suspended;
u16 level;
};
@@ -366,22 +368,26 @@ static int aw86927_haptics_play(struct input_dev *dev, void *data, struct ff_eff
struct aw86927_data *haptics = input_get_drvdata(dev);
int level;
+ /* The chip is powered down; a queued event would only fail. */
+ if (haptics->suspended)
+ return 0;
+
level = effect->u.rumble.strong_magnitude;
if (!level)
level = effect->u.rumble.weak_magnitude;
/* If level does not change, don't restart playback */
- if (haptics->level == level)
+ if (READ_ONCE(haptics->level) == level)
return 0;
- haptics->level = level;
+ WRITE_ONCE(haptics->level, level);
schedule_work(&haptics->play_work);
return 0;
}
-static int aw86927_play_sine(struct aw86927_data *haptics)
+static int aw86927_play_sine(struct aw86927_data *haptics, u16 level)
{
int err;
@@ -426,7 +432,8 @@ static int aw86927_play_sine(struct aw86927_data *haptics)
if (err)
return err;
- err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG, haptics->level * 0x80 / 0xffff);
+ err = regmap_write(haptics->regmap, AW86927_PLAYCFG2_REG,
+ level * 0x80 / 0xffff);
if (err)
return err;
@@ -445,6 +452,7 @@ static void aw86927_close(struct input_dev *input)
int err;
cancel_work_sync(&haptics->play_work);
+ WRITE_ONCE(haptics->level, 0);
err = aw86927_stop(haptics);
if (err)
@@ -456,10 +464,11 @@ static void aw86927_haptics_play_work(struct work_struct *work)
struct aw86927_data *haptics =
container_of(work, struct aw86927_data, play_work);
struct device *dev = &haptics->client->dev;
+ u16 level = READ_ONCE(haptics->level);
int err;
- if (haptics->level)
- err = aw86927_play_sine(haptics);
+ if (level)
+ err = aw86927_play_sine(haptics, level);
else
err = aw86927_stop(haptics);
@@ -801,6 +810,20 @@ static int aw86927_detect(struct aw86927_data *haptics)
return 0;
}
+static void aw86927_reset(void *data)
+{
+ struct aw86927_data *haptics = data;
+
+ /*
+ * Drain the worker before the regmap can go away: this action also runs
+ * from devres on unbind, where input_close_device() may have been skipped
+ * (inhibited device) and the memless effect timer can have queued the
+ * work again.
+ */
+ disable_work_sync(&haptics->play_work);
+ gpiod_set_value_cansleep(haptics->reset_gpio, 1);
+}
+
static int aw86927_probe(struct i2c_client *client)
{
struct aw86927_data *haptics;
@@ -829,6 +852,10 @@ static int aw86927_probe(struct i2c_client *client)
return dev_err_probe(haptics->dev, PTR_ERR(haptics->reset_gpio),
"Failed to get reset gpio\n");
+ err = devm_add_action_or_reset(haptics->dev, aw86927_reset, haptics);
+ if (err)
+ return err;
+
/* Hardware reset */
aw86927_hw_reset(haptics);
@@ -900,6 +927,50 @@ static int aw86927_probe(struct i2c_client *client)
return 0;
}
+static void aw86927_shutdown(struct i2c_client *client)
+{
+ struct aw86927_data *haptics = i2c_get_clientdata(client);
+
+ aw86927_reset(haptics);
+}
+
+static int aw86927_suspend(struct device *dev)
+{
+ struct aw86927_data *haptics = dev_get_drvdata(dev);
+ int err;
+
+ guard(mutex)(&haptics->input_dev->mutex);
+
+ /* Block events from the memless effect timer before draining the work. */
+ scoped_guard(spinlock_irq, &haptics->input_dev->event_lock)
+ haptics->suspended = true;
+
+ cancel_work_sync(&haptics->play_work);
+ err = aw86927_stop(haptics);
+
+ scoped_guard(spinlock_irq, &haptics->input_dev->event_lock) {
+ if (err)
+ haptics->suspended = false;
+ else
+ WRITE_ONCE(haptics->level, 0);
+ }
+
+ return err;
+}
+
+static int aw86927_resume(struct device *dev)
+{
+ struct aw86927_data *haptics = dev_get_drvdata(dev);
+
+ guard(mutex)(&haptics->input_dev->mutex);
+ guard(spinlock_irq)(&haptics->input_dev->event_lock);
+ haptics->suspended = false;
+
+ return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(aw86927_pm_ops, aw86927_suspend, aw86927_resume);
+
static const struct of_device_id aw86927_of_id[] = {
{ .compatible = "awinic,aw86927" },
{ /* sentinel */ }
@@ -911,8 +982,10 @@ static struct i2c_driver aw86927_driver = {
.driver = {
.name = "aw86927-haptics",
.of_match_table = aw86927_of_id,
+ .pm = pm_sleep_ptr(&aw86927_pm_ops),
},
.probe = aw86927_probe,
+ .shutdown = aw86927_shutdown,
};
module_i2c_driver(aw86927_driver);
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3] Input: aw86927 - stop playback over suspend and on shutdown
2026-11-24 1:50 ` [PATCH v3] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
@ 2026-11-24 2:03 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-24 2:03 UTC (permalink / raw)
To: Qianhui Xu; +Cc: devicetree, linux-input, robh, conor+dt, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] Input: aw86927: missing Signed-off-by trailer in commit message
- [Medium] Input: aw86927: uninitialized work_struct in aw86927_reset()
on probe error
- [Medium] Input: aw86927: race in aw86927_close() allows timer to
restart playback
- [Low] Input: aw86927: inaccurate chip state claims in commit message
and comment
--
commit a797a001f2024a181e85b8bd947512d590b74fb5
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
> Input: aw86927 - stop playback over suspend and on shutdown
>
> Playback is not stopped across system sleep or shutdown: an effect
> that is
> being played when the system suspends keeps the chip driving the
> actuator,
> and nothing holds the chip in reset on shutdown or unbind.
>
> Park the chip in standby on suspend (resume leaves it in reset, as probe
> does), assert reset on shutdown, and drain the work item in a devres
> action
> so it runs on unbind as well: the memless effect timer can queue the
> work
> again when input_close_device() is skipped for an inhibited device, and
> the
> work must not reach the regmap after the device is gone.
> Changes since v2:
> - [sashiko, 2026-11-17, High] "race in aw86927_close() and unbind
> queues
> play_work after stop": the devres action now drains the work item
> before
> asserting reset, so an effect timer that re-queued the work
> (inhibited
> device, or a flush interrupted by a signal) cannot reach the regmap
> after
> the device is gone. aw86927_shutdown() calls the same helper.
> - [sashiko, same report, Low] "commit message and comment mismatch on
> suspend/shutdown": the message now states that suspend parks the
> chip in
> standby without asserting reset and shutdown asserts reset without a
> separate stop, which is what the code does.
[Severity: High]
The commit message is missing a Signed-off-by: trailer.
> diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
> index e1b811e183ea2..a94eb27a82b1b 100644
> --- a/drivers/input/misc/aw86927.c
> +++ b/drivers/input/misc/aw86927.c
[ ... ]
> @@ -335,22 +337,26 @@ static int aw86927_haptics_play(struct input_dev *dev, void *data, struct ff_eff
> struct aw86927_data *haptics = input_get_drvdata(dev);
> int level;
>
> + /* The chip is powered down; a queued event would only fail. */
> + if (haptics->suspended)
> + return 0;
[Severity: Low]
This isn't a bug, but is this comment accurate? aw86927_suspend() only
parks the chip in standby mode via aw86927_stop() rather than powering it
down, so events are ignored here to avoid restarting playback while
suspended.
Similarly, the commit message says "resume leaves it in reset, as probe
does", whereas both aw86927_probe() and aw86927_resume() leave the chip out
of reset in standby mode with SRAM initialized. The "Changes since v2:"
notes should also go below the "---" separator rather than in the permanent
changelog.
[ ... ]
> @@ -410,6 +417,7 @@ static void aw86927_close(struct input_dev *input)
> int err;
>
> cancel_work_sync(&haptics->play_work);
> + WRITE_ONCE(haptics->level, 0);
>
> err = aw86927_stop(haptics);
> if (err)
[Severity: Medium]
Can clearing haptics->level in aw86927_close() without blocking
aw86927_haptics_play() cause ml_effect_timer() to restart playback while or
after the device is closed?
When the input device is inhibited via input_inhibit_device(), or when
input_flush_device() is skipped for a revoked client or interrupted by a
signal in evdev_release(), active memless effects are not flushed before
dev->close() runs:
CPU0 CPU1 (<softirq>)
aw86927_close()
cancel_work_sync(&haptics->play_work)
WRITE_ONCE(haptics->level, 0)
ml_effect_timer()
aw86927_haptics_play()
/* haptics->level (0) != level */
WRITE_ONCE(haptics->level, level)
schedule_work(&haptics->play_work)
aw86927_stop(haptics)
aw86927_haptics_play_work()
aw86927_play_sine() <-- restarts
Because haptics->level is reset to 0, even a constant-magnitude effect that
previously matched haptics->level sees a level change on the next timer tick
and schedules play_work, leaving the actuator running while the device is
closed or inhibited.
[ ... ]
> @@ -762,6 +771,20 @@ static int aw86927_detect(struct aw86927_data *haptics)
> return 0;
> }
>
> +static void aw86927_reset(void *data)
> +{
> + struct aw86927_data *haptics = data;
> +
> + /*
> + * Drain the worker before the regmap can go away: this action also runs
> + * from devres on unbind, where input_close_device() may have been skipped
> + * (inhibited device) and the memless effect timer can have queued the
> + * work again.
> + */
> + disable_work_sync(&haptics->play_work);
> + gpiod_set_value_cansleep(haptics->reset_gpio, 1);
> +}
> +
> static int aw86927_probe(struct i2c_client *client)
> {
> struct aw86927_data *haptics;
> @@ -790,6 +813,10 @@ static int aw86927_probe(struct i2c_client *client)
> return dev_err_probe(haptics->dev, PTR_ERR(haptics->reset_gpio),
> "Failed to get reset gpio\n");
>
> + err = devm_add_action_or_reset(haptics->dev, aw86927_reset, haptics);
> + if (err)
> + return err;
[Severity: Medium]
Does aw86927_reset() call disable_work_sync(&haptics->play_work) before
haptics->play_work is initialized if probe fails early?
aw86927_probe() does not call INIT_WORK(&haptics->play_work, ...) until
after the software reset, aw86927_detect(), interrupt register setup, and
devm_request_threaded_irq(). If any of those steps fails, devres runs
aw86927_reset() with play_work.func still NULL, triggering
WARN_ON(!work->func) in __flush_work(). Initializing haptics->play_work
before devm_add_action_or_reset() avoids this regression.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124015028.1427420-7-xiaqinghuan@mail.ustc.edu.cn?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-24 2:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 1:50 [PATCH v3 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 2/6] Input: aw86927 - widen the AW86938 boost mode mask Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 4/6] Input: aw86927 - add support for Awinic AW86937 Qianhui Xu
2026-11-24 1:50 ` [PATCH v3 5/6] Input: aw86927 - handle the AW8693X play and boost register layout Qianhui Xu
2026-11-24 1:50 ` [PATCH v3] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
2026-11-24 2:03 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox