Re: [PATCH 1/5] iov: Update virtfn_max_buses to validate offset and stride

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 28, 2015 at 02:46:50PM -0700, Alexander Duyck wrote:
> On 10/28/2015 11:43 AM, Bjorn Helgaas wrote:
> >On Wed, Oct 28, 2015 at 11:32:16AM -0500, Bjorn Helgaas wrote:

> >Here's my new proposal:
> >
> >   static int compute_max_vf_buses(struct pci_dev *dev)
> >   {
> >           struct pci_sriov *iov = dev->sriov;
> >           int nr_virtfn, busnr, rc = 0;
> >
> >           for (nr_virtfn = iov->total_VFs; nr_virtfn; nr_virtfn--) {
> >                   pci_iov_set_numvfs(dev, nr_virtfn);
> >                   if (!iov->offset || (nr_virtfn > 1 && !iov->stride)) {
> >                           rc = -EIO;
> >                           goto out;
> >                   }
> >
> >                   busnr = pci_iov_virtfn_bus(dev, nr_virtfn - 1);
> >                   if (busnr > iov->max_VF_buses)
> >                           iov->max_VF_buses = busnr;
> >           }
> >
> >   out:
> >           pci_iov_set_numvfs(dev, 0);
> >           return rc;
> >   }
> >
> 
> This looks good to me.  In theory you could save yourself a pair of
> MMIO reads at the end of the loop by just writing numvfs without the
> offset and stride read, but this should work.

True.  It's called once per device at boot-time, so it's not a hot path,
and I think it's worth two unnecessary MMIO reads to make it easier to
analyze: there's exactly one place that updates PCI_SRIOV_NUM_VF, and that
place always updates our caches of PCI_SRIOV_VF_OFFSET and
PCI_SRIOV_VF_STRIDE.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux