iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
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 v5 8/8] iommu/vt-d: Misc macro clean up for SVM
Date: Tue, 3 Dec 2019 10:27:56 -0800	[thread overview]
Message-ID: <20191203102756.73611444@jacob-builder> (raw)
In-Reply-To: <d3dd39dabf20814174c11f60dc22c2401490e4ca.camel@perches.com>

On Mon, 02 Dec 2019 12:10:45 -0800
Joe Perches <joe@perches.com> wrote:

> On Mon, 2019-12-02 at 11:58 -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  
> []
> > @@ -427,40 +430,36 @@ int intel_svm_unbind_mm(struct device *dev,
> > int pasid)  
> []
> > +	for_each_svm_dev(sdev, svm, dev) {
> > +		ret = 0;
> > +		sdev->users--;
> > +		if (!sdev->users) {  
> 
> This might be better by reducing indentation here too
> 
> 		if (sdev->users)
> 			break;
> 
> > +			list_del_rcu(&sdev->list);  
> 
> to reduce indentation 1 level below this
Sounds good but perhaps we can do this in a separate patch.

> 
> > +			/* Flush the PASID cache and IOTLB for
> > this device.
> > +			 * Note that we do depend on the hardware
> > *not* using
> > +			 * the PASID any more. Just as we depend
> > on other
> > +			 * devices never using PASIDs that they
> > have no right
> > +			 * to use. We have a *shared* PASID table,
> > because it's
> > +			 * large and has to be physically
> > contiguous. So it's
> > +			 * hard to be as defensive as we might
> > like. */
> > +			intel_pasid_tear_down_entry(iommu, dev,
> > svm->pasid);
> > +			intel_flush_svm_range_dev(svm, sdev, 0,
> > -1, 0);
> > +			kfree_rcu(sdev, rcu);
> > +
> > +			if (list_empty(&svm->devs)) {
> > +				ioasid_free(svm->pasid);
> > +				if (svm->mm)
> > +
> > mmu_notifier_unregister(&svm->notifier, svm->mm);
> > +				list_del(&svm->list);
> > +				/* We mandate that no page faults
> > may be outstanding
> > +				 * for the PASID when
> > intel_svm_unbind_mm() is called.
> > +				 * If that is not obeyed, subtle
> > errors will happen.
> > +				 * Let's make them less subtle...
> > */
> > +				memset(svm, 0x6b, sizeof(*svm));
> > +				kfree(svm);
> >  			}
> > -			break;
> >  		}
> > +		break;
> >  	}
> >   out:
> >  	mutex_unlock(&pasid_mutex);  
> 

[Jacob Pan]
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2019-12-03 18:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02 19:58 [PATCH v5 0/8] VT-d Native Shared virtual memory cleanup and fixes Jacob Pan
2019-12-02 19:58 ` [PATCH v5 1/8] iommu/vt-d: Fix CPU and IOMMU SVM feature matching checks Jacob Pan
2019-12-02 19:58 ` [PATCH v5 2/8] iommu/vt-d: Match CPU and IOMMU paging mode Jacob Pan
2019-12-02 19:58 ` [PATCH v5 3/8] iommu/vt-d: Reject SVM bind for failed capability check Jacob Pan
2019-12-02 19:58 ` [PATCH v5 4/8] iommu/vt-d: Avoid duplicated code for PASID setup Jacob Pan
2019-12-02 19:58 ` [PATCH v5 5/8] iommu/vt-d: Fix off-by-one in PASID allocation Jacob Pan
2019-12-02 19:58 ` [PATCH v5 6/8] iommu/vt-d: Replace Intel specific PASID allocator with IOASID Jacob Pan
2019-12-02 19:58 ` [PATCH v5 7/8] iommu/vt-d: Avoid sending invalid page response Jacob Pan
2019-12-02 19:58 ` [PATCH v5 8/8] iommu/vt-d: Misc macro clean up for SVM Jacob Pan
2019-12-02 20:10   ` Joe Perches
2019-12-03 18:27     ` Jacob Pan [this message]
2019-12-09 17:14 ` [PATCH v5 0/8] VT-d Native Shared virtual memory cleanup and fixes Jacob Pan
2019-12-10  1:14   ` Lu Baolu
2019-12-10 20:29     ` Jacob Pan
2019-12-28  2:46 ` Lu Baolu

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=20191203102756.73611444@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).