Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp108915rdb; Fri, 26 Jan 2024 22:04:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWxIlUuE1DoVeENuIN+HrOZiZDYiEDn3c7QARpEx6QiKiFj4My0xQYXGAP5Ez5iefQj+Ir X-Received: by 2002:a0d:d781:0:b0:5ff:85e6:717b with SMTP id z123-20020a0dd781000000b005ff85e6717bmr1023505ywd.70.1706335495083; Fri, 26 Jan 2024 22:04:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706335495; cv=pass; d=google.com; s=arc-20160816; b=R7pR88uXKh3/s81LY6lQW0h16CjJEaAe+SSsXthWFPp+QtXdBdQAnac4kh8svK1N8C pUunCKpGxNOvHMezJKRATfZ97U7g8NGc0yFhbJouZakIK7Vc4Lh0aqJvht61XajaAcmH rCIQ8zjfEb3d+0xJbjTSHFw5MdU2WI7niWS8ZC626q4SH73wil5TP4v6AuUL6WMZVSgq JG1e9D+q9hfUnWXaETBhgLKO1HskMPb8xlJy3AxqsqKfycTsrGG1vSvnFiw5/FxP35Mr xpnH8iTgHXS0SpY46T7+bKROcA+vWqi8B1klG7wOwz1ImLV7H2oMoVEyFAKm9c35L+dv UHmA== 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=boyYNHPb4W//sP77V5gYcDmdv4gVsXvXFUaF79zRXQM=; fh=EHxjn8iMtmEJ1Nwp2Nv05+TVlxb0pe4eSZ5ytBRUMYc=; b=tspHSDVeS0507U0LI/YXy60HwnnrqpgVk+1ONXtdec4QEboiSQE1llKLTkA5A3WeCE WwHlcvPdkCw4Ze7q60CvMRf1C1+oFNu3gSkhRXWW5cMC+T0PJkFTIXTbvkzP+jPZC5My KVthXceAl82GwopjLrb0WLQYia5sNY/IYGhhCXVKD1T4fIln3NAGRc+IPUqhn6FKXTbT sKmOHo2r/RmM0m/QKPmU00JMJyjl857grGswEWLyt7d0Rge9J4QuQRE4g7aTrGGz3NDn /NcjLEFeJzhM2sl57YpaiepE43JFGJIqhevcMqGGlUw9y+yskNPHaR2/NksRaZk0JxX3 oUcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nR8z5EQ+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q4-20020a170902dac400b001d73192de39si2404140plx.36.2024.01.26.22.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 22:04:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nR8z5EQ+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40858-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C206BB2105B for ; Fri, 26 Jan 2024 23:39:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2740604CA; Fri, 26 Jan 2024 23:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nR8z5EQ+" 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 C3AA65A7AC; Fri, 26 Jan 2024 23:37:25 +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=1706312247; cv=none; b=XpPeUT3i5BmvrkxIsTn+zthLVe5Nui6FA6HlG2NMZruAwAKZ6dz89P+236m4Vet8/Tn2udhNtcOD5aQn9Z9X+lN+VRyiXtMzgolLWb6ogBpnaegSGWPQeUe3F747oz+g0IFDuIWjUnnZ/DsNLsYE922vmFmw+zp5L0194UrifjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706312247; c=relaxed/simple; bh=+jcfYcRgLrk4OhxkOXBPXFSpbQQeXvWOwimgSWB0zss=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TdFEiq7MrOSWCHW8d98PG8/9xgrpm/nnr1eJp8jH9qNBO/G/4AMiMWBXAjF9S+LbmnVTpU1PF3vhcISh3AeqEwUdJI97C+2KyNauCzXBKBGrpiLkn2hi7VrmOL0muCiwVDOBaV07Xr0DHu5nBOC+CEttqTgJRN63q3cD+RapmQQ= 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=nR8z5EQ+; 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=1706312246; x=1737848246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+jcfYcRgLrk4OhxkOXBPXFSpbQQeXvWOwimgSWB0zss=; b=nR8z5EQ+GTHFx2l49XovDXyuCOKPzblDhxWmnJF8NCI+2U0tnSx1yH7x d/J9dsfp32mTczBdrqEA6sZ/h7z1pq9nSxIAOMtJYq8/qfWo7RmCcb4P8 tKW+XSeC6f8GBxgz+0WzkwvR3J0+h29RhcUoJ+Q3UNoleLZgH81x4u59e seGva7bVVMIpmwXPXdP7EsKfgD7tTJpsOfeCkV99KYA1UDv1wk46QjDTL aBJT32E3p8akCKyg85y+ZGefBTtB6Ng+zC0ohmBcIpvVhC0c/TyoJTg7Z APvA675h4DrPyTwazejFOk7YgMxPW4jSmoYRl0ZF7qgFQsfzMgXLG2NTd w==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9990697" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="9990697" 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="821290728" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="821290728" 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 06/15] x86/irq: Set up per host CPU posted interrupt descriptors Date: Fri, 26 Jan 2024 15:42:28 -0800 Message-Id: <20240126234237.547278-7-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 From: Thomas Gleixner To support posted MSIs, create a posted interrupt descriptor (PID) for each host CPU. Later on, when setting up IRQ CPU affinity, IOMMU's interrupt remapping table entry (IRTE) will point to the physical address of the matching CPU's PID. Each PID is initialized with the owner CPU's physical APICID as the destination. Signed-off-by: Thomas Gleixner Signed-off-by: Jacob Pan --- arch/x86/include/asm/hardirq.h | 3 +++ arch/x86/include/asm/posted_intr.h | 7 +++++++ arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/irq.c | 16 ++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h index 66837b8c67f1..72c6a084dba3 100644 --- a/arch/x86/include/asm/hardirq.h +++ b/arch/x86/include/asm/hardirq.h @@ -48,6 +48,9 @@ typedef struct { DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); +#ifdef CONFIG_X86_POSTED_MSI +DECLARE_PER_CPU_ALIGNED(struct pi_desc, posted_interrupt_desc); +#endif #define __ARCH_IRQ_STAT #define inc_irq_stat(member) this_cpu_inc(irq_stat.member) diff --git a/arch/x86/include/asm/posted_intr.h b/arch/x86/include/asm/posted_intr.h index 896b3462f3dd..a36cc971ea13 100644 --- a/arch/x86/include/asm/posted_intr.h +++ b/arch/x86/include/asm/posted_intr.h @@ -88,4 +88,11 @@ static inline bool pi_test_sn(struct pi_desc *pi_desc) return test_bit(POSTED_INTR_SN, (unsigned long *)&pi_desc->control); } +#ifdef CONFIG_X86_POSTED_MSI +extern void intel_posted_msi_init(void); + +#else +static inline void intel_posted_msi_init(void) {}; + +#endif /* X86_POSTED_MSI */ #endif /* _X86_POSTED_INTR_H */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 0b97bcde70c6..9b6248e7c073 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -67,6 +67,7 @@ #include #include #include +#include #include "cpu.h" @@ -2253,6 +2254,8 @@ void cpu_init(void) barrier(); x2apic_setup(); + + intel_posted_msi_init(); } mmgrab(&init_mm); diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 11761c124545..f6546f83d616 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #define CREATE_TRACE_POINTS #include @@ -334,6 +336,20 @@ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm_posted_intr_nested_ipi) } #endif +#ifdef CONFIG_X86_POSTED_MSI + +/* Posted Interrupt Descriptors for coalesced MSIs to be posted */ +DEFINE_PER_CPU_ALIGNED(struct pi_desc, posted_interrupt_desc); + +void intel_posted_msi_init(void) +{ + struct pi_desc *pid = this_cpu_ptr(&posted_interrupt_desc); + + pid->nv = POSTED_MSI_NOTIFICATION_VECTOR; + pid->ndst = this_cpu_read(x86_cpu_to_apicid); +} +} +#endif /* X86_POSTED_MSI */ #ifdef CONFIG_HOTPLUG_CPU /* A cpu has been removed from cpu_online_mask. Reset irq affinities. */ -- 2.25.1