Skip to contentSkip to conversation

PCI: Fix devfn for VPD access through function 0

PATCH Applied Alex Williamson 4 participants 6 messages Sep 15, 2015 – Sep 24, 2015 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")

---

Since the original patch and quirk was marked for stable and applies to all Intel NICs, regardless of the bus type, I assume this needs to chase it or VPD might disappear on e1000/e100 if it currently exists.

 drivers/pci/access.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/access.c +6 -3
index 769f7e3..5a5f0a7 100644
@@ -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,
 			       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;
 
 	if (!tdev)
@@ -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,
 				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;
 
 	if (!tdev)
@@ -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)
 {
-	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;
 
 	if (!tdev)
Acked-by on v1 1/1
#1 lore raw
Quoted 55 lines · Alex Williamson

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")

---

Since the original patch and quirk was marked for stable and applies to all Intel NICs, regardless of the bus type, I assume this needs to chase it or VPD might disappear on e1000/e100 if it currently exists.

 drivers/pci/access.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/access.c +6 -4
index 769f7e3..5a5f0a7 100644
@@ -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,
                               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;
 
        if (!tdev)
@@ -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,
                                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;
 
        if (!tdev)
@@ -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)
 {
-       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;
 
        if (!tdev)
 
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by on v1 1/1
#2 lore raw
In reply to Alex Williamson
Quoted 9 lines · Alex Williamson

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.

Quoted 8 lines
Fixes 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0")

---

Since the original patch and quirk was marked for stable and applies to all Intel NICs, regardless of the bus type, I assume this needs to chase it or VPD might disappear on e1000/e100 if it currently exists.

This looks good to me.

--
Mark Rustad, Networking Division, Intel Corporation

#3 lore raw
In reply to Alex Williamson
Quoted 10 lines · Alex Williamson

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")

Applied to for-linus for v4.3 with acks from Myron & Mark, thanks!

I removed the stable tag because 932c435caba8 first appeared in v4.3-rc1, so it shouldn't appear in any stable kernels yet. Right?

Quoted 49 lines

---

Since the original patch and quirk was marked for stable and applies to all Intel NICs, regardless of the bus type, I assume this needs to chase it or VPD might disappear on e1000/e100 if it currently exists.

 drivers/pci/access.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/access.c +6 -4
index 769f7e3..5a5f0a7 100644
@@ -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,
 			       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;
 
 	if (!tdev)
@@ -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,
 				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;
 
 	if (!tdev)
@@ -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)
 {
-	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;
 
 	if (!tdev)
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
Quoted 6 lines · Bjorn Helgaas

Applied to for-linus for v4.3 with acks from Myron & Mark, thanks!

I removed the stable tag because 932c435caba8 first appeared in v4.3-rc1, so it shouldn't appear in any stable kernels yet. Right?

I have seen the patch in some stable code reviews already. I know it was deferred from one, but I see it in the changelogs for 4.1.8 and 4.2.1. I have lost track if it is in any others.

--
Mark Rustad, Networking Division, Intel Corporation

#5 lore raw
Quoted 10 lines · Mark D
Quoted 6 lines · Bjorn Helgaas

Applied to for-linus for v4.3 with acks from Myron & Mark, thanks!

I removed the stable tag because 932c435caba8 first appeared in v4.3-rc1, so it shouldn't appear in any stable kernels yet. Right?

I have seen the patch in some stable code reviews already. I know it was deferred from one, but I see it in the changelogs for 4.1.8 and 4.2.1. I have lost track if it is in any others.

I added the stable tag back. 932c435caba8 itself was marked for stable, so I guess bugfixes to it should be marked the same way.

Bjorn