Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Dec 2015 17:11:14 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r291862 - head/sys/dev/sfxge/common
Message-ID:  <201512051711.tB5HBEZp036051@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <pfox at solarflare.com>
  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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512051711.tB5HBEZp036051>