Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic dwiic(4): Don't try processing interrupts before ...



details:   https://anonhg.NetBSD.org/src/rev/f4f30c2e419d
branches:  trunk
changeset: 371949:f4f30c2e419d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Oct 19 22:34:10 2022 +0000

description:
dwiic(4): Don't try processing interrupts before attach completes.

PR kern/57063

diffstat:

 sys/dev/ic/dwiic.c     |  19 +++++++++++++++++--
 sys/dev/ic/dwiic_var.h |   4 +++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diffs (67 lines):

diff -r 5a0b8690a3b2 -r f4f30c2e419d sys/dev/ic/dwiic.c
--- a/sys/dev/ic/dwiic.c        Wed Oct 19 22:28:35 2022 +0000
+++ b/sys/dev/ic/dwiic.c        Wed Oct 19 22:34:10 2022 +0000
@@ -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 @@
 
        /* 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 @@
        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 -r 5a0b8690a3b2 -r f4f30c2e419d sys/dev/ic/dwiic_var.h
--- a/sys/dev/ic/dwiic_var.h    Wed Oct 19 22:28:35 2022 +0000
+++ b/sys/dev/ic/dwiic_var.h    Wed Oct 19 22:34:10 2022 +0000
@@ -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 @@
                int             flags;
                volatile int    error;
        } sc_i2c_xfer;
+
+       volatile bool           sc_attached;
 };
 
 bool           dwiic_attach(struct dwiic_softc *);



Home | Main Index | Thread Index | Old Index