Hi Ulf, > > > > +static bool mmc_may_poweroff_notify(const struct mmc_host *host, > > > > + bool is_suspend) > > > > Maybe add some comments about the difference between > > mmc_can_poweroff_notify() and mmc_may_poweroff_notify()? Like make it > > super-obvious, so I will easily remember next year again :) > > mmc_can_* functions are mostly about checking what the card is capable > of. So mmc_can_poweroff_notify() should be consistent with the other > similar functions. > > For eMMC power-off notifications in particular, it has become more > complicated as we need to check the power-off scenario along with the > host's capabilities, to understand what we should do. > > I am certainly open to another name than mmc_may_power_off_notify(), > if that is what you are suggesting. Do you have a proposal? :-) Initially, I didn't think of new names but some explanation in comments. But since you are mentioning a rename now, how about: mmc_card_can_poweroff_notify() and mmc_host_can_poweroff_notify()? Similar to the commit 32f18e596141 ("mmc: improve API to make clear hw_reset callback is for cards") where I renamed 'hw_reset' to 'card_hw_reset' for AFAICS similar reasons. > > > > if (mmc_can_poweroff_notify(host->card) && > > > > - !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) > > > > + !mmc_may_poweroff_notify(host, true)) > > > I guess this deserve some extra documentation because: > > > If MMC_CAP2_FULL_PWR_CYCLE is not set but MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND is set, > > > !mmc_may_poweroff_notify(host, true) will evaluate to false while !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) will evaluate to true. > > Right. See more below. > > > > > I agree, I neither get this. Another way to express my confusion is: Why > > do we set the 'is_suspend' flag to true in the shutdown function? > > > > I understand your concern and I agree that this is rather messy. > Anyway, for shutdown, we set the is_suspend flag to false. The > reasoning behind this is that during shutdown we know that the card > will be fully powered-down (both vcc and vccq will be cut). > > In suspend/runtime_suspend, we don't really know as it depends on what > the platform/host is capable of. If we can't do a full power-off > (maybe just vcc can be cut), then we prefer the sleep command instead. I do understand that. I don't see why this needs a change in the existing logic as Alan pointed out above. > I was hoping that patch3 should make this more clear (using an enum Sadly, it didn't. Using MMC_POWEROFF_SUSPEND first and then later MMC_POWEROFF_SHUTDOWN in mmc_shutdown() is still confusing. Do you want to return false in case none of the two PWR_CYCLE flags is set? > type), but I can try to add some comment(s) in the code to further > clarify the policy. Please do. All the best, Wolfram
Attachment:
signature.asc
Description: PGP signature