Skip to contentSkip to conversation

Bug #1807: sensors with kernel 2.4, but not with kernel 2.6

DISCUSSION Benjamin Judas 4 participants 16 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

I was told to continue on this list, so...here's the additional info requested:

Quoted 8 lines

Second, you do not mention the version of lm_sensors you are using, just like it doesn?t matter for a 2.6 kernel. It does. The lm_sensors package may not providekernel drivers for the 2.6 series, but it still provides the user-space library and tools. Since the kernel-space/user-space interface changed several times between the early 2.6 kernels, you should ensure that you use a recent version. 2.8.6 or later is required for proper operations with a 2.6.8 kernel. Newer is even better.

I have lm-sensors-2.8.7 installed. (And before you ask, yes - I also compiled it without any CFLAGS set to be sure ;) )

Quoted 5 lines

You should take a look at the logs
(/var/log/syslog, /var/log/messages, dmesg) when you load the i2c kernel modules. If anything goes wrong it
should tell you. If you compiled your kernel with I2C debugging enabled, you may also gather useful additional information.

Syslog doesn't show any error-messages when asb100.ko and i2c-viapro are loaded. However when I enable really verbose logging, I get a bunch of messages that look like this:

Oct 31 22:01:02 antares kernel: i2c_adapter i2c-0: master_xfer: with 1
msgs.
Oct 31 22:01:02 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x703, arg: 4c.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x720, arg: 8377858.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: master_xfer: with 1
msgs.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x703, arg: 4d.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x720, arg: 8377858.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: master_xfer: with 1
msgs.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x703, arg: 4e.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x720, arg: 8377858.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: master_xfer: with 1
msgs.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x703, arg: 4f.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x720, arg: 8377858.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: master_xfer: with 1
msgs.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:
0x703, arg: 50.
Oct 31 22:01:03 antares kernel: i2c_adapter i2c-0: i2c-0 ioctl, cmd:

0x720, arg: 8377858.

Quoted 5 lines

If both drivers load properly, you should take a look
at /sys/bus/i2c/devices/.
In this directory, you should find a subdirectory for the asb100. If you don?t, then either kernel driver is faulty. If you do, then the kernel is fine and the user-space if faulty.

The modules themselves load properly, the directory in /sys/bus/i2c/drivers gets created:

antares /home/benni # cd /sys/bus/i2c/drivers/
antares /sys/bus/i2c/drivers # ls -al
insgesamt 0

drwxr-xr-x  11 root root 0  3. Nov 16:54 .
drwxr-xr-x   4 root root 0  3. Nov 2004  ..
drwxr-xr-x   2 root root 0  3. Nov 16:54 asb100
drwxr-xr-x   2 root root 0  3. Nov 2004  generic i2c audio driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c_adapter
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c msp3400 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c tda7432 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c tda9875 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c tda9887 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c TV tuner driver
drwxr-xr-x   2 root root 0  3. Nov 2004  ir remote kbd driver

Thanks

Regards,
Benjamin

Signature · 18 lines
Benjamin Judas

---------------------------------------------------------------------                                  
Gentoo-developer                        http://dev.gentoo.org/~beejay
Giessen, Germany                                http://www.gentoo.org

GPG-Key         : 0xC31DEDD8
Key-Fingerprint : 4E65 AAFE 785B 61D8 E4D9  1671 E017 87B7 C31D EDD8
Jabber          : [email protected]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20041103/00bcdb5d/attachment.bin
#1 lore raw
Quoted 5 lines

The modules themselves load properly, the directory in /sys/bus/i2c/drivers gets created:

antares /home/benni # cd /sys/bus/i2c/drivers/
antares /sys/bus/i2c/drivers # ls -al
insgesamt 0

Quoted 11 lines
drwxr-xr-x  11 root root 0  3. Nov 16:54 .
drwxr-xr-x   4 root root 0  3. Nov 2004  ..
drwxr-xr-x   2 root root 0  3. Nov 16:54 asb100
drwxr-xr-x   2 root root 0  3. Nov 2004  generic i2c audio driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c_adapter
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c msp3400 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c tda7432 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c tda9875 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c tda9887 driver
drwxr-xr-x   2 root root 0  3. Nov 2004  i2c TV tuner driver
drwxr-xr-x   2 root root 0  3. Nov 2004  ir remote kbd driver

