git: c58c931e2004 - stable/14 - ig4_iic: Allow sleeping if called from iichid interrupt handler.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 15 May 2025 18:17:48 UTC
The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c58c931e20045a6e254df5901e0321b537337440 commit c58c931e20045a6e254df5901e0321b537337440 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2025-03-07 06:26:51 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2025-05-15 18:11:55 +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 (cherry picked from commit c7225a3ede3cf99c538158962f4d65dee435bbcd) --- 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 749a39e25117..31b097fd68bb 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 @@ -713,14 +713,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 964a610e7408..cb44a1e7cd58 100644 --- a/sys/dev/ichiic/ig4_var.h +++ b/sys/dev/ichiic/ig4_var.h @@ -92,7 +92,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 e99facdb06bb..fd544e82b2fc 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)