Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp175450rdh; Tue, 13 Feb 2024 13:10:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4sszEEJr+MnnWqWKy186yV4zR2b+pKA0kT1MqZNYYWFp6IyWP8KRvHzklifDdEG2kQl5DaCPBOGhZfkzyg0q3VwP0rIcWZQe/QjqXIw== X-Google-Smtp-Source: AGHT+IF+XWTKstj8r0nNc9VxtkJd3JpI680pYXlN2usccutAPJJXW5xdYUexdeGd6Y3oCLkQTJNp X-Received: by 2002:a2e:87c5:0:b0:2d0:99b7:e68c with SMTP id v5-20020a2e87c5000000b002d099b7e68cmr533024ljj.15.1707858600067; Tue, 13 Feb 2024 13:10:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707858600; cv=pass; d=google.com; s=arc-20160816; b=UbkEwswVcjb/K7QWTXb1mCeib4OsfDoDGkKXtN+JWMsvALbocendWSMe7feNJSK+aB RsnAQ/jOLKgLkWDZAT0WcfELTgMA1mtifg9TNkUpl9kW1SqpJrjwogU4bXIT56PiPn1c lUDl53I8By76wgO6zaF8/GE8HK/Q9dKILa28+sMGqWRoUsc0/9f0LE4gUjkIJTOsofKL TTPbuIufrnoHRXY91FrVjBRb04iuGLsZCGGAhkz1CkkoE/+167X+fksrqmZCnm0kPTt/ NuBRVH18IsHqrjkSv5BFJmMmHydxWYAHgSLa4NPGv0nVO5Luf7+OpquYjez9tVsTfnRq I0iw== 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=S+nyMnGpn3vlcKUrJGYRN9n3N6nmtNubmli01m0xfZk=; b=XzRM8u/9ajcAHeuRxXqlt+076E3VTAhtaRnzzuz/AKKwPjfijnYsdXZEiljkPYem1P deZx7PgB5tZJJCUQd09zeT94a+OzLFthq7kvcSaPze6pm88I8WDCuU46MGo/jPVJUZnF uruu6RwhOy2vQT0UhjgtlJGIBhGJBps2Gtzph9N46ReDQmO4FzDnS/MhyCu8+jJxqCMt 3KGlEdYNw5FruzJ3AuyIQq116BYbeLZUn9zd9HK0xihWZU+g+0tmgq5CClPRmyVmnljt MHsS9kMAnNlyDDoZ/Lt6Y5T3cWs0ZYtGnW1OiR9ADSLf7eMVhteL470gLQPjKm/FeZUQ Dg5w==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64265-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCWI6xIlU5glstDGoEQ0ebJK0Cv0j/4TPxvrsdv2pEddQ41hznRfixRhzrVGlwiz90EV0PRwUhlrc2IPja9RQJVU76O3yGOXAZACRKRWlA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o28-20020a509b1c000000b00561607e800csi3985836edi.262.2024.02.13.13.10.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 13:10:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64265-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=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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64265-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 A08331F2840F for ; Tue, 13 Feb 2024 21:09:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED58A6997F; Tue, 13 Feb 2024 21:05:00 +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 Content-Type: text/plain; charset=UTF-8 Date: Tue, 13 Feb 2024 22:04:56 +0100 (CET) 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)