Skip to contentSkip to conversation

mmc: dwmmc: only clear handled interrupts

PATCH In review John Keeping 5 participants 5 messages Sep 15, 2022 – Oct 25, 2022 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: dwmmc: only clear handled interrupts

Unconditionally clearing DTO when RXDR is set leads to spurious timeouts in FIFO mode transfers if events occur in the following order:

	mask = dwmci_readl(host, DWMCI_RINTSTS);

	// Hardware asserts DWMCI_INTMSK_DTO here

	dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_DTO);

	if (mask & DWMCI_INTMSK_DTO) {
		// Unreachable as DTO is cleared without being handled!
		return 0;
	}

Only clear interrupts that we have seen and are handling so that DTO is not missed.

---
 drivers/mmc/dw_mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +2 -1
index 4232c5eb8c..5085a3b491 100644
@@ -168,7 +168,8 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 			if (data->flags == MMC_DATA_READ &&
 			    (mask & (DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO))) {
 				dwmci_writel(host, DWMCI_RINTSTS,
-					     DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO);
+					     mask & (DWMCI_INTMSK_RXDR |
+						     DWMCI_INTMSK_DTO));
 				while (size) {
 					ret = dwmci_fifo_ready(host,
 							DWMCI_FIFO_EMPTY,
Signature · 1 line
2.37.3
Tested-by on v1 1/1
#1 lore raw
Quoted 27 lines · John Keeping

Unconditionally clearing DTO when RXDR is set leads to spurious timeouts in FIFO mode transfers if events occur in the following order:

	mask = dwmci_readl(host, DWMCI_RINTSTS);

	// Hardware asserts DWMCI_INTMSK_DTO here

	dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_DTO);

	if (mask & DWMCI_INTMSK_DTO) {
		// Unreachable as DTO is cleared without being handled!
		return 0;
	}

Only clear interrupts that we have seen and are handling so that DTO is not missed.

---
 drivers/mmc/dw_mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +0 -0
index 4232c5eb8c..5085a3b491 100644

drivers/mmc/dw_mmc.c static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) · line 175

Quoted 9 lines
drivers/mmc/dw_mmc.c +2 -1
@@ -168,7 +168,8 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 			if (data->flags == MMC_DATA_READ &&
 			    (mask & (DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO))) {
 				dwmci_writel(host, DWMCI_RINTSTS,
-					     DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO);
+					     mask & (DWMCI_INTMSK_RXDR |
+						     DWMCI_INTMSK_DTO));
 				while (size) {
 					ret = dwmci_fifo_ready(host,
 							DWMCI_FIFO_EMPTY,

Boot logs:

- 2022.04 without this patch:

[...]
U-Boot SPL 2022.04 (Apr 04 2022 - 14:31:32 +0000)

Trying to boot from MMC1

## Checking hash(es) for config config_1 ... sha1,rsa2048:dev+ OK

## Checking hash(es) for Image atf_1 ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image uboot ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image fdt_1 ... sha1+ sha1,rsa2048:dev+ OK

spl_load_simple_fit: can't load image loadables index 1 (ret = -5)

mmc_load_image_raw_sector: mmc block read error

[...]

- 2022.04 with this patch:

[...]
U-Boot SPL 2022.04 (Apr 04 2022 - 14:31:32 +0000)

Trying to boot from MMC1

## Checking hash(es) for config config_1 ... sha1,rsa2048:dev+ OK

## Checking hash(es) for Image atf_1 ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image uboot ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image fdt_1 ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image atf_2 ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image atf_3 ... sha1+ sha1,rsa2048:dev+ OK

## Checking hash(es) for Image atf_4 ... sha1+ sha1,rsa2048:dev+ OK

NOTICE: BL31: v2.6(debug):v2.6-879-gc3bdd3d3cf-dirty

[...]

Thanks,

Signature · 1 line
Jerome
Tested-by on v1 1/1
#2 lore raw
In reply to John Keeping

Hi John,

Quoted 14 lines · John Keeping

Unconditionally clearing DTO when RXDR is set leads to spurious timeouts in FIFO mode transfers if events occur in the following order:

	mask = dwmci_readl(host, DWMCI_RINTSTS);

	// Hardware asserts DWMCI_INTMSK_DTO here

	dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_DTO);

	if (mask & DWMCI_INTMSK_DTO) {
		// Unreachable as DTO is cleared without being handled!
		return 0;
	}
Quoted 4 lines

Only clear interrupts that we have seen and are handling so that DTO is not missed.

Awesome! I was having what I thought were stability issues on a board I'm bringing up and this fixes the issue. Thanks!

Cheers,
Quentin

Reviewed-by on v1 1/1
#3 lore raw
In reply to John Keeping
Quoted 14 lines · John Keeping

Unconditionally clearing DTO when RXDR is set leads to spurious timeouts in FIFO mode transfers if events occur in the following order:

	mask = dwmci_readl(host, DWMCI_RINTSTS);

	// Hardware asserts DWMCI_INTMSK_DTO here

	dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_DTO);

	if (mask & DWMCI_INTMSK_DTO) {
		// Unreachable as DTO is cleared without being handled!
		return 0;
	}
Quoted 4 lines

Only clear interrupts that we have seen and are handling so that DTO is not missed.

Best Regards,
Jaehoon Chung

Quoted 18 lines
---
 drivers/mmc/dw_mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +2 -1
index 4232c5eb8c..5085a3b491 100644
@@ -168,7 +168,8 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 			if (data->flags == MMC_DATA_READ &&
 			    (mask & (DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO))) {
 				dwmci_writel(host, DWMCI_RINTSTS,
-					     DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO);
+					     mask & (DWMCI_INTMSK_RXDR |
+						     DWMCI_INTMSK_DTO));
 				while (size) {
 					ret = dwmci_fifo_ready(host,
 							DWMCI_FIFO_EMPTY,
#4 lore raw
In reply to John Keeping
Quoted 14 lines · John Keeping

Unconditionally clearing DTO when RXDR is set leads to spurious timeouts in FIFO mode transfers if events occur in the following order:

	mask = dwmci_readl(host, DWMCI_RINTSTS);

	// Hardware asserts DWMCI_INTMSK_DTO here

	dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_DTO);

	if (mask & DWMCI_INTMSK_DTO) {
		// Unreachable as DTO is cleared without being handled!
		return 0;
	}
Quoted 7 lines

Only clear interrupts that we have seen and are handling so that DTO is not missed.

Applied to u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung

Quoted 18 lines
---
 drivers/mmc/dw_mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +2 -1
index 4232c5eb8c..5085a3b491 100644
@@ -168,7 +168,8 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 			if (data->flags == MMC_DATA_READ &&
 			    (mask & (DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO))) {
 				dwmci_writel(host, DWMCI_RINTSTS,
-					     DWMCI_INTMSK_RXDR | DWMCI_INTMSK_DTO);
+					     mask & (DWMCI_INTMSK_RXDR |
+						     DWMCI_INTMSK_DTO));
 				while (size) {
 					ret = dwmci_fifo_ready(host,
 							DWMCI_FIFO_EMPTY,