Skip to contentSkip to conversation

[PATCH 0/2]

PATCH Superseded Rex Chen 2 participants 7 messages Jun 27, 2025 – Jul 4, 2025

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Rex Chen

author
#0 lore raw

cover [PATCH 0/2]

[PATCH 1/2]
Function mmc_sdio_alive() check if sd device alive by cmd7, but SPI mode cmd7 unavailable, so replaced by check if can read CCCR register success. [PATCH 2/2]
SPI multiple read operation doesn't need to read crc ack, so remove it.

Rex Chen (2):
mmc: core: SPI mode remove cmd7
mmc: mmc_spi: multiple block read remove read crc ack

 drivers/mmc/core/sdio.c    | 8 +++++++-
 drivers/mmc/host/mmc_spi.c | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/2 mmc: core: SPI mode remove cmd7

SPI mode doesn't support cmd7, so remove it in mmc_sdio_alive() and confirm if sdio is active by checking CCCR register value is available or not.

---
 drivers/mmc/core/sdio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/core/sdio.c +7 -1
index 0f753367aec1..a5679a0add16 100644
@@ -945,7 +945,13 @@ static void mmc_sdio_remove(struct mmc_host *host)
  */
 static int mmc_sdio_alive(struct mmc_host *host)
 {
-	return mmc_select_card(host->card);
+	u8 data;
+
+	if (!mmc_host_is_spi(host))
+		return mmc_select_card(host->card);
+	else
+		return mmc_io_rw_direct(host->card, 0, 0, SDIO_CCCR_CCCR, 0,
+					&data);
 }
 
 /*
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/2] mmc: core: SPI mode remove cmd7

Quoted 16 lines · Rex Chen

SPI mode doesn't support cmd7, so remove it in mmc_sdio_alive() and confirm if sdio is active by checking CCCR register value is available or not.

---
 drivers/mmc/core/sdio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/core/sdio.c +0 -0
index 0f753367aec1..a5679a0add16 100644
@@ -945,7 +945,13 @@ static void mmc_sdio_remove(struct mmc_host *host)
  */

drivers/mmc/core/sdio.c static void mmc_sdio_remove(struct mmc_host *host) · line 954

Quoted 10 lines
drivers/mmc/core/sdio.c +7 -1
 static int mmc_sdio_alive(struct mmc_host *host)
 {
-       return mmc_select_card(host->card);
+       u8 data;
+
+       if (!mmc_host_is_spi(host))
+               return mmc_select_card(host->card);
+       else
+               return mmc_io_rw_direct(host->card, 0, 0, SDIO_CCCR_CCCR, 0,
+                                       &data);

There is no reason to provide &data as the out-parameter unless we are going to use it. Just provide NULL instead.

Quoted 6 lines
drivers/mmc/core/sdio.c +0 -1
 }
 
 /*
--

2.25.1

Kind regards
Uffe

author
#3 lore raw

PATCH 2/2 mmc: mmc_spi: multiple block read remove read crc ack

In reply to Rex Chen

Multiple block read doesn't need to read crc ack, so remove it.

---
 drivers/mmc/host/mmc_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/mmc_spi.c +1 -1
index 47443fb5eb33..f42d5f9c48c1 100644
@@ -563,7 +563,7 @@ mmc_spi_setup_data_message(struct mmc_spi_host *host, bool multiple, bool write)
 	 * the next token (next data block, or STOP_TRAN).  We can try to
 	 * minimize I/O ops by using a single read to collect end-of-busy.
 	 */
-	if (multiple || write) {
+	if (write) {
 		t = &host->early_status;
 		memset(t, 0, sizeof(*t));
 		t->len = write ? sizeof(scratch->status) : 1;
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH 2/2] mmc: mmc_spi: multiple block read remove read crc ack

Quoted 2 lines · Rex Chen

Multiple block read doesn't need to read crc ack, so remove it.

Why? Please elaborate.

Kind regards
Uffe

Quoted 22 lines
---
 drivers/mmc/host/mmc_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/mmc_spi.c +1 -2
index 47443fb5eb33..f42d5f9c48c1 100644
@@ -563,7 +563,7 @@ mmc_spi_setup_data_message(struct mmc_spi_host *host, bool multiple, bool write)
         * the next token (next data block, or STOP_TRAN).  We can try to
         * minimize I/O ops by using a single read to collect end-of-busy.
         */
-       if (multiple || write) {
+       if (write) {
                t = &host->early_status;
                memset(t, 0, sizeof(*t));
                t->len = write ? sizeof(scratch->status) : 1;
--

2.25.1

author
#5 lore raw

Re: [PATCH 2/2] mmc: mmc_spi: multiple block read remove read crc ack

Quoted 2 lines · Rex Chen

Multiple block read doesn't need to read crc ack, so remove it.

Why? Please elaborate.
-----From Rex Chen:
The origin implementation without my change, function mmc_spi_setup_data_message builds data transfer sequence, transfer one block data sequence contains token, payload, crc, and 29 bytes scratch->status to wait crc ack from sdio device side for block write, also 1 byte for block read, I don't know why need this 1 byte transfer, and block read transfer failed if I add this 1 byte sequence. I didn't find related description in specification about this 1 byte transfer, maybe I miss it, if so, could you pls let me know the details?
Thanks.

Kind regards
Uffe

Quoted 22 lines
---
 drivers/mmc/host/mmc_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/mmc_spi.c +1 -2
index 47443fb5eb33..f42d5f9c48c1 100644
@@ -563,7 +563,7 @@ mmc_spi_setup_data_message(struct mmc_spi_host *host, bool multiple, bool write)
         * the next token (next data block, or STOP_TRAN).  We can try to
         * minimize I/O ops by using a single read to collect end-of-busy.
         */
-       if (multiple || write) {
+       if (write) {
                t = &host->early_status;
                memset(t, 0, sizeof(*t));
                t->len = write ? sizeof(scratch->status) : 1;
--

2.25.1

#6 lore raw

Re: [PATCH 2/2] mmc: mmc_spi: multiple block read remove read crc ack

Quoted 10 lines · Rex Chen
Quoted 2 lines · Rex Chen

Multiple block read doesn't need to read crc ack, so remove it.

Why? Please elaborate.
-----From Rex Chen:
The origin implementation without my change, function mmc_spi_setup_data_message builds data transfer sequence, transfer one block data sequence contains token, payload, crc, and 29 bytes scratch->status to wait crc ack from sdio device side for block write, also 1 byte for block read, I don't know why need this 1 byte transfer, and block read transfer failed if I add this 1 byte sequence. I didn't find related description in specification about this 1 byte transfer, maybe I miss it, if so, could you pls let me know the details?

I don't know the details from the top of my head, sorry.

I would have to go and read the spec to find out, but I don't have the time to do that currently. In other words, I will be relying on you and others in the community to help out with this. So, please re-submit your patches and include a proper commit message with the information, then we can take it from there.

[...]

Kind regards
Uffe