tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

resettodr() and (over)use of I2C_F_POLL



I2C_F_POLL (poll for completion -- no sleeping) is used a lot in sys/dev/i2c.  In some places, it's used conditionally based on the value of 'cold', which seems fine, and I am going to centralize that logic in i2c_exec.c so it doesn't have to be replicated.

But there's a number of places using I2C_F_POLL outside of cold auto configuration, and I can't believe that it's actually necessary in all of them.

Each i2c device has exclusive access to the i2c bus while doing its operation, and I don't believe that's allowed in any interrupt context at all.  Certainly, I don't think the various i2c real-time clock drivers need to use I2C_F_POLL -- inittodr() is called very late in the startup process, and resettodr() is not called in the crash or shutdown process.  That said, resettodr() *is* called from kern_time.c:settime1(), which wraps the entire function body in a splclock() / splx() pair.  This seems ... unnecessary.  Seems like the following diff is safe / appropriate, though I'm still suspicious of the whole splclock() thing.

Comments / thoughts / rotten produce?


diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 6ff70ad74be9..8226372404f8 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -160,9 +160,9 @@ settime1(struct proc *p, const struct timespec *ts, bool check_kauth)
        tc_setclock(ts);
 
        timespecadd(&boottime, &delta, &boottime);
+       splx(s);
 
        resettodr();
-       splx(s);
 
        return (0);
 }


-- thorpej



Home | Main Index | Thread Index | Old Index