Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Unmap device registers only when successfully ma...



details:   https://anonhg.NetBSD.org/src/rev/a6d6835f5f7c
branches:  trunk
changeset: 368217:a6d6835f5f7c
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Jun 29 15:37:25 2022 +0000

description:
Unmap device registers only when successfully mapped.

diffstat:

 sys/dev/pci/uhci_pci.c |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (59 lines):

diff -r 5cce099b97f3 -r a6d6835f5f7c sys/dev/pci/uhci_pci.c
--- a/sys/dev/pci/uhci_pci.c    Wed Jun 29 15:34:15 2022 +0000
+++ b/sys/dev/pci/uhci_pci.c    Wed Jun 29 15:37:25 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci_pci.c,v 1.66 2021/08/07 16:19:14 thorpej Exp $    */
+/*     $NetBSD: uhci_pci.c,v 1.67 2022/06/29 15:37:25 mlelstv Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.66 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.67 2022/06/29 15:37:25 mlelstv Exp $");
 
 #include "ehci.h"
 
@@ -68,6 +68,7 @@
        unsigned                sc_initialized;
 #define                SC_INIT_UHCI    1
 #define                SC_INIT_PMF     2
+#define                SC_INIT_MAPPED  4
 };
 
 static int
@@ -107,6 +108,7 @@
                aprint_error_dev(self, "can't map i/o space\n");
                return;
        }
+       sc->sc_initialized = SC_INIT_MAPPED;
 
        /*
         * Disable interrupts, so we don't get any spurious ones.
@@ -174,7 +176,7 @@
                aprint_error_dev(self, "init failed, error=%d\n", err);
                return;
        }
-       sc->sc_initialized = SC_INIT_UHCI;
+       sc->sc_initialized |= SC_INIT_UHCI;
 
 #if NEHCI > 0
        usb_pci_add(&sc->sc_pci, pa, self);
@@ -206,9 +208,12 @@
                pmf_device_deregister(self);
 
        /* disable interrupts and acknowledge any pending */
-       bus_space_write_2(sc->sc.iot, sc->sc.ioh, UHCI_INTR, 0);
-       bus_space_write_2(sc->sc.iot, sc->sc.ioh, UHCI_STS,
-           bus_space_read_2(sc->sc.iot, sc->sc.ioh, UHCI_STS));
+       if (sc->sc_initialized & SC_INIT_MAPPED) {
+               bus_space_write_2(sc->sc.iot, sc->sc.ioh, UHCI_INTR, 0);
+               bus_space_write_2(sc->sc.iot, sc->sc.ioh, UHCI_STS,
+                   bus_space_read_2(sc->sc.iot, sc->sc.ioh, UHCI_STS));
+       }
+       sc->sc_initialized = 0;
 
        if (sc->sc_ih != NULL) {
                pci_intr_disestablish(sc->sc_pc, sc->sc_ih);



Home | Main Index | Thread Index | Old Index