Module Name: src Committed By: riastradh Date: Wed Oct 19 22:34:10 UTC 2022
Modified Files: src/sys/dev/ic: dwiic.c dwiic_var.h Log Message: dwiic(4): Don't try processing interrupts before attach completes. PR kern/57063 To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/dwiic.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/dwiic_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/dwiic.c diff -u src/sys/dev/ic/dwiic.c:1.8 src/sys/dev/ic/dwiic.c:1.9 --- src/sys/dev/ic/dwiic.c:1.8 Sun Nov 14 20:51:57 2021 +++ src/sys/dev/ic/dwiic.c Wed Oct 19 22:34:10 2022 @@ -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) Index: src/sys/dev/ic/dwiic_var.h diff -u src/sys/dev/ic/dwiic_var.h:1.2 src/sys/dev/ic/dwiic_var.h:1.3 --- src/sys/dev/ic/dwiic_var.h:1.2 Wed Sep 26 18:32:51 2018 +++ src/sys/dev/ic/dwiic_var.h Wed Oct 19 22:34:10 2022 @@ -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 *);