From 613b37150fadb105c98c617f68b1c2eda3ad6755 Mon Sep 17 00:00:00 2001 From: Sarthak Garg Date: Fri, 10 Jun 2022 11:04:25 +0530 Subject: [PATCH] mmc: sdhci-msm: Remove mmc->card check from MGPI design support Remove mmc->card check from MGPI design support to handle one corner case where the card can be removed as part of mmc_set_uhs_voltage inside mmc_sd_get_cid. In that case we may go for mmc_power_cycle due to errors which occur due to card removal. Moreover mmc->card will be NULL at that point as card is not initialized yet due to which we may end up turning ON the regulators as part of mmc_power_up leading to SIM card burn issue. To avoid that remove mmc->card check to handle such cases where card is removed before initialization and we do power_cycle due to card removal. Also notify sdhci_msm_check_power_status in such cases which will be waiting for completion of such irq's to avoid irq timeouts leading to bootup delays by 5secs for each such irq. Change-Id: I50e2647cff183cd48d3e2565e4b97839ec1355b3 Signed-off-by: Sarthak Garg --- drivers/mmc/host/sdhci-msm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index e8bc8a7519a5..5bd590fcc127 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * * drivers/mmc/host/sdhci-msm.c - Qualcomm Technologies, Inc. MSM SDHCI Platform * driver source file @@ -3188,11 +3189,14 @@ static irqreturn_t sdhci_msm_pwr_irq(int irq, void *data) sdhci_msm_clear_pwrctl_status(host, irq_status); - if (mmc->card && mmc->ops->get_cd && !mmc->ops->get_cd(mmc) && + if (mmc->ops->get_cd && !mmc->ops->get_cd(mmc) && irq_status & CORE_PWRCTL_BUS_ON) { irq_ack = CORE_PWRCTL_BUS_FAIL; sdhci_msm_writeb_relaxed(irq_ack, host, msm_host_offset->CORE_PWRCTL_CTL); + spin_lock_irqsave(&host->lock, flags); + complete(&msm_host->pwr_irq_completion); + spin_unlock_irqrestore(&host->lock, flags); return IRQ_HANDLED; } @@ -3430,7 +3434,7 @@ static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type) sdhci_msm_dump_pwr_ctrl_regs(host); } - if (mmc->card && mmc->ops->get_cd && !mmc->ops->get_cd(mmc) && + if (mmc->ops->get_cd && !mmc->ops->get_cd(mmc) && (req_type & REQ_BUS_ON)) { host->pwr = 0; sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);