Sorry, what I forgot to mention is that asb100/ is *empty*.

Signature · 18 lines
Benjamin Judas

---------------------------------------------------------------------                                  
Gentoo-developer                        http://dev.gentoo.org/~beejay
Giessen, Germany                                http://www.gentoo.org

GPG-Key         : 0xC31DEDD8
Key-Fingerprint : 4E65 AAFE 785B 61D8 E4D9  1671 E017 87B7 C31D EDD8
Jabber          : [email protected]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20041103/f73f8a4e/attachment.bin
#2 lore raw
In reply to Benjamin Judas

Bonsoir Jean,

Quoted 4 lines

What I am mostly interested is the devices directory, not the drivers directory. Do you see any subdirectory named *-002d there, those "name" file reads asb100? What else do you see in this subdirectory? There should be a whole bunch of in*, temp* and fan* files.

I don't have that directory in /sys/bus/i2c/devices. What I have is:

antares /sys/bus/i2c/devices # ls -al
insgesamt 0

drwxr-xr-x  2 root root 0  3. Nov 17:31 .
drwxr-xr-x  4 root root 0  3. Nov 17:31 ..
lrwxrwxrwx  1 root root 0  3. Nov 17:31 0-0018

-> ../../../devices/pci0000:00/0000:00:0b.0/i2c-0/0-0018 lrwxrwxrwx 1 root root 0 3. Nov 17:31 0-0040 -> ../../../devices/pci0000:00/0000:00:0b.0/i2c-0/0-0040 lrwxrwxrwx 1 root root 0 3. Nov 17:31 0-0042 -> ../../../devices/pci0000:00/0000:00:0b.0/i2c-0/0-0042 lrwxrwxrwx 1 root root 0 3. Nov 17:31 0-0061 -> ../../../devices/pci0000:00/0000:00:0b.0/i2c-0/0-0061

Regards,
Benjamin

Signature · 18 lines
Benjamin Judas

---------------------------------------------------------------------                                  
Gentoo-developer                        http://dev.gentoo.org/~beejay
Giessen, Germany                                http://www.gentoo.org

GPG-Key         : 0xC31DEDD8
Key-Fingerprint : 4E65 AAFE 785B 61D8 E4D9  1671 E017 87B7 C31D EDD8
Jabber          : [email protected]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20041103/d44738d1/attachment.bin
#3 lore raw
In reply to Benjamin Judas

Following an IRC-request by Jean here:

this is a log-excerpt that shows the life of the driver from loading until bailing out:

Oct 31 22:03:05 antares kernel: i2c-core: driver asb100 registered.
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: found normal
i2c_range entry for adapter 1, addr 0028
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (pre):
CNT, CMDO, ADDP, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: SMBus busy (0x40).
Resetting...
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Successfull!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Error: no response!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (post):
CNT, CMDO, ADDP, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: found normal
i2c_range entry for adapter 1, addr 0029
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (pre):
CNT, CMDO, ADDR, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: SMBus busy (0x40).
Resetting...
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Successfull!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Error: no response!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (post):
CNT, CMDO, ADDR, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: found normal
i2c_range entry for adapter 1, addr 002a
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (pre):
CNT, CMDO, ADDT, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: SMBus busy (0x40).
Resetting...
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Successfull!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Error: no response!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (post):
CNT, CMDO, ADDT, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: found normal
i2c_range entry for adapter 1, addr 002b
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (pre):
CNT, CMDO, ADDV, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: SMBus busy (0x40).
Resetting...
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Successfull!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (post):
CNT, CMDO, ADDV, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (pre):
CNT, CMDN, ADDW, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: SMBus busy (0x40).
Resetting...
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Successfull!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (post):
CNT, CMDN, ADDW, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (pre):
CNT, CMDO, ADDW, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: SMBus busy (0x40).
Resetting...
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Successfull!
Oct 31 22:03:05 antares kernel: i2c_adapter i2c-1: Transaction (post):
CNT, CMDO, ADDW, DAT0, DAT1ÿ
Oct 31 22:03:05 antares kernel: asb100.o: detect failed, bad chip id

0x00!

Signature · 18 lines
Benjamin Judas

---------------------------------------------------------------------                                  
Gentoo-developer                        http://dev.gentoo.org/~beejay
Giessen, Germany                                http://www.gentoo.org

