The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c7225a3ede3cf99c538158962f4d65dee435bbcd
commit c7225a3ede3cf99c538158962f4d65dee435bbcd Author: Vladimir Kondratyev <w...@freebsd.org> AuthorDate: 2025-03-07 06:26:51 +0000 Commit: Vladimir Kondratyev <w...@freebsd.org> CommitDate: 2025-03-07 06:26:51 +0000 ig4_iic: Allow sleeping if called from iichid interrupt handler. This replaces 50 ms busy loop with mtx_sleep for the same duration thus saving CPU time when iichid is driven with interrupts. Sponsored by: Future Crew, LLC MFC after: 2 month Differential Revision: https://reviews.freebsd.org/D48956 --- sys/dev/ichiic/ig4_iic.c | 5 +---- sys/dev/ichiic/ig4_var.h | 1 - sys/dev/iicbus/iichid.c | 3 +++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/dev/ichiic/ig4_iic.c b/sys/dev/ichiic/ig4_iic.c index c9346ff12350..cd88b28a2d52 100644 --- a/sys/dev/ichiic/ig4_iic.c +++ b/sys/dev/ichiic/ig4_iic.c @@ -72,7 +72,7 @@ #include <dev/ichiic/ig4_reg.h> #include <dev/ichiic/ig4_var.h> -#define DO_POLL(sc) (cold || kdb_active || SCHEDULER_STOPPED() || sc->poll) +#define DO_POLL(sc) (cold || kdb_active || SCHEDULER_STOPPED()) /* * tLOW, tHIGH periods of the SCL clock and maximal falling time of both @@ -720,14 +720,11 @@ ig4iic_callback(device_t dev, int index, caddr_t data) if ((how & IIC_WAIT) == 0) { if (sx_try_xlock(&sc->call_lock) == 0) error = IIC_EBUSBSY; - else - sc->poll = true; } else sx_xlock(&sc->call_lock); break; case IIC_RELEASE_BUS: - sc->poll = false; sx_unlock(&sc->call_lock); break; diff --git a/sys/dev/ichiic/ig4_var.h b/sys/dev/ichiic/ig4_var.h index 989cf23779a2..0d000ab34c1d 100644 --- a/sys/dev/ichiic/ig4_var.h +++ b/sys/dev/ichiic/ig4_var.h @@ -93,7 +93,6 @@ struct ig4iic_softc { bool platform_attached : 1; bool use_10bit : 1; bool slave_valid : 1; - bool poll: 1; /* * Locking semantics: diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c index 346d432a74b5..fb6e8606adae 100644 --- a/sys/dev/iicbus/iichid.c +++ b/sys/dev/iicbus/iichid.c @@ -39,6 +39,7 @@ #include <sys/lock.h> #include <sys/malloc.h> #include <sys/module.h> +#include <sys/proc.h> #include <sys/rman.h> #include <sys/sysctl.h> #include <sys/systm.h> @@ -602,7 +603,9 @@ iichid_intr(void *context) * acknowledge interrupts we fetch only length header and discard it. */ maxlen = sc->power_on ? sc->intr_bufsize : 0; + THREAD_SLEEPING_OK(); error = iichid_cmd_read(sc, sc->intr_buf, maxlen, &actual); + THREAD_NO_SLEEPING(); if (error == 0) { if (sc->power_on) { if (actual != 0)