]> git.baikalelectronics.ru Git - kernel.git/commit
pinctrl: mcp23s08: fix race condition in irq handler
authorRadim Pavlik <radim.pavlik@tbs-biometrics.com>
Tue, 1 Jun 2021 10:48:18 +0000 (10:48 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jul 2021 06:53:09 +0000 (08:53 +0200)
commit55e4a13bc7249cc4c4e6c9fa345e8c5e4c220ac4
tree20a56b7c1a2326c8ab9d995c6ef6d28f602011aa
parent9317bd467017295ff16fd8ae596e6ddab47d796c
pinctrl: mcp23s08: fix race condition in irq handler

[ Upstream commit 897120d41e7afd9da435cb00041a142aeeb53c07 ]

Checking value of MCP_INTF in mcp23s08_irq suggests that the handler may be
called even when there is no interrupt pending.

But the actual interrupt could happened between reading MCP_INTF and MCP_GPIO.
In this situation we got nothing from MCP_INTF, but the event gets acknowledged
on the expander by reading MCP_GPIO. This leads to losing events.

Fix the problem by not reading any register until we see something in MCP_INTF.

The error was reproduced and fix tested on MCP23017.

Signed-off-by: Radim Pavlik <radim.pavlik@tbs-biometrics.com>
Link: https://lore.kernel.org/r/AM7PR06MB6769E1183F68DEBB252F665ABA3E9@AM7PR06MB6769.eurprd06.prod.outlook.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pinctrl/pinctrl-mcp23s08.c