Commit 1a74f72d authored by Alex Williamson's avatar Alex Williamson Committed by Luis Henriques

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 avatarLuis Henriques <luis.henriques@canonical.com>
parent d0633d21
...@@ -355,7 +355,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = { ...@@ -355,7 +355,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)
...@@ -369,7 +370,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, ...@@ -369,7 +370,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)
...@@ -388,7 +390,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = { ...@@ -388,7 +390,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