Skip to content

Commit

Permalink
ARM: shmobile: rcar-gen2: Fix deadlock in regulator quirk
Browse files Browse the repository at this point in the history
Simon Horman reported that Koelsch and Lager hang during boot, and
bisected this to commit 1c3c5ea ("sched/core: Enable
might_sleep() and smp_processor_id() checks early").

The da9063/da9210 regulator quirk for R-Car Gen2 boards uses a bus
notifier, and unregisters the notifier when it is no longer needed.
However, a notifier must not be unregistered from within the call chain.

This bug went unnoticed, as blocking_notifier_chain_unregister() didn't
take the semaphore during early boot.  The aforementioned commit changed
that behavior, leading to a deadlock.

Fix this by removing the call to bus_unregister_notifier(), and keeping
local completion state instead.

Reported-by: Simon Horman <horms+renesas@verge.net.au>
Fixes: 663fbb5 ("ARM: shmobile: R-Car Gen2: Add da9063/da9210 regulator quirk")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
  • Loading branch information
Geert Uytterhoeven authored and Simon Horman committed Jul 29, 2017
1 parent 2ea659a commit fce8dc5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ static int regulator_quirk_notify(struct notifier_block *nb,
{
struct device *dev = data;
struct i2c_client *client;
static bool done;
u32 mon;

if (done)
return 0;

mon = ioread32(irqc + IRQC_MONITOR);
dev_dbg(dev, "%s: %ld, IRQC_MONITOR = 0x%x\n", __func__, action, mon);
if (mon & REGULATOR_IRQ_MASK)
Expand Down Expand Up @@ -99,7 +103,7 @@ static int regulator_quirk_notify(struct notifier_block *nb,
remove:
dev_info(dev, "IRQ2 is not asserted, removing quirk\n");

bus_unregister_notifier(&i2c_bus_type, nb);
done = true;
iounmap(irqc);
return 0;
}
Expand Down

0 comments on commit fce8dc5

Please sign in to comment.