From patchwork Fri Mar 16 16:13:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 131933 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp939814ljb; Fri, 16 Mar 2018 09:13:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELuhh6WXmyeOuPjUIv/WTcWMyEwWjihJ8AiCdeud00bqkB2/lD1x3Pe+sQ88Fc3OItAZhZ0f X-Received: by 2002:a17:902:e83:: with SMTP id 3-v6mr2838445plx.158.1521216821782; Fri, 16 Mar 2018 09:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216821; cv=none; d=google.com; s=arc-20160816; b=A16GaR5UVNGYb5lIAZvVFiRwK6dMDqUXrmmgTmkGvdKBs65VXRN44jF4x/J+EA3BGH VRZn2WrOpASIOdjHUJ/m2e5cBnjgATpNfjI4MfmVKS3tbB1yQx1S4djP5vHobU9MgNHG dEsw1Pna6w+hBHdnB4wFM5izh5ErDfZRZt6pbqa4ianRA/R4tEK8K1F6mrO809UjM3MB GEfzXwGYadkZpP1a2fvlN0eQ6JEkueXnQ3fkiP8JTjKiFH2CaHOW+p0TfyDjd8sSjYHz SjtbuNAU9zXJtQ883RixFYtkn1p6z0qBTKkJOPjb9cczblwa6u+IoNp3b99PatFB4Sv3 ZrXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=zFrowba6D7yL/3hIGkqAluqOMsTSe8Cs8hLc2HXr0MI=; b=VuVY0AKB82xuT3sQwl5EVe7Zkrdi0BQ+478UNz015W6vHPI0etxQ+lPpmiNjupLxe8 RbzCfBH1R3AEeqRiclONDZyhA17Xrad4Z8w3Nn3y0lw+3vCR4d4w8N+TeUcHMwYqRatJ 1cudpBL1a8nbeKGPTxT+cC7c0XVUJ9ZpPln6LL6ZaBSJ0JmbKU3m2EuC9Vn0P+NqfBMj /K4oWtonhEBmcZRutnL4+T+zM+kAARM4MNKWaKY9H1NSpqEbq6winbMEUu0U5kXE4lSg 7+gHo+jz5/TT8LqHpp6pN4yg8NGv8ljMo1Cy3ZWOT3kyvMEgC072xAGjP/k9C60kEu7C 69IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KQw8rg5K; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 61-v6si6452873plr.136.2018.03.16.09.13.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Mar 2018 09:13:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KQw8rg5K; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4DF12223FCF36; Fri, 16 Mar 2018 09:07:13 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 717612202E4AF for ; Fri, 16 Mar 2018 09:07:11 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id o1so12233445wro.10 for ; Fri, 16 Mar 2018 09:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5zWoz4XsfNzYO5i7jXhnZx2hjxS46cJVPJpCOxbm2Gs=; b=KQw8rg5K62YAEiZ11U4NGJJ5GmIsjmgI7kOqdr39mMT99aY7OXxPtcSoNnd+Rs0RyE CLFdA5eW1mRhG9XEQZ6b7ZVLrFOymP1RkEpAuyJD/3B85xWcTZtrv/GO+xebrTFhG2ms 1fGwJXPVUTdGfkooHZywaTZSeX7HX2NLqxui0= 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=5zWoz4XsfNzYO5i7jXhnZx2hjxS46cJVPJpCOxbm2Gs=; b=rMqFwZa4dxGea+jTC8cYiiPDRI3P7GuJg+Xe4KRb4Ff2VodscYdLcpV5uRWVryty1i OscN4D5icvS/aeYt9yQ7LSzh1VN2Hp9FuxyHbm7SCuCBoQ2fj/jCTL0TA8qN6JqWbKig T+WK5K7Wjw5anPsvWktPAxCJ/mrU9Z/Zh34TnP5vHo0ozpcvybLzPZsASS7hfOVeo7cw 6c3H6hUMfyR9tTwTIQp8ZHeBTYz5QdT/2CnepD9lSUwjfFMR89je+1M+5+VwvhyOPa5r b4hbQCj08mxVPlnbZHJeNguV2tQq3GyTMFr/NYCA7INLKtFp8SEEzNXZH1CGSN86W6wZ 3SUw== X-Gm-Message-State: AElRT7G7hN23NwjUA9807y4XWRsy+cZC3BeqYsvHWsgdh+H+prgK0shL Lg8VIm7Jbw+dxq0BAlfQ0+DaiQ7OoBs= X-Received: by 10.223.135.148 with SMTP id b20mr2170826wrb.100.1521216815075; Fri, 16 Mar 2018 09:13:35 -0700 (PDT) Received: from localhost.localdomain ([105.142.191.63]) by smtp.gmail.com with ESMTPSA id n8sm7876242wrf.12.2018.03.16.09.13.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Mar 2018 09:13:34 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 16 Mar 2018 16:13:19 +0000 Message-Id: <20180316161322.6756-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180316161322.6756-1-ard.biesheuvel@linaro.org> References: <20180316161322.6756-1-ard.biesheuvel@linaro.org> Subject: [edk2] [RFC PATCH edk2-platforms 3/6] Silicon/SynQuacerPlatformFlashAccessLib: skip empty blocks X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Before adding more payload to the capsule which may be only partially occupied, add some logic to skip writing these blocks after erasing them. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c | 41 +++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) -- 2.15.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c index 82fe3f74aa7f..0131e33a4fe7 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c @@ -115,6 +115,35 @@ GetFvbByAddress ( return Status; } +/** + Check whether a buffer has any data in it, i.e., bytes with value != 0xff + + @param[in] Buffer Address of the buffer + @param[in] Length Size of the buffer + + @retval TRUE A non-0xff byte was found + @retval FALSE Buffer has 0xff bytes only + +**/ +STATIC +BOOLEAN +BufferHasData ( + IN VOID *Buffer, + IN UINTN Length + ) +{ + UINT8 *Data; + UINTN Index; + + Data = Buffer; + for (Index = 0; Index < Length; Index++) { + if (Data[Index] != 0xff) { + return TRUE; + } + } + return FALSE; +} + /** Perform flash write operation. @@ -257,11 +286,13 @@ PerformFlashWrite ( __FUNCTION__, BlockSize, Lba)); NumBytes = BlockSize; - Status = Fvb->Write (Fvb, Lba, 0, &NumBytes, Buffer); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, - "%a: write of LBA 0x%lx failed - %r (NumBytes == 0x%lx)\n", - __FUNCTION__, Lba, Status, NumBytes)); + if (BufferHasData (Buffer, NumBytes)) { + Status = Fvb->Write (Fvb, Lba, 0, &NumBytes, Buffer); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: write of LBA 0x%lx failed - %r (NumBytes == 0x%lx)\n", + __FUNCTION__, Lba, Status, NumBytes)); + } } if (HaveBootGraphics) {