From patchwork Mon Jul 17 23:15:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1401807vqt; Mon, 17 Jul 2023 16:25:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlHbblswG0Ss4/WVfRIiqNB4J0xa8ZFYOEM/fbvqhn1TmObzy7UOyvEdLFExsTFb8syY3FmN X-Received: by 2002:a17:903:249:b0:1bb:1e69:28be with SMTP id j9-20020a170903024900b001bb1e6928bemr10071575plh.42.1689636301138; Mon, 17 Jul 2023 16:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636301; cv=none; d=google.com; s=arc-20160816; b=jXBuneieLoxBpBEJiG7zSgtkPneHwiM7Xm4a+SO2udVSd/rzpDDaPBECufOtURxz2j ASKN8sOgE8KmS+0q2gzBrsfAnle/pNtH5SZxtyhODESkD3VEVfPGof8x0C377EPcggPa Kq0Q6rg9iPFjB3utxXGgnYNW2p0/ZCHAZbvqZQP/vBnVMv+UK0PXSqzEWJYX9HLWLjUT QY/8dlRzH61gXBO2pgGQBd1Wg6H2KwIQiPp8RHW6uIv9yQM1C88XOkwE2y93UQycUJ93 W4ypTDygpU4Ar+i1OOvoRelq+snhipszm1xLEDSovxmAVuJOiqJW7L44iXT1JUKMJw8E HpwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=4BLE3+yKPO5gwc0BMR9mix8xtcjKVx9Oe/w05M3UNgo=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=WHis69mmEACCZeo2mW2vVxOI6ZmCX2FA8vZEK44ZXAtxWP2C+YSJhl2RdwdfMHrur5 P76jtGHd3pAV5SsAASB7LWWCEaN8JL5aNQfjws1RdXCtBnKbdjiryxHByubyk/REvYOc 6W+x2lD7dMkY9sMG4mzilp8U4pmT903jkqj/cl1qCcbkcTpUy4l9t9ICgGro/JYNufjr IIZ9uUYoUTxhTWH/L3l12LYA6+eVrD2HOKKw1arNIfhtuPvJmdSl5DPF6OfNJ2jECL8n lhDrM6CgiTR0DZYqyOI+8QZRO6Y2XIRbt6drLsJATGHO5RuHDTuO+OCz8k3AA1x1lx7E bjeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qOxr+TxD; 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 u17-20020a170902e5d100b001b9e3a18270si607410plf.420.2023.07.17.16.24.48; Mon, 17 Jul 2023 16:25:01 -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=qOxr+TxD; 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 S231610AbjGQXSu (ORCPT + 99 others); Mon, 17 Jul 2023 19:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbjGQXSm (ORCPT ); Mon, 17 Jul 2023 19:18:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091AEE4F for ; Mon, 17 Jul 2023 16:17:57 -0700 (PDT) Message-ID: <20230717223225.334807697@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4BLE3+yKPO5gwc0BMR9mix8xtcjKVx9Oe/w05M3UNgo=; b=qOxr+TxD5+bSVnDx7EcALBZ038LlrFO0DGfArAheniYF+ztj6KV158Wd0YQqVelpmmV/UT iNOK9KeYViRVTAsYFWk6gBzq+FFuTRZH88638kX7qEdvX+LgHcKvYoBKildgmXrqdjrta8 QZaykCZ1jC3OPi7yfOPytJnEADZ8HfdvUtJh76EbzTWmTo9a8HnKqfcWdaXBtK46pv94mb 0imusoafVA5qYwgm62wcBJmOXMGjTeWo1MKNzw1Q2cB0bxqfFpEjgpI02e675DTVeGk627 QVcvjYK1cImRR/wl248VNa+DBpa9Fgn3VInl67UO2HMMbAIwuPUwXh5x+FpqMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4BLE3+yKPO5gwc0BMR9mix8xtcjKVx9Oe/w05M3UNgo=; b=cnDdZ0mfDxo2YlLhWMoPIG2qgSk5TCJnk1FcqhpGJyC5cP0NmesbixwZsa3moIeJ+c0JCE 3tiCxmpEZJOjZYBw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 38/58] x86/apic/x2apic: Share all common IPI functions References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:33 +0200 (CEST) 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,T_SCC_BODY_TEXT_LINE 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: 1771712073849339684 X-GMAIL-MSGID: 1771712073849339684 Yet more copy and pasta gone. Signed-off-by: Thomas Gleixner --- 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(-) --- 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 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 */ --- 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 st __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]; --- 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_apici 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", --- 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_ap 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 .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,