This is a note to let you know that I've just added the patch titled Input: iqs7222 - acknowledge reset before writing 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-acknowledge-reset-before-writing-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 2e70ef525b7309287b2d4dd24e7c9c038a006328 Mon Sep 17 00:00:00 2001 From: Jeff LaBundy <jeff@xxxxxxxxxxx> Date: Mon, 27 Jun 2022 15:14:42 -0700 Subject: Input: iqs7222 - acknowledge reset before writing registers From: Jeff LaBundy <jeff@xxxxxxxxxxx> commit 2e70ef525b7309287b2d4dd24e7c9c038a006328 upstream. If the device suffers a spurious reset while reacting to a previous spurious reset, the second reset interrupt is preempted because the ACK_RESET bit is written last. To solve this problem, write the ACK_RESET bit prior to writing any other registers. This ensures that any registers written before the second spurious reset will be rewritten. Last but not least, the order in which the ACK_RESET bit is written relative to the second filter beta register is important for select variants of silicon. Enforce the correct order so as to not clobber the system status register. 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-5-jeff@xxxxxxxxxxx Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/input/misc/iqs7222.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c index c46d3c8f0230..aa46f2cd4d34 100644 --- a/drivers/input/misc/iqs7222.c +++ b/drivers/input/misc/iqs7222.c @@ -94,11 +94,11 @@ enum iqs7222_reg_key_id { enum iqs7222_reg_grp_id { IQS7222_REG_GRP_STAT, + IQS7222_REG_GRP_FILT, IQS7222_REG_GRP_CYCLE, IQS7222_REG_GRP_GLBL, IQS7222_REG_GRP_BTN, IQS7222_REG_GRP_CHAN, - IQS7222_REG_GRP_FILT, IQS7222_REG_GRP_SLDR, IQS7222_REG_GRP_GPIO, IQS7222_REG_GRP_SYS, @@ -1348,6 +1348,34 @@ static int iqs7222_dev_init(struct iqs7222_private *iqs7222, int dir) int comms_offset = dev_desc->comms_offset; int error, i, j, k; + /* + * Acknowledge reset before writing any registers in case the device + * suffers a spurious reset during initialization. Because this step + * may change the reserved fields of the second filter beta register, + * its cache must be updated. + * + * Writing the second filter beta register, in turn, may clobber the + * system status register. As such, the filter beta register pair is + * written first to protect against this hazard. + */ + if (dir == WRITE) { + u16 reg = dev_desc->reg_grps[IQS7222_REG_GRP_FILT].base + 1; + u16 filt_setup; + + error = iqs7222_write_word(iqs7222, IQS7222_SYS_SETUP, + iqs7222->sys_setup[0] | + IQS7222_SYS_SETUP_ACK_RESET); + if (error) + return error; + + error = iqs7222_read_word(iqs7222, reg, &filt_setup); + if (error) + return error; + + iqs7222->filt_setup[1] &= GENMASK(7, 0); + iqs7222->filt_setup[1] |= (filt_setup & ~GENMASK(7, 0)); + } + /* * Take advantage of the stop-bit disable function, if available, to * save the trouble of having to reopen a communication window after @@ -2254,8 +2282,6 @@ static int iqs7222_parse_all(struct iqs7222_private *iqs7222) return error; } - sys_setup[0] |= IQS7222_SYS_SETUP_ACK_RESET; - return iqs7222_parse_props(iqs7222, NULL, 0, IQS7222_REG_GRP_SYS, IQS7222_REG_KEY_NONE); } -- 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