From nobody Tue Feb 10 17:30:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1692366318; cv=none; d=zohomail.com; s=zohoarc; b=B4dByYUgqQS2ygBbuxCl7rJGSPTydEaYGTBz6hPLzWWZp81H41eJ4pXnYMRRwJ9pO8OBfMfhbxl2V1+EO98drV7EIHXEJsF8GbknaUZ/hbu5OkQigusQVSzxkwPTPlcP+ROfE+DXlbr29oIENKm6yGQ40nJBzYCyf3odSafLC3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692366318; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lf3E6qWM/eYtxtUMYYrXFPP69s9JP5c1zgdxZnGHfo4=; b=H929XiAbqHlVE57hSUt9G4vDlpHmsHi7Vr5qQwMB8HyHtPnl2Ac2HJS85LQ2p95Q3E9neOThHvKfMbAOMMK28kzvaQVdhATBBsu9BPfboNkFL13RcpIfYIhpY3KFUG+Sf9Wcd8J8/8AjAFtFmobDnywm8Yebb9ZH6mmU3UKeJcM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1692366318967874.3920299300439; Fri, 18 Aug 2023 06:45:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.586328.917551 (Exim 4.92) (envelope-from ) id 1qWzmX-0003Pz-5r; Fri, 18 Aug 2023 13:44:53 +0000 Received: by outflank-mailman (output) from mailman id 586328.917551; Fri, 18 Aug 2023 13:44:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmX-0003Pq-32; Fri, 18 Aug 2023 13:44:53 +0000 Received: by outflank-mailman (input) for mailman id 586328; Fri, 18 Aug 2023 13:44:51 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-00034T-6g for xen-devel@lists.xenproject.org; Fri, 18 Aug 2023 13:44:51 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qWzmV-0002FT-36; Fri, 18 Aug 2023 13:44:51 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1qWzmU-00023L-Rg; Fri, 18 Aug 2023 13:44:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=lf3E6qWM/eYtxtUMYYrXFPP69s9JP5c1zgdxZnGHfo4=; b=swKHiGCGFvxejmKdL/hpiUNxhz 8ZF+q6EvrHvFPpN8MQQm0/6gaNJgVZLE9eioHmEJ57dct1wC911FKpZLKKiBsr7201nAVfRkO7NZ5 ulmZuuFDt9abwG4IWVonkSF4HDFu8Dc0oFmXP4nL3SQ15/xBPoq4GCu5k1XScQiCznZM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/2] xen/x86: ioapic: Bail out from timer_irq_works() as soon as possible Date: Fri, 18 Aug 2023 14:44:41 +0100 Message-Id: <20230818134441.45586-3-julien@xen.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230818134441.45586-1-julien@xen.org> References: <20230818134441.45586-1-julien@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1692366320236100004 Content-Type: text/plain; charset="utf-8" From: Julien Grall Currently timer_irq_works() will wait the full 100ms before checking that pit0_ticks has been incremented at least 4 times. However, the bulk of the BIOS/platform should not have a buggy timer. So waiting for the full 100ms is a bit harsh. Rework the logic to only wait until 100ms passed or we saw more than 4 ticks. So now, in the good case, this will reduce the wait time to ~50ms. Signed-off-by: Julien Grall --- xen/arch/x86/io_apic.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 4875bb97003f..0bd774962a68 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -1509,6 +1509,8 @@ static void __init setup_ioapic_ids_from_mpc(void) static int __init timer_irq_works(void) { unsigned long t1, flags; + /* Wait for maximum 10 ticks */ + unsigned long msec =3D (10 * 1000) / HZ; =20 if ( no_timer_check ) return 1; @@ -1517,19 +1519,25 @@ static int __init timer_irq_works(void) =20 local_save_flags(flags); local_irq_enable(); - /* Let ten ticks pass... */ - mdelay((10 * 1000) / HZ); - local_irq_restore(flags); =20 - /* - * Expect a few ticks at least, to be sure some possible - * glue logic does not lock up after one or two first - * ticks in a non-ExtINT mode. Also the local APIC - * might have cached one ExtINT interrupt. Finally, at - * least one tick may be lost due to delays. - */ - if ( (ACCESS_ONCE(pit0_ticks) - t1) > 4 ) + while ( msec-- ) + { + mdelay(1); + /* + * Expect a few ticks at least, to be sure some possible + * glue logic does not lock up after one or two first + * ticks in a non-ExtINT mode. Also the local APIC + * might have cached one ExtINT interrupt. Finally, at + * least one tick may be lost due to delays. + */ + if ( (ACCESS_ONCE(pit0_ticks) - t1) <=3D 4 ) + continue; + + local_irq_restore(flags); return 1; + } + + local_irq_restore(flags); =20 return 0; } --=20 2.40.1