GPG-Key         : 0xC31DEDD8
Key-Fingerprint : 4E65 AAFE 785B 61D8 E4D9  1671 E017 87B7 C31D EDD8
Jabber          : [email protected]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20041103/9e77f68c/attachment.bin
#4 lore raw
In reply to Benjamin Judas

Another info requested by Jean on IRC:

antares /home/benni # i2cdump 1 0x2f
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and
worse!
I will probe file /dev/i2c-1, address 0x2f, mode byte You have five seconds to reconsider and press CTRL-C!

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 00 00 00 00 00 00 00 00 00 8a 00 00 01 00 00 ff    .........?..?...
10: 00 00 7f 00 00 10 00 00 00 00 00 00 00 00 00 80    ..?..?.........?
20: 00 00 00 b7 00 00 00 7f ff ff ff ff 00 ff 00 ed    ...?...?.......?
30: b0 40 84 2a 84 41 4a 00 9d 00 08 00 01 18 ff ff    ?@?*?AJ.?.?.??..
40: 01 fc 6f 00 00 00 00 5f 2f 11 01 44 01 95 80 5c    ??o...._/??D???\
50: ff ff ff ff ff ff 00 80 71 70 ff 00 00 00 05 ff    .......?qp....?.
60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
80: 01 ff 01 ff 00 00 00 00 01 01 01 01 3c 3c 0a 0a    ?.?.....????<<??
90: 00 00 00 01 ff 00 00 00 01 01 3c 18 00 00 01 01    ...?....??<?..??
a0: ff ff ff 00 00 00 00 00 17 fc 6f 18 00 ff ff ff    ........??o?....
b0: b8 00 00 ff 10 90 30 01 20 41 ff ff 34 00 ff ff    ?...??0? A..4...
c0: 7f 00 00 4b 00 55 00 ff 7f 00 00 4b 00 50 00 ff    ?..K.U..?..K.P..
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
f0: ff ff 00 ff 00 01 00 ff ff 02 ff 00 00 11 ff 1d    .....?...?...?.?

antares /home/benni # i2cdump 1 0x2d
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and
worse!
I will probe file /dev/i2c-1, address 0x2d, mode byte You have five seconds to reconsider and press CTRL-C!

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: b5 b8 ce cd cc c9 00 cd a7 f8 a5 ac 8c 68 54 f8    ??????.??????hT?
10: a5 f8 a5 ff 00 00 00 0c 50 4b 2d 50 4b 00 00 00    ???....?PK-PK...
20: 72 71 cd b6 ca ca ca 1e 43 ff ff 7f 54 7f 54 e3    rq??????C..?T?T?
30: b9 cd a7 ed 9d 00 00 00 00 50 4b c6 00 08 00 00    ?????....PK?.?..
40: 01 80 00 00 00 0c 00 44 00 42 01 40 00 50 80 06    [email protected]??
50: ff ff 00 ff ff ff ff ff 31 8f 02 d5 ff 48 e2 1f    ........1???.H??
60: 71 71 cc b5 c9 c9 ca 1e 43 ff ff 7f 54 7f 54 e3    qq??????C..?T?T?
70: b9 cd a7 ed 9d 00 00 00 00 50 4b c6 00 08 00 00    ?????....PK?.?..
80: b6 b9 cd cd cb c9 00 cd a7 f8 a5 ac 8c 68 54 f8    ??????.??????hT?
90: a5 f8 a5 ff 00 00 00 0c 50 4b 2e 50 4b 00 00 00    ???....?PK.PK...
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

antares /home/benni # i2cdump 1 0x2b
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and
worse!
I will probe file /dev/i2c-1, address 0x2b, mode byte You have five seconds to reconsider and press CTRL-C!

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: fe 71 71 00 00 00 00 00 08 40 84 ff ff ff ff ff    ?qq.....?@?.....
10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
90: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
f0: 00 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10    .???????????????
Signature · 18 lines
Benjamin Judas

---------------------------------------------------------------------                                  
Gentoo-developer                        http://dev.gentoo.org/~beejay
Giessen, Germany                                http://www.gentoo.org

GPG-Key         : 0xC31DEDD8
Key-Fingerprint : 4E65 AAFE 785B 61D8 E4D9  1671 E017 87B7 C31D EDD8
Jabber          : [email protected]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20041103/c5317588/attachment.bin
#5 lore raw
In reply to Benjamin Judas

Hello Benjamin et. al.

