* [PATCH] PCI: Remove unnecessary re-read of SR-IOV offset/stride registers
@ 2015-10-16 21:16 Bjorn Helgaas
2015-10-22 18:56 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Helgaas @ 2015-10-16 21:16 UTC (permalink / raw)
To: linux-pci; +Cc: Ben Shelton, linux-kernel, Alexander Duyck
Previously, we read PCI_SRIOV_VF_OFFSET and PCI_SRIOV_VF_STRIDE from the
SR-IOV capability in pci_iov_set_numvfs() after changing PCI_SRIOV_NUM_VF,
and we read them again in sriov_enable(). But sriov_init() always calls
pci_iov_set_numvfs() before a successful return, and it caches the offset
and stride values, so there's no need to read the capability again in
sriov_enable().
Remove the PCI_SRIOV_VF_OFFSET and PCI_SRIOV_VF_STRIDE config reads from
sriov_enable() and use the cached values from the pci_sriov structure.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/iov.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 0202ab0..9b52ad4 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -230,7 +230,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
int rc;
int i, j;
int nres;
- u16 offset, stride, initial;
+ u16 initial;
struct resource *res;
struct pci_dev *pdev;
struct pci_sriov *iov = dev->sriov;
@@ -253,9 +253,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
(!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial)))
return -EINVAL;
- pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_OFFSET, &offset);
- pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_STRIDE, &stride);
- if (!offset || (nr_virtfn > 1 && !stride))
+ if (!iov->offset || (nr_virtfn > 1 && !iov->stride))
return -EIO;
nres = 0;
@@ -270,9 +268,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
return -ENOMEM;
}
- iov->offset = offset;
- iov->stride = stride;
-
bus = pci_iov_virtfn_bus(dev, nr_virtfn - 1);
if (bus > dev->bus->busn_res.end) {
dev_err(&dev->dev, "can't enable %d VFs (bus %02x out of range of %pR)\n",
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] PCI: Remove unnecessary re-read of SR-IOV offset/stride registers
2015-10-16 21:16 [PATCH] PCI: Remove unnecessary re-read of SR-IOV offset/stride registers Bjorn Helgaas
@ 2015-10-22 18:56 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2015-10-22 18:56 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Ben Shelton, linux-kernel, Alexander Duyck
On Fri, Oct 16, 2015 at 04:16:28PM -0500, Bjorn Helgaas wrote:
> Previously, we read PCI_SRIOV_VF_OFFSET and PCI_SRIOV_VF_STRIDE from the
> SR-IOV capability in pci_iov_set_numvfs() after changing PCI_SRIOV_NUM_VF,
> and we read them again in sriov_enable(). But sriov_init() always calls
> pci_iov_set_numvfs() before a successful return, and it caches the offset
> and stride values, so there's no need to read the capability again in
> sriov_enable().
>
> Remove the PCI_SRIOV_VF_OFFSET and PCI_SRIOV_VF_STRIDE config reads from
> sriov_enable() and use the cached values from the pci_sriov structure.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
I haven't seen any objections, so I applied this to pci/virtualization for
v4.4.
> ---
> drivers/pci/iov.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index 0202ab0..9b52ad4 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -230,7 +230,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
> int rc;
> int i, j;
> int nres;
> - u16 offset, stride, initial;
> + u16 initial;
> struct resource *res;
> struct pci_dev *pdev;
> struct pci_sriov *iov = dev->sriov;
> @@ -253,9 +253,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
> (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial)))
> return -EINVAL;
>
> - pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_OFFSET, &offset);
> - pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_STRIDE, &stride);
> - if (!offset || (nr_virtfn > 1 && !stride))
> + if (!iov->offset || (nr_virtfn > 1 && !iov->stride))
> return -EIO;
>
> nres = 0;
> @@ -270,9 +268,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
> return -ENOMEM;
> }
>
> - iov->offset = offset;
> - iov->stride = stride;
> -
> bus = pci_iov_virtfn_bus(dev, nr_virtfn - 1);
> if (bus > dev->bus->busn_res.end) {
> dev_err(&dev->dev, "can't enable %d VFs (bus %02x out of range of %pR)\n",
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-22 18:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-16 21:16 [PATCH] PCI: Remove unnecessary re-read of SR-IOV offset/stride registers Bjorn Helgaas
2015-10-22 18:56 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).