From owner-svn-src-head@freebsd.org Sat Jan 26 17:52:13 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5F2314A820C; Sat, 26 Jan 2019 17:52:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A5AD8D16A; Sat, 26 Jan 2019 17:52:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 479AB2384B; Sat, 26 Jan 2019 17:52:13 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0QHqDD1093074; Sat, 26 Jan 2019 17:52:13 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0QHqDDZ093073; Sat, 26 Jan 2019 17:52:13 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201901261752.x0QHqDDZ093073@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sat, 26 Jan 2019 17:52:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343477 - head/sys/dev/iwm X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/dev/iwm X-SVN-Commit-Revision: 343477 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5A5AD8D16A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jan 2019 17:52:14 -0000 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);