Skip to contentSkip to conversation

bus scan removal

DISCUSSION Jean Delvare 3 participants 11 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi Ky?sti,

In the process of merging our i2c CVS repository changes into the Linux 2.4 kernel, I saw that, back in January 2003, you removed bus scanning from two drivers (i2c-algo-bit and i2c-algo-pcf). What was your reason for doing so? Is it because it was unused, or because i2cdetect can be used instead, or both, or any other reason I didn't think of?

I took a look at the i2c drivers present in both Linux 2.4 and 2.6, and it turns out that there are other drivers still having a bus scanning parameter (i2c-algo-ite.c and i2c-algo-sibyte.c in 2.4, i2c-algo-ite.c and i2c-ibm_iic.c in 2.6). As I will be submitting a patch to remove bus scanning from "our" drivers (i2c-algo-bit and i2c-algo-pcf), I'm wondering if I should do the same for these extra drivers as well.

BTW, does i2cdetect work on non-i386 architectures?

Any insight on your original motivations appreciated.

The patch will also remove SLO_IO usage, since it is supposed not to compile anymore anyway, and cleanup headers.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#1 lore raw
Quoted 2 lines

1. If wanted in kernel code, have a single scanner in i2c-core instead.

But you finally did not implement that, right?

Quoted 4 lines

I2C address space is not that flat and some addresses have special meanings for 10-bit addressing, high-speed, routing/multiplexing. A simple scan 0x00-0x7f only gives you half the picture.

True, still both sensors-detect and i2c-detect also do a "flat" scan.

Quoted 4 lines

2. A simple SMBus Quick command may have effect, the most simple i2c chip is a relay acting on the R/W bit of the address. Some chip at 0x69 (?) locked the bus in the early days (-99), and I think it was solved using write, not read address in the bus scan.

I wasn't there back to these times, but we now use a quick write command (which, as you know, doesn't really write anything). A quick look at i2c-ibm_iic.c in Linux 2.6.0 shows that they use one-byte read instead.

Quoted 4 lines

3. The ThinkPad issue, corruption on bus scan. While it is a bug on the EEPROM fw, you well know that somehow this type of issue needs to be handled. The fewer places to fix the better. The sensors-detect prog has 24RF08 fix, how about adding that in i2cdetect too?

You got a point, we forgot i2c-detect. MDS, is doubling the quickwrite on addresses 0x54-0x57 enough?

Quoted 2 lines

4. The in-module bus scan only outputs to log, the format may not be uniform cross algorithms. There is i2cdetect.

Makes sense too.

Quoted 1 line

I vote for removal of bus scan in all algorithm sources.

OK, will do.

Quoted 4 lines
Quoted 1 line

BTW, does i2cdetect work on non-i386 architectures?

Its pretty straight-forward. If it doesn't work, problem is more likely in i2c-dev.

That's not how I meant it. My point is that I think I remember Greg saying someting about i2c-dev not being portable cross platforms. If I'm not mistaking, i2cdetect relies on i2c-dev. What I mean is that removing in-modules bus scanning might not be accepted if the architectures using these modules are not able to use the new and prefered method, i.e. i2cdetect.

I searched my mail archive for Greg's original comment, but couldn't find it. Greg, any chance you could refresh my memory?

Thanks.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#2 lore raw
In reply to Jean Delvare
Quoted 8 lines
Quoted 4 lines

I wasn't there back to these times, but we now use a quick write command (which, as you know, doesn't really write anything). A quick look at i2c-ibm_iic.c in Linux 2.6.0 shows that they use one-byte read instead.

Not all chips acknowledge the read address. With the i2c-ibm_iic, I don't see the reason for using one-byte read, if hw could not do quick write a one-byte read is next best choice.

I don't quite follow you there. Is the one-byte read method a good choice or not?

Anyway, that's not really a problem if we are going to remove that bus scan from the i2c-ibm_iic driver. Just curious.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#3 lore raw
In reply to Jean Delvare
Quoted 12 lines · Jean Delvare
Quoted 4 lines
Quoted 1 line

BTW, does i2cdetect work on non-i386 architectures?

Its pretty straight-forward. If it doesn't work, problem is more likely in i2c-dev.

