vpd.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * PCI VPD support
  4. *
  5. * Copyright (C) 2010 Broadcom Corporation.
  6. */
  7. #include <linux/pci.h>
  8. #include <linux/delay.h>
  9. #include <linux/export.h>
  10. #include <linux/sched/signal.h>
  11. #include <linux/unaligned.h>
  12. #include "pci.h"
  13. #define PCI_VPD_LRDT_TAG_SIZE 3
  14. #define PCI_VPD_SRDT_LEN_MASK 0x07
  15. #define PCI_VPD_SRDT_TAG_SIZE 1
  16. #define PCI_VPD_STIN_END 0x0f
  17. #define PCI_VPD_INFO_FLD_HDR_SIZE 3
  18. static u16 pci_vpd_lrdt_size(const u8 *lrdt)
  19. {
  20. return get_unaligned_le16(lrdt + 1);
  21. }
  22. static u8 pci_vpd_srdt_tag(const u8 *srdt)
  23. {
  24. return *srdt >> 3;
  25. }
  26. static u8 pci_vpd_srdt_size(const u8 *srdt)
  27. {
  28. return *srdt & PCI_VPD_SRDT_LEN_MASK;
  29. }
  30. static u8 pci_vpd_info_field_size(const u8 *info_field)
  31. {
  32. return info_field[2];
  33. }
  34. /* VPD access through PCI 2.2+ VPD capability */
  35. static struct pci_dev *pci_get_func0_dev(struct pci_dev *dev)
  36. {
  37. return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
  38. }
  39. #define PCI_VPD_MAX_SIZE (PCI_VPD_ADDR_MASK + 1)
  40. #define PCI_VPD_SZ_INVALID UINT_MAX
  41. /**
  42. * pci_vpd_size - determine actual size of Vital Product Data
  43. * @dev: pci device struct
  44. */
  45. static size_t pci_vpd_size(struct pci_dev *dev)
  46. {
  47. size_t off = 0, size;
  48. unsigned char tag, header[1+2]; /* 1 byte tag, 2 bytes length */
  49. while (pci_read_vpd_any(dev, off, 1, header) == 1) {
  50. size = 0;
  51. if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
  52. goto error;
  53. if (header[0] & PCI_VPD_LRDT) {
  54. /* Large Resource Data Type Tag */
  55. if (pci_read_vpd_any(dev, off + 1, 2, &header[1]) != 2) {
  56. pci_warn(dev, "failed VPD read at offset %zu\n",
  57. off + 1);
  58. return off ?: PCI_VPD_SZ_INVALID;
  59. }
  60. size = pci_vpd_lrdt_size(header);
  61. if (off + size > PCI_VPD_MAX_SIZE)
  62. goto error;
  63. off += PCI_VPD_LRDT_TAG_SIZE + size;
  64. } else {
  65. /* Short Resource Data Type Tag */
  66. tag = pci_vpd_srdt_tag(header);
  67. size = pci_vpd_srdt_size(header);
  68. if (off + size > PCI_VPD_MAX_SIZE)
  69. goto error;
  70. off += PCI_VPD_SRDT_TAG_SIZE + size;
  71. if (tag == PCI_VPD_STIN_END) /* End tag descriptor */
  72. return off;
  73. }
  74. }
  75. return off;
  76. error:
  77. pci_info(dev, "invalid VPD tag %#04x (size %zu) at offset %zu%s\n",
  78. header[0], size, off, off == 0 ?
  79. "; assume missing optional EEPROM" : "");
  80. return off ?: PCI_VPD_SZ_INVALID;
  81. }
  82. static bool pci_vpd_available(struct pci_dev *dev, bool check_size)
  83. {
  84. struct pci_vpd *vpd = &dev->vpd;
  85. if (!vpd->cap)
  86. return false;
  87. if (vpd->len == 0 && check_size) {
  88. vpd->len = pci_vpd_size(dev);
  89. if (vpd->len == PCI_VPD_SZ_INVALID) {
  90. vpd->cap = 0;
  91. return false;
  92. }
  93. }
  94. return true;
  95. }
  96. /*
  97. * Wait for last operation to complete.
  98. * This code has to spin since there is no other notification from the PCI
  99. * hardware. Since the VPD is often implemented by serial attachment to an
  100. * EEPROM, it may take many milliseconds to complete.
  101. * @set: if true wait for flag to be set, else wait for it to be cleared
  102. *
  103. * Returns 0 on success, negative values indicate error.
  104. */
  105. static int pci_vpd_wait(struct pci_dev *dev, bool set)
  106. {
  107. struct pci_vpd *vpd = &dev->vpd;
  108. unsigned long timeout = jiffies + msecs_to_jiffies(125);
  109. unsigned long max_sleep = 16;
  110. u16 status;
  111. int ret;
  112. do {
  113. ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
  114. &status);
  115. if (ret < 0)
  116. return ret;
  117. if (!!(status & PCI_VPD_ADDR_F) == set)
  118. return 0;
  119. if (time_after(jiffies, timeout))
  120. break;
  121. usleep_range(10, max_sleep);
  122. if (max_sleep < 1024)
  123. max_sleep *= 2;
  124. } while (true);
  125. pci_warn(dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n");
  126. return -ETIMEDOUT;
  127. }
  128. static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
  129. void *arg, bool check_size)
  130. {
  131. struct pci_vpd *vpd = &dev->vpd;
  132. unsigned int max_len;
  133. int ret = 0;
  134. loff_t end = pos + count;
  135. u8 *buf = arg;
  136. if (!pci_vpd_available(dev, check_size))
  137. return -ENODEV;
  138. if (pos < 0)
  139. return -EINVAL;
  140. max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
  141. if (pos >= max_len)
  142. return 0;
  143. if (end > max_len) {
  144. end = max_len;
  145. count = end - pos;
  146. }
  147. if (mutex_lock_killable(&vpd->lock))
  148. return -EINTR;
  149. while (pos < end) {
  150. u32 val;
  151. unsigned int i, skip;
  152. if (fatal_signal_pending(current)) {
  153. ret = -EINTR;
  154. break;
  155. }
  156. ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
  157. pos & ~3);
  158. if (ret < 0)
  159. break;
  160. ret = pci_vpd_wait(dev, true);
  161. if (ret < 0)
  162. break;
  163. ret = pci_user_read_config_dword(dev, vpd->cap + PCI_VPD_DATA, &val);
  164. if (ret < 0)
  165. break;
  166. skip = pos & 3;
  167. for (i = 0; i < sizeof(u32); i++) {
  168. if (i >= skip) {
  169. *buf++ = val;
  170. if (++pos == end)
  171. break;
  172. }
  173. val >>= 8;
  174. }
  175. }
  176. mutex_unlock(&vpd->lock);
  177. return ret ? ret : count;
  178. }
  179. static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
  180. const void *arg, bool check_size)
  181. {
  182. struct pci_vpd *vpd = &dev->vpd;
  183. unsigned int max_len;
  184. const u8 *buf = arg;
  185. loff_t end = pos + count;
  186. int ret = 0;
  187. if (!pci_vpd_available(dev, check_size))
  188. return -ENODEV;
  189. if (pos < 0 || (pos & 3) || (count & 3))
  190. return -EINVAL;
  191. max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
  192. if (end > max_len)
  193. return -EINVAL;
  194. if (mutex_lock_killable(&vpd->lock))
  195. return -EINTR;
  196. while (pos < end) {
  197. ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA,
  198. get_unaligned_le32(buf));
  199. if (ret < 0)
  200. break;
  201. ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
  202. pos | PCI_VPD_ADDR_F);
  203. if (ret < 0)
  204. break;
  205. ret = pci_vpd_wait(dev, false);
  206. if (ret < 0)
  207. break;
  208. buf += sizeof(u32);
  209. pos += sizeof(u32);
  210. }
  211. mutex_unlock(&vpd->lock);
  212. return ret ? ret : count;
  213. }
  214. void pci_vpd_init(struct pci_dev *dev)
  215. {
  216. if (dev->vpd.len == PCI_VPD_SZ_INVALID)
  217. return;
  218. dev->vpd.cap = pci_find_capability(dev, PCI_CAP_ID_VPD);
  219. mutex_init(&dev->vpd.lock);
  220. }
  221. static ssize_t vpd_read(struct file *filp, struct kobject *kobj,
  222. struct bin_attribute *bin_attr, char *buf, loff_t off,
  223. size_t count)
  224. {
  225. struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
  226. struct pci_dev *vpd_dev = dev;
  227. ssize_t ret;
  228. if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
  229. vpd_dev = pci_get_func0_dev(dev);
  230. if (!vpd_dev)
  231. return -ENODEV;
  232. }
  233. pci_config_pm_runtime_get(vpd_dev);
  234. ret = pci_read_vpd(vpd_dev, off, count, buf);
  235. pci_config_pm_runtime_put(vpd_dev);
  236. if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0)
  237. pci_dev_put(vpd_dev);
  238. return ret;
  239. }
  240. static ssize_t vpd_write(struct file *filp, struct kobject *kobj,
  241. struct bin_attribute *bin_attr, char *buf, loff_t off,
  242. size_t count)
  243. {
  244. struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
  245. struct pci_dev *vpd_dev = dev;
  246. ssize_t ret;
  247. if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
  248. vpd_dev = pci_get_func0_dev(dev);
  249. if (!vpd_dev)
  250. return -ENODEV;
  251. }
  252. pci_config_pm_runtime_get(vpd_dev);
  253. ret = pci_write_vpd(vpd_dev, off, count, buf);
  254. pci_config_pm_runtime_put(vpd_dev);
  255. if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0)
  256. pci_dev_put(vpd_dev);
  257. return ret;
  258. }
  259. static BIN_ATTR(vpd, 0600, vpd_read, vpd_write, 0);
  260. static struct bin_attribute *vpd_attrs[] = {
  261. &bin_attr_vpd,
  262. NULL,
  263. };
  264. static umode_t vpd_attr_is_visible(struct kobject *kobj,
  265. struct bin_attribute *a, int n)
  266. {
  267. struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
  268. if (!pdev->vpd.cap)
  269. return 0;
  270. return a->attr.mode;
  271. }
  272. const struct attribute_group pci_dev_vpd_attr_group = {
  273. .bin_attrs = vpd_attrs,
  274. .is_bin_visible = vpd_attr_is_visible,
  275. };
  276. void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size)
  277. {
  278. unsigned int len;
  279. void *buf;
  280. int cnt;
  281. if (!pci_vpd_available(dev, true))
  282. return ERR_PTR(-ENODEV);
  283. len = dev->vpd.len;
  284. buf = kmalloc(len, GFP_KERNEL);
  285. if (!buf)
  286. return ERR_PTR(-ENOMEM);
  287. cnt = pci_read_vpd(dev, 0, len, buf);
  288. if (cnt != len) {
  289. kfree(buf);
  290. return ERR_PTR(-EIO);
  291. }
  292. if (size)
  293. *size = len;
  294. return buf;
  295. }
  296. EXPORT_SYMBOL_GPL(pci_vpd_alloc);
  297. static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt, unsigned int *size)
  298. {
  299. int i = 0;
  300. /* look for LRDT tags only, end tag is the only SRDT tag */
  301. while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) {
  302. unsigned int lrdt_len = pci_vpd_lrdt_size(buf + i);
  303. u8 tag = buf[i];
  304. i += PCI_VPD_LRDT_TAG_SIZE;
  305. if (tag == rdt) {
  306. if (i + lrdt_len > len)
  307. lrdt_len = len - i;
  308. if (size)
  309. *size = lrdt_len;
  310. return i;
  311. }
  312. i += lrdt_len;
  313. }
  314. return -ENOENT;
  315. }
  316. int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size)
  317. {
  318. return pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_ID_STRING, size);
  319. }
  320. EXPORT_SYMBOL_GPL(pci_vpd_find_id_string);
  321. static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
  322. unsigned int len, const char *kw)
  323. {
  324. int i;
  325. for (i = off; i + PCI_VPD_INFO_FLD_HDR_SIZE <= off + len;) {
  326. if (buf[i + 0] == kw[0] &&
  327. buf[i + 1] == kw[1])
  328. return i;
  329. i += PCI_VPD_INFO_FLD_HDR_SIZE +
  330. pci_vpd_info_field_size(&buf[i]);
  331. }
  332. return -ENOENT;
  333. }
  334. static ssize_t __pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf,
  335. bool check_size)
  336. {
  337. ssize_t ret;
  338. if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
  339. dev = pci_get_func0_dev(dev);
  340. if (!dev)
  341. return -ENODEV;
  342. ret = pci_vpd_read(dev, pos, count, buf, check_size);
  343. pci_dev_put(dev);
  344. return ret;
  345. }
  346. return pci_vpd_read(dev, pos, count, buf, check_size);
  347. }
  348. /**
  349. * pci_read_vpd - Read one entry from Vital Product Data
  350. * @dev: PCI device struct
  351. * @pos: offset in VPD space
  352. * @count: number of bytes to read
  353. * @buf: pointer to where to store result
  354. */
  355. ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
  356. {
  357. return __pci_read_vpd(dev, pos, count, buf, true);
  358. }
  359. EXPORT_SYMBOL(pci_read_vpd);
  360. /* Same, but allow to access any address */
  361. ssize_t pci_read_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
  362. {
  363. return __pci_read_vpd(dev, pos, count, buf, false);
  364. }
  365. EXPORT_SYMBOL(pci_read_vpd_any);
  366. static ssize_t __pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count,
  367. const void *buf, bool check_size)
  368. {
  369. ssize_t ret;
  370. if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
  371. dev = pci_get_func0_dev(dev);
  372. if (!dev)
  373. return -ENODEV;
  374. ret = pci_vpd_write(dev, pos, count, buf, check_size);
  375. pci_dev_put(dev);
  376. return ret;
  377. }
  378. return pci_vpd_write(dev, pos, count, buf, check_size);
  379. }
  380. /**
  381. * pci_write_vpd - Write entry to Vital Product Data
  382. * @dev: PCI device struct
  383. * @pos: offset in VPD space
  384. * @count: number of bytes to write
  385. * @buf: buffer containing write data
  386. */
  387. ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
  388. {
  389. return __pci_write_vpd(dev, pos, count, buf, true);
  390. }
  391. EXPORT_SYMBOL(pci_write_vpd);
  392. /* Same, but allow to access any address */
  393. ssize_t pci_write_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
  394. {
  395. return __pci_write_vpd(dev, pos, count, buf, false);
  396. }
  397. EXPORT_SYMBOL(pci_write_vpd_any);
  398. int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len,
  399. const char *kw, unsigned int *size)
  400. {
  401. int ro_start, infokw_start;
  402. unsigned int ro_len, infokw_size;
  403. ro_start = pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_RO_DATA, &ro_len);
  404. if (ro_start < 0)
  405. return ro_start;
  406. infokw_start = pci_vpd_find_info_keyword(buf, ro_start, ro_len, kw);
  407. if (infokw_start < 0)
  408. return infokw_start;
  409. infokw_size = pci_vpd_info_field_size(buf + infokw_start);
  410. infokw_start += PCI_VPD_INFO_FLD_HDR_SIZE;
  411. if (infokw_start + infokw_size > len)
  412. return -EINVAL;
  413. if (size)
  414. *size = infokw_size;
  415. return infokw_start;
  416. }
  417. EXPORT_SYMBOL_GPL(pci_vpd_find_ro_info_keyword);
  418. int pci_vpd_check_csum(const void *buf, unsigned int len)
  419. {
  420. const u8 *vpd = buf;
  421. unsigned int size;
  422. u8 csum = 0;
  423. int rv_start;
  424. rv_start = pci_vpd_find_ro_info_keyword(buf, len, PCI_VPD_RO_KEYWORD_CHKSUM, &size);
  425. if (rv_start == -ENOENT) /* no checksum in VPD */
  426. return 1;
  427. else if (rv_start < 0)
  428. return rv_start;
  429. if (!size)
  430. return -EINVAL;
  431. while (rv_start >= 0)
  432. csum += vpd[rv_start--];
  433. return csum ? -EILSEQ : 0;
  434. }
  435. EXPORT_SYMBOL_GPL(pci_vpd_check_csum);
  436. #ifdef CONFIG_PCI_QUIRKS
  437. /*
  438. * Quirk non-zero PCI functions to route VPD access through function 0 for
  439. * devices that share VPD resources between functions. The functions are
  440. * expected to be identical devices.
  441. */
  442. static void quirk_f0_vpd_link(struct pci_dev *dev)
  443. {
  444. struct pci_dev *f0;
  445. if (!PCI_FUNC(dev->devfn))
  446. return;
  447. f0 = pci_get_func0_dev(dev);
  448. if (!f0)
  449. return;
  450. if (f0->vpd.cap && dev->class == f0->class &&
  451. dev->vendor == f0->vendor && dev->device == f0->device)
  452. dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
  453. pci_dev_put(f0);
  454. }
  455. DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
  456. PCI_CLASS_NETWORK_ETHERNET, 8, quirk_f0_vpd_link);
  457. /*
  458. * If a device follows the VPD format spec, the PCI core will not read or
  459. * write past the VPD End Tag. But some vendors do not follow the VPD
  460. * format spec, so we can't tell how much data is safe to access. Devices
  461. * may behave unpredictably if we access too much. Blacklist these devices
  462. * so we don't touch VPD at all.
  463. */
  464. static void quirk_blacklist_vpd(struct pci_dev *dev)
  465. {
  466. dev->vpd.len = PCI_VPD_SZ_INVALID;
  467. pci_warn(dev, FW_BUG "disabling VPD access (can't determine size of non-standard VPD format)\n");
  468. }
  469. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0060, quirk_blacklist_vpd);
  470. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x007c, quirk_blacklist_vpd);
  471. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0413, quirk_blacklist_vpd);
  472. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0078, quirk_blacklist_vpd);
  473. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0079, quirk_blacklist_vpd);
  474. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0073, quirk_blacklist_vpd);
  475. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x0071, quirk_blacklist_vpd);
  476. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x005b, quirk_blacklist_vpd);
  477. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x002f, quirk_blacklist_vpd);
  478. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x005d, quirk_blacklist_vpd);
  479. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LSI_LOGIC, 0x005f, quirk_blacklist_vpd);
  480. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID, quirk_blacklist_vpd);
  481. /*
  482. * The Amazon Annapurna Labs 0x0031 device id is reused for other non Root Port
  483. * device types, so the quirk is registered for the PCI_CLASS_BRIDGE_PCI class.
  484. */
  485. DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031,
  486. PCI_CLASS_BRIDGE_PCI, 8, quirk_blacklist_vpd);
  487. static void quirk_chelsio_extend_vpd(struct pci_dev *dev)
  488. {
  489. int chip = (dev->device & 0xf000) >> 12;
  490. int func = (dev->device & 0x0f00) >> 8;
  491. int prod = (dev->device & 0x00ff) >> 0;
  492. /*
  493. * If this is a T3-based adapter, there's a 1KB VPD area at offset
  494. * 0xc00 which contains the preferred VPD values. If this is a T4 or
  495. * later based adapter, the special VPD is at offset 0x400 for the
  496. * Physical Functions (the SR-IOV Virtual Functions have no VPD
  497. * Capabilities). The PCI VPD Access core routines will normally
  498. * compute the size of the VPD by parsing the VPD Data Structure at
  499. * offset 0x000. This will result in silent failures when attempting
  500. * to accesses these other VPD areas which are beyond those computed
  501. * limits.
  502. */
  503. if (chip == 0x0 && prod >= 0x20)
  504. dev->vpd.len = 8192;
  505. else if (chip >= 0x4 && func < 0x8)
  506. dev->vpd.len = 2048;
  507. }
  508. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID,
  509. quirk_chelsio_extend_vpd);
  510. #endif