From: George Brooke <figgyc@figgyc.uk>
To: Tudor Ambarus <tudor.ambarus@microchip.com>
Cc: sr@denx.de, vigneshr@ti.com, jaimeliao@mxic.com.tw,
richard@nod.at, esben@geanix.com, linux@rasmusvillemoes.dk,
knaerzche@gmail.com, michael@walle.cc,
linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, macromorgan@hotmail.com,
miquel.raynal@bootlin.com, heiko.thiery@gmail.com,
zhengxunli@mxic.com.tw, p.yadav@ti.com, mail@david-bauer.net,
code@reto-schneider.ch
Subject: Re: [PATCH v4 5/6] mtd: spi-nor: Introduce Manufacturer ID collisions driver
Date: Fri, 04 Mar 2022 21:20:04 +0000 [thread overview]
Message-ID: <86o82lct0l.fsf@figgyc.uk> (raw)
In-Reply-To: <20220228134505.203270-6-tudor.ambarus@microchip.com>
Hi Tudor,
Tudor Ambarus <tudor.ambarus@microchip.com> writes:
> Some manufacturers completely ignore the manufacturer's
> identification code
> standard (JEP106) and do not define the manufacturer ID
> continuation
> scheme. This will result in manufacturer ID collisions.
>
> An an example, JEP106BA requires Boya that it's manufacturer ID
> to be
> preceded by 8 continuation codes. Boya's identification code
> must be:
> 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x68. But Boya
> ignores the
> continuation scheme and its ID collides with the manufacturer
> defined in
> bank one: Convex Computer.
>
> Introduce the manuf-id-collisions driver in order to address ID
> collisions
> between manufacturers. flash_info entries will be added in a
> first come,
> first served manner. Differentiation between flashes will be
> done at
> runtime if possible. Where runtime differentiation is not
> possible, new
> compatibles will be introduced, but this will be done as a last
> resort.
> Every new flash addition that define the SFDP tables, should
> dump its SFDP
> tables in the patch's comment section below the --- line, so
> that we can
> reference it in case of collisions.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
> drivers/mtd/spi-nor/Makefile | 1 +
> drivers/mtd/spi-nor/core.c | 3 +++
> drivers/mtd/spi-nor/core.h | 1 +
> drivers/mtd/spi-nor/manuf-id-collisions.c | 32
> +++++++++++++++++++++++
> drivers/mtd/spi-nor/sysfs.c | 2 +-
> include/linux/mtd/spi-nor.h | 6 ++++-
> 6 files changed, 43 insertions(+), 2 deletions(-)
> create mode 100644 drivers/mtd/spi-nor/manuf-id-collisions.c
>
> diff --git a/drivers/mtd/spi-nor/Makefile
> b/drivers/mtd/spi-nor/Makefile
> index 6b904e439372..48763d10daad 100644
> --- a/drivers/mtd/spi-nor/Makefile
> +++ b/drivers/mtd/spi-nor/Makefile
> @@ -1,6 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
>
> spi-nor-objs := core.o sfdp.o swp.o otp.o sysfs.o
> +spi-nor-objs += manuf-id-collisions.o
> spi-nor-objs += atmel.o
> spi-nor-objs += catalyst.o
> spi-nor-objs += eon.o
> diff --git a/drivers/mtd/spi-nor/core.c
> b/drivers/mtd/spi-nor/core.c
> index aef00151c116..80d6ce41122a 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -1610,6 +1610,7 @@ int spi_nor_sr2_bit7_quad_enable(struct
> spi_nor *nor)
> }
>
> static const struct spi_nor_manufacturer *manufacturers[] = {
> + &spi_nor_manuf_id_collisions,
> &spi_nor_atmel,
> &spi_nor_catalyst,
> &spi_nor_eon,
> @@ -3037,6 +3038,8 @@ int spi_nor_scan(struct spi_nor *nor,
> const char *name,
>
> if (!nor->name)
> nor->name = info->name;
> + if (!nor->manufacturer_name)
> + nor->manufacturer_name = nor->manufacturer->name;
>
> dev_info(dev, "%s (%lld Kbytes)\n", nor->name,
> (long long)mtd->size >> 10);
> diff --git a/drivers/mtd/spi-nor/core.h
> b/drivers/mtd/spi-nor/core.h
> index b7fd760e3b47..f727e632c0ee 100644
> --- a/drivers/mtd/spi-nor/core.h
> +++ b/drivers/mtd/spi-nor/core.h
> @@ -500,6 +500,7 @@ struct sfdp {
> };
>
> /* Manufacturer drivers. */
> +extern const struct spi_nor_manufacturer
> spi_nor_manuf_id_collisions;
> extern const struct spi_nor_manufacturer spi_nor_atmel;
> extern const struct spi_nor_manufacturer spi_nor_catalyst;
> extern const struct spi_nor_manufacturer spi_nor_eon;
> diff --git a/drivers/mtd/spi-nor/manuf-id-collisions.c
> b/drivers/mtd/spi-nor/manuf-id-collisions.c
> new file mode 100644
> index 000000000000..75c5ad6480ee
> --- /dev/null
> +++ b/drivers/mtd/spi-nor/manuf-id-collisions.c
> @@ -0,0 +1,32 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Used to handle collisions between manufacturers, where
> manufacturers are
> + * ignorant enough to not implement the ID continuation scheme
> described in the
> + * JEP106 JEDEC standard.
> + */
> +
> +#include <linux/mtd/spi-nor.h>
> +#include "core.h"
> +
> +static void boya_nor_late_init(struct spi_nor *nor)
> +{
> + nor->manufacturer_name = "boya";
> +}
> +
> +static const struct spi_nor_fixups boya_nor_fixups = {
> + .late_init = boya_nor_late_init,
> +};
> +
> +static const struct flash_info id_collision_parts[] = {
> + /* Boya */
> + { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256)
> + FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
> + NO_SFDP_FLAGS(SPI_NOR_SKIP_SFDP | SECT_4K |
> SPI_NOR_DUAL_READ |
> + SPI_NOR_QUAD_READ)
> + .fixups = &boya_nor_fixups },
> +};
> +
Finally got around to testing v4, and it looks good to me.
Sorry for the delay, I was struggling a bit with device tree
overlays because I lost my old one for this Raspberry Pi.
For v5+ I should be able to test a lot quicker if needed. Thanks
for working on this again.
Tested-by: George Brooke <figgyc@figgyc.uk>
# cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id
684018
# cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer
boya
# cat /sys/bus/spi/devices/spi0.0/spi-nor/partname
by25q128as
# xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
xxd: /sys/bus/spi/devices/spi0.0/spi-nor/sfdp: No such file or
directory
# dd bs=1M count=6 if=/dev/urandom of=./nor_test
6+0 records in
6+0 records out
6291456 bytes (6.3 MB, 6.0 MiB) copied, 0.158377 s, 39.7 MB/s
# time mtd_debug erase /dev/mtd0 0 6291456
Erased 6291456 bytes from address 0x00000000 in flash
real 1m25.420s
user 0m0.000s
sys 0m56.700s
# time mtd_debug read /dev/mtd0 0 6291456 nor_read
Copied 6291456 bytes from address 0x00000000 in flash to nor_read
real 0m2.472s
user 0m0.001s
sys 0m0.050s
# hexdump nor_read
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
*
0600000
# time mtd_debug write /dev/mtd0 0 6291456 nor_test
Copied 6291456 bytes from nor_test to address 0x00000000 in flash
real 0m14.151s
user 0m0.001s
sys 0m7.880s
# time mtd_debug read /dev/mtd0 0 6291456 nor_read
Copied 6291456 bytes from address 0x00000000 in flash to nor_read
real 0m2.580s
user 0m0.001s
sys 0m0.059s
# sha1sum nor_test nor_read
6a4ecd64a21335ade4dd8e329718df6666a8c2e8 nor_test
6a4ecd64a21335ade4dd8e329718df6666a8c2e8 nor_read
> +const struct spi_nor_manufacturer spi_nor_manuf_id_collisions =
> {
> + .parts = id_collision_parts,
> + .nparts = ARRAY_SIZE(id_collision_parts),
> +};
> diff --git a/drivers/mtd/spi-nor/sysfs.c
> b/drivers/mtd/spi-nor/sysfs.c
> index 017119768f32..fa0cf1a96797 100644
> --- a/drivers/mtd/spi-nor/sysfs.c
> +++ b/drivers/mtd/spi-nor/sysfs.c
> @@ -14,7 +14,7 @@ static ssize_t manufacturer_show(struct device
> *dev,
> struct spi_mem *spimem = spi_get_drvdata(spi);
> struct spi_nor *nor = spi_mem_get_drvdata(spimem);
>
> - return sysfs_emit(buf, "%s\n", nor->manufacturer->name);
> + return sysfs_emit(buf, "%s\n", nor->manufacturer_name);
> }
> static DEVICE_ATTR_RO(manufacturer);
>
> diff --git a/include/linux/mtd/spi-nor.h
> b/include/linux/mtd/spi-nor.h
> index 449496b57acb..3087589d01ac 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -351,7 +351,10 @@ struct spi_nor_flash_parameter;
> * @bouncebuf: bounce buffer used when the buffer passed
> by the MTD
> * layer is not DMA-able
> * @bouncebuf_size: size of the bounce buffer
> - * @name: used to point to correct name in case of ID
> collisions.
> + * @name: used to point to correct flash name in case of
> ID
> + * collisions.
> + * @manufacturer_name: used to point to correct manufacturer
> name in case of
> + * ID collisions.
> * @info: SPI NOR part JEDEC MFR ID and other info
> * @manufacturer: SPI NOR manufacturer
> * @addr_width: number of address bytes
> @@ -382,6 +385,7 @@ struct spi_nor {
> u8 *bouncebuf;
> size_t bouncebuf_size;
> const char *name;
> + const char *manufacturer_name;
> const struct flash_info *info;
> const struct spi_nor_manufacturer *manufacturer;
> u8 addr_width;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-03-04 21:24 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 13:44 [PATCH v4 0/6] mtd: spi-nor: Handle ID collisions Tudor Ambarus
2022-02-28 13:45 ` [PATCH v4 1/6] mtd: spi-nor: core: Report correct name in case of " Tudor Ambarus
2022-03-01 21:38 ` Michael Walle
2022-04-05 19:41 ` Pratyush Yadav
2022-02-28 13:45 ` [PATCH v4 2/6] mtd: spi-nor: core: Handle ID collisions between SFDP & non-SFDP flashes Tudor Ambarus
2022-03-01 21:52 ` Michael Walle
2022-03-03 14:41 ` Tudor.Ambarus
2022-03-03 14:51 ` Michael Walle
2022-03-03 15:25 ` Tudor.Ambarus
2022-03-03 15:42 ` Michael Walle
2022-03-03 16:03 ` Tudor.Ambarus
2022-03-03 16:39 ` Michael Walle
2022-02-28 13:45 ` [PATCH v4 3/6] mtd: spi-nor: macronix: Handle ID collision b/w MX25L3233F and MX25L3205D Tudor Ambarus
2022-03-01 21:57 ` Michael Walle
2022-03-03 15:28 ` Tudor.Ambarus
2022-03-03 15:33 ` Michael Walle
[not found] ` <CAEyMn7aN+wJnYkTJU_nWA9bPzF1sezA9_=E5YG5rnPBLMAmabA@mail.gmail.com>
2022-03-03 16:45 ` Michael Walle
2022-03-04 0:36 ` Tudor.Ambarus
2022-03-04 14:36 ` Michael Walle
2022-04-05 19:50 ` Pratyush Yadav
2022-02-28 13:45 ` [PATCH v4 4/6] mtd: spi-nor: macronix: Handle ID collision b/w MX25L12805D and MX25L12835F Tudor Ambarus
2022-03-01 7:55 ` Heiko Thiery
2022-03-01 8:52 ` Tudor.Ambarus
2022-03-01 9:31 ` Heiko Thiery
2022-02-28 13:45 ` [PATCH v4 5/6] mtd: spi-nor: Introduce Manufacturer ID collisions driver Tudor Ambarus
2022-03-01 22:19 ` Michael Walle
2022-03-03 16:12 ` Tudor.Ambarus
2022-03-03 21:38 ` Michael Walle
2022-03-04 7:07 ` Tudor.Ambarus
2022-03-04 14:10 ` Michael Walle
2022-03-04 21:20 ` George Brooke [this message]
2022-03-07 7:07 ` Tudor.Ambarus
2022-02-28 13:45 ` [PATCH v4 6/6] mtd: spi-nor: manuf-id-collisions: Add support for xt25f128b Tudor Ambarus
2022-03-01 22:23 ` Michael Walle
2022-03-03 21:04 ` Chris Morgan
2022-03-03 23:50 ` Tudor.Ambarus
2022-03-04 2:23 ` Chris Morgan
2022-02-28 13:55 ` [PATCH v4 0/6] mtd: spi-nor: Handle ID collisions Michael Walle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86o82lct0l.fsf@figgyc.uk \
--to=figgyc@figgyc.uk \
--cc=code@reto-schneider.ch \
--cc=esben@geanix.com \
--cc=heiko.thiery@gmail.com \
--cc=jaimeliao@mxic.com.tw \
--cc=knaerzche@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux@rasmusvillemoes.dk \
--cc=macromorgan@hotmail.com \
--cc=mail@david-bauer.net \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=p.yadav@ti.com \
--cc=richard@nod.at \
--cc=sr@denx.de \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
--cc=zhengxunli@mxic.com.tw \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).