From owner-svn-src-stable-8@FreeBSD.ORG Sat Jun 18 11:29:45 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24712106564A; Sat, 18 Jun 2011 11:29:45 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A2CB8FC12; Sat, 18 Jun 2011 11:29:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5IBTi6L038380; Sat, 18 Jun 2011 11:29:44 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5IBTiQm038378; Sat, 18 Jun 2011 11:29:44 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201106181129.p5IBTiQm038378@svn.freebsd.org> From: Bernhard Schmidt Date: Sat, 18 Jun 2011 11:29:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223236 - stable/8/sys/dev/iwn X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jun 2011 11:29:45 -0000 Author: bschmidt Date: Sat Jun 18 11:29:44 2011 New Revision: 223236 URL: http://svn.freebsd.org/changeset/base/223236 Log: MFC r220661: Fixes for firmware handling: - there is a local variable for sc->fw_dma, use that instead - OpenBSD uses 5*hz to wait for firmware to be loaded - in case the firmware module contains invalid data, actually release it Modified: stable/8/sys/dev/iwn/if_iwn.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/iwn/if_iwn.c ============================================================================== --- stable/8/sys/dev/iwn/if_iwn.c Sat Jun 18 11:27:44 2011 (r223235) +++ stable/8/sys/dev/iwn/if_iwn.c Sat Jun 18 11:29:44 2011 (r223236) @@ -5629,10 +5629,10 @@ iwn4965_load_firmware(struct iwn_softc * /* Copy initialization sections into pre-allocated DMA-safe memory. */ memcpy(dma->vaddr, fw->init.data, fw->init.datasz); - bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE); + bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); memcpy(dma->vaddr + IWN4965_FW_DATA_MAXSZ, fw->init.text, fw->init.textsz); - bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE); + bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); /* Tell adapter where to find initialization sections. */ error = iwn_nic_lock(sc); @@ -5670,10 +5670,10 @@ iwn4965_load_firmware(struct iwn_softc * /* Copy runtime sections into pre-allocated DMA-safe memory. */ memcpy(dma->vaddr, fw->main.data, fw->main.datasz); - bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE); + bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); memcpy(dma->vaddr + IWN4965_FW_DATA_MAXSZ, fw->main.text, fw->main.textsz); - bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE); + bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); /* Tell adapter where to find runtime sections. */ error = iwn_nic_lock(sc); @@ -5700,7 +5700,7 @@ iwn5000_load_firmware_section(struct iwn /* Copy firmware section into pre-allocated DMA-safe memory. */ memcpy(dma->vaddr, section, size); - bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE); + bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE); error = iwn_nic_lock(sc); if (error != 0) @@ -5726,7 +5726,7 @@ iwn5000_load_firmware_section(struct iwn iwn_nic_unlock(sc); /* Wait at most five seconds for FH DMA transfer to complete. */ - return msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz); + return msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", 5 * hz); } static int @@ -5771,7 +5771,7 @@ iwn_read_firmware_leg(struct iwn_softc * size_t hdrlen = 24; uint32_t rev; - ptr = (const uint32_t *)sc->fw_fp->data; + ptr = (const uint32_t *)fw->data; rev = le32toh(*ptr++); /* Check firmware API version. */ @@ -5819,7 +5819,7 @@ iwn_read_firmware_leg(struct iwn_softc * /* * Extract text and data sections from a TLV firmware image. */ -int +static int iwn_read_firmware_tlv(struct iwn_softc *sc, struct iwn_fw_info *fw, uint16_t alt) { @@ -5931,6 +5931,8 @@ iwn_read_firmware(struct iwn_softc *sc) device_printf(sc->sc_dev, "%s: firmware file too short: %zu bytes\n", __func__, fw->size); + firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); + sc->fw_fp = NULL; return EINVAL; } @@ -5942,6 +5944,8 @@ iwn_read_firmware(struct iwn_softc *sc) if (error != 0) { device_printf(sc->sc_dev, "%s: could not read firmware sections\n", __func__); + firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); + sc->fw_fp = NULL; return error; } @@ -5954,6 +5958,8 @@ iwn_read_firmware(struct iwn_softc *sc) (fw->boot.textsz & 3) != 0) { device_printf(sc->sc_dev, "%s: firmware sections too large\n", __func__); + firmware_put(sc->fw_fp, FIRMWARE_UNLOAD); + sc->fw_fp = NULL; return EINVAL; }