linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] MTD: OneNAND: S5PC110: Add timeout to prevent the endless loop
@ 2010-09-27  7:25 Kyungmin Park
  2010-09-28  6:27 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Kyungmin Park @ 2010-09-27  7:25 UTC (permalink / raw)
  To: linux-mtd; +Cc: Artem.Bityutskiy, dwmw2

From: Kyungmin Park <kyungmin.park@samsung.com>

There's no case timeout but add it for some H/W problem or
wrong codes implementation

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/mtd/onenand/samsung.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index 30eccd7..afdb4c5 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -535,6 +535,7 @@ static int s5pc110_dma_ops(void *dst, void *src, size_t count, int direction)
 {
 	void __iomem *base = onenand->dma_addr;
 	int status;
+	unsigned long timeout;
 
 	writel(src, base + S5PC110_DMA_SRC_ADDR);
 	writel(dst, base + S5PC110_DMA_DST_ADDR);
@@ -552,6 +553,13 @@ static int s5pc110_dma_ops(void *dst, void *src, size_t count, int direction)
 
 	writel(S5PC110_DMA_TRANS_CMD_TR, base + S5PC110_DMA_TRANS_CMD);
 
+	/*
+	 * There's no exact timeout values at Spec.
+	 * In real case it takes under 1 msec.
+	 * So 20 msecs are enough.
+	 */
+	timeout = jiffies + msecs_to_jiffies(20);
+
 	do {
 		status = readl(base + S5PC110_DMA_TRANS_STATUS);
 		if (status & S5PC110_DMA_TRANS_STATUS_TE) {
@@ -559,7 +567,8 @@ static int s5pc110_dma_ops(void *dst, void *src, size_t count, int direction)
 					base + S5PC110_DMA_TRANS_CMD);
 			return -EIO;
 		}
-	} while (!(status & S5PC110_DMA_TRANS_STATUS_TD));
+	} while (!(status & S5PC110_DMA_TRANS_STATUS_TD) &&
+		time_before(jiffies, timeout));
 
 	writel(S5PC110_DMA_TRANS_CMD_TDC, base + S5PC110_DMA_TRANS_CMD);
 
-- 
1.5.3.3

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

* Re: [PATCH 4/4] MTD: OneNAND: S5PC110: Add timeout to prevent the endless loop
  2010-09-27  7:25 [PATCH 4/4] MTD: OneNAND: S5PC110: Add timeout to prevent the endless loop Kyungmin Park
@ 2010-09-28  6:27 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2010-09-28  6:27 UTC (permalink / raw)
  To: Kyungmin Park; +Cc: dwmw2, linux-mtd

On Mon, 2010-09-27 at 16:25 +0900, Kyungmin Park wrote:
> From: Kyungmin Park <kyungmin.park@samsung.com>
> 
> There's no case timeout but add it for some H/W problem or
> wrong codes implementation
> 
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

I've pushed this patch to l2-mtd-2.6.git, but did not push patches 1-3.
Please, re-send them against the l2 tree.

Also, please note that we use "mtd:" prefix for the MTD patches, not
"MTD:".

Thanks!

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

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

end of thread, other threads:[~2010-09-28  6:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27  7:25 [PATCH 4/4] MTD: OneNAND: S5PC110: Add timeout to prevent the endless loop Kyungmin Park
2010-09-28  6:27 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).