From patchwork Wed Nov 13 13:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 13873769 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 5EBF8201036 for ; Wed, 13 Nov 2024 13:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731505582; cv=none; b=bLkZtVpVsFKgPNL8m0CBYdgWyZJOxo1z4qFRKbXsXf/Y1NCHod9tQIy95uUVwYOOT87tzGtMDasg2vMa45ZUC+APAw0CBp8InsQdMVq0V4Sh3m6savxDjo4IqjSkDDJRtb/yL7w7BpzNr7hnffqIkmaKx1baNvMSys1IAUwL1DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731505582; c=relaxed/simple; bh=RSZiUmG12bOfUY9cuPpOaVCOvpSre8G8I7IPBw8s4VA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L6VnEpS0T6F7b6RjZfNaLHu4p+OOBIFgbmWvak6IP63N94IYbrW0dajYEWzzTwmEXXYNsgkYr/9enLWeE5FhkRfbmPQzQQ1DaeuTcrPVKub9iXcJmVRz9F5SXZvfE2l7TzPsvaTK9RPD+PeHdvqJzJYx5LytBmY+7LMju4Qb4nw= 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=ghORtReT; arc=none smtp.client-ip=192.198.163.11 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="ghORtReT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731505580; x=1763041580; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RSZiUmG12bOfUY9cuPpOaVCOvpSre8G8I7IPBw8s4VA=; b=ghORtReTxQatqDu+oDukVvagfyOthqa2QSdvuD4WZ4Pfe3+V+xiapiRT /c7bLx7JUlxKQ/y9peyUscXXPley5ZojkF0OfCI+0tOxnL4mnZZNFjR/W yn+Ug+npQWWs88Uei/G0RPcQYv20DFrTZqJ6n44J71EQm/aH/B9yHZnav hWAs9gA1mDJNS1+uG1eqgmHDariKIEyxKZpc5kKucWNBPKm289r9Cz82P nYywP3igWdCb8hqJcAYsBC2S5A7IMSp44bIgB9Fxj8b0wl4LDRy6A4d6i Y6Uu2UjLO11zxTJ5bE7rfJh/cDnrAW5u3ynwRVaBqlpL4so00oaTTP53w Q==; X-CSE-ConnectionGUID: bO+lq2YbSxa2U6LKJKDqjw== X-CSE-MsgGUID: RajcmH0hRl+lh6P1i0GWHw== X-IronPort-AV: E=McAfee;i="6700,10204,11254"; a="42025735" X-IronPort-AV: E=Sophos;i="6.12,151,1728975600"; d="scan'208";a="42025735" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 05:46:18 -0800 X-CSE-ConnectionGUID: sZTYEZIRQ4GTyTm6J0Hwcg== X-CSE-MsgGUID: QhaMjDBbSoGjOBH292t0cA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,151,1728975600"; d="scan'208";a="87445611" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by fmviesa006.fm.intel.com with ESMTP; 13 Nov 2024 05:46:17 -0800 From: Yi Liu To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com, baolu.lu@linux.intel.com Cc: 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, will@kernel.org Subject: [PATCH v5 7/7] iommu: Remove the remove_dev_pasid op Date: Wed, 13 Nov 2024 05:46:13 -0800 Message-Id: <20241113134613.7173-8-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241113134613.7173-1-yi.l.liu@intel.com> References: <20241113134613.7173-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 that supports PASID have supported attaching pasid to the blocked_domain, hence remove the remove_dev_pasid op from the iommu_ops. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Vasant Hegde Reviewed-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/iommu.c | 17 ++++------------- include/linux/iommu.h | 5 ----- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 25d170de76fe..8a3e3a753fd5 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3303,17 +3303,9 @@ static void iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid, { const struct iommu_ops *ops = dev_iommu_ops(dev); struct iommu_domain *blocked_domain = ops->blocked_domain; - int ret = 1; - if (blocked_domain && blocked_domain->ops->set_dev_pasid) { - ret = blocked_domain->ops->set_dev_pasid(blocked_domain, - dev, pasid, domain); - } else { - ops->remove_dev_pasid(dev, pasid, domain); - ret = 0; - } - - WARN_ON(ret); + WARN_ON(blocked_domain->ops->set_dev_pasid(blocked_domain, + dev, pasid, domain)); } static int __iommu_set_group_pasid(struct iommu_domain *domain, @@ -3376,9 +3368,8 @@ int iommu_attach_device_pasid(struct iommu_domain *domain, ops = dev_iommu_ops(dev); if (!domain->ops->set_dev_pasid || - (!ops->remove_dev_pasid && - (!ops->blocked_domain || - !ops->blocked_domain->ops->set_dev_pasid))) + !ops->blocked_domain || + !ops->blocked_domain->ops->set_dev_pasid) return -EOPNOTSUPP; if (ops != domain->owner || pasid == IOMMU_NO_PASID) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 0c3bfb66dc7c..1d033121bf00 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -537,9 +537,6 @@ static inline int __iommu_copy_struct_from_user_array( * - IOMMU_DOMAIN_DMA: must use a dma domain * - 0: use the default setting * @default_domain_ops: the default ops for domains - * @remove_dev_pasid: Remove any translation configurations of a specific - * pasid, so that any DMA transactions with this pasid - * will be blocked by the hardware. * @pgsize_bitmap: bitmap of all possible supported page sizes * @owner: Driver module providing these ops * @identity_domain: An always available, always attachable identity @@ -586,8 +583,6 @@ struct iommu_ops { struct iommu_page_response *msg); int (*def_domain_type)(struct device *dev); - void (*remove_dev_pasid)(struct device *dev, ioasid_t pasid, - struct iommu_domain *domain); const struct iommu_domain_ops *default_domain_ops; unsigned long pgsize_bitmap;