Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tg3: improve PCI VPD access

When working on the PCI VPD code I also tested with a Broadcom BCM95719
card. tg3 uses internal NVRAM access with this card, so I forced it to
PCI VPD mode for testing. PCI VPD access fails
(i + PCI_VPD_LRDT_TAG_SIZE + j > len) because only TG3_NVM_VPD_LEN (256)
bytes are read, but PCI VPD has 400 bytes on this card.

So add a constant TG3_NVM_PCI_VPD_MAX_LEN that defines the maximum
PCI VPD size. The actual VPD size is returned by pci_read_vpd().
In addition it's not worth looping over pci_read_vpd(). If we miss the
125ms timeout per VPD dword read then definitely something is wrong,
and if the tg3 module loading is killed then there's also not much
benefit in retrying the VPD read.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/cb9e9113-0861-3904-87e0-d4c4ab3c8860@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
24f97b6a a61e4b60

+11 -18
+10 -18
drivers/net/ethernet/broadcom/tg3.c
··· 12826 12826 12827 12827 offset = tg3_nvram_logical_addr(tp, offset); 12828 12828 } 12829 - } 12830 12829 12831 - if (!offset || !len) { 12832 - offset = TG3_NVM_VPD_OFF; 12833 - len = TG3_NVM_VPD_LEN; 12830 + if (!offset || !len) { 12831 + offset = TG3_NVM_VPD_OFF; 12832 + len = TG3_NVM_VPD_LEN; 12833 + } 12834 + } else { 12835 + len = TG3_NVM_PCI_VPD_MAX_LEN; 12834 12836 } 12835 12837 12836 12838 buf = kmalloc(len, GFP_KERNEL); ··· 12848 12846 if (tg3_nvram_read_be32(tp, offset + i, &buf[i/4])) 12849 12847 goto error; 12850 12848 } 12849 + *vpdlen = len; 12851 12850 } else { 12852 - u8 *ptr; 12853 12851 ssize_t cnt; 12854 - unsigned int pos = 0; 12855 12852 12856 - ptr = (u8 *)&buf[0]; 12857 - for (i = 0; pos < len && i < 3; i++, pos += cnt, ptr += cnt) { 12858 - cnt = pci_read_vpd(tp->pdev, pos, 12859 - len - pos, ptr); 12860 - if (cnt == -ETIMEDOUT || cnt == -EINTR) 12861 - cnt = 0; 12862 - else if (cnt < 0) 12863 - goto error; 12864 - } 12865 - if (pos != len) 12853 + cnt = pci_read_vpd(tp->pdev, 0, len, (u8 *)buf); 12854 + if (cnt < 0) 12866 12855 goto error; 12856 + *vpdlen = cnt; 12867 12857 } 12868 - 12869 - *vpdlen = len; 12870 12858 12871 12859 return buf; 12872 12860
+1
drivers/net/ethernet/broadcom/tg3.h
··· 2101 2101 /* Hardware Legacy NVRAM layout */ 2102 2102 #define TG3_NVM_VPD_OFF 0x100 2103 2103 #define TG3_NVM_VPD_LEN 256 2104 + #define TG3_NVM_PCI_VPD_MAX_LEN 512 2104 2105 2105 2106 /* Hardware Selfboot NVRAM layout */ 2106 2107 #define TG3_NVM_HWSB_CFG1 0x00000004