From nobody Thu Oct 30 22:53:02 2025 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1760599919; cv=none; d=zohomail.com; s=zohoarc; b=gAbqkWjHey6dw3OHU0in9hTEPRLLzHQj9MQqep6mNXAu3dLhKZcEHpIn9Hge9DdtyPSW/PgnZVZuNYYpMnGVusyCVY3RwvhQci9WzQXVdC30L72POmcKJiz9u4Yu1vhc+895NhIILPRd6hNN4fHiB5q1YMREmTT2F1m5Ylf+/VA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760599919; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tiqdV3t0ZthBuMf+JLZku3ZCXN60IlcllF41Xvu/uZM=; b=J1RrkyLfvIvWCON7D6TNX0zJXFST7EQnN3yIw95YK/jzBiu6MQs+w66IoIcxnW1Y7kZbpEaXc/8uFNX2W2HapOWbPUP59piwQqWFF8p9CiiZxC+RBt8IgCUZNSkup/gHsKK3QGAhbejICqRKGY+A1cW6iY/mX87HCFRa6Ed8X70= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1760599919236698.3983540510085; Thu, 16 Oct 2025 00:31:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1144170.1477622 (Exim 4.92) (envelope-from ) id 1v9ISg-0007R7-7I; Thu, 16 Oct 2025 07:31:46 +0000 Received: by outflank-mailman (output) from mailman id 1144170.1477622; Thu, 16 Oct 2025 07:31:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v9ISg-0007R0-4Q; Thu, 16 Oct 2025 07:31:46 +0000 Received: by outflank-mailman (input) for mailman id 1144170; Thu, 16 Oct 2025 07:31:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v9ISf-0006tj-3V for xen-devel@lists.xenproject.org; Thu, 16 Oct 2025 07:31:45 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2a5570b4-aa62-11f0-9d15-b5c5bf9af7f9; Thu, 16 Oct 2025 09:31:44 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-471131d6121so1887465e9.1 for ; Thu, 16 Oct 2025 00:31:44 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-471144b5c34sm10997075e9.10.2025.10.16.00.31.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Oct 2025 00:31:43 -0700 (PDT) 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" X-Inumbo-ID: 2a5570b4-aa62-11f0-9d15-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1760599904; x=1761204704; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=tiqdV3t0ZthBuMf+JLZku3ZCXN60IlcllF41Xvu/uZM=; b=bwu9VRbIWFBP35/sWcGB9bM34KyjvWDRKTdBMuGI/XkUwoDkc4t1Ps8dV3fCb+UGP9 jDw9yZ8fTawHYlE6q6tpUswWo6RTdnLaQvCRypeubabzonjx5qSAVCVvLq8gieWxix0P aWksSe/7ZLIfZR/G6GDkA+V0MrBxhs+R0mIOwyErlTpwGsrz7zIFyFSr2BW9Y2i3CRhb KHbvTjDcpaLpkMrr12rfedY+X8H6HppgsHnoQdWjlsmOAArGJz4g+YRXzaH/Sn0nPmvU 91odmenN7I+hUmQibSLaRdPWu4VMNju1JVuzrtjsp4fIDzhbE8XPna6wN6kzkygQR2O6 fPJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760599904; x=1761204704; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tiqdV3t0ZthBuMf+JLZku3ZCXN60IlcllF41Xvu/uZM=; b=ulmaIxXO8oxUGOqAaNBnwOfajMONIsZhuwb2R4KFLwY/3b/IjQM/vtmzQKq6VB+02Y G2PbbyduCp+CBxP1cytOwJccxHo9GaFN1nbBacQAxGAGKqBa2loZfu3dxPSBJrzqna/W ScZZJ8SjQjCBWOXqEjtiOjQa2z1p6FI5r7YxR+qewFWP+0lCYa/aQZ0IidppAlUVybWK ZaKeS1kpBIkPTztZarM1dryIsSfE2mbh70UsFTUW8RAWEmvtNSEDC1voHUqHq+ulLDtI jhf9a+kNP9IgaY0auy6tUMl2VzfYR98mh9UwOGoxpODr0cHfBGmUzxFqAAE6uP8t3q4L Ntkw== X-Gm-Message-State: AOJu0Yx/XX5A2Kwt5QI5iADxZhDDDjw8us1FNPCE1Cz99mKekzs485SQ OGmfHYoL8ocWThB7Hd5rz5BI0wJZrHqyRC2gQDAAhZ/nrPk9wK4yizipeyx4Yl5honEzdTSNdQv 2es0= X-Gm-Gg: ASbGncv57XQ9A4w2YiyRq+eCSA8bJNJ3AA3ZazK99mlEJrnkeqy9x9si46lVyNg/7Nq l9Efa7h1kPNo/VlkxlPDq+du3aAxEC3iSPYi5tu/kyBWQbp25gvl2C3xCSPLJ/QIFFpS7fI1qHI Qs9WSDAEoubOb0WIMom5fvEkFj54kKWfOGJhouY6PVETgTckDNZDt17OKRnrgu26cIZRjpJjFya R23Bod/p4EgpqWPzjGVBujrhISM9RPutEJpbIQvuVRDuaQTpJSTUMgLJ+fTCLpM6mNb6nL4cQJR dblvj9yHGDgySYZKl6TdohKxjn6mWKBl8Ybdwx/ZYuheyBUHIv10SmwiS12Hleu+hF7AJG6nNrd ahP91YZLgZJGgIvCTZx4G8c4YuEaIr+xurrtSCyY20d+Q7SRPku04m+zd7yuf4c1LCldxOVEyRo aX1DUaHT73VD1MUp76CA7NLd8LcgpvSAfyDlqTDLpRHa5Gp2syXXUMKgU3LqQA9mP6+r3Yudw= X-Google-Smtp-Source: AGHT+IES7YsKSsjHBHMouBGRlfXagkajsNJlAbxiDyWg00HT6g8+t8UZxS+bicYfgu7dhsIsbWldTA== X-Received: by 2002:a05:600c:1e28:b0:46e:3edc:2811 with SMTP id 5b1f17b1804b1-46fa9aa45e2mr198307235e9.14.1760599903791; Thu, 16 Oct 2025 00:31:43 -0700 (PDT) Message-ID: <8913e64b-d172-43f9-9c4d-447ba4984c9a@suse.com> Date: Thu, 16 Oct 2025 09:31:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.21 02/10] x86/HPET: disable unused channels From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Oleksii Kurochko References: <8d94abf8-70d1-478c-885e-ff9a960ac72d@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <8d94abf8-70d1-478c-885e-ff9a960ac72d@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1760599920764158500 Content-Type: text/plain; charset="utf-8" Keeping channels enabled when they're unused is only causing problems: Extra interrupts harm performance, and extra nested interrupts could even have caused worse problems. Note that no explicit "enable" is necessary - that's implicitly done by set_channel_irq_affinity() once the channel goes into use again. Along with disabling the counter, also "clear" the channel's "next event", for it to be properly written by whatever the next user is going to want (possibly avoiding too early an IRQ). Further, along the same lines, don't enable channels early when starting up an IRQ. This similarly should happen no earlier than from set_channel_irq_affinity() (here: once a channel goes into use the very first time). This eliminates a single instance of (XEN) [VT-D]INTR-REMAP: Request device [0000:00:1f.0] fault index 0 (XEN) [VT-D]INTR-REMAP: reason 25 - Blocked a compatibility format interrup= t request during boot. (Why exactly there's only one instance, when we use multiple counters and hence multiple IRQs, I can't tell. My understanding would be that this was due to __hpet_setup_msi_irq() being called only after request_irq() [and hence the .startup handler], yet that should have affected all channels.) Fixes: 3ba523ff957c ("CPUIDLE: enable MSI capable HPET for timer broadcast") Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monn=C3=A9 --- A window still remains for IRQs to be caused by stale comparator values: hpet_attach_channel() is called ahead of reprogram_hpet_evt_channel(). Should we also write the comparator to "far into the future"? Furthermore this prolongues the window until "old" vectors may be released again, as this way we potentially (and intentionally) delay the ocurrence of the next IRQ for the channel in question. (This issue will disappear once we switch to a fixed, global vector.) --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -262,10 +262,9 @@ static void cf_check hpet_msi_unmask(str ch->msi.msi_attrib.host_masked =3D 0; } =20 -static void cf_check hpet_msi_mask(struct irq_desc *desc) +static void hpet_disable_channel(struct hpet_event_channel *ch) { u32 cfg; - struct hpet_event_channel *ch =3D desc->action->dev_id; =20 cfg =3D hpet_read32(HPET_Tn_CFG(ch->idx)); cfg &=3D ~HPET_TN_ENABLE; @@ -273,6 +272,11 @@ static void cf_check hpet_msi_mask(struc ch->msi.msi_attrib.host_masked =3D 1; } =20 +static void cf_check hpet_msi_mask(struct irq_desc *desc) +{ + hpet_disable_channel(desc->action->dev_id); +} + static int hpet_msi_write(struct hpet_event_channel *ch, struct msi_msg *m= sg) { ch->msi.msg =3D *msg; @@ -295,12 +299,6 @@ static int hpet_msi_write(struct hpet_ev return 0; } =20 -static unsigned int cf_check hpet_msi_startup(struct irq_desc *desc) -{ - hpet_msi_unmask(desc); - return 0; -} - #define hpet_msi_shutdown hpet_msi_mask =20 static void cf_check hpet_msi_set_affinity( @@ -326,7 +324,7 @@ static void cf_check hpet_msi_set_affini */ static hw_irq_controller hpet_msi_type =3D { .typename =3D "HPET-MSI", - .startup =3D hpet_msi_startup, + .startup =3D irq_startup_none, .shutdown =3D hpet_msi_shutdown, .enable =3D hpet_msi_unmask, .disable =3D hpet_msi_mask, @@ -542,6 +540,8 @@ static void hpet_detach_channel(unsigned spin_unlock_irq(&ch->lock); else if ( (next =3D cpumask_first(ch->cpumask)) >=3D nr_cpu_ids ) { + hpet_disable_channel(ch); + ch->next_event =3D STIME_MAX; ch->cpu =3D -1; clear_bit(HPET_EVT_USED_BIT, &ch->flags); spin_unlock_irq(&ch->lock);