From patchwork Mon Jul 24 13:34:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 124969 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1809735vqg; Mon, 24 Jul 2023 06:45:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlE0vVK61KjwcODaVhCuWUvvAUiBNJtHcwoe//6V5Zo7zAv6yyxD5FQxorSRKsJg4okBL8x3 X-Received: by 2002:a17:906:15b:b0:993:e9b8:90f4 with SMTP id 27-20020a170906015b00b00993e9b890f4mr10884001ejh.8.1690206314849; Mon, 24 Jul 2023 06:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690206314; cv=none; d=google.com; s=arc-20160816; b=Cb4CQg0M7VU2HwK/O++B6UCY4z5eX5eAdgW+N4rRm0CnNbEKEPJjrgNgMYDDoZvToD N4xwhKNcQkllI0YuHTqVkkIm+LNGvTblASNoG28RRhUKxzW4jo/iin1Qip+tfpvdFNf8 QnXFf3Ogd9h3vGsnXJgYZnwDJshsqybumEMDBWWuNg0RHWEGc04QX//mYQQtR6bd6PEe clVq/Ok0dHQiSD3upj/6FJ1N6rcYdbBalAtgDwVwcswVgDO2GVkylpnph62HDDr7aY59 wqPxKvoD5+kMTVR+CG3YtI7h5ouv8SKdY8gaDX4y83PwUNpisxeNA5FSon7nFrfXqdlL RYCQ== 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=0iz4gOQLk9YymQJzW0sXfBIS7q8+WXoqEL26ZlioJL4=; fh=mE3iieUIZLcDfOLIULj9X6/p0bMDPZGFSVRsnyRUnTc=; b=Kx+GiHwlW99/SdvTBrJj72/hn0Cw72cYG/RhmH51Oni9ly1/Lt6nXQ66MUXW9EbN5/ pG+9ZF8spQ0s3N6H2VfSgSAyTOJ50e/162ZJbqDCU84AK+B23TuBoanysiWO7fChVFne E+qRsxQr/k7/ODEdTBVRgzhrMEnG0znvr1hVX6IpQy8+yaK31qom8tZJ8B+/retwqhoy W/7OQ7A6rMtRPiZGkNgfdRPyjePs0R5LqpkfotAnsviHkK4Hh1Mje/b1CURUv6ugM27u xWoB0qvnG81P7o+Y6t8bbLC/PBuI8PISaNx+QiNcd2RzHijX3JaubL2aEuWkv6mtf6qy WvwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Xz0CBr9L; dkim=neutral (no key) header.i=@linutronix.de header.b=IPIJ1OB6; 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 k1-20020a1709065fc100b0099b7a166dccsi3623007ejv.308.2023.07.24.06.44.45; Mon, 24 Jul 2023 06:45:14 -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=Xz0CBr9L; dkim=neutral (no key) header.i=@linutronix.de header.b=IPIJ1OB6; 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 S231496AbjGXNeo (ORCPT + 99 others); Mon, 24 Jul 2023 09:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjGXNe3 (ORCPT ); Mon, 24 Jul 2023 09:34:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC17E4F for ; Mon, 24 Jul 2023 06:34:07 -0700 (PDT) Message-ID: <20230724132045.302673759@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690205645; 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=0iz4gOQLk9YymQJzW0sXfBIS7q8+WXoqEL26ZlioJL4=; b=Xz0CBr9Lx/F97q60oo2TJl/rIh4wp9YR5yDt/NzlEfhRyvG/k4hkwGXHbqIttOltxjkIIE n1NkEPszq+IY2E8Xbm9vUVFXkGWCb+8sMgSSloBoq6E7sYsPjhe/vtsttHB7i3gteDeKUy Q0cTfsroCBBfhLgteNdOHF6liK2nkP4yWgVNcMQMchyAghfrqgrKeh9srmx/jXiOz6hLh0 XXhjm56aXF/3S3njp6ikNTj5teGShCU/yINPNqgd7U0z+QTs8pYU9c2Tg1RLYeaugNCN2N LwJHgKYBc9p9jW91OsOfh4/TsrkQJRjPuI7nnLuIoks07T0Gs41RPQDaR3AErQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690205645; 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=0iz4gOQLk9YymQJzW0sXfBIS7q8+WXoqEL26ZlioJL4=; b=IPIJ1OB6vHgbYWZ+wbD/Ea5C0pKjCuU9X5VMxMh6DCl6Y9WA26t9nP8HXWg466VLBFHFeL uL2M/9ZnvgHii2Aw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross , Michael Kelley , Peter Keresztes Schmidt , "Peter Zijlstra (Intel)" Subject: [patch V2 12/58] x86/of: Fix the APIC address registration References: <20230724131206.500814398@linutronix.de> MIME-Version: 1.0 Date: Mon, 24 Jul 2023 15:34:04 +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,T_SCC_BODY_TEXT_LINE 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: 1772309776503598726 X-GMAIL-MSGID: 1772309776503598726 The device tree APIC parser tries to force enable the local APIC when it is not set in CPUID. apic_force_enable() registers the boot CPU apic on success. If that succeeds then dtb_lapic_setup() registers the local APIC again eventually with a different address. Rewrite the code so that it only registers it once. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) --- arch/x86/kernel/devicetree.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -157,19 +157,15 @@ static void __init dtb_lapic_setup(void) /* Did the boot loader setup the local APIC ? */ if (!boot_cpu_has(X86_FEATURE_APIC)) { + /* Try force enabling, which registers the APIC address */ if (apic_force_enable(lapic_addr)) return; - } - smp_found_config = 1; - if (of_property_read_bool(dn, "intel,virtual-wire-mode")) { - pr_info("Virtual Wire compatibility mode.\n"); - pic_mode = 0; } else { - pr_info("IMCR and PIC compatibility mode.\n"); - pic_mode = 1; + register_lapic_address(lapic_addr); } - - register_lapic_address(lapic_addr); + smp_found_config = 1; + pic_mode = !of_property_read_bool(dn, "intel,virtual-wire-mode"); + pr_info("%s compatibility mode.\n", pic_mode ? "IMCR and PIC" : "Virtual Wire"); } #endif /* CONFIG_X86_LOCAL_APIC */