diff options
author | arybchik <arybchik@FreeBSD.org> | 2015-12-05 17:11:14 +0000 |
---|---|---|
committer | arybchik <arybchik@FreeBSD.org> | 2015-12-05 17:11:14 +0000 |
commit | 3e90d8ef55f98cd3a8a0506f1ff10d579b1cc5e8 (patch) | |
tree | 1c8740caf51731d0afa8e41eb362a9796b59da6b | |
parent | 55c3b70608f1e860b76ccbe9f9376dff70fe9056 (diff) | |
download | FreeBSD-src-3e90d8ef55f98cd3a8a0506f1ff10d579b1cc5e8.zip FreeBSD-src-3e90d8ef55f98cd3a8a0506f1ff10d579b1cc5e8.tar.gz |
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
-rw-r--r-- | sys/dev/sfxge/common/hunt_nvram.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/dev/sfxge/common/hunt_nvram.c b/sys/dev/sfxge/common/hunt_nvram.c index c32f8ab..341a31b 100644 --- a/sys/dev/sfxge/common/hunt_nvram.c +++ b/sys/dev/sfxge/common/hunt_nvram.c @@ -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); |