All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Alexander Duyck <aduyck@mirantis.com>,
	bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] iov: Update virtfn_max_buses to validate offset and stride
Date: Thu, 29 Oct 2015 14:50:10 -0500	[thread overview]
Message-ID: <20151029195010.GB19083@localhost> (raw)
In-Reply-To: <5631424A.7010408@gmail.com>

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

  reply	other threads:[~2015-10-29 19:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 20:52 [PATCH 0/5] Various of SR-IOV fixes and cleanup Alexander Duyck
2015-10-27 20:52 ` [PATCH 1/5] iov: Update virtfn_max_buses to validate offset and stride Alexander Duyck
2015-10-28 16:32   ` Bjorn Helgaas
2015-10-28 17:57     ` Alexander Duyck
2015-10-28 18:43     ` Bjorn Helgaas
2015-10-28 21:46       ` Alexander Duyck
2015-10-29 19:50         ` Bjorn Helgaas [this message]
2015-10-27 20:52 ` [PATCH 2/5] iov: Reset resources to 0 if totalVFs increases after enabling ARI Alexander Duyck
2015-10-28 16:37   ` Bjorn Helgaas
2015-10-28 18:32     ` Alexander Duyck
2015-10-28 19:52       ` Bjorn Helgaas
2015-10-28 21:37         ` Alexander Duyck
2015-10-27 20:52 ` [PATCH 3/5] iov: Fix sriov_enable exception handling path Alexander Duyck
2015-10-29 16:32   ` Bjorn Helgaas
2015-10-29 16:54     ` Alex Duyck
2015-10-29 20:41       ` Bjorn Helgaas
2015-10-27 20:52 ` [PATCH 4/5] iov: Variable and loop cleanup for sriov_disable and sriov_enable Alexander Duyck
2015-10-29 21:43   ` Bjorn Helgaas
2015-10-29 23:19     ` Alexander Duyck
2015-10-27 20:52 ` [PATCH 5/5] iov: Update sriov_enable to correctly handle offset and stride Alexander Duyck

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=20151029195010.GB19083@localhost \
    --to=helgaas@kernel.org \
    --cc=aduyck@mirantis.com \
    --cc=alexander.duyck@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.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 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.