• Hannes Reinecke's avatar
    PCI: Determine actual VPD size on first access · 104daa71
    Hannes Reinecke authored
    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: 's avatarShane Seymour <shane.seymour@hpe.com>
    Tested-by: 's avatarBabu Moger <babu.moger@oracle.com>
    Signed-off-by: 's avatarHannes Reinecke <hare@suse.de>
    Signed-off-by: 's avatarBjorn Helgaas <bhelgaas@google.com>
    Cc: Alexander Duyck <alexander.duyck@gmail.com>
    104daa71
access.c 19.9 KB