All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Zeng, Xin" <xin.zeng@intel.com>
Cc: "herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"yishaih@nvidia.com" <yishaih@nvidia.com>,
	"shameerali.kolothum.thodi@huawei.com"
	<shameerali.kolothum.thodi@huawei.com>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	qat-linux <qat-linux@intel.com>,
	"Cao, Yahui" <yahui.cao@intel.com>
Subject: Re: [PATCH 10/10] vfio/qat: Add vfio_pci driver for Intel QAT VF devices
Date: Fri, 9 Feb 2024 08:10:45 -0400	[thread overview]
Message-ID: <20240209121045.GP10476@nvidia.com> (raw)
In-Reply-To: <DM4PR11MB550222F7A5454DF9DBEE7FEC884B2@DM4PR11MB5502.namprd11.prod.outlook.com>

On Fri, Feb 09, 2024 at 08:23:32AM +0000, Zeng, Xin wrote:
> Thanks for your comments, Jason.
> On Tuesday, February 6, 2024 8:55 PM, Jason Gunthorpe <jgg@nvidia.com> wrote:
> > > +
> > > +	ops = mdev->ops;
> > > +	if (!ops || !ops->init || !ops->cleanup ||
> > > +	    !ops->open || !ops->close ||
> > > +	    !ops->save_state || !ops->load_state ||
> > > +	    !ops->suspend || !ops->resume) {
> > > +		ret = -EIO;
> > > +		dev_err(&parent->dev, "Incomplete device migration ops
> > structure!");
> > > +		goto err_destroy;
> > > +	}
> > 
> > Why are there ops pointers here? I would expect this should just be
> > direct function calls to the PF QAT driver.
> 
> I indeed had a version where the direct function calls are Implemented in
> QAT driver, while when I look at the functions, most of them 
> only translate the interface to the ops pointer. That's why I put
> ops pointers directly into vfio variant driver.

But why is there an ops indirection at all? Are there more than one
ops?

> > > +static void qat_vf_pci_aer_reset_done(struct pci_dev *pdev)
> > > +{
> > > +	struct qat_vf_core_device *qat_vdev = qat_vf_drvdata(pdev);
> > > +
> > > +	if (!qat_vdev->core_device.vdev.mig_ops)
> > > +		return;
> > > +
> > > +	/*
> > > +	 * As the higher VFIO layers are holding locks across reset and using
> > > +	 * those same locks with the mm_lock we need to prevent ABBA
> > deadlock
> > > +	 * with the state_mutex and mm_lock.
> > > +	 * In case the state_mutex was taken already we defer the cleanup work
> > > +	 * to the unlock flow of the other running context.
> > > +	 */
> > > +	spin_lock(&qat_vdev->reset_lock);
> > > +	qat_vdev->deferred_reset = true;
> > > +	if (!mutex_trylock(&qat_vdev->state_mutex)) {
> > > +		spin_unlock(&qat_vdev->reset_lock);
> > > +		return;
> > > +	}
> > > +	spin_unlock(&qat_vdev->reset_lock);
> > > +	qat_vf_state_mutex_unlock(qat_vdev);
> > > +}
> > 
> > Do you really need this? I thought this ugly thing was going to be a
> > uniquely mlx5 thing..
> 
> I think that's still required to make the migration state synchronized
> if the VF is reset by other VFIO emulation paths. Is it the case? 
> BTW, this implementation is not only in mlx5 driver, but also in other
> Vfio pci variant drivers such as hisilicon acc driver and pds
> driver.

It had to specifically do with the mm lock interaction that, I
thought, was going to be unique to the mlx driver. Otherwise you could
just directly hold the state_mutex here.

Yishai do you remember the exact trace for the mmlock entanglement?

Jason

  reply	other threads:[~2024-02-09 12:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 15:33 [PATCH 00/10] crypto: qat - enable SRIOV VF live migration for Xin Zeng
2024-02-01 15:33 ` [PATCH 01/10] crypto: qat - adf_get_etr_base() helper Xin Zeng
2024-02-01 15:33 ` [PATCH 02/10] crypto: qat - relocate and rename 4xxx PF2VM definitions Xin Zeng
2024-02-01 15:33 ` [PATCH 03/10] crypto: qat - move PFVF compat checker to a function Xin Zeng
2024-02-01 15:33 ` [PATCH 04/10] crypto: qat - relocate CSR access code Xin Zeng
2024-02-01 15:33 ` [PATCH 05/10] crypto: qat - rename get_sla_arr_of_type() Xin Zeng
2024-02-01 15:33 ` [PATCH 06/10] crypto: qat - expand CSR operations for QAT GEN4 devices Xin Zeng
2024-02-01 15:33 ` [PATCH 07/10] crypto: qat - add bank save and restore flows Xin Zeng
2024-02-04  7:49   ` [EXTERNAL] " Kamlesh Gurudasani
2024-02-19  3:41     ` Wan, Siming
2024-02-01 15:33 ` [PATCH 08/10] crypto: qat - add interface for live migration Xin Zeng
2024-02-01 15:33 ` [PATCH 09/10] crypto: qat - implement " Xin Zeng
2024-02-01 15:33 ` [PATCH 10/10] vfio/qat: Add vfio_pci driver for Intel QAT VF devices Xin Zeng
2024-02-06 12:55   ` Jason Gunthorpe
2024-02-09  8:23     ` Zeng, Xin
2024-02-09 12:10       ` Jason Gunthorpe [this message]
2024-02-11  8:17         ` Yishai Hadas
2024-02-17 16:20           ` Zeng, Xin
2024-02-20 13:24             ` Jason Gunthorpe
2024-02-20 15:53               ` Zeng, Xin
2024-02-20 17:03                 ` Jason Gunthorpe
2024-02-21  8:44                   ` Zeng, Xin
2024-02-21 13:18                     ` Jason Gunthorpe
2024-02-21 15:11                       ` Yishai Hadas
2024-02-22  9:39                         ` Yishai Hadas
2024-02-06 21:14   ` Alex Williamson
2024-02-09 16:16     ` Zeng, Xin
2024-02-08 12:17   ` Shameerali Kolothum Thodi
2024-02-13 13:08     ` Zeng, Xin
2024-02-13 14:55       ` 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=20240209121045.GP10476@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=xin.zeng@intel.com \
    --cc=yahui.cao@intel.com \
    --cc=yishaih@nvidia.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.