From nobody Sat Feb 7 23:23:20 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 5CDDC13B5B7 for ; Thu, 11 Apr 2024 03:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804941; cv=none; b=qF3BXBNAo6aZm4ie7VUta4aSet03pKjKzGEonbBYt3vjdfqp2I3o0U0yHFCc2VwGcMyfdIqsfks0UBhc23ZoWLnnT5TMZOM8siCKMchutl8YFqo9dwFF3vBJZ9QGioM3gywJ2ZKFkgb6gyWKIFiHi6uY6wYP7PYJ7o0MOzVgnFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804941; c=relaxed/simple; bh=CrCQveiZdwYAH0mjaVPcjR6DITjQEl30tKTsxVaY4M0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oGNLlvwSM8T70OiIqRr/PgIPxsI45PgWhNpbNnfWuHuMkrEuSSGZkZ04CObt2JY77PcpwJIK2tlJgJw+mIgtvHuzJSrvkHjG3fzGaRuTN86V2U9Hhd6JRIPp3iwu4enilG/xRCsQXTMcjY3QFK1FCP8pIWDQZISLH+8m08FsN1A= 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=GRyKRaQS; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GRyKRaQS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712804940; x=1744340940; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CrCQveiZdwYAH0mjaVPcjR6DITjQEl30tKTsxVaY4M0=; b=GRyKRaQSyI0JIockxFlNIh7R7vxnsTGbdd0S8N+PJlNHhyYOWFAJEhJy 3sSmXZJjb/Il489d5Rgz7kpgms/4SqksIGEsn6K+MMLfPA5+pcfSWANii 1xXO/Zv4HjfLgWtruOznpAvTO7zHVNO6WqTEFW/ObL8IFv+bYWYNOw7WV uEm/BX8K8HZOLpbcVfX6390zfSh5WMm4XyBNRBHz+4GXtZ+6ShAykvz1Q yw0Mm9xfOaFzY2sECANVyvzXsmDq2b9F8mKXvOCl/Alz9L5/M62dhCKkn WzQlZtarKyHSf9srvL3Yur01AiTmXFLFbKqxElT4TguKNy7tfJ9QGImaT w==; X-CSE-ConnectionGUID: faPHAm63TeSvCcMfzzkCZw== X-CSE-MsgGUID: +CXydNXaR6CHR/2PTL3IhA== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="30681438" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="30681438" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 20:08:59 -0700 X-CSE-ConnectionGUID: 6U1REfodQoa03XAI2YHA1Q== X-CSE-MsgGUID: Q0hxQO99SRKIYxHMhqIDTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20822964" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 10 Apr 2024 20:08:57 -0700 From: Lu Baolu To: Joerg Roedel Cc: Jacob Pan , Xuchun Shang , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] iommu/vt-d: Fix wrong use of pasid config Date: Thu, 11 Apr 2024 11:07:42 +0800 Message-Id: <20240411030744.273460-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411030744.273460-1-baolu.lu@linux.intel.com> References: <20240411030744.273460-1-baolu.lu@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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xuchun Shang The commit "iommu/vt-d: Add IOMMU perfmon support" introduce IOMMU PMU feature, but use the wrong config when set pasid filter. Fixes: 7232ab8b89e9 ("iommu/vt-d: Add IOMMU perfmon support") Signed-off-by: Xuchun Shang Reviewed-by: Kan Liang Link: https://lore.kernel.org/r/20240401060753.3321318-1-xuchun.shang@linux= .alibaba.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/perfmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/perfmon.c b/drivers/iommu/intel/perfmon.c index cf43e798eca4..44083d01852d 100644 --- a/drivers/iommu/intel/perfmon.c +++ b/drivers/iommu/intel/perfmon.c @@ -438,7 +438,7 @@ static int iommu_pmu_assign_event(struct iommu_pmu *iom= mu_pmu, iommu_pmu_set_filter(domain, event->attr.config1, IOMMU_PMU_FILTER_DOMAIN, idx, event->attr.config1); - iommu_pmu_set_filter(pasid, event->attr.config1, + iommu_pmu_set_filter(pasid, event->attr.config2, IOMMU_PMU_FILTER_PASID, idx, event->attr.config1); iommu_pmu_set_filter(ats, event->attr.config2, --=20 2.34.1 From nobody Sat Feb 7 23:23:20 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 C2F7013B795 for ; Thu, 11 Apr 2024 03:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804942; cv=none; b=u3B5dgdF3u56U6GVfa8fVQn8Y/ZqKMwIxegXWM8Ku1Vebn4rz9e8TlTmyCWcSUVPVq81vb09Ti648IV8vjtu8Bq1flyIiV+mebXBpipSspJnA1eSkMuz0eqGqujjY80Zh6xcJMCCIqb7kBL5mG6ks8nu04ziaLEm7lac+/iTcsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804942; c=relaxed/simple; bh=OGnOMxkpin9TYenIr8jNLqVcXysJ8LZw6T1asCHfxQA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ddnfg2dNNhgIAhWcSBiUCS4j8du74rnViqW1nCFfLeCMpzPuZvBWAWZ8DfWPeGvWAgbEzxdnu0pWgJNtHbJ2Hci3OAB0e5Mp2Qh5cW6aYJl0n2B9vKGLbnHqKgOP7ePSdRMNY3BDv94B8l8lhlxcqXiUAj8otPRoJL7s5sFNKMw= 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=Zj3Xqoc+; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Zj3Xqoc+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712804941; x=1744340941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OGnOMxkpin9TYenIr8jNLqVcXysJ8LZw6T1asCHfxQA=; b=Zj3Xqoc+OJ9ze3/clfGcrAhgCK93eZMLd7ARnjRzAEtoO8w2IqyRW4Gm QmZjOmyotw4yK561QJN2w8uPLDjqob+Cp5LsemROJwUiIF8XPqY0Ln5X5 ScNYcV6GGKSohwIE5IW0Fx5QxvW2Nv1xshy/pXQo7F9X85ClVzBFANrge XyPZ2Kb/mkWy1S92KlqW6JDnV9bCINoKt2Vd4o6342jyBaX2dtjyQ7pVU XLpVOLpuUh4xIQu4PQ1F0BMeFJ9aEikzerOnHiyuU2U8K7+VOo47rWtsd jmbkjPEhRBeWehnyGh2A6xoCgWIHXvOnev3mmTu3LXdfaIgTHjuqgbj6s Q==; X-CSE-ConnectionGUID: HSHb+TRARp6y58sem3PMMw== X-CSE-MsgGUID: aP0GrKg6T32tSWtgKZkTSA== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="30681442" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="30681442" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 20:09:00 -0700 X-CSE-ConnectionGUID: c67rkbpHQduq8UVS+RAUvg== X-CSE-MsgGUID: BDA9RDfFQgWOqCEdwfaKcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20822973" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 10 Apr 2024 20:08:59 -0700 From: Lu Baolu To: Joerg Roedel Cc: Jacob Pan , Xuchun Shang , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] iommu/vt-d: Allocate local memory for page request queue Date: Thu, 11 Apr 2024 11:07:43 +0800 Message-Id: <20240411030744.273460-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411030744.273460-1-baolu.lu@linux.intel.com> References: <20240411030744.273460-1-baolu.lu@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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jacob Pan The page request queue is per IOMMU, its allocation should be made NUMA-aware for performance reasons. Fixes: a222a7f0bb6c ("iommu/vt-d: Implement page request handling") Signed-off-by: Jacob Pan Reviewed-by: Kevin Tian Link: https://lore.kernel.org/r/20240403214007.985600-1-jacob.jun.pan@linux= .intel.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index c1bed89b1026..ee3b469e2da1 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -66,7 +66,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu) struct page *pages; int irq, ret; =20 - pages =3D alloc_pages(GFP_KERNEL | __GFP_ZERO, PRQ_ORDER); + pages =3D alloc_pages_node(iommu->node, GFP_KERNEL | __GFP_ZERO, PRQ_ORDE= R); if (!pages) { pr_warn("IOMMU: %s: Failed to allocate page request queue\n", iommu->name); --=20 2.34.1 From nobody Sat Feb 7 23:23:20 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 2EAB513BACD for ; Thu, 11 Apr 2024 03:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804943; cv=none; b=n4gUf9CBoKOHAOm+3pDLznFq8IvefYLjcd//sxtxn6UE4GqK9AL88qJyCH5lIRqACvyejsMT7eOnGWVnEWLhCcB+Wh5TY9qd7Y4bwhKNC/mP9oxDmj7Aax+uo3Pg+L8Y+rC53pWYGpt4iQQKEY6L1FZa4cwE8xyuH+P3CQsky7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712804943; c=relaxed/simple; bh=UtbS/BnDM6+ab6c1umntrMRFPd2zV9Gtz174uvCGgpM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cMKtKzAp2p2JJtQOQd9Mn0Nni+KeWS5uBX45yXhnzhPyV0LLMDFk3SS/8X67tSsmwvzqt+EyI+RwAFzZIoxQ8t68btBOq5dnvbJtf68okFyA2AkdfUcIHJUVpm7yYQoJ9rPyAFkyowQVhBgjNdFPTLVHMbRlktwG8mkq/jYaKtA= 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=NXaPhY0K; arc=none smtp.client-ip=198.175.65.9 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NXaPhY0K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712804942; x=1744340942; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UtbS/BnDM6+ab6c1umntrMRFPd2zV9Gtz174uvCGgpM=; b=NXaPhY0KQyKr/vtJNaCVlfXYa/x9+88xFP8NyyQWo1p2BmBoN22mc82P QaRditLRoc7i0jyUkotA4H12A19oyxV5tBmV22x8nJXo4hGaLzIm60Lx/ yZRzETibDadCvkC06tZesF5FAmaeFnE8Da6WaQPtTFV0mjcPWKdjXbAU+ wrXGe2hEGvC4e4Dt/GMidKN5eZG3RKxRr/qj/p+bwDsu0VGEBNKNcLtA2 ezmNHoNulNoQulQjNERqz7v7u2XU41ekE+lSaGq1IKHcF/Ub7gvrsr1pX yvVj+bPqzvfF/Cx0Du39p075qpLOmDZvZXKPxgEuI5yXpKOX/dn2iQFBi w==; X-CSE-ConnectionGUID: 83LeiyXiTF2zvBl8TO9brQ== X-CSE-MsgGUID: Vxiz7qGqQmy4P6/5dr6eOA== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="30681448" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="30681448" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 20:09:02 -0700 X-CSE-ConnectionGUID: 9FC1E0BbQCSatbM0W1KKnQ== X-CSE-MsgGUID: hRrOEHiFSrCGBP9U0TSrug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20822978" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 10 Apr 2024 20:09:00 -0700 From: Lu Baolu To: Joerg Roedel Cc: Jacob Pan , Xuchun Shang , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] iommu/vt-d: Fix WARN_ON in iommu probe path Date: Thu, 11 Apr 2024 11:07:44 +0800 Message-Id: <20240411030744.273460-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411030744.273460-1-baolu.lu@linux.intel.com> References: <20240411030744.273460-1-baolu.lu@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: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 1a75cc710b95 ("iommu/vt-d: Use rbtree to track iommu probed devices") adds all devices probed by the iommu driver in a rbtree indexed by the source ID of each device. It assumes that each device has a unique source ID. This assumption is incorrect and the VT-d spec doesn't state this requirement either. The reason for using a rbtree to track devices is to look up the device with PCI bus and devfunc in the paths of handling ATS invalidation time out error and the PRI I/O page faults. Both are PCI ATS feature related. Only track the devices that have PCI ATS capabilities in the rbtree to avoid unnecessary WARN_ON in the iommu probe path. Otherwise, on some platforms below kernel splat will be displayed and the iommu probe results in failure. WARNING: CPU: 3 PID: 166 at drivers/iommu/intel/iommu.c:158 intel_iommu_pr= obe_device+0x319/0xd90 Call Trace: ? __warn+0x7e/0x180 ? intel_iommu_probe_device+0x319/0xd90 ? report_bug+0x1f8/0x200 ? handle_bug+0x3c/0x70 ? exc_invalid_op+0x18/0x70 ? asm_exc_invalid_op+0x1a/0x20 ? intel_iommu_probe_device+0x319/0xd90 ? debug_mutex_init+0x37/0x50 __iommu_probe_device+0xf2/0x4f0 iommu_probe_device+0x22/0x70 iommu_bus_notifier+0x1e/0x40 notifier_call_chain+0x46/0x150 blocking_notifier_call_chain+0x42/0x60 bus_notify+0x2f/0x50 device_add+0x5ed/0x7e0 platform_device_add+0xf5/0x240 mfd_add_devices+0x3f9/0x500 ? preempt_count_add+0x4c/0xa0 ? up_write+0xa2/0x1b0 ? __debugfs_create_file+0xe3/0x150 intel_lpss_probe+0x49f/0x5b0 ? pci_conf1_write+0xa3/0xf0 intel_lpss_pci_probe+0xcf/0x110 [intel_lpss_pci] pci_device_probe+0x95/0x120 really_probe+0xd9/0x370 ? __pfx___driver_attach+0x10/0x10 __driver_probe_device+0x73/0x150 driver_probe_device+0x19/0xa0 __driver_attach+0xb6/0x180 ? __pfx___driver_attach+0x10/0x10 bus_for_each_dev+0x77/0xd0 bus_add_driver+0x114/0x210 driver_register+0x5b/0x110 ? __pfx_intel_lpss_pci_driver_init+0x10/0x10 [intel_lpss_pci] do_one_initcall+0x57/0x2b0 ? kmalloc_trace+0x21e/0x280 ? do_init_module+0x1e/0x210 do_init_module+0x5f/0x210 load_module+0x1d37/0x1fc0 ? init_module_from_file+0x86/0xd0 init_module_from_file+0x86/0xd0 idempotent_init_module+0x17c/0x230 __x64_sys_finit_module+0x56/0xb0 do_syscall_64+0x6e/0x140 entry_SYSCALL_64_after_hwframe+0x71/0x79 Fixes: 1a75cc710b95 ("iommu/vt-d: Use rbtree to track iommu probed devices") Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10689 Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20240407011429.136282-1-baolu.lu@linux.inte= l.com Reviewed-by: Kevin Tian --- drivers/iommu/intel/iommu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 50eb9aed47cc..a7ecd90303dc 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4299,9 +4299,11 @@ static struct iommu_device *intel_iommu_probe_device= (struct device *dev) } =20 dev_iommu_priv_set(dev, info); - ret =3D device_rbtree_insert(iommu, info); - if (ret) - goto free; + if (pdev && pci_ats_supported(pdev)) { + ret =3D device_rbtree_insert(iommu, info); + if (ret) + goto free; + } =20 if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) { ret =3D intel_pasid_alloc_table(dev); @@ -4336,7 +4338,8 @@ static void intel_iommu_release_device(struct device = *dev) struct intel_iommu *iommu =3D info->iommu; =20 mutex_lock(&iommu->iopf_lock); - device_rbtree_remove(info); + if (dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev))) + device_rbtree_remove(info); mutex_unlock(&iommu->iopf_lock); =20 if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev) && --=20 2.34.1