svn commit: r350841 - head/sys/arm/ti/am335x
Ian Lepore
ian at FreeBSD.org
Sat Aug 10 17:48:12 UTC 2019
Author: ian
Date: Sat Aug 10 17:48:11 2019
New Revision: 350841
URL: https://svnweb.freebsd.org/changeset/base/350841
Log:
When responding to an interrupt in the am335x_pmic driver, use a taskqueue
thread to do the work that involves i2c IO, which sleeps while the IO is
in progress.
Modified:
head/sys/arm/ti/am335x/am335x_pmic.c
Modified: head/sys/arm/ti/am335x/am335x_pmic.c
==============================================================================
--- head/sys/arm/ti/am335x/am335x_pmic.c Sat Aug 10 17:28:14 2019 (r350840)
+++ head/sys/arm/ti/am335x/am335x_pmic.c Sat Aug 10 17:48:11 2019 (r350841)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/reboot.h>
#include <sys/resource.h>
#include <sys/rman.h>
+#include <sys/taskqueue.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>
@@ -62,6 +63,7 @@ struct am335x_pmic_softc {
struct intr_config_hook enum_hook;
struct resource *sc_irq_res;
void *sc_intrhand;
+ struct task intr_task;
};
static const char *tps65217_voreg_c[4] = {"4.10V", "4.15V", "4.20V", "4.25V"};
@@ -86,7 +88,7 @@ am335x_pmic_write(device_t dev, uint8_t address, uint8
}
static void
-am335x_pmic_intr(void *arg)
+am335x_pmic_intrtask(void *arg, int pending)
{
struct am335x_pmic_softc *sc = (struct am335x_pmic_softc *)arg;
struct tps65217_status_reg status_reg;
@@ -94,20 +96,16 @@ am335x_pmic_intr(void *arg)
int rv;
char notify_buf[16];
- THREAD_SLEEPING_OK();
rv = am335x_pmic_read(sc->sc_dev, TPS65217_INT_REG, (uint8_t *)&int_reg, 1);
if (rv != 0) {
device_printf(sc->sc_dev, "Cannot read interrupt register\n");
- THREAD_NO_SLEEPING();
return;
}
rv = am335x_pmic_read(sc->sc_dev, TPS65217_STATUS_REG, (uint8_t *)&status_reg, 1);
if (rv != 0) {
device_printf(sc->sc_dev, "Cannot read status register\n");
- THREAD_NO_SLEEPING();
return;
}
- THREAD_NO_SLEEPING();
if (int_reg.pbi && status_reg.pb)
shutdown_nice(RB_POWEROFF);
@@ -118,6 +116,18 @@ am335x_pmic_intr(void *arg)
}
}
+static void
+am335x_pmic_intr(void *arg)
+{
+ struct am335x_pmic_softc *sc = arg;
+
+ /*
+ * Handling the interrupt requires doing i2c IO, which sleeps while the
+ * IO is in progress, so do the processing on a taskqueue thread.
+ */
+ taskqueue_enqueue(taskqueue_thread, &sc->intr_task);
+}
+
static int
am335x_pmic_probe(device_t dev)
{
@@ -279,6 +289,8 @@ am335x_pmic_attach(device_t dev)
int rid;
sc = device_get_softc(dev);
+
+ TASK_INIT(&sc->intr_task, 0, am335x_pmic_intrtask, sc);
rid = 0;
sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
More information about the svn-src-head
mailing list