All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] mmc: mtk-sd: fix possible incomplete read ops
@ 2019-01-17 17:06 Fabien Parent
  2019-01-17 17:06 ` [U-Boot] [PATCH 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n Fabien Parent
  2019-01-27  3:52 ` [U-Boot] [U-Boot, 1/2] mmc: mtk-sd: fix possible incomplete read ops Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Fabien Parent @ 2019-01-17 17:06 UTC (permalink / raw
  To: u-boot

The code is checking for incomplete read when it see the INT_XFER_COMPL
flag, but it forget to first check whether there is anything left in the
FIFO to copy to the RX buffer. This means that sometimes we will get
errors because of erroneous incomplete read operation.

This commit fixes the driver re-ordering the code so that we first
check for data inside the RX fifo and only after check the status
of the INT_XFER_COMPL flag.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/mmc/mtk-sd.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c
index 0741a525c0..e668df7017 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -554,6 +554,14 @@ static int msdc_pio_read(struct msdc_host *host, u8 *ptr, u32 size)
 			break;
 		}
 
+		chksz = min(size, (u32)MSDC_FIFO_SIZE);
+
+		if (msdc_fifo_rx_bytes(host) >= chksz) {
+			msdc_fifo_read(host, ptr, chksz);
+			ptr += chksz;
+			size -= chksz;
+		}
+
 		if (status & MSDC_INT_XFER_COMPL) {
 			if (size) {
 				pr_err("data not fully read\n");
@@ -562,15 +570,7 @@ static int msdc_pio_read(struct msdc_host *host, u8 *ptr, u32 size)
 
 			break;
 		}
-
-		chksz = min(size, (u32)MSDC_FIFO_SIZE);
-
-		if (msdc_fifo_rx_bytes(host) >= chksz) {
-			msdc_fifo_read(host, ptr, chksz);
-			ptr += chksz;
-			size -= chksz;
-		}
-	}
+}
 
 	return ret;
 }
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n
  2019-01-17 17:06 [U-Boot] [PATCH 1/2] mmc: mtk-sd: fix possible incomplete read ops Fabien Parent
@ 2019-01-17 17:06 ` Fabien Parent
  2019-01-27  3:52   ` [U-Boot] [U-Boot, " Tom Rini
  2019-01-27  3:52 ` [U-Boot] [U-Boot, 1/2] mmc: mtk-sd: fix possible incomplete read ops Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Fabien Parent @ 2019-01-17 17:06 UTC (permalink / raw
  To: u-boot

It is not possible to link the SPL image when CONFIG_GPIO is enabled
but CONFIG_SPL_GPIO is not.  Use the IS_ENABLED macro instead to
correctly check whether CONFIG_{SPL_}GPIO is enabled.

This commit fixes the following errors:
	* undefined reference to `dm_gpio_get_value
	* undefined reference to `gpio_request_by_name'

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/mmc/mtk-sd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c
index e668df7017..4c997977d7 100644
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -269,7 +269,7 @@ struct msdc_host {
 	bool builtin_cd;
 
 	/* card detection / write protection GPIOs */
-#ifdef CONFIG_DM_GPIO
+#if IS_ENABLED(DM_GPIO)
 	struct gpio_desc gpio_wp;
 	struct gpio_desc gpio_cd;
 #endif
@@ -849,7 +849,7 @@ static int msdc_ops_get_cd(struct udevice *dev)
 		return !(val & MSDC_PS_CDSTS);
 	}
 
-#ifdef CONFIG_DM_GPIO
+#if IS_ENABLED(DM_GPIO)
 	if (!host->gpio_cd.dev)
 		return 1;
 
@@ -863,7 +863,7 @@ static int msdc_ops_get_wp(struct udevice *dev)
 {
 	struct msdc_host *host = dev_get_priv(dev);
 
-#ifdef CONFIG_DM_GPIO
+#if IS_ENABLED(DM_GPIO)
 	if (!host->gpio_wp.dev)
 		return 0;
 
@@ -1332,7 +1332,7 @@ static int msdc_ofdata_to_platdata(struct udevice *dev)
 	if (ret < 0)
 		return ret;
 
-#ifdef CONFIG_DM_GPIO
+#if IS_ENABLED(DM_GPIO)
 	gpio_request_by_name(dev, "wp-gpios", 0, &host->gpio_wp, GPIOD_IS_IN);
 	gpio_request_by_name(dev, "cd-gpios", 0, &host->gpio_cd, GPIOD_IS_IN);
 #endif
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, 1/2] mmc: mtk-sd: fix possible incomplete read ops
  2019-01-17 17:06 [U-Boot] [PATCH 1/2] mmc: mtk-sd: fix possible incomplete read ops Fabien Parent
  2019-01-17 17:06 ` [U-Boot] [PATCH 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n Fabien Parent
@ 2019-01-27  3:52 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2019-01-27  3:52 UTC (permalink / raw
  To: u-boot

On Thu, Jan 17, 2019 at 06:06:00PM +0100, Fabien Parent wrote:

> The code is checking for incomplete read when it see the INT_XFER_COMPL
> flag, but it forget to first check whether there is anything left in the
> FIFO to copy to the RX buffer. This means that sometimes we will get
> errors because of erroneous incomplete read operation.
> 
> This commit fixes the driver re-ordering the code so that we first
> check for data inside the RX fifo and only after check the status
> of the INT_XFER_COMPL flag.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190126/d091f59b/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n
  2019-01-17 17:06 ` [U-Boot] [PATCH 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n Fabien Parent
@ 2019-01-27  3:52   ` Tom Rini
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2019-01-27  3:52 UTC (permalink / raw
  To: u-boot

On Thu, Jan 17, 2019 at 06:06:01PM +0100, Fabien Parent wrote:

> It is not possible to link the SPL image when CONFIG_GPIO is enabled
> but CONFIG_SPL_GPIO is not.  Use the IS_ENABLED macro instead to
> correctly check whether CONFIG_{SPL_}GPIO is enabled.
> 
> This commit fixes the following errors:
> 	* undefined reference to `dm_gpio_get_value
> 	* undefined reference to `gpio_request_by_name'
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190126/f8dd6922/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-27  3:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-17 17:06 [U-Boot] [PATCH 1/2] mmc: mtk-sd: fix possible incomplete read ops Fabien Parent
2019-01-17 17:06 ` [U-Boot] [PATCH 2/2] mmc: mtk-sd: fix SPL compilation when GPIO=y and SPL_GPIO=n Fabien Parent
2019-01-27  3:52   ` [U-Boot] [U-Boot, " Tom Rini
2019-01-27  3:52 ` [U-Boot] [U-Boot, 1/2] mmc: mtk-sd: fix possible incomplete read ops Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.