mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Granados <j.granados@samsung.com>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Nicolin Chen <nicolinc@nvidia.com>, Yi Liu <yi.l.liu@intel.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	Longfang Liu <liulongfang@huawei.com>,
	Yan Zhao <yan.y.zhao@intel.com>, <iommu@lists.linux.dev>,
	<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH v10 16/16] iommu: Make iommu_report_device_fault() reutrn void
Date: Thu, 25 Jan 2024 17:26:23 +0100	[thread overview]
Message-ID: <20240125162623.l3hg2i5k5kyh57cc@localhost> (raw)
In-Reply-To: <20240122054308.23901-17-baolu.lu@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 6815 bytes --]

On Mon, Jan 22, 2024 at 01:43:08PM +0800, Lu Baolu wrote:
> As the iommu_report_device_fault() has been converted to auto-respond a
> page fault if it fails to enqueue it, there's no need to return a code
> in any case. Make it return void.
> 
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>  include/linux/iommu.h                       |  5 ++---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c |  4 ++--
>  drivers/iommu/intel/svm.c                   | 19 +++++++----------
>  drivers/iommu/io-pgfault.c                  | 23 +++++++--------------
>  4 files changed, 19 insertions(+), 32 deletions(-)
> 
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index d7b6f4017254..1ccad10e8164 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -1549,7 +1549,7 @@ struct iopf_queue *iopf_queue_alloc(const char *name);
>  void iopf_queue_free(struct iopf_queue *queue);
>  int iopf_queue_discard_partial(struct iopf_queue *queue);
>  void iopf_free_group(struct iopf_group *group);
> -int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt);
> +void iommu_report_device_fault(struct device *dev, struct iopf_fault *evt);
>  void iopf_group_response(struct iopf_group *group,
>  			 enum iommu_page_response_code status);
>  #else
> @@ -1587,10 +1587,9 @@ static inline void iopf_free_group(struct iopf_group *group)
>  {
>  }
>  
> -static inline int
> +static inline void
>  iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
>  {
> -	return -ENODEV;
>  }
>  
>  static inline void iopf_group_response(struct iopf_group *group,
> 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 42eb59cb99f4..02580364acda 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -1455,7 +1455,7 @@ arm_smmu_find_master(struct arm_smmu_device *smmu, u32 sid)
>  /* IRQ and event handlers */
>  static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
>  {
> -	int ret;
> +	int ret = 0;
>  	u32 perm = 0;
>  	struct arm_smmu_master *master;
>  	bool ssid_valid = evt[0] & EVTQ_0_SSV;
> @@ -1511,7 +1511,7 @@ static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
>  		goto out_unlock;
>  	}
>  
> -	ret = iommu_report_device_fault(master->dev, &fault_evt);
> +	iommu_report_device_fault(master->dev, &fault_evt);
>  out_unlock:
>  	mutex_unlock(&smmu->streams_mutex);
>  	return ret;
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index 2f8716636dbb..b644d57da841 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -561,14 +561,11 @@ static int prq_to_iommu_prot(struct page_req_dsc *req)
>  	return prot;
>  }
>  
> -static int intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
> -				struct page_req_dsc *desc)
> +static void intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
> +				 struct page_req_dsc *desc)
>  {
>  	struct iopf_fault event = { };
>  
> -	if (!dev || !dev_is_pci(dev))
> -		return -ENODEV;
> -
>  	/* Fill in event data for device specific processing */
>  	event.fault.type = IOMMU_FAULT_PAGE_REQ;
>  	event.fault.prm.addr = (u64)desc->addr << VTD_PAGE_SHIFT;
> @@ -601,7 +598,7 @@ static int intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
>  		event.fault.prm.private_data[0] = ktime_to_ns(ktime_get());
>  	}
>  
> -	return iommu_report_device_fault(dev, &event);
> +	iommu_report_device_fault(dev, &event);
>  }
>  
>  static void handle_bad_prq_event(struct intel_iommu *iommu,
> @@ -704,12 +701,10 @@ static irqreturn_t prq_event_thread(int irq, void *d)
>  		if (!pdev)
>  			goto bad_req;
>  
> -		if (intel_svm_prq_report(iommu, &pdev->dev, req))
> -			handle_bad_prq_event(iommu, req, QI_RESP_INVALID);
> -		else
> -			trace_prq_report(iommu, &pdev->dev, req->qw_0, req->qw_1,
> -					 req->priv_data[0], req->priv_data[1],
> -					 iommu->prq_seq_number++);
> +		intel_svm_prq_report(iommu, &pdev->dev, req);
> +		trace_prq_report(iommu, &pdev->dev, req->qw_0, req->qw_1,
> +				 req->priv_data[0], req->priv_data[1],
> +				 iommu->prq_seq_number++);
>  		pci_dev_put(pdev);
>  prq_advance:
>  		head = (head + sizeof(*req)) & PRQ_RING_MASK;
> diff --git a/drivers/iommu/io-pgfault.c b/drivers/iommu/io-pgfault.c
> index 6e63e5a02884..b64229dab976 100644
> --- a/drivers/iommu/io-pgfault.c
> +++ b/drivers/iommu/io-pgfault.c
> @@ -179,23 +179,21 @@ static struct iopf_group *iopf_group_alloc(struct iommu_fault_param *iopf_param,
>   *
>   * Return: 0 on success and <0 on error.
>   */
Should you remove the documentation that describes the return also?

> -int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
> +void iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
>  {
>  	struct iommu_fault *fault = &evt->fault;
>  	struct iommu_fault_param *iopf_param;
>  	struct iopf_group abort_group = {};
>  	struct iopf_group *group;
> -	int ret;
>  
>  	iopf_param = iopf_get_dev_fault_param(dev);
>  	if (WARN_ON(!iopf_param))
> -		return -ENODEV;
> +		return;
>  
>  	if (!(fault->prm.flags & IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE)) {
> -		ret = report_partial_fault(iopf_param, fault);
> +		report_partial_fault(iopf_param, fault);
>  		iopf_put_dev_fault_param(iopf_param);
>  		/* A request that is not the last does not need to be ack'd */
> -		return ret;
>  	}
>  
>  	/*
> @@ -207,25 +205,21 @@ int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
>  	 * leaving, otherwise partial faults will be stuck.
>  	 */
>  	group = iopf_group_alloc(iopf_param, evt, &abort_group);
> -	if (group == &abort_group) {
> -		ret = -ENOMEM;
> +	if (group == &abort_group)
>  		goto err_abort;
> -	}
>  
>  	group->domain = get_domain_for_iopf(dev, fault);
> -	if (!group->domain) {
> -		ret = -EINVAL;
> +	if (!group->domain)
>  		goto err_abort;
> -	}
>  
>  	/*
>  	 * On success iopf_handler must call iopf_group_response() and
>  	 * iopf_free_group()
>  	 */
> -	ret = group->domain->iopf_handler(group);
> -	if (ret)
> +	if (group->domain->iopf_handler(group))
>  		goto err_abort;
> -	return 0;
> +
> +	return;
>  
>  err_abort:
>  	iopf_group_response(group, IOMMU_PAGE_RESP_FAILURE);
> @@ -233,7 +227,6 @@ int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
>  		__iopf_free_group(group);
>  	else
>  		iopf_free_group(group);
> -	return ret;
>  }
>  EXPORT_SYMBOL_GPL(iommu_report_device_fault);
>  
> -- 
> 2.34.1
> 

-- 

Joel Granados

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  parent reply	other threads:[~2024-01-25 16:26 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22  5:42 [PATCH v10 00/16] iommu: Prepare to deliver page faults to user space Lu Baolu
2024-01-22  5:42 ` [PATCH v10 01/16] iommu: Move iommu fault data to linux/iommu.h Lu Baolu
     [not found]   ` <CGME20240125091737eucas1p2091d853e27e669b3b12cea8ee3bbe34e@eucas1p2.samsung.com>
2024-01-25  9:17     ` Joel Granados
2024-01-25 11:21       ` Baolu Lu
2024-01-26 14:26         ` Joel Granados
2024-01-25 13:43       ` Jason Gunthorpe
2024-01-26 14:25         ` Joel Granados
2024-01-22  5:42 ` [PATCH v10 02/16] iommu/arm-smmu-v3: Remove unrecoverable faults reporting Lu Baolu
2024-01-22  5:42 ` [PATCH v10 03/16] iommu: Remove unrecoverable fault data Lu Baolu
2024-01-22  5:42 ` [PATCH v10 04/16] iommu: Cleanup iopf data structure definitions Lu Baolu
     [not found]   ` <CGME20240125102328eucas1p288a2c65df13b1f60d60f363447bb8e5c@eucas1p2.samsung.com>
2024-01-25 10:23     ` Joel Granados
2024-01-25 11:33       ` Baolu Lu
2024-01-25 13:44         ` Jason Gunthorpe
2024-01-22  5:42 ` [PATCH v10 05/16] iommu: Merge iopf_device_param into iommu_fault_param Lu Baolu
2024-01-22  5:42 ` [PATCH v10 06/16] iommu: Remove iommu_[un]register_device_fault_handler() Lu Baolu
2024-01-22  5:42 ` [PATCH v10 07/16] iommu: Merge iommu_fault_event and iopf_fault Lu Baolu
2024-01-22  5:43 ` [PATCH v10 08/16] iommu: Prepare for separating SVA and IOPF Lu Baolu
2024-01-22  5:43 ` [PATCH v10 09/16] iommu: Make iommu_queue_iopf() more generic Lu Baolu
2024-01-22  5:43 ` [PATCH v10 10/16] iommu: Separate SVA and IOPF Lu Baolu
2024-01-22  5:43 ` [PATCH v10 11/16] iommu: Refine locking for per-device fault data management Lu Baolu
2024-01-22  5:43 ` [PATCH v10 12/16] iommu: Use refcount for fault data access Lu Baolu
2024-01-22  5:43 ` [PATCH v10 13/16] iommu: Improve iopf_queue_remove_device() Lu Baolu
2024-01-22  5:43 ` [PATCH v10 14/16] iommu: Track iopf group instead of last fault Lu Baolu
2024-01-22  5:43 ` [PATCH v10 15/16] iommu: Make iopf_group_response() return void Lu Baolu
     [not found]   ` <CGME20240125162723eucas1p2cc7562a22b8af9b46076e1c7b616531b@eucas1p2.samsung.com>
2024-01-25 16:27     ` Joel Granados
2024-01-26  6:43       ` Baolu Lu
2024-02-02 15:36   ` Jason Gunthorpe
2024-01-22  5:43 ` [PATCH v10 16/16] iommu: Make iommu_report_device_fault() reutrn void Lu Baolu
     [not found]   ` <CGME20240125162625eucas1p1e9ae0f7cc7ba63f88316552048e77401@eucas1p1.samsung.com>
2024-01-25 16:26     ` Joel Granados [this message]
2024-01-26  6:42       ` Baolu Lu
2024-02-02 15:39   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240125162623.l3hg2i5k5kyh57cc@localhost \
    --to=j.granados@samsung.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jean-philippe@linaro.org \
    --cc=jgg@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liulongfang@huawei.com \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    --cc=yan.y.zhao@intel.com \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®