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()



The following reply was made to PR kern/49926; it has been noted by GNATS.

From: Robert Millan <rmh%freebsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost, kern-bug-people%netbsd.org@localhost, 
 gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost, 
 rumpkernel-users%freelists.org@localhost
Cc: 
Subject: Re: kern/49926: [PATCH] Avoid deadlock condition in auich_read_codec()
 and auich_write_codec()
Date: Sun, 24 May 2015 22:07:37 +0200

 This is a multi-part message in MIME format.
 --------------090706070508000801080506
 Content-Type: text/plain; charset=windows-1252; format=flowed
 Content-Transfer-Encoding: 7bit
 
 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
 
 --------------090706070508000801080506
 Content-Type: text/x-patch;
  name="auich_deadlock.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="auich_deadlock.diff"
 
 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,
 
 --------------090706070508000801080506--
 



Home | Main Index | Thread Index | Old Index