From patchwork Tue Feb 13 05:17:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?7J207Iq57Z2s?= X-Patchwork-Id: 772561 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0BA911717 for ; Tue, 13 Feb 2024 05:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707801219; cv=none; b=e8+UQXGmwNEw5F3btSSvvq/IcI2srb+Z7vvviXIhMhNeTnkLGaO+0w9+rcUdTdEqgHP1wKYn8G1DhaDeiRi0MtscxSwS2iqji4/35vqJN+/lzmdvmmzE0Qo5uSjSK4EjsP5NSI+icEf6nhD2C2ZAm2G/1FVihc5y+GKi/WFiC3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707801219; c=relaxed/simple; bh=DWFcKn1l9Sn/hd+zC927DFkvDijnYn0PyBhaocjqmPA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: References; b=VztXlke0TwVrhCy5xpUGKOXCxeRw/2iIyQa6RaLUeDQVGnk7boIjtAGach4dIriFO2138F5CiT6XHatLS3tCzw87bf6nOBaAhrwLamF9FZkN+QGb1i4LNTfWGqHXK13w4xOdqDUPewigYK5pjsA2nTWLfGpSOuw03keWhti3yA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=j0RtezKw; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="j0RtezKw" Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240213051333epoutp04b568ca6cbfd9eb1480bb9b1b87e660a8~zVCfV6PKo2215322153epoutp04M for ; Tue, 13 Feb 2024 05:13:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240213051333epoutp04b568ca6cbfd9eb1480bb9b1b87e660a8~zVCfV6PKo2215322153epoutp04M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707801213; bh=dqPFTyfLpIiOwNn2UYQocQjz2kFlkgOBWnJcMM8k5K8=; h=From:To:Cc:Subject:Date:References:From; b=j0RtezKwFfQt2vXITpkL1UhwRCJzuaenC7uSrN+cJbVYnkFR+j4lL13/9bPFKMl8W IymepB0g8RL9uzbNCUexWdiCUeE5vzqIsTn8cG55bckPHAMWc4SRKWVQVUmO02u01C NNpEJOi6XEN1HDC2mI/ofhLb7tJrYPzNNYB2a7sQ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20240213051333epcas1p1283e6c855368c394ace15522c9136aec~zVCexj1yQ2686026860epcas1p1H; Tue, 13 Feb 2024 05:13:33 +0000 (GMT) Received: from epsmgec1p1.samsung.com (unknown [182.195.36.227]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4TYqH05tM9z4x9Pv; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmgec1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 71.B8.08572.C7AFAC56; Tue, 13 Feb 2024 14:13:32 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc~zVCd_duAW2685026850epcas1p1c; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240213051332epsmtrp2d80db3c4e9ba94969b78a7d530bc6104~zVCd9xIvc0269502695epsmtrp2m; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) X-AuditID: b6c32a33-cefff7000000217c-07-65cafa7c6b12 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 7B.20.18939.C7AFAC56; Tue, 13 Feb 2024 14:13:32 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.101.71]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240213051332epsmtip1835b0865323701a316e6a73933c4c37c~zVCdt2vdC1628916289epsmtip17; Tue, 13 Feb 2024 05:13:32 +0000 (GMT) From: Seunghui Lee To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, gregkh@linuxfoundation.org, avri.altman@wdc.com Cc: grant.jung@samsung.com, jt77.jang@samsung.com, dh0421.hwang@samsung.com, junwoo80.lee@samsung.com, jangsub.yi@samsung.com, cw9316.lee@samsung.com, sh8267.baek@samsung.com, wkon.kim@samsung.com, Seunghui Lee Subject: [PATCH] mmc: sd: Add a variable to check a faulty device Date: Tue, 13 Feb 2024 14:17:16 +0900 Message-Id: <20240213051716.6596-1-sh043.lee@samsung.com> X-Mailer: git-send-email 2.29.0 Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmgW7Nr1OpBiv3aVq8/HmVzWLGqTZW i33XTrJb/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ANd3Ui3fAgAA X-CMS-MailID: 20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc References: In mobile devices, suspend/resume situations are frequent. In the case of a defective SD card in which initialization fails, unnecessary initialization time is consumed for each resume. A field is needed to check that SD card initialization has failed on the host. It could be used to remove unnecessary initialization. Signed-off-by: Seunghui Lee --- drivers/mmc/core/sd.c | 12 +++++++++++- drivers/mmc/core/slot-gpio.c | 1 + include/linux/mmc/host.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index c3e554344c99..f0eb3864dc24 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1410,6 +1410,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, bool v18_fixup_failed = false; WARN_ON(!host->claimed); + host->init_failed = false; retry: err = mmc_sd_get_cid(host, ocr, cid, &rocr); if (err) @@ -1752,6 +1753,8 @@ static int _mmc_sd_resume(struct mmc_host *host) mmc_power_up(host, host->card->ocr); err = mmc_sd_init_card(host, host->card->ocr, host->card); + if (err) + host->init_failed = true; mmc_card_clr_suspended(host->card); out: @@ -1803,8 +1806,12 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) static int mmc_sd_hw_reset(struct mmc_host *host) { + int err; mmc_power_cycle(host, host->card->ocr); - return mmc_sd_init_card(host, host->card->ocr, host->card); + err = mmc_sd_init_card(host, host->card->ocr, host->card); + if (err) + host->init_failed = true; + return err; } static const struct mmc_bus_ops mmc_sd_ops = { @@ -1891,5 +1898,8 @@ int mmc_attach_sd(struct mmc_host *host) pr_err("%s: error %d whilst initialising SD card\n", mmc_hostname(host), err); + if (err) + host->init_failed = true; + return err; } diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 2a2d949a9344..93d081c7dd53 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -33,6 +33,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) struct mmc_gpio *ctx = host->slot.handler_priv; host->trigger_card_event = true; + host->init_failed = false; mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms)); return IRQ_HANDLED; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 2f445c651742..1d75cfdbf981 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -467,6 +467,7 @@ struct mmc_host { struct timer_list retune_timer; /* for periodic re-tuning */ bool trigger_card_event; /* card_event necessary */ + bool init_failed; /* check if failed to initialize */ struct mmc_card *card; /* device attached to this host */