From patchwork Tue Jun 20 13:00:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 110462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3654721vqr; Tue, 20 Jun 2023 06:13:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+ybMg19vhUZGu1+fQWlsk9e9Ew3aJnKz44KGaOqKKarnt1gJorGnaLIQpguqHi+WaAOqS X-Received: by 2002:a05:6a00:1483:b0:65d:d5cd:6f17 with SMTP id v3-20020a056a00148300b0065dd5cd6f17mr13767941pfu.24.1687266799326; Tue, 20 Jun 2023 06:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687266799; cv=none; d=google.com; s=arc-20160816; b=qYQ+zwLYOT17FyuNpGMKo+kMyXnVUa47W4sdfrQVXFtrKYBWW39i1GZCpEplzmEPDs gWQNOEZxtoOzYS85l23TRdCTOOZmWidIrLtm0AJrd126MTn4s9dowb0os8pYlnp+DuhS 8u4mELgcixHnZ9twcNwNbAze9vy3xOofRrApQYJ311z0g4PSMjiuP7FwCWDcgcTrQLh+ m78Nd3fIADxvVnpS798ty5+EtCNeO/jWSN2ZgqWDjnF9vLAZbitxo0BICn2boWZkfh51 QWb21doU+Ss0qTWm6G9Kse7TgE1UtijXXhNrfAWI0GfKsaGMal+MK1ThytzSoIVDVRU8 K9Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=kGO0N+b4VLs0S7U3M2s5rSy9XlrIT13PxXT3rsvwIKk=; b=wJXlciCU7YkJdtDLxqmJ1fuhhn7IeklCjWITWef/lct+Hp7Ir4lq/Nvm7adliJ+Dpm eMfRsbl/7AHKi8MAz3C3ZsGF6zoXQuFGgiagFZSJqx8bz9J6aBGNdVHR07gQnkpFH69F Q9XhbxOgirS4saOlngvNEFlOrjdFOmy2mI2Rpzi+6X6oBtCfv5WgunjL2flYyMHyARIq Mmfft+YVqh5EL1jVMoFoiqaTGB61b71NqmtgREv67LxcYsClFVBb3DO0m3bVNH+H2SN9 4SCWDoj/iAOVTwwj4au5vEKzOE28i+qYGXnjfM8/KFpcx7QeoISi0zoh290u7zAnsh3+ h+iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DOzLFvsh; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k191-20020a636fc8000000b0054fe20a34b2si1606467pgc.850.2023.06.20.06.13.04; Tue, 20 Jun 2023 06:13:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DOzLFvsh; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232753AbjFTNB1 (ORCPT + 99 others); Tue, 20 Jun 2023 09:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232748AbjFTNBP (ORCPT ); Tue, 20 Jun 2023 09:01:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70CA519A1; Tue, 20 Jun 2023 06:00:52 -0700 (PDT) Date: Tue, 20 Jun 2023 13:00:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687266051; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGO0N+b4VLs0S7U3M2s5rSy9XlrIT13PxXT3rsvwIKk=; b=DOzLFvshbTzVdh2JY8agz/fN71GEG5OEPiywNaa+KRIp+lsiQWbp2xcjy+JL4AwKNkmxD5 j5Nli93/0/R5cgDzf9nxIARwSDg/ZgtInF+NNr5SLrGuHtkmw5VnR1m72PjHWg5d9NPprk NQz5+hGm5uL4d09mcv21FrwQGe6pGNh3McS+Potdqt+19P4g3TQNS8ic0DJodZH1Xo6w+T 90qM8g5lqbAcasTDGghY7qIT1cUZQLOUPy0JaxVthLVsADYyRHXgDjUyzhhC+oBLHpQE5U tU6ruO15qU9I99Yse1KeI4K0w7sJlls/s4HuRFs8kuwuesTd3n6yjIhTk0Vjlg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687266051; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGO0N+b4VLs0S7U3M2s5rSy9XlrIT13PxXT3rsvwIKk=; b=T2qEEqtsD9ZC2exBe7zz1q1Cnyl9MNRoZs90IgrEctmzlnGaNLl5hYRBCRlXzXv3BPfG0E K6eNpyBJKwNwrLCA== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86/smp: Split sending INIT IPI out into a helper function Cc: Thomas Gleixner , Ashok Raj , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230615193330.551157083@linutronix.de> References: <20230615193330.551157083@linutronix.de> MIME-Version: 1.0 Message-ID: <168726605053.404.8610488673779596542.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768802808722206559?= X-GMAIL-MSGID: =?utf-8?q?1769227471262978394?= The following commit has been merged into the x86/core branch of tip: Commit-ID: 6087dd5e86ff03a8cd4cffdf463a7f457e65cbff Gitweb: https://git.kernel.org/tip/6087dd5e86ff03a8cd4cffdf463a7f457e65cbff Author: Thomas Gleixner AuthorDate: Thu, 15 Jun 2023 22:33:58 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 20 Jun 2023 14:51:47 +02:00 x86/smp: Split sending INIT IPI out into a helper function Putting CPUs into INIT is a safer place during kexec() to park CPUs. Split the INIT assert/deassert sequence out so it can be reused. Signed-off-by: Thomas Gleixner Reviewed-by: Ashok Raj Link: https://lore.kernel.org/r/20230615193330.551157083@linutronix.de --- arch/x86/kernel/smpboot.c | 49 +++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 483df04..b403ead 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -853,47 +853,38 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip) return (send_status | accept_status); } -static int -wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) +static void send_init_sequence(int phys_apicid) { - unsigned long send_status = 0, accept_status = 0; - int maxlvt, num_starts, j; + int maxlvt = lapic_get_maxlvt(); - maxlvt = lapic_get_maxlvt(); - - /* - * Be paranoid about clearing APIC errors. - */ + /* Be paranoid about clearing APIC errors. */ if (APIC_INTEGRATED(boot_cpu_apic_version)) { - if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */ + /* Due to the Pentium erratum 3AP. */ + if (maxlvt > 3) apic_write(APIC_ESR, 0); apic_read(APIC_ESR); } - pr_debug("Asserting INIT\n"); - - /* - * Turn INIT on target chip - */ - /* - * Send IPI - */ - apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT, - phys_apicid); - - pr_debug("Waiting for send to finish...\n"); - send_status = safe_apic_wait_icr_idle(); + /* Assert INIT on the target CPU */ + apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT, phys_apicid); + safe_apic_wait_icr_idle(); udelay(init_udelay); - pr_debug("Deasserting INIT\n"); - - /* Target chip */ - /* Send IPI */ + /* Deassert INIT on the target CPU */ apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid); + safe_apic_wait_icr_idle(); +} - pr_debug("Waiting for send to finish...\n"); - send_status = safe_apic_wait_icr_idle(); +/* + * Wake up AP by INIT, INIT, STARTUP sequence. + */ +static int wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) +{ + unsigned long send_status = 0, accept_status = 0; + int num_starts, j, maxlvt = lapic_get_maxlvt(); + + send_init_sequence(phys_apicid); mb();