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 D1F73C433EF for ; Sat, 25 Sep 2021 17:34:00 +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 0F452610C9 for ; Sat, 25 Sep 2021 17:34:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0F452610C9 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 ACAE28359B; Sat, 25 Sep 2021 19:33:52 +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="r6h0biV+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A594C83587; Sat, 25 Sep 2021 19:33:37 +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 AF5CC8357E for ; Sat, 25 Sep 2021 19:33:26 +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 052B66108E; Sat, 25 Sep 2021 17:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632591203; bh=C5/PbtezoohYAnGFCI0ja48gnHHBGyVLhdWh/k7FYgY=; h=From:To:Cc:Subject:Date:From; b=r6h0biV+6RAEkF8JZ42nIfBODVOOvJVrhpMC1f8/aaXjlxj9XaVbUrwEda3DI9WC1 VAdbvZM3cmuz7XNXmv+VZ1LqMnX+s38YkpJSFyInTcC60YW+L3AYkLfU1mvDrYsm8L 7cg5PtTgUpegL4bm/DSpLZfSRjcyrAHQgOBYrpR6ThkwqZv/J8T9dYUZkhU8sfzwtV SGX+pFJjKtxNuG+67SajC8DbVuiKYJqAdCJTrsYcRR0EUJg94zmQf3IoK5vXhqvQeH HlFMo/c267Ghno9cyWau0SZAO53iesHvV60uNzdowXaSM57dH4zyU1SYMy0Hau9mY7 18sxKgUt0J9Jg== 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 , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-spi v2 0/9] Fix `mtd erase` when used with mtdpart Date: Sat, 25 Sep 2021 19:33:09 +0200 Message-Id: <20210925173318.25804-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 v1: - fixed CI bugs (by removing mtd_erase_callback() entirely) Marek BehĂșn (9): 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-nor-core: Don't check for zero length in 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 | 43 +++++++++++++++++++++++------- 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 - 15 files changed, 42 insertions(+), 94 deletions(-) -- 2.32.0