mmc: mmci: Only call .post_sig_volt_switch if voltage switch happened
Subsystems (2)
PATCH 1/1 mmc: mmci: Only call .post_sig_volt_switch if voltage switch happened
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.
--- drivers/mmc/host/mmci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mmc/host/mmci.c +7 -2
@@ -1861,10 +1861,12 @@ static int mmci_get_cd(struct mmc_host *mmc)static int mmci_sig_volt_switch (struct mmc_host *mmc,struct mmc_ios *ios) {struct mmci_host *host =mmc_priv (mmc); -int ret =0 ; +int old_voltage, new_voltage, ret =0 ;if (!IS_ERR (mmc->supply.vqmmc)) { + old_voltage =regulator_get_voltage (mmc->supply.vqmmc); +switch (ios->signal_voltage) {case MMC_SIGNAL_VOLTAGE_330 : ret = regulator_set_voltage(mmc->supply.vqmmc,
@@ -1880,7 +1882,10 @@ static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)break ; } -if (!ret && host->ops && host->ops->post_sig_volt_switch) + new_voltage =regulator_get_voltage (mmc->supply.vqmmc); + +if (!ret && old_voltage != new_voltage && + host->ops && host->ops->post_sig_volt_switch) ret = host->ops->post_sig_volt_switch (host, ios);if (ret)
Signature · 1 line
2.25.1
Quoted 10 lines · Marek Vasut
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().
Then on top of that, convert mmci into using the mmc_regulator_set_vqmmc() API.
Can please try this approach instead?
Kind regards
Uffe
Quoted 50 lines
Signed-off-by Marek Vasut <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Linus Walleij <[email protected]>Cc Ludovic Barre <[email protected]>Cc Manivannan Sadhasivam <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Patrice Chotard <[email protected]>Cc Patrick Delaunay <[email protected]>Cc Russell King <[email protected]>Cc Ulf Hansson <[email protected]>--- drivers/mmc/host/mmci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/mmc/host/mmci.c +7
-3@@ -1861,10 +1861,12 @@ static int mmci_get_cd(struct mmc_host *mmc)static int mmci_sig_volt_switch (struct mmc_host *mmc,struct mmc_ios *ios) {struct mmci_host *host =mmc_priv (mmc); -int ret =0 ; +int old_voltage, new_voltage, ret =0 ;if (!IS_ERR (mmc->supply.vqmmc)) { + old_voltage =regulator_get_voltage (mmc->supply.vqmmc); +switch (ios->signal_voltage) {case MMC_SIGNAL_VOLTAGE_330 : ret = regulator_set_voltage(mmc->supply.vqmmc,@@ -1880,7 +1882,10 @@ static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)break ; } -if (!ret && host->ops && host->ops->post_sig_volt_switch) + new_voltage =regulator_get_voltage (mmc->supply.vqmmc); + +if (!ret && old_voltage != new_voltage && + host->ops && host->ops->post_sig_volt_switch) ret = host->ops->post_sig_volt_switch (host, ios);if (ret) --2.25.1
Quoted 7 lines · Ulf Hansson
Quoted 6 lines · Marek Vasut
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.
Quoted 7 lines
Quoted 4 lines
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?
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 ?
Quoted 3 lines
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 ?
[...]
Signature · 2 lines
Best regards, Marek Vasut
Quoted 14 lines · Marek Vasut
Quoted 12 lines · Ulf Hansson
Quoted 10 lines · Marek Vasut
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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 13 lines
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(...);
Quoted 6 lines
That looks OK I guess ?
Quoted 3 lines
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!
Kind regards
Uffe
Quoted 37 lines · Ulf Hansson
Quoted 14 lines · Marek Vasut
Quoted 12 lines · Ulf Hansson
Quoted 10 lines · Marek Vasut
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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 13 lines
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(...);
Quoted 8 lines
Quoted 6 lines
That looks OK I guess ?
Quoted 3 lines
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.