diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-10-19 22:34:10 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-10-19 22:34:10 +0000 |
| commit | fb27fc287ea84fc082cdec0bbe5bfeb3ade98bfd (patch) | |
| tree | 42bf894860cfacd5b8c320bfa2c5e09548782172 /sys/dev/ic | |
| parent | a16774bacb96a34dea4ce7403495af4b19b014a8 (diff) | |
dwiic(4): Don't try processing interrupts before attach completes.
PR kern/57063
Diffstat (limited to 'sys/dev/ic')
| -rw-r--r-- | sys/dev/ic/dwiic.c | 19 | ||||
| -rw-r--r-- | sys/dev/ic/dwiic_var.h | 4 |
2 files changed, 20 insertions, 3 deletions
diff --git a/sys/dev/ic/dwiic.c b/sys/dev/ic/dwiic.c index b15d6d84940..7ca7e87bfa1 100644 --- a/sys/dev/ic/dwiic.c +++ b/sys/dev/ic/dwiic.c @@ -1,4 +1,4 @@ -/* $NetBSD: dwiic.c,v 1.8 2021/11/14 20:51:57 andvar Exp $ */ +/* $NetBSD: dwiic.c,v 1.9 2022/10/19 22:34:10 riastradh Exp $ */ /* $OpenBSD: dwiic.c,v 1.4 2018/05/23 22:08:00 kettenis Exp $ */ @@ -49,9 +49,11 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwiic.c,v 1.8 2021/11/14 20:51:57 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwiic.c,v 1.9 2022/10/19 22:34:10 riastradh Exp $"); #include <sys/param.h> + +#include <sys/atomic.h> #include <sys/bus.h> #include <sys/device.h> #include <sys/kernel.h> @@ -196,6 +198,8 @@ dwiic_attach(struct dwiic_softc *sc) /* config_found_ia for "i2cbus" is done in the bus-attachment glue */ + atomic_store_release(&sc->sc_attached, true); + return 1; } @@ -587,6 +591,17 @@ dwiic_intr(void *arg) struct dwiic_softc *sc = arg; uint32_t en, stat; + /* + * Give up if attach hasn't succeeded. If it failed, nothing + * to do here. If it is still ongoing and simply hasn't yet + * succeeded, interrupts from the device are masked -- so this + * interrupt must be shared with another driver -- and any + * interrupts applicable to us will be delivered once + * interrupts from the device are unmasked in dwiic_i2c_exec. + */ + if (!atomic_load_acquire(&sc->sc_attached)) + return 0; + en = dwiic_read(sc, DW_IC_ENABLE); /* probably for the other controller */ if (!en) diff --git a/sys/dev/ic/dwiic_var.h b/sys/dev/ic/dwiic_var.h index d65eefc90c2..2e3f9682c1b 100644 --- a/sys/dev/ic/dwiic_var.h +++ b/sys/dev/ic/dwiic_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: dwiic_var.h,v 1.2 2018/09/26 18:32:51 jakllsch Exp $ */ +/* $NetBSD: dwiic_var.h,v 1.3 2022/10/19 22:34:10 riastradh Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -71,6 +71,8 @@ struct dwiic_softc { int flags; volatile int error; } sc_i2c_xfer; + + volatile bool sc_attached; }; bool dwiic_attach(struct dwiic_softc *); |
