Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jan 2019 17:52:13 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343477 - head/sys/dev/iwm
Message-ID:  <201901261752.x0QHqDDZ093073@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Sat Jan 26 17:52:12 2019
New Revision: 343477
URL: https://svnweb.freebsd.org/changeset/base/343477

Log:
  Fix logic errors in iwm_pcie_load_firmware_chunk introduced in r314065.
  
   * There's no reason to have a while() loop here, because:
      - if msleep returns 0, that means we were woken up by the interrupt handler,
        and we are going to exit immediately as sc_fw_chunk_done will now be 1
        (there is nothing else that sleeps on sc_fw.)
      - if msleep doesn't return 0 (i.e. it returned ETIMEDOUT) then we will
        exit immediately because of the if-test.
     So, just use a single msleep() and then check sc_fw_chunk_done as before.
   * The comment said we were sleeping for 5 seconds, but the msleep was only
     for 1. Before r314065, this was 1 second and so was the comment,
     and in that commit the comment was changed and the function call wasn't.
  
  Possibly fixes failures to initialize uCode on certain devices.
  
  Submitted by:	Augustin Cavalier (waddlesplash gmail.com)
  Obtained from:	Haiku 132990ecdcb072f2ce597b5d497ff3e5b1f09c20
  MFC after:	10 days

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==============================================================================
--- head/sys/dev/iwm/if_iwm.c	Sat Jan 26 17:27:12 2019	(r343476)
+++ head/sys/dev/iwm/if_iwm.c	Sat Jan 26 17:52:12 2019	(r343477)
@@ -2397,8 +2397,6 @@ static int
 iwm_pcie_load_firmware_chunk(struct iwm_softc *sc, uint32_t dst_addr,
 			     bus_addr_t phy_addr, uint32_t byte_cnt)
 {
-	int ret;
-
 	sc->sc_fw_chunk_done = 0;
 
 	if (!iwm_nic_lock(sc))
@@ -2430,14 +2428,9 @@ iwm_pcie_load_firmware_chunk(struct iwm_softc *sc, uin
 	iwm_nic_unlock(sc);
 
 	/* wait up to 5s for this segment to load */
-	ret = 0;
-	while (!sc->sc_fw_chunk_done) {
-		ret = msleep(&sc->sc_fw, &sc->sc_mtx, 0, "iwmfw", hz);
-		if (ret)
-			break;
-	}
+	msleep(&sc->sc_fw, &sc->sc_mtx, 0, "iwmfw", hz * 5);
 
-	if (ret != 0) {
+	if (!sc->sc_fw_chunk_done) {
 		device_printf(sc->sc_dev,
 		    "fw chunk addr 0x%x len %d failed to load\n",
 		    dst_addr, byte_cnt);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901261752.x0QHqDDZ093073>