Re: [PATCH] regulator: mt6363: Serialize BUCK_TOP key access
From: Mark Brown
Date: Tue Nov 10 2026 - 13:27:56 EST
> The bits that select the FAST mode of the bucks only accept writes
> while the BUCK_TOP key is unlocked. mt6363_regulator_set_mode() unlocks
> the key, updates the bit and locks the key again, but the regulator
> core only locks the buck being changed. When two bucks change mode at
> the same time, one of them can lock the key between the unlock and
> the mode write of the other. The PMIC then ignores that write, and
> regulator_set_mode() returns 0 while the buck stays in its previous
> mode. mt6363_va15_set_voltage_sel() unlocks and locks the same key,
> so it can also lock it during a buck mode change.
>
> Hold a mutex from each unlock of the key to its relock, in the FAST bit
> writes and in the VA15 voltage setter.
> @@ -508,6 +519,8 @@ static int mt6363_va15_set_voltage_sel(struct regulator_dev *rdev, unsigned int
> struct regmap *regmap = rdev->regmap;
> int ret;
>
> + guard(mutex)(&mt6363_buck_top_lock);
This function uses goto for error handling, as documented in cleanup.h
you shouldn't mix the two styles since it tends to break often in ways
that the compiler notices and errors on.
--
Mark Brown <broonie@xxxxxxxxxx>