dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jerry Snitselaar <jsnitsel@redhat.com>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: Baolu Lu <baolu.lu@linux.intel.com>,
	iommu@lists.linux-foundation.org,
	Dave Jiang <dave.jiang@intel.com>,
	dmaengine@vger.kernel.org
Subject: Re: iommu_sva_bind_device question
Date: Sat, 25 Jun 2022 14:33:13 -0700	[thread overview]
Message-ID: <20220625213313.ekpo5vbowxlx4uwf@cantor> (raw)
In-Reply-To: <Yrdne20Eq+5KwF5h@fyu1.sc.intel.com>

On Sat, Jun 25, 2022 at 12:52:27PM -0700, Fenghua Yu wrote:
> Hi, Jerry and Baolu,
> 
> On Fri, Jun 24, 2022 at 07:47:30AM -0700, Jerry Snitselaar wrote:
> > > > > > > Hi Baolu & Dave,
> > > > > fails.
> > > > > 
> > > > > You also will get the following warning if you don't have scalable
> > > > > mode enabled (either not enabled by default, or if enabled by default
> > > > > and passed intel_iommu=on,sm_off):
> > > > 
> > > > If scalable mode is disabled, iommu_dev_enable_feature(IOMMU_SVA) will
> > > > return failure, hence driver should not call iommu_sva_bind_device().
> > > > I guess below will disappear if above is fixed in the idxd driver.
> 
> Yes, Jerry's patch fixes the WARNING as well.
> 
> > > > 
> > > > Best regards,
> > > > baolu
> > > >
> > > 
> > > It looks like there was a recent maintainer change, and Fenghua is now
> > > the maintainer. Fenghua thoughts on this? With 42a1b73852c4
> > > ("dmaengine: idxd: Separate user and kernel pasid enabling") the code
> > > no longer depends on iommu_dev_feature_enable succeeding. Testing with
> > > something like this works (ran dmatest without sm_on, and
> > > dsa_user_test_runner.sh with sm_on, plus booting with various
> > > intel_iommu= combinations):
> > > 
> > > diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
> > > index 355fb3ef4cbf..5b49fd5c1e25 100644
> > > --- a/drivers/dma/idxd/init.c
> > > +++ b/drivers/dma/idxd/init.c
> > > @@ -514,13 +514,14 @@ static int idxd_probe(struct idxd_device *idxd)
> > >         if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) {
> > >                 if (iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA))
> > >                         dev_warn(dev, "Unable to turn on user SVA feature.\n");
> > > -               else
> > > +               else {
> > >                         set_bit(IDXD_FLAG_USER_PASID_ENABLED, &idxd->flags);
> > > 
> > > -               if (idxd_enable_system_pasid(idxd))
> 
> Please add "{" after this if.
> 
> > > -                       dev_warn(dev, "No in-kernel DMA with PASID.\n");
> > > -               else
> then "}" before this else.
> 
> > > -                       set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags);
> > > +                       if (idxd_enable_system_pasid(idxd))
> > > +                               dev_warn(dev, "No in-kernel DMA with PASID.\n");
> > > +                       else
> > > +                               set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags);
> > > +               }
> > >         } else if (!sva) {
> > >                 dev_warn(dev, "User forced SVA off via module param.\n");
> > >         }
> 
> The patch was copied/pasted here. So the tabs are lost at beginning of each
> line. So it cannot be applied. Please change the tabs back.
> 
> Could you please send this patch in a separate email so that it has a
> right patch format and description and ready to be picked up?
> 

Sure, if you feel this is the correct solution. Just to be clear you would
like the end result to be:

	if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) {
		if (iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA))
			dev_warn(dev, "Unable to turn on user SVA feature.\n");
		else {
			set_bit(IDXD_FLAG_USER_PASID_ENABLED, &idxd->flags);

			if (idxd_enable_system_pasid(idxd)) {
				dev_warn(dev, "No in-kernel DMA with PASID.\n");
			} else
				set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags);
		}
	} else if (!sva) {
		dev_warn(dev, "User forced SVA off via module param.\n");
	}


> > > 
> > > The commit description is a bit confusing, because it talks about there
> > > being no dependency, but ties user pasid to enabling/disabling the SVA
> > > feature, which system pasid would depend on as well.
> > > 
> > > Regards,
> > > Jerry
> > 
> > Things like that warning message "Unable to turn on user SVA feature" when
> > iommu_dev_enable_feature fails though seems to be misleading with user
> > inserted in there. I'll leave it to the idxd folks to figure out.
> 
> How about removing "user" from the warning message? So the message will
> be "Unable to turn on SVA feature"?
>

I think what was confusing to me is it seemed to tie the SVA iommu
feature to the user, and talked about independence of the kernel and
user pasids. I understand the pasids themselves being independent, but
both depend on the SVA feature being enabled. So idxd_enable_system_pasid
can only happen if iommu_dev_feature_enable(dev, IOMMU_DEV_FEAT_SVA)
has succeeded prior to it, and idxd_disable_system_pasid should be
called if needed before there is a call to
iommu_dev_feature_disable(dev, IOMMU_DEV_FEAT_SVA).

When I looked at the code that seemed to be the case outside of this
block in idxd_probe, but I wasn't sure if I was missing something else.

Regards,
Jerry

> Thanks.
> 
> -Fenghua


      reply	other threads:[~2022-06-25 21:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 17:02 iommu_sva_bind_device question Jerry Snitselaar
2022-06-24  0:55 ` Baolu Lu
2022-06-24  1:14   ` Jerry Snitselaar
2022-06-24  1:43     ` Baolu Lu
2022-06-24 13:41       ` Jerry Snitselaar
2022-06-24 14:47         ` Jerry Snitselaar
2022-06-25 19:52           ` Fenghua Yu
2022-06-25 21:33             ` Jerry Snitselaar [this message]

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=20220625213313.ekpo5vbowxlx4uwf@cantor \
    --to=jsnitsel@redhat.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=iommu@lists.linux-foundation.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).