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

thunderbolt: Retry DROM reads for more failure scenarios

Currently DROM reads are only retried in the case that parsing failed.
However if the size or CRC fails, then there should also be a retry.

This helps with reading the DROM on TBT3 devices connected to AMD
Yellow Carp which will sometimes fail on the first attempt.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

authored by

Mario Limonciello and committed by
Mika Westerberg
e87491a9 7f7b571b

+10 -7
+10 -7
drivers/thunderbolt/eeprom.c
··· 553 553 crc = tb_crc8((u8 *) &header->uid, 8); 554 554 if (crc != header->uid_crc8) { 555 555 tb_sw_warn(sw, 556 - "DROM UID CRC8 mismatch (expected: %#x, got: %#x), aborting\n", 556 + "DROM UID CRC8 mismatch (expected: %#x, got: %#x)\n", 557 557 header->uid_crc8, crc); 558 - return -EINVAL; 558 + return -EILSEQ; 559 559 } 560 560 if (!sw->uid) 561 561 sw->uid = header->uid; ··· 654 654 sw->drom = kzalloc(size, GFP_KERNEL); 655 655 if (!sw->drom) 656 656 return -ENOMEM; 657 + read: 657 658 res = tb_drom_read_n(sw, 0, sw->drom, size); 658 659 if (res) 659 660 goto err; ··· 663 662 header = (void *) sw->drom; 664 663 665 664 if (header->data_len + TB_DROM_DATA_START != size) { 666 - tb_sw_warn(sw, "drom size mismatch, aborting\n"); 665 + tb_sw_warn(sw, "drom size mismatch\n"); 666 + if (retries--) { 667 + msleep(100); 668 + goto read; 669 + } 667 670 goto err; 668 671 } 669 672 ··· 688 683 689 684 /* If the DROM parsing fails, wait a moment and retry once */ 690 685 if (res == -EILSEQ && retries--) { 691 - tb_sw_warn(sw, "parsing DROM failed, retrying\n"); 686 + tb_sw_warn(sw, "parsing DROM failed\n"); 692 687 msleep(100); 693 - res = tb_drom_read_n(sw, 0, sw->drom, size); 694 - if (!res) 695 - goto parse; 688 + goto read; 696 689 } 697 690 698 691 if (!res)