* [PATCH v2 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938
2026-11-17 5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
@ 2026-11-17 5:21 ` Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 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-17 5:21 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
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 1f73f06..813f359 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -48,7 +48,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 v2 2/6] Input: aw86927 - widen the AW86938 boost mode mask
2026-11-17 5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
@ 2026-11-17 5:21 ` Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 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-17 5:21 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
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 813f359..9dda96c 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -45,7 +45,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 v2 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant
2026-11-17 5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 1/6] Input: aw86927 - fix the 7 V boost reference for AW86938 Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 2/6] Input: aw86927 - widen the AW86938 boost mode mask Qianhui Xu
@ 2026-11-17 5:21 ` Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 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-17 5:21 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
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 bd74b81..42b8f5f 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 v2 4/6] Input: aw86927 - add support for Awinic AW86937
2026-11-17 5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
` (2 preceding siblings ...)
2026-11-17 5:21 ` [PATCH v2 3/6] dt-bindings: input: awinic,aw86927: document the AW86937 variant Qianhui Xu
@ 2026-11-17 5:21 ` Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 5/6] Input: aw86927 - handle the AW8693X play and boost register layout Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-17 5:21 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
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 9dda96c..690726a 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -147,6 +147,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
@@ -183,6 +184,7 @@ enum aw86927_work_mode {
enum aw86927_model {
AW86927,
+ AW86937,
AW86938,
};
@@ -589,6 +591,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,
@@ -751,6 +754,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 v2 5/6] Input: aw86927 - handle the AW8693X play and boost register layout
2026-11-17 5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
` (3 preceding siblings ...)
2026-11-17 5:21 ` [PATCH v2 4/6] Input: aw86927 - add support for Awinic AW86937 Qianhui Xu
@ 2026-11-17 5:21 ` Qianhui Xu
2026-11-17 5:21 ` [PATCH v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
5 siblings, 0 replies; 8+ messages in thread
From: Qianhui Xu @ 2026-11-17 5:21 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
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 690726a..aa69994 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -50,6 +50,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
@@ -291,9 +299,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;
@@ -301,7 +314,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;
@@ -313,23 +327,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)
@@ -365,9 +394,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;
@@ -605,9 +638,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 v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown
2026-11-17 5:21 [PATCH v2 0/6] Input: aw86927 - add AW86937 support and fix the AW8693X layout Qianhui Xu
` (4 preceding siblings ...)
2026-11-17 5:21 ` [PATCH v2 5/6] Input: aw86927 - handle the AW8693X play and boost register layout Qianhui Xu
@ 2026-11-17 5:21 ` Qianhui Xu
2026-11-17 5:46 ` sashiko-bot
5 siblings, 1 reply; 8+ messages in thread
From: Qianhui Xu @ 2026-11-17 5:21 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
The chip keeps playing whatever was programmed into it when the system
suspends or reboots, so the actuator can still be buzzing after the screen
is off. Stop playback, drain the work item and park the part in reset on
both paths.
Suspending also has to stop the memless effect timer from queueing new
work, otherwise a queued event re-arms playback after the stop. Use a
suspended flag protected by the input event lock for that, and take the
input mutex around the whole sequence so that open()/close() cannot race
the drain. The magnitude is read once per work run, so a concurrent
event cannot change it between the check and the register write.
Register the reset action with the device as well, so that the part is
also parked in reset on unbind and on a probe failure after the GPIO has
been acquired.
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
drivers/input/misc/aw86927.c | 79 +++++++++++++++++++++++++++++++++---
1 file changed, 73 insertions(+), 6 deletions(-)
diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
index aa69994..793bb88 100644
--- a/drivers/input/misc/aw86927.c
+++ b/drivers/input/misc/aw86927.c
@@ -15,5 +15,6 @@
#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,13 @@ static int aw86927_detect(struct aw86927_data *haptics)
return 0;
}
+static void aw86927_reset(void *data)
+{
+ struct aw86927_data *haptics = data;
+
+ gpiod_set_value_cansleep(haptics->reset_gpio, 1);
+}
+
static int aw86927_probe(struct i2c_client *client)
{
struct aw86927_data *haptics;
@@ -829,6 +845,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 +920,51 @@ 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);
+
+ disable_work_sync(&haptics->play_work);
+ 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 +976,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 v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown
2026-11-17 5:21 ` [PATCH v2 6/6] Input: aw86927 - stop playback over suspend and on shutdown Qianhui Xu
@ 2026-11-17 5:46 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-17 5:46 UTC (permalink / raw)
To: Qianhui Xu, linux-input; +Cc: devicetree, robh, conor+dt, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] Input: aw86927: race in aw86927_close() and unbind queues
play_work after stop
- [Low] Input: aw86927: commit message and comment mismatch on
suspend/shutdown
--
commit 10d522b2154a0fe403051ae8e5379871fd0348a4
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
Input: aw86927 - stop playback over suspend and on shutdown
This commit adds system suspend, resume, and shutdown callbacks to stop
haptic playback and hold the chip in reset, and registers a devm action to
assert the reset GPIO on unbind or probe failure.
> diff --git a/drivers/input/misc/aw86927.c b/drivers/input/misc/aw86927.c
> index 1dbcba7988316..35a342131edff 100644
> --- a/drivers/input/misc/aw86927.c
> +++ b/drivers/input/misc/aw86927.c
[ ... ]
> @@ -444,6 +451,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)
[ ... ]
> @@ -800,6 +809,13 @@ static int aw86927_detect(struct aw86927_data *haptics)
> return 0;
> }
>
> +static void aw86927_reset(void *data)
> +{
> + struct aw86927_data *haptics = data;
> +
> + gpiod_set_value_cansleep(haptics->reset_gpio, 1);
> +}
> +
> static int aw86927_probe(struct i2c_client *client)
> {
> struct aw86927_data *haptics;
> @@ -828,6 +844,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: High]
Can haptics->play_work be scheduled after aw86927_close() and still be
running during driver unbind?
Clearing haptics->level in aw86927_close() while an ff-memless effect timer
is still armed lets ml_effect_timer() pass the READ_ONCE(haptics->level) ==
level check in aw86927_haptics_play() and queue haptics->play_work again.
This happens when an open device with an active effect is inhibited via
input_inhibit_device(), which calls dev->close() without calling
dev->flush() to stop ml->timer, or when input_flush_device() is interrupted
by a signal before input_close_device() runs.
If the driver is then unbound, input_close_device() skips aw86927_close() on
an inhibited device while input_flush_device() queues haptics->play_work to
stop the effect, and unlike aw86927_shutdown(), the devm aw86927_reset()
action does not call disable_work_sync(&haptics->play_work):
CPU0 CPU1 (kworker)
i2c_device_remove()
...
__input_unregister_device()
evdev_cleanup()
input_flush_device()
...
aw86927_haptics_play()
schedule_work(&haptics->play_work)
input_close_device()
/* skipped: dev->inhibited */
devres_release_all()
aw86927_reset()
/* regmap and haptics freed */
aw86927_haptics_play_work()
aw86927_stop(haptics)
regmap_write(haptics->regmap, ...)
<-- use-after-free
[ ... ]
> @@ -899,6 +919,51 @@ 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);
> +
> + disable_work_sync(&haptics->play_work);
> + 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);
[Severity: Low]
This isn't a bug, but the commit message and the comment in
aw86927_haptics_play() do not match what the suspend and shutdown callbacks
do.
The commit message states that both paths stop playback, drain the work item
and park the part in reset, whereas aw86927_suspend() only puts the chip into
standby via aw86927_stop() without asserting reset, and aw86927_shutdown()
asserts reset via aw86927_reset() without calling aw86927_stop(). In
addition, the comment in aw86927_haptics_play() says the chip is powered
down and a queued event would only fail, but during suspend the chip is only
in standby and a queued event would re-arm playback over I2C.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117052112.32527-1-xiaqinghuan@mail.ustc.edu.cn?part=6
^ permalink raw reply [flat|nested] 8+ messages in thread