From patchwork Mon Aug 14 08:54:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 135245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2621849vqi; Mon, 14 Aug 2023 02:25:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFUWeEkXFTEu9RmY02Fuy2rQVzEvU2TLE+otRPX0R2nbeYQZ8UzlMZzG5E7b4ToxUJ3SUq X-Received: by 2002:aa7:c491:0:b0:525:6d6e:ed4a with SMTP id m17-20020aa7c491000000b005256d6eed4amr451006edq.23.1692005151658; Mon, 14 Aug 2023 02:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692005151; cv=none; d=google.com; s=arc-20160816; b=O19gjAXApfWWFhLjg6BwO5BSZopkoANgLPtiEKof8OQIopIvThxm7T4JXcZBVF0aqJ cnQTQ2zVzWaQ0LVo898zy6E8V+c9Xmpsn9A1O45ww3dD77/mNw0vRTn0mHyFyefsrMWn QhPNgzUt0C1/37lOSZpYSDsAIkqwnaKlKT3l7xoiJ33QaT2oH4INa5za0GSvIpRiREwe JdUWkj2Dn15qgsOkJoQF5KmtoC651G5bEWynk6ZFp7sdvFSw/FvxAl1Xaos7BoA2CVpX W/Piz77VHnayz8qJPIPLUrNoB3dVnTMBZlZ4RvDCRXKN1qowIvZK/MAefYNot5ulUtDq e1YA== 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=4TtY+1BKk2VzsdzxqCUP6yDH6um+f9/iPyUkn07hGk0=; fh=vmKIJtcbtoHWhyuxI4oEq8r1SWZ2V9Rrbp1Orw2DxqA=; b=drhYF5/nt7aJ81d2cWTQzouCt+Qy+T22u1IxEAr+4ItDboygIohkEdnpV/+qdI2Jwj smzU6xro1v5ISS2tovPQfXaNsmW0hAsyfPIgqZ3wvogHgXPRDECzs7P1kLMHzSByUsBF joNFilUwMT41HdppFEm7ryUHwW8I3N6scKprT7RpnaY+HNNfdNbJGLIxPHYd2xGUwVuO Kd3ukD+rGaJ9hAdTMWtWzZ+loMC2nNKzzD2fYnxxedUULbPSuHfIAP0tFc7TtKmVWgZo F+Vfce5oaR0YvrcMM5xCz2CSRpEg768BN5efopGMd660HU/V0lwzGxL9ryhnAVw5bU3U jFWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=l72TkYrQ; 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 ca20-20020aa7cd74000000b0052337190ea8si7318205edb.281.2023.08.14.02.25.28; Mon, 14 Aug 2023 02:25:51 -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=l72TkYrQ; 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 S235667AbjHNI4w (ORCPT + 99 others); Mon, 14 Aug 2023 04:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234789AbjHNIyl (ORCPT ); Mon, 14 Aug 2023 04:54:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35EBC91 for ; Mon, 14 Aug 2023 01:54:40 -0700 (PDT) Message-ID: <20230814085114.482126235@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1692003278; 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=4TtY+1BKk2VzsdzxqCUP6yDH6um+f9/iPyUkn07hGk0=; b=l72TkYrQwV6LW8hQZt71/dDvRtb7NxF8HOES3gDb5v2Mz8640IdnZcrD7toGSuTZr78Mx9 Jpcsiyv8yWlGkBOzntESGws+vLxQVHNqBl+8iDfrqifsrhAc9deAyzPH0SU9VLivfliYZ0 9wgsZGJ9RZVoCkPa4QdJiRBxDpOVduWu/DgEKX8WCw395qOqkrZmuaD68xi3P37FHoap9I hH+k50kjTH7+SaEK/eV3dfZIjUgF9nQMPvw+kij3skPnG9ghjhphN6pcgMzoMW1iYlgh+X xy4IzVvEHvgxRvHCExzuNYeL5GrFWIGQUbEtTOYVpyO0Kv5qcqYXugAwv26IzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1692003278; 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=4TtY+1BKk2VzsdzxqCUP6yDH6um+f9/iPyUkn07hGk0=; b=Z1HnqMzmn7qUdropDSVkabzYBHAiuvagJseIA5kpwcROSQTee7BYwnWybyz2x7Ppw2WPG/ uVLN0uFV1EYQ48Cw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Michael Kelley , Wei Liu , Pu Wen , Qiuxu Zhuo , Sohil Mehta Subject: [patch V4 41/41] x86/apic/uv: Remove the private leaf 0xb parser References: <20230814085006.593997112@linutronix.de> MIME-Version: 1.0 Date: Mon, 14 Aug 2023 10:54:38 +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 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: 1774195993465490530 X-GMAIL-MSGID: 1774195993465490530 The package shift has been already evaluated by the early CPU init. Put the mindless copy right next to the original leaf 0xb parser. Signed-off-by: Thomas Gleixner Tested-by: Juergen Gross Tested-by: Sohil Mehta Tested-by: Michael Kelley --- arch/x86/include/asm/topology.h | 5 +++ arch/x86/kernel/apic/x2apic_uv_x.c | 52 ++++++------------------------------- 2 files changed, 14 insertions(+), 43 deletions(-) --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -126,6 +126,11 @@ static inline unsigned int topology_get_ return x86_topo_system.dom_size[dom]; } +static inline unsigned int topology_get_domain_shift(enum x86_topology_domains dom) +{ + return dom == TOPO_SMT_DOMAIN ? 0 : x86_topo_system.dom_shifts[dom - 1]; +} + extern const struct cpumask *cpu_coregroup_mask(int cpu); extern const struct cpumask *cpu_clustergroup_mask(int cpu); --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -241,54 +241,20 @@ static void __init uv_tsc_check_sync(voi is_uv(UV3) ? sname.s3.field : \ undef) -/* [Copied from arch/x86/kernel/cpu/topology.c:detect_extended_topology()] */ - -#define SMT_LEVEL 0 /* Leaf 0xb SMT level */ -#define INVALID_TYPE 0 /* Leaf 0xb sub-leaf types */ -#define SMT_TYPE 1 -#define CORE_TYPE 2 -#define LEAFB_SUBTYPE(ecx) (((ecx) >> 8) & 0xff) -#define BITS_SHIFT_NEXT_LEVEL(eax) ((eax) & 0x1f) - -static void set_x2apic_bits(void) -{ - unsigned int eax, ebx, ecx, edx, sub_index; - unsigned int sid_shift; - - cpuid(0, &eax, &ebx, &ecx, &edx); - if (eax < 0xb) { - pr_info("UV: CPU does not have CPUID.11\n"); - return; - } - - cpuid_count(0xb, SMT_LEVEL, &eax, &ebx, &ecx, &edx); - if (ebx == 0 || (LEAFB_SUBTYPE(ecx) != SMT_TYPE)) { - pr_info("UV: CPUID.11 not implemented\n"); - return; - } - - sid_shift = BITS_SHIFT_NEXT_LEVEL(eax); - sub_index = 1; - do { - cpuid_count(0xb, sub_index, &eax, &ebx, &ecx, &edx); - if (LEAFB_SUBTYPE(ecx) == CORE_TYPE) { - sid_shift = BITS_SHIFT_NEXT_LEVEL(eax); - break; - } - sub_index++; - } while (LEAFB_SUBTYPE(ecx) != INVALID_TYPE); - - uv_cpuid.apicid_shift = 0; - uv_cpuid.apicid_mask = (~(-1 << sid_shift)); - uv_cpuid.socketid_shift = sid_shift; -} - static void __init early_get_apic_socketid_shift(void) { + unsigned int sid_shift = topology_get_domain_shift(TOPO_ROOT_DOMAIN); + if (is_uv2_hub() || is_uv3_hub()) uvh_apicid.v = uv_early_read_mmr(UVH_APICID); - set_x2apic_bits(); + if (sid_shift) { + uv_cpuid.apicid_shift = 0; + uv_cpuid.apicid_mask = (~(-1 << sid_shift)); + uv_cpuid.socketid_shift = sid_shift; + } else { + pr_info("UV: CPU does not have valid CPUID.11\n"); + } pr_info("UV: apicid_shift:%d apicid_mask:0x%x\n", uv_cpuid.apicid_shift, uv_cpuid.apicid_mask); pr_info("UV: socketid_shift:%d pnode_mask:0x%x\n", uv_cpuid.socketid_shift, uv_cpuid.pnode_mask);