Skip to contentSkip to conversation

mtd: nand: allow NAND_NO_SUBPAGE_WRITE to be set from driver

PATCH Applied Brian Norris 6 participants 12 messages Jul 13, 2012 – Aug 17, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: allow NAND_NO_SUBPAGE_WRITE to be set from driver

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

---
Huang, please test this with your driver.

Artem,

If this is acceptable, should it go to -stable, since it fixes some major gpmi-nand breakage? It probably won't apply directly, since I've touched some code around it recently.

 drivers/mtd/nand/nand_base.c | 7 ++-----
 include/linux/mtd/nand.h     | 3 ---
 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/mtd/nand/nand_base.c +2 -5
index 98ba46e..6652d1f 100644
@@ -2909,8 +2909,6 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
 	if (le16_to_cpu(p->features) & 1)
 		*busw = NAND_BUSWIDTH_16;
 
-	chip->options &= ~NAND_CHIPOPTIONS_MSK;
-
 	pr_info("ONFI flash detected\n");
 	return 1;
 }
@@ -3074,9 +3072,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 			mtd->erasesize <<= ((id_data[3] & 0x03) << 1);
 		}
 	}
-	/* Get chip options, preserve non chip based options */
-	chip->options &= ~NAND_CHIPOPTIONS_MSK;
-	chip->options |= type->options & NAND_CHIPOPTIONS_MSK;
+	/* Get chip options */
+	chip->options |= type->options;
 
 	/*
 	 * Check if chip is not a Samsung device. Do not clear the
include/linux/mtd/nand.h +0 -3
index 6dce5a7..eeb7015 100644
@@ -206,9 +206,6 @@ typedef enum {
 #define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
 					&& (chip->page_shift > 9))
 
-/* Mask to zero out the chip options, which come from the id table */
-#define NAND_CHIPOPTIONS_MSK	0x0000ffff
-
 /* Non chip related options */
 /* This option skips the bbt scan during initialization. */
 #define NAND_SKIP_BBTSCAN	0x00010000
Signature · 1 line
1.7.11.1
#1 lore raw

Dear Brian Norris,

Quoted 5 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Quoted 8 lines

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Best regards,
Marek Vasut

#2 lore raw
Quoted 12 lines · Marek Vasut

Dear Brian Norris,

Quoted 10 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Quoted 7 lines
Quoted 3 lines
Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Isn't that what we're trying to get rid of?

-Scott

#3 lore raw
Quoted 14 lines · Scott Wood
Quoted 13 lines · Marek Vasut
Quoted 13 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>
Quoted 6 lines
Quoted 4 lines

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Isn't that what we're trying to get rid of?

I thought so.

Brian

#4 lore raw

Dear Brian Norris,

Quoted 17 lines · Scott Wood
Quoted 16 lines · Marek Vasut
Quoted 15 lines
Quoted 14 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Isn't that what we're trying to get rid of?

Sure, but aren't there controller specific properties and chip-specific properties? And than even chip-specific state?

Quoted 3 lines

I thought so.

Brian

Best regards,
Marek Vasut

#5 lore raw
Quoted 21 lines · Marek Vasut

Dear Brian Norris,

Quoted 19 lines · Scott Wood
Quoted 18 lines · Marek Vasut
Quoted 17 lines
Quoted 14 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

[...]

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Isn't that what we're trying to get rid of?

Sure, but aren't there controller specific properties and chip-specific properties?

Yes, but there are some properties than can be specified by either one.
If you're proposing three sets of options (chip, controller, or both),
or duplicating certain options between the sets and then checking both everywhere, I don't see how that's an improvement.

Quoted 1 line

And than even chip-specific state?

Not sure what you mean here.

-Scott

#6 lore raw

Dear Scott Wood,

Quoted 4 lines · Marek Vasut
Quoted 3 lines

Dear Brian Norris,

Quoted 1 line

On Fri, Jul 13, 2012 at 10:19 AM, Scott Wood <[email protected]>

Quoted 23 lines · wrote:
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines · Marek Vasut
Quoted 11 lines
Quoted 11 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Quoted 8 lines
Quoted 3 lines
Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Isn't that what we're trying to get rid of?

Quoted 7 lines
Quoted 2 lines

Sure, but aren't there controller specific properties and chip-specific properties?

Yes, but there are some properties than can be specified by either one.
If you're proposing three sets of options (chip, controller, or both),
or duplicating certain options between the sets and then checking both everywhere, I don't see how that's an improvement.

Ok, you're right here, screw that and let's do a single set ;-)

Quoted 5 lines
Quoted 1 line

