Message ID | 20230913163823.7880-32-james.morse@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220672vqx; Wed, 13 Sep 2023 09:52:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrYB/RRry30tJVDQrk1xhaDJk1ancLG/+0wcVa+j2M2rGVL7+6iO/0OSAzQ/oiu0kQXXKv X-Received: by 2002:a05:6a00:b93:b0:68f:d35d:217e with SMTP id g19-20020a056a000b9300b0068fd35d217emr3696098pfj.2.1694623959495; Wed, 13 Sep 2023 09:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623959; cv=none; d=google.com; s=arc-20160816; b=ZTUiS8i4jA9J6JCEUQieSBUO/ummc3BO0NQ7X2JkawqD+6LSQw3e2fIGSaU2KL7qLw j7WUZbgqBej9xfFvdmdN1X1Cz5oIhhooq2x53wnCmxdb1pOGi+STzstY/OHR13rQJYZL /6CEJx0zxY0WQSoR5xoTN23BL5G1rLszBczbpP07VOSpKZP+h9B7XBGLAuahahlwGgh9 wZJL09kFjBpnMhiVB4vPff/HHiyIyF7RX3FAKZtrF/jnTfMTq2CbtE0B63wT6FvcAu3D jBfagBk3/HfU85nSkxpDN/HXW4wfyYnI7ffTZs0obnKikSVQ/iBiMSJ+bib4dXmd+Grm DGuA== 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=IvnqDn4icDlfnv3u50enCSsoirJyRF6d/xs/RkITuSo=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=l/GYNjom3MlwR66mRJidDwGjFYvr8oZqR2BL4VmH838WUEvrT0u2iZRIxX0qHEM5oT jj1kzuEJbChxvD3fmwY1tnsmonWzXdAm7bEVwmXfpWlpYmoXFno9yfLu9ajte0UEBhIB duPYIdHQL8ikQtuio3HsIwqh+hHrdIgk2L+u/01VpH8jTZIHycJD+ZEfJ5pCfjdcVmIt s3miaETJK3Z2YXgfMkx+y0ZNh4tgxUp9nHQW13OcNkxnvUQOftP4tVyLnUawhv8QXn24 LCNBx3VpH7O5cVBEBBKz2DkhqQcDhIZogMejaoRrNczaH4V3LLMffCFCYB8iw1YctmCe 0HUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id p16-20020a056a000b5000b0069026fd5a29si59234pfo.19.2023.09.13.09.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 7913E8034173; Wed, 13 Sep 2023 09:42:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231426AbjIMQmD (ORCPT <rfc822;pwkd43@gmail.com> + 35 others); Wed, 13 Sep 2023 12:42:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231434AbjIMQlP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 12:41:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95E821FF6; Wed, 13 Sep 2023 09:39:55 -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 4D1701007; Wed, 13 Sep 2023 09:40:32 -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 5292E3F5A1; Wed, 13 Sep 2023 09:39:53 -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 31/35] arm64: psci: Ignore DENIED CPUs Date: Wed, 13 Sep 2023 16:38:19 +0000 Message-Id: <20230913163823.7880-32-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:10 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942012855209330 X-GMAIL-MSGID: 1776942012855209330 |
Series |
ACPI/arm64: add support for virtual cpuhotplug
|
|
Commit Message
James Morse
Sept. 13, 2023, 4:38 p.m. UTC
From: Jean-Philippe Brucker <jean-philippe@linaro.org> When a CPU is marked as disabled, but online capable in the MADT, PSCI applies some firmware policy to control when it can be brought online. PSCI returns DENIED to a CPU_ON request if this is not currently permitted. The OS can learn the current policy from the _STA enabled bit. Handle the PSCI DENIED return code gracefully instead of printing an error. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> [ morse: Rewrote commit message ] Signed-off-by: James Morse <james.morse@arm.com> --- arch/arm64/kernel/psci.c | 2 +- arch/arm64/kernel/smp.c | 3 ++- drivers/firmware/psci/psci.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-)
Comments
On Wed, 13 Sep 2023 16:38:19 +0000 James Morse <james.morse@arm.com> wrote: > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > When a CPU is marked as disabled, but online capable in the MADT, PSCI > applies some firmware policy to control when it can be brought online. > PSCI returns DENIED to a CPU_ON request if this is not currently > permitted. The OS can learn the current policy from the _STA enabled bit. > > Handle the PSCI DENIED return code gracefully instead of printing an > error. Specification reference would be good particularly as it's only been added as a possibility fairly recently. > > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> > [ morse: Rewrote commit message ] > Signed-off-by: James Morse <james.morse@arm.com> > --- > arch/arm64/kernel/psci.c | 2 +- > arch/arm64/kernel/smp.c | 3 ++- > drivers/firmware/psci/psci.c | 2 ++ > 3 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c > index 29a8e444db83..4fcc0cdd757b 100644 > --- a/arch/arm64/kernel/psci.c > +++ b/arch/arm64/kernel/psci.c > @@ -40,7 +40,7 @@ static int cpu_psci_cpu_boot(unsigned int cpu) > { > phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry); > int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry); > - if (err) > + if (err && err != -EPROBE_DEFER) Hmm. EPROBE_DEFER has very specific meaning around driver requesting a retry when some other bit of the system has finished booting. I'm not sure it's a good idea for this use case. Maybe just keep to EPERM as psci_to_linux_errno() will return anyway. Seems valid to me, or is the requirement to use EPROBE_DEFER coming from further up the stack? > pr_err("failed to boot CPU%d (%d)\n", cpu, err); > > return err; > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 8c8f55721786..e958db987665 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -124,7 +124,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) > /* Now bring the CPU into our world */ > ret = boot_secondary(cpu, idle); > if (ret) { > - pr_err("CPU%u: failed to boot: %d\n", cpu, ret); > + if (ret != -EPROBE_DEFER) > + pr_err("CPU%u: failed to boot: %d\n", cpu, ret); > return ret; > } > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index d9629ff87861..f7ab3fed3528 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -218,6 +218,8 @@ static int __psci_cpu_on(u32 fn, unsigned long cpuid, unsigned long entry_point) > int err; > > err = invoke_psci_fn(fn, cpuid, entry_point, 0); > + if (err == PSCI_RET_DENIED) > + return -EPROBE_DEFER; > return psci_to_linux_errno(err); > } >
On 9/15/23 02:01, Jonathan Cameron wrote: > On Wed, 13 Sep 2023 16:38:19 +0000 > James Morse <james.morse@arm.com> wrote: > >> From: Jean-Philippe Brucker <jean-philippe@linaro.org> >> >> When a CPU is marked as disabled, but online capable in the MADT, PSCI >> applies some firmware policy to control when it can be brought online. >> PSCI returns DENIED to a CPU_ON request if this is not currently >> permitted. The OS can learn the current policy from the _STA enabled bit. >> >> Handle the PSCI DENIED return code gracefully instead of printing an >> error. > > Specification reference would be good particularly as it's only been > added as a possibility fairly recently. > https://developer.arm.com/documentation/den0022/f/?lang=en page-58 It seems DENIED is the best matched indicator. >> >> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> >> [ morse: Rewrote commit message ] >> Signed-off-by: James Morse <james.morse@arm.com> >> --- >> arch/arm64/kernel/psci.c | 2 +- >> arch/arm64/kernel/smp.c | 3 ++- >> drivers/firmware/psci/psci.c | 2 ++ >> 3 files changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c >> index 29a8e444db83..4fcc0cdd757b 100644 >> --- a/arch/arm64/kernel/psci.c >> +++ b/arch/arm64/kernel/psci.c >> @@ -40,7 +40,7 @@ static int cpu_psci_cpu_boot(unsigned int cpu) >> { >> phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry); >> int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry); >> - if (err) >> + if (err && err != -EPROBE_DEFER) > > Hmm. EPROBE_DEFER has very specific meaning around driver requesting a retry > when some other bit of the system has finished booting. > I'm not sure it's a good idea for this use case. Maybe just keep to EPERM > as psci_to_linux_errno() will return anyway. Seems valid to me, or > is the requirement to use EPROBE_DEFER coming from further up the stack? > I agree with Jonathan that -EPERM from psci_to_linux_errno(DENIED) is good enough here. Actually, I think we need to bail from bringing up the CPU once error is raised on psci_ops.cpu_on() and avoid reporting it as error with help of -EPROBE_DEFER. -EPERM can serve the same purpose. > > >> pr_err("failed to boot CPU%d (%d)\n", cpu, err); >> >> return err; >> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c >> index 8c8f55721786..e958db987665 100644 >> --- a/arch/arm64/kernel/smp.c >> +++ b/arch/arm64/kernel/smp.c >> @@ -124,7 +124,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) >> /* Now bring the CPU into our world */ >> ret = boot_secondary(cpu, idle); >> if (ret) { >> - pr_err("CPU%u: failed to boot: %d\n", cpu, ret); >> + if (ret != -EPROBE_DEFER) >> + pr_err("CPU%u: failed to boot: %d\n", cpu, ret); >> return ret; >> } >> >> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c >> index d9629ff87861..f7ab3fed3528 100644 >> --- a/drivers/firmware/psci/psci.c >> +++ b/drivers/firmware/psci/psci.c >> @@ -218,6 +218,8 @@ static int __psci_cpu_on(u32 fn, unsigned long cpuid, unsigned long entry_point) >> int err; >> >> err = invoke_psci_fn(fn, cpuid, entry_point, 0); >> + if (err == PSCI_RET_DENIED) >> + return -EPROBE_DEFER; >> return psci_to_linux_errno(err); >> } >> Thanks, Gavin
diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 29a8e444db83..4fcc0cdd757b 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -40,7 +40,7 @@ static int cpu_psci_cpu_boot(unsigned int cpu) { phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry); int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry); - if (err) + if (err && err != -EPROBE_DEFER) pr_err("failed to boot CPU%d (%d)\n", cpu, err); return err; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 8c8f55721786..e958db987665 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -124,7 +124,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) /* Now bring the CPU into our world */ ret = boot_secondary(cpu, idle); if (ret) { - pr_err("CPU%u: failed to boot: %d\n", cpu, ret); + if (ret != -EPROBE_DEFER) + pr_err("CPU%u: failed to boot: %d\n", cpu, ret); return ret; } diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index d9629ff87861..f7ab3fed3528 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -218,6 +218,8 @@ static int __psci_cpu_on(u32 fn, unsigned long cpuid, unsigned long entry_point) int err; err = invoke_psci_fn(fn, cpuid, entry_point, 0); + if (err == PSCI_RET_DENIED) + return -EPROBE_DEFER; return psci_to_linux_errno(err); }