Re: [PATCH v10 5/7] PCI: handle SR-IOV Virtual Function Migration

Yu Zhao
2009-03-09T08:27:56Z

On Sat, Mar 07, 2009 at 05:13:41AM +0800, Matthew Wilcox wrote:
> On Fri, Feb 20, 2009 at 02:54:46PM +0800, Yu Zhao wrote:
> > +static int sriov_migration(struct pci_dev *dev)
> > +{
> > + u16 status;
> > + struct pci_sriov *iov = dev->sriov;
> > +
> > + if (!iov->nr_virtfn)
> > + return 0;
> > +
> > + if (!(iov->cap & PCI_SRIOV_CAP_VFM))
> > + return 0;
> > +
> > + pci_read_config_word(iov->self, iov->pos + PCI_SRIOV_STATUS, &status);
>
> You passed in dev here, you don't need to use iov->self, right?

Will do.

> > + if (!(status & PCI_SRIOV_STATUS_VFM))
> > + return 0;
> > +
> > + schedule_work(&iov->mtask);
> > +
> > + return 1;
> > +}
>
> > +/**
> > + * pci_sriov_migration - notify SR-IOV core of Virtual Function Migration
> > + * @dev: the PCI device
> > + *
> > + * Returns IRQ_HANDLED if the IRQ is handled, or IRQ_NONE if not.
> > + *
> > + * Physical Function driver is responsible to register IRQ handler using
> > + * VF Migration Interrupt Message Number, and call this function when the
> > + * interrupt is generated by the hardware.
> > + */
> > +irqreturn_t pci_sriov_migration(struct pci_dev *dev)
> > +{
> > + if (!dev->sriov)
> > + return IRQ_NONE;
> > +
> > + return sriov_migration(dev) ? IRQ_HANDLED : IRQ_NONE;
> > +}
> > +EXPORT_SYMBOL_GPL(pci_sriov_migration);
>
> OK, I think I get it -- you've basically written an interrupt handler
> for the driver to call from its interrupt handler. Am I right in
> thinking that the reason the driver needs to do the interrupt handler
> here is because we don't currently have an interface that looks like:
>
> int pci_get_msix_interrupt(struct pci_dev *dev, unsigned vector);
>
> ? If so, we should probably add it; I want it for my MSI-X rewrite
> anyway.

Right, we really need this function. But I guess we still have to keep the
handler in case the PF only has MSI, right?

Thanks,
Yu