From owner-svn-src-all@freebsd.org Mon May 16 04:03:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70289B3C56F; Mon, 16 May 2016 04:03:44 +0000 (UTC) (envelope-from adrian@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 mx1.freebsd.org (Postfix) with ESMTPS id 291D01E3E; Mon, 16 May 2016 04:03:44 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4G43hf8017056; Mon, 16 May 2016 04:03:43 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4G43hK5017055; Mon, 16 May 2016 04:03:43 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201605160403.u4G43hK5017055@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Mon, 16 May 2016 04:03:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299891 - head/sys/dev/bwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2016 04:03:44 -0000 Author: adrian Date: Mon May 16 04:03:43 2016 New Revision: 299891 URL: https://svnweb.freebsd.org/changeset/base/299891 Log: [bwn] use contigmalloc to allocate descriptors. We can't assume malloc() returns physically contiguous memory. Submitted by: Imre Vadasz Obtained from: DragonflyBSD Modified: head/sys/dev/bwn/if_bwn.c Modified: head/sys/dev/bwn/if_bwn.c ============================================================================== --- head/sys/dev/bwn/if_bwn.c Mon May 16 03:56:24 2016 (r299890) +++ head/sys/dev/bwn/if_bwn.c Mon May 16 04:03:43 2016 (r299891) @@ -2675,11 +2675,15 @@ bwn_dma_ringsetup(struct bwn_mac *mac, i KASSERT(BWN_TXRING_SLOTS % BWN_TX_SLOTS_PER_FRAME == 0, ("%s:%d: fail", __func__, __LINE__)); - dr->dr_txhdr_cache = - malloc((dr->dr_numslots / BWN_TX_SLOTS_PER_FRAME) * - BWN_HDRSIZE(mac), M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT(dr->dr_txhdr_cache != NULL, - ("%s:%d: fail", __func__, __LINE__)); + dr->dr_txhdr_cache = contigmalloc( + (dr->dr_numslots / BWN_TX_SLOTS_PER_FRAME) * + BWN_HDRSIZE(mac), M_DEVBUF, M_ZERO, + 0, BUS_SPACE_MAXADDR, 8, 0); + if (dr->dr_txhdr_cache == NULL) { + device_printf(sc->sc_dev, + "can't allocate TX header DMA memory\n"); + goto fail1; + } /* * Create TX ring DMA stuffs @@ -2698,7 +2702,7 @@ bwn_dma_ringsetup(struct bwn_mac *mac, i if (error) { device_printf(sc->sc_dev, "can't create TX ring DMA tag: TODO frees\n"); - goto fail1; + goto fail2; } for (i = 0; i < dr->dr_numslots; i += 2) { @@ -2713,7 +2717,7 @@ bwn_dma_ringsetup(struct bwn_mac *mac, i if (error) { device_printf(sc->sc_dev, "can't create RX buf DMA map\n"); - goto fail1; + goto fail2; } dr->getdesc(dr, i + 1, &desc, &mt); @@ -2727,7 +2731,7 @@ bwn_dma_ringsetup(struct bwn_mac *mac, i if (error) { device_printf(sc->sc_dev, "can't create RX buf DMA map\n"); - goto fail1; + goto fail2; } } } else { @@ -2767,7 +2771,11 @@ bwn_dma_ringsetup(struct bwn_mac *mac, i return (dr); fail2: - free(dr->dr_txhdr_cache, M_DEVBUF); + if (dr->dr_txhdr_cache != NULL) { + contigfree(dr->dr_txhdr_cache, + (dr->dr_numslots / BWN_TX_SLOTS_PER_FRAME) * + BWN_HDRSIZE(mac), M_DEVBUF); + } fail1: free(dr->dr_meta, M_DEVBUF); fail0: @@ -2785,7 +2793,11 @@ bwn_dma_ringfree(struct bwn_dma_ring **d bwn_dma_free_descbufs(*dr); bwn_dma_free_ringmemory(*dr); - free((*dr)->dr_txhdr_cache, M_DEVBUF); + if ((*dr)->dr_txhdr_cache != NULL) { + contigfree((*dr)->dr_txhdr_cache, + ((*dr)->dr_numslots / BWN_TX_SLOTS_PER_FRAME) * + BWN_HDRSIZE((*dr)->dr_mac), M_DEVBUF); + } free((*dr)->dr_meta, M_DEVBUF); free(*dr, M_DEVBUF);