NetBSD-Bugs archive

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

Re: kern/49926: [PATCH] Avoid deadlock condition in auich_read_codec() and auich_write_codec()



El 24/05/15 a les 17:05, Christos Zoulas ha escrit:
  On May 24,  2:15pm, rmh%freebsd.org@localhost (rmh%freebsd.org@localhost) wrote:
  -- Subject: kern/49926: [PATCH] Avoid deadlock condition in auich_read_codec(

  Should we have 2 static "first" variables, one per function, or one is
  enough?

Good point. A shared variable should be enough. And it works fine according
to my tests.

Furthermore, while doing this change I realized this isn't supposed to be
global, as the information it contains applies independently to each auich
device in the system, so I moved it to the sc_auich structure.

Here's a new (tested) patch.

Many thanks

--
Robert Millan
diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c
index 481ed16..ae1662f 100644
--- a/sys/dev/pci/auich.c
+++ b/sys/dev/pci/auich.c
@@ -232,6 +232,8 @@ struct auich_softc {
 	struct audio_format sc_modem_formats[AUICH_MODEM_NFORMATS];
 	struct audio_encoding_set *sc_encodings;
 	struct audio_encoding_set *sc_spdif_encodings;
+
+	int sc_cas_been_used;
 };
 
 /* Debug */
@@ -796,10 +798,9 @@ auich_read_codec(void *v, uint8_t reg, uint16_t *val)
 	 * a command is expected and therefore semaphore wait would hit
 	 * the timeout.
 	 */
-	static int first = 1;
-	if (i <= 0 && first)
+	if (!sc->sc_cas_been_used && i <= 0)
 		i = 1;
-	first = 0;
+	sc->sc_cas_been_used = 1;
 
 	if (i > 0) {
 		*val = bus_space_read_2(sc->iot, sc->mix_ioh,
@@ -845,10 +846,9 @@ auich_write_codec(void *v, uint8_t reg, uint16_t val)
 	    DELAY(ICH_CODECIO_INTERVAL));
 
 	/* Be permissive in first attempt (see comments in auich_read_codec) */
-	static int first = 1;
-	if (i <= 0 && first)
+	if (!sc->sc_cas_been_used && i <= 0)
 		i = 1;
-	first = 0;
+	sc->sc_cas_been_used = 1;
 
 	if (i > 0) {
 		bus_space_write_2(sc->iot, sc->mix_ioh,


Home | Main Index | Thread Index | Old Index