public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Nicolin Chen <nicolinc@nvidia.com>
Cc: baolu.lu@linux.intel.com, "Liu, Yi L" <yi.l.liu@intel.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] iommu: Consolidate pasid dma ownership check
Date: Wed, 2 Aug 2023 11:20:06 +0800	[thread overview]
Message-ID: <077966f0-d2fe-d85e-268a-a4f14c1870f1@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB5276B0865C9D8DC9060BF1A08C0BA@BN9PR11MB5276.namprd11.prod.outlook.com>

On 2023/8/2 9:39, Tian, Kevin wrote:
>> From: Baolu Lu<baolu.lu@linux.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

  reply	other threads:[~2023-08-02  3:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  6:31 [PATCH 0/2] iommu: Make pasid array per device Lu Baolu
2023-08-01  6:31 ` [PATCH 1/2] iommu: Consolidate pasid dma ownership check Lu Baolu
2023-08-01  7:03   ` Tian, Kevin
2023-08-01  7:43     ` Baolu Lu
2023-08-02  1:39       ` Tian, Kevin
2023-08-02  3:20         ` Baolu Lu [this message]
2023-08-01  6:31 ` [PATCH 2/2] iommu: Move pasid array from group to device Lu Baolu
     [not found]   ` <1254d61b-1f4e-2ef3-c3dc-95180f26f08c@intel.com>
2023-08-01  8:40     ` Baolu Lu
2023-08-02 14:15 ` [PATCH 0/2] iommu: Make pasid array per device Jason Gunthorpe
2023-08-03  0:44   ` Tian, Kevin
2023-08-03 15:18     ` Jason Gunthorpe
2023-08-04  0:57       ` Tian, Kevin
2023-08-04  2:20       ` Baolu Lu
2023-08-04  2:30         ` Baolu Lu
2023-08-04 13:12           ` 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=077966f0-d2fe-d85e-268a-a4f14c1870f1@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jean-philippe@linaro.org \
    --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=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.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