And than even chip-specific state?

Not sure what you mean here.

-Scott

Best regards,
Marek Vasut

#7 lore raw

Re: [PATCH] mtd: nand: allow NAND_NO_SUBPAGE_WRITE to be set from driver (REPORT SPAM)

In reply to Scott Wood

Em 13-07-2012 14:19, Scott Wood escreveu:

Quoted 29 lines · Marek Vasut
Quoted 12 lines

Dear Brian Norris,

Quoted 10 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Quoted 7 lines
Quoted 3 lines
Cc Huang Shijie<[email protected]>
Cc Marek Vasut<[email protected]>

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Isn't that what we're trying to get rid of?

-Scott

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#8 lore raw

Re: [PATCH] mtd: nand: allow NAND_NO_SUBPAGE_WRITE to be set from driver (REPORT SPAM)

In reply to Marek Vasut

Em 13-07-2012 14:12, Marek Vasut escreveu:

Quoted 28 lines

Dear Brian Norris,

Quoted 5 lines

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Quoted 8 lines

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Cc Huang Shijie<[email protected]>
Cc Marek Vasut<[email protected]>

[...]

Maybe we should simply split it into two sets of flags to make it clear -- chip ones and controller ones ?

Best regards,
Marek Vasut

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
.

Tested-by on v1 1/1
#9 lore raw
In reply to Brian Norris
Quoted 10 lines · Brian Norris

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Quoted 6 lines
Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

---
Huang, please test this with your driver.

I tested this patch on imx6q-arm2 board with Micron MT29F32G08QAA. it works fine, thanks.

Quoted 52 lines

Artem,

If this is acceptable, should it go to -stable, since it fixes some major gpmi-nand breakage? It probably won't apply directly, since I've touched some code around it recently.

 drivers/mtd/nand/nand_base.c | 7 ++-----
 include/linux/mtd/nand.h     | 3 ---
 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/mtd/nand/nand_base.c +2 -5
index 98ba46e..6652d1f 100644
@@ -2909,8 +2909,6 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
        if (le16_to_cpu(p->features) & 1)
                *busw = NAND_BUSWIDTH_16;
 
-       chip->options &= ~NAND_CHIPOPTIONS_MSK;
-
        pr_info("ONFI flash detected\n");
        return 1;
 }
@@ -3074,9 +3072,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
                        mtd->erasesize <<= ((id_data[3] & 0x03) << 1);
                }
        }
-       /* Get chip options, preserve non chip based options */
-       chip->options &= ~NAND_CHIPOPTIONS_MSK;
-       chip->options |= type->options & NAND_CHIPOPTIONS_MSK;
+       /* Get chip options */
+       chip->options |= type->options;
 
        /*
         * Check if chip is not a Samsung device. Do not clear the
include/linux/mtd/nand.h +0 -4
index 6dce5a7..eeb7015 100644
@@ -206,9 +206,6 @@ typedef enum {
 #define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
                                        && (chip->page_shift > 9))
 
-/* Mask to zero out the chip options, which come from the id table */
-#define NAND_CHIPOPTIONS_MSK   0x0000ffff
-
 /* Non chip related options */
 /* This option skips the bbt scan during initialization. */
 #define NAND_SKIP_BBTSCAN      0x00010000
--

1.7.11.1

#10 lore raw

Bump.

Quoted 18 lines · Huang Shijie
Quoted 10 lines · Brian Norris

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Quoted 6 lines
Cc Huang Shijie <[email protected]>
Cc Marek Vasut <[email protected]>

---
Huang, please test this with your driver.

Quoted 4 lines

I tested this patch on imx6q-arm2 board with Micron MT29F32G08QAA. it works fine, thanks.

Any other Acks? Or acceptance from Artem/David?

Brian

#11 lore raw
In reply to Brian Norris
Quoted 11 lines · Brian Norris

The NAND_CHIPOPTIONS_MSK has limited utility and is causing real bugs. It silently masks off at least one flag that might be set by the driver (NAND_NO_SUBPAGE_WRITE). This breaks the GPMI NAND driver and possibly others.

Really, as long as driver writers exercise a small amount of care with NAND_* options, this mask is not necessary at all; it was only here to prevent certain options from accidentally being set by the driver. But the original thought turns out to be a bad idea occasionally. Thus, kill it.

Pushed to l2-mtd.git, thanks.

Quoted 3 lines

If this is acceptable, should it go to -stable, since it fixes some major gpmi-nand breakage? It probably won't apply directly, since I've touched some code around it recently.

Done.

Signature · 2 lines
Best Regards,
Artem Bityutskiy