* Benjamin Judas <[email protected]> [2004-11-03 20:13:31 +0100]:
(snip)

Quoted 16 lines

antares /home/benni # i2cdump 1 0x2b
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and
worse!
I will probe file /dev/i2c-1, address 0x2b, mode byte You have five seconds to reconsider and press CTRL-C!

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: fe 71 71 00 00 00 00 00 08 40 84 ff ff ff ff ff    ?qq.....?@?.....
10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
Quoted 8 lines
80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
90: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
f0: 00 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10    .???????????????

Benjamin:

This mystery device on 0x2b is part of the problem. As a workaround, you could load the asb100 module with the option "ignore=1,0x2b".

I2C/sensors people:

The real problem is in i2c_detect():

(lines 153-159 of i2c-sensor-detect.c)

Quoted 7 lines
               /* OK, so we really should examine this address. First check
                  whether there is some client here at all! */
               if (is_isa ||
                   (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
                       if ((err = found_proc(adapter, addr, -1)))
                               return err;
       }

I.e. after the chip driver correctly decides that the device responding to 0x2b is NOT an asb100, it never gets the chance to examine 0x2d.

I'm not sure that replacing "return err;" with "continue;" is good enough. Also note that if it loops through the whole range but finds nothing, it returns 0 instead of e.g. -ENODEV. The whole function seems to want a re-write... would it break otherwise working configs if I cleaned this thing up?

0 => detected one or more clients
-ENODEV => nothing responded to SMBUS_QUICK (or)
-E[...] => return from most recent client detect attempt

Regards,

Signature · 2 lines
Mark M. Hoffman
[email protected]
#6 lore raw
In reply to Benjamin Judas

Hi Jean:

Quoted 11 lines · Jean Delvare
Quoted 2 lines

I.e. after the chip driver correctly decides that the device responding to 0x2b is NOT an asb100, it never gets the chance to examine 0x2d.

This would explain the behavior observed on Benjamin's board, correct.

Quoted 5 lines

I'm not sure that replacing "return err;" with "continue;" is good enough. Also note that if it loops through the whole range but finds nothing, it returns 0 instead of e.g. -ENODEV. The whole function seems to want a re-write... would it break otherwise working configs if I cleaned this thing up?

Quoted 5 lines

I don't think your analysis is correct. My feeling is that *_detect functions found in the client drivers should NOT return non-zero values on "misdetections". A misdetection is not an error per se, and obviously the i2c_detect function was written with that in mind. So I believe that the asb100 driver, not i2c_detect, would need to be fixed.

Well, you're right.

Quoted 4 lines

There are several other drivers that would need a similar fix, such as w83781d and possibly it87. Other drivers I looked at seem to be OK (lm75, lm83, lm90, w83627hf). I guess that a full review of all client drivers would be welcome.

Looks like I've misunderstood this for quite some time. Other drivers are broken like this thanks to me "fixing" them during 2.6.0-pre. It just seemed obvious that a misdetection should return -ENODEV. It's no excuse though, as you pointed out - the docs are clear enough.

I'll prepare a patch when I get the chance.

Quoted 15 lines

My investigations led me to ask several related questions:

1* What is the different between "normal" i2c addresses and "probe" i2c addresses? It seems that both arrays are treated the same way, and no client driver is using "probe" addresses (at a quick glance at least.) Can't we just get rid of it?

2* What is the difference between i2c_probe in i2c-core and i2c_detect in i2c-sensor (i2c-proc in 2.4)? Both functions seem to be very similar, I couldn't find a difference (but I admittedly did not compare line by line yet). If there are, it's probably not worth the code duplication. As a matter of fact, I don't see how exactly i2c_detect is supposed to be sensor-related. Can't we get rid of i2c_detect and use i2c_probe everywhere?

Quoted 7 lines

It would be great if we could clean this mess now because I will do significant changes to that part of the code soon (to get rid of the thinkpad breakage issue, just like I did in the userspace tools already).

I admit that I find it a little strange that two things so obviously redundant could have been in place for so long and nobody ever objected. Am I missing something?

Good questions...

Quoted 5 lines

3* Did we ever see an ASB100 chip at any other address than 0x2d? We don't have any documentation for that chip so it would probably be more reasonable to limit the range to the only known address so far. As a side effect, I suspect that it could help solve that ticket:
http://bugzilla.kernel.org/show_bug.cgi?id(99

Fair enough; I'll do a patch for this too.

Regards,

Signature · 2 lines
Mark M. Hoffman
[email protected]
#7 lore raw
In reply to Benjamin Judas
Quoted 5 lines · Jean Delvare

1* What is the different between "normal" i2c addresses and "probe" i2c addresses? It seems that both arrays are treated the same way, and no client driver is using "probe" addresses (at a quick glance at least.) Can't we just get rid of it?

Yes we should. I've started to look at how to reduce the number of things in the per-driver structure and this is one that will go away soon (along with the ranges, but that's for another email...)

