Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/hdaudio Enter link reset even if GCTL says we are al...



details:   https://anonhg.NetBSD.org/src/rev/5b3349bffcce
branches:  trunk
changeset: 828033:5b3349bffcce
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Nov 24 00:30:29 2017 +0000

description:
Enter link reset even if GCTL says we are already in reset state. Fixes
hdaudio codec detection under VirtualBox on a "cold" boot.

XXX pullup

diffstat:

 sys/dev/hdaudio/hdaudio.c |  30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diffs (61 lines):

diff -r 1dbae17b19d9 -r 5b3349bffcce sys/dev/hdaudio/hdaudio.c
--- a/sys/dev/hdaudio/hdaudio.c Thu Nov 23 23:47:09 2017 +0000
+++ b/sys/dev/hdaudio/hdaudio.c Fri Nov 24 00:30:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.5 2017/06/04 23:34:55 pgoyette Exp $ */
+/* $NetBSD: hdaudio.c,v 1.6 2017/11/24 00:30:29 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.5 2017/06/04 23:34:55 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.6 2017/11/24 00:30:29 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -612,21 +612,21 @@
        hda_write1(sc, HDAUDIO_MMIO_RIRBSTS,
            hda_read1(sc, HDAUDIO_MMIO_RIRBSTS));
 
-       /* If the controller isn't in reset state, initiate the transition */
+       /* Put the controller into reset state */
        gctl = hda_read4(sc, HDAUDIO_MMIO_GCTL);
-       if (gctl & HDAUDIO_GCTL_CRST) {
-               gctl &= ~HDAUDIO_GCTL_CRST;
-               hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl);
-               do {
-                       hda_delay(10);
-                       gctl = hda_read4(sc, HDAUDIO_MMIO_GCTL);
-               } while (--retry > 0 && (gctl & HDAUDIO_GCTL_CRST) != 0);
-               if (retry == 0) {
-                       hda_error(sc, "timeout entering reset state\n");
-                       return ETIME;
-               }
+       gctl &= ~HDAUDIO_GCTL_CRST;
+       hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl);
+       do {
+               hda_delay(10);
+               gctl = hda_read4(sc, HDAUDIO_MMIO_GCTL);
+       } while (--retry > 0 && (gctl & HDAUDIO_GCTL_CRST) != 0);
+       if (retry == 0) {
+               hda_error(sc, "timeout entering reset state\n");
+               return ETIME;
        }
 
+       hda_delay(1000);
+
        /* Now the controller is in reset state, so bring it out */
        retry = HDAUDIO_RESET_TIMEOUT;
        hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl | HDAUDIO_GCTL_CRST);
@@ -639,6 +639,8 @@
                return ETIME;
        }
 
+       hda_delay(2000);
+
        /* Accept unsolicited responses */
        hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl | HDAUDIO_GCTL_UNSOL_EN);
 



Home | Main Index | Thread Index | Old Index