mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] nand: denali: use correct interrupts in read_page
@ 2016-09-22 14:46 Steffen Trumtrar
  2016-09-22 14:46 ` [PATCH 2/3] nand: denali: use is_timeout in while loop Steffen Trumtrar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 14:46 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

The interrupt mask is incorrect in case of HW error correction.
The driver will time out waiting for the wrong interrupts.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/mtd/nand/nand_denali.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_denali.c b/drivers/mtd/nand/nand_denali.c
index bf9a05d85264..ceb5a8b87e42 100644
--- a/drivers/mtd/nand/nand_denali.c
+++ b/drivers/mtd/nand/nand_denali.c
@@ -1102,8 +1102,9 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 	size_t size = denali->mtd.writesize + denali->mtd.oobsize;
 
 	uint32_t irq_status;
-	uint32_t irq_mask = INTR_STATUS__ECC_TRANSACTION_DONE |
-			    INTR_STATUS__ECC_ERR;
+	uint32_t irq_mask = denali->have_hw_ecc_fixup ?
+		(INTR_STATUS__DMA_CMD_COMP) :
+		(INTR_STATUS__ECC_TRANSACTION_DONE | INTR_STATUS__ECC_ERR);
 	bool check_erased_page = false;
 
 	if (page != denali->page) {
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] nand: denali: use is_timeout in while loop
  2016-09-22 14:46 [PATCH 1/3] nand: denali: use correct interrupts in read_page Steffen Trumtrar
@ 2016-09-22 14:46 ` Steffen Trumtrar
  2016-09-22 14:46 ` [PATCH 3/3] nand: denali: get rid of compile-time debug information Steffen Trumtrar
  2016-09-26  6:03 ` [PATCH 1/3] nand: denali: use correct interrupts in read_page Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 14:46 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Instead of using udelay and a countdown, use the is_timeout function.
Also, move the code closer to the kernel version, i.e. check for the
correct bank and clean the interrupt status.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/mtd/nand/nand_denali.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/nand_denali.c b/drivers/mtd/nand/nand_denali.c
index ceb5a8b87e42..6a6c0e462514 100644
--- a/drivers/mtd/nand/nand_denali.c
+++ b/drivers/mtd/nand/nand_denali.c
@@ -25,6 +25,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <io.h>
+#include <clock.h>
 #include <of_mtd.h>
 #include <errno.h>
 #include <asm/io.h>
