All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>,
	Christoph Hellwig <hch@infradead.org>
Cc: baolu.lu@linux.intel.com, iommu@lists.linux-foundation.org,
	LKML <linux-kernel@vger.kernel.org>,
	Joerg Roedel <joro@8bytes.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Jean-Philippe Brucker <jean-philippe@linaro.com>,
	Eric Auger <eric.auger@redhat.com>, Yi Liu <yi.l.liu@intel.com>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	Raj Ashok <ashok.raj@intel.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support
Date: Sat, 16 May 2020 14:02:23 +0800	[thread overview]
Message-ID: <462cad5b-624d-6f77-9503-82d2c5142940@linux.intel.com> (raw)
In-Reply-To: <20200514085745.105af4fb@jacob-builder>

Hi Jacob,

On 2020/5/14 23:57, Jacob Pan wrote:
> Hi Christoph,
> 
> Thanks a lot for the reviews, comments below.
> 
> Jacob
> 
> On Wed, 13 May 2020 22:59:30 -0700
> Christoph Hellwig<hch@infradead.org>  wrote:
> 
>>> +	if (dev_is_pci(dev)) {
>>> +		/* VT-d supports devices with full 20 bit PASIDs
>>> only */
>>> +		if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX)
>>> +			return -EINVAL;
>>> +	} else {
>>> +		return -ENOTSUPP;
>>> +	}
>> This looks strange.  Why not:
>>
>> 	if (!dev_is_pci(dev)) {
>> 		return -ENOTSUPP;
>>
>> 	/* VT-d supports devices with full 20 bit PASIDs only */
>> 	if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX)
>> 		return -EINVAL;
>>
> That is better, will do.
> 
>>> +		for_each_svm_dev(sdev, svm, dev) {
>>> +			/*
>>> +			 * For devices with aux domains, we should
>>> allow multiple
>>> +			 * bind calls with the same PASID and pdev.
>>> +			 */
>>> +			if (iommu_dev_feature_enabled(dev,
>>> IOMMU_DEV_FEAT_AUX)) {
>>> +				sdev->users++;
>>> +			} else {
>>> +				dev_warn_ratelimited(dev, "Already
>>> bound with PASID %u\n",
>>> +						svm->pasid);
>>> +				ret = -EBUSY;
>>> +			}
>>> +			goto out;
>> Is this intentionally a for loop that jumps out of the loop after
>> the first device?
>>
> The name is confusing, it is not a loop. I will change it to
> find_svm_dev() and comments like this?
> 
> /*
>   * Find the matching device in a given SVM. The bind code ensures that
>   * each device can only be added to the SVM list once.
>   */
> #define find_svm_dev(sdev, svm, d)			\
> 	list_for_each_entry((sdev), &(svm)->devs, list)	\
> 		if ((d) != (sdev)->dev) {} else
> 

The for_each_svm_dev() is not added by this series and is also used by
other functions. How about changing it in a separated patch?

Best regards,
baolu

WARNING: multiple messages have this Message-ID
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>,
	Christoph Hellwig <hch@infradead.org>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Raj Ashok <ashok.raj@intel.com>,
	David Woodhouse <dwmw2@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	iommu@lists.linux-foundation.org,
	Jean-Philippe Brucker <jean-philippe@linaro.com>,
	Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support
Date: Sat, 16 May 2020 14:02:23 +0800	[thread overview]
Message-ID: <462cad5b-624d-6f77-9503-82d2c5142940@linux.intel.com> (raw)
In-Reply-To: <20200514085745.105af4fb@jacob-builder>

Hi Jacob,

On 2020/5/14 23:57, Jacob Pan wrote:
> Hi Christoph,
> 
> Thanks a lot for the reviews, comments below.
> 
> Jacob
> 
> On Wed, 13 May 2020 22:59:30 -0700
> Christoph Hellwig<hch@infradead.org>  wrote:
> 
>>> +	if (dev_is_pci(dev)) {
>>> +		/* VT-d supports devices with full 20 bit PASIDs
>>> only */
>>> +		if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX)
>>> +			return -EINVAL;
>>> +	} else {
>>> +		return -ENOTSUPP;
>>> +	}
>> This looks strange.  Why not:
>>
>> 	if (!dev_is_pci(dev)) {
>> 		return -ENOTSUPP;
>>
>> 	/* VT-d supports devices with full 20 bit PASIDs only */
>> 	if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX)
>> 		return -EINVAL;
>>
> That is better, will do.
> 
>>> +		for_each_svm_dev(sdev, svm, dev) {
>>> +			/*
>>> +			 * For devices with aux domains, we should
>>> allow multiple
>>> +			 * bind calls with the same PASID and pdev.
>>> +			 */
>>> +			if (iommu_dev_feature_enabled(dev,
>>> IOMMU_DEV_FEAT_AUX)) {
>>> +				sdev->users++;
>>> +			} else {
>>> +				dev_warn_ratelimited(dev, "Already
>>> bound with PASID %u\n",
>>> +						svm->pasid);
>>> +				ret = -EBUSY;
>>> +			}
>>> +			goto out;
>> Is this intentionally a for loop that jumps out of the loop after
>> the first device?
>>
> The name is confusing, it is not a loop. I will change it to
> find_svm_dev() and comments like this?
> 
> /*
>   * Find the matching device in a given SVM. The bind code ensures that
>   * each device can only be added to the SVM list once.
>   */
> #define find_svm_dev(sdev, svm, d)			\
> 	list_for_each_entry((sdev), &(svm)->devs, list)	\
> 		if ((d) != (sdev)->dev) {} else
> 

The for_each_svm_dev() is not added by this series and is also used by
other functions. How about changing it in a separated patch?

Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  parent reply	other threads:[~2020-05-16  6:02 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 23:01 [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support Jacob Pan
2020-05-13 23:01 ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 1/8] iommu/vt-d: Move domain helper to header Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-14  5:51   ` Christoph Hellwig
2020-05-14  5:51     ` Christoph Hellwig
2020-05-14 15:20     ` Jacob Pan
2020-05-14 15:20       ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-14  5:54   ` Christoph Hellwig
2020-05-14  5:54     ` Christoph Hellwig
2020-05-14 15:31     ` Jacob Pan
2020-05-14 15:31       ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-14  5:59   ` Christoph Hellwig
2020-05-14  5:59     ` Christoph Hellwig
2020-05-14 15:57     ` Jacob Pan
2020-05-14 15:57       ` Jacob Pan
2020-05-15  1:01       ` Lu Baolu
2020-05-15  1:01         ` Lu Baolu
2020-05-16  6:02       ` Lu Baolu [this message]
2020-05-16  6:02         ` Lu Baolu
2020-05-13 23:01 ` [PATCH v13 5/8] iommu/vt-d: Support flushing more translation cache types Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 6/8] iommu/vt-d: Add svm/sva invalidate function Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 7/8] iommu/vt-d: Enlightened PASID allocation Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-13 23:01 ` [PATCH v13 8/8] iommu/vt-d: Add custom allocator for IOASID Jacob Pan
2020-05-13 23:01   ` Jacob Pan
2020-05-16  6:31 ` [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support Lu Baolu
2020-05-16  6:31   ` Lu Baolu
2020-05-16  4:59 [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support kbuild test robot

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=462cad5b-624d-6f77-9503-82d2c5142940@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=ashok.raj@intel.com \
    --cc=dwmw2@infradead.org \
    --cc=eric.auger@redhat.com \
    --cc=hch@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jean-philippe@linaro.com \
    --cc=jic23@kernel.org \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.