Module Name:    src
Committed By:   martin
Date:           Fri Sep  4 15:07:08 UTC 2015

Modified Files:
        src/sys/dev/pci/hdaudio [netbsd-7]: hdafg.c hdaudio.c hdaudiovar.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #963):
        sys/dev/pci/hdaudio/hdafg.c: revision 1.26
        sys/dev/pci/hdaudio/hdaudiovar.h: revision 1.10
        sys/dev/pci/hdaudio/hdaudio.c: revision 1.25
Fix locking against myself problem:
        hdaudio_intr() ->
            mutex_enter(&sc->sc_corb_mtx);
            hdaudio_rirb_dequeue() ->
                hdaudio_rirb_unsol() ->
                    hdafg_unsol() ->
                        hdafg_assoc_dump_dd() ->
                            hdaudio_command() ->
                                mutex_enter(&sc->sc_corb_mtx);
Should that be done differently?


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.2.1 src/sys/dev/pci/hdaudio/hdafg.c
cvs rdiff -u -r1.22 -r1.22.2.1 src/sys/dev/pci/hdaudio/hdaudio.c
cvs rdiff -u -r1.9 -r1.9.30.1 src/sys/dev/pci/hdaudio/hdaudiovar.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/pci/hdaudio/hdafg.c
diff -u src/sys/dev/pci/hdaudio/hdafg.c:1.21 src/sys/dev/pci/hdaudio/hdafg.c:1.21.2.1
--- src/sys/dev/pci/hdaudio/hdafg.c:1.21	Fri May 23 13:57:04 2014
+++ src/sys/dev/pci/hdaudio/hdafg.c	Fri Sep  4 15:07:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.21 2014/05/23 13:57:04 msaitoh Exp $ */
+/* $NetBSD: hdafg.c,v 1.21.2.1 2015/09/04 15:07:08 martin Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <[email protected]>
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.21 2014/05/23 13:57:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.21.2.1 2015/09/04 15:07:08 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -834,21 +834,24 @@ hdafg_assoc_type_string(struct hdaudio_a
 }
 
 static void
-hdafg_assoc_dump_dd(struct hdafg_softc *sc, struct hdaudio_assoc *as, int pin)
+hdafg_assoc_dump_dd(struct hdafg_softc *sc, struct hdaudio_assoc *as, int pin,
+	int lock)
 {
 	struct hdafg_dd_info hdi;
 	struct hdaudio_widget *w;
 	uint8_t elddata[256];
 	unsigned int elddatalen = 0, i;
 	uint32_t res;
+	uint32_t (*cmd)(struct hdaudio_codec *, int, uint32_t, uint32_t) =
+	    lock ? hdaudio_command : hdaudio_command_unlocked;
 
 	w = hdafg_widget_lookup(sc, as->as_pins[pin]);
 
 	if (w->w_pin.cap & COP_PINCAP_TRIGGER_REQD) {
-		hdaudio_command(sc->sc_codec, as->as_pins[pin],
+		(*cmd)(sc->sc_codec, as->as_pins[pin],
 		    CORB_SET_PIN_SENSE, 0);
 	}
-	res = hdaudio_command(sc->sc_codec, as->as_pins[pin],
+	res = (*cmd)(sc->sc_codec, as->as_pins[pin],
 	    CORB_GET_PIN_SENSE, 0);
 
 #ifdef HDAFG_HDMI_DEBUG
@@ -862,13 +865,13 @@ hdafg_assoc_dump_dd(struct hdafg_softc *
 	if ((res &
 	    (COP_GET_PIN_SENSE_PRESENSE_DETECT|COP_GET_PIN_SENSE_ELD_VALID)) ==
 	    (COP_GET_PIN_SENSE_PRESENSE_DETECT|COP_GET_PIN_SENSE_ELD_VALID)) {
-		res = hdaudio_command(sc->sc_codec, as->as_pins[pin],
+		res = (*cmd)(sc->sc_codec, as->as_pins[pin],
 		    CORB_GET_HDMI_DIP_SIZE, COP_DIP_ELD_SIZE);
 		elddatalen = COP_DIP_BUFFER_SIZE(res);
 		if (elddatalen == 0)
 			elddatalen = sizeof(elddata); /* paranoid */
 		for (i = 0; i < elddatalen; i++) {
-			res = hdaudio_command(sc->sc_codec, as->as_pins[pin],
+			res = (*cmd)(sc->sc_codec, as->as_pins[pin],
 			    CORB_GET_HDMI_ELD_DATA, i);
 			if (!(res & COP_ELD_VALID)) {
 				hda_error(sc, "bad ELD size (%u/%u)\n",
@@ -1087,7 +1090,7 @@ hdafg_assoc_dump(struct hdafg_softc *sc)
 			for (j = 0; j < HDAUDIO_MAXPINS; j++) {
 				if (as[i].as_pins[j] == 0)
 					continue;
-				hdafg_assoc_dump_dd(sc, &as[i], j);
+				hdafg_assoc_dump_dd(sc, &as[i], j, 1);
 			}
 		}
 	}
@@ -4264,7 +4267,7 @@ hdafg_unsol(device_t self, uint8_t tag)
 			for (j = 0; j < HDAUDIO_MAXPINS; j++) {
 				if (as[i].as_pins[j] == 0)
 					continue;
-				hdafg_assoc_dump_dd(sc, &as[i], j);
+				hdafg_assoc_dump_dd(sc, &as[i], j, 0);
 			}
 		}
 		break;

Index: src/sys/dev/pci/hdaudio/hdaudio.c
diff -u src/sys/dev/pci/hdaudio/hdaudio.c:1.22 src/sys/dev/pci/hdaudio/hdaudio.c:1.22.2.1
--- src/sys/dev/pci/hdaudio/hdaudio.c:1.22	Fri Jul 25 08:10:38 2014
+++ src/sys/dev/pci/hdaudio/hdaudio.c	Fri Sep  4 15:07:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.22 2014/07/25 08:10:38 dholland Exp $ */
+/* $NetBSD: hdaudio.c,v 1.22.2.1 2015/09/04 15:07:08 martin Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <[email protected]>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.22 2014/07/25 08:10:38 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.22.2.1 2015/09/04 15:07:08 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -326,15 +326,25 @@ uint32_t
 hdaudio_command(struct hdaudio_codec *co, int nid, uint32_t control,
     uint32_t param)
 {
+	uint32_t result;
+	struct hdaudio_softc *sc = co->co_host;
+	mutex_enter(&sc->sc_corb_mtx);
+	result = hdaudio_command_unlocked(co, nid, control, param);
+	mutex_exit(&sc->sc_corb_mtx);
+	return result;
+}
+
+uint32_t
+hdaudio_command_unlocked(struct hdaudio_codec *co, int nid, uint32_t control,
+    uint32_t param)
+{
 	struct hdaudio_softc *sc = co->co_host;
 	uint32_t result;
 
-	mutex_enter(&sc->sc_corb_mtx);
 	hda_trace(sc, "cmd  : request %08X %08X (%02X)\n",
 	    control, param, nid);
 	hdaudio_corb_enqueue(sc, co->co_addr, nid, control, param);
 	result = hdaudio_rirb_dequeue(sc, false);
-	mutex_exit(&sc->sc_corb_mtx);
 
 	return result;
 }

Index: src/sys/dev/pci/hdaudio/hdaudiovar.h
diff -u src/sys/dev/pci/hdaudio/hdaudiovar.h:1.9 src/sys/dev/pci/hdaudio/hdaudiovar.h:1.9.30.1
--- src/sys/dev/pci/hdaudio/hdaudiovar.h:1.9	Sun Feb 13 17:49:12 2011
+++ src/sys/dev/pci/hdaudio/hdaudiovar.h	Fri Sep  4 15:07:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudiovar.h,v 1.9 2011/02/13 17:49:12 jmcneill Exp $ */
+/* $NetBSD: hdaudiovar.h,v 1.9.30.1 2015/09/04 15:07:08 martin Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <[email protected]>
@@ -176,6 +176,8 @@ int	hdaudio_rescan(struct hdaudio_softc 
 void	hdaudio_childdet(struct hdaudio_softc *, device_t);
 
 uint32_t hdaudio_command(struct hdaudio_codec *, int, uint32_t, uint32_t);
+uint32_t hdaudio_command_unlocked(struct hdaudio_codec *, int, uint32_t,
+    uint32_t);
 int	hdaudio_intr(struct hdaudio_softc *);
 
 int	hdaudio_dma_alloc(struct hdaudio_softc *, struct hdaudio_dma *, int);

Reply via email to