Lines Matching +full:firmware +full:- +full:reset
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2018-2019, Intel Corporation. */
20 /* Track the firmware response of the required reset to complete the
23 * 0 - ICE_AQC_NVM_POR_FLAG - A full power on is required
24 * 1 - ICE_AQC_NVM_PERST_FLAG - A cold PCIe reset is required
25 * 2 - ICE_AQC_NVM_EMPR_FLAG - An EMP reset is required
29 /* Track if EMP reset is available */
34 * ice_send_package_data - Send record package data to firmware
40 * this device to the firmware.
51 struct netlink_ext_ack *extack = priv->extack; in ice_send_package_data()
52 struct device *dev = context->dev; in ice_send_package_data()
53 struct ice_pf *pf = priv->pf; in ice_send_package_data()
54 struct ice_hw *hw = &pf->hw; in ice_send_package_data()
58 dev_dbg(dev, "Sending PLDM record package data to firmware\n"); in ice_send_package_data()
62 return -ENOMEM; in ice_send_package_data()
69 dev_err(dev, "Failed to send record package data to firmware, err %d aq_err %s\n", in ice_send_package_data()
70 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_send_package_data()
71 NL_SET_ERR_MSG_MOD(extack, "Failed to record package data to firmware"); in ice_send_package_data()
72 return -EIO; in ice_send_package_data()
79 * ice_check_component_response - Report firmware response to a component
86 * Check whether firmware indicates if this component can be updated. Report
90 * Returns: zero if the component can be updated, or -ECANCELED of the
91 * firmware indicates the component cannot be updated.
112 return -EINVAL; in ice_check_component_response()
115 dev_dbg(dev, "%s: firmware response 0x%x, code 0x%x\n", in ice_check_component_response()
120 /* firmware indicated this update is good to proceed */ in ice_check_component_response()
123 …dev_warn(dev, "firmware recommends not updating %s, as it may result in a downgrade. continuing an… in ice_check_component_response()
126 dev_info(dev, "firmware has rejected updating %s\n", component); in ice_check_component_response()
152 dev_err(dev, "Pre-requisites for component %s have not been met\n", in ice_check_component_response()
154 NL_SET_ERR_MSG_MOD(extack, "Component pre-requisites not met"); in ice_check_component_response()
184 NL_SET_ERR_MSG_MOD(extack, "Received unexpected response code from firmware"); in ice_check_component_response()
188 return -ECANCELED; in ice_check_component_response()
192 * ice_send_component_table - Send PLDM component table to firmware
198 * firmware. Check the response to determine if the firmware indicates that
211 struct netlink_ext_ack *extack = priv->extack; in ice_send_component_table()
214 struct device *dev = context->dev; in ice_send_component_table()
215 struct ice_pf *pf = priv->pf; in ice_send_component_table()
216 struct ice_hw *hw = &pf->hw; in ice_send_component_table()
220 switch (component->identifier) { in ice_send_component_table()
226 dev_err(dev, "Unable to update due to a firmware component with unknown ID %u\n", in ice_send_component_table()
227 component->identifier); in ice_send_component_table()
228 NL_SET_ERR_MSG_MOD(extack, "Unable to update due to unknown firmware component"); in ice_send_component_table()
229 return -EOPNOTSUPP; in ice_send_component_table()
232 length = struct_size(comp_tbl, cvs, component->version_len); in ice_send_component_table()
235 return -ENOMEM; in ice_send_component_table()
237 comp_tbl->comp_class = cpu_to_le16(component->classification); in ice_send_component_table()
238 comp_tbl->comp_id = cpu_to_le16(component->identifier); in ice_send_component_table()
239 comp_tbl->comp_class_idx = FWU_COMP_CLASS_IDX_NOT_USE; in ice_send_component_table()
240 comp_tbl->comp_cmp_stamp = cpu_to_le32(component->comparison_stamp); in ice_send_component_table()
241 comp_tbl->cvs_type = component->version_type; in ice_send_component_table()
242 comp_tbl->cvs_len = component->version_len; in ice_send_component_table()
243 memcpy(comp_tbl->cvs, component->version_string, component->version_len); in ice_send_component_table()
245 dev_dbg(dev, "Sending component table to firmware:\n"); in ice_send_component_table()
254 dev_err(dev, "Failed to transfer component table to firmware, err %d aq_err %s\n", in ice_send_component_table()
255 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_send_component_table()
256 NL_SET_ERR_MSG_MOD(extack, "Failed to transfer component table to firmware"); in ice_send_component_table()
257 return -EIO; in ice_send_component_table()
260 return ice_check_component_response(pf, component->identifier, comp_response, in ice_send_component_table()
265 * ice_write_one_nvm_block - Write an NVM block and await completion response
272 * @reset_level: storage for reset level required
276 * response message from firmware.
280 * On successful return, reset level indicates the device reset required to
283 * 0 - ICE_AQC_NVM_POR_FLAG - A full power on is required
284 * 1 - ICE_AQC_NVM_PERST_FLAG - A cold PCIe reset is required
285 * 2 - ICE_AQC_NVM_EMPR_FLAG - An EMP reset is required
297 struct ice_hw *hw = &pf->hw; in ice_write_one_nvm_block()
312 ice_aq_str(hw->adminq.sq_last_status)); in ice_write_one_nvm_block()
314 return -EIO; in ice_write_one_nvm_block()
317 /* In most cases, firmware reports a write completion within a few in ice_write_one_nvm_block()
321 * firmware is slow to respond. in ice_write_one_nvm_block()
327 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_write_one_nvm_block()
328 return -EIO; in ice_write_one_nvm_block()
332 completion_module = le16_to_cpu(desc->params.nvm.module_typeid); in ice_write_one_nvm_block()
333 completion_retval = le16_to_cpu(desc->retval); in ice_write_one_nvm_block()
335 completion_offset = le16_to_cpu(desc->params.nvm.offset_low); in ice_write_one_nvm_block()
336 completion_offset |= desc->params.nvm.offset_high << 16; in ice_write_one_nvm_block()
341 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_write_one_nvm_block()
342 return -EIO; in ice_write_one_nvm_block()
348 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_write_one_nvm_block()
349 return -EIO; in ice_write_one_nvm_block()
353 …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()
356 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to program flash module"); in ice_write_one_nvm_block()
357 return -EIO; in ice_write_one_nvm_block()
361 * firmware indicate the required level of reset to complete in ice_write_one_nvm_block()
362 * activation of firmware. If the firmware supports this, cache the in ice_write_one_nvm_block()
367 if (hw->dev_caps.common_cap.pcie_reset_avoidance) { in ice_write_one_nvm_block()
368 *reset_level = desc->params.nvm.cmd_flags & in ice_write_one_nvm_block()
370 dev_dbg(dev, "Firmware reported required reset level as %u\n", in ice_write_one_nvm_block()
374 …dev_dbg(dev, "Firmware doesn't support indicating required reset level. Assuming a power cycle is … in ice_write_one_nvm_block()
382 * ice_write_nvm_module - Write data to an NVM module
388 * @reset_level: storage for reset level required
420 return -ENOMEM; in ice_write_nvm_module()
425 block_size = min_t(u32, ICE_AQ_MAX_BUF_LEN, length - offset); in ice_write_nvm_module()
428 /* ice_aq_update_nvm may copy the firmware response into the in ice_write_nvm_module()
465 * ice_erase_nvm_module - Erase an NVM module and await firmware completion
472 * a completion response message from firmware.
485 struct ice_hw *hw = &pf->hw; in ice_erase_nvm_module()
502 ice_aq_str(hw->adminq.sq_last_status)); in ice_erase_nvm_module()
504 err = -EIO; in ice_erase_nvm_module()
510 …dev_err(dev, "Timed out waiting for firmware to respond with erase completion for %s (module 0x%02… in ice_erase_nvm_module()
512 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_erase_nvm_module()
517 completion_module = le16_to_cpu(desc->params.nvm.module_typeid); in ice_erase_nvm_module()
518 completion_retval = le16_to_cpu(desc->retval); in ice_erase_nvm_module()
523 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_erase_nvm_module()
524 err = -EIO; in ice_erase_nvm_module()
529 dev_err(dev, "Firmware failed to erase %s (module 0x02%x), aq_err %s\n", in ice_erase_nvm_module()
532 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to erase flash"); in ice_erase_nvm_module()
533 err = -EIO; in ice_erase_nvm_module()
551 * ice_switch_flash_banks - Tell firmware to switch NVM banks
554 * @emp_reset_available: on return, indicates if EMP reset is available
557 * Notify firmware to activate the newly written flash banks, and wait for the
558 * firmware response.
568 struct ice_hw *hw = &pf->hw; in ice_switch_flash_banks()
578 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_switch_flash_banks()
580 return -EIO; in ice_switch_flash_banks()
583 /* Newer versions of firmware have support to indicate whether an EMP in ice_switch_flash_banks()
584 * reset to reload firmware is available. For older firmware, EMP in ice_switch_flash_banks()
585 * reset is always available. in ice_switch_flash_banks()
588 if (hw->dev_caps.common_cap.reset_restrict_support) { in ice_switch_flash_banks()
590 dev_dbg(dev, "Firmware indicated that EMP reset is %s\n", in ice_switch_flash_banks()
595 dev_dbg(dev, "Firmware does not support restricting EMP reset availability\n"); in ice_switch_flash_banks()
601 dev_err(dev, "Timed out waiting for firmware to switch active flash banks, err %d\n", in ice_switch_flash_banks()
603 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_switch_flash_banks()
609 dev_err(dev, "Firmware failed to switch active flash banks aq_err %s\n", in ice_switch_flash_banks()
611 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to switch active flash banks"); in ice_switch_flash_banks()
612 return -EIO; in ice_switch_flash_banks()
619 * ice_flash_component - Flash a component of the NVM
635 struct netlink_ext_ack *extack = priv->extack; in ice_flash_component()
636 struct ice_pf *pf = priv->pf; in ice_flash_component()
643 switch (component->identifier) { in ice_flash_component()
653 reset_level = &priv->reset_level; in ice_flash_component()
664 * sending the component table to firmware. in ice_flash_component()
667 component->identifier); in ice_flash_component()
668 return -EINVAL; in ice_flash_component()
672 priv->activate_flags |= flag; in ice_flash_component()
678 return ice_write_nvm_module(pf, module, name, component->component_data, in ice_flash_component()
679 component->component_size, reset_level, in ice_flash_component()
684 * ice_finalize_update - Perform last steps to complete device update
688 * telling the firmware to switch active banks, and perform a reset of
696 struct netlink_ext_ack *extack = priv->extack; in ice_finalize_update()
697 struct ice_pf *pf = priv->pf; in ice_finalize_update()
701 /* Finally, notify firmware to activate the written NVM banks */ in ice_finalize_update()
702 err = ice_switch_flash_banks(pf, priv->activate_flags, in ice_finalize_update()
703 &priv->emp_reset_available, extack); in ice_finalize_update()
709 /* If the required reset is EMPR, but EMPR is disabled, report that in ice_finalize_update()
712 if (priv->reset_level == ICE_AQC_NVM_EMPR_FLAG && in ice_finalize_update()
713 !priv->emp_reset_available) { in ice_finalize_update()
714 …dev_dbg(ice_pf_to_dev(pf), "Firmware indicated EMP reset as sufficient, but EMP reset is disabled\… in ice_finalize_update()
715 priv->reset_level = ICE_AQC_NVM_PERST_FLAG; in ice_finalize_update()
718 switch (priv->reset_level) { in ice_finalize_update()
721 "Activate new firmware by devlink reload", in ice_finalize_update()
726 "Activate new firmware by rebooting the system", in ice_finalize_update()
732 "Activate new firmware by power cycling the system", in ice_finalize_update()
737 pf->fw_emp_reset_disabled = !priv->emp_reset_available; in ice_finalize_update()
750 * ice_op_pci_match_record - Check if a PCI device matches the record
766 struct pci_dev *pdev = to_pci_dev(context->dev); in ice_op_pci_match_record()
775 list_for_each_entry(desc, &record->descs, entry) { in ice_op_pci_match_record()
779 switch (desc->type) { in ice_op_pci_match_record()
797 value = get_unaligned_le16(desc->data); in ice_op_pci_match_record()
810 if ((id.vendor == PCI_ANY_ID || id.vendor == pdev->vendor) && in ice_op_pci_match_record()
811 (id.device == PCI_ANY_ID || id.device == pdev->device || in ice_op_pci_match_record()
814 id.subsystem_vendor == pdev->subsystem_vendor) && in ice_op_pci_match_record()
816 id.subsystem_device == pdev->subsystem_device)) in ice_op_pci_match_record()
839 * ice_get_pending_updates - Check if the component has a pending update
854 struct ice_hw *hw = &pf->hw; in ice_get_pending_updates()
859 return -ENOMEM; in ice_get_pending_updates()
861 /* Read the most recent device capabilities from firmware. Do not use in ice_get_pending_updates()
862 * the cached values in hw->dev_caps, because the pending update flag in ice_get_pending_updates()
875 if (dev_caps->common_cap.nvm_update_pending_nvm) { in ice_get_pending_updates()
880 if (dev_caps->common_cap.nvm_update_pending_orom) { in ice_get_pending_updates()
885 if (dev_caps->common_cap.nvm_update_pending_netlist) { in ice_get_pending_updates()
896 * ice_cancel_pending_update - Cancel any pending update for a component
912 struct ice_hw *hw = &pf->hw; in ice_cancel_pending_update()
939 * firmware to cancel that update by issuing the appropriate command. in ice_cancel_pending_update()
948 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_cancel_pending_update()
959 * reset is restricted. in ice_cancel_pending_update()
961 pf->fw_emp_reset_disabled = false; in ice_cancel_pending_update()
967 * ice_devlink_flash_update - Write a firmware image to the device
972 * Parse the data for a given firmware file, verifying that it is a valid PLDM
976 * to the firmware. Extract and write the flash data for each of the three
978 * firmware once the data is written to the inactive banks.
988 struct ice_hw *hw = &pf->hw; in ice_devlink_flash_update()
993 if (!params->overwrite_mask) { in ice_devlink_flash_update()
996 } else if (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) { in ice_devlink_flash_update()
999 } else if (params->overwrite_mask == (DEVLINK_FLASH_OVERWRITE_SETTINGS | in ice_devlink_flash_update()
1005 return -EOPNOTSUPP; in ice_devlink_flash_update()
1008 if (!hw->dev_caps.common_cap.nvm_unified_update) { in ice_devlink_flash_update()
1009 NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update"); in ice_devlink_flash_update()
1010 return -EOPNOTSUPP; in ice_devlink_flash_update()
1016 if (hw->mac_type == ICE_MAC_GENERIC) in ice_devlink_flash_update()
1034 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_devlink_flash_update()
1039 err = pldmfw_flash_image(&priv.context, params->fw); in ice_devlink_flash_update()
1040 if (err == -ENOENT) { in ice_devlink_flash_update()
1041 dev_err(dev, "Firmware image has no record matching this device\n"); in ice_devlink_flash_update()
1042 NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device"); in ice_devlink_flash_update()