Lines Matching +full:erase +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0-only
34 if (fw->size < header_end) in efx_reflash_parse_reflash_header()
37 header = fw->data + header_offset; in efx_reflash_parse_reflash_header()
53 if (fw->size < trailer_end) in efx_reflash_parse_reflash_header()
56 trailer = fw->data + trailer_offset; in efx_reflash_parse_reflash_header()
69 *data = fw->data; in efx_reflash_parse_reflash_header()
70 *data_size = fw->size; in efx_reflash_parse_reflash_header()
100 rc = -EINVAL; in efx_reflash_partition_type()
119 fw->size < header_end) in efx_reflash_parse_snic_header()
122 header = fw->data + header_offset; in efx_reflash_parse_snic_header()
136 fw->size < payload_end) in efx_reflash_parse_snic_header()
146 header_len + payload_size - EFX_SNICIMAGE_HEADER_CRC_OFST - in efx_reflash_parse_snic_header()
155 *data = fw->data; in efx_reflash_parse_snic_header()
156 *data_size = fw->size; in efx_reflash_parse_snic_header()
175 if (fw->size < header_end) in efx_reflash_parse_snic_bundle_header()
178 header = fw->data + header_offset; in efx_reflash_parse_snic_bundle_header()
202 *data = fw->data; in efx_reflash_parse_snic_bundle_header()
203 *data_size = fw->size; in efx_reflash_parse_snic_bundle_header()
221 * prepend a header for which finding the size is a non-trivial in efx_reflash_parse_firmware_data()
235 for (header_offset = 0; header_offset < fw->size; header_offset++) { in efx_reflash_parse_firmware_data()
255 return -EINVAL; in efx_reflash_parse_firmware_data()
258 /* Limit the number of status updates during the erase or write phases */
264 /* Ideal erase chunk size. This is a balance between minimising the number of
265 * MCDI requests to erase an entire partition whilst avoiding tripping the MCDI
279 /* Partitions that cannot be erased or do not require erase before in efx_reflash_erase_partition()
280 * write are advertised with a erase alignment/sector size of zero. in efx_reflash_erase_partition()
287 return -EINVAL; in efx_reflash_erase_partition()
289 /* Erase the entire NVRAM partition a chunk at a time to avoid in efx_reflash_erase_partition()
305 chunk = min_t(size_t, partition_size - offset, chunk); in efx_reflash_erase_partition()
309 "Erase failed for NVRAM partition %#x at %#zx-%#zx", in efx_reflash_erase_partition()
310 type, offset, offset + chunk - 1); in efx_reflash_erase_partition()
331 return -EINVAL; in efx_reflash_write_partition()
337 if (efx->type->mcdi_max_ver < 2) in efx_reflash_write_partition()
356 "Write failed for NVRAM partition %#x at %#zx-%#zx", in efx_reflash_write_partition()
357 type, offset, offset + chunk - 1); in efx_reflash_write_partition()
364 size_t remaining = data_size - offset; in efx_reflash_write_partition()
375 return -ENOMEM; in efx_reflash_write_partition()
378 memset(buf + remaining, 0xFF, chunk - remaining); in efx_reflash_write_partition()
383 "Write failed for NVRAM partition %#x at %#zx-%#zx", in efx_reflash_write_partition()
384 type, offset, offset + chunk - 1); in efx_reflash_write_partition()
398 size_t data_size, size, erase_align, write_align; in efx_reflash_flash_firmware() local
399 struct devlink *devlink = efx->devlink; in efx_reflash_flash_firmware()
407 return -EOPNOTSUPP; in efx_reflash_flash_firmware()
410 mutex_lock(&efx->reflash_mutex); in efx_reflash_flash_firmware()
414 if (efx->type->flash_auto_partition) { in efx_reflash_flash_firmware()
419 data = fw->data; in efx_reflash_flash_firmware()
420 data_size = fw->size; in efx_reflash_flash_firmware()
441 rc = -EINVAL; in efx_reflash_flash_firmware()
446 rc = efx_mcdi_nvram_info(efx, type, &size, &erase_align, &write_align, in efx_reflash_flash_firmware()
459 rc = -EPERM; in efx_reflash_flash_firmware()
467 rc = -EACCES; in efx_reflash_flash_firmware()
471 if (erase_align != 0 && size % erase_align) { in efx_reflash_flash_firmware()
473 "NVRAM partition %#x has a bad partition table entry, can't erase it", in efx_reflash_flash_firmware()
475 rc = -EACCES; in efx_reflash_flash_firmware()
479 if (data_size > size) { in efx_reflash_flash_firmware()
483 rc = -EFBIG; in efx_reflash_flash_firmware()
497 rc = efx_reflash_erase_partition(efx, extack, devlink, type, size, in efx_reflash_flash_firmware()
517 mutex_unlock(&efx->reflash_mutex); in efx_reflash_flash_firmware()