Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Nov 2019 20:51:22 +0000 (UTC)
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354301 - head/sys/dev/ichiic
Message-ID:  <201911032051.xA3KpM00060160@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wulf
Date: Sun Nov  3 20:51:22 2019
New Revision: 354301
URL: https://svnweb.freebsd.org/changeset/base/354301

Log:
  [ig4] Add support for polled mode
  
  Currently ig4 internally depends on it's own interrupts and uses mtx_sleep()
  to wait for them. That means it can not be used from any context where
  sleeping is disallowed e.g. on cold boot, from DDB/KDB, from other device
  driver's interrupt handlers and so on.
  
  This change replaces sleeps with busy loops in cold boot and DDB cases.

Modified:
  head/sys/dev/ichiic/ig4_iic.c

Modified: head/sys/dev/ichiic/ig4_iic.c
==============================================================================
--- head/sys/dev/ichiic/ig4_iic.c	Sun Nov  3 20:50:06 2019	(r354300)
+++ head/sys/dev/ichiic/ig4_iic.c	Sun Nov  3 20:51:22 2019	(r354301)
@@ -48,8 +48,10 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/errno.h>
+#include <sys/kdb.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
+#include <sys/proc.h>
 #include <sys/sx.h>
 #include <sys/syslog.h>
 #include <sys/bus.h>
@@ -70,6 +72,8 @@ __FBSDID("$FreeBSD$");
 #define TRANS_PCALL	2
 #define TRANS_BLOCK	3
 
+#define DO_POLL(sc)	(cold || kdb_active || SCHEDULER_STOPPED())
+
 static void ig4iic_start(void *xdev);
 static void ig4iic_intr(void *cookie);
 static void ig4iic_dump(ig4iic_softc_t *sc);
@@ -187,7 +191,7 @@ wait_status(ig4iic_softc_t *sc, uint32_t status)
 		 * When waiting for receive data let the interrupt do its
 		 * work, otherwise poll with the lock held.
 		 */
-		if (status & IG4_STATUS_RX_NOTEMPTY) {
+		if ((status & IG4_STATUS_RX_NOTEMPTY) && !DO_POLL(sc)) {
 			mtx_lock(&sc->io_lock);
 			set_intr_mask(sc, IG4_INTR_STOP_DET | IG4_INTR_RX_FULL);
 			mtx_sleep(sc, &sc->io_lock, 0, "i2cwait",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911032051.xA3KpM00060160>