From patchwork Tue Sep 18 13:05:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Worsley X-Patchwork-Id: 971094 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cK29uA0w"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fnR8I1gA"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42F3D46Ntqz9s9h for ; Tue, 18 Sep 2018 23:06:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=nqBFR+uitKvSMc9AvwKR7zcEjPA2znGSjFjSLUDpuJQ=; b=cK29uA0wf8/XnJB7rZ9WPj/5y2 i2Bl8sguNZS7x1FNdurrw4ocEJKP1voJOM5CLB78ZN+5D/Qz6n3TdpLfU9rtEWqjZ10wFhVCX5m/D Q0CMW0cVvceX/bemC57afDkqqXvDwxnZavlHDrAmAvxrup4t3adS97J8AB7ceeZJpdlmQbiy75ziO sML1jr+WefY7gaA02QYjAxF6CXA2GIL3Z8ssP7o4ejL2ig0/OiU7ilComBvV4CowstLnnUsA5Z0l2 v2W1IJGUvRKJVH9oyPv85Hvg93NTH0bwUAcasaswIz7DPN7Kv/BAIbZco1Mg3dk5I9Vap309kpTC/ ahEJKOww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2Fi1-0004JV-7Z; Tue, 18 Sep 2018 13:06:29 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2Fhb-0003xa-UW for linux-mtd@lists.infradead.org; Tue, 18 Sep 2018 13:06:18 +0000 Received: by mail-pf1-x443.google.com with SMTP id s13-v6so1001756pfi.7 for ; Tue, 18 Sep 2018 06:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1a2U8BQyEsSn6l+/bDVwsJsFBUD0QbFEgCGuHrWLnvs=; b=fnR8I1gA1EPSGC1lvkpmWe4zOlwZHLP0d04yWx2pgwOfaU38xk8USRgo5Q6tgKFR5y SG1A9oPA1BxoYQyVTco3Om+hp6FZJDxfG8+UERF5/Yc6ebjHSZpC633Ss0aB8LF9pUVQ 5VKFQwuFCNRKlMv21v+usQMA+1ouHSKJu8b5Hefm8c5F7r2nWO5vIB3x6qFjqjDLru8+ txMhFpTo8CHSDwOpTq9/WLupQTx6D2iyOeiuoVyHnu2rARMEUuoGsRybXbU5KyxrFH/o ueE0uMumEbrMKIqTAymQcS+jXedJK4cW++O+ufvAOH+4diz/oET5fWxMUVNT8e6YvuTu i90w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1a2U8BQyEsSn6l+/bDVwsJsFBUD0QbFEgCGuHrWLnvs=; b=CFj6bke4I3dSAvC07aDNP/OKb1n0kfJhQpEgMqS6e0gHcjBIXbdBzVWYJTHdDzpZGq BbzG1IBYgmtMJ24WJOAN2TD1gEOaeCo2bC8kB2l+UnGeMNKmKc2CYr5KlMiPrdO2yPuz 8OINEU+9L3WmBBSqKYl6M1TlTFa7JiymBqpKEx+7DeIivyIicfsOqpJ+XHQxmTVi1UD4 IZ/JdT/5XZJD9Yj8NZS5KHmz5RLy1BPrMFxAyAaRm6XuVBcMBrcf53r3a5j99fK2pemx 2sZhHiGCv+VxMEqBSEXxPTz7BX6Q8usWfdZ4PFkC3NEjsPbIm8x9GElw+bRY7yXd3/zg LeGA== X-Gm-Message-State: APzg51B/5yNT0lU6fxYWcDDTCJj7g9pKIqpM1J5KSue7VoosiFEh9BB1 tz/iAddrQ48yZFosS3BBJjcig3IFC+I= X-Google-Smtp-Source: ANB0VdangKKK9EqYVo4mMUaDuI7dMJg6LQ0knWkt++VlG8L9Y0DICVEhAB2Ir/hFEMUJ8CEpO4uI/Q== X-Received: by 2002:a63:3dc6:: with SMTP id k189-v6mr27735061pga.191.1537275953136; Tue, 18 Sep 2018 06:05:53 -0700 (PDT) Received: from localhost (27-32-189-129.static.tpgi.com.au. [27.32.189.129]) by smtp.gmail.com with ESMTPSA id l6-v6sm25142198pfl.169.2018.09.18.06.05.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Sep 2018 06:05:52 -0700 (PDT) From: Andrew Worsley To: Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , linux-mtd@lists.infradead.org (open list:UNSORTED BLOCK IMAGES (UBI)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] Round UBI average erase count up to next integer Date: Tue, 18 Sep 2018 23:05:21 +1000 Message-Id: <20180918130521.22880-2-amworsley@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180918130521.22880-1-amworsley@gmail.com> References: <20180918130521.22880-1-amworsley@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180918_060604_058325_EA971037 X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (amworsley[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Worsley MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use a slightly larger than average EC so these PEBs will be reinitialised with erase counts that make them less likely to be reused than other (perhaps less worn or error-prone) PEBs We have more frequent ECC failures on reads of page 0 of some PEBs which manifest itself commonly during ubiattach. We believe this is due to "program disturb" and want those PEB to be re-used later than average. Signed-off-by: Andrew Worsley --- drivers/mtd/ubi/attach.c | 2 +- drivers/mtd/ubi/fastmap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c index 93ceea4f27d5..f97e2ba56fb2 100644 --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -1414,7 +1414,7 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai, /* Calculate mean erase counter */ if (ai->ec_count) - ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); + ai->mean_ec = div_u64(ai->ec_sum+ai->ec_count-1, ai->ec_count); err = late_analysis(ubi, ai); if (err) diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index 462526a10537..91e513788f38 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -684,7 +684,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, be32_to_cpu(fmec->ec), 1); } - ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); + ai->mean_ec = div_u64(ai->ec_sum+ai->ec_count-1, ai->ec_count); ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); /* Iterate over all volumes and read their EBA table */