Quoted 7 lines

2* What is the difference between i2c_probe in i2c-core and i2c_detect in i2c-sensor (i2c-proc in 2.4)? Both functions seem to be very similar, I couldn't find a difference (but I admittedly did not compare line by line yet). If there are, it's probably not worth the code duplication. As a matter of fact, I don't see how exactly i2c_detect is supposed to be sensor-related. Can't we get rid of i2c_detect and use i2c_probe everywhere?

Yes we can, if we merge the two structures properly. Right now they aren't alike in a very tiny way. Any patches to fix all of this up would be greatly appreciated so that I can mark another thing off of my todo list :)

Quoted 7 lines

It would be great if we could clean this mess now because I will do significant changes to that part of the code soon (to get rid of the thinkpad breakage issue, just like I did in the userspace tools already).

I admit that I find it a little strange that two things so obviously redundant could have been in place for so long and nobody ever objected. Am I missing something?

I've always noticed them, but in the 2.6 push to get stable, I ignored them as it will take a bit of work to fix them up.

thanks,

greg k-h

#8 lore raw
In reply to Benjamin Judas

Hi:

Quoted 5 lines · Jean Delvare
Quoted 4 lines

There are several other drivers that would need a similar fix, such as w83781d and possibly it87. Other drivers I looked at seem to be OK (lm75, lm83, lm90, w83627hf). I guess that a full review of all client drivers would be welcome.

Quoted 4 lines · Mark M. Hoffman

Looks like I've misunderstood this for quite some time. Other drivers are broken like this thanks to me "fixing" them during 2.6.0-pre. It just seemed obvious that a misdetection should return -ENODEV. It's no excuse though, as you pointed out - the docs are clear enough.

OK, I reviewed all of the sensor chip drivers to see what is returned from each of their respective i2c_detect() callbacks.

1. Almost all of the drivers return -ENOMEM in response to a kmalloc failure. I think this is acceptable. Exception: isp1301_omap.c

2. All of the drivers return any error from i2c_attach_client(). This is harder to understand... why should failure to attach *this* instance also prevent me from *detecting* others?

Not counting the two cases above, the drivers that return non-zero in response to (what looks like) a failed detection include: asb100.c, it87.c, lm78.c, smsc47m1.c, via686a.c, w83627hf.c, and w83781d.c. I'll work up a patch for these.

Whatever we agree are legitimate reasons to cancel detection, I would like to add specific documentation for them. I think a case can be made that there's *no* legitimate reason for a driver to halt detection that way... but I'm sure I'll hear otherwise. As an interface, this interpretation of a return value (I failed so badly that you're not allowed to call me again) isn't my favorite.

Also note: all of the drivers register their sysfs files during their <driver>_detect() function. That suddenly seems weird to me... logically those calls belong to <driver>_attach_client(), no?

Regards,

Signature · 2 lines
Mark M. Hoffman
[email protected]
#9 lore raw
In reply to Benjamin Judas

Hi again...

Quoted 6 lines · Mark M. Hoffman

Whatever we agree are legitimate reasons to cancel detection, I would like to add specific documentation for them. I think a case can be made that there's *no* legitimate reason for a driver to halt detection that way... but I'm sure I'll hear otherwise. As an interface, this interpretation of a return value (I failed so badly that you're not allowed to call me again) isn't my favorite.

After working on a patch for a bit... now I hate it. Why does i2c_detect() need to work that way?

