On 4/1/20 10:16 AM, Ulf Hansson wrote: > On Tue, 31 Mar 2020 at 23:01, Marek Vasut <marex@xxxxxxx> wrote: >> >> On 3/31/20 8:53 PM, Ulf Hansson wrote: >>> On Tue, 31 Mar 2020 at 17:53, Marek Vasut <marex@xxxxxxx> wrote: >>>> >>>> Call the post voltage switch handler only if the voltage switch actually >>>> happened. It is well possible that the regulator is already set correctly >>>> and no voltage switch happened, so there is no need to take any further >>>> action. >>>> >>>> This fixes a real issue on STM32MP1 where, if the eMMC is supplied with >>>> VccQ=1.8 V, the post voltage switch code will spin indefinitelly waiting >>>> for the voltage switch to complete, even though no voltage switch really >>>> happened. >>> >>> Whether this is a common problem or not, I think in a first step we >>> should manage this in the common mmc_regulator_set_vqmmc(). >> >> I can pass in a variable which would be set if a voltage switch actually >> happened in mmc_regulator_set_vqmmc() OR I can return a code > 0 from >> there. Which one do you prefer? > > Return a code > 0. > >> >> Then I guess we can add something like >> >> if (regulator_get_voltage(...vqmmc) is already in voltage range) >> return 1; >> >> ... >> >> and the MMCI driver would do something like >> >> if (mmc_regulator_set_vqmmc(...) > 0) >> host->ops->post_sig_volt_switch(...); >> >> That looks OK I guess ? >> >>> Then on top of that, convert mmci into using the mmc_regulator_set_vqmmc() API. >>> >>> Can please try this approach instead? >> Sure. Does the above look sane ? > > Yes, great! The resulting patch doesn't really look all that great, but I sent out a small series.