That's not how I meant it. My point is that I think I remember Greg saying someting about i2c-dev not being portable cross platforms. If I'm not mistaking, i2cdetect relies on i2c-dev. What I mean is that removing in-modules bus scanning might not be accepted if the architectures using these modules are not able to use the new and prefered method, i.e. i2cdetect.

Quoted 2 lines

I searched my mail archive for Greg's original comment, but couldn't find it. Greg, any chance you could refresh my memory?

For systems that have a 64bit kernel, and a 32bit userspace, all ioctls in the kernel need a "thunking" layer in order to pass the data between the kernel and userspace properly. Last I looked that layer did not contain any i2c ioctls, so i2c-dev will not work on those kinds of systems (ppc64, sparc64, mips64, amd64, ia64, etc...)

Hope this helps,

greg k-h

#4 lore raw
In reply to Jean Delvare
Quoted 13 lines · Jean Delvare
Quoted 8 lines
Quoted 2 lines

I searched my mail archive for Greg's original comment, but couldn't find it. Greg, any chance you could refresh my memory?

For systems that have a 64bit kernel, and a 32bit userspace, all ioctls in the kernel need a "thunking" layer in order to pass the data between the kernel and userspace properly. Last I looked that layer did not contain any i2c ioctls, so i2c-dev will not work on those kinds of systems (ppc64, sparc64, mips64, amd64, ia64, etc...)

OK. This means that these architectures can't user i2cdetect at the moment, but could do at a later time, providing the necessary layer is written.

Quoted 5 lines

So I think that the right thing to do would be to remove all bus scanning from the drivers themselves. Reasons for doing this have been discused earlier in this thread. If some people need bus scanning and i2cdetect doesn't work for them, I guess we'll hear from them, and we'll write the layer.

I agree, it should be done by the i2c core, or by userspace, but not by each individual driver. I played around a bit with adding it to the i2c core, and enabling hotplug events for every device found, which would cause the different i2c chip drivers to be automatically loaded by userspace. But I felt it was too big of a change for 2.6, due to it being so late in the development cycle. Something like that should be on the 2.7 wishlist though...

thanks,

greg k-h

#5 lore raw
In reply to Jean Delvare
Quoted 8 lines
Quoted 2 lines

I searched my mail archive for Greg's original comment, but couldn't find it. Greg, any chance you could refresh my memory?

For systems that have a 64bit kernel, and a 32bit userspace, all ioctls in the kernel need a "thunking" layer in order to pass the data between the kernel and userspace properly. Last I looked that layer did not contain any i2c ioctls, so i2c-dev will not work on those kinds of systems (ppc64, sparc64, mips64, amd64, ia64, etc...)

OK. This means that these architectures can't user i2cdetect at the moment, but could do at a later time, providing the necessary layer is written.

So I think that the right thing to do would be to remove all bus scanning from the drivers themselves. Reasons for doing this have been discused earlier in this thread. If some people need bus scanning and i2cdetect doesn't work for them, I guess we'll hear from them, and we'll write the layer.

Unless anyone objects, I'll be writing patches for both linux 2.4.23 and 2.6.0, and submit them to Marcelo and Greg, respectively.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#6 lore raw
In reply to Jean Delvare
Quoted 5 lines · Jean Delvare

In the process of merging our i2c CVS repository changes into the Linux 2.4 kernel, I saw that, back in January 2003, you removed bus scanning from two drivers (i2c-algo-bit and i2c-algo-pcf). What was your reason for doing so? Is it because it was unused, or because i2cdetect can be used instead, or both, or any other reason I didn't think of?

1. If wanted in kernel code, have a single scanner in i2c-core instead. I2C address space is not that flat and some addresses have special meanings for 10-bit addressing, high-speed, routing/multiplexing. A simple scan 0x00-0x7f only gives you half the picture.

2. A simple SMBus Quick command may have effect, the most simple i2c chip is a relay acting on the R/W bit of the address. Some chip at 0x69 (?) locked the bus in the early days (-99), and I think it was solved using write, not read address in the bus scan.

3. The ThinkPad issue, corruption on bus scan. While it is a bug on the EEPROM fw, you well know that somehow this type of issue needs to be handled. The fewer places to fix the better. The sensors-detect prog has 24RF08 fix, how about adding that in i2cdetect too?

4. The in-module bus scan only outputs to log, the format may not be uniform cross algorithms. There is i2cdetect.

Quoted 6 lines

I took a look at the i2c drivers present in both Linux 2.4 and 2.6, and it turns out that there are other drivers still having a bus scanning parameter (i2c-algo-ite.c and i2c-algo-sibyte.c in 2.4, i2c-algo-ite.c and i2c-ibm_iic.c in 2.6). As I will be submitting a patch to remove bus scanning from "our" drivers (i2c-algo-bit and i2c-algo-pcf), I'm wondering if I should do the same for these extra drivers as well.

Pretty much everything gets copy-pasted from i2c-algo-bit and i2c-algo-pcf without much thought, the algorithm interface could be better so this wouldn't happen. I vote for removal of bus scan in all algorithm sources.

Quoted 1 line

BTW, does i2cdetect work on non-i386 architectures?

Its pretty straight-forward. If it doesn't work, problem is more likely in i2c-dev.

Signature · 1 line
  Ky?sti M?lkki  <[email protected]>
#7 lore raw
In reply to Jean Delvare
Quoted 4 lines · Jean Delvare
Quoted 2 lines

1. If wanted in kernel code, have a single scanner in i2c-core instead.

But you finally did not implement that, right?

Did not. There was i2cdetect.

Quoted 9 lines
Quoted 4 lines

2. A simple SMBus Quick command may have effect, the most simple i2c chip is a relay acting on the R/W bit of the address. Some chip at 0x69 (?) locked the bus in the early days (-99), and I think it was solved using write, not read address in the bus scan.

I wasn't there back to these times, but we now use a quick write command (which, as you know, doesn't really write anything). A quick look at i2c-ibm_iic.c in Linux 2.6.0 shows that they use one-byte read instead.

Not all chips acknowledge the read address. With the i2c-ibm_iic, I don't see the reason for using one-byte read, if hw could not do quick write a one-byte read is next best choice.

Signature · 1 line
  Ky?sti M?lkki  <[email protected]>
#8 lore raw
In reply to Jean Delvare
Quoted 6 lines · Jean Delvare
Quoted 3 lines

Not all chips acknowledge the read address. With the i2c-ibm_iic, I don't see the reason for using one-byte read, if hw could not do quick write a one-byte read is next best choice.

I don't quite follow you there. Is the one-byte read method a good choice or not?

Depends of the chip, really. Commands in order of preference, what is least likely to cause ill side effects on the bus.

1. Write Quick Wr "0"
2. Write Quick Rd "1"
3. Read Byte(s)
4. Write Byte(s)

Seems i2c_probe/detect requires Write Quick, while the chip driver itself could do without it, so the chip never gets properly detected. By properly, I mean the code in the chip driver that knows the specific message format to use.

Signature · 1 line
  Ky?sti M?lkki  <[email protected]>
#9 lore raw
In reply to Jean Delvare
Quoted 9 lines · Jean Delvare
Quoted 5 lines

For systems that have a 64bit kernel, and a 32bit userspace, all ioctls in the kernel need a "thunking" layer in order to pass the data between the kernel and userspace properly. Last I looked that layer did not contain any i2c ioctls, so i2c-dev will not work on those kinds of systems (ppc64, sparc64, mips64, amd64, ia64, etc...)

Take a look at 2.6.0-mm1's changelog. Didn't look at the code but it looks like someone just implemented this. Greg, do you confirm it's the same as what you're talking about?

You are correct, I forgot about Ben's patch. Yes, this is exactly what I was talking about. So, if any people using kernels on the above platform want to use i2c-detect, they should use the -mm tree.

thanks,

greg k-h

#10 lore raw
In reply to Jean Delvare
Quoted 5 lines

For systems that have a 64bit kernel, and a 32bit userspace, all ioctls in the kernel need a "thunking" layer in order to pass the data between the kernel and userspace properly. Last I looked that layer did not contain any i2c ioctls, so i2c-dev will not work on those kinds of systems (ppc64, sparc64, mips64, amd64, ia64, etc...)

Take a look at 2.6.0-mm1's changelog. Didn't look at the code but it looks like someone just implemented this. Greg, do you confirm it's the same as what you're talking about?

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/