From patchwork Tue Feb 13 21:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 200610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp810100dyb; Tue, 13 Feb 2024 13:10:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVCCMOjLKyySnZEqPMl5GS5GcWilvUT7vepi4hUpVnyf4Gf2UhAMMAg9Br/P5Nzl8XrZbLtEyn5fBk+DLJIKOEN3RlrlQ== X-Google-Smtp-Source: AGHT+IHBOj1TLVxaXFsDdUGvNZCISo70bsKL0wN5tJlamn3aKH6rENNH2IiZuGExDXo704nXJtX3 X-Received: by 2002:a17:906:ccc1:b0:a3d:30a0:2e79 with SMTP id ot1-20020a170906ccc100b00a3d30a02e79mr316894ejb.54.1707858622985; Tue, 13 Feb 2024 13:10:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707858622; cv=pass; d=google.com; s=arc-20160816; b=vC+S76+Mh0AGB1tjtzaMf2cRj7vPNeYv/sB+WBIiiamvFhQl3YnxtMc4D0VxKQPA3k u5RTaryLmludPSvA1Kv7ubhXW5mExyHw3H7I0PgGkqGESVOjq8wfux1GlpVHsxzHwPsU y2INFaMLl/AgL4HsqzUIJaeBS94pfm2vANVe+GJLZnExTPFNuZliqmuAjExKrg1aMoRE LujTq/qQMSgb1MqhH6kp4Ip3ibZIcZEA0FniV4/sbVDVxPJmjpLx1U0NaKiqWBhOKfVj KwpmTdLqRBy/H8E4sBAxxPrb8qNTkg/I98a6F5jJvALxfjrsotVg1IhWisaszMwon3mD y0Lw== 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=UfdzocNFGBq69iV//wkeRzLjmBpQkQlCRm8UD9Xx43A=; fh=dGHqXAcADqxP7WIR4f/JxredIgbtmKJWXbuuBJXwrg4=; b=trTPKutGGz4Dn95Y5VzOTApKfTSchgAL9cdFV4g2orJCUYwiIlCEMXtbIC/BvaqHot Af0sUvXQ3HpZOQA8KhXhPT4rKhDGCjmdF6Uqru/zZurVt6uCnU2v9Hcw92CSzIbzn0Fi K1/6LtDb3i/+U6xR7Q1IMoPZMGDRtVoHw3kKvmPVgLOoklwwu0LFBHZwOz5HlxUAOzKa Zl7aZz6QhIazdDXEiWdoKk+iL7zirihk4fkqnJRelnjzmYApfy/nR7qCqyhfcdr/0kfM uM+nFvCGxPx5k3vNoBPGccY04EXqOC9XB/iuITIJ1A9pYoOzglaFC9jRe9BgJtBcXRTV cNpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=loVEXONa; 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-64265-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64265-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCX77+oTEqkMMceHxF4bswzs/+Bh6RAd1IRmaUsmMToyhTFmtxq4HVazSckptRuGN7AytKId2gOTgGXgDyhVEvxXsaVY8A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kk14-20020a170907766e00b00a3d265f2422si338016ejc.555.2024.02.13.13.10.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:10:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64265-ouuuleilei=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=loVEXONa; 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-64265-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64265-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6DB3D1F27CEC for ; Tue, 13 Feb 2024 21:10:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E2CB69D38; Tue, 13 Feb 2024 21:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="loVEXONa"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hnjhPnmf" 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 3814265E02 for ; Tue, 13 Feb 2024 21:04:58 +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=1707858300; cv=none; b=cTVJLvdc0u18f/J+xkbQRuinrUeKzjDwXWQrWAjrlhHvvwamxB6CEqUOWL0Lpa6QeSNY0UOhquG3XWpX2hIKw/QGsY6RijfTJVXKXp5tvCynoR0BTnq0RN7sLRyXLLbakgrsVBiXzWqVnrMOOp4x/IMoS/uFneOFLrYW1eC6hqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707858300; c=relaxed/simple; bh=yaokxf92+mgnW4T+1uRdM4vePkxxF9JY9SeGC4Ai5+c=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=LhEAOX2iTgLBcKlwiPmH9tdZpdlZkvz8vP6Huse2dEA+hey/cIHYkzsRYpJp1IcBiorcrVg2pZEsC7GCMwVa/hMm1GRHE51b86+DsIitLO1ok+O5MK27iGxeREcFc65/ytSUwpcMypmIYuP+TAVYrEC7+637n32jfPKKDjZ0l1A= 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=loVEXONa; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hnjhPnmf; 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: <20240212154639.057209154@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707858296; 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=UfdzocNFGBq69iV//wkeRzLjmBpQkQlCRm8UD9Xx43A=; b=loVEXONaRzrGSoxDUT8/zYOmMFSgt8HxWGWLQnd3IwiHarRM9LNUMhlwsN89r2ghgFXSVl IyG3zqwInq2wCWLK1mm3AC0ftBokISHeWmWQ8NBDjpZpUePEbbWNVVdXkOJi0ABjD5AzPm SSOq3izZiR3W4psCLjyNDxVVoeail4S29WLcx/+8vwMbz2ej2kE1tFMvOINE1n67irV6F2 Wh3YpUWn8d3EpP3nqVlQZ3zFo0JhAAyKTan7LHbG68BQBa1qD6fpYAY6A9PcqlX/zJZ/CG 8KOvOtQ/GdViSzfzpVz3hDMW6ek0geMHbZxjiVkHS8+TlR4Cx+pFpcq+imVDQg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707858296; 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=UfdzocNFGBq69iV//wkeRzLjmBpQkQlCRm8UD9Xx43A=; b=hnjhPnmf0D20CcvMmPT2K3Muv7JBuFIo0wBlttrMwCcPRLEu5qesvqQca1V5XK5PPI6osE uy4kdMDkpBnguCCg== 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)" , Andy Shevchenko , Wei Liu Subject: [patch V3 04/22] x86/apic: Get rid of get_physical_broadcast() References: <20240212154529.402604963@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:56 +0100 (CET) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790819563139723514 X-GMAIL-MSGID: 1790819563139723514 From: Thomas Gleixner There is no point for this function. The only case where this is used is when there is no XAPIC available, which means the broadcast address is 0xF. Signed-off-by: Thomas Gleixner --- V3: Fix printk format - Sohil --- arch/x86/kernel/apic/apic.c | 10 -------- arch/x86/kernel/apic/io_apic.c | 49 ++++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 37 deletions(-) --- --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -261,16 +261,6 @@ u64 native_apic_icr_read(void) return icr1 | ((u64)icr2 << 32); } -#ifdef CONFIG_X86_32 -/** - * get_physical_broadcast - Get number of physical broadcast IDs - */ -int get_physical_broadcast(void) -{ - return modern_apic() ? 0xff : 0xf; -} -#endif - /** * lapic_get_maxlvt - get the maximum number of local vector table entries */ --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1460,12 +1460,12 @@ void restore_boot_irq_mode(void) */ static void __init setup_ioapic_ids_from_mpc_nocheck(void) { - union IO_APIC_reg_00 reg_00; physid_mask_t phys_id_present_map; - int ioapic_idx; - int i; + const u32 broadcast_id = 0xF; + union IO_APIC_reg_00 reg_00; unsigned char old_id; unsigned long flags; + int ioapic_idx, i; /* * This is broken; anything with a real cpu count has to @@ -1484,11 +1484,10 @@ static void __init setup_ioapic_ids_from old_id = mpc_ioapic_id(ioapic_idx); - if (mpc_ioapic_id(ioapic_idx) >= get_physical_broadcast()) { - printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n", - ioapic_idx, mpc_ioapic_id(ioapic_idx)); - printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", - reg_00.bits.ID); + if (mpc_ioapic_id(ioapic_idx) >= broadcast_id) { + pr_err(FW_BUG "IO-APIC#%d ID is %d in the MPC table!...\n", + ioapic_idx, mpc_ioapic_id(ioapic_idx)); + pr_err("... fixing up to %d. (tell your hw vendor)\n", reg_00.bits.ID); ioapics[ioapic_idx].mp_config.apicid = reg_00.bits.ID; } @@ -1499,15 +1498,14 @@ static void __init setup_ioapic_ids_from */ if (apic->check_apicid_used(&phys_id_present_map, mpc_ioapic_id(ioapic_idx))) { - printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n", - ioapic_idx, mpc_ioapic_id(ioapic_idx)); - for (i = 0; i < get_physical_broadcast(); i++) + pr_err(FW_BUG "IO-APIC#%d ID %d is already used!...\n", + ioapic_idx, mpc_ioapic_id(ioapic_idx)); + for (i = 0; i < broadcast_id; i++) if (!physid_isset(i, phys_id_present_map)) break; - if (i >= get_physical_broadcast()) + if (i >= broadcast_id) panic("Max APIC ID exceeded!\n"); - printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", - i); + pr_err("... fixing up to %d. (tell your hw vendor)\n", i); physid_set(i, phys_id_present_map); ioapics[ioapic_idx].mp_config.apicid = i; } else { @@ -2209,7 +2207,7 @@ static inline void __init check_timer(vo * 8259A. */ if (pin1 == -1) { - panic_if_irq_remap("BIOS bug: timer not connected to IO-APIC"); + panic_if_irq_remap(FW_BUG "Timer not connected to IO-APIC"); pin1 = pin2; apic1 = apic2; no_pin1 = 1; @@ -2495,6 +2493,7 @@ unsigned int arch_dynirq_lower_bound(uns static int io_apic_get_unique_id(int ioapic, int apic_id) { static physid_mask_t apic_id_map = PHYSID_MASK_NONE; + const u32 broadcast_id = 0xF; union IO_APIC_reg_00 reg_00; unsigned long flags; int i = 0; @@ -2515,9 +2514,9 @@ static int io_apic_get_unique_id(int ioa reg_00.raw = io_apic_read(ioapic, 0); raw_spin_unlock_irqrestore(&ioapic_lock, flags); - if (apic_id >= get_physical_broadcast()) { - printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying " - "%d\n", ioapic, apic_id, reg_00.bits.ID); + if (apic_id >= broadcast_id) { + pr_warn("IOAPIC[%d]: Invalid apic_id %d, trying %d\n", + ioapic, apic_id, reg_00.bits.ID); apic_id = reg_00.bits.ID; } @@ -2527,17 +2526,15 @@ static int io_apic_get_unique_id(int ioa */ if (apic->check_apicid_used(&apic_id_map, apic_id)) { - for (i = 0; i < get_physical_broadcast(); i++) { + for (i = 0; i < broadcast_id; i++) { if (!apic->check_apicid_used(&apic_id_map, i)) break; } - if (i == get_physical_broadcast()) + if (i == broadcast_id) panic("Max apic_id exceeded!\n"); - printk(KERN_WARNING "IOAPIC[%d]: apic_id %d already used, " - "trying %d\n", ioapic, apic_id, i); - + pr_warn("IOAPIC[%d]: apic_id %d already used, trying %d\n", ioapic, apic_id, i); apic_id = i; } @@ -2567,11 +2564,9 @@ static int io_apic_get_unique_id(int ioa static u8 io_apic_unique_id(int idx, u8 id) { - if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && - !APIC_XAPIC(boot_cpu_apic_version)) + if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && !APIC_XAPIC(boot_cpu_apic_version)) return io_apic_get_unique_id(idx, id); - else - return id; + return id; } #else static u8 io_apic_unique_id(int idx, u8 id)