From patchwork Tue Feb 13 21:04:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 200608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp809327dyb; Tue, 13 Feb 2024 13:08:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVCVqQ6wl5D8cwLJCGonJwkmrEGxUhxu5Si0tYwV6uzrgDKyR6EJwcykPleRIcf/j+Eqa7r4dJIT7+tFXf9hcNg0bn/DQ== X-Google-Smtp-Source: AGHT+IE7qhDakdGdz71sey2iFuNg8J65vjlnG/D4yu1IgKgUeWdzmwB4pBHMQKJvaiqpYOjmhOJ0 X-Received: by 2002:a05:620a:1a95:b0:783:c7c1:3814 with SMTP id bl21-20020a05620a1a9500b00783c7c13814mr965642qkb.26.1707858526947; Tue, 13 Feb 2024 13:08:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707858526; cv=pass; d=google.com; s=arc-20160816; b=GIlGgDVEVgWkdnXNp4ZpDDQGdxjBCVaPdXa3N9sufvMdGE9hijhrTJ6/J2IVGqQskf Z5Y36NkqPxyq6A4KInPdqQ4ewA7xHvHUHInoa67t4xpgB5KHumsoo1LgaceIfR58rfbe ytI/O8AtLWzBc2A5K+zdOjU5Cjtd+471sBDxCi3BkKPLVR72lfcQoggkhRT4dGEanu9T z8U37KC2loaxL8K/NrOR022ST0SMz41EZg9CQs8uD7AJLfan1pJlRWLUi7LwyHpDDJDE w5rOTU0lxaUFM+K9YKlLazg4iKeIDhKEha245W2sK9D95dDo+gDJ16ZAmMoMZaMveWYX uRUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=XwJ0QaSKJYUlMs7BjkVS3/Pl3Z3VCdhmpQOd6QtZAx0=; fh=3mwa0f8nXUIyf9wUIKEaDrqUpbc7s0fyfcrVeatBbSM=; b=mCGuKrVyjUltTYxHNFgdpC0M6bmDxPww6veWM1I6sMyvpw6OBtugfEeCdrlhM0k3rQ K8UCc8XshDakvxG2a2KX4msX99+oZ/DTV5mFCfROntdXlmqsfuGZsS06g5n47Ql7BZXF aVLqVgSEDd32dtQhwRU9Qk6wcA7AR39DypmtDEDxQevSQiAujLQjL/HU1qMSmhEgbnES nYuJgcsx0nAhY46PC866AGx9oJJxZASkpJCZ3GSb0AkRe1xOWOpWco5f2Q+bRdpQPEzO C6zNtZm9GVPB/aH8CWTbllbXXPFvUIQeYxb/TdpxnPdkFoZEW55+l1ae1P1yqm9d78Bv v4ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MTjlJ759; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fw6zbRxa; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64259-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64259-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCXl5EtkvT+BVhG+r6XlHmpmyOfzFogXtVGmg+JRYJOU1kCI4JdAqeqfCbbm4tp5HL6s2tWMvIziOKp4WTqouOZ1JeKY+w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v21-20020a05620a441500b00785beb523e3si9967533qkp.559.2024.02.13.13.08.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:08:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64259-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MTjlJ759; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fw6zbRxa; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-64259-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64259-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B9E021C22D5D for ; Tue, 13 Feb 2024 21:08:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18EA965BA7; Tue, 13 Feb 2024 21:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MTjlJ759"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fw6zbRxa" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1CD861687 for ; Tue, 13 Feb 2024 21:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858269; cv=none; b=YhVA196MFhbdMSi3XYUc4Fbc3HYMsV2J6zPh8IPDRe0FvucoFcQyjBtgWmhSTU2ysHooieA+NS9/i0gy231rzPWfX5t5SIDrtOlW1H2rGaOyqcuMt81yaXXnqjM36lCBWN7dC0BqTqLmYkTH0L0MJX3bDcLno69RE3mRHNuQlL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858269; c=relaxed/simple; bh=7Cb7/du6kErwh45yPf9eV+BkuCekgKIyTT0FgHiX2Ng=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=dnTChBWBKZbQzCdLVcZPJlFrIaXlIfOjcTonGOI0C73pKScZtixJqmv9YChisrQ90WbLZpVW2PbEU8IlKBhDof63GYHeNDbqxCupy8L0PYsDGlwAkQQ8RJRqO3cZPFN+NbNUCjJZAooP/WuGn6JVE1MXcmbQRyKPTCo1ga8hGsg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MTjlJ759; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fw6zbRxa; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240212153625.637385562@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707858266; 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=XwJ0QaSKJYUlMs7BjkVS3/Pl3Z3VCdhmpQOd6QtZAx0=; b=MTjlJ759gd5o1C1FOVxEVvqfiLiLMnWFreFRGVdtm47vuADZ5jP4QKLaY6fazFkbbG5Tpy B4ZraYt2T2jaPeMVLv3vlU5j/u+LJ1xIeANU4Dp2YbqrrX+F3z7Ax37aUNDX7vgQKt4API d6h+9QQrgpDdkjX+R8woCQB9zDdnipLW81Bkh2ELXH/lak7qyQEcbVtBkzyOWjbwqjvdnS 0Rj/cXusxnmIjq+z1Y5a8itXCbq9nA2QOq9/VjeMw6DUV3KD0dlGI5JlrD2iXYgtWZyHHx 7y0QlDrkIS6jsqY/elM2zusSEUc6eZzTmK58ZwI7jVVxiUamQ4N3ZlFyNdHB3A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707858266; 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=XwJ0QaSKJYUlMs7BjkVS3/Pl3Z3VCdhmpQOd6QtZAx0=; b=fw6zbRxauUpt0eEYzaLL7grA1cJAGhQjblfSKgAWTKJoqKRy8TdcacRmauvd3gIovW9bBL On79xOtSmWSKOzCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , Huang Rui , Juergen Gross , Dimitri Sivanich , Sohil Mehta , K Prateek Nayak , Kan Liang , Zhang Rui , "Paul E. McKenney" , Feng Tang , Andy Shevchenko , Michael Kelley , "Peter Zijlstra (Intel)" , Wang Wendy Subject: [patch V6 19/19] x86/apic/uv: Remove the private leaf 0xb parser References: <20240212153109.330805450@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Tue, 13 Feb 2024 22:04:25 +0100 (CET) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790819462544690334 X-GMAIL-MSGID: 1790819462544690334 From: Thomas Gleixner 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 Tested-by: Zhang Rui Tested-by: Wang Wendy --- 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_PKG_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);