From patchwork Fri Oct 18 05:58:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 13841173 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 C1041184535 for ; Fri, 18 Oct 2024 05:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729231109; cv=none; b=gQBnX6hCv6naK48r0oX54W29mJXqiRUlGN2KWFVbjczYZBGs2b/BQa+/pCXGwaOrZgUy8NwCyZVKMjHL/V8IQ2lqs4XsrCDs9Ebd0GJPKY2ksoJPfK2GWqY7syo4MATV50S06B/GA0R6BNYuQV97JDCVRf7wFhzmV9dnqPcLNo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729231109; c=relaxed/simple; bh=hQh/alPdWirG+fauDX2BRT65avMKmeffGeTFMuJoT9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cgnHmucBtmZnIfij19uFBLgV2prFGo1IAW1ghccYaiiLi0RA2tVKCiePj0CpKS5gRGFX0/taJ1roxF6fDN6jgIUFI0eVfpzjC9/SNDPC+GZcJAkT8RrLDVxFeQknzdegNdBxwIhmj6S3roM8dp3mMb4e10REP6NBRJg6rSDeGbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=anTxONkt; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="anTxONkt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729231107; x=1760767107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hQh/alPdWirG+fauDX2BRT65avMKmeffGeTFMuJoT9M=; b=anTxONktRBvQC+gv2jY86AHIVz5XkMs6DHBLuK3q4QlAqPDPqMc237x4 wyJwx3lk4fhHW9MRIA/kIRni4J7w94ZHQP02OLT7LSiA5aZRDRist9bEY 6q7IqRT+Qi3VOeF6NWV8EcEmUblo7TrhHWHfe7kKxFlSSMX46FyceuDi3 5FcbUh3Xjmy9Ci16TrpzOtTSpjK4VhwpO4vjzAfEwbKwUqXdyZ6uqKbeU 3MTKHQVKkm3TEZcZm0zdUmvUL0g0lw9CPm/h+FZcFV0p28qQcJoeb39In isG4PUigTU83jSRRYbAmtG2/d24nz6PNAejsb4IgkIErrC3fyyB9jvYli w==; X-CSE-ConnectionGUID: 2+HCHanSRvundOFGEm58wA== X-CSE-MsgGUID: jQJ8zExqQOyShU/k1ynA7Q== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="39879122" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="39879122" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 22:58:26 -0700 X-CSE-ConnectionGUID: FWHub406T+S05+lIMpI0dg== X-CSE-MsgGUID: 6LKb6JYQQ6OA4tC/G/bvuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="78675724" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orviesa009.jf.intel.com with ESMTP; 17 Oct 2024 22:58:26 -0700 From: Yi Liu To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, will@kernel.org Cc: alex.williamson@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, iommu@lists.linux.dev, zhenzhong.duan@intel.com, vasant.hegde@amd.com Subject: [PATCH v2 1/3] iommu: Add a wrapper for remove_dev_pasid Date: Thu, 17 Oct 2024 22:58:22 -0700 Message-Id: <20241018055824.24880-2-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018055824.24880-1-yi.l.liu@intel.com> References: <20241018055824.24880-1-yi.l.liu@intel.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The iommu drivers are on the way to drop the remove_dev_pasid op by extending the blocked_domain to support PASID. However, this cannot be done in one shot. So far, the Intel iommu and the ARM SMMUv3 driver have supported it, while the AMD iommu driver has not yet. During this transition, the IOMMU core needs to support both ways to destroy the attachment of device/PASID and domain. Reviewed-by: Kevin Tian Signed-off-by: Yi Liu --- drivers/iommu/iommu.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f3f81c04b8fb..9266e4ebebc2 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3324,6 +3324,28 @@ bool iommu_group_dma_owner_claimed(struct iommu_group *group) } EXPORT_SYMBOL_GPL(iommu_group_dma_owner_claimed); +/* + * This is gated by AMD's blocked domain pasid support, it should be + * dropped once AMD iommu driver is ready. + */ +static void iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid, + struct iommu_domain *domain) +{ + const struct iommu_ops *ops = dev_iommu_ops(dev); + struct iommu_domain *blocked_domain = ops->blocked_domain; + int ret = 1; + + if (blocked_domain->ops->set_dev_pasid) { + ret = blocked_domain->ops->set_dev_pasid(blocked_domain, + dev, pasid, domain); + } else if (ops->remove_dev_pasid) { + ops->remove_dev_pasid(dev, pasid, domain); + ret = 0; + } + + WARN_ON(ret); +} + static int __iommu_set_group_pasid(struct iommu_domain *domain, struct iommu_group *group, ioasid_t pasid) { @@ -3342,11 +3364,9 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain, err_revert: last_gdev = device; for_each_group_device(group, device) { - const struct iommu_ops *ops = dev_iommu_ops(device->dev); - if (device == last_gdev) break; - ops->remove_dev_pasid(device->dev, pasid, domain); + iommu_remove_dev_pasid(device->dev, pasid, domain); } return ret; } @@ -3356,11 +3376,9 @@ static void __iommu_remove_group_pasid(struct iommu_group *group, struct iommu_domain *domain) { struct group_device *device; - const struct iommu_ops *ops; for_each_group_device(group, device) { - ops = dev_iommu_ops(device->dev); - ops->remove_dev_pasid(device->dev, pasid, domain); + iommu_remove_dev_pasid(device->dev, pasid, domain); } } From patchwork Fri Oct 18 05:58:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 13841174 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 19FE7185B68 for ; Fri, 18 Oct 2024 05:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729231110; cv=none; b=OfM2gejJ/4x7OjnE1B+tMIF89Gw0QTYLpzKSMohFhzC+6M+bQ7iVbuS0H2aiDPzlm1seujClBFAJOiOM0CVQGuYbf6bzR88U4aMBjpaBFZhmyW4B+l2P0F2GCS7pImP3XsVuz+3/SjCLo9YnzWrxTKXB9On8A8LKbJWxiOiJGN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729231110; c=relaxed/simple; bh=T7fBMWi071z7M1pLhief7DGpLGWGlmFH1yYzkvK762c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ocOkRAJ04KfQy4MOshfl2O2X0VypSRR5ejmcybk9ApJRsL00BKD999SfKg0N9rs2KNapOVtqxl4+Ns3wVMIGXc2GcmUyK+wJeVkvpp5nacaohNpUNioit3Vnk5mZw5ejMyKHnO2biAOQfHZQqQ9wFitpPLIc76Z7hLLrQ+h/uto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hHI41tyZ; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hHI41tyZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729231108; x=1760767108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T7fBMWi071z7M1pLhief7DGpLGWGlmFH1yYzkvK762c=; b=hHI41tyZN+sbbdQjSfvGf5lQMllU6/MkHhAIgfmkMwOsTfZMEFLCJRQt 2Ybw6OsazvK1qvH7ocsjApILZAHLMf1tVPbLckKVh0YV0TSZ1GGTEaczK k0aHlhAhcnJWAHqX7VWwY0sqXIPTycmTc8bpDXkecI51vFZMBnLR0GNrO hpwBdz/I40FGVPCGz8eU3YD4yqr72L/xfecoU/0Yaw+UTcNP+TWA4GHUw nK7tuhQ6qqp3ubIDxXjv7hUtVEoxWmeNxJMUrPdZlfmGBwB2iPH/hQ7JF /KexRPTz7jwATCzz+kCcrKSYzfwbB5glsmxwky29Gs76Ge083XDY8DmUu Q==; X-CSE-ConnectionGUID: 2ukODoyGQ9KBjhz8Ru+b2g== X-CSE-MsgGUID: LHvN+9wGTyCQaUPJ3IHCcg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="39879131" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="39879131" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 22:58:27 -0700 X-CSE-ConnectionGUID: mCUYuPyqSDeqfzKB/nPR3g== X-CSE-MsgGUID: Xh6VZBgbRHyri+f8sBdP2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="78675730" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orviesa009.jf.intel.com with ESMTP; 17 Oct 2024 22:58:27 -0700 From: Yi Liu To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, will@kernel.org Cc: alex.williamson@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, iommu@lists.linux.dev, zhenzhong.duan@intel.com, vasant.hegde@amd.com Subject: [PATCH v2 2/3] iommu/arm-smmu-v3: Make the blocked domain support PASID Date: Thu, 17 Oct 2024 22:58:23 -0700 Message-Id: <20241018055824.24880-3-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018055824.24880-1-yi.l.liu@intel.com> References: <20241018055824.24880-1-yi.l.liu@intel.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gunthorpe The blocked domain is used to park RID to be blocking DMA state. This can be extended to PASID as well. By this, the remove_dev_pasid() op of ARM SMMUv3 can be dropped. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Yi Liu --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index f70165f544df..ae68c7b7fcd5 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2961,13 +2961,12 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master, return ret; } -static void arm_smmu_remove_dev_pasid(struct device *dev, ioasid_t pasid, - struct iommu_domain *domain) +static int arm_smmu_blocking_set_dev_pasid(struct iommu_domain *new_domain, + struct device *dev, ioasid_t pasid, + struct iommu_domain *old_domain) { + struct arm_smmu_domain *smmu_domain = to_smmu_domain(old_domain); struct arm_smmu_master *master = dev_iommu_priv_get(dev); - struct arm_smmu_domain *smmu_domain; - - smmu_domain = to_smmu_domain(domain); mutex_lock(&arm_smmu_asid_lock); arm_smmu_clear_cd(master, pasid); @@ -2988,6 +2987,7 @@ static void arm_smmu_remove_dev_pasid(struct device *dev, ioasid_t pasid, sid_domain->type == IOMMU_DOMAIN_BLOCKED) sid_domain->ops->attach_dev(sid_domain, dev); } + return 0; } static void arm_smmu_attach_dev_ste(struct iommu_domain *domain, @@ -3069,6 +3069,7 @@ static int arm_smmu_attach_dev_blocked(struct iommu_domain *domain, static const struct iommu_domain_ops arm_smmu_blocked_ops = { .attach_dev = arm_smmu_attach_dev_blocked, + .set_dev_pasid = arm_smmu_blocking_set_dev_pasid, }; static struct iommu_domain arm_smmu_blocked_domain = { @@ -3497,7 +3498,6 @@ static struct iommu_ops arm_smmu_ops = { .device_group = arm_smmu_device_group, .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, - .remove_dev_pasid = arm_smmu_remove_dev_pasid, .dev_enable_feat = arm_smmu_dev_enable_feature, .dev_disable_feat = arm_smmu_dev_disable_feature, .page_response = arm_smmu_page_response, From patchwork Fri Oct 18 05:58:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 13841175 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 4F439188A06 for ; Fri, 18 Oct 2024 05:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729231110; cv=none; b=EiMmTqn7AZEHEmoiKs2zTSPGXAPFI0qw0PRiVERaDCcKVIgHXrxR/6rOqhL6sWGzcjqzHfR1sIOV5tAxGbR1UfT0zf//O43zF6kEWdhmVsV+gmqEBhqwPSBtTGfBYlg0mgvp7KrWW4G0g4e3tnet75iqnTbSHfiati2SiULXVVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729231110; c=relaxed/simple; bh=1d3TsI4vymaiOMQGByLF7JVCA3jll3YyxdnZnCcwgPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gn4G6miq3m19mLGqi8i5zPoqaH7bVIH/cq4DNi/MnZwrEV5eXrbZTuHAYvMoRlAKZpSJhinwIC//fhYLg+pFJqHF+PHwh3cDouLsHmlnXtANUWoF+twL/9XtyCfRQi2NOCgIdd8VIiFBmOqzNS0n3DLpBijfs3j5jb8kDAOmU+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fgNUZdyZ; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fgNUZdyZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729231109; x=1760767109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1d3TsI4vymaiOMQGByLF7JVCA3jll3YyxdnZnCcwgPU=; b=fgNUZdyZSex3KdP4Yy/yJZiXHhdGAEZuiggNlDv5ebhHuutsDhkxk93f u+7+Hw0HAMkM3ObeZHOqTTLjrfUV6wO4KyQZZfjprbeCZ5ttTC1NIoEap 58Cp+1YlMTEKciQgHoh0C2NN9AwLVYba4zMBPbMMmM5qnFIHnVDc0Io+Z 4Osk266d1Bf6NoM+lFW3fxzt2yVQ0eWvcpKyv7QdTXl4QfIneLzSO5EiL wzkTsHRBsnPEOVoTkbU6Ea/i9aS62FAd2bRXY2P4n+XHTmxQitYr37qAo /dsxr2JIQXsBH8sqqx76AMkOflcm3xMGY3+n0sk0GblKzZgAjblBHzkSs g==; X-CSE-ConnectionGUID: 8aWba9LKRtOGBrnn2GIMLQ== X-CSE-MsgGUID: 60K4DaH/RtOFJ0Tqylataw== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="39879138" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="39879138" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 22:58:28 -0700 X-CSE-ConnectionGUID: QNvYhXqTScaYVOYvaAkHWw== X-CSE-MsgGUID: uoNzn0OOTFWZITBkAYCikg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="78675735" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orviesa009.jf.intel.com with ESMTP; 17 Oct 2024 22:58:28 -0700 From: Yi Liu To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com, baolu.lu@linux.intel.com, will@kernel.org Cc: alex.williamson@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, iommu@lists.linux.dev, zhenzhong.duan@intel.com, vasant.hegde@amd.com Subject: [PATCH v2 3/3] iommu/vt-d: Make the blocked domain support PASID Date: Thu, 17 Oct 2024 22:58:24 -0700 Message-Id: <20241018055824.24880-4-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018055824.24880-1-yi.l.liu@intel.com> References: <20241018055824.24880-1-yi.l.liu@intel.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The blocked domain can be extended to park PASID of a device to be the DMA blocking state. By this the remove_dev_pasid() op is dropped. Reviewed-by: Kevin Tian Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 19 +++++++++++++------ drivers/iommu/intel/pasid.c | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index d089ac148a7e..f814fadcf34e 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3412,10 +3412,15 @@ static int blocking_domain_attach_dev(struct iommu_domain *domain, return 0; } +static int blocking_domain_set_dev_pasid(struct iommu_domain *domain, + struct device *dev, ioasid_t pasid, + struct iommu_domain *old); + static struct iommu_domain blocking_domain = { .type = IOMMU_DOMAIN_BLOCKED, .ops = &(const struct iommu_domain_ops) { .attach_dev = blocking_domain_attach_dev, + .set_dev_pasid = blocking_domain_set_dev_pasid, } }; @@ -4282,8 +4287,9 @@ static void domain_remove_dev_pasid(struct iommu_domain *domain, kfree(dev_pasid); } -static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid, - struct iommu_domain *domain) +static int blocking_domain_set_dev_pasid(struct iommu_domain *domain, + struct device *dev, ioasid_t pasid, + struct iommu_domain *old) { struct device_domain_info *info = dev_iommu_priv_get(dev); struct intel_iommu *iommu = info->iommu; @@ -4292,10 +4298,12 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid, INTEL_PASID_TEARDOWN_DRAIN_PRQ); /* Identity domain has no meta data for pasid. */ - if (domain->type == IOMMU_DOMAIN_IDENTITY) - return; + if (old->type == IOMMU_DOMAIN_IDENTITY) + goto out; - domain_remove_dev_pasid(domain, dev, pasid); + domain_remove_dev_pasid(old, dev, pasid); +out: + return 0; } static struct dev_pasid_info * @@ -4653,7 +4661,6 @@ const struct iommu_ops intel_iommu_ops = { .dev_disable_feat = intel_iommu_dev_disable_feat, .is_attach_deferred = intel_iommu_is_attach_deferred, .def_domain_type = device_def_domain_type, - .remove_dev_pasid = intel_iommu_remove_dev_pasid, .pgsize_bitmap = SZ_4K, #ifdef CONFIG_INTEL_IOMMU_SVM .page_response = intel_svm_page_response, diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index ce0a3bf701df..abf2f54e847e 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -238,7 +238,8 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu, /* * Caller can request to drain PRQ in this helper if it hasn't done so, - * e.g. in a path which doesn't follow remove_dev_pasid(). + * e.g. in a path which doesn't follow the set_dev_pasid() op of the + * blocked domain. * Return the pasid entry pointer if the entry is found or NULL if no * entry found. */