Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB8E1C04A95 for ; Thu, 29 Sep 2022 00:20:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4BDFF84BCD; Thu, 29 Sep 2022 02:20:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=kohlschutter.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=kohlschutter-com.20210112.gappssmtp.com header.i=@kohlschutter-com.20210112.gappssmtp.com header.b="10u9r0KY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7965C84BD6; Thu, 29 Sep 2022 02:20:52 +0200 (CEST) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 3639584571 for ; Thu, 29 Sep 2022 02:20:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=kohlschutter.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=christian@kohlschuetter.com Received: by mail-ej1-x62a.google.com with SMTP id nb11so30336641ejc.5 for ; Wed, 28 Sep 2022 17:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kohlschutter-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=c1OSW+6qgYaVVKM0bbmxYCDXOz/7pg2chbrtejWhUew=; b=10u9r0KYo9tUYh66beYV7F0yHGKk9EeypQqBJm86N0E1CetvpcNz185OAqfRP8a0Gx QG2yDPfMoxt9TKSLPOVCQ2Ymb6SDJ5OeI+La36D+N/0PmPvgwhZGrejE77IdfEU4rG0K KBXKaYNoO8DykHDcnziRbOBNCja8ZuvTcASV5E/Cx67MZVyQ9PjQwJctDvJRapjk0guN FD04gap2+x7EYP0EiBDK7QRA8We6ZGFG3SHbNRm/uKS43XSNx5+R4/yQkZ9b36L71gov MqrsqspBJdw5Fjx9ZNpYUcPA7LFs6S2PHH8qcj0OAJ+EF1usPBye07wf5gOY8sobhNfk rwCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=c1OSW+6qgYaVVKM0bbmxYCDXOz/7pg2chbrtejWhUew=; b=Qg/xCoHn8SFLBr1osckkGt0jzLdmvYKdjAnIpCRru0HZSuj2GjzcMx2lSD1EJx4UM7 3ZUWksKGNHRoXGc5AEcndBqA2y5YGQFe2lT4YX10JkFWtLjaKoLfqbeEppnqiHAoaTU7 wEXs0i5Xb9/yDKE4cnm81Tpuhs4abTal8IFDZLxSErRctEDA5FvyK4xcSpf8jpNYuI1C uNyygwQHpEAb6wMz90wbYay1JLxWjnrsJFRkN71MEofI042mm4kuMK/Fhm/XvHePaIyV jDDRaqMRZUJUf3C6GQVpOd6PtaofQkIyTJj5N9FvpVz9l+yAs1KTxNVJ6fO/nW+qUO9x Nr3Q== X-Gm-Message-State: ACrzQf3mseX6BGaxAlavbJRsEWQgWbF+/7Ck66K+3/c3wj0+e2Cv9eeB OgFvj+V0uyuwt3p689ozevrZUO5soXGqaYbwhUI= X-Google-Smtp-Source: AMsMyM6KpgUJALvtrP1h898uE8ZzX5tDFfg9e1NYkqrT1eDkEBG/sUoBshkDuibJFInEpqY2FeTloA== X-Received: by 2002:a17:906:fe46:b0:730:ca2b:cb7b with SMTP id wz6-20020a170906fe4600b00730ca2bcb7bmr388691ejb.703.1664410849627; Wed, 28 Sep 2022 17:20:49 -0700 (PDT) Received: from plus1.kohl.home (ip5b434222.dynamic.kabel-deutschland.de. [91.67.66.34]) by smtp.gmail.com with ESMTPSA id 2-20020a170906318200b0078116c361d9sm3125348ejy.10.2022.09.28.17.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:20:49 -0700 (PDT) From: =?UTF-8?q?Christian=20Kohlsch=C3=BCtter?= To: u-boot@lists.denx.de Cc: =?UTF-8?q?Christian=20Kohlsch=C3=BCtter?= Subject: [PATCH] common: board_f: Fix crash in print_cpuinfo Date: Thu, 29 Sep 2022 00:20:07 +0000 Message-Id: <20220929002008.9177-1-christian@kohlschutter.com> X-Mailer: git-send-email 2.36.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean With CONFIG_DISPLAY_CPUINFO=y and CONFIG_CPU=y, the initcall sequence may fail (and therefore hang the boot process) with an -ENODEV (err=-19) error code. This is caused by either cpu_get_current_dev/cpu_get_desc failing to return CPU information. If no CPU information can be obtained, fall-back to the non-Driver Model implementation of print_cpuinfo. Signed-off-by: Christian Kohlschütter --- common/board_f.c | 14 +++++++++----- include/init.h | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index 18e2246733..0656845e24 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -182,9 +182,12 @@ static int print_resetinfo(void) } #endif -#if defined(CONFIG_DISPLAY_CPUINFO) && CONFIG_IS_ENABLED(CPU) -static int print_cpuinfo(void) +#if defined(CONFIG_DISPLAY_CPUINFO) +static int print_cpuinfo_0(void) { +#if !CONFIG_IS_ENABLED(CPU) + return print_cpuinfo(); +#else struct udevice *dev; char desc[512]; int ret; @@ -193,19 +196,20 @@ static int print_cpuinfo(void) if (!dev) { debug("%s: Could not get CPU device\n", __func__); - return -ENODEV; + return print_cpuinfo(); // fallback } ret = cpu_get_desc(dev, desc, sizeof(desc)); if (ret) { debug("%s: Could not get CPU description (err = %d)\n", dev->name, ret); - return ret; + return print_cpuinfo(); // fallback } printf("CPU: %s\n", desc); return 0; +#endif } #endif @@ -866,7 +870,7 @@ static const init_fnc_t init_sequence_f[] = { print_resetinfo, #endif #if defined(CONFIG_DISPLAY_CPUINFO) - print_cpuinfo, /* display cpu info (and speed) */ + print_cpuinfo_0, /* display cpu info (and speed) */ #endif #if defined(CONFIG_DTB_RESELECT) embedded_dtb_select, diff --git a/include/init.h b/include/init.h index 7b8f62c121..9837c22b75 100644 --- a/include/init.h +++ b/include/init.h @@ -210,14 +210,13 @@ int pci_init(void); */ int init_cache_f_r(void); -#if !CONFIG_IS_ENABLED(CPU) /** * print_cpuinfo() - Display information about the CPU * * Return: 0 if OK, -ve on error */ int print_cpuinfo(void); -#endif + int timer_init(void); #if defined(CONFIG_DTB_RESELECT) -- 2.36.2