diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2015-09-15 13:17:21 -0400 |
---|---|---|
committer | Bjorn Helgaas <helgaas@kernel.org> | 2015-09-24 18:06:32 -0400 |
commit | 9d9240756e63dd87d6cbf5da8b98ceb8f8192b55 (patch) | |
tree | 42cd8cc1a0587095cc8835a8c1d454643ccddcd6 | |
parent | 38ea72bdb65df2f40ec77b2c9d1413e7f5e34465 (diff) |
PCI: Fix devfn for VPD access through function 0
Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function
0") passes PCI_SLOT(devfn) for the devfn parameter of pci_get_slot().
Generally this works because we're fairly well guaranteed that a PCIe
device is at slot address 0, but for the general case, including
conventional PCI, it's incorrect. We need to get the slot and then convert
it back into a devfn.
Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <helgaas@kernel.org>
Acked-by: Myron Stowe <myron.stowe@redhat.com>
Acked-by: Mark Rustad <mark.d.rustad@intel.com>
CC: stable@vger.kernel.org
-rw-r--r-- | drivers/pci/access.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 769f7e35f1a2..5a5f0a7ba801 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -442,7 +442,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = { | |||
442 | static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, | 442 | static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, |
443 | void *arg) | 443 | void *arg) |
444 | { | 444 | { |
445 | struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); | 445 | struct pci_dev *tdev = pci_get_slot(dev->bus, |
446 | PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); | ||
446 | ssize_t ret; | 447 | ssize_t ret; |
447 | 448 | ||
448 | if (!tdev) | 449 | if (!tdev) |
@@ -456,7 +457,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, | |||
456 | static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count, | 457 | static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count, |
457 | const void *arg) | 458 | const void *arg) |
458 | { | 459 | { |
459 | struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); | 460 | struct pci_dev *tdev = pci_get_slot(dev->bus, |
461 | PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); | ||
460 | ssize_t ret; | 462 | ssize_t ret; |
461 | 463 | ||
462 | if (!tdev) | 464 | if (!tdev) |
@@ -475,7 +477,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = { | |||
475 | 477 | ||
476 | static int pci_vpd_f0_dev_check(struct pci_dev *dev) | 478 | static int pci_vpd_f0_dev_check(struct pci_dev *dev) |
477 | { | 479 | { |
478 | struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); | 480 | struct pci_dev *tdev = pci_get_slot(dev->bus, |
481 | PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); | ||
479 | int ret = 0; | 482 | int ret = 0; |
480 | 483 | ||
481 | if (!tdev) | 484 | if (!tdev) |