Re: [RFC v4 7/8] hisi_acc_vfio_pci: Add support for VFIO live migration

From: Jason Gunthorpe
Date: Tue Feb 08 2022 - 11:01:19 EST


On Tue, Feb 08, 2022 at 03:48:16PM +0000, Shameerali Kolothum Thodi wrote:

> > > +static int hisi_acc_vfio_pci_init(struct hisi_acc_vf_core_device
> > *hisi_acc_vdev)
> > > +{
> > > + struct vfio_pci_core_device *vdev = &hisi_acc_vdev->core_device;
> > > + struct pci_dev *vf_dev = vdev->pdev;
> > > + struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm;
> > > +
> > > + /*
> > > + * ACC VF dev BAR2 region consists of both functional register space
> > > + * and migration control register space. For migration to work, we
> > > + * need access to both. Hence, we map the entire BAR2 region here.
> > > + * But from a security point of view, we restrict access to the
> > > + * migration control space from Guest(Please see mmap/ioctl/read/write
> > > + * override functions).
> > > + *
> > > + * Also the HiSilicon ACC VF devices supported by this driver on
> > > + * HiSilicon hardware platforms are integrated end point devices
> > > + * and has no capability to perform PCIe P2P.
> > > + */
> > > + vf_qm->io_base =
> > > + ioremap(pci_resource_start(vf_dev, VFIO_PCI_BAR2_REGION_INDEX),
> > > + pci_resource_len(vf_dev, VFIO_PCI_BAR2_REGION_INDEX));
> > > + if (!vf_qm->io_base)
> > > + return -EIO;
> > > +
> > > + vf_qm->fun_type = QM_HW_VF;
> > > + vf_qm->pdev = vf_dev;
> > > + mutex_init(&vf_qm->mailbox_lock);
> >
> > mailbox_lock seems unused
>
> I think we need that as that will be used in the QM driver APIs. I will add a
> comment here.

Perhaps you need some 'init hisi_qm' function to make this more clear
instead of opening coding initing so other module's structure?

Jason