Skip to contentSkip to conversation

mmc: dw_mmc: transfer proper bytes to FIFO

PATCH New Ziyuan Xu 4 participants 9 messages Jul 28, 2016 – Aug 5, 2016 MMC, SD and SDIO

lore
Share & tools
lore

Ziyuan Xu

author
#0 lore raw

PATCH 1/2 mmc: dw_mmc: transfer proper bytes to FIFO

The former implement, dw_mmc will push and pop the redundant data to FIFO, we should transfer it according to the real size.

---

 drivers/mmc/dw_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/dw_mmc.c +2 -0
index 2cf7bae..38d4a64 100644
@@ -126,6 +126,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = dwmci_readl(host, DWMCI_STATUS);
 					len = (len >> DWMCI_FIFO_SHIFT) &
 						    DWMCI_FIFO_MASK;
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						*buf++ =
 						dwmci_readl(host, DWMCI_DATA);
@@ -139,6 +140,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = fifo_depth - ((len >>
 						   DWMCI_FIFO_SHIFT) &
 						   DWMCI_FIFO_MASK);
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						dwmci_writel(host, DWMCI_DATA,
 							     *buf++);
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/2 mmc: dw_mmc: fix data starvation by host timeout under FIFO mode

This patch fixes data starvation by host timeout(HTO) error interrupt which occurred under FIFO mode transfer on rk3036 board.

The former implement, the actual bytes were transmitted may be less than should be. The size will still subtract value of len in case of there is no receive/transmit FIFO data request interrupt.

---

 drivers/mmc/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/dw_mmc.c +1 -0
index 38d4a64..41b7035 100644
@@ -120,6 +120,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 		}
 
 		if (host->fifo_mode && size) {
+			len = 0;
 			if (data->flags == MMC_DATA_READ) {
 				if ((dwmci_readl(host, DWMCI_RINTSTS) &
 				     DWMCI_INTMSK_RXDR)) {
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/2 mmc: dw_mmc: fix data starvation by host timeout under FIFO mode

Hi Ziyuan,

Quoted 6 lines · Ziyuan Xu

This patch fixes data starvation by host timeout(HTO) error interrupt which occurred under FIFO mode transfer on rk3036 board.

The former implement, the actual bytes were transmitted may be less than should be. The size will still subtract value of len in case of there is no receive/transmit FIFO data request interrupt.

Looks good to me.

Best Regards,
Jaehoon Chung

Quoted 20 lines

---

 drivers/mmc/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/dw_mmc.c +1 -0
index 38d4a64..41b7035 100644
@@ -120,6 +120,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 		}
 
 		if (host->fifo_mode && size) {
+			len = 0;
 			if (data->flags == MMC_DATA_READ) {
 				if ((dwmci_readl(host, DWMCI_RINTSTS) &
 				     DWMCI_INTMSK_RXDR)) {
#3 lore raw

PATCH 2/2 mmc: dw_mmc: fix data starvation by host timeout under FIFO mode

In reply to Ziyuan Xu
Quoted 7 lines · Ziyuan Xu

This patch fixes data starvation by host timeout(HTO) error interrupt which occurred under FIFO mode transfer on rk3036 board.

The former implement, the actual bytes were transmitted may be less than should be. The size will still subtract value of len in case of there is no receive/transmit FIFO data request interrupt.

Quoted 5 lines

---

 drivers/mmc/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
#4 lore raw

PATCH 2/2 mmc: dw_mmc: fix data starvation by host timeout under FIFO mode

In reply to Ziyuan Xu
Quoted 10 lines · Xu Ziyuan

This patch fixes data starvation by host timeout(HTO) error interrupt which occurred under FIFO mode transfer on rk3036 board.

The former implement, the actual bytes were transmitted may be less than should be. The size will still subtract value of len in case of there is no receive/transmit FIFO data request interrupt.

Applied on u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung

Quoted 18 lines

---

 drivers/mmc/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/dw_mmc.c +1 -0
index 38d4a64..41b7035 100644
@@ -120,6 +120,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 		}
 
 		if (host->fifo_mode && size) {
+			len = 0;
 			if (data->flags == MMC_DATA_READ) {
 				if ((dwmci_readl(host, DWMCI_RINTSTS) &
 				     DWMCI_INTMSK_RXDR)) {
#5 lore raw

PATCH 1/2 mmc: dw_mmc: transfer proper bytes to FIFO

In reply to Ziyuan Xu

Hi Ziyuan,

Quoted 2 lines · Ziyuan Xu

The former implement, dw_mmc will push and pop the redundant data to FIFO, we should transfer it according to the real size.

Looks good to me.

Best Regards,
Jaehoon Chung

Quoted 28 lines

---

 drivers/mmc/dw_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/dw_mmc.c +2 -0
index 2cf7bae..38d4a64 100644
@@ -126,6 +126,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = dwmci_readl(host, DWMCI_STATUS);
 					len = (len >> DWMCI_FIFO_SHIFT) &
 						    DWMCI_FIFO_MASK;
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						*buf++ =
 						dwmci_readl(host, DWMCI_DATA);
@@ -139,6 +140,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = fifo_depth - ((len >>
 						   DWMCI_FIFO_SHIFT) &
 						   DWMCI_FIFO_MASK);
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						dwmci_writel(host, DWMCI_DATA,
 							     *buf++);
#7 lore raw

PATCH 1/2 mmc: dw_mmc: transfer proper bytes to FIFO

In reply to Ziyuan Xu

? 2016/7/28 10:25, Ziyuan Xu ??:

Quoted 3 lines

The former implement, dw_mmc will push and pop the redundant data to FIFO, we should transfer it according to the real size.

Bascially I never checked any bootloader code, but I get dw_mmc of uboot to check your patch. Obviously it should be the case you mentioned.

Feel free to add

Quoted 27 lines

---

 drivers/mmc/dw_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/dw_mmc.c +2 -0
index 2cf7bae..38d4a64 100644
@@ -126,6 +126,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = dwmci_readl(host, DWMCI_STATUS);
 					len = (len >> DWMCI_FIFO_SHIFT) &
 						    DWMCI_FIFO_MASK;
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						*buf++ =
 						dwmci_readl(host, DWMCI_DATA);
@@ -139,6 +140,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = fifo_depth - ((len >>
 						   DWMCI_FIFO_SHIFT) &
 						   DWMCI_FIFO_MASK);
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						dwmci_writel(host, DWMCI_DATA,
 							     *buf++);
Signature · 2 lines
Best Regards
Shawn Lin
#8 lore raw

PATCH 1/2 mmc: dw_mmc: transfer proper bytes to FIFO

In reply to Ziyuan Xu
Quoted 7 lines · Xu Ziyuan

The former implement, dw_mmc will push and pop the redundant data to FIFO, we should transfer it according to the real size.

Applied on u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung

Quoted 26 lines

---

 drivers/mmc/dw_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/dw_mmc.c +2 -0
index 2cf7bae..38d4a64 100644
@@ -126,6 +126,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = dwmci_readl(host, DWMCI_STATUS);
 					len = (len >> DWMCI_FIFO_SHIFT) &
 						    DWMCI_FIFO_MASK;
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						*buf++ =
 						dwmci_readl(host, DWMCI_DATA);
@@ -139,6 +140,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)
 					len = fifo_depth - ((len >>
 						   DWMCI_FIFO_SHIFT) &
 						   DWMCI_FIFO_MASK);
+					len = min(size, len);
 					for (i = 0; i < len; i++)
 						dwmci_writel(host, DWMCI_DATA,
 							     *buf++);