Re: [PATCH 1/2] Input: synaptics-rmi4 - clear irqs before set irqs

From: Aaron Ma
Date: Sat Mar 09 2019 - 03:37:49 EST


Hi,

On 3/9/19 7:13 AM, Christopher Heiny wrote:
> I'm not sure this is a safe action, due to a race condition with the
> actual IRQ handler (rmi_process_interrupt_requests from rmi_driver.c).
> Remember that reading the IRQ status register clears all the IRQ bits.
> So you're faced with this possible scenario:
> - ATTN asserted, indicating new data in IRQ status register
> - rmi_driver_set_irq_bits called
> - rmi_driver_set_irq_bits reads IRQ status, clearing bits
> - rmi_process_interrupt_requests called
> - rmi_process_interrupt_request reads IRQ status, sees no
> bits set, nested IRQs are not handled
> This could lead to loss of data or inconsistent system state
> information. For example, a button up or down event may be lost, with
> consequent weird behavior by the user interface.

rmi_driver_set_irq_bits is only called to config and enable specific
functions of RMI.
Reading IRQ status before set irqs is supposed to clear spam data/irq
status.
spam data make probe/detect touchpad/trackpoint fail.

rmi_smb_resume -> rmi_driver_reset_handler -> fn-config ->
clear_irq_bits -> set_irq_bits -> enable_irq -> irq_handler ->
rmi_process_interrupt_requests

set_irq_bits will not be in interrupt context, it enables IRQ bits of RMI.

Regards,
Aaron