pci: Use a bus-global mutex to protect VPD operations
PATCH 1/1 pci: Use a bus-global mutex to protect VPD operations
Some devices have a problem with concurrent VPD access to different functions of the same physical device, so move the protecting mutex from the pci_vpd structure to the pci_bus structure. There are a number of reports on support sites for a variety of devices from various vendors getting the "vpd r/w failed" message. This is likely to at least fix some of them. Thanks to Shannon Nelson for helping to come up with this approach.
--- drivers/pci/access.c | 10 ++++------ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/pci/access.c +4 -6
@@ -281,7 +281,6 @@ PCI_USER_WRITE_CONFIG(dword, u32)struct pci_vpd_pci22 {struct pci_vpd base; -struct mutex lock;u16 flag;bool busy;u8 cap;
@@ -340,7 +339,7 @@ static ssize_t pci_vpd_pci22_read(struct pci_dev *dev, loff_t pos, size_t count,if (pos <0 || pos > vpd->base.len || end > vpd->base.len)return -EINVAL ; -if (mutex_lock_killable (&vpd->lock)) +if (mutex_lock_killable (&dev->bus->vpd_mutex))return -EINTR ; ret =pci_vpd_pci22_wait (dev);
@@ -376,7 +375,7 @@ static ssize_t pci_vpd_pci22_read(struct pci_dev *dev, loff_t pos, size_t count, } } out: -mutex_unlock (&vpd->lock); +mutex_unlock (&dev->bus->vpd_mutex);return ret ? ret : count; }
@@ -392,7 +391,7 @@ static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t countif (pos <0 || (pos &3 ) || (count &3 ) || end > vpd->base.len)return -EINVAL ; -if (mutex_lock_killable (&vpd->lock)) +if (mutex_lock_killable (&dev->bus->vpd_mutex))return -EINTR ; ret =pci_vpd_pci22_wait (dev);
@@ -424,7 +423,7 @@ static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count pos +=sizeof (u32); } out: -mutex_unlock (&vpd->lock); +mutex_unlock (&dev->bus->vpd_mutex);return ret ? ret : count; }
@@ -453,7 +452,6 @@ int pci_vpd_pci22_init(struct pci_dev *dev) vpd->base.len =PCI_VPD_PCI22_SIZE ; vpd->base.ops = &pci_vpd_pci22_ops; -mutex_init (&vpd->lock); vpd->cap = cap; vpd->busy = false; dev->vpd = &vpd->base;
drivers/pci/probe.c +1 -0
@@ -494,6 +494,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)INIT_LIST_HEAD (&b->devices);INIT_LIST_HEAD (&b->slots);INIT_LIST_HEAD (&b->resources); +mutex_init (&b->vpd_mutex); b->max_bus_speed =PCI_SPEED_UNKNOWN ; b->cur_bus_speed =PCI_SPEED_UNKNOWN ;#ifdef CONFIG_PCI_DOMAINS_GENERIC
include/linux/pci.h +1 -0
@@ -454,6 +454,7 @@ struct pci_bus {struct msi_controller *msi;/* MSI controller */ void *sysdata;/* hook for sys-specific extension */ struct proc_dir_entry *procdir;/* directory entry in /proc/bus/pci */ +struct mutex vpd_mutex;/* bus-wide VPD access mutex */ unsigned char number;/* bus number */ unsigned char primary;/* number of primary bridge */
Nelson
PATCH 1/1 pci: Use a bus-global mutex to protect VPD operations
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Mark D Rustad
Sent: Friday, May 15, 2015 5:14 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH] pci: Use a bus-global mutex to protect VPD operationsSome devices have a problem with concurrent VPD access to different functions of the same physical device, so move the protecting mutex from the
pci_vpdstructure to thepci_busstructure. There are a number of reports on support sites for a variety of devices from various vendors getting the "vpd r/w failed" message. This is likely to at least fix some of them. Thanks to Shannon Nelson for helping to come up with this approach.
Quoted 1 line
Signed-off-by Mark Rustad <[email protected]>
Quoted 97 lines
--- drivers/pci/access.c | 10 ++++------ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-)drivers/pci/access.c +1
-2@@ -281,7 +281,6 @@ PCI_USER_WRITE_CONFIG(dword, u32)struct pci_vpd_pci22 {struct pci_vpd base; -struct mutex lock;u16 flag;bool busy;u8 cap;@@ -340,7 +339,7 @@ static ssize_t pci_vpd_pci22_read(struct pci_dev *dev, loff_t pos, size_t count, if (pos < 0 || pos > vpd->base.len || end > vpd->base.len) return -EINVAL; -if (mutex_lock_killable (&vpd->lock)) +if (mutex_lock_killable (&dev->bus->vpd_mutex))return -EINTR ;drivers/pci/access.c +2
-2ret =pci_vpd_pci22_wait (dev);@@ -376,7 +375,7 @@ static ssize_t pci_vpd_pci22_read(struct pci_dev *dev, loff_t pos, size_t count, } } out: - mutex_unlock(&vpd->lock); + mutex_unlock(&dev->bus->vpd_mutex);return ret ? ret : count; }@@ -392,7 +391,7 @@ static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t countif (pos <0 || (pos &3 ) || (count &3 ) || end > vpd->base.len)return -EINVAL ; -if (mutex_lock_killable (&vpd->lock)) +if (mutex_lock_killable (&dev->bus->vpd_mutex))return -EINTR ;drivers/pci/access.c +1
-2ret =pci_vpd_pci22_wait (dev);@@ -424,7 +423,7 @@ static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count pos +=sizeof (u32); } out: -mutex_unlock (&vpd->lock); +mutex_unlock (&dev->bus->vpd_mutex);return ret ? ret : count; }@@ -453,7 +452,6 @@ int pci_vpd_pci22_init(struct pci_dev *dev) vpd->base.len =PCI_VPD_PCI22_SIZE ; vpd->base.ops = &pci_vpd_pci22_ops; -mutex_init (&vpd->lock); vpd->cap = cap; vpd->busy = false; dev->vpd = &vpd->base;drivers/pci/probe.c +1
-0@@ -494,6 +494,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)INIT_LIST_HEAD (&b->devices);INIT_LIST_HEAD (&b->slots);INIT_LIST_HEAD (&b->resources); +mutex_init (&b->vpd_mutex); b->max_bus_speed =PCI_SPEED_UNKNOWN ; b->cur_bus_speed =PCI_SPEED_UNKNOWN ;#ifdef
CONFIG_PCI_DOMAINS_GENERICinclude/linux/pci.h +1
-0@@ -454,6 +454,7 @@ struct pci_bus {struct msi_controller *msi;/* MSI controller */ void *sysdata;/* hook for sys-specific extension */ struct proc_dir_entry *procdir;/* directory entry in /proc/bus/pci */ +struct mutex vpd_mutex;/* bus-wide VPD access mutex */ unsigned char number;/* bus number */ unsigned char primary; /* number of primary bridge */
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at lists.osuosl.org
http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 1/1 pci: Use a bus-global mutex to protect VPD operations
Quoted 17 lines · Shannon
Quoted 2 lines
-----Original Message-----
From: Intel-wired-lan[mailto:intel-wired-lan-bounces at lists.osuosl.org]
Quoted 14 lines
On Behalf Of Mark D Rustad
Sent: Friday, May 15, 2015 5:14 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH] pci: Use a bus-global mutex to protect VPD operationsSome devices have a problem with concurrent VPD access to different functions of the same physical device, so move the protecting mutex from the
pci_vpdstructure to thepci_busstructure. There are a number of reports on support sites for a variety of devices from various vendors getting the "vpd r/w failed" message. This is likely to at least fix some of them. Thanks to Shannon Nelson for helping to come up with this approach.
Quoted 11 lines
Quoted 1 line
Signed-off-by Mark Rustad <[email protected]>Acked-by Shannon Nelson <[email protected]>Quoted 5 lines
--- drivers/pci/access.c | 10 ++++------ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-)
Since this patch really needs to be sent to linux-pci & netdev, I have let Mark know to re-send this to Bjorn and the linux-pci mailing list.
Dropping this patch so that Mark can resend to the more appropriate
mailing lists.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20150518/8ee31a78/attachment-0001.asc>