[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <077966f0-d2fe-d85e-268a-a4f14c1870f1@linux.intel.com>
Date: Wed, 2 Aug 2023 11:20:06 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: "Tian, Kevin" <kevin.tian@...el.com>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Jason Gunthorpe <jgg@...pe.ca>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Nicolin Chen <nicolinc@...dia.com>
Cc: baolu.lu@...ux.intel.com, "Liu, Yi L" <yi.l.liu@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] iommu: Consolidate pasid dma ownership check
On 2023/8/2 9:39, Tian, Kevin wrote:
>> From: Baolu Lu<baolu.lu@...ux.intel.com>
>> Sent: Tuesday, August 1, 2023 3:44 PM
>>
>> On 2023/8/1 15:03, Tian, Kevin wrote:
>>>> /**
>>>> * iommu_device_use_default_domain() - Device driver wants to handle
>>>> device
>>>> * DMA through the kernel DMA API.
>>>> @@ -3052,14 +3063,14 @@ int
>> iommu_device_use_default_domain(struct
>>>> device *dev)
>>>>
>>>> mutex_lock(&group->mutex);
>>>> if (group->owner_cnt) {
>>>> - if (group->owner || !iommu_is_default_domain(group) ||
>>>> - !xa_empty(&group->pasid_array)) {
>>>> + if (group->owner || !iommu_is_default_domain(group)) {
>>>> ret = -EBUSY;
>>>> goto unlock_out;
>>>> }
>>>> }
>>>>
>>>> group->owner_cnt++;
>>>> + assert_pasid_dma_ownership(group);
>>> Old code returns error if pasid_xrrary is not empty.
>>>
>>> New code continues to take ownership with a warning.
>>>
>>> this is a functional change. Is it intended or not?
>> If iommu_device_use_default_domain() is called with pasid_array not
>> empty, there must be a bug somewhere in the device driver. We should
>> WARN it instead of returning an error. Probably this is a functional
>> change? If so, I can add this in the commit message.
>>
> IMHO we should WARN*and* return an error.
Okay, fine to me. Will make this in the next version.
Best regards,
baolu
Powered by blists - more mailing lists