Re: [RFC PATCH 1/2] mmc: sdhci: Manually check card status after reset

From: Raul Rangel
Date: Wed Jun 19 2019 - 11:01:40 EST


On Tue, Jun 11, 2019 at 01:30:55PM +0300, Adrian Hunter wrote:
> Does the following work?
>
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 0cd5f2ce98df..f672171246b0 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -341,8 +341,19 @@ static void sdhci_init(struct sdhci_host *host, int soft)
>
> static void sdhci_reinit(struct sdhci_host *host)
> {
> + u32 cd = host->ier & (SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
> +
> sdhci_init(host, 0);
> sdhci_enable_card_detection(host);
> +
> + /*
> + * A change to the card detect bits indicates a change in present state,
> + * refer sdhci_set_card_detection(). A card detect interrupt might have
> + * been missed while the host controller was being reset, so trigger a
> + * rescan to check.
> + */
> + if (cd != (host->ier & (SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT)))
> + mmc_detect_change(host->mmc, msecs_to_jiffies(200));
> }
>
> static void __sdhci_led_activate(struct sdhci_host *host)

Your patch looks good. I tried it out and got over 57k insertion/removal
iterations. Do you want me to send out your patch, or do you want to do
it?

Just to recap, the patch you proposed + the AMD SDHCI specific patch fix
the problem.

Thanks!