Back to where I started: anyone mind if I rewrite i2c_detect()? A grep said that drivers/i2c/chips/*.c are the only callers.

Regards,

Signature · 2 lines
Mark M. Hoffman
[email protected]
#10 lore raw
In reply to Benjamin Judas
Quoted 10 lines · Mark M. Hoffman

Hi again...

Quoted 6 lines · Mark M. Hoffman

Whatever we agree are legitimate reasons to cancel detection, I would like to add specific documentation for them. I think a case can be made that there's *no* legitimate reason for a driver to halt detection that way... but I'm sure I'll hear otherwise. As an interface, this interpretation of a return value (I failed so badly that you're not allowed to call me again) isn't my favorite.

Quoted 5 lines

After working on a patch for a bit... now I hate it. Why does i2c_detect() need to work that way?

Back to where I started: anyone mind if I rewrite i2c_detect()? A grep said that drivers/i2c/chips/*.c are the only callers.

Heh, I tried to rewrite it a while ago, and just gave up, it's a mess. Please redo it.

Oh, I'm getting rid of all of the "range" variables in the structures right now, so that will affect i2c_detect. I'll have patches in a few hours.

thanks,

greg k-h

#11 lore raw
In reply to Benjamin Judas

Hi Mark,

Quoted 2 lines

This mystery device on 0x2b is part of the problem. As a workaround, you could load the asb100 module with the option "ignore=1,0x2b".

True, this is how we got it to work (over IRC) yesterday evening (European time). I did not investigate why though, but it seems you did.

As a side note, we still don't know where the mysterious chips at 0x2b and 0x2f come from. They are not supposed to be there on A7V8X boards as far as I can remember. The chip at the latter address seems to be a W83791D chip, unfortunately not supported under Linux 2.6 (why, BTW?)

Quoted 12 lines

The real problem is in i2c_detect():

(lines 153-159 of i2c-sensor-detect.c)

Quoted 7 lines
        /* OK, so we really should examine this address. First check
           whether there is some client here at all! */
        if (is_isa ||
            (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK,
                             NULL) >= 0))
                if ((err = found_proc(adapter, addr, -1)))
                        return err;
Quoted 2 lines

I.e. after the chip driver correctly decides that the device responding to 0x2b is NOT an asb100, it never gets the chance to examine 0x2d.

This would explain the behavior observed on Benjamin's board, correct.

Quoted 5 lines

I'm not sure that replacing "return err;" with "continue;" is good enough. Also note that if it loops through the whole range but finds nothing, it returns 0 instead of e.g. -ENODEV. The whole function seems to want a re-write... would it break otherwise working configs if I cleaned this thing up?

I don't think your analysis is correct. My feeling is that *_detect functions found in the client drivers should NOT return non-zero values on "misdetections". A misdetection is not an error per se, and obviously the i2c_detect function was written with that in mind. So I believe that the asb100 driver, not i2c_detect, would need to be fixed.

There are several other drivers that would need a similar fix, such as w83781d and possibly it87. Other drivers I looked at seem to be OK (lm75, lm83, lm90, w83627hf). I guess that a full review of all client drivers would be welcome.

My investigations led me to ask several related questions:

1* What is the different between "normal" i2c addresses and "probe" i2c addresses? It seems that both arrays are treated the same way, and no client driver is using "probe" addresses (at a quick glance at least.) Can't we just get rid of it?

2* What is the difference between i2c_probe in i2c-core and i2c_detect in i2c-sensor (i2c-proc in 2.4)? Both functions seem to be very similar, I couldn't find a difference (but I admittedly did not compare line by line yet). If there are, it's probably not worth the code duplication. As a matter of fact, I don't see how exactly i2c_detect is supposed to be sensor-related. Can't we get rid of i2c_detect and use i2c_probe everywhere?

It would be great if we could clean this mess now because I will do significant changes to that part of the code soon (to get rid of the thinkpad breakage issue, just like I did in the userspace tools already).

I admit that I find it a little strange that two things so obviously redundant could have been in place for so long and nobody ever objected. Am I missing something?

3* Did we ever see an ASB100 chip at any other address than 0x2d? We don't have any documentation for that chip so it would probably be more reasonable to limit the range to the only known address so far. As a side effect, I suspect that it could help solve that ticket:
http://bugzilla.kernel.org/show_bug.cgi?id(99

Thanks,
Jean

#12 lore raw
In reply to Benjamin Judas

Hi Mark,

Quoted 5 lines

OK, I reviewed all of the sensor chip drivers to see what is returned from each of their respective i2c_detect() callbacks.

1. Almost all of the drivers return -ENOMEM in response to a kmalloc failure. I think this is acceptable. Exception: isp1301_omap.c

