From: Jason Gunthorpe <jgg@ziepe.ca>
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>,
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
Subject: Re: [PATCH v9 13/14] iommu: Improve iopf_queue_remove_device()
Date: Fri, 5 Jan 2024 12:25:40 -0400 [thread overview]
Message-ID: <20240105162540.GH50608@ziepe.ca> (raw)
In-Reply-To: <20231220012332.168188-14-baolu.lu@linux.intel.com>
On Wed, Dec 20, 2023 at 09:23:31AM +0800, Lu Baolu wrote:
> -int iopf_queue_remove_device(struct iopf_queue *queue, struct device *dev)
> +void iopf_queue_remove_device(struct iopf_queue *queue, struct device *dev)
> {
> - int ret = 0;
> struct iopf_fault *iopf, *next;
> + struct iommu_page_response resp;
> struct dev_iommu *param = dev->iommu;
> struct iommu_fault_param *fault_param;
> + const struct iommu_ops *ops = dev_iommu_ops(dev);
>
> mutex_lock(&queue->lock);
> mutex_lock(¶m->lock);
> fault_param = rcu_dereference_check(param->fault_param,
> lockdep_is_held(¶m->lock));
> - if (!fault_param) {
> - ret = -ENODEV;
> - goto unlock;
> - }
> -
> - if (fault_param->queue != queue) {
> - ret = -EINVAL;
> - goto unlock;
> - }
>
> - if (!list_empty(&fault_param->faults)) {
> - ret = -EBUSY;
> + if (WARN_ON(!fault_param || fault_param->queue != queue))
> goto unlock;
> - }
> -
> - list_del(&fault_param->queue_list);
>
> - /* Just in case some faults are still stuck */
> + mutex_lock(&fault_param->lock);
> list_for_each_entry_safe(iopf, next, &fault_param->partial, list)
> kfree(iopf);
>
> + list_for_each_entry_safe(iopf, next, &fault_param->faults, list) {
> + memset(&resp, 0, sizeof(struct iommu_page_response));
> + resp.pasid = iopf->fault.prm.pasid;
> + resp.grpid = iopf->fault.prm.grpid;
> + resp.code = IOMMU_PAGE_RESP_INVALID;
I would probably move the resp and iopf variables into here:
struct iopf_fault *iopf = &group->last_fault;
struct iommu_page_response resp = {
.pasid = iopf->fault.prm.pasid,
.grpid = iopf->fault.prm.grpid,
.code = IOMMU_PAGE_RESP_INVALID
};
(and call the other one partial_iopf)
But this looks fine either way
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Jason
next prev parent reply other threads:[~2024-01-05 16:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 1:23 [PATCH v9 00/14] iommu: Prepare to deliver page faults to user space Lu Baolu
2023-12-20 1:23 ` [PATCH v9 01/14] iommu: Move iommu fault data to linux/iommu.h Lu Baolu
2023-12-20 1:23 ` [PATCH v9 02/14] iommu/arm-smmu-v3: Remove unrecoverable faults reporting Lu Baolu
2023-12-20 1:23 ` [PATCH v9 03/14] iommu: Remove unrecoverable fault data Lu Baolu
2023-12-20 1:23 ` [PATCH v9 04/14] iommu: Cleanup iopf data structure definitions Lu Baolu
2023-12-20 1:23 ` [PATCH v9 05/14] iommu: Merge iopf_device_param into iommu_fault_param Lu Baolu
2023-12-20 1:23 ` [PATCH v9 06/14] iommu: Remove iommu_[un]register_device_fault_handler() Lu Baolu
2023-12-20 1:23 ` [PATCH v9 07/14] iommu: Merge iommu_fault_event and iopf_fault Lu Baolu
2023-12-20 1:23 ` [PATCH v9 08/14] iommu: Prepare for separating SVA and IOPF Lu Baolu
2023-12-20 1:23 ` [PATCH v9 09/14] iommu: Make iommu_queue_iopf() more generic Lu Baolu
2023-12-20 1:23 ` [PATCH v9 10/14] iommu: Separate SVA and IOPF Lu Baolu
2023-12-20 1:23 ` [PATCH v9 11/14] iommu: Refine locking for per-device fault data management Lu Baolu
2023-12-20 1:23 ` [PATCH v9 12/14] iommu: Use refcount for fault data access Lu Baolu
2024-01-05 16:09 ` Jason Gunthorpe
2024-01-09 2:47 ` Baolu Lu
2023-12-20 1:23 ` [PATCH v9 13/14] iommu: Improve iopf_queue_remove_device() Lu Baolu
2024-01-05 16:25 ` Jason Gunthorpe [this message]
2024-01-09 3:36 ` Baolu Lu
2023-12-20 1:23 ` [PATCH v9 14/14] iommu: Track iopf group instead of last fault Lu Baolu
2024-01-05 17:53 ` Jason Gunthorpe
2024-01-09 5:55 ` Baolu Lu
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=20240105162540.GH50608@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.org \
--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