Lines Matching +full:firmware +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2018-2019, Intel Corporation. */
21 /* Track the firmware response of the required reset to complete the
24 * 0 - ICE_AQC_NVM_POR_FLAG - A full power on is required
25 * 1 - ICE_AQC_NVM_PERST_FLAG - A cold PCIe reset is required
26 * 2 - ICE_AQC_NVM_EMPR_FLAG - An EMP reset is required
30 /* Track if EMP reset is available */
35 * ice_send_package_data - Send record package data to firmware
41 * this device to the firmware.
52 struct netlink_ext_ack *extack = priv->extack; in ice_send_package_data()
53 struct device *dev = context->dev; in ice_send_package_data()
54 struct ice_pf *pf = priv->pf; in ice_send_package_data()
55 struct ice_hw *hw = &pf->hw; in ice_send_package_data()
59 dev_dbg(dev, "Sending PLDM record package data to firmware\n"); in ice_send_package_data()
63 return -ENOMEM; in ice_send_package_data()
70 dev_err(dev, "Failed to send record package data to firmware, err %d aq_err %s\n", in ice_send_package_data()
71 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_send_package_data()
72 NL_SET_ERR_MSG_MOD(extack, "Failed to record package data to firmware"); in ice_send_package_data()
73 return -EIO; in ice_send_package_data()
80 * ice_check_component_response - Report firmware response to a component
87 * Check whether firmware indicates if this component can be updated. Report
91 * Returns: zero if the component can be updated, or -ECANCELED of the
92 * firmware indicates the component cannot be updated.
113 return -EINVAL; in ice_check_component_response()
116 dev_dbg(dev, "%s: firmware response 0x%x, code 0x%x\n", in ice_check_component_response()
121 /* firmware indicated this update is good to proceed */ in ice_check_component_response()
124 …dev_warn(dev, "firmware recommends not updating %s, as it may result in a downgrade. continuing an… in ice_check_component_response()
127 dev_info(dev, "firmware has rejected updating %s\n", component); in ice_check_component_response()
130 if (ice_is_recovery_mode(&pf->hw)) in ice_check_component_response()
157 dev_err(dev, "Pre-requisites for component %s have not been met\n", in ice_check_component_response()
159 NL_SET_ERR_MSG_MOD(extack, "Component pre-requisites not met"); in ice_check_component_response()
189 NL_SET_ERR_MSG_MOD(extack, "Received unexpected response code from firmware"); in ice_check_component_response()
193 return -ECANCELED; in ice_check_component_response()
197 * ice_send_component_table - Send PLDM component table to firmware
203 * firmware. Check the response to determine if the firmware indicates that
216 struct netlink_ext_ack *extack = priv->extack; in ice_send_component_table()
219 struct device *dev = context->dev; in ice_send_component_table()
220 struct ice_pf *pf = priv->pf; in ice_send_component_table()
221 struct ice_hw *hw = &pf->hw; in ice_send_component_table()
225 switch (component->identifier) { in ice_send_component_table()
231 dev_err(dev, "Unable to update due to a firmware component with unknown ID %u\n", in ice_send_component_table()
232 component->identifier); in ice_send_component_table()
233 NL_SET_ERR_MSG_MOD(extack, "Unable to update due to unknown firmware component"); in ice_send_component_table()
234 return -EOPNOTSUPP; in ice_send_component_table()
237 length = struct_size(comp_tbl, cvs, component->version_len); in ice_send_component_table()
240 return -ENOMEM; in ice_send_component_table()
242 comp_tbl->comp_class = cpu_to_le16(component->classification); in ice_send_component_table()
243 comp_tbl->comp_id = cpu_to_le16(component->identifier); in ice_send_component_table()
244 comp_tbl->comp_class_idx = FWU_COMP_CLASS_IDX_NOT_USE; in ice_send_component_table()
245 comp_tbl->comp_cmp_stamp = cpu_to_le32(component->comparison_stamp); in ice_send_component_table()
246 comp_tbl->cvs_type = component->version_type; in ice_send_component_table()
247 comp_tbl->cvs_len = component->version_len; in ice_send_component_table()
248 memcpy(comp_tbl->cvs, component->version_string, component->version_len); in ice_send_component_table()
250 dev_dbg(dev, "Sending component table to firmware:\n"); in ice_send_component_table()
259 dev_err(dev, "Failed to transfer component table to firmware, err %d aq_err %s\n", in ice_send_component_table()
260 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_send_component_table()
261 NL_SET_ERR_MSG_MOD(extack, "Failed to transfer component table to firmware"); in ice_send_component_table()
262 return -EIO; in ice_send_component_table()
265 return ice_check_component_response(pf, component->identifier, comp_response, in ice_send_component_table()
270 * ice_write_one_nvm_block - Write an NVM block and await completion response
277 * @reset_level: storage for reset level required
281 * response message from firmware.
285 * On successful return, reset level indicates the device reset required to
288 * 0 - ICE_AQC_NVM_POR_FLAG - A full power on is required
289 * 1 - ICE_AQC_NVM_PERST_FLAG - A cold PCIe reset is required
290 * 2 - ICE_AQC_NVM_EMPR_FLAG - An EMP reset is required
301 struct ice_hw *hw = &pf->hw; in ice_write_one_nvm_block()
316 ice_aq_str(hw->adminq.sq_last_status)); in ice_write_one_nvm_block()
318 return -EIO; in ice_write_one_nvm_block()
321 /* In most cases, firmware reports a write completion within a few in ice_write_one_nvm_block()
325 * firmware is slow to respond. in ice_write_one_nvm_block()
331 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_write_one_nvm_block()
332 return -EIO; in ice_write_one_nvm_block()
336 completion_module = le16_to_cpu(desc->params.nvm.module_typeid); in ice_write_one_nvm_block()
337 completion_retval = le16_to_cpu(desc->retval); in ice_write_one_nvm_block()
339 completion_offset = le16_to_cpu(desc->params.nvm.offset_low); in ice_write_one_nvm_block()
340 completion_offset |= desc->params.nvm.offset_high << 16; in ice_write_one_nvm_block()
345 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_write_one_nvm_block()
346 return -EIO; in ice_write_one_nvm_block()
352 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_write_one_nvm_block()
353 return -EIO; in ice_write_one_nvm_block()
357 …dev_err(dev, "Firmware failed to flash module 0x%02x with block of size %u at offset %u, err %s\n", in ice_write_one_nvm_block()
360 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to program flash module"); in ice_write_one_nvm_block()
361 return -EIO; in ice_write_one_nvm_block()
365 * firmware indicate the required level of reset to complete in ice_write_one_nvm_block()
366 * activation of firmware. If the firmware supports this, cache the in ice_write_one_nvm_block()
371 if (hw->dev_caps.common_cap.pcie_reset_avoidance) { in ice_write_one_nvm_block()
372 *reset_level = desc->params.nvm.cmd_flags & in ice_write_one_nvm_block()
374 dev_dbg(dev, "Firmware reported required reset level as %u\n", in ice_write_one_nvm_block()
378 …dev_dbg(dev, "Firmware doesn't support indicating required reset level. Assuming a power cycle is … in ice_write_one_nvm_block()
386 * ice_write_nvm_module - Write data to an NVM module
392 * @reset_level: storage for reset level required
424 return -ENOMEM; in ice_write_nvm_module()
429 block_size = min_t(u32, ICE_AQ_MAX_BUF_LEN, length - offset); in ice_write_nvm_module()
432 /* ice_aq_update_nvm may copy the firmware response into the in ice_write_nvm_module()
469 * ice_erase_nvm_module - Erase an NVM module and await firmware completion
476 * a completion response message from firmware.
489 struct ice_hw *hw = &pf->hw; in ice_erase_nvm_module()
506 ice_aq_str(hw->adminq.sq_last_status)); in ice_erase_nvm_module()
508 err = -EIO; in ice_erase_nvm_module()
514 …dev_err(dev, "Timed out waiting for firmware to respond with erase completion for %s (module 0x%02… in ice_erase_nvm_module()
516 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_erase_nvm_module()
521 completion_module = le16_to_cpu(desc->params.nvm.module_typeid); in ice_erase_nvm_module()
522 completion_retval = le16_to_cpu(desc->retval); in ice_erase_nvm_module()
527 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_erase_nvm_module()
528 err = -EIO; in ice_erase_nvm_module()
533 dev_err(dev, "Firmware failed to erase %s (module 0x02%x), aq_err %s\n", in ice_erase_nvm_module()
536 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to erase flash"); in ice_erase_nvm_module()
537 err = -EIO; in ice_erase_nvm_module()
555 * ice_switch_flash_banks - Tell firmware to switch NVM banks
558 * @emp_reset_available: on return, indicates if EMP reset is available
561 * Notify firmware to activate the newly written flash banks, and wait for the
562 * firmware response.
572 struct ice_hw *hw = &pf->hw; in ice_switch_flash_banks()
582 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_switch_flash_banks()
584 return -EIO; in ice_switch_flash_banks()
587 /* Newer versions of firmware have support to indicate whether an EMP in ice_switch_flash_banks()
588 * reset to reload firmware is available. For older firmware, EMP in ice_switch_flash_banks()
589 * reset is always available. in ice_switch_flash_banks()
592 if (hw->dev_caps.common_cap.reset_restrict_support) { in ice_switch_flash_banks()
594 dev_dbg(dev, "Firmware indicated that EMP reset is %s\n", in ice_switch_flash_banks()
599 dev_dbg(dev, "Firmware does not support restricting EMP reset availability\n"); in ice_switch_flash_banks()
605 dev_err(dev, "Timed out waiting for firmware to switch active flash banks, err %d\n", in ice_switch_flash_banks()
607 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_switch_flash_banks()
613 dev_err(dev, "Firmware failed to switch active flash banks aq_err %s\n", in ice_switch_flash_banks()
615 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to switch active flash banks"); in ice_switch_flash_banks()
616 return -EIO; in ice_switch_flash_banks()
623 * ice_flash_component - Flash a component of the NVM
639 struct netlink_ext_ack *extack = priv->extack; in ice_flash_component()
640 struct ice_pf *pf = priv->pf; in ice_flash_component()
647 switch (component->identifier) { in ice_flash_component()
657 reset_level = &priv->reset_level; in ice_flash_component()
668 * sending the component table to firmware. in ice_flash_component()
671 component->identifier); in ice_flash_component()
672 return -EINVAL; in ice_flash_component()
676 priv->activate_flags |= flag; in ice_flash_component()
682 return ice_write_nvm_module(pf, module, name, component->component_data, in ice_flash_component()
683 component->component_size, reset_level, in ice_flash_component()
688 * ice_finalize_update - Perform last steps to complete device update
692 * telling the firmware to switch active banks, and perform a reset of
700 struct netlink_ext_ack *extack = priv->extack; in ice_finalize_update()
701 struct ice_pf *pf = priv->pf; in ice_finalize_update()
705 /* Finally, notify firmware to activate the written NVM banks */ in ice_finalize_update()
706 err = ice_switch_flash_banks(pf, priv->activate_flags, in ice_finalize_update()
707 &priv->emp_reset_available, extack); in ice_finalize_update()
713 /* If the required reset is EMPR, but EMPR is disabled, report that in ice_finalize_update()
716 if (priv->reset_level == ICE_AQC_NVM_EMPR_FLAG && in ice_finalize_update()
717 !priv->emp_reset_available) { in ice_finalize_update()
718 …dev_dbg(ice_pf_to_dev(pf), "Firmware indicated EMP reset as sufficient, but EMP reset is disabled\… in ice_finalize_update()
719 priv->reset_level = ICE_AQC_NVM_PERST_FLAG; in ice_finalize_update()
722 switch (priv->reset_level) { in ice_finalize_update()
725 "Activate new firmware by devlink reload", in ice_finalize_update()
730 "Activate new firmware by rebooting the system", in ice_finalize_update()
736 "Activate new firmware by power cycling the system", in ice_finalize_update()
741 pf->fw_emp_reset_disabled = !priv->emp_reset_available; in ice_finalize_update()
754 * ice_op_pci_match_record - Check if a PCI device matches the record
770 struct pci_dev *pdev = to_pci_dev(context->dev); in ice_op_pci_match_record()
779 list_for_each_entry(desc, &record->descs, entry) { in ice_op_pci_match_record()
783 switch (desc->type) { in ice_op_pci_match_record()
801 value = get_unaligned_le16(desc->data); in ice_op_pci_match_record()
814 if ((id.vendor == PCI_ANY_ID || id.vendor == pdev->vendor) && in ice_op_pci_match_record()
815 (id.device == PCI_ANY_ID || id.device == pdev->device || in ice_op_pci_match_record()
818 id.subsystem_vendor == pdev->subsystem_vendor) && in ice_op_pci_match_record()
820 id.subsystem_device == pdev->subsystem_device)) in ice_op_pci_match_record()
843 * ice_get_pending_updates - Check if the component has a pending update
858 struct ice_hw *hw = &pf->hw; in ice_get_pending_updates()
863 return -ENOMEM; in ice_get_pending_updates()
865 /* Read the most recent device capabilities from firmware. Do not use in ice_get_pending_updates()
866 * the cached values in hw->dev_caps, because the pending update flag in ice_get_pending_updates()
879 if (dev_caps->common_cap.nvm_update_pending_nvm) { in ice_get_pending_updates()
884 if (dev_caps->common_cap.nvm_update_pending_orom) { in ice_get_pending_updates()
889 if (dev_caps->common_cap.nvm_update_pending_netlist) { in ice_get_pending_updates()
900 * ice_cancel_pending_update - Cancel any pending update for a component
916 struct ice_hw *hw = &pf->hw; in ice_cancel_pending_update()
943 * firmware to cancel that update by issuing the appropriate command. in ice_cancel_pending_update()
952 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_cancel_pending_update()
963 * reset is restricted. in ice_cancel_pending_update()
965 pf->fw_emp_reset_disabled = false; in ice_cancel_pending_update()
971 * ice_devlink_flash_update - Write a firmware image to the device
976 * Parse the data for a given firmware file, verifying that it is a valid PLDM
980 * to the firmware. Extract and write the flash data for each of the three
982 * firmware once the data is written to the inactive banks.
992 struct ice_hw *hw = &pf->hw; in ice_devlink_flash_update()
997 if (!params->overwrite_mask) { in ice_devlink_flash_update()
1000 } else if (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) { in ice_devlink_flash_update()
1003 } else if (params->overwrite_mask == (DEVLINK_FLASH_OVERWRITE_SETTINGS | in ice_devlink_flash_update()
1009 return -EOPNOTSUPP; in ice_devlink_flash_update()
1012 if (!hw->dev_caps.common_cap.nvm_unified_update && !ice_is_recovery_mode(hw)) { in ice_devlink_flash_update()
1013 NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update"); in ice_devlink_flash_update()
1014 return -EOPNOTSUPP; in ice_devlink_flash_update()
1019 if (params->component && strcmp(params->component, "fw.mgmt") == 0) { in ice_devlink_flash_update()
1022 } else if (params->component) { in ice_devlink_flash_update()
1023 return -EOPNOTSUPP; in ice_devlink_flash_update()
1027 if (hw->mac_type == ICE_MAC_GENERIC) in ice_devlink_flash_update()
1045 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_devlink_flash_update()
1050 err = pldmfw_flash_image(&priv.context, params->fw); in ice_devlink_flash_update()
1051 if (err == -ENOENT) { in ice_devlink_flash_update()
1052 dev_err(dev, "Firmware image has no record matching this device\n"); in ice_devlink_flash_update()
1053 NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device"); in ice_devlink_flash_update()