True. For consistency's sake, isp1301_omap.c could be "fixed".

Quoted 3 lines

2. All of the drivers return any error from i2c_attach_client(). This is harder to understand... why should failure to attach *this* instance also prevent me from *detecting* others?

Agreed, this doesn't make much sense to me either. The only reason why i2c_attach_client can fail in 2.6 is if the address is already in use. Nothing critical and at any rate address-specific, so it shouldn't stop from probing other addresses.

Quoted 4 lines

Not counting the two cases above, the drivers that return non-zero in response to (what looks like) a failed detection include: asb100.c, it87.c, lm78.c, smsc47m1.c, via686a.c, w83627hf.c, and w83781d.c. I'll work up a patch for these.

Thanks. Similar fixes would be welcome for 2.4/CVS as well (where there may be a couple more drivers needing fixing).

Quoted 4 lines

Whatever we agree are legitimate reasons to cancel detection, I would like to add specific documentation for them. I think a case can be made that there's *no* legitimate reason for a driver to halt detection that way... but I'm sure I'll hear otherwise.

Nice foreseeing ;) I actually believe that stopping the probings on memory shortage makes sense, as there is no reason why other memory allocation requests would succeed, and we better don't insist. This is the only case where I would agree with a "global failure" kind of action. That said, I don't really want us to do that, just that the current model lets us do it. If the model were to change (hint hint) and we wouldn't be able to easily preserve this behavior, I wouldn't care.

Quoted 3 lines

As an interface, this interpretation
of a return value (I failed so badly that you're not allowed to call me again) isn't my favorite.

Agreed outside of the kernel. But in the kernel I think we can try to optimize things a little more (not at any price though).

Quoted 3 lines

Also note: all of the drivers register their sysfs files during their <driver>_detect() function. That suddenly seems weird to me... logically those calls belong to <driver>_attach_client(), no?

Probably true. If you go in that direction though, even more things can be moved outside of *_detect functions. Chip configuration doesn't really belong there, and even the call to i2c_attach_client doesn't. Not sure it's worth the change now though, since it doesn't win anything beyond the local driver structure cleanness.

Thanks,
Jean

#13 lore raw
In reply to Benjamin Judas

Hi Benjamin,

Quoted 8 lines
Quoted 5 lines

If both drivers load properly, you should take a look
at /sys/bus/i2c/devices/.
In this directory, you should find a subdirectory for the asb100. If you don't, then either kernel driver is faulty. If you do, then the kernel is fine and the user-space if faulty.

The modules themselves load properly, the directory in /sys/bus/i2c/drivers gets created:

What I am mostly interested is the devices directory, not the drivers directory. Do you see any subdirectory named *-002d there, those "name" file reads asb100? What else do you see in this subdirectory? There should be a whole bunch of in*, temp* and fan* files.

Thanks,
Jean

#14 lore raw
In reply to Benjamin Judas

Quoting myself:

Quoted 5 lines

I don't think your analysis is correct. My feeling is that *_detect functions found in the client drivers should NOT return non-zero values on "misdetections". A misdetection is not an error per se, and obviously the i2c_detect function was written with that in mind. So I believe that the asb100 driver, not i2c_detect, would need to be fixed.

Just found the confirmation in Documentation/i2c/writing-clients:

"The detect client function
--------------------------

The detect client function is called by i2c_probe or i2c_detect. (...)
This function should only return an error (any value != 0) if there is some reason why no more detection should be done anymore. If the detection just fails for this address, return 0."

So we are simply not doing the correct thing in various clients.

Thanks,
Jean

#15 lore raw
In reply to Benjamin Judas

Hi again Mark,

Quoted 5 lines

After working on a patch for a bit... now I hate it. Why does i2c_detect() need to work that way?

Back to where I started: anyone mind if I rewrite i2c_detect()? A grep said that drivers/i2c/chips/*.c are the only callers.

Fine with me as long as it is done in a consistent way, and the documentation is updated accordingly (both writing- and porting-clients).

As a side note, such a change is not suitable for 2.4/CVS, so fixing the drivers you listed in your other post there is still on the to-do list.

As yet another side note, I have noticed that i2c_detect checks all addresses from 0 to 0x7f for business before processing them. This sounds bad in terms of efficiency. The test should be done before actually attempting to detect chips at any given address.

Thanks,
Jean