Skip to contentSkip to conversation

mmc: core: resume not check card exist before powerup

PATCH In review Ricky Wu 2 participants 6 messages Mar 27, 2024 – Apr 29, 2024 MMC, SD and SDIO

lore
Share & tools
lore

Ricky Wu

author
#0 lore raw

PATCH 1/1 mmc: core: resume not check card exist before powerup

_mmc_sd_resume
add get_cd before call powerup, make sure the card exist

---
 drivers/mmc/core/sd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/core/sd.c +3 -0
index 1c8148cdda50..35e036672cfb 100644
@@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct mmc_host *host)
 	if (!mmc_card_suspended(host->card))
 		goto out;
 
+	if (host->ops->get_cd && !host->ops->get_cd(host))
+		goto out;
+
 	mmc_power_up(host, host->card->ocr);
 	err = mmc_sd_init_card(host, host->card->ocr, host->card);
 	mmc_card_clr_suspended(host->card);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Ricky Wu

_mmc_sd_resume
add get_cd before call powerup, make sure the card exist

Please elaborate more on what problem you are trying to solve, the above doesn't make much sense to me, sorry.

Yes, the card may be removed while the system is suspended. Then, even if ->get_cd() indicates that there is no card inserted in the SD-card-slot, we may still have the card being registered - and then we need to unregister it.
That said, we need to call mmc_power_up() in order to try to communicate with the card again. At least that is what the mmc_rescan() work assumes when it runs the bus_ops->detect() callback at some point later in time.

Quoted 21 lines
---
 drivers/mmc/core/sd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/core/sd.c +3 -1
index 1c8148cdda50..35e036672cfb 100644
@@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct mmc_host *host)
        if (!mmc_card_suspended(host->card))
                goto out;
 
+       if (host->ops->get_cd && !host->ops->get_cd(host))
+               goto out;
+
        mmc_power_up(host, host->card->ocr);
        err = mmc_sd_init_card(host, host->card->ocr, host->card);
        mmc_card_clr_suspended(host->card);
--
Quoted 2 lines

2.25.1

Kind regards
Uffe

author
#2 lore raw
Quoted 8 lines · Ricky Wu
Quoted 3 lines

_mmc_sd_resume
add get_cd before call powerup, make sure the card exist

Please elaborate more on what problem you are trying to solve, the above doesn't make much sense to me, sorry.

Quoted 9 lines

Yes, the card may be removed while the system is suspended. Then, even if ->get_cd() indicates that there is no card inserted in the SD-card-slot, we may still have the card being registered - and then we need to unregister it.
That said, we need to call mmc_power_up() in order to try to communicate with the card again. At least that is what the mmc_rescan() work assumes when it runs the bus_ops->detect() callback at some point later in time.

We saw the power up in a short time from waveform when removing the card, So we saw mmc_sd_resume call the power up did not check the card exist.

We think this the short time power up maybe cause OCP if no card exist. And this power up we think is unnecessary when no card exist.

Quoted 27 lines

drivers/mmc/core/sd.c static int _mmc_sd_resume(struct mmc_host

Quoted 11 lines
---
 drivers/mmc/core/sd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/core/sd.c +0 -0
index 1c8148cdda50..35e036672cfb 100644
@@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct mmc_host

*host)

Quoted 10 lines
drivers/mmc/core/sd.c +3 -1
        if (!mmc_card_suspended(host->card))
                goto out;
 
+       if (host->ops->get_cd && !host->ops->get_cd(host))
+               goto out;
+
        mmc_power_up(host, host->card->ocr);
        err = mmc_sd_init_card(host, host->card->ocr, host->card);
        mmc_card_clr_suspended(host->card);
--
Quoted 2 lines

2.25.1

Kind regards
Uffe

author
#3 lore raw
In reply to Ulf Hansson

Soft reminder

If this solution, you still have concert on sd.c.
can we just do this check card flow in mmc host power up call_back?

Quoted 51 lines
Quoted 7 lines
Quoted 3 lines

_mmc_sd_resume
add get_cd before call powerup, make sure the card exist

Please elaborate more on what problem you are trying to solve, the above doesn't make much sense to me, sorry.

Quoted 9 lines

Yes, the card may be removed while the system is suspended. Then, even if ->get_cd() indicates that there is no card inserted in the SD-card-slot, we may still have the card being registered - and then we need to unregister it.
That said, we need to call mmc_power_up() in order to try to communicate with the card again. At least that is what the mmc_rescan() work assumes when it runs the bus_ops->detect() callback at some point later in time.

We saw the power up in a short time from waveform when removing the card, So we saw mmc_sd_resume call the power up did not check the card exist.

We think this the short time power up maybe cause OCP if no card exist. And this power up we think is unnecessary when no card exist.

Quoted 27 lines

drivers/mmc/core/sd.c static int _mmc_sd_resume(struct mmc_host

Quoted 11 lines
---
 drivers/mmc/core/sd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0 -0

1c8148cdda50..35e036672cfb 100644

drivers/mmc/core/sd.c +0 -0
@@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct mmc_host

*host)

