From patchwork Sat Nov 23 22:51:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 1199899 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=none (p=none dis=none) header.from=timesys.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=timesys-com.20150623.gappssmtp.com header.i=@timesys-com.20150623.gappssmtp.com header.b="qcwrfN31"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47L7kH29S7z9sPj for ; Sun, 24 Nov 2019 09:48:23 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id EB6D2C21D65; Sat, 23 Nov 2019 22:48:19 +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=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2FBA1C21C2F; Sat, 23 Nov 2019 22:48:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A4CD8C21C2F; Sat, 23 Nov 2019 22:48:17 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by lists.denx.de (Postfix) with ESMTPS id 4A9C4C21BE5 for ; Sat, 23 Nov 2019 22:48:17 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id b11so1851693wmj.4 for ; Sat, 23 Nov 2019 14:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timesys-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nHjJRYAqMeJZdIHg+Nakp35Bfd6LMgfmZ2s6BBbr108=; b=qcwrfN31FCNPcLU/qu+RF2Ph/U4CPECML113aZNuWF3GuMhWJMI+e5YVSPIb9WOmNH 8Aw8W2GoQHWiDmpxIMwgQdc4vDVkxb+IcIJNc2uIrFa2hXcdXQOYP5N+TnQKTyQqTdqV Ghqa+IU0lZdYRWesycJ452dL3psJeqc5ixikD9UMsGlZPJLcC8KD9ByrrYawcx/pBizr a4O5bHpDJd+yBfZhwE4S02ooqFHU47cwk5qAmry5DtGJqiBFMJQdWRrVXVUvsVQuKDLc 2+YOm/wy8EBPsZKGAaCc5ms7nMzxtCyWr3+AkN1VuxbP7SLZw5kNjSwcoTMgyPCy093/ Vvrg== 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:mime-version :content-transfer-encoding; bh=nHjJRYAqMeJZdIHg+Nakp35Bfd6LMgfmZ2s6BBbr108=; b=WxldOwtt0YAvWIFi0hABDl3SqUDUwfc2DAH9YGfV9CL9lVj87O6QYNPq5wBq9D4Zkv hZBO2GTg4Fv8PAXuv+3rd6LHGeowq8sVbd0mSbJRFPWZv90zov9Oz8tgXaGaS6UAriaf LDvDar4bgNgjGme66x30jnNbt3vEGL/6DglKsxHoSkERNtXYdwWP8dsYh6C7aZzP8qUE fsrbBxJw2+tcABHSDoc0/7Uv9uCsL054NA7TuFFnFZ2S+YDtRKpfUG/yzZ02aq22yZv3 FTEyfjSqvjiiNRD/f4ErHhpkuGurJd82cFZyHyN6Z12eS4IoVACZwBdvQgBeY10NisFN I8jw== X-Gm-Message-State: APjAAAW+YZueZi2TMQNXXHlN94IJc3skKjmCZX7motfKYqkO0pfLaHIo CtilarVnYv6QO29CtDGV5yZpMQ== X-Google-Smtp-Source: APXvYqzxBQiCHa4MncgQlzX0dJADlAiNeL58lIsXHtd2N9FTLdUbQyxZy31CFZeFgvevGqoPp2dLjQ== X-Received: by 2002:a1c:998f:: with SMTP id b137mr23142756wme.104.1574549296925; Sat, 23 Nov 2019 14:48:16 -0800 (PST) Received: from localhost.localdomain (host196-236-dynamic.21-79-r.retail.telecomitalia.it. [79.21.236.196]) by smtp.gmail.com with ESMTPSA id 2sm3644484wrq.31.2019.11.23.14.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Nov 2019 14:48:16 -0800 (PST) From: Angelo Dureghello To: trini@konsulko.com, eric@nelint.com, mgroeger@sysgo.de, wd@denx.de Date: Sat, 23 Nov 2019 23:51:11 +0100 Message-Id: <20191123225111.384628-1-angelo.dureghello@timesys.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Cc: u-boot@lists.denx.de, Angelo Durgehello Subject: [U-Boot] [RESEND PATCH] common: add blkcache init 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" From: Angelo Durgehello On m68k, block_cache list is relocated, but next and prev list pointers are not adjusted to the relocated struct list_head address, so the first iteration over the block_cache list hangs. This patch initializes the block_cache list after relocation. Signed-off-by: Angelo Durgehello --- common/board_r.c | 12 ++++++++++++ drivers/block/blkcache.c | 7 ++++++- include/blk.h | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/board_r.c b/common/board_r.c index 65720849cd..13e70a5ffb 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -628,6 +628,15 @@ static int initr_bedbug(void) } #endif +#ifdef CONFIG_BLOCK_CACHE +static int initr_blkcache(void) +{ + blkcache_init(); + + return 0; +} +#endif + static int run_main_loop(void) { #ifdef CONFIG_SANDBOX @@ -832,6 +841,9 @@ static init_fnc_t init_sequence_r[] = { #endif #if defined(CONFIG_PRAM) initr_mem, +#endif +#ifdef CONFIG_BLOCK_CACHE + initr_blkcache, #endif run_main_loop, }; diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c index 1fa64989d3..bf0fa1ea6f 100644 --- a/drivers/block/blkcache.c +++ b/drivers/block/blkcache.c @@ -21,13 +21,18 @@ struct block_cache_node { char *cache; }; -static LIST_HEAD(block_cache); +static struct list_head block_cache; static struct block_cache_stats _stats = { .max_blocks_per_entry = 8, .max_entries = 32 }; +void blkcache_init(void) +{ + INIT_LIST_HEAD(&block_cache); +} + static struct block_cache_node *cache_find(int iftype, int devnum, lbaint_t start, lbaint_t blkcnt, unsigned long blksz) diff --git a/include/blk.h b/include/blk.h index d0c033aece..7070fd6af3 100644 --- a/include/blk.h +++ b/include/blk.h @@ -113,6 +113,12 @@ struct blk_desc { (PAD_SIZE(size, blk_desc->blksz)) #if CONFIG_IS_ENABLED(BLOCK_CACHE) + +/** + * blkcache_init() - initialize the block cache list pointers + */ +void blkcache_init(void); + /** * blkcache_read() - attempt to read a set of blocks from cache *