Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2424419pxb; Mon, 11 Jan 2021 09:16:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEwbvvqnPdIFw3oa+JnMxTZOn9OSxzCaJAZdzhEz5WwRUZfZ57rf41rJTS8KKRTddldaKb X-Received: by 2002:a50:e882:: with SMTP id f2mr313534edn.76.1610385364786; Mon, 11 Jan 2021 09:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610385364; cv=none; d=google.com; s=arc-20160816; b=XOPIAss8J5CaN36o/YAOMuNfQ0JutM7zCSL56V/B8t07Z4OOuTmm6eA3l8YInIU0N0 BgDncXFx4y3eyJHlaEjWYN/LaEH7Pfwk8Tp+pHNszwUimT7sQ2IC7peuAzCy26DPairt JTbyTH+X0cTU3e+0sd92WZ6Qn6jcKOuMHPlvLnjhkCGtYBNEd6X0ACupJvnbdv0rg75J iZMObOBthtI4pB7pXLjlCK6ly1DbU/zHi6K5xITSasQh2tFc//hfpL67BaO3I8+YwBAk MgcbS7+iQnJcLc0fhN1mJx2xbDBYz+/2tEVByDb1gOa8CyjDNfHiStNMDUu2bObdygTF PoUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=e0NGXTukN1O0YEDVvnQDigG6v4Q3Ib9nyZs600mOPVE=; b=l+qvg/odO8tF9pQpPCP1zMgK+GfzjRuw2Sk9VaMv6xRPMh11L22ujeuMJsnjm0jm9f 6SESkM21A8porD0YOCxt3Slro3NLO7nNV+ljyDcoa4XvtItx4JtE3TVZnib0cSx3oG5L OhtAnDBO7FfM9Io41aSemMuHMygAyFab7agmzXjVXhDfThtPqp265yemSoT36utm5u2/ XM/FHtFsBpJO6bUSQsiflxEcblaF2rQLiEUk0hMr35caglESrvuaItvQX98SOfcgF4Wo hPkaIGR0CMkWxxg6JZn0I731gk3Fj1+dW7YPg6lHSLbUEwoLiQcFOw772BA1QOMUizsU y4Bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn4si25792ejc.376.2021.01.11.09.15.41; Mon, 11 Jan 2021 09:16:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389367AbhAKRMZ (ORCPT + 99 others); Mon, 11 Jan 2021 12:12:25 -0500 Received: from foss.arm.com ([217.140.110.172]:33228 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389352AbhAKRMW (ORCPT ); Mon, 11 Jan 2021 12:12:22 -0500 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 11A7613A1; Mon, 11 Jan 2021 09:11:37 -0800 (PST) Received: from e120877-lin.cambridge.arm.com (e120877-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 47FED3F73C; Mon, 11 Jan 2021 09:11:36 -0800 (PST) From: vincent.donnefort@arm.com To: peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org Cc: valentin.schneider@arm.com, Vincent Donnefort Subject: [PATCH 4/4] cpu/hotplug: Fix CPU down rollback Date: Mon, 11 Jan 2021 17:10:47 +0000 Message-Id: <1610385047-92151-5-git-send-email-vincent.donnefort@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610385047-92151-1-git-send-email-vincent.donnefort@arm.com> References: <1610385047-92151-1-git-send-email-vincent.donnefort@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Donnefort After the AP brought itself down to CPUHP_TEARDOWN_CPU, the BP will finish the job. The steps left are as followed: +--------------------+ | CPUHP_TEARDOWN_CPU | -> If fails state is CPUHP_TEARDOWN_CPU +--------------------+ | ATOMIC STATES | -> Cannot Fail +--------------------+ | CPUHP_BRINGUP_CPU | -> Cannot fail +--------------------+ | ... | | ... | -> Can fail and rollback | CPUHP_OFFLINE | +--------------------+ There are, in case of failure two possibilities: 1. Failure in CPUHP_TEARDOWN_CPU, then st->state will still be CPUHP_TEARDOWN_CPU 2. Failure between CPUHP_OFFLINE and CPUHP_BRINGUP_CPU. For 2. The rollback will always run in the CPUHP_BRINGUP_CPU bringup callback (bringup_cpu()) which kicks the AP back on. The latter will then end-up setting st->state to CPUHP_AP_ONLINE_IDLE. Checking for CPUHP_AP_ONLINE_IDLE allows then to rollback in all cases. Signed-off-by: Vincent Donnefort --- kernel/cpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index aebec3a..8b3f84e 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1078,7 +1078,14 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, * to do the further cleanups. */ ret = cpuhp_down_callbacks(cpu, st, target); - if (ret && st->state == CPUHP_TEARDOWN_CPU && st->state < prev_state) { + if (ret && (st->state == CPUHP_AP_ONLINE_IDLE || + st->state == CPUHP_TEARDOWN_CPU) && + st->state < prev_state) { + /* + * After an error the state can be either: + * - CPUHP_TEARDOWN_CPU if this step failed. + * - CPUHP_AP_ONLINE_IDLE if any other failed. + */ cpuhp_reset_state(st, prev_state); __cpuhp_kick_ap(st); } -- 2.7.4