From patchwork Wed Jun 13 21:23:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 929099 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=none (p=none dis=none) header.from=nod.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZD7MM59o"; 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 415fxy38NDz9s2g for ; Thu, 14 Jun 2018 07:28:38 +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=ifIQS6PGokOJgq7sVRINlrmeikFyDjKsSas/+7/GX80=; b=ZD7MM59ol+N8xlB53KKUOXmeGr mgTNbG0bOsLWTWxU0EJojoCOkY9s1RXomvnT8nuHkkhp7C+4c4Wtu0fIq7rxreNs3U+TuNgoTSgY9 HwaFL4uAUvktdQl4aPkq+CaHXP9QhcRER7tqqfxEOO98qLcWC23YPZHGLUURSIFGZ5k6Hodv2vUNC Q+zlBAPXqHeV6YOWUCiWup8rB62H2Kio9GY9jh85AvXEVSYP94eeLoa7YrVOfPlCoaAW1RnY1i0eK NmO+L9s46fUroUeL35Pes4bq6k/AJJQ7qSoFrojnzHMWuH71sTgPMUNKk778uW7wzi1y6UZxrlWYI lppUEKNw==; 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 1fTDJe-0000EV-2A; Wed, 13 Jun 2018 21:28:30 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTDFi-0004u5-O6 for linux-mtd@lists.infradead.org; Wed, 13 Jun 2018 21:24:38 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id DE6F5181B5052; Wed, 13 Jun 2018 23:24:03 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 06/14] ubi: fastmap: Handle bad block count for preseeded fastmap case Date: Wed, 13 Jun 2018 23:23:36 +0200 Message-Id: <20180613212344.11608-7-richard@nod.at> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180613212344.11608-1-richard@nod.at> References: <20180613212344.11608-1-richard@nod.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180613_142427_001984_8A4CBE16 X-CRM114-Status: GOOD ( 14.41 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 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: Richard Weinberger , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If the fastmap is preseeded the bad block count is created while scanning for bad blocks in the PEB fixup code. Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/fastmap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index 279d02874297..69b855b3cf2a 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -725,7 +725,16 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, } ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); - ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); + + if (fm->flags & UBI_FM_SB_PRESEEDED_FLG) { + /* When we have a preseeded Fastmap we cannot use the provided bad block number */ + if (be32_to_cpu(fmhdr->bad_peb_count) != 0) { + ubi_err(ubi, "Bad block count in preseeded Fastmap is non-zero"); + goto fail_bad; + } + } else { + ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); + } /* Iterate over all volumes and read their EBA table */ for (i = 0; i < be32_to_cpu(fmhdr->vol_count); i++) {