[RFC,v2,05/35] drivers: base: Print a warning instead of panic() when register_cpu() fails
Message ID | 20230913163823.7880-6-james.morse@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp73962vqi; Wed, 13 Sep 2023 19:58:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJoXTm7wpMjQrZfD4ZY/Qkf5HK74RM9xv+qOBdhOeUhIcCwLyGq0tWLYQpHO4+LNe4VCHS X-Received: by 2002:a17:902:ce82:b0:1bf:3378:6808 with SMTP id f2-20020a170902ce8200b001bf33786808mr5865891plg.56.1694660329958; Wed, 13 Sep 2023 19:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694660329; cv=none; d=google.com; s=arc-20160816; b=pOXnr+9h0OWkRO7dOCGdtSi7kItWl2sT7MOXCMNimwpbbcFpzi/hKt7Idj937nZmRc 2BqPLcZSnADqO/Ke+eyUTe2EbNRhx9bUoD1cLF8Vv6RcGvcRpnGHZjKSNxppfLTEv4II XUusG8NcPgAfiR5F/sTnHmy3wpVwOhc51kDCOvT96wgHHtj66F/e00fxu7SbP3aeTixp kvEPXyeul+3WirFg/5NLvJOh9xJCTrEO2cn6/zc6IShxCASRn+fuC7c4PrvWinCmxHB3 8eMy5sFSTOh5v9CveWzEnlINFWFkGqxkhpCwjiLbfs8ljvSmDNqyPETgnuMGEQyFJ+Fj oiIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BkPaW2dUUg2OUXqQf5AHAQZwRwuBQlCdS9dHLWUFGK0=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ISr58uvI6r8pUWuAS1RjQrv3ugGDIf9ylvilQH8vX54Zwp7Kv+K2qcufhjigz4qVwY AIcpyzeFxpd750eI++qtNfidZJc6Wc5ayaD2HpJkmoDcJGYy6+JRuzv9Ow029s4syBFU 8UEfJX+I2ArlLKOiY7y5fYkXlVYs7Z3j/Z4700x1gZ3ga769SiijqcMnKcYwmR99TKU5 6jzGH6bGNKCyL3gDeoU8kSv3cOQ40FD9TTt1fGKGYT45HrdMVcahPPc4cwYBIB1j/YsP o1RrdzzUmJDGDtF6EW2UPR1Xgw1qD563ebBwnI/S8KNQzx+rMq5v5AkZ8LKf4JvwN151 vp/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u17-20020a17090341d100b001c20e55153esi763776ple.496.2023.09.13.19.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:58:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 485C181D2D5A; Wed, 13 Sep 2023 09:39:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjIMQjQ (ORCPT <rfc822;pwkd43@gmail.com> + 35 others); Wed, 13 Sep 2023 12:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjIMQjH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 12:39:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4405E1BD0; Wed, 13 Sep 2023 09:39:03 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42F2DC15; Wed, 13 Sep 2023 09:39:40 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 480883F5A1; Wed, 13 Sep 2023 09:39:01 -0700 (PDT) From: James Morse <james.morse@arm.com> To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev Cc: x86@kernel.org, Salil Mehta <salil.mehta@huawei.com>, Russell King <linux@armlinux.org.uk>, Jean-Philippe Brucker <jean-philippe@linaro.org>, jianyong.wu@arm.com, justin.he@arm.com Subject: [RFC PATCH v2 05/35] drivers: base: Print a warning instead of panic() when register_cpu() fails Date: Wed, 13 Sep 2023 16:37:53 +0000 Message-Id: <20230913163823.7880-6-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230913163823.7880-1-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776980149673963819 X-GMAIL-MSGID: 1776980149673963819 |
Series |
ACPI/arm64: add support for virtual cpuhotplug
|
|
Commit Message
James Morse
Sept. 13, 2023, 4:37 p.m. UTC
loongarch, mips, parisc, riscv and sh all print a warning if
register_cpu() returns an error. Architectures that use
GENERIC_CPU_DEVICES call panic() instead.
Errors in this path indicate something is wrong with the firmware
description of the platform, but the kernel is able to keep running.
Downgrade this to a warning to make it easier to debug this issue.
This will allow architectures that switching over to GENERIC_CPU_DEVICES
to drop their warning, but keep the existing behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
---
drivers/base/cpu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On Wed, Sep 13, 2023 at 04:37:53PM +0000, James Morse wrote: > loongarch, mips, parisc, riscv and sh all print a warning if > register_cpu() returns an error. Architectures that use > GENERIC_CPU_DEVICES call panic() instead. > > Errors in this path indicate something is wrong with the firmware > description of the platform, but the kernel is able to keep running. > > Downgrade this to a warning to make it easier to debug this issue. > > This will allow architectures that switching over to GENERIC_CPU_DEVICES > to drop their warning, but keep the existing behaviour. > > Signed-off-by: James Morse <james.morse@arm.com> Assuming other architectures do similar to x86 (which only return the error code from register_cpu()), the only error that would occur here is if device_register() fails, which would be catastophic, and I suspect the system would fail to boot anyway. Downgrading the panic to a warning at least gives us a chance that the system may come up sufficiently to examine what happened, so I think this makes sense: Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
On 9/14/23 02:37, James Morse wrote: > loongarch, mips, parisc, riscv and sh all print a warning if > register_cpu() returns an error. Architectures that use > GENERIC_CPU_DEVICES call panic() instead. > > Errors in this path indicate something is wrong with the firmware > description of the platform, but the kernel is able to keep running. > > Downgrade this to a warning to make it easier to debug this issue. > > This will allow architectures that switching over to GENERIC_CPU_DEVICES > to drop their warning, but keep the existing behaviour. > > Signed-off-by: James Morse <james.morse@arm.com> > --- > drivers/base/cpu.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > index 579064fda97b..d31c936f0955 100644 > --- a/drivers/base/cpu.c > +++ b/drivers/base/cpu.c > @@ -535,14 +535,15 @@ int __weak arch_register_cpu(int cpu) > > static void __init cpu_dev_register_generic(void) > { > - int i; > + int i, ret; > > if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) > return; > > for_each_present_cpu(i) { > - if (arch_register_cpu(i)) > - panic("Failed to register CPU device"); > + ret = arch_register_cpu(i); > + if (ret) > + pr_warn("register_cpu %d failed (%d)\n", i, ret); > } > } > The same warning message has been printed by arch/loongarch/kernel/topology.c::arch_register_cpu(). In order to avoid the duplication, I think the warning message in arch/loongarch needs to be dropped? Thanks, Gavin
On Mon, Sep 18, 2023 at 01:33:37PM +1000, Gavin Shan wrote: > > > On 9/14/23 02:37, James Morse wrote: > > loongarch, mips, parisc, riscv and sh all print a warning if > > register_cpu() returns an error. Architectures that use > > GENERIC_CPU_DEVICES call panic() instead. > > > > Errors in this path indicate something is wrong with the firmware > > description of the platform, but the kernel is able to keep running. > > > > Downgrade this to a warning to make it easier to debug this issue. > > > > This will allow architectures that switching over to GENERIC_CPU_DEVICES > > to drop their warning, but keep the existing behaviour. > > > > Signed-off-by: James Morse <james.morse@arm.com> > > --- > > drivers/base/cpu.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c > > index 579064fda97b..d31c936f0955 100644 > > --- a/drivers/base/cpu.c > > +++ b/drivers/base/cpu.c > > @@ -535,14 +535,15 @@ int __weak arch_register_cpu(int cpu) > > static void __init cpu_dev_register_generic(void) > > { > > - int i; > > + int i, ret; > > if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) > > return; > > for_each_present_cpu(i) { > > - if (arch_register_cpu(i)) > > - panic("Failed to register CPU device"); > > + ret = arch_register_cpu(i); > > + if (ret) > > + pr_warn("register_cpu %d failed (%d)\n", i, ret); > > } > > } > > The same warning message has been printed by arch/loongarch/kernel/topology.c::arch_register_cpu(). > In order to avoid the duplication, I think the warning message in arch/loongarch needs to be dropped? No it doesn't, as far as Loongarch is concerned. Given where this change occurs in the series, it is correct as far as this is concerned. The reason is that this code path can only be reached when CONFIG_GENERIC_CPU_DEVICES is set, which is something the arch has to select. Loongarch doesn't select that until patch 9 in the series, "LoongArch: Switch over to GENERIC_CPU_DEVICES", and that patch is where the warning message in arch/loongarch is removed.
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 579064fda97b..d31c936f0955 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -535,14 +535,15 @@ int __weak arch_register_cpu(int cpu) static void __init cpu_dev_register_generic(void) { - int i; + int i, ret; if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) return; for_each_present_cpu(i) { - if (arch_register_cpu(i)) - panic("Failed to register CPU device"); + ret = arch_register_cpu(i); + if (ret) + pr_warn("register_cpu %d failed (%d)\n", i, ret); } }