From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: Kevin Tian <kevin.tian@intel.com>,
Ashok Raj <ashok.raj@intel.com>,
Robin Murphy <robin.murphy@arm.com>,
linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
iommu@lists.linux-foundation.org,
Jacob jun Pan <jacob.jun.pan@intel.com>,
Jason Gunthorpe <jgg@nvidia.com>, Will Deacon <will@kernel.org>
Subject: Re: [PATCH v4 10/12] iommu: Prepare IOMMU domain for IOPF
Date: Fri, 29 Apr 2022 14:17:23 +0800 [thread overview]
Message-ID: <dfe247b5-10d9-75d7-b742-28be910b5fb2@linux.intel.com> (raw)
In-Reply-To: <YmqpGFzMZn7ZMzsQ@myrica>
Hi Jean,
On 2022/4/28 22:47, Jean-Philippe Brucker wrote:
> Hi Baolu,
>
> On Thu, Apr 21, 2022 at 01:21:19PM +0800, Lu Baolu wrote:
>> +/*
>> + * Get the attached domain for asynchronous usage, for example the I/O
>> + * page fault handling framework. The caller get a reference counter
>> + * of the domain automatically on a successful return and should put
>> + * it with iommu_domain_put() after usage.
>> + */
>> +struct iommu_domain *
>> +iommu_get_domain_for_dev_pasid_async(struct device *dev, ioasid_t pasid)
>> +{
>> + struct iommu_domain *domain;
>> + struct iommu_group *group;
>> +
>> + if (!pasid_valid(pasid))
>> + return NULL;
>> +
>> + group = iommu_group_get(dev);
>> + if (!group)
>> + return NULL;
>> +
>> + mutex_lock(&group->mutex);
>
> There is a possible deadlock between unbind() and the fault handler:
>
> unbind() iopf_handle_group()
> mutex_lock(&group->mutex)
> iommu_detach_device_pasid()
> iopf_queue_flush_dev() iommu_get_domain_for_dev_pasid_async()
> ... waits for IOPF work mutex_lock(&group->mutex)
>
Yes, really.
> I was wrong in my previous review: we do have a guarantee that the SVA
> domain does not go away during IOPF handling, because unbind() waits for
> pending faults with iopf_queue_flush_dev() before freeing the domain (or
> for Arm stall, knows that there are no pending faults). So we can just get
> rid of domain->async_users and the group->mutex in IOPF, I think?
Agreed with you. The Intel code does the same thing in its unbind().
Thus, the sva domain's life cycle has already synchronized with IOPF
handling, there's no need for domain->async.
I will drop it in the next version. Thanks you!
Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-04-29 6:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-21 5:21 [PATCH v4 00/12] iommu: SVA and IOPF refactoring Lu Baolu
2022-04-21 5:21 ` [PATCH v4 01/12] dmaengine: idxd: Separate user and kernel pasid enabling Lu Baolu
2022-04-21 5:21 ` [PATCH v4 02/12] iommu: Add pasid_bits field in struct dev_iommu Lu Baolu
2022-04-21 5:21 ` [PATCH v4 03/12] iommu: Add attach/detach_dev_pasid domain ops Lu Baolu
2022-04-28 14:53 ` Jean-Philippe Brucker
2022-04-29 6:27 ` Baolu Lu
2022-04-21 5:21 ` [PATCH v4 04/12] iommu/sva: Basic data structures for SVA Lu Baolu
2022-04-21 5:21 ` [PATCH v4 05/12] iommu/vt-d: Remove SVM_FLAG_SUPERVISOR_MODE support Lu Baolu
2022-04-21 5:21 ` [PATCH v4 06/12] iommu/vt-d: Add SVA domain support Lu Baolu
2022-04-21 5:21 ` [PATCH v4 07/12] arm-smmu-v3/sva: " Lu Baolu
2022-04-21 5:21 ` [PATCH v4 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces Lu Baolu
2022-04-21 5:21 ` [PATCH v4 09/12] iommu: Remove SVA related callbacks from iommu ops Lu Baolu
2022-04-21 5:21 ` [PATCH v4 10/12] iommu: Prepare IOMMU domain for IOPF Lu Baolu
2022-04-28 14:47 ` Jean-Philippe Brucker
2022-04-29 6:17 ` Baolu Lu [this message]
2022-04-21 5:21 ` [PATCH v4 11/12] iommu: Per-domain I/O page fault handling Lu Baolu
2022-04-28 14:57 ` Jean-Philippe Brucker
2022-04-29 6:35 ` Baolu Lu
2022-04-21 5:21 ` [PATCH v4 12/12] iommu: Rename iommu-sva-lib.{c,h} Lu Baolu
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=dfe247b5-10d9-75d7-b742-28be910b5fb2@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jean-philippe@linaro.com \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).