hwmon: (jc42) Strengthen detect function
Guenter Roeck
maintainerPATCH 1/1 hwmon: (jc42) Strengthen detect function
Configuration register bit 5 must read 0 for all JC42.4 compliant chips. Several capability register bits must be set for all TSE2004 compliant chips. Use that information to strengthen the detect function.
--- drivers/hwmon/jc42.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/jc42.c +5 -1
@@ -413,7 +413,11 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)if (cap <0 || config <0 || manid <0 || devid <0 )return -ENODEV ; -if ((cap &0xff00 ) || (config &0xf800 )) +if ((cap &0xff00 ) || (config &0xf820 )) +return -ENODEV ; + +if ((devid &TSE2004_DEVID_MASK ) ==TSE2004_DEVID && + (cap &0x00e7 ) !=0x00e7 )return -ENODEV ;for (i =0 ; i <ARRAY_SIZE (jc42_chips); i++) {
Signature · 1 line
2.39.2
Hi Guenter,
Quoted 16 lines · Guenter Roeck
Configuration register bit 5 must read 0 for all JC42.4 compliant chips. Several capability register bits must be set for all TSE2004 compliant chips. Use that information to strengthen the detect function.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/jc42.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/hwmon/jc42.c +0
-0@@ -413,7 +413,11 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)if (cap <0 || config <0 || manid <0 || devid <0 )return -ENODEV ;
drivers/hwmon/jc42.c static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info) · line 423
Quoted 10 lines
drivers/hwmon/jc42.c +5
-1-if ((cap &0xff00 ) || (config &0xf800 )) +if ((cap &0xff00 ) || (config &0xf820 )) +return -ENODEV ; + +if ((devid &TSE2004_DEVID_MASK ) ==TSE2004_DEVID && + (cap &0x00e7 ) !=0x00e7 )return -ENODEV ;for (i =0 ; i <ARRAY_SIZE (jc42_chips); i++) {
I have a user reporting that this change is causing the jc42 driver to no longer bind to his memory module temperature sensor devices after updating to kernel v6.11. I asked for a register dump:
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f
00: 7f00 0000 0000 0000 0000 6ac2 091b 3022
After swapping the bytes, I see that this is a TSE2004-compliant device (devid = 0x2230) and the capabilities register reads 0x007f. This doesn't pass the 0x00e7 mask test you added, as bit 7 isn't set in his case.
The JEDEC standard indeed says that bit 7 should be set, but apparently this isn't always the case in the real world.
Also note that I looked at the Renesas TSE2004GB2B0 datasheet and it shows bit 2 (RANGE) as not always set. The ST STTS2004 datasheet shows bits 0 (EVENT) and 2 (RANGE) as possibly reading 0. So I wonder how much we can rely on these capability bits being set in the detect function. Unfortunately I don't have any TS2004-compliant device at hand to verify, nor do I own register dumps of such devices. Would it be OK with you if we relax the check to at least ignore bit 7, and possibly also bits 0 and 2?
Thanks,
Signature · 2 lines
Jean Delvare SUSE L3 Support
Guenter Roeck
maintainerQuoted 45 lines · Jean Delvare
Hi Guenter,
Quoted 16 lines · Guenter Roeck
Configuration register bit 5 must read 0 for all JC42.4 compliant chips. Several capability register bits must be set for all TSE2004 compliant chips. Use that information to strengthen the detect function.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/jc42.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/hwmon/jc42.c +0
-0@@ -413,7 +413,11 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)if (cap <0 || config <0 || manid <0 || devid <0 )return -ENODEV ;drivers/hwmon/jc42.c static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info) · line 423
Quoted 10 lines
drivers/hwmon/jc42.c +5
-1-if ((cap &0xff00 ) || (config &0xf800 )) +if ((cap &0xff00 ) || (config &0xf820 )) +return -ENODEV ; + +if ((devid &TSE2004_DEVID_MASK ) ==TSE2004_DEVID && + (cap &0x00e7 ) !=0x00e7 )return -ENODEV ;for (i =0 ; i <ARRAY_SIZE (jc42_chips); i++) {I have a user reporting that this change is causing the jc42 driver to no longer bind to his memory module temperature sensor devices after updating to kernel v6.11. I asked for a register dump:
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f00: 7f00 0000 0000 0000 0000 6ac2 091b 3022
After swapping the bytes, I see that this is a TSE2004-compliant device (devid =
0x2230) and the capabilities register reads0x007f. This doesn't pass the0x00e7mask test you added, as bit 7 isn't set in his case.The JEDEC standard indeed says that bit 7 should be set, but apparently this isn't always the case in the real world.
Quoted 9 lines
Also note that I looked at the Renesas TSE2004GB2B0 datasheet and it shows bit 2 (RANGE) as not always set. The ST STTS2004 datasheet shows bits 0 (EVENT) and 2 (RANGE) as possibly reading 0. So I wonder how much we can rely on these capability bits being set in the detect function. Unfortunately I don't have any TS2004-compliant device at hand to verify, nor do I own register dumps of such devices. Would it be OK with you if we relax the check to at least ignore bit 7, and possibly also bits 0 and 2?
Sigh. I guess it would have been a miracle if vendors followed the standard. Let's ignore all three bits, with explanation. Care to send a patch, or do you want me to do it ?
Thanks,
Guenter
Quoted 25 lines · Guenter Roeck
Quoted 15 lines · Jean Delvare
I have a user reporting that this change is causing the jc42 driver to no longer bind to his memory module temperature sensor devices after updating to kernel v6.11. I asked for a register dump:
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f00: 7f00 0000 0000 0000 0000 6ac2 091b 3022
After swapping the bytes, I see that this is a TSE2004-compliant device (devid =
0x2230) and the capabilities register reads0x007f. This doesn't pass the0x00e7mask test you added, as bit 7 isn't set in his case.The JEDEC standard indeed says that bit 7 should be set, but apparently this isn't always the case in the real world.
Quoted 8 lines
Also note that I looked at the Renesas TSE2004GB2B0 datasheet and it shows bit 2 (RANGE) as not always set. The ST STTS2004 datasheet shows bits 0 (EVENT) and 2 (RANGE) as possibly reading 0. So I wonder how much we can rely on these capability bits being set in the detect function. Unfortunately I don't have any TS2004-compliant device at hand to verify, nor do I own register dumps of such devices. Would it be OK with you if we relax the check to at least ignore bit 7, and possibly also bits 0 and 2?
Quoted 3 lines
Sigh. I guess it would have been a miracle if vendors followed the standard. Let's ignore all three bits, with explanation. Care to send a patch, or do you want me to do it ?
Working on it, I'll submit it later today.
Thanks,
Signature · 2 lines
Jean Delvare SUSE L3 Support