All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset
@ 2018-11-28  5:27 Masahiro Yamada
  2018-11-28  5:27 ` [PATCH v2 1/2] mtd: rawnand: denali: remove ->dev_ready() hook Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Masahiro Yamada @ 2018-11-28  5:27 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Miquel Raynal
  Cc: Masahiro Yamada, linux-kernel, Marek Vasut, Brian Norris,
	Richard Weinberger, David Woodhouse

I sent this series on September,
and Miquel replied this series was applied:
http://patchwork.ozlabs.org/patch/967242/

But, It turned out not applied.

I rebased it and resending now.


Masahiro Yamada (2):
  mtd: rawnand: denali: remove ->dev_ready() hook
  mtd: rawnand: denali: remove denali_reset_banks()

 drivers/mtd/nand/raw/denali.c | 52 +------------------------------------------
 1 file changed, 1 insertion(+), 51 deletions(-)

-- 
2.7.4

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

* [PATCH v2 1/2] mtd: rawnand: denali: remove ->dev_ready() hook
  2018-11-28  5:27 [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Masahiro Yamada
@ 2018-11-28  5:27 ` Masahiro Yamada
  2018-11-28  5:27 ` [PATCH v2 2/2] mtd: rawnand: denali: remove denali_reset_banks() Masahiro Yamada
  2018-12-07  7:46 ` [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Miquel Raynal
  2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2018-11-28  5:27 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Miquel Raynal
  Cc: Masahiro Yamada, linux-kernel, Marek Vasut, Brian Norris,
	Richard Weinberger, David Woodhouse

The Denali NAND IP has no way to read out the current signal level
of the R/B# pin. Instead, denali_dev_ready() checks if the R/B#
transition has already happened. (The INTR__INT_ACT interrupt is
asserted at the rising edge of the R/B# pin.) It is not a correct
way to implement the ->dev_ready() hook.

In fact, it has a drawback; in the nand_scan_ident phase, the chip
detection iterates over maxchips until it fails to find a homogeneous
chip. For the last loop, nand_reset() fails if no chip is there.

If ->dev_ready hook exists, nand_command(_lp) calls nand_wait_ready()
after NAND_CMD_RESET. However, we know denali_dev_ready() never
returns 1 unless there exists a chip that toggles R/B# in that chip
select. Then, nand_wait_ready() just ends up with wasting 400 msec,
in the end, shows the "timeout while waiting for chip to become ready"
warning.

Let's remove the mis-implemented dev_ready hook, and fallback to
sending the NAND_CMD_STATUS and nand_wait_status_ready(), which
bails out more quickly.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v2:
  - Rebase

 drivers/mtd/nand/raw/denali.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index 830ea24..ead6e60 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -204,18 +204,6 @@ static uint32_t denali_wait_for_irq(struct denali_nand_info *denali,
 	return denali->irq_status;
 }
 
-static uint32_t denali_check_irq(struct denali_nand_info *denali)
-{
-	unsigned long flags;
-	uint32_t irq_status;
-
-	spin_lock_irqsave(&denali->irq_lock, flags);
-	irq_status = denali->irq_status;
-	spin_unlock_irqrestore(&denali->irq_lock, flags);
-
-	return irq_status;
-}
-
 static void denali_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
 {
 	struct mtd_info *mtd = nand_to_mtd(chip);
@@ -288,8 +276,7 @@ static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl)
 		return;
 
 	/*
-	 * Some commands are followed by chip->legacy.dev_ready or
-	 * chip->legacy.waitfunc.
+	 * Some commands are followed by chip->legacy.waitfunc.
 	 * irq_status must be cleared here to catch the R/B# interrupt later.
 	 */
 	if (ctrl & NAND_CTRL_CHANGE)
@@ -298,13 +285,6 @@ static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl)
 	denali->host_write(denali, DENALI_BANK(denali) | type, dat);
 }
 
-static int denali_dev_ready(struct nand_chip *chip)
-{
-	struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip));
-
-	return !!(denali_check_irq(denali) & INTR__INT_ACT);
-}
-
 static int denali_check_erased_page(struct mtd_info *mtd,
 				    struct nand_chip *chip, uint8_t *buf,
 				    unsigned long uncor_ecc_flags,
@@ -1359,7 +1339,6 @@ int denali_init(struct denali_nand_info *denali)
 	chip->legacy.read_byte = denali_read_byte;
 	chip->legacy.write_byte = denali_write_byte;
 	chip->legacy.cmd_ctrl = denali_cmd_ctrl;
-	chip->legacy.dev_ready = denali_dev_ready;
 	chip->legacy.waitfunc = denali_waitfunc;
 
 	if (features & FEATURES__INDEX_ADDR) {
-- 
2.7.4

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

* [PATCH v2 2/2] mtd: rawnand: denali: remove denali_reset_banks()
  2018-11-28  5:27 [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Masahiro Yamada
  2018-11-28  5:27 ` [PATCH v2 1/2] mtd: rawnand: denali: remove ->dev_ready() hook Masahiro Yamada
@ 2018-11-28  5:27 ` Masahiro Yamada
  2018-12-07  7:46 ` [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Miquel Raynal
  2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2018-11-28  5:27 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Miquel Raynal
  Cc: Masahiro Yamada, linux-kernel, Marek Vasut, Brian Norris,
	Richard Weinberger, David Woodhouse

In nand_scan_ident(), the controller driver resets every NAND chip.
This is done by sending NAND_CMD_RESET. The Denali IP provides
another way to do the equivalent thing; if a bit is set in the
DEVICE_RESET register, the controller sends the RESET command to
the corresponding device. denali_reset_banks() uses it to reset
all devices beforehand.

This redundant reset sequence was needed to know the actual number
of chips before calling nand_scan_ident(); if DEVICE_RESET fails,
there is no chip in that chip select. Then, denali_reset_banks()
sets denali->max_banks to the number of detected chips.

As commit f486287d2372 ("mtd: nand: denali: fix bank reset function
to detect the number of chips") explained, nand_scan_ident() issued
Set Features (0xEF) command to all CS lines, some of which may not be
connected with a chip. Then, the driver would wait for R/B# response,
which never happens.

This problem was solved by commit 107b7d6a7ad4 ("mtd: rawnand: avoid
setting again the timings to mode 0 after a reset"). In the current
code, nand_setup_data_interface() is called from nand_scan_tail(),
which is invoked after the chip detection.

Now, we can really remove the redundant denali_nand_banks() by simply
passing the maximum number of chip selects supported by this IP
(typically 4 or 8) to nand_scan(). Let's leave all the chip detection
process to nand_scan_ident().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v2: None

 drivers/mtd/nand/raw/denali.c | 29 -----------------------------
 1 file changed, 29 deletions(-)

diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index ead6e60..2302010 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -1045,29 +1045,6 @@ static int denali_setup_data_interface(struct nand_chip *chip, int chipnr,
 	return 0;
 }
 
-static void denali_reset_banks(struct denali_nand_info *denali)
-{
-	u32 irq_status;
-	int i;
-
-	for (i = 0; i < denali->max_banks; i++) {
-		denali->active_bank = i;
-
-		denali_reset_irq(denali);
-
-		iowrite32(DEVICE_RESET__BANK(i),
-			  denali->reg + DEVICE_RESET);
-
-		irq_status = denali_wait_for_irq(denali,
-			INTR__RST_COMP | INTR__INT_ACT | INTR__TIME_OUT);
-		if (!(irq_status & INTR__INT_ACT))
-			break;
-	}
-
-	dev_dbg(denali->dev, "%d chips connected\n", i);
-	denali->max_banks = i;
-}
-
 static void denali_hw_init(struct denali_nand_info *denali)
 {
 	/*
@@ -1321,12 +1298,6 @@ int denali_init(struct denali_nand_info *denali)
 	}
 
 	denali_enable_irq(denali);
-	denali_reset_banks(denali);
-	if (!denali->max_banks) {
-		/* Error out earlier if no chip is found for some reasons. */
-		ret = -ENODEV;
-		goto disable_irq;
-	}
 
 	denali->active_bank = DENALI_INVALID_BANK;
 
-- 
2.7.4

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

* Re: [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset
  2018-11-28  5:27 [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Masahiro Yamada
  2018-11-28  5:27 ` [PATCH v2 1/2] mtd: rawnand: denali: remove ->dev_ready() hook Masahiro Yamada
  2018-11-28  5:27 ` [PATCH v2 2/2] mtd: rawnand: denali: remove denali_reset_banks() Masahiro Yamada
@ 2018-12-07  7:46 ` Miquel Raynal
  2 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2018-12-07  7:46 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mtd, Boris Brezillon, linux-kernel, Marek Vasut,
	Brian Norris, Richard Weinberger, David Woodhouse

Hi Masahiro,

Masahiro Yamada <yamada.masahiro@socionext.com> wrote on Wed, 28 Nov
2018 14:27:35 +0900:

> I sent this series on September,
> and Miquel replied this series was applied:
> http://patchwork.ozlabs.org/patch/967242/
> 
> But, It turned out not applied.
> 
> I rebased it and resending now.
> 
> 
> Masahiro Yamada (2):
>   mtd: rawnand: denali: remove ->dev_ready() hook
>   mtd: rawnand: denali: remove denali_reset_banks()
> 
>  drivers/mtd/nand/raw/denali.c | 52 +------------------------------------------
>  1 file changed, 1 insertion(+), 51 deletions(-)
> 

I don't know how I missed those. Sorry for that, they are now applied
on nand/next.


Thanks,
Miquèl

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

end of thread, other threads:[~2018-12-07  7:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-28  5:27 [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Masahiro Yamada
2018-11-28  5:27 ` [PATCH v2 1/2] mtd: rawnand: denali: remove ->dev_ready() hook Masahiro Yamada
2018-11-28  5:27 ` [PATCH v2 2/2] mtd: rawnand: denali: remove denali_reset_banks() Masahiro Yamada
2018-12-07  7:46 ` [PATCH v2 0/2] mtd: rawnand: denali: clean-up unnecessary hook and device reset Miquel Raynal

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.