From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28990C433F5 for ; Tue, 5 Oct 2021 13:56:24 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F8D361AAC for ; Tue, 5 Oct 2021 13:56:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5F8D361AAC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD10782DA1; Tue, 5 Oct 2021 15:56:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="sH6HDoFo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 22C8782C30; Tue, 5 Oct 2021 15:56:18 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6E9D280FBE for ; Tue, 5 Oct 2021 15:56:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F9C4615E3; Tue, 5 Oct 2021 13:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633442172; bh=F8fJi4PDJnmxq2mBDfj75sU565r6mWk7zZUFVqLfGnw=; h=From:To:Cc:Subject:Date:From; b=sH6HDoFo1t9zSZUkEOqGfZXc3KHxF67SJbesBeFN2eupHXzYhP0w7Q4BFHOwoYWyw +xsLiLdkHdSsWS0zpfdB3MdZPOfvn9YZBk5VxH+Z4KlLBkgbBuVjwfpiVV0oycZ8ms 4xHonNUP7XI0C2EiSe3iU98CbNUnnVj+gT+pOXxPAMxedY7k8QKE+tktPgVcho3n7s wvJ9Cl0q32qpf1kga4LSMMp2wVQ1gPmKo3g9wRVAyOcssN1deSD19Bw4RAAXGzFFTv eO8XsDawR2hP6dRXDm4Wpnnf1l0mHu7lZgVjgQTe86zgvkPmhosPlZub7NXcB4x4er vAnWnEA4no8FQ== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Jagan Teki , Tom Rini Cc: u-boot@lists.denx.de, Patrick Delaunay , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Patrice Chotard , Marek Vasut , Pratyush Yadav , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-spi v3 00/10] Fix `mtd erase` when used with mtdpart Date: Tue, 5 Oct 2021 15:55:56 +0200 Message-Id: <20211005135606.2246-1-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Marek BehĂșn 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