Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp451486rdb; Tue, 23 Jan 2024 04:58:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEx8Qzeinw6qDocfRbgq0t0kBZR2Vh0if/b3AxlXaFu0QCSKv7T7DQi8oTdgzea//P3yXUd X-Received: by 2002:a17:906:6a2a:b0:a28:50dd:66cb with SMTP id qw42-20020a1709066a2a00b00a2850dd66cbmr4200845ejc.88.1706014723117; Tue, 23 Jan 2024 04:58:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706014723; cv=pass; d=google.com; s=arc-20160816; b=VqBY1vF3Ytu84OL2IAO81bRQ1XxY/ADvsnJK55tCsnPKk3+e6JfMcJNSFUgPV26fgx KpLnHpipXWAwzR+pliOUkmDAMBJ4gIgBUmLdqylHLDNKgb60kUN+GW5aIW6RKrYp8PsW d2idQY1ODlqrWkTd4MNzQoKYE7k7r6+VMrBC2fex9cmA0ApFTOZKUSUAkpcXSgRFYDtz 7rQ717bTO1IWCkKtGGIRZhLm9qH/M6XENs81dtpYBsjKIqLC3aCgIaJGJE78IYHOmG4k PjC4TA1+n//noF0mjBMmez6/fouPuSkHLUCHWFZyGIS9T2HxsyPTnS++6Djm4gqC8THF U92w== 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=FJqT3mPgCqqamnmXXVMxEDykuKO5FlyIcFcBDU9yaR4=; fh=Te0fDPJ/sd+7p881M6fa/oF213lBbJvGdEFWr/TLqNA=; b=KCg4JPa6n+bP30H2W4SlO9Dz4FotpxGPAICVz5SFsUYBPNTvwVOOynXPiqLvDdsS6a a0ITlhadXxZ2APuIKZAqeqi+GZSIAVFN0rIimUdeuv2cXDWNj0ACkk1nHoGhSTJav5i8 Xg8QGExWUz7PElzv/PODh1IPz0pJjMKfwCCC2DTfLQ2LIvF5rquPcXLE3x0umZ8fHI8N 9nEQxz3FARvxV0JKPANUyKkEp4sTH3NEwMWXLYVYCcRCwWtJ5XAtPC33hFsQyfkSLWiP PHBh71WCJj2gDYvBRiMPs3064gjVoS6yP1f4WwJEs6kUapDmXbOtQODd/cuCAvRfITTn JZmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HsZoHXy8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-35284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o11-20020a1709064f8b00b00a2b23f08c5asi11679478eju.808.2024.01.23.04.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 04:58:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HsZoHXy8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-35284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35284-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id DCEBE1F25BFB for ; Tue, 23 Jan 2024 12:58:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6938F60BA7; Tue, 23 Jan 2024 12:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HsZoHXy8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tbSHBNLm" 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 2DE126088E for ; Tue, 23 Jan 2024 12:54:02 +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=1706014444; cv=none; b=CrGHomN7RNbjxZP+jkli2bMyyABysT1uEwfNGcCSQLdt0l1ihHWcZMgGosSK/Kcw/0xxlux3gypa/ak2HjB7N1TtbYlwJ+tHzcZHxzQ0b/tCouiygJ6seD50cOgENZGzeNdQvsDyZcWN2XNHfX8431YDCwajPNOf/AaOMcnz3Lg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014444; c=relaxed/simple; bh=IiVU/EQPGLAtjCv4Y2GFk70d/aytmYANUKUADaDyc3w=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=sWCNEC+6EvO96eMahJiOdz1OJuPZvfYChHGUyrtPdeEIyCZDxnSbbQ9oX8x5/KA4N2EvH5HPsF8JYx0fAcInAZIGvzg0CD4DljiJD/LmN2UC9+qPGz8vUgFNXPWo2YIN0Hw9dT4tsJU61lxLuxxMXsI1UTr4lWYlaqxksRn3yc0= 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=HsZoHXy8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tbSHBNLm; 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: <20240117115909.537148439@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706014441; 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=FJqT3mPgCqqamnmXXVMxEDykuKO5FlyIcFcBDU9yaR4=; b=HsZoHXy8+gRXUpUOH/XUP7HwSjmrpPS5d/+Kg8DwCvQZKiGhYiAPjs6grU2ThZbaDKEVo6 ZhYfHva3KHDLjem4JbfPVv4eO4Vd67OkaR16OJK5uRUFslYuH/pJLTlzpgPQG+08iUIZ5q vJpwqS8uV4XoYHO4zswYi8c6ukPDV9e0Hk1IlyAyUrSP3y/JYvVatdyvjGGRYQOkYNf4Ae 02FmC0gaSfN2nmKY1BIWzPaXeCaHsDXPTZn8dLlYgFIocI4TJYWjiDvrFUNS4MDkax2sGg I+Hs/8FV3THpoYMhuSiSAWCAfAVuvkeoTy42Scyf/DGLWjmIETQpfAGnhOwMcw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706014441; 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=FJqT3mPgCqqamnmXXVMxEDykuKO5FlyIcFcBDU9yaR4=; b=tbSHBNLmr0ByTI4PN3XIyfrGmgJGJ/lnJFqsBh2M5NYZzTUdI/wfz10ReiSqh533LX3R8Z lrl/msVk4iPWaEDA== 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)" Subject: [patch v5 19/19] x86/apic/uv: Remove the private leaf 0xb parser References: <20240117115752.863482697@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 23 Jan 2024 13:53:59 +0100 (CET) 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 --- 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);