From owner-svn-src-head@FreeBSD.ORG Thu Jan 13 23:15:10 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F250A1065693; Thu, 13 Jan 2011 23:15:09 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E15FA8FC0C; Thu, 13 Jan 2011 23:15:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0DNF9MN066975; Thu, 13 Jan 2011 23:15:09 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0DNF9dM066973; Thu, 13 Jan 2011 23:15:09 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201101132315.p0DNF9dM066973@svn.freebsd.org> From: Pyun YongHyeon Date: Thu, 13 Jan 2011 23:15:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217385 - head/sys/dev/re X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 13 Jan 2011 23:15:10 -0000 Author: yongari Date: Thu Jan 13 23:15:09 2011 New Revision: 217385 URL: http://svn.freebsd.org/changeset/base/217385 Log: If driver is not able to allocate RX buffer, do not start driver. While I'm here move RX buffer allocation and descriptor initialization up to not touch hardware registers in case of RX buffer allocation failure. Modified: head/sys/dev/re/if_re.c Modified: head/sys/dev/re/if_re.c ============================================================================== --- head/sys/dev/re/if_re.c Thu Jan 13 23:00:28 2011 (r217384) +++ head/sys/dev/re/if_re.c Thu Jan 13 23:15:09 2011 (r217385) @@ -2622,6 +2622,16 @@ re_init_locked(struct rl_softc *sc) re_reset(sc); /* + * For C+ mode, initialize the RX descriptors and mbufs. + */ + if (re_rx_list_init(sc) != 0) { + device_printf(sc->rl_dev, "no memory for RX buffers\n"); + re_stop(sc); + return; + } + re_tx_list_init(sc); + + /* * Enable C+ RX and TX mode, as well as VLAN stripping and * RX checksum offload. We must configure the C+ register * before all others. @@ -2673,12 +2683,6 @@ re_init_locked(struct rl_softc *sc) CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF); /* - * For C+ mode, initialize the RX descriptors and mbufs. - */ - re_rx_list_init(sc); - re_tx_list_init(sc); - - /* * Load the addresses of the RX and TX lists into the chip. */