From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Joe Perches <joe@perches.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
Raj Ashok <ashok.raj@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
iommu@lists.linux-foundation.org,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v4 8/8] iommu/vt-d: Misc macro clean up for SVM
Date: Mon, 2 Dec 2019 10:15:53 -0800 [thread overview]
Message-ID: <20191202101553.079898a3@jacob-builder> (raw)
In-Reply-To: <38d4586f3aeb21bb08028525db89868acb34e9fd.camel@perches.com>
On Thu, 21 Nov 2019 13:37:10 -0800
Joe Perches <joe@perches.com> wrote:
> On Thu, 2019-11-21 at 13:26 -0800, Jacob Pan wrote:
> > Use combined macros for_each_svm_dev() to simplify SVM device
> > iteration and error checking.
> []
> > diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
> []
> > +#define for_each_svm_dev(sdev, svm, d) \
> > + list_for_each_entry((sdev), &(svm)->devs, list) \
> > + if ((d) != (sdev)->dev) {} else
> > +
> > int intel_svm_bind_mm(struct device *dev, int *pasid, int flags,
> > struct svm_dev_ops *ops) {
> > struct intel_iommu *iommu = intel_svm_device_to_iommu(dev);
> > @@ -274,15 +278,13 @@ int intel_svm_bind_mm(struct device *dev, int
> > *pasid, int flags, struct svm_dev_ goto out;
> > }
> >
> > - list_for_each_entry(sdev, &svm->devs,
> > list) {
> > - if (dev == sdev->dev) {
> > - if (sdev->ops != ops) {
> > - ret = -EBUSY;
> > - goto out;
> > - }
> > - sdev->users++;
> > - goto success;
> > + for_each_svm_dev(sdev, svm, dev) {
> > + if (sdev->ops != ops) {
> > + ret = -EBUSY;
> > + goto out;
> > }
> > + sdev->users++;
> > + goto success;
> > }
>
> I think this does not read better as this is now a
> for_each loop that exits the loop on the first match.
>
I think one of the benefits is reduced indentation. What do you
recommend?
> >
> > break;
> > @@ -427,43 +429,36 @@ int intel_svm_unbind_mm(struct device *dev,
> > int pasid) goto out;
> > }
> >
> > - if (!svm)
> > - goto out;
> > -
> > - list_for_each_entry(sdev, &svm->devs, list) {
> []
> > + for_each_svm_dev(sdev, svm, dev) {
>
> I think this should not remove the !svm test above.
>
Yeah, !svm test should have been part of 6/8. I will fix that.
Thanks,
Jacob
>
[Jacob Pan]
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Jacob Pan <jacob.jun.pan@linux.intel.com>
To: Joe Perches <joe@perches.com>
Cc: iommu@lists.linux-foundation.org,
LKML <linux-kernel@vger.kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
David Woodhouse <dwmw2@infradead.org>,
"Tian, Kevin" <kevin.tian@intel.com>,
Raj Ashok <ashok.raj@intel.com>, Yi Liu <yi.l.liu@intel.com>,
Eric Auger <eric.auger@redhat.com>,
"Mehta, Sohil" <sohil.mehta@intel.com>,
jacob.jun.pan@linux.intel.com
Subject: Re: [PATCH v4 8/8] iommu/vt-d: Misc macro clean up for SVM
Date: Mon, 2 Dec 2019 10:15:53 -0800 [thread overview]
Message-ID: <20191202101553.079898a3@jacob-builder> (raw)
In-Reply-To: <38d4586f3aeb21bb08028525db89868acb34e9fd.camel@perches.com>
On Thu, 21 Nov 2019 13:37:10 -0800
Joe Perches <joe@perches.com> wrote:
> On Thu, 2019-11-21 at 13:26 -0800, Jacob Pan wrote:
> > Use combined macros for_each_svm_dev() to simplify SVM device
> > iteration and error checking.
> []
> > diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
> []
> > +#define for_each_svm_dev(sdev, svm, d) \
> > + list_for_each_entry((sdev), &(svm)->devs, list) \
> > + if ((d) != (sdev)->dev) {} else
> > +
> > int intel_svm_bind_mm(struct device *dev, int *pasid, int flags,
> > struct svm_dev_ops *ops) {
> > struct intel_iommu *iommu = intel_svm_device_to_iommu(dev);
> > @@ -274,15 +278,13 @@ int intel_svm_bind_mm(struct device *dev, int
> > *pasid, int flags, struct svm_dev_ goto out;
> > }
> >
> > - list_for_each_entry(sdev, &svm->devs,
> > list) {
> > - if (dev == sdev->dev) {
> > - if (sdev->ops != ops) {
> > - ret = -EBUSY;
> > - goto out;
> > - }
> > - sdev->users++;
> > - goto success;
> > + for_each_svm_dev(sdev, svm, dev) {
> > + if (sdev->ops != ops) {
> > + ret = -EBUSY;
> > + goto out;
> > }
> > + sdev->users++;
> > + goto success;
> > }
>
> I think this does not read better as this is now a
> for_each loop that exits the loop on the first match.
>
I think one of the benefits is reduced indentation. What do you
recommend?
> >
> > break;
> > @@ -427,43 +429,36 @@ int intel_svm_unbind_mm(struct device *dev,
> > int pasid) goto out;
> > }
> >
> > - if (!svm)
> > - goto out;
> > -
> > - list_for_each_entry(sdev, &svm->devs, list) {
> []
> > + for_each_svm_dev(sdev, svm, dev) {
>
> I think this should not remove the !svm test above.
>
Yeah, !svm test should have been part of 6/8. I will fix that.
Thanks,
Jacob
>
[Jacob Pan]
next prev parent reply other threads:[~2019-12-02 18:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 21:26 [PATCH v4 0/8] VT-d Native Shared virtual memory cleanup and fixes Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 1/8] iommu/vt-d: Fix CPU and IOMMU SVM feature matching checks Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 2/8] iommu/vt-d: Match CPU and IOMMU paging mode Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 3/8] iommu/vt-d: Reject SVM bind for failed capability check Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 4/8] iommu/vt-d: Avoid duplicated code for PASID setup Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 5/8] iommu/vt-d: Fix off-by-one in PASID allocation Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 6/8] iommu/vt-d: Replace Intel specific PASID allocator with IOASID Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 7/8] iommu/vt-d: Avoid sending invalid page response Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:26 ` [PATCH v4 8/8] iommu/vt-d: Misc macro clean up for SVM Jacob Pan
2019-11-21 21:26 ` Jacob Pan
2019-11-21 21:37 ` Joe Perches
2019-11-21 21:37 ` Joe Perches
2019-12-02 18:15 ` Jacob Pan [this message]
2019-12-02 18:15 ` Jacob Pan
2019-12-02 18:22 ` Joe Perches
2019-12-02 18:22 ` Joe Perches
2019-12-02 19:51 ` Jacob Pan
2019-12-02 19:51 ` 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=20191202101553.079898a3@jacob-builder \
--to=jacob.jun.pan@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joe@perches.com \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.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 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.