From patchwork Wed Sep 25 14:57:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1167475 X-Patchwork-Delegate: bmeng.cn@gmail.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZjPJ/87v"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46djwS2Mb5z9sNx for ; Thu, 26 Sep 2019 02:20:56 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 03B6CC22135; Wed, 25 Sep 2019 16:11:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=RCVD_IN_MSPIKE_H2, TVD_PH_BODY_ACCOUNTS_PRE, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2D2E4C2220C; Wed, 25 Sep 2019 15:05:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6A37CC220C5; Wed, 25 Sep 2019 15:05:00 +0000 (UTC) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by lists.denx.de (Postfix) with ESMTPS id E8022C220C7 for ; Wed, 25 Sep 2019 14:59:04 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id q1so14664085ion.1 for ; Wed, 25 Sep 2019 07:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/VEF4DsOYnMqpHIAGMtuiQJ5ArdHP6GYZl8z/TjSHmI=; b=ZjPJ/87vM50lJ2ZpRocmBgLV0oWeGL5d2eGBFlCM9tF/jJYENuo+cNpre/mEojTAQA RtHjBnYo6zeSX8ChNW+CmNSYXvknoMxD5jHmAUcZ6JPgVNYQz47j9Tkdk43gXXkoN6jK OLI4OdhGGFirpNQ9+vDqZMYir0B8Xd2m2wbk8= 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:mime-version:content-transfer-encoding; bh=/VEF4DsOYnMqpHIAGMtuiQJ5ArdHP6GYZl8z/TjSHmI=; b=ixEg9k7fdnoqCqfxOdWRJwDt1NW/cq5dL4l72zZkES72v4LURkD8rxHNZCO29weW1Q lP077HUc7o85PKUqr3jcifus/Y6LWYDowzZvTgKFa2rf5kshB/BB5DSX1clogOx1XO0c 8AsBNXZHXmH3Z7MxeftKg7/0WjWC9f1/SzOUZYTWG7zq81Bm6lgvMGqY5fZYTw1+yESq FEsDO6KWo7tGil0RUzwK02vhJJ1shkdBb0nzWLwpX0dXgaV/iHT7muEzpVRLp1cWtDb5 irnIEnfKpKIK5Sk8ANdFcF0Krckmg7yQ0gC5OLcPoOXejwIbR1EfS8iVQr/thLr1RhLV EzbQ== X-Gm-Message-State: APjAAAUTut8dUdgWEZGuPyLdpcpEcWacN9/4cfMQ2QuPl7V0+8+05AEp T0hlDB76zR/Jw1DbIcEE2FFsSrlSd08= X-Google-Smtp-Source: APXvYqy8Eeyps60T8i4eJ6J+R8TS3TPcAQh3cBkMdziqi+X64WZKVpjnco+zu5UWrJZPPqLHNeUEuw== X-Received: by 2002:a5d:9457:: with SMTP id x23mr10415285ior.14.1569423543680; Wed, 25 Sep 2019 07:59:03 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id d9sm4254964ioq.9.2019.09.25.07.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 07:59:03 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 25 Sep 2019 08:57:05 -0600 Message-Id: <20190925145750.200592-82-sjg@chromium.org> X-Mailer: git-send-email 2.23.0.444.g18eeb5a265-goog In-Reply-To: <20190925145750.200592-1-sjg@chromium.org> References: <20190925145750.200592-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 081/126] x86: Correct mrccache find_next_mrc_cache() calculation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This should take account of the end of the new cache record since a record cannot extend beyond the end of the flash region. This problem was not seen before due to the alignment of the relatively small amount of MRC data. But with apollolake the MRC data is about 45KB, even if most of it is zeroes. Fix this bug and update the parameter name to be less confusing. Signed-off-by: Simon Glass --- arch/x86/lib/mrccache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c index 33bb52039bd..e286bdf1b30 100644 --- a/arch/x86/lib/mrccache.c +++ b/arch/x86/lib/mrccache.c @@ -86,15 +86,16 @@ struct mrc_data_container *mrccache_find_current(struct mrc_region *entry) * @return next cache entry if found, NULL if we got to the end */ static struct mrc_data_container *find_next_mrc_cache(struct mrc_region *entry, - struct mrc_data_container *cache) + struct mrc_data_container *prev) { + struct mrc_data_container *cache; ulong base_addr, end_addr; base_addr = entry->base + entry->offset; end_addr = base_addr + entry->length; - cache = next_mrc_block(cache); - if ((ulong)cache >= end_addr) { + cache = next_mrc_block(prev); + if ((ulong)cache + mrc_block_size(prev->data_size) > end_addr) { /* Crossed the boundary */ cache = NULL; debug("%s: no available entries found\n", __func__);