i2c_force_data
Ick, does anyone still use i2c_force_data?
Does the lm_sensors tools create force data that users use on the modprobe command line?
I'd really like to get rid of that structure (hint, it's the last thing standing between the current code probe mess, and automatic chip driver loading when adapters are loaded, like the pci and usb and ieee1394 and pnp subsystems...)
thanks,
greg k-h
Quoted 6 lines · Jean Delvare
Hi Greg,
Quoted 1 line
Ick, does anyone still use
i2c_force_data?Yes, we do.
Ok, thanks for the descriptions. But moving the structure out of the i2c_address_data field shouldn't be a problem, as long as I retain the original functionality, right?
Also, a lot of this will be done with sysfs, and not as module paramaters, to make it more uniform accross bus types (see the various odd threads on lkml about trying to unify the "add a device id" to a bus type for more details.)
Quoted 7 lines
Quoted 4 lines
I'd really like to get rid of that structure (hint, it's the last thing standing between the current code probe mess, and automatic chip driver loading when adapters are loaded, like the pci and usb and ieee1394 and pnp subsystems...)
Beware. Fully automatic detection of I2C clients is technically impossible.
Oh, I know this is not going to work for all people on all platforms. I will be careful :)
Quoted 5 lines
If you are going to try ALL client drivers on all addresses, this will mean a LOT of register probings and some I2C clients really don't like this. This would basically mean running a sensors-detect-like process on each boot. See how slow and I2c-bus intensive it is?
Speed really isn't an issue, as device probing will soon be multithreaded within the kernel. It would just be a thread off doing the probing while everything else happens like normal.
Quoted 7 lines
You'll also notice that some chips are supported by
more than just one driver (but with varying feature support levels), so the driver order will matter much (and possibly no order will be efficient enough for older chips). In most cases the sensors-detect script knows about that (it uses confidence levels, not booleans) but we don't want to move the whole sensors-detect code into kernel space, do we?
Heh, no.
All I want to do is have the address that chip drivers support be exported to userspace throught the MODULE_DEVICE_ID interface. Then, if the user wants it, basically do the same thing as i2c-detect does (testing all addresses for a valid answer). If it looks like there is a chip there, create a device, which creates a hotplug event, which lets userspace look up what driver it wants to have loaded, if any.
The logic about detecting which driver for which device still remains in userspace, where it belongs.
Although moving some of the sensors-detect logic into a hotplug script might be useful in the end, but I'll worry about that when we get there. I really just want the MODULE_DEVICE_ID() stuff done first. More fun can happen after that.
Quoted 3 lines
BTW, I don't say that we shouldn't consider automating things at all. Just that we better be very careful and go by small steps, and accept the idea that it may not work all the time.
I agree, I'll go slowly, and I know everyone here will be sure to tell me when I get things wrong :)
Quoted 6 lines
In particular, if we go that
direction, I think we would start by listing which chips can safely be automatically detected and which do not, and only attempt to autoload safe drivers (or, more precisely, safe devices within a driver). As a rule of thumb, most recent chips are safe (they have chip ID and manufacturer ID at relatively standard locations), but older are not.
That would be great, do we have such a list anywhere already?
thanks,
greg k-h
Quoted 7 lines
Quoted 1 line
That would be great, do we have such a list anywhere already?
Not exactly. However, such a list could be easily regenerated from the confidence values stored in sensors-detect. Chips to which we never grant a confidence value greater than (say) 5 are bad candidates to autoloading. A closer look should let us refine the list.
Quoted 6 lines
If you are interested, I may provide a comprehensive list of I2C client drivers and chips stating the "autoloadability" for each chip. Since I know the various hardware monitoring chips and sensors-detect very well, I will probably come to a decent candidate list faster than anyone else. If you want a similar document for ISA chips and Super-I/O chips, just let me know.
On second though, we don't need this, do we? The hotplug events will be generated by the kernel, but on the kernel side we have no idea what the client chips are (which is why we need the whole detection stuff in the first place). The detection code will remain in user-space and won't necessarily be very different from what it was. All we will need to do it convert the confidence value into a boolean balue (autoload a client driver or not).
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Quoted 14 lines · Jean Delvare
Quoted 7 lines
Quoted 1 line
That would be great, do we have such a list anywhere already?
Not exactly. However, such a list could be easily regenerated from the confidence values stored in sensors-detect. Chips to which we never grant a confidence value greater than (say) 5 are bad candidates to autoloading. A closer look should let us refine the list.
Quoted 6 lines
If you are interested, I may provide a comprehensive list of I2C client drivers and chips stating the "autoloadability" for each chip. Since I know the various hardware monitoring chips and sensors-detect very well, I will probably come to a decent candidate list faster than anyone else. If you want a similar document for ISA chips and Super-I/O chips, just let me know.
Quoted 7 lines
On second though, we don't need this, do we? The hotplug events will be generated by the kernel, but on the kernel side we have no idea what the client chips are (which is why we need the whole detection stuff in the first place). The detection code will remain in user-space and won't necessarily be very different from what it was. All we will need to do it convert the confidence value into a boolean balue (autoload a client driver or not).
Exactly, you are correct.
thanks,
greg k-h
Quoted 6 lines · Jean Delvare
I'm not diving into the LKML archives today. I think I remember of threads about how to standardize the way devices are numbered and identified among the various bus types so that the hotplug stuff can be kept simple. I guess this is what you refer to. I were not aware that other busses had device id forcing requirements like we have for I2C though.
You can now add pci ids on the fly through sysfs, which causes drivers to accept new devices from what they were originally compiled with.
We're extending that logic to say, "try to bind this driver to that device" from userspace through sysfs, which should be sufficient to replace this force logic, right?
Quoted 7 lines
Quoted 3 lines
Speed really isn't an issue, as device probing will soon be multithreaded within the kernel. It would just be a thread off doing the probing while everything else happens like normal.
I'm more concerned about bus load. We have seen poor hardware implementations and messy BIOSes causing SMBus locks on high load. We don't want this to happen at boot time.
Hm, I'll have to think about this. I really don't want a white/black list of busses that this will work on, as if you look at the kernel code today, we already scan all addresses for validity in i2c_detect() before handing off to the chip driver (yeah, that's a bit different from scanning all addresses, I agree, but conceptually it's the same.)
Wonder if we just sleep for a second or two between bus address probes, if that will help out or not :)
Quoted 4 lines
If I understand correctly, the information the kernel would transmit to hotplug would be "a client chip was found at I2C address (N, M)", and it would be left to the user-space to probe that address (sensors-detect like) and load the appropriate module?
Exactly. Hm, it will really be even simpler, it will just be a "this address was found" type hotplug event that today gets generated when we add a chip device to the sysfs tree. We will just be adding the devices to sysfs _before_ binding them to a driver, which is the "proper" order in which to do this (unlike today, where I cheated and did it the other way around...)
Quoted 5 lines
Quoted 2 lines
I agree, I'll go slowly, and I know everyone here will be sure to tell me when I get things wrong :)
True. Feel free to share your code and thoughts as you go, in case I could be of some help.
I will do that. Looks like I'm signing myself up to rework the whole locking model in the driver core to fix some of these issues first, so it might be a while before I get back to i2c work :(
thanks,
greg k-h
Hi Greg,
Quoted 6 lines
You can now add pci ids on the fly through sysfs, which causes drivers to accept new devices from what they were originally compiled with.
We're extending that logic to say, "try to bind this driver to that device" from userspace through sysfs, which should be sufficient to replace this force logic, right?
So basically we would load the driver first, it wouldn't recognize the device at first, then we would write something to sysfs and the driver would attempt to recognize the device again, successfully this time?
This matches the "force" module parameter we have pretty well. However we also have e.g. force_w83782d, force_lm84 etc... which not only forcibly bind a driver to a device, but also invite the driver to handle that chip in a specific way. Will this be doable as well?
Quoted 9 lines
Quoted 3 lines
I'm more concerned about bus load. We have seen poor hardware implementations and messy BIOSes causing SMBus locks on high load. We don't want this to happen at boot time.
Hm, I'll have to think about this. I really don't want a white/black list of busses that this will work on, as if you look at the kernel code today, we already scan all addresses for validity in
i2c_detect()before handing off to the chip driver (yeah, that's a bit different from scanning all addresses, I agree, but conceptually it's the same.)
That's not quite what I was thinking about. My point was that sensors-detect will issue dozens of register reads for each responsive address, including several reads on the very same registers. This is caused by a faulty design in the first place (well the script knew about half a dozen client chips in the first place, and 85 now, that explains it). For a family of chip we would need one detection function that tells what the most likely chip of the family is. Instead we have one function per chip type returning its own confidence value (zero for almost all and non-zero for one or sometimes two). Each function is probing the registers again, thus the bus load. This could be improved by introducing a local cache of the registers, but this ain't trivial either because some chips have "banks" which means that a given address may be a different register next time you ask for it. Rewriting the whole thing with a better design would probably be even better, but sensors-detect is a very sensible piece of code and it simply seems that nobody wants to take the risk.
The client drivers, in that respect, behave much better than sensors-detect does.
The bus load issue in sensors-detect wasn't critical as long as it was a stand-alone script meant to be run just once. Now that a similar action is supposed to be taken on each boot (or bus driver load) this is a different matter.
My proposal would be not to blacklist any bus, but to limit the bus traffic we will be generating. One way to do that is to only support autoloading of the easy-to-identify chips through the hotplug interface. Recent chips have chip ID and manufacturer ID registers at relatively standard locations. These can be easily identified. Older chips cannot and we use bus-intensive, half-reliable heuristics to detect them. See the CVS log of sensors-detect if you want to figure out how much I have been refining detection heuristics in the last year. Maybe we don't want to support such chips through hotplug.
Quoted 2 lines
Wonder if we just sleep for a second or two between bus address probes, if that will help out or not :)
You must be kidding, right?
Thanks.
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Quoted 5 lines · Jean Delvare
Hi Greg,
Quoted 3 lines
You can now add pci ids on the fly through sysfs, which causes drivers to accept new devices from what they were originally compiled with.
Quoted 7 lines
Quoted 3 lines
We're extending that logic to say, "try to bind this driver to that device" from userspace through sysfs, which should be sufficient to replace this force logic, right?
So basically we would load the driver first, it wouldn't recognize the device at first, then we would write something to sysfs and the driver would attempt to recognize the device again, successfully this time?
Yes.
Quoted 4 lines
This matches the "force" module parameter we have pretty well. However we also have e.g.
force_w83782d,force_lm84etc... which not only forcibly bind a driver to a device, but also invite the driver to handle that chip in a specific way. Will this be doable as well?
Yeah, I've been thinking about this too. We might have to break those types of drivers out into multiple "drivers" within sysfs. Should be easy to do, and will let sysfs work just fine.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
I'm more concerned about bus load. We have seen poor hardware implementations and messy BIOSes causing SMBus locks on high load. We don't want this to happen at boot time.
Hm, I'll have to think about this. I really don't want a white/black list of busses that this will work on, as if you look at the kernel code today, we already scan all addresses for validity in
i2c_detect()before handing off to the chip driver (yeah, that's a bit different from scanning all addresses, I agree, but conceptually it's the same.)
Quoted 3 lines
That's not quite what I was thinking about. My point was that sensors-detect will issue dozens of register reads for each responsive address, including several reads on the very same registers.
No, I'm talking about doing something like i2cdetect.c in the kernel to just loop over all of the addresses on the bus and do a small "ping". If we get a response back, create the sysfs device, and that causes userspace to get the event and look up what driver to try to load for that device.
Does that make more sense?
Quoted 4 lines
Quoted 2 lines
Wonder if we just sleep for a second or two between bus address probes, if that will help out or not :)
You must be kidding, right?
I've seen worse workarounds in the past before :)
thanks,
greg k-h
Hi Greg,
Quoted 3 lines
Ok, thanks for the descriptions. But moving the structure out of the
i2c_address_datafield shouldn't be a problem, as long as I retain the original functionality, right?
True as far as I can see. However, I don't know what exactly you have in mind. If you want to describe it in more details, I would be more able to tell you how good it sounds to me. Or just wait until you have it ready and I'll review it then, at your option. Depends on how confident you are I guess ;)
Quoted 4 lines
Also, a lot of this will be done with sysfs, and not as module paramaters, to make it more uniform accross bus types (see the various odd threads on lkml about trying to unify the "add a device id" to a bus type for more details.)
I'm not diving into the LKML archives today. I think I remember of threads about how to standardize the way devices are numbered and identified among the various bus types so that the hotplug stuff can be kept simple. I guess this is what you refer to. I were not aware that other busses had device id forcing requirements like we have for I2C though.
Quoted 3 lines
Speed really isn't an issue, as device probing will soon be multithreaded within the kernel. It would just be a thread off doing the probing while everything else happens like normal.
I'm more concerned about bus load. We have seen poor hardware implementations and messy BIOSes causing SMBus locks on high load. We don't want this to happen at boot time.
Quoted 7 lines
All I want to do is have the address that chip drivers support be exported to userspace throught the
MODULE_DEVICE_IDinterface. Then, if the user wants it, basically do the same thing as i2c-detect does (testing all addresses for a valid answer). If it looks like there is a chip there, create a device, which creates a hotplug event, which lets userspace look up what driver it wants to have loaded, if any.
Quoted 7 lines
The logic about detecting which driver for which device still remains in userspace, where it belongs.
Although moving some of the sensors-detect logic into a hotplug script might be useful in the end, but I'll worry about that when we get there. I really just want the
MODULE_DEVICE_ID()stuff done first. More fun can happen after that.
OK, now I see what you want to do. Basically adapt the sensors-detect script so that it is suitable for hotplug. Sounds interesting. The good part being that sensors-detect is hosed and needs a complete rewrite anyway ;)
If I understand correctly, the information the kernel would transmit to hotplug would be "a client chip was found at I2C address (N, M)", and it would be left to the user-space to probe that address (sensors-detect like) and load the appropriate module?
As a side note, it won't work for non-Super-I/O ISA chips unless I'm missing something (ISA PnP maybe?)
And the Super-I/O chips would probably need yet something different, but that's quite another story.
Quoted 2 lines
I agree, I'll go slowly, and I know everyone here will be sure to tell me when I get things wrong :)
True. Feel free to share your code and thoughts as you go, in case I could be of some help.
Quoted 6 lines
Quoted 4 lines
In particular, if we go that
direction, I think we would start by listing which chips can safely be automatically detected and which do not, and only attempt to autoload safe drivers (or, more precisely, safe devices within a driver).That would be great, do we have such a list anywhere already?
Not exactly. However, such a list could be easily regenerated from the confidence values stored in sensors-detect. Chips to which we never grant a confidence value greater than (say) 5 are bad candidates to autoloading. A closer look should let us refine the list.
If you are interested, I may provide a comprehensive list of I2C client drivers and chips stating the "autoloadability" for each chip. Since I know the various hardware monitoring chips and sensors-detect very well, I will probably come to a decent candidate list faster than anyone else. If you want a similar document for ISA chips and Super-I/O chips, just let me know.
Thanks,
Jean
Hi Greg,
Quoted 1 line
Ick, does anyone still use
i2c_force_data?
Yes, we do.
Quoted 2 lines
Does the
lm_sensorstools create force data that users use on the modprobe command line?
Exactly. Say you have a brand new ABC42 hardware monitoring chip, which is not recognized by any driver, but happens to be somewhat compatible with the ABC40, which is one of the devices supported by our xyz120 driver. You can use "modprobe xyz120 force_abc40=0,0xADDR" to get it to work until better, dedicated support is added. This has proven to be very useful in the past.
Another use is to workaround improperly identified chips (I have an LM83 eval board where the chip ID and manufacturer ID have not been set, for example), or for some chips that are not detectable so forcing them is the only (somewhat safe) way to go.
Now, I do not defend the current implementation of this functionality. If you can come up with something more elegant, I'm all for that. But the functionality is doubtlessly useful.
Quoted 4 lines
I'd really like to get rid of that structure (hint, it's the last thing standing between the current code probe mess, and automatic chip driver loading when adapters are loaded, like the pci and usb and ieee1394 and pnp subsystems...)
Beware. Fully automatic detection of I2C clients is technically impossible. If you are going to try ALL client drivers on all addresses, this will mean a LOT of register probings and some I2C clients really don't like this. This would basically mean running a sensors-detect-like process on each boot. See how slow and I2c-bus intensive it is? You'll also notice that some chips are supported by more than just one driver (but with varying feature support levels), so the driver order will matter much (and possibly no order will be efficient enough for older chips). In most cases the sensors-detect script knows about that (it uses confidence levels, not booleans) but we don't want to move the whole sensors-detect code into kernel space, do we?
BTW, I don't say that we shouldn't consider automating things at all. Just that we better be very careful and go by small steps, and accept the idea that it may not work all the time. In particular, if we go that direction, I think we would start by listing which chips can safely be automatically detected and which do not, and only attempt to autoload safe drivers (or, more precisely, safe devices within a driver). As a rule of thumb, most recent chips are safe (they have chip ID and manufacturer ID at relatively standard locations), but older are not.
Thanks,
Jean