Commit 3522ac7b authored by Alex Williamson's avatar Alex Williamson Committed by Kamal Mostafa

PCI: Fix devfn for VPD access through function 0

commit 9d924075 upstream.

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>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 971a8fa9
...@@ -362,7 +362,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = { ...@@ -362,7 +362,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)
...@@ -376,7 +377,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, ...@@ -376,7 +377,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)
...@@ -395,7 +397,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = { ...@@ -395,7 +397,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