* [PATCH] mtd: rawnand: initialize ntargets with maxchips
@ 2019-05-21 8:17 Sascha Hauer
2019-05-21 8:28 ` Schrempf Frieder
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2019-05-21 8:17 UTC (permalink / raw)
To: linux-mtd
Cc: Richard Weinberger, Sascha Hauer, Miquel Raynal, kernel,
Boris Brezillon
memorg->ntargets is initialized with '1'. It should be initialized with
the maxchips argument from nand_scan() instead. Otherwise multi chip
support errors out on the secondary chip selects when trying to call
nand_reset() on them:
WARNING: CPU: 0 PID: 1 at drivers/mtd/nand/raw/internals.h:114
nand_reset_op+0x194/0x1c4
With this memorg->ntargets is initialized with the maximum number of
chip selects supported by the driver. After having detected the number
of actually connected chips memory->ntargets is updated with that
number.
Fixes: 2813e288414 ("mtd: rawnand: Get rid of chip->numchips")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/nand/raw/nand_base.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 7db0f04cf52b..0c717f3fb906 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4621,7 +4621,8 @@ nand_manufacturer_name(const struct nand_manufacturer *manufacturer)
/*
* Get the flash and manufacturer id and lookup if the type is supported.
*/
-static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
+static int nand_detect(struct nand_chip *chip, unsigned int maxchips,
+ struct nand_flash_dev *type)
{
const struct nand_manufacturer *manufacturer;
struct mtd_info *mtd = nand_to_mtd(chip);
@@ -4638,7 +4639,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
memorg = nanddev_get_memorg(&chip->base);
memorg->planes_per_lun = 1;
memorg->luns_per_target = 1;
- memorg->ntargets = 1;
+ memorg->ntargets = maxchips;
/*
* Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
@@ -5004,7 +5005,7 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
return ret;
/* Read the flash type */
- ret = nand_detect(chip, table);
+ ret = nand_detect(chip, maxchips, table);
if (ret) {
if (!(chip->options & NAND_SCAN_SILENT_NODEV))
pr_warn("No NAND device found\n");
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: rawnand: initialize ntargets with maxchips
2019-05-21 8:17 [PATCH] mtd: rawnand: initialize ntargets with maxchips Sascha Hauer
@ 2019-05-21 8:28 ` Schrempf Frieder
2019-05-21 8:29 ` Boris Brezillon
2019-05-21 8:33 ` Miquel Raynal
2 siblings, 0 replies; 4+ messages in thread
From: Schrempf Frieder @ 2019-05-21 8:28 UTC (permalink / raw)
To: Sascha Hauer, linux-mtd@lists.infradead.org
Cc: Richard Weinberger, Boris Brezillon, kernel@pengutronix.de,
Miquel Raynal
On 21.05.19 10:17, Sascha Hauer wrote:
> memorg->ntargets is initialized with '1'. It should be initialized with
> the maxchips argument from nand_scan() instead. Otherwise multi chip
> support errors out on the secondary chip selects when trying to call
> nand_reset() on them:
>
> WARNING: CPU: 0 PID: 1 at drivers/mtd/nand/raw/internals.h:114
> nand_reset_op+0x194/0x1c4
>
> With this memorg->ntargets is initialized with the maximum number of
> chip selects supported by the driver. After having detected the number
> of actually connected chips memory->ntargets is updated with that
> number.
>
> Fixes: 2813e288414 ("mtd: rawnand: Get rid of chip->numchips")
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Thanks for reporting/fixing this.
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> ---
> drivers/mtd/nand/raw/nand_base.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 7db0f04cf52b..0c717f3fb906 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -4621,7 +4621,8 @@ nand_manufacturer_name(const struct nand_manufacturer *manufacturer)
> /*
> * Get the flash and manufacturer id and lookup if the type is supported.
> */
> -static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
> +static int nand_detect(struct nand_chip *chip, unsigned int maxchips,
> + struct nand_flash_dev *type)
> {
> const struct nand_manufacturer *manufacturer;
> struct mtd_info *mtd = nand_to_mtd(chip);
> @@ -4638,7 +4639,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
> memorg = nanddev_get_memorg(&chip->base);
> memorg->planes_per_lun = 1;
> memorg->luns_per_target = 1;
> - memorg->ntargets = 1;
> + memorg->ntargets = maxchips;
>
> /*
> * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
> @@ -5004,7 +5005,7 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
> return ret;
>
> /* Read the flash type */
> - ret = nand_detect(chip, table);
> + ret = nand_detect(chip, maxchips, table);
> if (ret) {
> if (!(chip->options & NAND_SCAN_SILENT_NODEV))
> pr_warn("No NAND device found\n");
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: rawnand: initialize ntargets with maxchips
2019-05-21 8:17 [PATCH] mtd: rawnand: initialize ntargets with maxchips Sascha Hauer
2019-05-21 8:28 ` Schrempf Frieder
@ 2019-05-21 8:29 ` Boris Brezillon
2019-05-21 8:33 ` Miquel Raynal
2 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2019-05-21 8:29 UTC (permalink / raw)
To: Sascha Hauer
Cc: Richard Weinberger, Miquel Raynal, linux-mtd, kernel,
Boris Brezillon
On Tue, 21 May 2019 10:17:21 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:
> memorg->ntargets is initialized with '1'. It should be initialized with
> the maxchips argument from nand_scan() instead. Otherwise multi chip
> support errors out on the secondary chip selects when trying to call
> nand_reset() on them:
>
> WARNING: CPU: 0 PID: 1 at drivers/mtd/nand/raw/internals.h:114
> nand_reset_op+0x194/0x1c4
>
> With this memorg->ntargets is initialized with the maximum number of
> chip selects supported by the driver. After having detected the number
> of actually connected chips memory->ntargets is updated with that
> number.
>
> Fixes: 2813e288414 ("mtd: rawnand: Get rid of chip->numchips")
>
You an get rid of this blank line.
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/mtd/nand/raw/nand_base.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 7db0f04cf52b..0c717f3fb906 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -4621,7 +4621,8 @@ nand_manufacturer_name(const struct nand_manufacturer *manufacturer)
> /*
> * Get the flash and manufacturer id and lookup if the type is supported.
> */
> -static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
> +static int nand_detect(struct nand_chip *chip, unsigned int maxchips,
> + struct nand_flash_dev *type)
> {
> const struct nand_manufacturer *manufacturer;
> struct mtd_info *mtd = nand_to_mtd(chip);
> @@ -4638,7 +4639,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
> memorg = nanddev_get_memorg(&chip->base);
> memorg->planes_per_lun = 1;
> memorg->luns_per_target = 1;
> - memorg->ntargets = 1;
> + memorg->ntargets = maxchips;
I'd rather move this initialization to nand_scan_ident() as I don't like
the idea of passing maxchips to nand_detect(), but if you want to
keep it like that, can we at least rename the argument num_cs.
>
> /*
> * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
> @@ -5004,7 +5005,7 @@ static int nand_scan_ident(struct nand_chip *chip, unsigned int maxchips,
> return ret;
>
> /* Read the flash type */
> - ret = nand_detect(chip, table);
> + ret = nand_detect(chip, maxchips, table);
> if (ret) {
> if (!(chip->options & NAND_SCAN_SILENT_NODEV))
> pr_warn("No NAND device found\n");
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: rawnand: initialize ntargets with maxchips
2019-05-21 8:17 [PATCH] mtd: rawnand: initialize ntargets with maxchips Sascha Hauer
2019-05-21 8:28 ` Schrempf Frieder
2019-05-21 8:29 ` Boris Brezillon
@ 2019-05-21 8:33 ` Miquel Raynal
2 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2019-05-21 8:33 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Richard Weinberger, linux-mtd, kernel, Boris Brezillon
Hi Sascha,
Sascha Hauer <s.hauer@pengutronix.de> wrote on Tue, 21 May 2019
10:17:21 +0200:
> memorg->ntargets is initialized with '1'. It should be initialized with
> the maxchips argument from nand_scan() instead. Otherwise multi chip
> support errors out on the secondary chip selects when trying to call
> nand_reset() on them:
>
> WARNING: CPU: 0 PID: 1 at drivers/mtd/nand/raw/internals.h:114
> nand_reset_op+0x194/0x1c4
>
> With this memorg->ntargets is initialized with the maximum number of
> chip selects supported by the driver. After having detected the number
> of actually connected chips memory->ntargets is updated with that
> number.
>
> Fixes: 2813e288414 ("mtd: rawnand: Get rid of chip->numchips")
>
My Git history does not know this commit, are you sure it's not
32813e288414 instead?
This commit will go through the fixes branch.
Thanks!
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-21 8:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-21 8:17 [PATCH] mtd: rawnand: initialize ntargets with maxchips Sascha Hauer
2019-05-21 8:28 ` Schrempf Frieder
2019-05-21 8:29 ` Boris Brezillon
2019-05-21 8:33 ` Miquel Raynal
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).