From patchwork Tue Jan 21 09:37:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 1226336 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.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=pass (2048-bit key; unprotected) header.d=timesys-com.20150623.gappssmtp.com header.i=@timesys-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=YdLJLdwP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4823Mw2vk5z9sPJ for ; Tue, 21 Jan 2020 20:36:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C6058194B; Tue, 21 Jan 2020 10:36:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=timesys.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=timesys-com.20150623.gappssmtp.com header.i=@timesys-com.20150623.gappssmtp.com header.b="YdLJLdwP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BCC9581924; Tue, 21 Jan 2020 10:36:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7CFCE81924 for ; Tue, 21 Jan 2020 10:36:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=timesys.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angelo.dureghello@timesys.com Received: by mail-wr1-x442.google.com with SMTP id y11so2340737wrt.6 for ; Tue, 21 Jan 2020 01:36:39 -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=7xTFly3mFEJ1ThDqd1KTnOQCSqL6fMeZ7xZqdsvvL0s=; b=YdLJLdwPwx+2XGFCGVFzoExfDTVO12If7uVN8P+t2A7GvqfeJJSSP2T217gp5vh49v yE0GpoBoXAsFOKV9IjlaUUyw3DyoxZEzJmR6JZCIuzz+XK1DcKd9iUxFaOLIQBMn4FZ3 BGLiIsODcNJ61mZA8V58iZzxSC+TYaHmlYDc2DSLeFUhvmK2Nsb3WuSHT2mt9zj/SOip iCAnLhr8spPJuIc9peocsGPLwM3v121zx4G2xvuh5/FdidxAsd6iBexYM0dItQQaEXzT +6vo0VqLN7tbcShThy+gWzmFbgLSBjYRT9cv4uaajMdn/2yv5/yPCHa+6A+879fPsPCa 4jMw== 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=7xTFly3mFEJ1ThDqd1KTnOQCSqL6fMeZ7xZqdsvvL0s=; b=uU5EotnlPbkez3FC2cqTw3X1HLBhGnqnWQrHQRVQQrYk/HTU6LeYsnUoANS5BKYYa8 2IzUzew6briKTP04FboW9IrVkwCKh3IgdGHAJwkTuURRj2D1MZ3um4b+P28Dw5Y6BrlN x991HrCZ06A9cy0sLf/TZpwJ5brtkxcWp2nLPKn6yAggnM1aQInda3aexM8XRIpmnqmQ res5afSWt0OpQtDPYYx132mDvRcHQNZaj/KJoKc+uSjn2//mj0/CkQjBAmRcPBN1JNm5 ZcW7n29wh3xcTmuQV7hPB59i3nRoCPKJspij3XbSAR9I8/oCUWtf2+5jTgVugiRlRIgp 7akg== X-Gm-Message-State: APjAAAWIHVL5VBAUL5901448cJbA9HkcDob35JRLqdj7zg6QofrJA9Bv TEaj87W4kXbSq53EJopQtZYLeQ== X-Google-Smtp-Source: APXvYqxb/uKWFrwMFALiBFvSltL9x93pS+Duw2aGMO3G9RjdtH3lZAHK+2BXBN5r7SdG/7z6RRgcPg== X-Received: by 2002:a5d:6390:: with SMTP id p16mr4382925wru.170.1579599398831; Tue, 21 Jan 2020 01:36:38 -0800 (PST) Received: from localhost.localdomain (host31-4-dynamic.248-95-r.retail.telecomitalia.it. [95.248.4.31]) by smtp.gmail.com with ESMTPSA id v14sm51207728wrm.28.2020.01.21.01.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 01:36:38 -0800 (PST) From: Angelo Dureghello To: trini@konsulko.com, eric@nelint.com, wd@denx.de Subject: [PATCH] common: add blkcache init Date: Tue, 21 Jan 2020 10:37:27 +0100 Message-Id: <20200121093727.33758-1-angelo.dureghello@timesys.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, Angelo Durgehello Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Eric Nelson --- Changes for v2: - call blkcache_init directly --- common/board_r.c | 3 +++ drivers/block/blkcache.c | 9 ++++++++- include/blk.h | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/board_r.c b/common/board_r.c index 8a0c1114e7..4f56c19fcc 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -864,6 +864,9 @@ static init_fnc_t init_sequence_r[] = { #endif #if defined(CONFIG_PRAM) initr_mem, +#endif +#ifdef CONFIG_BLOCK_CACHE + blkcache_init, #endif run_main_loop, }; diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c index 1fa64989d3..f603aa129d 100644 --- a/drivers/block/blkcache.c +++ b/drivers/block/blkcache.c @@ -21,13 +21,20 @@ 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 }; +int blkcache_init(void) +{ + INIT_LIST_HEAD(&block_cache); + + return 0; +} + 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..65db69f5d9 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 + */ +int blkcache_init(void); + /** * blkcache_read() - attempt to read a set of blocks from cache *