public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Jagan Teki <jagan@amarulasolutions.com>, Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de,
	"Patrick Delaunay" <patrick.delaunay@st.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Patrice Chotard" <patrice.chotard@foss.st.com>,
	"Marek Vasut" <marex@denx.de>, "Pratyush Yadav" <p.yadav@ti.com>,
	"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-spi v3 00/10] Fix `mtd erase` when used with mtdpart
Date: Tue,  5 Oct 2021 15:55:56 +0200	[thread overview]
Message-ID: <20211005135606.2246-1-kabel@kernel.org> (raw)

From: Marek Behún <marek.behun@nic.cz>

The original cover letter said:

this patch series fixes the `mtd erase` command when used with mtdpart
with a partition of non-zero offset.

Currently when the `mtd erase` command is used for such a partition,
it does not erase all blocks. Instead after a block is erased, the next
block address not current block address + block size, but current block
address + block size + partition offset, due to spi_nor_erase() not
calling mtd_erase_callback():
  => mtd erase "Rescue system"..
  Erasing 0x00000000 ... 0x006fffff (1792 eraseblock(s))
  jedec_spi_nor spi-nor@0: at 0x100000, len 4096
  jedec_spi_nor spi-nor@0: at 0x201000, len 4096
  jedec_spi_nor spi-nor@0: at 0x302000, len 4096
  jedec_spi_nor spi-nor@0: at 0x403000, len 4096
  jedec_spi_nor spi-nor@0: at 0x504000, len 4096
  jedec_spi_nor spi-nor@0: at 0x605000, len 4096
  jedec_spi_nor spi-nor@0: at 0x706000, len 4096

This series adds some fixes to spi_nor_erase() function, then adds
calling of mtd_erase_callback() to fix this bug.

The series also contains an improvement - adding the posibility to
interrupt spi_nor_erase() with Ctrl+C; and another one - making mtdpart's
_erase() method more sane so that the above mentioned bug will not occur
even if underlying driver does not call mtd_erase_callback().

Finally the last patch removes mtd_erase_callback() entirely, since:
- all provided callbacks across U-Boot are no-ops
- mtd_erase_callback() is abused for completely different purpose
  than the original one (as explained in last commit message)

Marek

Changes since v2:
- added patch (5) adding check for zero length into legacy spi_flash_*()
  functions
- changes patch (6, previously 5) to remove check for zero length also
  from spi_nor_write()

Changes since v1:
- fixed CI bugs (by removing mtd_erase_callback() entirely)

Marek Behún (10):
  mtd: spi-nor-core: Try cleaning up in case writing BAR failed
  mtd: spi-nor-core: Check return value of write_enable() in
    spi_nor_erase()
  mtd: spi-nor-core: Don't overwrite return value if it is non-zero
  mtd: spi-nor-core: Check return value of write_disable() in
    spi_nor_erase()
  mtd: spi-flash: Check for zero length in legacy spi_flash_*()
  mtd: spi-nor-core: Don't check for zero length in spi_nor_write() /
    spi_nor_erase()
  mtd: spi-nor-core: Call mtd_erase_callback() from spi_nor_erase()
  mtd: spi-nor-core: Check for ctrlc() in spi_nor_erase()
  mtd: mtdpart: Make mtdpart's _erase method sane
  mtd: Remove mtd_erase_callback() entirely

 cmd/onenand.c                      |  9 ++----
 drivers/mtd/altera_qspi.c          |  3 --
 drivers/mtd/cfi_mtd.c              |  1 -
 drivers/mtd/mtdconcat.c            | 11 -------
 drivers/mtd/mtdcore.c              |  8 ------
 drivers/mtd/mtdpart.c              | 23 ++++-----------
 drivers/mtd/nand/raw/nand_base.c   |  4 ---
 drivers/mtd/onenand/onenand_base.c |  3 --
 drivers/mtd/spi/sf_mtd.c           |  1 -
 drivers/mtd/spi/spi-nor-core.c     | 46 +++++++++++++++++++++---------
 drivers/mtd/ubi/io.c               | 13 ---------
 env/onenand.c                      |  4 +--
 fs/yaffs2/yaffs_mtdif.c            |  1 -
 include/linux/mtd/mtd.h            | 11 -------
 include/nand.h                     |  1 -
 include/spi_flash.h                |  9 ++++++
 16 files changed, 51 insertions(+), 97 deletions(-)

-- 
2.32.0


             reply	other threads:[~2021-10-05 13:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 13:55 Marek Behún [this message]
2021-10-05 13:55 ` [PATCH u-boot-spi v3 01/10] mtd: spi-nor-core: Try cleaning up in case writing BAR failed Marek Behún
2021-10-05 13:55 ` [PATCH u-boot-spi v3 02/10] mtd: spi-nor-core: Check return value of write_enable() in spi_nor_erase() Marek Behún
2021-10-05 13:55 ` [PATCH u-boot-spi v3 03/10] mtd: spi-nor-core: Don't overwrite return value if it is non-zero Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 04/10] mtd: spi-nor-core: Check return value of write_disable() in spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 05/10] mtd: spi-flash: Check for zero length in legacy spi_flash_*() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 06/10] mtd: spi-nor-core: Don't check for zero length in spi_nor_write() / spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 07/10] mtd: spi-nor-core: Call mtd_erase_callback() from spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 08/10] mtd: spi-nor-core: Check for ctrlc() in spi_nor_erase() Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 09/10] mtd: mtdpart: Make mtdpart's _erase method sane Marek Behún
2021-10-05 13:56 ` [PATCH u-boot-spi v3 10/10] mtd: Remove mtd_erase_callback() entirely Marek Behún

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=20211005135606.2246-1-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=jagan@amarulasolutions.com \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=p.yadav@ti.com \
    --cc=pali@kernel.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@st.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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