From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
Joerg Roedel <joro@8bytes.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
Robin Murphy <robin.murphy@arm.com>
Cc: baolu.lu@linux.intel.com, Jason Gunthorpe <jgg@nvidia.com>,
Will Deacon <will@kernel.org>, "Liu, Yi L" <yi.l.liu@intel.com>,
"Yu, Fenghua" <fenghua.yu@intel.com>,
"Luck, Tony" <tony.luck@intel.com>
Subject: Re: [PATCH v10 5/7] iommu/vt-d: Make prq draining code generic
Date: Wed, 19 Jul 2023 15:40:52 +0800 [thread overview]
Message-ID: <de4d5fcc-d402-68db-d712-8561ec6e745f@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB5276CE65DBB24EF838825B628C39A@BN9PR11MB5276.namprd11.prod.outlook.com>
On 2023/7/19 13:39, Tian, Kevin wrote:
>> From: Baolu Lu <baolu.lu@linux.intel.com>
>> Sent: Friday, July 14, 2023 1:47 PM
>>
>> On 2023/7/14 11:49, Tian, Kevin wrote:
>>>> From: Baolu Lu <baolu.lu@linux.intel.com>
>>>> Sent: Friday, July 14, 2023 11:28 AM
>>>>
>>>> On 2023/7/13 15:49, Tian, Kevin wrote:
>>>>>> From: Jacob Pan <jacob.jun.pan@linux.intel.com>
>>>>>> Sent: Thursday, July 13, 2023 12:34 AM
>>>>>>
>>>>>> - /* Domain type specific cleanup: */
>>>>>> domain = iommu_get_domain_for_dev_pasid(dev, pasid, 0);
>>>>>> - if (domain) {
>>>>>> - switch (domain->type) {
>>>>>> - case IOMMU_DOMAIN_SVA:
>>>>>> - intel_svm_remove_dev_pasid(dev, pasid);
>>>>>> - break;
>>>>>> - default:
>>>>>> - /* should never reach here */
>>>>>> - WARN_ON(1);
>>>>>> - break;
>>>>>> - }
>>>>>> + if (!domain)
>>>>>> + goto out_tear_down;
>>>>>
>>>>> WARN_ON()
>>>>
>>>> Why?
>>>>
>>>> My understanding is that remve_device_pasid could be call in any context
>>>> including no domain attached.
>>>>
>>>
>>> oh I'm not aware of that. Can you elaborate the usage which uses a pasid
>>> w/o domain? pasid needs to point to a page table. Presumably every
>>> page table should be wrapped by a iommu domain...
>>
>> A case I can think of is error rewinding. A domain is being attached to
>> multiple pasids. When one of them is failed, remove_device_pasid should
>> be called on all pasids so that they are parked at a determinant state.
>
> Can you elaborate what is the association among those pasid's so failing
> one would lead to failing all?
>
> Just like a domain can be attached to multiple devices. I don't think there
> is an unwinding policy forcing to detach all devices just because there is
> a failure attaching the domain to a new one.
It's fine to add a check here if there's no real case. I was just
thinking that remove_device_pasid could also be invoked when there's no
domain attached.
>>
>> On the other hand, I don't want the remove_device_pasid to be the
>> counterpart of attach_dev_pasid. remove_device_pasid simply denotes:
>>
>> - The pasid will be parked in blocking state;
>> - If any domain that has been attached to this pasid, stop reference to
>> it any more. Otherwise, there might be use-after-free issues.
>>
>> Hence, remove_device_pasid should never fail.
>>
>
> It should never fail. But could warn if there is a condition which shouldn't
> be hit. 😊
Okay, let's add a check here. And we can loose it later if any real use
case comes.
Best regards,
baolu
next prev parent reply other threads:[~2023-07-19 7:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 16:33 [PATCH v10 0/7] Re-enable IDXD kernel workqueue under DMA API Jacob Pan
2023-07-12 16:33 ` [PATCH v10 1/7] iommu: Generalize PASID 0 for normal DMA w/o PASID Jacob Pan
2023-07-12 16:33 ` [PATCH v10 2/7] iommu: Move global PASID allocation from SVA to core Jacob Pan
2023-07-13 7:42 ` Tian, Kevin
2023-07-13 16:00 ` Jacob Pan
2023-07-12 16:33 ` [PATCH v10 3/7] iommu/vt-d: Add domain_flush_pasid_iotlb() Jacob Pan
2023-07-13 7:45 ` Tian, Kevin
2023-07-13 7:52 ` Tian, Kevin
2023-07-14 3:36 ` Baolu Lu
2023-07-14 3:51 ` Tian, Kevin
2023-07-14 6:02 ` Baolu Lu
2023-07-12 16:33 ` [PATCH v10 4/7] iommu/vt-d: Remove pasid_mutex Jacob Pan
2023-07-13 7:46 ` Tian, Kevin
2023-07-12 16:33 ` [PATCH v10 5/7] iommu/vt-d: Make prq draining code generic Jacob Pan
2023-07-13 7:49 ` Tian, Kevin
2023-07-14 3:28 ` Baolu Lu
2023-07-14 3:49 ` Tian, Kevin
2023-07-14 5:47 ` Baolu Lu
2023-07-19 5:39 ` Tian, Kevin
2023-07-19 7:40 ` Baolu Lu [this message]
2023-07-12 16:33 ` [PATCH v10 6/7] iommu/vt-d: Add set_dev_pasid callback for dma domain Jacob Pan
2023-07-13 7:56 ` Tian, Kevin
2023-07-14 3:34 ` Baolu Lu
2023-07-14 3:50 ` Tian, Kevin
2023-07-14 6:00 ` Baolu Lu
2023-07-19 5:39 ` Tian, Kevin
2023-07-12 16:33 ` [PATCH v10 7/7] dmaengine/idxd: Re-enable kernel workqueue under DMA API Jacob Pan
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=de4d5fcc-d402-68db-d712-8561ec6e745f@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=tony.luck@intel.com \
--cc=will@kernel.org \
--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