Linux-mmc Archive mirror
 help / color / mirror / Atom feed
From: Seunghui Lee <sh043.lee@samsung.com>
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 <sh043.lee@samsung.com>
Subject: [PATCH] mmc: sd: Add a variable to check a faulty device
Date: Tue, 13 Feb 2024 14:17:16 +0900	[thread overview]
Message-ID: <20240213051716.6596-1-sh043.lee@samsung.com> (raw)
In-Reply-To: CGME20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc@epcas1p1.samsung.com

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 <sh043.lee@samsung.com>
---
 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 */
 
-- 
2.29.0


       reply	other threads:[~2024-02-13  5:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240213051332epcas1p1f45d02dc34d1b95ea5608ab779d6b6cc@epcas1p1.samsung.com>
2024-02-13  5:17 ` Seunghui Lee [this message]
2024-02-13  8:42   ` [PATCH] mmc: sd: Add a variable to check a faulty device Avri Altman
2024-02-13  9:49     ` 이승희
2024-02-13 13:35       ` Christian Loehle
2024-02-14  2:01         ` 이승희
2024-02-14 11:26   ` Ulf Hansson
2024-02-15  1:03     ` 이승희
2024-02-15  8:07       ` Greg KH
2024-02-15 11:15         ` 이승희
2024-02-15 11:38           ` 'Greg KH'
2024-02-16  2:26             ` 이승희
2024-02-15 11:00       ` Ulf Hansson
2024-02-16  1:14         ` 이승희
2024-03-01 10:33           ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240213051716.6596-1-sh043.lee@samsung.com \
    --to=sh043.lee@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=cw9316.lee@samsung.com \
    --cc=dh0421.hwang@samsung.com \
    --cc=grant.jung@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jangsub.yi@samsung.com \
    --cc=jt77.jang@samsung.com \
    --cc=junwoo80.lee@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=sh8267.baek@samsung.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wkon.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).