Parcourir la source

[realtek] Ensure EEPROM writes reach chip before starting udelay()

On some systems, it appears to be possible for writes to the EEPROM
registers to be delayed for long enough that the EEPROM's setup and
hold times are violated, resulting in invalid data being read from the
EEPROM.

Fix by inserting a PCI read cycle immediately after writes to
RTL_9346CR, to ensure that the write has completed before starting the
udelay() used to time the SPI bus transitions.

Reported-by: Gelip <mrgelip@gmail.com>
Tested-by: Gelip <mrgelip@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 11 ans
Parent
révision
9b1ec3132f
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3
    0
      src/drivers/net/realtek.c

+ 3
- 0
src/drivers/net/realtek.c Voir le fichier

@@ -74,6 +74,7 @@ static void realtek_spi_open_bit ( struct bit_basher *basher ) {
74 74
 
75 75
 	/* Enable EEPROM access */
76 76
 	writeb ( RTL_9346CR_EEM_EEPROM, rtl->regs + RTL_9346CR );
77
+	readb ( rtl->regs + RTL_9346CR ); /* Ensure write reaches chip */
77 78
 }
78 79
 
79 80
 /**
@@ -87,6 +88,7 @@ static void realtek_spi_close_bit ( struct bit_basher *basher ) {
87 88
 
88 89
 	/* Disable EEPROM access */
89 90
 	writeb ( RTL_9346CR_EEM_NORMAL, rtl->regs + RTL_9346CR );
91
+	readb ( rtl->regs + RTL_9346CR ); /* Ensure write reaches chip */
90 92
 }
91 93
 
92 94
 /**
@@ -129,6 +131,7 @@ static void realtek_spi_write_bit ( struct bit_basher *basher,
129 131
 	reg &= ~mask;
130 132
 	reg |= ( data & mask );
131 133
 	writeb ( reg, rtl->regs + RTL_9346CR );
134
+	readb ( rtl->regs + RTL_9346CR ); /* Ensure write reaches chip */
132 135
 	DBG_ENABLE ( DBGLVL_IO );
133 136
 }
134 137
 

Chargement…
Annuler
Enregistrer