From patchwork Wed Sep 13 06:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 813180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xsXc13Yf7z9sNV for ; Wed, 13 Sep 2017 17:00:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rwLPdYTf"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xsXc1295kzDqr8 for ; Wed, 13 Sep 2017 17:00:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rwLPdYTf"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::241; helo=mail-pf0-x241.google.com; envelope-from=sjitindarsingh@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rwLPdYTf"; dkim-atps=neutral Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xsXbd2JVMzDqlw for ; Wed, 13 Sep 2017 16:59:56 +1000 (AEST) Received: by mail-pf0-x241.google.com with SMTP id g65so6953472pfe.1 for ; Tue, 12 Sep 2017 23:59:56 -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; bh=HIdCRMMYJe8f7aAPqOESkW0hJ6lMY6UjnZgWtOvABwY=; b=rwLPdYTfgTSxcWQCMq0ANIes2fmyYXky7EOKj7hGOX/Alzh6QLXJQjMNuH3+efFGAf Ra71EMMfhd9FQHnWQkcxBdN186bj5DtBKZ+IH/Ho/VvShG7Ua1tRfsZDx+V5MNQHWEIq /CTxpdzNKJ7TFa8SmhWyOk52ia0YzvF61w2dQ45SUH3Qx3jDHHpe7URAFJ80HZ9UJAt1 bFznfR2LSRBGXfjNozvJoddIFBb2apT6mQhpUNCeShdFmYvwUygqPnw0X6ceFjz3azj8 BCP0WHN7dB/jm2xYwKkx4LpfLmc0qZX4ymBcktjhIRWcI7LeLinkrXNd27DMUcV2ahgN DP6Q== 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; bh=HIdCRMMYJe8f7aAPqOESkW0hJ6lMY6UjnZgWtOvABwY=; b=jLBVxa6as+h+X+SrgOvFpj12HqMODPD8aY1ecPnIhsIiO2TLHcMtAHTYuEuRhUlz4F dWhhYGJN9KOP4pukc+Zd+TRtpbgVUEplCXRgwFYIa+7i3jsBSD99bEuQ07Tgkp+DZTFG XUretsrrQVn+YJnqPkUxIm6bLICGMoPZ+sUfxBFepMoE8knncFzSWdowIQFyRKWRmJCS ta+ggkAg4KDcOXflo2E6limP8ggpnNt5f2BbMQxfFSKib87AJhRrbjRyO/bUZeLaHkmu Mk2KW7kbjC8d3p18c603V9zxKeVgtXyBPhkYlZCEtZ/KTeeN1hbUYI79167esbT7z9ze dMyg== X-Gm-Message-State: AHPjjUiyLhmGROD2RHFVRFnqYwKxvFRIceYclxzZshoYk+1OUqcM+HHw mtwvYkuTqkpOohvn X-Google-Smtp-Source: ADKCNb4kVOWEANkSs/o0SpDOEcc07KrvPnERmOBmuLiqrKhNafPGJYC50SIj47J0RYjJjC6WMKKdtg== X-Received: by 10.98.19.203 with SMTP id 72mr17319149pft.124.1505285994138; Tue, 12 Sep 2017 23:59:54 -0700 (PDT) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id k27sm18892196pfk.20.2017.09.12.23.59.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 23:59:53 -0700 (PDT) From: Suraj Jitindar Singh To: skiboot@lists.ozlabs.org Date: Wed, 13 Sep 2017 16:59:46 +1000 Message-Id: <20170913065946.11262-1-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.9.4 Subject: [Skiboot] [SKIBOOT] [PATCH] pflash: Fix erase command for unaligned start address X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cyrilbur@gmail.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The erase_range() function handles erasing the flash for a given start address and length, and can handle an unaligned start address and length. However in the unaligned start address case we are incorrectly calculating the remaining size which can lead to incomplete erases. If we're going to update the remaining size based on what the start address was then we probably want to do that before we overide the origin start address. So rearrange the code so that this is indeed the case. Reported-by: Pridhiviraj Paidipeddi Signed-off-by: Suraj Jitindar Singh Reviewed-by: Cyril Bur --- external/pflash/pflash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index bfc975f..5b1be3c 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -331,9 +331,9 @@ static int erase_range(struct flash_details *flash, fprintf(stderr, "Failed to blocklevel_smart_erase(): %d\n", rc); return 1; } - start += flash->erase_granule - (start & erase_mask); size -= flash->erase_granule - (start & erase_mask); done = flash->erase_granule - (start & erase_mask); + start += flash->erase_granule - (start & erase_mask); } progress_tick(done); while (size & ~(erase_mask)) {