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
296 struct ice_hw *hw = &pf->hw; in ice_write_one_nvm_block()
311 ice_aq_str(hw->adminq.sq_last_status)); in ice_write_one_nvm_block()
313 return -EIO; in ice_write_one_nvm_block()
316 /* In most cases, firmware reports a write completion within a few in ice_write_one_nvm_block()
320 * firmware is slow to respond. in ice_write_one_nvm_block()
326 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_write_one_nvm_block()
327 return -EIO; in ice_write_one_nvm_block()
331 completion_module = le16_to_cpu(desc->params.nvm.module_typeid); in ice_write_one_nvm_block()
332 completion_retval = le16_to_cpu(desc->retval); in ice_write_one_nvm_block()
334 completion_offset = le16_to_cpu(desc->params.nvm.offset_low); in ice_write_one_nvm_block()
335 completion_offset |= desc->params.nvm.offset_high << 16; in ice_write_one_nvm_block()
340 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_write_one_nvm_block()
341 return -EIO; in ice_write_one_nvm_block()
347 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_write_one_nvm_block()
348 return -EIO; in ice_write_one_nvm_block()
352 …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()
355 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to program flash module"); in ice_write_one_nvm_block()
356 return -EIO; in ice_write_one_nvm_block()
360 * firmware indicate the required level of reset to complete in ice_write_one_nvm_block()
361 * activation of firmware. If the firmware supports this, cache the in ice_write_one_nvm_block()
366 if (hw->dev_caps.common_cap.pcie_reset_avoidance) { in ice_write_one_nvm_block()
367 *reset_level = desc->params.nvm.cmd_flags & in ice_write_one_nvm_block()
369 dev_dbg(dev, "Firmware reported required reset level as %u\n", in ice_write_one_nvm_block()
373 …dev_dbg(dev, "Firmware doesn't support indicating required reset level. Assuming a power cycle is … in ice_write_one_nvm_block()
381 * ice_write_nvm_module - Write data to an NVM module
387 * @reset_level: storage for reset level required
419 return -ENOMEM; in ice_write_nvm_module()
424 block_size = min_t(u32, ICE_AQ_MAX_BUF_LEN, length - offset); in ice_write_nvm_module()
427 /* ice_aq_update_nvm may copy the firmware response into the in ice_write_nvm_module()
464 * ice_erase_nvm_module - Erase an NVM module and await firmware completion
471 * a completion response message from firmware.
484 struct ice_hw *hw = &pf->hw; in ice_erase_nvm_module()
501 ice_aq_str(hw->adminq.sq_last_status)); in ice_erase_nvm_module()
503 err = -EIO; in ice_erase_nvm_module()
509 …dev_err(dev, "Timed out waiting for firmware to respond with erase completion for %s (module 0x%02… in ice_erase_nvm_module()
511 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_erase_nvm_module()
516 completion_module = le16_to_cpu(desc->params.nvm.module_typeid); in ice_erase_nvm_module()
517 completion_retval = le16_to_cpu(desc->retval); in ice_erase_nvm_module()
522 NL_SET_ERR_MSG_MOD(extack, "Unexpected firmware response"); in ice_erase_nvm_module()
523 err = -EIO; in ice_erase_nvm_module()
528 dev_err(dev, "Firmware failed to erase %s (module 0x02%x), aq_err %s\n", in ice_erase_nvm_module()
531 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to erase flash"); in ice_erase_nvm_module()
532 err = -EIO; in ice_erase_nvm_module()
550 * ice_switch_flash_banks - Tell firmware to switch NVM banks
553 * @emp_reset_available: on return, indicates if EMP reset is available
556 * Notify firmware to activate the newly written flash banks, and wait for the
557 * firmware response.
567 struct ice_hw *hw = &pf->hw; in ice_switch_flash_banks()
577 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_switch_flash_banks()
579 return -EIO; in ice_switch_flash_banks()
582 /* Newer versions of firmware have support to indicate whether an EMP in ice_switch_flash_banks()
583 * reset to reload firmware is available. For older firmware, EMP in ice_switch_flash_banks()
584 * reset is always available. in ice_switch_flash_banks()
587 if (hw->dev_caps.common_cap.reset_restrict_support) { in ice_switch_flash_banks()
589 dev_dbg(dev, "Firmware indicated that EMP reset is %s\n", in ice_switch_flash_banks()
594 dev_dbg(dev, "Firmware does not support restricting EMP reset availability\n"); in ice_switch_flash_banks()
600 dev_err(dev, "Timed out waiting for firmware to switch active flash banks, err %d\n", in ice_switch_flash_banks()
602 NL_SET_ERR_MSG_MOD(extack, "Timed out waiting for firmware"); in ice_switch_flash_banks()
608 dev_err(dev, "Firmware failed to switch active flash banks aq_err %s\n", in ice_switch_flash_banks()
610 NL_SET_ERR_MSG_MOD(extack, "Firmware failed to switch active flash banks"); in ice_switch_flash_banks()
611 return -EIO; in ice_switch_flash_banks()
618 * ice_flash_component - Flash a component of the NVM
634 struct netlink_ext_ack *extack = priv->extack; in ice_flash_component()
635 struct ice_pf *pf = priv->pf; in ice_flash_component()
642 switch (component->identifier) { in ice_flash_component()
652 reset_level = &priv->reset_level; in ice_flash_component()
663 * sending the component table to firmware. in ice_flash_component()
666 component->identifier); in ice_flash_component()
667 return -EINVAL; in ice_flash_component()
671 priv->activate_flags |= flag; in ice_flash_component()
677 return ice_write_nvm_module(pf, module, name, component->component_data, in ice_flash_component()
678 component->component_size, reset_level, in ice_flash_component()
683 * ice_finalize_update - Perform last steps to complete device update
687 * telling the firmware to switch active banks, and perform a reset of
695 struct netlink_ext_ack *extack = priv->extack; in ice_finalize_update()
696 struct ice_pf *pf = priv->pf; in ice_finalize_update()
700 /* Finally, notify firmware to activate the written NVM banks */ in ice_finalize_update()
701 err = ice_switch_flash_banks(pf, priv->activate_flags, in ice_finalize_update()
702 &priv->emp_reset_available, extack); in ice_finalize_update()
708 /* If the required reset is EMPR, but EMPR is disabled, report that in ice_finalize_update()
711 if (priv->reset_level == ICE_AQC_NVM_EMPR_FLAG && in ice_finalize_update()
712 !priv->emp_reset_available) { in ice_finalize_update()
713 …dev_dbg(ice_pf_to_dev(pf), "Firmware indicated EMP reset as sufficient, but EMP reset is disabled\… in ice_finalize_update()
714 priv->reset_level = ICE_AQC_NVM_PERST_FLAG; in ice_finalize_update()
717 switch (priv->reset_level) { in ice_finalize_update()
720 "Activate new firmware by devlink reload", in ice_finalize_update()
725 "Activate new firmware by rebooting the system", in ice_finalize_update()
731 "Activate new firmware by power cycling the system", in ice_finalize_update()
736 pf->fw_emp_reset_disabled = !priv->emp_reset_available; in ice_finalize_update()
749 * ice_op_pci_match_record - Check if a PCI device matches the record
765 struct pci_dev *pdev = to_pci_dev(context->dev); in ice_op_pci_match_record()
774 list_for_each_entry(desc, &record->descs, entry) { in ice_op_pci_match_record()
778 switch (desc->type) { in ice_op_pci_match_record()
796 value = get_unaligned_le16(desc->data); in ice_op_pci_match_record()
809 if ((id.vendor == PCI_ANY_ID || id.vendor == pdev->vendor) && in ice_op_pci_match_record()
810 (id.device == PCI_ANY_ID || id.device == pdev->device || in ice_op_pci_match_record()
813 id.subsystem_vendor == pdev->subsystem_vendor) && in ice_op_pci_match_record()
815 id.subsystem_device == pdev->subsystem_device)) in ice_op_pci_match_record()
838 * ice_get_pending_updates - Check if the component has a pending update
853 struct ice_hw *hw = &pf->hw; in ice_get_pending_updates()
858 return -ENOMEM; in ice_get_pending_updates()
860 /* Read the most recent device capabilities from firmware. Do not use in ice_get_pending_updates()
861 * the cached values in hw->dev_caps, because the pending update flag in ice_get_pending_updates()
874 if (dev_caps->common_cap.nvm_update_pending_nvm) { in ice_get_pending_updates()
879 if (dev_caps->common_cap.nvm_update_pending_orom) { in ice_get_pending_updates()
884 if (dev_caps->common_cap.nvm_update_pending_netlist) { in ice_get_pending_updates()
895 * ice_cancel_pending_update - Cancel any pending update for a component
911 struct ice_hw *hw = &pf->hw; in ice_cancel_pending_update()
938 * firmware to cancel that update by issuing the appropriate command. in ice_cancel_pending_update()
947 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_cancel_pending_update()
958 * reset is restricted. in ice_cancel_pending_update()
960 pf->fw_emp_reset_disabled = false; in ice_cancel_pending_update()
966 * ice_devlink_flash_update - Write a firmware image to the device
971 * Parse the data for a given firmware file, verifying that it is a valid PLDM
975 * to the firmware. Extract and write the flash data for each of the three
977 * firmware once the data is written to the inactive banks.
987 struct ice_hw *hw = &pf->hw; in ice_devlink_flash_update()
992 if (!params->overwrite_mask) { in ice_devlink_flash_update()
995 } else if (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) { in ice_devlink_flash_update()
998 } else if (params->overwrite_mask == (DEVLINK_FLASH_OVERWRITE_SETTINGS | in ice_devlink_flash_update()
1004 return -EOPNOTSUPP; in ice_devlink_flash_update()
1007 if (!hw->dev_caps.common_cap.nvm_unified_update) { in ice_devlink_flash_update()
1008 NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update"); in ice_devlink_flash_update()
1009 return -EOPNOTSUPP; in ice_devlink_flash_update()
1015 if (hw->mac_type == ICE_MAC_GENERIC) in ice_devlink_flash_update()
1033 err, ice_aq_str(hw->adminq.sq_last_status)); in ice_devlink_flash_update()
1038 err = pldmfw_flash_image(&priv.context, params->fw); in ice_devlink_flash_update()
1039 if (err == -ENOENT) { in ice_devlink_flash_update()
1040 dev_err(dev, "Firmware image has no record matching this device\n"); in ice_devlink_flash_update()
1041 NL_SET_ERR_MSG_MOD(extack, "Firmware image has no record matching this device"); in ice_devlink_flash_update()