From patchwork Wed Aug 9 16:49:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 133362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2957947vqr; Wed, 9 Aug 2023 10:24:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkD+egWGlTZjCyf3m6pln54ChQ2QgZs2Ywy6QUADXKeD6/e5r8RNngPaKn8uvILwf8AbdN X-Received: by 2002:a54:4710:0:b0:3a7:7e66:2184 with SMTP id k16-20020a544710000000b003a77e662184mr3179338oik.48.1691601855591; Wed, 09 Aug 2023 10:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691601855; cv=none; d=google.com; s=arc-20160816; b=kLVHM8oDLsRf/dowv4EqW981mxJvtJD2NumD4ywdEOKCLwKoQZ1C7aPno6BGCvnjea K65SFTIMH/17H/38ysm0vFJpWj3W9Zoi2fkR9sfzS4/EPKjAi8ZAPFmdOeCASthB1LoU SQgbHCAshO9MLuCiinp6daAdfkl29TaOkK497flyRjaytm927DhqqmHycOlLR08bgyUd 6E/PxNkVyS9YDwvYsz8h8eYXElDIV6NVGMIHXMnyodoQ2OK85oimqdVvScK1Wl46CBMu Npax9KjQUvBBbRSsthV4LyiG0QVMjET8Cwi7KO+ozEEUytiPMikasyfNQSn8s9KyuPJ4 rdRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=9DRlMd6dGzM/4XEmIyUphM8I9Tgh4ZcIpPqm6yUoKo0=; fh=xeBNGOuZM5vy4okdFvBNsMTGHQ6tdBlFPaNKCUScG5A=; b=dIK5ROQT7Y3JFWpWH/FwQY3DCltdYb2E6B0ytEKRCC3IvpN/qkq7PSwpPKBY10YFmG aaJ0XfUcD6wxrKZFhXqtjYW1i6LgbedZqNRoFt9s86niyygyt4xRiTmf2LQLC5ghruMV KpjWHwQ5FwClgEzvwu8x0RO7LYnpwy9+jDIWmbut2xtXSTfLshPpc/lE3hS+vB1bvH2r l7SqjzBL8TKwBi9omX9bCjhGalY1k8owrAqvv4TwR2eeKooojDf/TrspZTVtKjtVUHJW GTRAtWYTLwzXIyC0lac/dBo+KbeqbyDRfrYYh9OQtA7gYoHY/2ON2pkD+OpZGXdqpvS0 8Uow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kKR21BRH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Ot2sEmNs; 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 n17-20020a17090ac69100b0026815fe629esi1815246pjt.70.2023.08.09.10.24.03; Wed, 09 Aug 2023 10:24:15 -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=kKR21BRH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Ot2sEmNs; 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 S231406AbjHIQtl (ORCPT + 99 others); Wed, 9 Aug 2023 12:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230476AbjHIQtc (ORCPT ); Wed, 9 Aug 2023 12:49:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037731FCC; Wed, 9 Aug 2023 09:49:31 -0700 (PDT) Date: Wed, 09 Aug 2023 16:49:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691599770; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9DRlMd6dGzM/4XEmIyUphM8I9Tgh4ZcIpPqm6yUoKo0=; b=kKR21BRHkRBULkKXZqfICEVVMEv+34WParQjYFMquAaxDENUe9Y/mJjwvSDKBXYcdFb307 CSed2HGaoAjdc2vYJumAy5KVdSX4rBFKmKMW8cg0b+5xPWbbdgvToNs1DzfIv9iH/CPBqZ GSTjQLjXOHYI5uuQLqrd3gRVfRetb4tAPrlMB/0B0PlSMw0ALUcvhyMQXRpyefILJCN1eT /iSCI3rc7f0+zfXFyEvRfKP1fo1k2JqNVQMy2jPV7ENRcpJfIvxY7tDmbg5jbgWC6/q/HF sN2qagdvD6s+gdcwpFT8VdyoAm8F1L9On/cc5Iv2ci6NklxIWT4N925DJTh2sw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691599770; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9DRlMd6dGzM/4XEmIyUphM8I9Tgh4ZcIpPqm6yUoKo0=; b=Ot2sEmNsxRIvEkw7ATvdLLQVbAWyT0JASaOSogJgxhs4HbbQHeP+019Mg0i5eehsP/BHS8 v6pz/F2OSFes2oCQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/apic: Move safe wait_icr_idle() next to apic_mem_wait_icr_idle() Cc: Thomas Gleixner , Dave Hansen , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169159976980.27769.15512341418119100114.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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,URIBL_BLOCKED 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: 1773773107646154094 X-GMAIL-MSGID: 1773773107646154094 The following commit has been merged into the x86/apic branch of tip: Commit-ID: 97b9d715efd4979fda58a300689e09e5dbbbd975 Gitweb: https://git.kernel.org/tip/97b9d715efd4979fda58a300689e09e5dbbbd975 Author: Thomas Gleixner AuthorDate: Tue, 08 Aug 2023 15:04:06 -07:00 Committer: Dave Hansen CommitterDate: Wed, 09 Aug 2023 08:10:12 -07:00 x86/apic: Move safe wait_icr_idle() next to apic_mem_wait_icr_idle() Move it next to apic_mem_wait_icr_idle(), rename it so that it's clear what it does and rewrite it in readable form. Signed-off-by: Thomas Gleixner Signed-off-by: Dave Hansen Acked-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/apic.h | 1 - arch/x86/kernel/apic/apic.c | 17 ----------------- arch/x86/kernel/apic/apic_flat_64.c | 4 ++-- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/ipi.c | 19 +++++++++++++++++-- arch/x86/kernel/apic/local.h | 1 + arch/x86/kernel/apic/probe_32.c | 2 +- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index dd0a05d..49b6c7e 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -98,7 +98,6 @@ static inline u32 native_apic_mem_read(u32 reg) return *((volatile u32 *)(APIC_BASE + reg)); } -extern u32 native_safe_apic_wait_icr_idle(void); extern void native_apic_icr_write(u32 low, u32 id); extern u64 native_apic_icr_read(void); diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index ab26a61..80a31f2 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -240,23 +240,6 @@ static void __init apic_disable(void) apic = &apic_noop; } -u32 native_safe_apic_wait_icr_idle(void) -{ - u32 send_status; - int timeout; - - timeout = 0; - do { - send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY; - if (!send_status) - break; - inc_irq_stat(icr_read_retry_count); - udelay(100); - } while (timeout++ < 1000); - - return send_status; -} - void native_apic_icr_write(u32 low, u32 id) { unsigned long flags; diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c index 57d3afb..1da865f 100644 --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -112,7 +112,7 @@ static struct apic apic_flat __ro_after_init = { .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; /* @@ -188,7 +188,7 @@ static struct apic apic_physflat __ro_after_init = { .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; /* diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c index 57077fc..32984bf 100644 --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -109,7 +109,7 @@ static struct apic apic_bigsmp __ro_after_init = { .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; bool __init apic_bigsmp_possible(bool cmdline_override) diff --git a/arch/x86/kernel/apic/ipi.c b/arch/x86/kernel/apic/ipi.c index e0e0567..460df02 100644 --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include + #include #include "local.h" @@ -102,6 +104,19 @@ static inline int __prepare_ICR2(unsigned int mask) return SET_XAPIC_DEST_FIELD(mask); } +u32 apic_mem_wait_icr_idle_timeout(void) +{ + int cnt; + + for (cnt = 0; cnt < 1000; cnt++) { + if (!(apic_read(APIC_ICR) & APIC_ICR_BUSY)) + return 0; + inc_irq_stat(icr_read_retry_count); + udelay(100); + } + return APIC_ICR_BUSY; +} + void apic_mem_wait_icr_idle(void) { while (native_apic_mem_read(APIC_ICR) & APIC_ICR_BUSY) @@ -135,7 +150,7 @@ static void __default_send_IPI_shortcut(unsigned int shortcut, int vector) * to stop the others before launching the kdump kernel. */ if (unlikely(vector == NMI_VECTOR)) - safe_apic_wait_icr_idle(); + apic_mem_wait_icr_idle_timeout(); else apic_mem_wait_icr_idle(); @@ -152,7 +167,7 @@ void __default_send_IPI_dest_field(unsigned int dest_mask, int vector, { /* See comment in __default_send_IPI_shortcut() */ if (unlikely(vector == NMI_VECTOR)) - safe_apic_wait_icr_idle(); + apic_mem_wait_icr_idle_timeout(); else apic_mem_wait_icr_idle(); diff --git a/arch/x86/kernel/apic/local.h b/arch/x86/kernel/apic/local.h index 2eb49d4..98cfe78 100644 --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -45,6 +45,7 @@ static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector, void default_init_apic_ldr(void); void apic_mem_wait_icr_idle(void); +u32 apic_mem_wait_icr_idle_timeout(void); /* * This is used to send an IPI with no shorthand notation (the destination is diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c index 52f3c6f..a861a77 100644 --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -65,7 +65,7 @@ static struct apic apic_default __ro_after_init = { .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; apic_driver(apic_default);