Commit 9d924075 authored by Alex Williamson's avatar Alex Williamson Committed by Bjorn Helgaas

PCI: Fix devfn for VPD access through function 0

Commit 932c435c ("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: 932c435c ("PCI: Add dev_flags bit to access VPD through function 0")
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: default avatarBjorn Helgaas <helgaas@kernel.org>
Acked-by: default avatarMyron Stowe <myron.stowe@redhat.com>
Acked-by: default avatarMark Rustad <mark.d.rustad@intel.com>
CC: stable@vger.kernel.org
parent 38ea72bd
...@@ -442,7 +442,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = { ...@@ -442,7 +442,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = {
static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
void *arg) void *arg)
{ {
struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); struct pci_dev *tdev = pci_get_slot(dev->bus,
PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
ssize_t ret; ssize_t ret;
if (!tdev) if (!tdev)
...@@ -456,7 +457,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, ...@@ -456,7 +457,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count, static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
const void *arg) const void *arg)
{ {
struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); struct pci_dev *tdev = pci_get_slot(dev->bus,
PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
ssize_t ret; ssize_t ret;
if (!tdev) if (!tdev)
...@@ -475,7 +477,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = { ...@@ -475,7 +477,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = {
static int pci_vpd_f0_dev_check(struct pci_dev *dev) static int pci_vpd_f0_dev_check(struct pci_dev *dev)
{ {
struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); struct pci_dev *tdev = pci_get_slot(dev->bus,
PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
int ret = 0; int ret = 0;
if (!tdev) if (!tdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment