Skip to content

Commit

Permalink
smbus: eeprom: work around #416 by reading in 128 chunks
Browse files Browse the repository at this point in the history
Related: #416
  • Loading branch information
jonasmalacofilho committed Feb 6, 2022
1 parent eba1900 commit b21200c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion liquidctl/driver/smbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,22 @@ def load_eeprom(self, address):
dev = f'{self._number}-{address:04x}'
try:
name = self._i2c_dev.joinpath(dev, 'name').read_text().strip()
eeprom = self._i2c_dev.joinpath(dev, 'eeprom').read_bytes()

# work around a bug in the kernel by reading the ee1004 eeprom
# in small enough chunks
# related: #416 ("DDR4 support broken on Linux 5.16.3")
# related: https://lore.kernel.org/lkml/20220203165024.47767-1-jonas@protocubo.io/
eeprom_path = self._i2c_dev.joinpath(dev, 'eeprom')
eeprom_size = eeprom_path.stat().st_size
_LOGGER.debug('path=%s, size=%s', eeprom_path, eeprom_size)
with eeprom_path.open(mode='rb', buffering=0) as f:
eeprom = bytearray()
while len(eeprom) < eeprom_size:
b = f.read(128)
if not b:
break
eeprom.extend(b)

return LinuxEeprom(name, eeprom)
except FileNotFoundError:
return None
Expand Down

0 comments on commit b21200c

Please sign in to comment.