Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp102758rdb; Fri, 26 Jan 2024 21:42:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIg9K/V0KtHWnK2/g00Zx24oDxFThhpv0cSfJQBiYJdmp29KdP9bk9ru+GpN+LmyKkhZ5f X-Received: by 2002:a05:6a00:1e04:b0:6db:ec12:5ba4 with SMTP id gx4-20020a056a001e0400b006dbec125ba4mr815616pfb.34.1706334157683; Fri, 26 Jan 2024 21:42:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706334157; cv=pass; d=google.com; s=arc-20160816; b=Rs7tXxVb44JcMMG+MQrmfPPA/010/U/GpmCIAqEqhcFctjPUAP4IQetp07c3W01AA4 C/uFE240+2htQQkma9hsjeSKXPQDEuccGbzJ+ZlXo5qJp8jWoiNw2tbNy53U0DsN1cio 0gTyqXah8nxyqpfygh7GOx25tECh1Th6+e85nbRnHmRZeWJhhDD+j5gRVuYhTv8qOdMB ULCDeNcCM0GU50J+cRaR9JYcWq7u25sS9wWIWB2p7Q4eVdpwW4ciRbQwaACzoQVmvbEF eRhgudayImz5yu4LkDMHzRcP9kfqEqpFczoVIFdeb0X3kZD/z7CZHDkQpiU0Ky2ChUFL Upxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wVBg6EqYfzNpq0OtvsNUUJkF00pm79okHM5UpTglfGM=; fh=EHxjn8iMtmEJ1Nwp2Nv05+TVlxb0pe4eSZ5ytBRUMYc=; b=eC5CO4lFhqGawKsyWg3UKLLJm5auZGnH/2gZqvVbmvAouJP5nXbyj+c0iEDc+a1/Q4 kF+90RoQcCLSroJNAHpqOTvGkmdh0faCztnp8nIniyZCzOdsq1U6aU4fsGc+VzFhV33F HG3R8WQ6WUqvYr7yfCmt9J+184NI4PBuKSrhLWBm9Ie3aR2HoKZw0KNVUe90Fpj5TpFZ eyA7JKlV4VQpo/3XfJQSbo8hRC2+vN2EhqKRJ/9kXV7/B9ZLOfbRD9Qh9MBasLNYTsum zPxx0zVAU0V6FQB7bMFhwwVehyZXd3jqK5SfNB7XRR/0M7tsf2PAhf/j2//nMTAByuEp eGiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6tgjPIF; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x35-20020a056a000be300b006dbe92f12dasi2260574pfu.375.2024.01.26.21.42.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 21:42:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6tgjPIF; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A98E0289C69 for ; Fri, 26 Jan 2024 23:39:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FDA460866; Fri, 26 Jan 2024 23:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J6tgjPIF" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 A90365BAE7; Fri, 26 Jan 2024 23:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706312249; cv=none; b=jFaVeGS+m5CDLgnuAYB3uJvAQedi6r61T+5tTNlqsQJ7f+WK8O43pM9xcZVSpHwdC0cHjYO8OohG1uHN5gtLfNMJvf1Q14i2vYGr3fAPTXpUVj0L5wZWTkJF9t4uAHJZKuVI/wV5i5aboHAJlUfs9B2m5/zDlQYqL3IdP62yc2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706312249; c=relaxed/simple; bh=MqzYCPV34vdfoVMKAgtS0juqP6fLnnDqzn4F90K69Xk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L9LIFjH97JfLrZeK47JqeCznRdwPI7D8SicVMdalyeL1P/RiOsfzpfMZKZY/uQrMa2Dm+bXne53fNPMkcxm30TBaE7hcQVWHUv5bGy7vBMtI979ZF1Gzl1yR6PdnCS2gd3b7xcX5YXUd7VIzyvpuVAQBXn2hhNAALPHwWS99twI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=J6tgjPIF; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706312248; x=1737848248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MqzYCPV34vdfoVMKAgtS0juqP6fLnnDqzn4F90K69Xk=; b=J6tgjPIFmZEEAu3lcIFffeQgtu8D++Cv4u8kZ853dPNWmQ6qxXQLXw+6 vaTQjmtiWbw1/k8HsuDPk7ZeJKgWjslKaN8JWY7qQ2NzogM5XmBvgybx3 BPXUuTYVd+60XLenrTBej+2Bb3DOy1jDBbbql2kW7q+RK4E5U1oeOOyhD hLCMg2HMjZEqP8oAl5tmFSuSDd4Q3Mlscy74P/nx05H8pCtEypadbKxGY RijMjjo22AdPN9RL9D1avMKJ2U9CeWyaqljl0njH9CR1GSP9owcJGpSBx /GCqIxlUIHjs5tR+wlDA/sa+EwsXcr77C9ikjTRQCEYNwO3Zt8IdYtUQM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9990714" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="9990714" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 15:37:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="821290731" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="821290731" Received: from srinivas-otcpl-7600.jf.intel.com (HELO jacob-builder.jf.intel.com) ([10.54.39.116]) by orsmga001.jf.intel.com with ESMTP; 26 Jan 2024 15:37:21 -0800 From: Jacob Pan To: LKML , X86 Kernel , Peter Zijlstra , iommu@lists.linux.dev, Thomas Gleixner , "Lu Baolu" , kvm@vger.kernel.org, Dave Hansen , Joerg Roedel , "H. Peter Anvin" , "Borislav Petkov" , "Ingo Molnar" Cc: Paul Luse , Dan Williams , Jens Axboe , Raj Ashok , "Tian, Kevin" , maz@kernel.org, seanjc@google.com, "Robin Murphy" , Jacob Pan Subject: [PATCH 07/15] x86/irq: Add accessors for posted interrupt descriptors Date: Fri, 26 Jan 2024 15:42:29 -0800 Message-Id: <20240126234237.547278-8-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240126234237.547278-1-jacob.jun.pan@linux.intel.com> References: <20240126234237.547278-1-jacob.jun.pan@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Posted interrupts are controlled by and pending interrupts are marked in the posted interrupt descriptor. The upcoming support for host side posted interrupts requires accessors to check for pending vectors. This patch adds a helper function to check individual vector status. Signed-off-by: Jacob Pan --- arch/x86/include/asm/posted_intr.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/include/asm/posted_intr.h b/arch/x86/include/asm/posted_intr.h index a36cc971ea13..eb939f630b02 100644 --- a/arch/x86/include/asm/posted_intr.h +++ b/arch/x86/include/asm/posted_intr.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _X86_POSTED_INTR_H #define _X86_POSTED_INTR_H +#include #define POSTED_INTR_ON 0 #define POSTED_INTR_SN 1 @@ -89,9 +90,26 @@ static inline bool pi_test_sn(struct pi_desc *pi_desc) } #ifdef CONFIG_X86_POSTED_MSI +/* + * Not all external vectors are subject to interrupt remapping, e.g. IOMMU's + * own interrupts. Here we do not distinguish them since those vector bits in + * PIR will always be zero. + */ +static inline bool pi_pending_this_cpu(unsigned int vector) +{ + struct pi_desc *pid = this_cpu_ptr(&posted_interrupt_desc); + + if (WARN_ON_ONCE(vector > NR_VECTORS || vector < FIRST_EXTERNAL_VECTOR)) + return false; + + return test_bit(vector, (unsigned long *)pid->pir); +} + extern void intel_posted_msi_init(void); #else +static inline bool pi_pending_this_cpu(unsigned int vector) { return false; } + static inline void intel_posted_msi_init(void) {}; #endif /* X86_POSTED_MSI */ -- 2.25.1