From patchwork Wed Aug 5 21:13:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Thomson X-Patchwork-Id: 1341436 X-Patchwork-Delegate: freifunk@adrianschmutzler.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=johnthomson.fastmail.com.au Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=pUlOJvy7; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fastmail.com.au header.i=@fastmail.com.au header.a=rsa-sha256 header.s=fm3 header.b=YrETGhBK; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=VU3zg+/A; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BMPZW21Yyz9sTC for ; Thu, 6 Aug 2020 07:16:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=diS2s7ftQlms7YmOsrvWukWz2gSKgCHNJAeZL5eiPvI=; b=pUlOJvy7OwFDXzwA+iMxB4wTri M7PgxDRbwhIcmawwkr3yvC8k9UystW5ipD7XupavrXwoH3XuQeWt+uHF3AObTZycV9Dr+Pu11pbXI LWxywPqvYy7hza4L7zV8WW7ioxpufVHXw01Twe4M9BXIVGfKjrkXDgurdzs4Q2P2avAZIWaflCI2V pWxBmrM2toclfweUrDkFxkcXFomRF0eGR6Yci06jcPGVBUWqglAf5bUw+b1zaW64fb6ZiC0kywLdh RzE9wFYmCgVi8Yu3qTyPeScH5LRCWfnqinCuQUAEtfqqH7b7tOLplWjlzKZ/zrSBRoZHUsQXNTPTS vAuGZgxA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3Qjs-0008Th-DC; Wed, 05 Aug 2020 21:14:20 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3Qjo-0008SR-Gx for openwrt-devel@lists.openwrt.org; Wed, 05 Aug 2020 21:14:17 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id EE0B25C0178; Wed, 5 Aug 2020 17:14:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 05 Aug 2020 17:14:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com.au; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=VvQpPGA2iRVTGiMxRcmnjVzris WPGSWqHCJDMzHyZhc=; b=YrETGhBKXaRzB+V2Dlnc0decpKjNnYALFq+De8QDTi PaTPXDz1gmANMg3VfLTEoiCJBLlcAwT4gDskeLnbxfORKuu1+Ds+H/7kmoZ5pqoO juU288gRnMrCpZ6CkUeQK2ELiMcf40yfbiAMAHiGwW3wlBGmWH9hF+bm5TaQwPY1 K/buKjTSyOEnw2HQCNw3dtCyMkziaC0yEdMC9i6cW71nujPvepmlQGI5D0HEPJqb 6ErAfOqScJGuWhEs0Rl6bCYP9Af8w1ptvWJ5SzlHtdReQgR9aX0W2Sgc9slFdlAv poJLWuMpTqUqqOPxTic89myv8vnAFm/2w7iWZSZ5Q6hQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=VvQpPGA2iRVTGiMxR cmnjVzrisWPGSWqHCJDMzHyZhc=; b=VU3zg+/A2n9ezt+HBaBP9C4sUZL0Pn1Ai 4hrOGAxoVgrF+02PDI1XoRvDE32IaAYw3CkwwlT+oCXKYuX6yWbTTUQPlIbrpxIY iZ5JsthmkPdCghT0zsAlR6XAnx2UGWbfWvxnGePJEWuEEOBnJd2Xlfe5tLh8UrrI UTlOTxR3hUr3kUgsVu4Z63TlUIvtX+sbdGuYQrr4TZsIPOxSISL7PhwseVggq8Jb e2I8A/merPDthKByKU1+lftTqIc4gg3kRVOMF13NNy9+FwvyWc11s4rvTlw8LLzu in9rhMoI89sHUm/eiyY4zYOQQsRWIy3SG6gIZMEXDW1076L4nGJ5A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjeekgdduiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheplfhohhhnucfvhhhomhhsohhnuceoghhithesjhhohhhnthhhohhm shhonhdrfhgrshhtmhgrihhlrdgtohhmrdgruheqnecuggftrfgrthhtvghrnhepkeetgf dutdehjeffudfhuefhfeetudekgeejteeuheeludeikeetjeelhfdvffevnecuffhomhgr ihhnpehgihhthhhusgdrtghomhenucfkphepheekrdduieehrddvheehrdduvdeknecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhithesjhho hhhnthhhohhmshhonhdrfhgrshhtmhgrihhlrdgtohhmrdgruh X-ME-Proxy: Received: from john.thome.spur.red (unknown [58.165.255.128]) by mail.messagingengine.com (Postfix) with ESMTPA id 83D9930600A6; Wed, 5 Aug 2020 17:14:00 -0400 (EDT) From: John Thomson To: openwrt-devel@lists.openwrt.org Subject: [PATCH] kernel: fix mtd partition erase X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_171416_949302_D05BCE7A X-CRM114-Status: GOOD ( 12.54 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [66.111.4.29 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [66.111.4.29 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Thomson Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This bug applied where mtd partition end address, or erase start address, was not cleanly divisible by parent mtd erasesize. This error would cause the bits following the end of the partition to the next erasesize block boundary to be erased, and this partition-overflow data to be written to the partition erase address (missing additional partition offset address) of the mtd (top) parent device. Signed-off-by: John Thomson Tested-by: Tomasz Maciej Nowak --- 4.19 also requires this fix A little discussion here: https://github.com/openwrt/openwrt/pull/3103#issuecomment-667610510 mtdpart.c should be made to work with 4K erase sectors, where available Considering this here: https://github.com/openwrt/openwrt/pull/3271 --- .../411-mtd-partial_eraseblock_write.patch | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch b/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch index b46c3f5ed4..c48a144d3d 100644 --- a/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch +++ b/target/linux/generic/pending-5.4/411-mtd-partial_eraseblock_write.patch @@ -19,7 +19,7 @@ Signed-off-by: Felix Fietkau /* Our partition linked list */ static LIST_HEAD(mtd_partitions); static DEFINE_MUTEX(mtd_partitions_mutex); -@@ -206,6 +208,53 @@ static int part_erase(struct mtd_info *m +@@ -206,11 +208,77 @@ static int part_erase(struct mtd_info *m { struct mtd_part *part = mtd_to_part(mtd); int ret; @@ -73,10 +73,9 @@ Signed-off-by: Felix Fietkau instr->addr += part->offset; ret = part->parent->_erase(part->parent, instr); -@@ -213,6 +262,24 @@ static int part_erase(struct mtd_info *m + if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) instr->fail_addr -= part->offset; - instr->addr -= part->offset; - ++ + if (mtd->flags & MTD_ERASE_PARTIAL) { + if (partial_start) { + part->parent->_write(part->parent, @@ -95,10 +94,10 @@ Signed-off-by: Felix Fietkau + kfree(erase_buf); + } + - return ret; - } + instr->addr -= part->offset; -@@ -525,19 +592,22 @@ static struct mtd_part *allocate_partiti + return ret; +@@ -525,19 +593,22 @@ static struct mtd_part *allocate_partiti remainder = do_div(tmp, wr_alignment); if ((slave->mtd.flags & MTD_WRITEABLE) && remainder) { /* Doesn't start on a boundary of major erase size */