@@ -633,26 +634,32 @@ static uint32_t read_interrupt_status(struct denali_nand_info *denali)
 
 static uint32_t wait_for_irq(struct denali_nand_info *denali, uint32_t irq_mask)
 {
-	unsigned long comp_res = 1000;
 	uint32_t intr_status = 0;
+	uint64_t start;
 
-	do {
+	if (!is_flash_bank_valid(denali->flash_bank)) {
+		dev_dbg(denali->dev, "No valid chip selected (%d)\n",
+			denali->flash_bank);
+		return 0;
+	}
+
+	start = get_time_ns();
+
+	while (!is_timeout(start, 1000 * MSECOND)) {
 		intr_status = read_interrupt_status(denali);
-		if (intr_status & irq_mask) {
-			/* our interrupt was detected */
-			break;
-		}
-		udelay(1);
-		comp_res--;
-	} while (comp_res != 0);
-
-	if (comp_res == 0) {
-		/* timeout */
-		intr_status = 0;
-		dev_dbg(denali->dev, "timeout occurred, status = 0x%x, mask = 0x%x\n",
-				intr_status, irq_mask);
+
+		if (intr_status != 0)
+			clear_interrupt(denali, intr_status);
+
+		if (intr_status & irq_mask)
+			return intr_status;
 	}
-	return intr_status;
+
+	/* timeout */
+	dev_dbg(denali->dev, "timeout occurred, status = 0x%x, mask = 0x%x\n",
+		intr_status, irq_mask);
+
+	return 0;
 }
 
 /*
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] nand: denali: get rid of compile-time debug information
  2016-09-22 14:46 [PATCH 1/3] nand: denali: use correct interrupts in read_page Steffen Trumtrar
  2016-09-22 14:46 ` [PATCH 2/3] nand: denali: use is_timeout in while loop Steffen Trumtrar
@ 2016-09-22 14:46 ` Steffen Trumtrar
  2016-09-26  6:03 ` [PATCH 1/3] nand: denali: use correct interrupts in read_page Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2016-09-22 14:46 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Remove dev_dbgs containing __FILE__ and __LINE__ and no other
interesting debug informations.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/mtd/nand/nand_denali.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/mtd/nand/nand_denali.c b/drivers/mtd/nand/nand_denali.c
index 6a6c0e462514..8b09b3722fd9 100644
--- a/drivers/mtd/nand/nand_denali.c
+++ b/drivers/mtd/nand/nand_denali.c
@@ -174,9 +174,6 @@ static uint16_t denali_nand_reset(struct denali_nand_info *denali)
 {
 	int i;
 
-	dev_dbg(denali->dev, "%s, Line %d, Function: %s\n",
-		__FILE__, __LINE__, __func__);
-
 	for (i = 0; i < denali->max_banks; i++)
 		iowrite32(INTR_STATUS__RST_COMP | INTR_STATUS__TIME_OUT,
 		denali->flash_reg + INTR_STATUS(i));
@@ -227,9 +224,6 @@ static void nand_onfi_timing_set(struct denali_nand_info *denali,
 	uint16_t acc_clks;
 	uint16_t addr_2_data, re_2_we, re_2_re, we_2_re, cs_cnt;
 
-	dev_dbg(denali->dev, "%s, Line %d, Function: %s\n",
-		__FILE__, __LINE__, __func__);
-
 	en_lo = CEIL_DIV(Trp[mode], CLK_X);
 	en_hi = CEIL_DIV(Treh[mode], CLK_X);
 #if ONFI_BLOOM_TIME
@@ -492,9 +486,6 @@ static uint16_t denali_nand_timing_set(struct denali_nand_info *denali)
 	uint8_t maf_id, device_id;
 	int i;
 
-	dev_dbg(denali->dev, "%s, Line %d, Function: %s\n",
-			__FILE__, __LINE__, __func__);
-
 	/*
 	 * Use read id method to get device ID and other params.
 	 * For some NAND chips, controller can't report the correct
@@ -551,9 +542,6 @@ static uint16_t denali_nand_timing_set(struct denali_nand_info *denali)
 static void denali_set_intr_modes(struct denali_nand_info *denali,
 					uint16_t INT_ENABLE)
 {
-	dev_dbg(denali->dev, "%s, Line %d, Function: %s\n",
-		__FILE__, __LINE__, __func__);
-
 	if (INT_ENABLE)
 		iowrite32(1, denali->flash_reg + GLOBAL_INT_ENABLE);
 	else
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/3] nand: denali: use correct interrupts in read_page
  2016-09-22 14:46 [PATCH 1/3] nand: denali: use correct interrupts in read_page Steffen Trumtrar
  2016-09-22 14:46 ` [PATCH 2/3] nand: denali: use is_timeout in while loop Steffen Trumtrar
  2016-09-22 14:46 ` [PATCH 3/3] nand: denali: get rid of compile-time debug information Steffen Trumtrar
@ 2016-09-26  6:03 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2016-09-26  6:03 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

On Thu, Sep 22, 2016 at 04:46:37PM +0200, Steffen Trumtrar wrote:
> The interrupt mask is incorrect in case of HW error correction.
> The driver will time out waiting for the wrong interrupts.
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  drivers/mtd/nand/nand_denali.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/mtd/nand/nand_denali.c b/drivers/mtd/nand/nand_denali.c
> index bf9a05d85264..ceb5a8b87e42 100644
> --- a/drivers/mtd/nand/nand_denali.c
> +++ b/drivers/mtd/nand/nand_denali.c
> @@ -1102,8 +1102,9 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
>  	size_t size = denali->mtd.writesize + denali->mtd.oobsize;
>  
>  	uint32_t irq_status;
> -	uint32_t irq_mask = INTR_STATUS__ECC_TRANSACTION_DONE |
> -			    INTR_STATUS__ECC_ERR;
> +	uint32_t irq_mask = denali->have_hw_ecc_fixup ?
> +		(INTR_STATUS__DMA_CMD_COMP) :
> +		(INTR_STATUS__ECC_TRANSACTION_DONE | INTR_STATUS__ECC_ERR);
>  	bool check_erased_page = false;
>  
>  	if (page != denali->page) {
> -- 
> 2.9.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2016-09-26  6:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 14:46 [PATCH 1/3] nand: denali: use correct interrupts in read_page Steffen Trumtrar
2016-09-22 14:46 ` [PATCH 2/3] nand: denali: use is_timeout in while loop Steffen Trumtrar
2016-09-22 14:46 ` [PATCH 3/3] nand: denali: get rid of compile-time debug information Steffen Trumtrar
2016-09-26  6:03 ` [PATCH 1/3] nand: denali: use correct interrupts in read_page Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox