From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935386AbdKQS6U (ORCPT ); Fri, 17 Nov 2017 13:58:20 -0500 Received: from mga03.intel.com ([134.134.136.65]:54146 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161482AbdKQSyg (ORCPT ); Fri, 17 Nov 2017 13:54:36 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,410,1505804400"; d="scan'208";a="3461206" From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , Greg Kroah-Hartman , Rafael Wysocki , Alex Williamson Cc: "Liu, Yi L" , Lan Tianyu , "Tian, Kevin" , Raj Ashok , Jean Delvare , "Christoph Hellwig" , Jacob Pan Subject: [PATCH v3 14/16] iommu/intel-svm: replace dev ops with fault report API Date: Fri, 17 Nov 2017 10:55:12 -0800 Message-Id: <1510944914-54430-15-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510944914-54430-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1510944914-54430-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the introduction of generic IOMMU device fault reporting API, we can replace the private fault callback functions with standard function and event data. Signed-off-by: Jacob Pan --- drivers/iommu/intel-svm.c | 7 +------ include/linux/intel-svm.h | 20 +++----------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 77c25d8..93b1849 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -283,7 +283,7 @@ static const struct mmu_notifier_ops intel_mmuops = { static DEFINE_MUTEX(pasid_mutex); -int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ops *ops) +int intel_svm_bind_mm(struct device *dev, int *pasid, int flags) { struct intel_iommu *iommu = intel_svm_device_to_iommu(dev); struct intel_svm_dev *sdev; @@ -329,10 +329,6 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ list_for_each_entry(sdev, &svm->devs, list) { if (dev == sdev->dev) { - if (sdev->ops != ops) { - ret = -EBUSY; - goto out; - } sdev->users++; goto success; } @@ -358,7 +354,6 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ } /* Finish the setup now we know we're keeping it */ sdev->users = 1; - sdev->ops = ops; init_rcu_head(&sdev->rcu); if (!svm) { diff --git a/include/linux/intel-svm.h b/include/linux/intel-svm.h index 99bc5b3..a39a502 100644 --- a/include/linux/intel-svm.h +++ b/include/linux/intel-svm.h @@ -18,18 +18,6 @@ struct device; -struct svm_dev_ops { - void (*fault_cb)(struct device *dev, int pasid, u64 address, - u32 private, int rwxp, int response); -}; - -/* Values for rxwp in fault_cb callback */ -#define SVM_REQ_READ (1<<3) -#define SVM_REQ_WRITE (1<<2) -#define SVM_REQ_EXEC (1<<1) -#define SVM_REQ_PRIV (1<<0) - - /* * The SVM_FLAG_PRIVATE_PASID flag requests a PASID which is *not* the "main" * PASID for the current process. Even if a PASID already exists, a new one @@ -60,7 +48,6 @@ struct svm_dev_ops { * @dev: Device to be granted acccess * @pasid: Address for allocated PASID * @flags: Flags. Later for requesting supervisor mode, etc. - * @ops: Callbacks to device driver * * This function attempts to enable PASID support for the given device. * If the @pasid argument is non-%NULL, a PASID is allocated for access @@ -82,8 +69,7 @@ struct svm_dev_ops { * Multiple calls from the same process may result in the same PASID * being re-used. A reference count is kept. */ -extern int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, - struct svm_dev_ops *ops); +extern int intel_svm_bind_mm(struct device *dev, int *pasid, int flags); /** * intel_svm_unbind_mm() - Unbind a specified PASID @@ -120,7 +106,7 @@ extern int intel_svm_is_pasid_valid(struct device *dev, int pasid); #else /* CONFIG_INTEL_IOMMU_SVM */ static inline int intel_svm_bind_mm(struct device *dev, int *pasid, - int flags, struct svm_dev_ops *ops) + int flags) { return -ENOSYS; } @@ -136,6 +122,6 @@ static int intel_svm_is_pasid_valid(struct device *dev, int pasid) } #endif /* CONFIG_INTEL_IOMMU_SVM */ -#define intel_svm_available(dev) (!intel_svm_bind_mm((dev), NULL, 0, NULL)) +#define intel_svm_available(dev) (!intel_svm_bind_mm((dev), NULL, 0)) #endif /* __INTEL_SVM_H__ */ -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacob Pan Subject: [PATCH v3 14/16] iommu/intel-svm: replace dev ops with fault report API Date: Fri, 17 Nov 2017 10:55:12 -0800 Message-ID: <1510944914-54430-15-git-send-email-jacob.jun.pan@linux.intel.com> References: <1510944914-54430-1-git-send-email-jacob.jun.pan@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1510944914-54430-1-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, LKML , Joerg Roedel , David Woodhouse , Greg Kroah-Hartman , Rafael Wysocki , Alex Williamson Cc: Lan Tianyu , Jean Delvare List-Id: iommu@lists.linux-foundation.org With the introduction of generic IOMMU device fault reporting API, we can replace the private fault callback functions with standard function and event data. Signed-off-by: Jacob Pan --- drivers/iommu/intel-svm.c | 7 +------ include/linux/intel-svm.h | 20 +++----------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 77c25d8..93b1849 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -283,7 +283,7 @@ static const struct mmu_notifier_ops intel_mmuops = { static DEFINE_MUTEX(pasid_mutex); -int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ops *ops) +int intel_svm_bind_mm(struct device *dev, int *pasid, int flags) { struct intel_iommu *iommu = intel_svm_device_to_iommu(dev); struct intel_svm_dev *sdev; @@ -329,10 +329,6 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ list_for_each_entry(sdev, &svm->devs, list) { if (dev == sdev->dev) { - if (sdev->ops != ops) { - ret = -EBUSY; - goto out; - } sdev->users++; goto success; } @@ -358,7 +354,6 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ } /* Finish the setup now we know we're keeping it */ sdev->users = 1; - sdev->ops = ops; init_rcu_head(&sdev->rcu); if (!svm) { diff --git a/include/linux/intel-svm.h b/include/linux/intel-svm.h index 99bc5b3..a39a502 100644 --- a/include/linux/intel-svm.h +++ b/include/linux/intel-svm.h @@ -18,18 +18,6 @@ struct device; -struct svm_dev_ops { - void (*fault_cb)(struct device *dev, int pasid, u64 address, - u32 private, int rwxp, int response); -}; - -/* Values for rxwp in fault_cb callback */ -#define SVM_REQ_READ (1<<3) -#define SVM_REQ_WRITE (1<<2) -#define SVM_REQ_EXEC (1<<1) -#define SVM_REQ_PRIV (1<<0) - - /* * The SVM_FLAG_PRIVATE_PASID flag requests a PASID which is *not* the "main" * PASID for the current process. Even if a PASID already exists, a new one @@ -60,7 +48,6 @@ struct svm_dev_ops { * @dev: Device to be granted acccess * @pasid: Address for allocated PASID * @flags: Flags. Later for requesting supervisor mode, etc. - * @ops: Callbacks to device driver * * This function attempts to enable PASID support for the given device. * If the @pasid argument is non-%NULL, a PASID is allocated for access @@ -82,8 +69,7 @@ struct svm_dev_ops { * Multiple calls from the same process may result in the same PASID * being re-used. A reference count is kept. */ -extern int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, - struct svm_dev_ops *ops); +extern int intel_svm_bind_mm(struct device *dev, int *pasid, int flags); /** * intel_svm_unbind_mm() - Unbind a specified PASID @@ -120,7 +106,7 @@ extern int intel_svm_is_pasid_valid(struct device *dev, int pasid); #else /* CONFIG_INTEL_IOMMU_SVM */ static inline int intel_svm_bind_mm(struct device *dev, int *pasid, - int flags, struct svm_dev_ops *ops) + int flags) { return -ENOSYS; } @@ -136,6 +122,6 @@ static int intel_svm_is_pasid_valid(struct device *dev, int pasid) } #endif /* CONFIG_INTEL_IOMMU_SVM */ -#define intel_svm_available(dev) (!intel_svm_bind_mm((dev), NULL, 0, NULL)) +#define intel_svm_available(dev) (!intel_svm_bind_mm((dev), NULL, 0)) #endif /* __INTEL_SVM_H__ */ -- 2.7.4