Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit c465a56e authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Anirudh Ghayal
Browse files

power: smb135x-charger: ensure that no I2C calls after pm suspend



Trying to read from the I2C bus before the dev_pm_ops resume function is
complete can cause errors on the I2C bus because the pm options are not
complete. However, in the current implementation, the SMB135X driver can
receive a stat interrupt after the I2C suspend function is called and
cause I2C controller errors when reading from the bus in a bad state.

Ensure that there is no outstanding waiting stat irq handler by adding a
irq_waiting flag and setting it in the stat irq handler before going to
sleep when waiting for the completion. If this flag is set, then in the
suspend_noirq function cancel the suspend to handle the stat interrupt.
The kernel threads that the irq is using are of a higher priority than
the user threads that suspend is initiated from, and are guaranteed to
terminate or sleep before suspend_noirq is called by the kernel.

The mutex takes care of the race between the irq and the suspend handler.
There is a possibility that the i2c bus might get suspended while executing
the STAT IRQ handler causing the subsequent i2c calls to fail. To avoid
this serialize the suspend and irq handler.

This guarantees that:
	1. No stat irq handlers can be suspended in a incomplete state
	   so that USB detection fails.
	2. No I2C communication will be called after the SMB and I2C
	   driver's suspend pm operation.

Change-Id: I86280c42d437c975a0536dbe51e405f0420e09db
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 4028e2c9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment