Re: i2c_smbus_write_block_data vs scheduled routine calls (add_timer) - kernel crash

Mark Brown
2009-08-04T20:35:56Z

On Tue, Aug 04, 2009 at 09:42:41PM +0300, NiTr0 wrote:

> All variables are declared as static, all data is prepared correctly
> - so IMHO trouble is outside of my driver.
> There is a part of code:

The problem is that your driver is trying to do I2C/SMBus I/O from a
timer, which is run from an interrupt context. Since I2C buses are
generally very slow the controllers are interrupt driven and the read
and write operations on them will sleep waiting for operations to
complete. If the code waited for the I/O to complete in an interrupt
context it would cause serious performance problems in the rest of the
system.

You should do the actual I/O from another context, such as a workqueue.
schedule_delayed_work() may be helpful here.