From patchwork Wed Aug 9 20:36:13 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: 133499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c765:0:b0:3f4:cb6f:45e2 with SMTP id a5csp112478vqu; Wed, 9 Aug 2023 13:44:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa4+TD+dtDNfqSnd238Lb+/smY/q8ziKrx+ZAcVQO8kfT/n0BjLMy1za0FK5EcObPI018a X-Received: by 2002:a17:907:7d8a:b0:978:2b56:d76e with SMTP id oz10-20020a1709077d8a00b009782b56d76emr49325ejc.12.1691613888159; Wed, 09 Aug 2023 13:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691613888; cv=none; d=google.com; s=arc-20160816; b=DJFmZBv9LOjrfjcLYMdV7xK6OReWnhYYqYuhLsuhC5DdOn+4QPaonJdLlVIEKE8FH1 qBK1fxLJk7xqmD7UWY9U87ZS6LS29ky4eRqS02bJl14wu/dcnJr8jL8CjrGS7TNxtS3M u0bSeCz2yV6aLoxmJQCLkotFD8Gl+nbEL62Jf34MPeqIxqDSUK9ESGQQR2QfpzY8gaOA V7eQsvV5xbyk23fELMGmx/3sqxKEt9ls9mUJUO8o1WjwEAd/htbGf2+X8g4NFEJamS+O H5u3VI4so60xHuOny6O9XlC0RIUe6XRn7+dWXOTWwGAQbEk2ipWLHl81+tTWrDZ0YsUm +gPA== 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:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=SQaraEsbSixXoPnRx04X9hn4T2+ucJufNUse7jO/W+Y=; fh=jBwjuriIPWA1lnCf5oMMiNAPpgGE0iGPmBzZMsd85oQ=; b=XRWhP2xZcjtWz5zQFg2gm6CxzZikAHzxWSliQYDzrdiHGPNeD7OgLU+Ekx9CfRXBnx WfEz7RwpVBWoLH35ZVvxRcfA4yxnoEEgko5d/3RdlDNROvmw5TAmH3D1GgLLE0v0daYC PO31ZR25qmoNc+3nSfURxFUt7zsLjxFsDs3K/mnWleQ2aLh/1yapSxW5FoI5xDpSxT55 VTC8U8gviwyLw8Trffil3EtedtfB2oN/saJ4WAX8nM/uwTt9BH0m2XhHMNO/oWTZTuNM JZ0iREykMbMqpbeV6g3dagVwyrjhjjmKt5yR1HANKNf1YAcDZZJjlneKEjZACx5ZtoIP cOZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LZmdt7Fz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 t18-20020a1709063e5200b0099ce23c3a71si4755361eji.1041.2023.08.09.13.44.24; Wed, 09 Aug 2023 13:44:48 -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=LZmdt7Fz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S234582AbjHIUhA (ORCPT + 99 others); Wed, 9 Aug 2023 16:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234597AbjHIUgT (ORCPT ); Wed, 9 Aug 2023 16:36:19 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C8AC2683; Wed, 9 Aug 2023 13:36:15 -0700 (PDT) Date: Wed, 09 Aug 2023 20:36:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691613374; 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; bh=SQaraEsbSixXoPnRx04X9hn4T2+ucJufNUse7jO/W+Y=; b=LZmdt7FzPYPnopC6gEt3PjRGca4XrEo7YKDpx4SyVeLZ2ZBWDUshY8HhoRWZ3BL+woJZDq zmtATF2IqkJPgIsZuANwrpOPbktJ6MvLiV5JeL4T1ta55nkJ/Fd1f+u6mFdF5r7uW6lufR F3Cg4YDEFq2tkuMAmlf62vOWnnMnRdyYWGpA3EZquaQSlkkqwxIRZgsFqSW+FG5ATn1bTm VWrxjjI5F/5uQhJvOWxLpUpCqMQlsLgpP/FL2jCNfXIUIBt2N3t79JEEKQVZU3jr5rEIjZ 2P+8oV+YoKhOyzxH8GI1kqPomfYHh5UT4/rgvtRs1CsYm44ZoHnih4X4PLf49Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691613374; 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; bh=SQaraEsbSixXoPnRx04X9hn4T2+ucJufNUse7jO/W+Y=; b=vewH+6vINzIaRQr16xr+LNA1e3zCfDlvlF+cD04mO4c+7K5zrARgOjt7rfHR49yaokU04P r0O4q433T8PjKTDA== 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/apic] x86/apic/x2apic: Share all common IPI functions Cc: Thomas Gleixner , Dave Hansen , "Peter Zijlstra (Intel)" , Michael Kelley , Sohil Mehta , Juergen Gross , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169161337366.27769.13093753809701907931.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,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: INBOX X-GMAIL-THRID: 1773771021988856693 X-GMAIL-MSGID: 1773785724441441480 The following commit has been merged into the x86/apic branch of tip: Commit-ID: 96ae35c75bdd8a327c686cf39030d8ed7f82f558 Gitweb: https://git.kernel.org/tip/96ae35c75bdd8a327c686cf39030d8ed7f82f558 Author: Thomas Gleixner AuthorDate: Tue, 08 Aug 2023 15:04:07 -07:00 Committer: Dave Hansen CommitterDate: Wed, 09 Aug 2023 11:58:29 -07:00 x86/apic/x2apic: Share all common IPI functions Yet more copy and pasta gone. Signed-off-by: Thomas Gleixner Signed-off-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) Tested-by: Michael Kelley Tested-by: Sohil Mehta Tested-by: Juergen Gross # Xen PV (dom0 and unpriv. guest) --- arch/x86/kernel/apic/local.h | 4 +- arch/x86/kernel/apic/x2apic_cluster.c | 10 +------ arch/x86/kernel/apic/x2apic_phys.c | 44 +++++++++++++------------- arch/x86/kernel/apic/x2apic_uv_x.c | 14 +------- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/arch/x86/kernel/apic/local.h b/arch/x86/kernel/apic/local.h index 98cfe78..a250675 100644 --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -19,8 +19,10 @@ void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest); unsigned int x2apic_get_apic_id(unsigned long id); u32 x2apic_set_apic_id(unsigned int id); int x2apic_phys_pkg_id(int initial_apicid, int index_msb); + +void x2apic_send_IPI_all(int vector); +void x2apic_send_IPI_allbutself(int vector); void x2apic_send_IPI_self(int vector); -void __x2apic_send_IPI_shorthand(int vector, u32 which); /* IPI */ diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 355da47..afd2676 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -83,16 +83,6 @@ x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); } -static void x2apic_send_IPI_allbutself(int vector) -{ - __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLBUT); -} - -static void x2apic_send_IPI_all(int vector) -{ - __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLINC); -} - static u32 x2apic_calc_apicid(unsigned int cpu) { return x86_cpu_to_logical_apicid[cpu]; diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c index 2c9a884..c40d19b 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -81,16 +81,36 @@ static void __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); } -static void x2apic_send_IPI_allbutself(int vector) +static void __x2apic_send_IPI_shorthand(int vector, u32 which) +{ + unsigned long cfg = __prepare_ICR(which, vector, 0); + + /* x2apic MSRs are special and need a special fence: */ + weak_wrmsr_fence(); + native_x2apic_icr_write(cfg, 0); +} + +void x2apic_send_IPI_allbutself(int vector) { __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLBUT); } -static void x2apic_send_IPI_all(int vector) +void x2apic_send_IPI_all(int vector) { __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLINC); } +void x2apic_send_IPI_self(int vector) +{ + apic_write(APIC_SELF_IPI, vector); +} + +void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) +{ + unsigned long cfg = __prepare_ICR(0, vector, dest); + native_x2apic_icr_write(cfg, apicid); +} + static int x2apic_phys_probe(void) { if (!x2apic_mode) @@ -111,21 +131,6 @@ int x2apic_apic_id_valid(u32 apicid) return 1; } -void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) -{ - unsigned long cfg = __prepare_ICR(0, vector, dest); - native_x2apic_icr_write(cfg, apicid); -} - -void __x2apic_send_IPI_shorthand(int vector, u32 which) -{ - unsigned long cfg = __prepare_ICR(which, vector, 0); - - /* x2apic MSRs are special and need a special fence: */ - weak_wrmsr_fence(); - native_x2apic_icr_write(cfg, 0); -} - unsigned int x2apic_get_apic_id(unsigned long id) { return id; @@ -141,11 +146,6 @@ int x2apic_phys_pkg_id(int initial_apicid, int index_msb) return initial_apicid >> index_msb; } -void x2apic_send_IPI_self(int vector) -{ - apic_write(APIC_SELF_IPI, vector); -} - static struct apic apic_x2apic_phys __ro_after_init = { .name = "physical x2apic", diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index f0580a6..a8ed237 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -25,6 +25,8 @@ #include #include +#include "local.h" + static enum uv_system_type uv_system_type; static int uv_hubbed_system; static int uv_hubless_system; @@ -783,11 +785,6 @@ static int uv_apic_id_valid(u32 apicid) return 1; } -static unsigned int x2apic_get_apic_id(unsigned long id) -{ - return id; -} - static u32 set_apic_id(unsigned int id) { return id; @@ -803,11 +800,6 @@ static int uv_phys_pkg_id(int initial_apicid, int index_msb) return uv_read_apic_id() >> index_msb; } -static void uv_send_IPI_self(int vector) -{ - apic_write(APIC_SELF_IPI, vector); -} - static int uv_probe(void) { return apic == &apic_x2apic_uv_x; @@ -840,7 +832,7 @@ static struct apic apic_x2apic_uv_x __ro_after_init = { .send_IPI_mask_allbutself = uv_send_IPI_mask_allbutself, .send_IPI_allbutself = uv_send_IPI_allbutself, .send_IPI_all = uv_send_IPI_all, - .send_IPI_self = uv_send_IPI_self, + .send_IPI_self = x2apic_send_IPI_self, .wakeup_secondary_cpu = uv_wakeup_secondary,