From owner-svn-src-head@freebsd.org Sat Dec 5 17:11:15 2015 Return-Path: Delivered-To: svn-src-head@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 B5E4BA42E99; Sat, 5 Dec 2015 17:11:15 +0000 (UTC) (envelope-from arybchik@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 80EA21130; Sat, 5 Dec 2015 17:11:15 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB5HBEMc036052; Sat, 5 Dec 2015 17:11:14 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB5HBEZp036051; Sat, 5 Dec 2015 17:11:14 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201512051711.tB5HBEZp036051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 5 Dec 2015 17:11:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291862 - head/sys/dev/sfxge/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 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, 05 Dec 2015 17:11:15 -0000 Author: arybchik Date: Sat Dec 5 17:11:14 2015 New Revision: 291862 URL: https://svnweb.freebsd.org/changeset/base/291862 Log: sfxge: erase nvram partitions in chunks equal to their erase size The erase size is reported by the nvram info command. Submitted by: Paul Fox Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4386 Modified: head/sys/dev/sfxge/common/hunt_nvram.c Modified: head/sys/dev/sfxge/common/hunt_nvram.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_nvram.c Sat Dec 5 17:01:38 2015 (r291861) +++ head/sys/dev/sfxge/common/hunt_nvram.c Sat Dec 5 17:11:14 2015 (r291862) @@ -1363,12 +1363,37 @@ hunt_nvram_partn_erase( __in size_t size) { efx_rc_t rc; + uint32_t erase_size; - if ((rc = efx_mcdi_nvram_erase(enp, partn, offset, size)) != 0) + if ((rc = efx_mcdi_nvram_info(enp, partn, NULL, NULL, + &erase_size, NULL)) != 0) goto fail1; + if (erase_size == 0) { + if ((rc = efx_mcdi_nvram_erase(enp, partn, offset, size)) != 0) + goto fail2; + } else { + if (size % erase_size != 0) { + rc = EINVAL; + goto fail3; + } + while (size > 0) { + if ((rc = efx_mcdi_nvram_erase(enp, partn, offset, + erase_size)) != 0) + goto fail4; + offset += erase_size; + size -= erase_size; + } + } + return (0); +fail4: + EFSYS_PROBE(fail4); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc);