This is a note to let you know that I've just added the patch titled Input: iqs7222 - protect volatile registers to the 5.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: input-iqs7222-protect-volatile-registers.patch and it can be found in the queue-5.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 1e4189d8af2749e2db406f92bdc4abccbab63138 Mon Sep 17 00:00:00 2001 From: Jeff LaBundy <jeff@xxxxxxxxxxx> Date: Mon, 27 Jun 2022 15:14:23 -0700 Subject: Input: iqs7222 - protect volatile registers From: Jeff LaBundy <jeff@xxxxxxxxxxx> commit 1e4189d8af2749e2db406f92bdc4abccbab63138 upstream. Select variants of silicon silently mirror part of the event mask register to the system setup register (0xD0), and vice versa. For the following sequence: 1. Read registers 0xD0 onward and store their contents. 2. Modify the contents, including event mask fields. 3. Write registers 0xD0 onward with the modified contents. 4. Write register 0xD0 on its own again later, using the contents from step 1 to populate any reserved fields. ...the event mask register (e.g. address 0xDA) has been corrupted by writing register 0xD0 with contents that were made stale after step 3. To solve this problem, read register 0xD0 once more between steps 3 and 4. When register 0xD0 is written during step 4, the portion which is mirrored to the event mask register already matches what was written in step 3. Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C") Signed-off-by: Jeff LaBundy <jeff@xxxxxxxxxxx> Link: https://lore.kernel.org/r/20220626072412.475211-4-jeff@xxxxxxxxxxx Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/input/misc/iqs7222.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c index 57616a7ebeae..c46d3c8f0230 100644 --- a/drivers/input/misc/iqs7222.c +++ b/drivers/input/misc/iqs7222.c @@ -1274,9 +1274,22 @@ static int iqs7222_ati_trigger(struct iqs7222_private *iqs7222) struct i2c_client *client = iqs7222->client; ktime_t ati_timeout; u16 sys_status = 0; - u16 sys_setup = iqs7222->sys_setup[0] & ~IQS7222_SYS_SETUP_ACK_RESET; + u16 sys_setup; int error, i; + /* + * The reserved fields of the system setup register may have changed + * as a result of other registers having been written. As such, read + * the register's latest value to avoid unexpected behavior when the + * register is written in the loop that follows. + */ + error = iqs7222_read_word(iqs7222, IQS7222_SYS_SETUP, &sys_setup); + if (error) + return error; + + sys_setup &= ~IQS7222_SYS_SETUP_INTF_MODE_MASK; + sys_setup &= ~IQS7222_SYS_SETUP_PWR_MODE_MASK; + for (i = 0; i < IQS7222_NUM_RETRIES; i++) { /* * Trigger ATI from streaming and normal-power modes so that @@ -2241,9 +2254,6 @@ static int iqs7222_parse_all(struct iqs7222_private *iqs7222) return error; } - sys_setup[0] &= ~IQS7222_SYS_SETUP_INTF_MODE_MASK; - sys_setup[0] &= ~IQS7222_SYS_SETUP_PWR_MODE_MASK; - sys_setup[0] |= IQS7222_SYS_SETUP_ACK_RESET; return iqs7222_parse_props(iqs7222, NULL, 0, IQS7222_REG_GRP_SYS, -- 2.37.2 Patches currently in stable-queue which might be from jeff@xxxxxxxxxxx are queue-5.19/dt-bindings-input-iqs7222-remove-support-for-rf-filter.patch queue-5.19/input-iqs7222-handle-reset-during-ati.patch queue-5.19/input-iqs7222-fortify-slider-event-reporting.patch queue-5.19/dt-bindings-input-iqs7222-correct-bottom-speed-step-size.patch queue-5.19/input-iqs7222-acknowledge-reset-before-writing-registers.patch queue-5.19/input-iqs7222-remove-support-for-rf-filter.patch queue-5.19/input-iqs7222-correct-slider-event-disable-logic.patch queue-5.19/input-iqs7222-protect-volatile-registers.patch queue-5.19/dt-bindings-input-iqs7222-extend-slider-mapped-gpio-to-iqs7222c.patch