]> git.baikalelectronics.ru Git - kernel.git/commit
PCI: Determine actual VPD size on first access
authorHannes Reinecke <hare@suse.de>
Mon, 15 Feb 2016 08:42:01 +0000 (09:42 +0100)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 29 Feb 2016 23:47:04 +0000 (17:47 -0600)
commit6607d8017b01b4f2c2ecaac4ce674949611141fc
treeb74da33bf26e965809e35d310b73e95a4ea4cedc
parent393e5adcae697ab818d5b02e7c34b8047f02fce9
PCI: Determine actual VPD size on first access

PCI-2.2 VPD entries have a maximum size of 32k, but might actually be
smaller than that.  To figure out the actual size one has to read the VPD
area until the 'end marker' is reached.

Per spec, reading outside of the VPD space is "not allowed."  In practice,
it may cause simple read errors or even crash the card.  To make matters
worse not every PCI card implements this properly, leaving us with no 'end'
marker or even completely invalid data.

Try to determine the size of the VPD data when it's first accessed.  If no
valid data can be read an I/O error will be returned when reading or
writing the sysfs attribute.

As the amount of VPD data is unknown initially the size of the sysfs
attribute will always be set to '0'.

[bhelgaas: changelog, use 0/1 (not false/true) for bitfield, tweak
pci_vpd_pci22_read() error checking]
Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
drivers/pci/access.c
drivers/pci/pci-sysfs.c