i2c: allow ddr5 ram page change with active intel spd write protection
PATCH 1/1 i2c: allow ddr5 ram page change with active intel spd write protection
SPD of most Intel DDR5 systems is write protected.
The write protection also includes changing page, via MR11 register, and prevents reading data.
This patch allows page changing with write protection active via a I2C_SMBUS_READ on PROC_CALL. That is a, publicly undocumented, Intel specific way to allow page change.
--- drivers/i2c/busses/i2c-i801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +1 -1
@@ -788,7 +788,7 @@ static int i801_simple_transaction(struct i801_priv *priv, union i2c_smbus_data xact =I801_WORD_DATA ;break ;case I2C_SMBUS_PROC_CALL : -i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); +i801_set_hstadd (priv, addr, read_write);iowrite8 (data->word &0xff ,SMBHSTDAT0 (priv));iowrite8 ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv));iowrite8 (hstcmd,SMBHSTCMD (priv));
base-commit: 0739473694c4878513031006829f1030ec850bc2
Hi Florian,
Quoted 19 lines · Blacktempel (Florian K.)
SPD of most Intel DDR5 systems is write protected.
The write protection also includes changing page, via MR11 register, and prevents reading data.This patch allows page changing with write protection active via a
I2C_SMBUS_READonPROC_CALL. That is a, publicly undocumented, Intel specific way to allow page change.Signed-off-by Blacktempel (Florian K.) <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static int i801_simple_transaction(struct i801_priv *priv, union i2c_smbus_data · line 794
Quoted 8 lines
drivers/i2c/busses/i2c-i801.c +1
-1@@ -788,7 +788,7 @@ static int i801_simple_transaction(struct i801_priv *priv, union i2c_smbus_data xact =I801_WORD_DATA ;break ;case I2C_SMBUS_PROC_CALL : -i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); +i801_set_hstadd (priv, addr, read_write);iowrite8 (data->word &0xff ,SMBHSTDAT0 (priv));iowrite8 ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv));iowrite8 (hstcmd,SMBHSTCMD (priv));
This looks similar to the workaround we applied for AT24-based SPD implementations many years ago:
Because all datasheets since the 82801AA explicitly say that "for process call command, the value written into bit 0 of the Transmit Slave Address Register (SMB I/O register, offset 04h) needs to be 0", I would prefer to have a similar implementation for the SMBus Process
Call: check SMBHSTCFG_SPD_WD and only apply the workaround if that bit is set. This will avoid risking a regression on older chipsets.
I checked the spd5118 driver (which implements DDR5 SPD EEPROM support) and it is NOT using the SMBus Process Call. So the above change alone isn't going to allow accessing DDR5 SPD data on Intel systems where SPD write protection is enabled. And the spd5118 driver is built on top of regmap which is a generic register map access implementation. Convincing it to use the SMBus Process Call transfer type for page selection won't be trivial, if possible at all.
Are you using a modified spd5118 driver? Or are you accessing the SPD EEPROM from user-space using the i2c-dev driver?
I must confess I'm curious how using the SMBus Process Call for the purpose of switching the pages could work safely. This transfer type will write 3 bytes on the bus, while page switching only expects 2. The third written byte could have unexpected side effects, such as writing to the following register (MR12). I'm not sure that's a risk I would be willing to take. Then the process call will attempt to read 2 bytes from the SPD, I'm not sure how the SPD will react, but that should be less of a problem.
If Intel messed up their Write Protect implementation for the DDR5 SPD standard then they should really fix it in future chipsets.
Signature · 2 lines
Jean Delvare SUSE L3 Support