From nobody Wed Feb 11 19:41:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38D65C76196 for ; Tue, 11 Apr 2023 06:49:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbjDKGtU (ORCPT ); Tue, 11 Apr 2023 02:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjDKGsy (ORCPT ); Tue, 11 Apr 2023 02:48:54 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E45744AE for ; Mon, 10 Apr 2023 23:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681195717; x=1712731717; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rMHo8yYSBVXvdzGdpugvYObeZKKcdE/cMZKOA3T4vNU=; b=TANIm8Aa2l+BxJt/94b5Eh4ELo/utgeM/03osoMLzbwrw0jZMk94pXq3 +xmoSgFB54tjLoppcGuDsckqwyB6/ZUiyd4ltn42ZGcLySdy4zWpGw97D HM4fDVxcQNAiwkh8gQ3UAHgEPy6C/Us2XhwQRr5z1eVQzSZFRAZVNQ363 v0n7bRimIMSTwZk4mHk5jbGctNyg0yr+ih3xkwIsENFrGuLSl+XWI9KjC 3O41Sl/F8o3QW7SFkHPFa2fZmVbDeM9S9NmjubhZ0hjKGmPQALtcNHbfZ 8OZSLMXNEbzUNElQeDpx/EJ/YOwPootmR8LZTFrsNn5fIT7rSqiSYtm9b A==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="341028504" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="341028504" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2023 23:48:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="1018256541" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="1018256541" Received: from allen-box.sh.intel.com ([10.239.159.127]) by fmsmga005.fm.intel.com with ESMTP; 10 Apr 2023 23:48:13 -0700 From: Lu Baolu To: Joerg Roedel Cc: Vinod Koul , Tina Zhang , Jacob Pan , Christophe JAILLET , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 02/17] iommu/vt-d: Allow SVA with device-specific IOPF Date: Tue, 11 Apr 2023 14:48:00 +0800 Message-Id: <20230411064815.31456-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411064815.31456-1-baolu.lu@linux.intel.com> References: <20230411064815.31456-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently enabling SVA requires IOPF support from the IOMMU and device PCI PRI. However, some devices can handle IOPF by itself without ever sending PCI page requests nor advertising PRI capability. Allow SVA support with IOPF handled either by IOMMU (PCI PRI) or device driver (device-specific IOPF). As long as IOPF could be handled, SVA should continue to work. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Link: https://lore.kernel.org/r/20230324120234.313643-3-baolu.lu@linux.inte= l.com --- drivers/iommu/intel/iommu.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 7c2f4bd33582..caf664448ee9 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4650,7 +4650,21 @@ static int intel_iommu_enable_sva(struct device *dev) if (!(iommu->flags & VTD_FLAG_SVM_CAPABLE)) return -ENODEV; =20 - if (!info->pasid_enabled || !info->pri_enabled || !info->ats_enabled) + if (!info->pasid_enabled || !info->ats_enabled) + return -EINVAL; + + /* + * Devices having device-specific I/O fault handling should not + * support PCI/PRI. The IOMMU side has no means to check the + * capability of device-specific IOPF. Therefore, IOMMU can only + * default that if the device driver enables SVA on a non-PRI + * device, it will handle IOPF in its own way. + */ + if (!info->pri_supported) + return 0; + + /* Devices supporting PRI should have it enabled. */ + if (!info->pri_enabled) return -EINVAL; =20 ret =3D iopf_queue_add_device(iommu->iopf_queue, dev); --=20 2.34.1