i3c: mipi-i3c-hci: Fix race between bus cleanup and interrupt
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Thu, 21 Sep 2023 05:56:59 +0000 (08:56 +0300)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 25 Sep 2023 21:35:14 +0000 (23:35 +0200)
commit4e40642cdb621c669507d7ef098c93ff98e8747c
tree79dca19ca8c84adf4b12ef78712cd68b89e1f07a
parente141db842766b1d9af32030a842ceb5eaf389bbb
i3c: mipi-i3c-hci: Fix race between bus cleanup and interrupt

If there is a transfer error during i3c_master_bus_init() and code goes
doing the bus cleanup in i3c_hci_bus_cleanup() there is possibility that
i3c_hci_irq_handler() is running in parallel with hci->io->cleanup()
which can be racy.

Prevent this by waiting there is no pending interrupt on other CPU
before doing the IO cleanup.

This was observed with ring headers where first transfer failed and
sometimes transfer error or ring transfer abort interrupt was coming
simultaneously with the bus cleanup path.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20230921055704.1087277-8-jarkko.nikula@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/i3c/master/mipi-i3c-hci/core.c