Quoted 10 lines
drivers/mmc/core/sd.c +3 -1
        if (!mmc_card_suspended(host->card))
                goto out;
 
+       if (host->ops->get_cd && !host->ops->get_cd(host))
+               goto out;
+
        mmc_power_up(host, host->card->ocr);
        err = mmc_sd_init_card(host, host->card->ocr, host->card);
        mmc_card_clr_suspended(host->card);
--
Quoted 2 lines

2.25.1

Kind regards
Uffe

#4 lore raw
Quoted 25 lines · Ricky WU

Soft reminder

If this solution, you still have concert on sd.c.
can we just do this check card flow in mmc host power up call_back?

Quoted 19 lines
Quoted 7 lines
Quoted 3 lines

_mmc_sd_resume
add get_cd before call powerup, make sure the card exist

Please elaborate more on what problem you are trying to solve, the above doesn't make much sense to me, sorry.

Quoted 9 lines

Yes, the card may be removed while the system is suspended. Then, even if ->get_cd() indicates that there is no card inserted in the SD-card-slot, we may still have the card being registered - and then we need to unregister it.
That said, we need to call mmc_power_up() in order to try to communicate with the card again. At least that is what the mmc_rescan() work assumes when it runs the bus_ops->detect() callback at some point later in time.

We saw the power up in a short time from waveform when removing the card, So we saw mmc_sd_resume call the power up did not check the card exist.

Well, that doesn't really tell me if that is a problem or not?

Doesn't the first command sent to the SD card (that has been removed) fail if there is no card inserted anyway?

Quoted 2 lines
Quoted 2 lines

We think this the short time power up maybe cause OCP if no card exist.

OCP?

Quoted 1 line
Quoted 1 line

And this power up we think is unnecessary when no card exist.

It may not be necessary, but in what way does it hurt?

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

drivers/mmc/core/sd.c static int _mmc_sd_resume(struct mmc_host

Quoted 13 lines
---
 drivers/mmc/core/sd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0 -0

1c8148cdda50..35e036672cfb 100644

drivers/mmc/core/sd.c +0 -0
@@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct mmc_host

*host)

Quoted 3 lines
drivers/mmc/core/sd.c +0 -0
        if (!mmc_card_suspended(host->card))
                goto out;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/mmc/core/sd.c static int _mmc_sd_resume(struct mmc_host *host)

Quoted 7 lines
drivers/mmc/core/sd.c +3 -1
+       if (host->ops->get_cd && !host->ops->get_cd(host))
+               goto out;
+
        mmc_power_up(host, host->card->ocr);
        err = mmc_sd_init_card(host, host->card->ocr, host->card);
        mmc_card_clr_suspended(host->card);
--

Kind regards
Uffe

author
#5 lore raw
Quoted 29 lines
Quoted 24 lines

Soft reminder

If this solution, you still have concert on sd.c.
can we just do this check card flow in mmc host power up call_back?

Quoted 18 lines
Quoted 7 lines
Quoted 3 lines

_mmc_sd_resume
add get_cd before call powerup, make sure the card exist

Please elaborate more on what problem you are trying to solve, the above doesn't make much sense to me, sorry.

Quoted 9 lines

Yes, the card may be removed while the system is suspended. Then, even if ->get_cd() indicates that there is no card inserted in the SD-card-slot, we may still have the card being registered - and then we need to unregister it.
That said, we need to call mmc_power_up() in order to try to communicate with the card again. At least that is what the mmc_rescan() work assumes when it runs the bus_ops->detect() callback at some point later in time.

We saw the power up in a short time from waveform when removing the

card,

Quoted 1 line
Quoted 1 line

So we saw mmc_sd_resume call the power up did not check the card exist.

Well, that doesn't really tell me if that is a problem or not?

Quoted 7 lines

Doesn't the first command sent to the SD card (that has been removed) fail if there is no card inserted anyway?

Quoted 2 lines
Quoted 2 lines

We think this the short time power up maybe cause OCP if no card exist.

OCP?

OCP: over current protection
We think this short time power up has short circuit risk when no card exist That is why we want to check card exist or not when power up

Quoted 33 lines
Quoted 2 lines
Quoted 2 lines

And this power up we think is unnecessary when no card exist.

It may not be necessary, but in what way does it hurt?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
---
 drivers/mmc/core/sd.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/mmc/core/sd.c static int _mmc_sd_resume(struct

Quoted 5 lines
drivers/mmc/core/sd.c index renamed from drivers/mmc/core/sd.c +0 -0

1c8148cdda50..35e036672cfb 100644

drivers/mmc/core/sd.c +0 -0
@@ -1750,6 +1750,9 @@ static int _mmc_sd_resume(struct

mmc_host

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

*host)

Quoted 10 lines
drivers/mmc/core/sd.c +3 -1
        if (!mmc_card_suspended(host->card))
                goto out;
 
+       if (host->ops->get_cd && !host->ops->get_cd(host))
+               goto out;
+
        mmc_power_up(host, host->card->ocr);
        err = mmc_sd_init_card(host, host->card->ocr, host->card);
        mmc_card_clr_suspended(host->card);
--

Kind regards
Uffe