ice: reduce time to read Option ROM CIVD data
Subsystems (6)
PATCH v7 1/2 ice: reduce time to read Option ROM CIVD data
During probe and device reset, the ice driver reads some data from the NVM image as part of ice_init_nvm. Part of this data includes a section of the Option ROM which contains version information.
The function ice_get_orom_civd_data is used to locate the '$CIV' data section of the Option ROM.
Timing of ice_probe and ice_rebuild indicate that the ice_get_orom_civd_data function takes about 10 seconds to finish executing.
The function locates the section by scanning the Option ROM every 512 bytes. This requires a significant number of NVM read accesses, since the Option ROM bank is 500KB. In the worst case it would take about 1000 reads. Worse, all PFs serialize this operation during reload because of acquiring the NVM semaphore.
The CIVD section is located at the end of the Option ROM image data. Unfortunately, the driver has no easy method to determine the offset manually. Practical experiments have shown that the data could be at a variety of locations, so simply reversing the scanning order is not sufficient to reduce the overall read time.
Instead, copy the entire contents of the Option ROM into memory. This allows reading the data using 4Kb pages instead of 512 bytes at a time. This reduces the total number of firmware commands by a factor of 8. In addition, reading the whole section together at once allows better indication to firmware of when we're "done".
Re-write ice_get_orom_civd_data to allocate virtual memory to store the Option ROM data. Copy the entire OptionROM contents at once using ice_read_flash_module. Finally, use this memory copy to scan for the '$CIV' section.
This change significantly reduces the time to read the Option ROM CIVD section from ~10 seconds down to ~1 second. This has a significant impact on the total time to complete a driver rebuild or probe.
---
Changes since v6
* fix a memory leak
Changes since v5
* new patch
drivers/net/ethernet/intel/ice/ice_nvm.c | 48 ++++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_nvm.c +36 -12
@@ -619,7 +619,7 @@ static int ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, struct ice_orom_civd_info *civd) { - struct ice_orom_civd_info tmp; + u8 *orom_data;int status;u32 offset;
@@ -627,36 +627,60 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank,* The first 4 bytes must contain the ASCII characters "$CIV". * A simple modulo 256 sum of all of the bytes of the structure must * equal 0. +* +* The exact location is unknown and varies between images but is +* usually somewhere in the middle of the bank. We need to scan the +* Option ROM bank to locate it. +* +* It's significantly faster to read the entire Option ROM up front +* using the maximum page size, than to read each possible location +* with a separate firmware command. */ + orom_data =vzalloc (hw->flash.banks.orom_size); +if (!orom_data) +return -ENOMEM ; + + status =ice_read_flash_module (hw, bank,ICE_SR_1ST_OROM_BANK_PTR ,0 , + orom_data, hw->flash.banks.orom_size); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Unable to read Option ROM data\n" ); +return status; + } + +/* Scan the memory buffer to locate the CIVD data section */ for (offset =0 ; (offset +512 ) <= hw->flash.banks.orom_size; offset +=512 ) { +struct ice_orom_civd_info *tmp;u8 sum =0 , i; - status =ice_read_flash_module (hw, bank,ICE_SR_1ST_OROM_BANK_PTR , - offset, (u8 *)&tmp,sizeof (tmp)); -if (status) { -ice_debug (hw,ICE_DBG_NVM ,"Unable to read Option ROM CIVD data\n" ); -return status; - } + tmp = (struct ice_orom_civd_info *)&orom_data[offset];/* Skip forward until we find a matching signature */ -if (memcmp ("$CIV" , tmp.signature,sizeof (tmp.signature)) !=0 ) +if (memcmp ("$CIV" , tmp->signature,sizeof (tmp->signature)) !=0 )continue ; +ice_debug (hw,ICE_DBG_NVM ,"Found CIVD section at offset %u\n" , + offset); +/* Verify that the simple checksum is zero */ -for (i =0 ; i <sizeof (tmp); i++) +for (i =0 ; i <sizeof (*tmp); i++)/* cppcheck-suppress objectIndex */ - sum += ((u8 *)&tmp)[i]; + sum += ((u8 *)tmp)[i];if (sum) {ice_debug (hw,ICE_DBG_NVM ,"Found CIVD data with invalid checksum of %u\n" , sum); -return -EIO ; + goto err_invalid_checksum; } - *civd = tmp; + *civd = *tmp; +vfree (orom_data);return 0 ; } +ice_debug (hw,ICE_DBG_NVM ,"Unable to locate CIVD data within the Option ROM\n" ); + +err_invalid_checksum: +vfree (orom_data);return -EIO ; }
base-commit: f52e48210595b1a21ec36f151f3c2b1e5de6e5ca
Signature · 1 line
2.31.1.331.gb0c09ab8796f
PATCH v7 2/2 ice: support immediate firmware activation via devlink reload
The ice hardware contains an embedded chip with firmware which can be updated using devlink flash. The firmware which runs on this chip is referred to as the Embedded Management Processor firmware (EMP firmware).
Activating the new firmware image currently requires that the system be rebooted. This is not ideal as rebooting the system can cause unwanted downtime.
In practical terms, activating the firmware does not always require a full system reboot. In many cases it is possible to activate the EMP firmware immediately. There are a couple of different scenarios to cover.
* The EMP firmware itself can be reloaded by issuing a special update to the device called an Embedded Management Processor reset (EMP reset). This reset causes the device to reset and reload the EMP firmware.
* PCI configuration changes are only reloaded after a cold PCIe reset. Unfortunately there is no generic way to trigger this for a PCIe device without a system reboot.
When performing a flash update, firmware is capable of responding with some information about the specific update requirements.
The driver updates the flash by programming a secondary inactive bank with the contents of the new image, and then issuing a command to request to switch the active bank starting from the next load.
The response to the final command for updating the inactive NVM flash bank includes an indication of the minimum reset required to fully update the device. This can be one of the following:
* A full power on is required
* A cold PCIe reset is required
* An EMP reset is required
The response to the command to switch flash banks includes an indication of whether or not the firmware will allow an EMP reset request.
For most updates, an EMP reset is sufficient to load the new EMP firmware without issues. In some cases, this reset is not sufficient because the PCI configuration space has changed. When this could cause incompatibility with the new EMP image, the firmware is capable of rejecting the EMP reset request.
Add logic to ice_fw_update.c to handle the response data flash update AdminQ commands.
For the reset level, issue a devlink status notification informing the user of how to complete the update with a simple suggestion like "Activate new firmware by rebooting the system".
Cache the status of whether or not firmware will restrict the EMP reset for use in implementing devlink reload.
Implement support for devlink reload with the "fw_activate" flag. This allows user space to request the firmware be activated immediately.
For the .reload_down handler, we will issue a request for the EMP reset using the appropriate firmware AdminQ command. If we know that the firmware will not allow an EMP reset, simply exit with a suitable netlink extended ACK message indicating that the EMP reset is not available.
For the .reload_up handler, simply wait until the driver has finished resetting. Logic to handle processing of an EMP reset already exists in the driver as part of its reset and rebuild flows.
Implement support for the devlink reload interface with the "fw_activate" action. This allows userspace to request activation of firmware without a reboot.
Note that support for indicating the required reset and EMP reset restriction is not supported on old versions of firmware. The driver can determine if the two features are supported by checking the device capabilities report. I confirmed support has existed since at least version 5.5.2 as reported by the 'fw.mgmt' version. Support to issue the EMP reset request has existed in all version of the EMP firmware for the ice hardware.
Check the device capabilities report to determine whether or not the indications are reported by the running firmware. If the reset requirement indication is not supported, always assume a full power on is necessary. If the reset restriction capability is not supported, always assume the EMP reset is available.
Users can verify if the EMP reset has activated the firmware by using the devlink info report to check that the 'running' firmware version has updated. For example a user might do the following:
# Check current version
$ devlink dev info
# Update the device
$ devlink dev flash pci/0000:af:00.0 file firmware.bin
# Confirm stored version updated
$ devlink dev info
# Reload to activate new firmware
$ devlink dev reload pci/0000:af:00.0 action fw_activate
# Confirm running version updated
$ devlink dev info
Finally, this change does *not* implement basic driver-only reload support. I did look into trying to do this. However, it requires significant refactor of how the ice driver probes and loads everything. The ice driver probe and allocation flows were not designed with such a reload in mind. Refactoring the flow to support this is beyond the scope of this change.
---
Changes since v6
* none
Changes since v5
* Added a new patch that reduces the reset (and probe!) time
* Reduced the maximum timeout of reload_up to 1 minute. This is probably still a bit overkill in terms of total wait but ensures we wait long enough for cases where multiple PFs rebuild flows are serialized due to locks
* Improved the error message when reset times out.
Changes since v4
* completely re-write commit message for clarity
* Update devlink ice.rst with documentation about reload
* expand the terms "EMP" and "empr" for clarity
* Rename the ice_devlink_reload_down to ice_devlink_reload_empr_start and rename ice_devlink_reload_up to ice_devlink_reload_empr_finish. This is done to clarify their functionality. It is also done because any future support for devlink reload with driver reinit will want to continue re-using these functions to support firmware activation.
* Increase the maximum wait time for EMP reset to complete to 2 minutes. It turns out that in practice the reset might take a while (longer than the original 20 seconds I had in v4 and earlier).
* Move the clearing of fw_emp_reset_disabled into the ice_rebuild logic. This ensures the flag is properly cleared even when the EMP reset was caused by another physical function.
* Add comments explaining the various reset levels that the firmware can report.
Changes since v3
* correctly read response of NVM write activate from synchronous reply value instead of from the ARQ event. This fixes a bug where we never reported that EMP reset is available.
Changes since v2
* ensure DEVLINK_F_RELOAD gets set
* rebase to avoid conflicts
Documentation/networking/devlink/ice.rst | 24 ++- drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 7 + drivers/net/ethernet/intel/ice/ice_common.c | 12 ++ drivers/net/ethernet/intel/ice/ice_devlink.c | 99 ++++++++++ .../net/ethernet/intel/ice/ice_fw_update.c | 181 +++++++++++++++--- .../net/ethernet/intel/ice/ice_fw_update.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 8 + drivers/net/ethernet/intel/ice/ice_nvm.c | 19 +- drivers/net/ethernet/intel/ice/ice_nvm.h | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 4 + 11 files changed, 330 insertions(+), 29 deletions(-)
Documentation/networking/devlink/ice.rst +22 -2
@@ -26,8 +26,10 @@ The ``ice`` driver reports the following versions * - ``fw.mgmt`` - running - 2.1.7 - - 3-digit version number of the management firmware that controls the - PHY, link, etc. + - 3-digit version number of the management firmware running on the + Embedded Management Processor of the device. It controls the PHY, + link, access to device resources, etc. Intel documentation refers to + this as the EMP firmware. * - ``fw.mgmt.api`` - running - 1.5.1
@@ -119,6 +121,24 @@ preserving settings, and thus ``DEVLINK_FLASH_OVERWRITE_IDENTIFIERS`` on its own will be rejected. If no overwrite mask is provided, the firmware will be instructed to preserve all settings and identifying fields when updating. +Reload +====== + +The ``ice`` driver supports activating new firmware after a flash update +using ``DEVLINK_CMD_RELOAD`` with the ``DEVLINK_RELOAD_ACTION_FW_ACTIVATE`` +action. + +.. code:: shell + + $ devlink dev reload pci/0000:01:00.0 reload action fw_activate + +The new firmware is activated by issuing a device specific Embedded +Management Processor reset which requests the device to reset and reload the +EMP firmware image. + +The driver does not currently support reloading the driver via +``DEVLINK_RELOAD_ACTION_DRIVER_REINIT``. + Regions =======
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -551,6 +551,7 @@ struct ice_pf {spinlock_t aq_wait_lock;struct hlist_head aq_wait_list;wait_queue_head_t aq_wait_queue; +bool fw_emp_reset_disabled;wait_queue_head_t reset_wait_queue;
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +7 -0
@@ -117,6 +117,8 @@ struct ice_aqc_list_caps_elem {#define ICE_AQC_CAPS_NET_VER 0x004C#define ICE_AQC_CAPS_PENDING_NET_VER 0x004D#define ICE_AQC_CAPS_RDMA 0x0051 +#define ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE 0x0076 +#define ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT 0x0077#define ICE_AQC_CAPS_NVM_MGMT 0x0080u8 major_ver;
@@ -1406,6 +1408,11 @@ struct ice_aqc_nvm {#define ICE_AQC_NVM_REVERT_LAST_ACTIV BIT(6)/* Write Activate only */ #define ICE_AQC_NVM_ACTIV_SEL_MASK ICE_M(0x7, 3)#define ICE_AQC_NVM_FLASH_ONLY BIT(7) +#define ICE_AQC_NVM_RESET_LVL_M ICE_M(0x3, 0)/* Write reply only */ +#define ICE_AQC_NVM_POR_FLAG 0 +#define ICE_AQC_NVM_PERST_FLAG 1 +#define ICE_AQC_NVM_EMPR_FLAG 2 +#define ICE_AQC_NVM_EMPR_ENA BIT(0)/* Write Activate reply only */ __le16 module_typeid;__le16 length;#define ICE_AQC_NVM_ERASE_LEN 0xFFFF
drivers/net/ethernet/intel/ice/ice_common.c +12 -0
@@ -2069,6 +2069,18 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,ice_debug (hw,ICE_DBG_INIT ,"%s: max_mtu = %d\n" , prefix, caps->max_mtu);break ; +case ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE : + caps->pcie_reset_avoidance = (number >0 ); +ice_debug (hw,ICE_DBG_INIT , +"%s: pcie_reset_avoidance = %d\n" , prefix, + caps->pcie_reset_avoidance); +break ; +case ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT : + caps->reset_restrict_support = (number ==1 ); +ice_debug (hw,ICE_DBG_INIT , +"%s: reset_restrict_support = %d\n" , prefix, + caps->reset_restrict_support); +break ;default :/* Not one of the recognized common capabilities */ found = false;
drivers/net/ethernet/intel/ice/ice_devlink.c +99 -0
113 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fw_update.c +158 -23
334 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fw_update.h +2 -0
@@ -7,5 +7,7 @@int ice_devlink_flash_update (struct devlink *devlink,struct devlink_flash_update_params *params,struct netlink_ext_ack *extack); +int ice_get_pending_updates (struct ice_pf *pf,u8 *pending, +struct netlink_ext_ack *extack);#endif
drivers/net/ethernet/intel/ice/ice_main.c +8 -0
@@ -6527,6 +6527,14 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)dev_dbg (dev,"rebuilding PF after reset_type=%d\n" , reset_type); +if (reset_type ==ICE_RESET_EMPR ) { +/* If an EMP reset has occurred, any previously pending flash +* update will have completed. We no longer know whether or +* not the NVM update EMP reset is restricted. +*/ + pf->fw_emp_reset_disabled = false; + } + err =ice_init_all_ctrlq (hw);if (err) {dev_err (dev,"control queues init failed %d\n" , err);
drivers/net/ethernet/intel/ice/ice_nvm.c +16 -3
@@ -1112,22 +1112,35 @@ int ice_nvm_validate_checksum(struct ice_hw *hw)/** * ice_nvm_write_activate * @hw: pointer to the HW struct -* @cmd_flags: NVM activate admin command bits (banks to be validated) +* @cmd_flags: flags for write activate command +* @response_flags: response indicators from firmware * * Update the control word with the required banks' validity bits * and dumps the Shadow RAM to flash (0x0707) +* +* cmd_flags controls which banks to activate, and the preservation level to +* use when activating the NVM bank. +* +* On successful return of the firmware command, the response_flags variable +* is updated with the flags reported by firmware indicating certain status, +* such as whether EMP reset is enabled. */ -int ice_nvm_write_activate (struct ice_hw *hw,u8 cmd_flags) +int ice_nvm_write_activate (struct ice_hw *hw,u8 cmd_flags,u8 *response_flags) {struct ice_aqc_nvm *cmd;struct ice_aq_desc desc; +int err; cmd = &desc.params.nvm;ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_nvm_write_activate); cmd->cmd_flags = cmd_flags; -return ice_aq_send_cmd (hw, &desc,NULL ,0 ,NULL ); + err =ice_aq_send_cmd (hw, &desc,NULL ,0 ,NULL ); +if (!err && response_flags) + *response_flags = cmd->cmd_flags; + +return err; }/**
drivers/net/ethernet/intel/ice/ice_nvm.h +1 -1
@@ -38,7 +38,7 @@ ice_aq_update_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset,int ice_aq_erase_nvm (struct ice_hw *hw,u16 module_typeid,struct ice_sq_cd *cd);int ice_nvm_validate_checksum (struct ice_hw *hw); -int ice_nvm_write_activate (struct ice_hw *hw,u8 cmd_flags); +int ice_nvm_write_activate (struct ice_hw *hw,u8 cmd_flags,u8 *response_flags);int ice_aq_nvm_update_empr (struct ice_hw *hw); int ice_nvm_set_pkg_data(struct ice_hw *hw, bool del_pkg_data_flag, u8 *data,
drivers/net/ethernet/intel/ice/ice_type.h +4 -0
@@ -278,6 +278,10 @@ struct ice_hw_common_caps {#define ICE_NVM_PENDING_NETLIST BIT(2)bool nvm_unified_update;#define ICE_NVM_MGMT_UNIFIED_UPD_SUPPORT BIT(3) +/* PCIe reset avoidance */ +bool pcie_reset_avoidance; +/* Post update reset restriction */ +bool reset_restrict_support; };/* IEEE 1588 TIME_SYNC specific info */
Signature · 1 line
2.31.1.331.gb0c09ab8796f
PATCH v7 1/2 ice: reduce time to read Option ROM CIVD data
In reply to Jacob Keller[Cc: +linux-pci for ideas how to work with Option ROMs]
Dear Jacob,
Quoted 23 lines · Jacob Keller
During probe and device reset, the ice driver reads some data from the NVM image as part of
ice_init_nvm. Part of this data includes a section of the Option ROM which contains version information.The function
ice_get_orom_civd_datais used to locate the '$CIV' data section of the Option ROM.Timing of
ice_probeandice_rebuildindicate that theice_get_orom_civd_datafunction takes about 10 seconds to finish executing.The function locates the section by scanning the Option ROM every 512 bytes. This requires a significant number of NVM read accesses, since the Option ROM bank is 500KB. In the worst case it would take about 1000 reads. Worse, all PFs serialize this operation during reload because of acquiring the NVM semaphore.
The CIVD section is located at the end of the Option ROM image data. Unfortunately, the driver has no easy method to determine the offset manually. Practical experiments have shown that the data could be at a variety of locations, so simply reversing the scanning order is not sufficient to reduce the overall read time.
Quoted 8 lines
Instead, copy the entire contents of the Option ROM into memory. This allows reading the data using 4Kb pages instead of 512 bytes at a time. This reduces the total number of firmware commands by a factor of 8. In addition, reading the whole section together at once allows better indication to firmware of when we're "done".
Re-write
ice_get_orom_civd_datato allocate virtual memory to store the Option ROM data. Copy the entire OptionROM contents at once using
Option ROM
Quoted 6 lines
ice_read_flash_module. Finally, use this memory copy to scan for the '$CIV' section.This change significantly reduces the time to read the Option ROM CIVD section from ~10 seconds down to ~1 second. This has a significant impact on the total time to complete a driver rebuild or probe.
Thank you for taking up the challenge and looking into this, and for decreasing the time.
OT: Out of curiosity, how does it work on UEFI systems without using Compatibility System Mode (CSM) and just ?EFI drivers??
Quoted 16 lines
Signed-off-by Jacob Keller <[email protected]>---
Changes since v6
* fix a memory leakChanges since v5
* new patchdrivers/net/ethernet/intel/ice/ice_nvm.c | 48 ++++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/ice/ice_nvm.c +0
-0
drivers/net/ethernet/intel/ice/ice_nvm.c static int · line 622
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_nvm.c +1
-1@@ -619,7 +619,7 @@ static int ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, struct ice_orom_civd_info *civd) { - struct ice_orom_civd_info tmp; + u8 *orom_data;
I know the function names use orom, but oprom is already used in other subsystems.
Quoted 64 lines
drivers/net/ethernet/intel/ice/ice_nvm.c +30
-11int status;u32 offset;@@ -627,36 +627,60 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank,* The first 4 bytes must contain the ASCII characters "$CIV". * A simple modulo 256 sum of all of the bytes of the structure must * equal 0. +* +* The exact location is unknown and varies between images but is +* usually somewhere in the middle of the bank. We need to scan the +* Option ROM bank to locate it. +* +* It's significantly faster to read the entire Option ROM up front +* using the maximum page size, than to read each possible location +* with a separate firmware command. */ + orom_data =vzalloc (hw->flash.banks.orom_size); +if (!orom_data) +return -ENOMEM ; + + status =ice_read_flash_module (hw, bank,ICE_SR_1ST_OROM_BANK_PTR ,0 , + orom_data, hw->flash.banks.orom_size); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Unable to read Option ROM data\n" ); +return status; + } + +/* Scan the memory buffer to locate the CIVD data section */ for (offset =0 ; (offset +512 ) <= hw->flash.banks.orom_size; offset +=512 ) { +struct ice_orom_civd_info *tmp;u8 sum =0 , i; - status =ice_read_flash_module (hw, bank,ICE_SR_1ST_OROM_BANK_PTR , - offset, (u8 *)&tmp,sizeof (tmp)); -if (status) { -ice_debug (hw,ICE_DBG_NVM ,"Unable to read Option ROM CIVD data\n" ); -return status; - } + tmp = (struct ice_orom_civd_info *)&orom_data[offset];/* Skip forward until we find a matching signature */ -if (memcmp ("$CIV" , tmp.signature,sizeof (tmp.signature)) !=0 ) +if (memcmp ("$CIV" , tmp->signature,sizeof (tmp->signature)) !=0 )continue ; +ice_debug (hw,ICE_DBG_NVM ,"Found CIVD section at offset %u\n" , + offset); +/* Verify that the simple checksum is zero */ -for (i =0 ; i <sizeof (tmp); i++) +for (i =0 ; i <sizeof (*tmp); i++)/* cppcheck-suppress objectIndex */ - sum += ((u8 *)&tmp)[i]; + sum += ((u8 *)tmp)[i];if (sum) {ice_debug (hw,ICE_DBG_NVM ,"Found CIVD data with invalid checksum of %u\n" , sum); -return -EIO ; + goto err_invalid_checksum; } - *civd = tmp; + *civd = *tmp;
drivers/net/ethernet/intel/ice/ice_nvm.c ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, · line 685
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_nvm.c +5
-0+vfree (orom_data);return 0 ; } +ice_debug (hw,ICE_DBG_NVM ,"Unable to locate CIVD data within the Option ROM\n" ); + +err_invalid_checksum: +vfree (orom_data);return -EIO ; }
Please excuse my ignorance. I would have though, that the system firmware already put that Option ROM into memory. There is a function pci_map_biosrom() declared in arch/x86/include/asm/probe_roms.h and implemented in arch/x86/kernel/probe_roms.c, which might be used?
Kind regards,
Paul
Keller
PATCH v7 1/2 ice: reduce time to read Option ROM CIVD data
Quoted 55 lines
-----Original Message-----
From: Paul Menzel <[email protected]>
Sent: Wednesday, October 27, 2021 11:43 PM
To: Keller, Jacob E <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>; intel-wired- lan at lists.osuosl.org; linux-pci at vger.kernel.org
Subject: Re: [PATCH v7 1/2] ice: reduce time to read Option ROM CIVD data[Cc: +linux-pci for ideas how to work with Option ROMs]
Dear Jacob,
Quoted 23 lines · Jacob Keller
During probe and device reset, the ice driver reads some data from the NVM image as part of
ice_init_nvm. Part of this data includes a section of the Option ROM which contains version information.The function
ice_get_orom_civd_datais used to locate the '$CIV' data section of the Option ROM.Timing of
ice_probeandice_rebuildindicate that theice_get_orom_civd_datafunction takes about 10 seconds to finish executing.The function locates the section by scanning the Option ROM every 512 bytes. This requires a significant number of NVM read accesses, since the Option ROM bank is 500KB. In the worst case it would take about 1000 reads. Worse, all PFs serialize this operation during reload because of acquiring the NVM semaphore.
The CIVD section is located at the end of the Option ROM image data. Unfortunately, the driver has no easy method to determine the offset manually. Practical experiments have shown that the data could be at a variety of locations, so simply reversing the scanning order is not sufficient to reduce the overall read time.
Quoted 8 lines
Instead, copy the entire contents of the Option ROM into memory. This allows reading the data using 4Kb pages instead of 512 bytes at a time. This reduces the total number of firmware commands by a factor of 8. In addition, reading the whole section together at once allows better indication to firmware of when we're "done".
Re-write
ice_get_orom_civd_datato allocate virtual memory to store the Option ROM data. Copy the entire OptionROM contents at once usingOption ROM
Quoted 6 lines
ice_read_flash_module. Finally, use this memory copy to scan for the '$CIV' section.This change significantly reduces the time to read the Option ROM CIVD section from ~10 seconds down to ~1 second. This has a significant impact on the total time to complete a driver rebuild or probe.
Quoted 6 lines
Thank you for taking up the challenge and looking into this, and for decreasing the time.
OT: Out of curiosity, how does it work on UEFI systems without using Compatibility System Mode (CSM) and just ?EFI drivers??
This code is just about accessing the version data that we report via devlink info.
Thanks,
Jake
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_nvm.c static int · line 622
Quoted 5 lines
ice_get_orom_civd_data(struct
ice_hw*hw, enumice_bank_selectbank,
structice_orom_civd_info*civd)
{drivers/net/ethernet/intel/ice/ice_nvm.c +1
-1-struct ice_orom_civd_info tmp; +u8 *orom_data;I know the function names use orom, but oprom is already used in other subsystems.
Sure, but there's dozens of instances in this driver where we use the short 'orom'. Not worth changing that in this patch series.
Quoted 7 lines
Quoted 1 line
}Please excuse my ignorance. I would have though, that the system firmware already put that Option ROM into memory. There is a function
pci_map_biosrom()declared inarch/x86/include/asm/probe_roms.hand implemented inarch/x86/kernel/probe_roms.c, which might be used?
Sure. This function is used to read the version data that we report about the flash contents via devlink info.
I believe the reasoning this is done during rebuild is because there wasn't a need to scan it on demand since it won't change unless you do a flash update.
We read information on the 3 major components of the flash during init: the EMP firmware versions, the Option ROM version data, and something we call netlist which I understand contains some configuration TLVs
The point of this separate function is to be able to report precisely what version of the firmware image that we have loaded onto the device.
This gets reported in devlink info:
pci/0000:af:00.1:
driver ice
serial_number 00-01-00-ff-ff-00-00-00
versions:
fixed:
board.id K91258-000
running:
fw.mgmt 6.1.5
fw.mgmt.api 1.7.9
fw.mgmt.build 0x6986bfdb
fw.undi 1.3025.0
fw.psid.api 3.10
fw.bundle_id 0x80008e6a
fw.app.name ICE OS Default Package
fw.app 1.3.27.0
fw.app.bundle_id 0xc0000001
fw.netlist 3.10.2000-3.1e.0
fw.netlist.build 0x4154dfac
stored:
fw.undi 1.3025.0
fw.psid.api 3.10
fw.bundle_id 0x80008e6a
fw.netlist 3.10.2000-3.1e.0
fw.netlist.build 0x4154dfacSpecifically, fw.undi contains the version of the Option ROM image. We report both the "running" version, and, if there is a pending bank switch during next firmware load, the version stored in the inactive flash bank that will be switched to next load.
Thanks,
Jake
Quoted 3 lines
Kind regards,
Paul
G
PATCH v7 2/2 ice: support immediate firmware activation via devlink reload
In reply to Jacob KellerQuoted 161 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, October 28, 2021 4:53 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <intel- wired-lan at lists.osuosl.org>
Cc: pmenzel at molgen.mpg.de
Subject: [Intel-wired-lan] [PATCH v7 2/2] ice: support immediate firmware activation via devlink reloadThe ice hardware contains an embedded chip with firmware which can be updated using devlink flash. The firmware which runs on this chip is referred to as the Embedded Management Processor firmware (EMP firmware).
Activating the new firmware image currently requires that the system be rebooted. This is not ideal as rebooting the system can cause unwanted downtime.
In practical terms, activating the firmware does not always require a full system reboot. In many cases it is possible to activate the EMP firmware immediately. There are a couple of different scenarios to cover.
* The EMP firmware itself can be reloaded by issuing a special update to the device called an Embedded Management Processor reset (EMP reset). This reset causes the device to reset and reload the EMP firmware.
* PCI configuration changes are only reloaded after a cold PCIe reset. Unfortunately there is no generic way to trigger this for a PCIe device without a system reboot.
When performing a flash update, firmware is capable of responding with some information about the specific update requirements.
The driver updates the flash by programming a secondary inactive bank with the contents of the new image, and then issuing a command to request to switch the active bank starting from the next load.
The response to the final command for updating the inactive NVM flash bank includes an indication of the minimum reset required to fully update the device. This can be one of the following:
* A full power on is required
* A cold PCIe reset is required
* An EMP reset is requiredThe response to the command to switch flash banks includes an indication of whether or not the firmware will allow an EMP reset request.
For most updates, an EMP reset is sufficient to load the new EMP firmware without issues. In some cases, this reset is not sufficient because the PCI configuration space has changed. When this could cause incompatibility with the new EMP image, the firmware is capable of rejecting the EMP reset request.
Add logic to
ice_fw_update.cto handle the response data flash update AdminQ commands.For the reset level, issue a devlink status notification informing the user of how to complete the update with a simple suggestion like "Activate new firmware by rebooting the system".
Cache the status of whether or not firmware will restrict the EMP reset for use in implementing devlink reload.
Implement support for devlink reload with the "
fw_activate" flag. This allows user space to request the firmware be activated immediately.For the .reload_down handler, we will issue a request for the EMP reset using the appropriate firmware AdminQ command. If we know that the firmware will not allow an EMP reset, simply exit with a suitable netlink extended ACK message indicating that the EMP reset is not available.
For the .reload_up handler, simply wait until the driver has finished resetting. Logic to handle processing of an EMP reset already exists in the driver as part of its reset and rebuild flows.
Implement support for the devlink reload interface with the "
fw_activate" action. This allows userspace to request activation of firmware without a reboot.Note that support for indicating the required reset and EMP reset restriction is not supported on old versions of firmware. The driver can determine if the two features are supported by checking the device capabilities report. I confirmed support has existed since at least version 5.5.2 as reported by the 'fw.mgmt' version. Support to issue the EMP reset request has existed in all version of the EMP firmware for the ice hardware.
Check the device capabilities report to determine whether or not the indications are reported by the running firmware. If the reset requirement indication is not supported, always assume a full power on is necessary. If the reset restriction capability is not supported, always assume the EMP reset is available.
Users can verify if the EMP reset has activated the firmware by using the devlink info report to check that the 'running' firmware version has updated. For example a user might do the following:
# Check current version
$ devlink dev info# Update the device
$ devlink dev flash pci/0000:af:00.0 file firmware.bin# Confirm stored version updated
$ devlink dev info# Reload to activate new firmware
$ devlink dev reload pci/0000:af:00.0 action fw_activate# Confirm running version updated
$ devlink dev infoFinally, this change does *not* implement basic driver-only reload support. I did look into trying to do this. However, it requires significant refactor of how the ice driver probes and loads everything.
The ice driver probe and allocation flows were not designed with such a reload in mind. Refactoring the flow to support this is beyond the scope of this change.Signed-off-by Jacob Keller <[email protected]>---
Changes since v6
* noneChanges since v5
* Added a new patch that reduces the reset (and probe!) time
* Reduced the maximum timeout ofreload_upto 1 minute. This is probably still a bit overkill in terms of total wait but ensures we wait long enough for cases where multiple PFs rebuild flows are serialized due to locks
* Improved the error message when reset times out.Changes since v4
* completely re-write commit message for clarity
* Update devlinkice.rstwith documentation about reload
* expand the terms "EMP" and "empr" for clarity
* Rename theice_devlink_reload_downtoice_devlink_reload_empr_startand renameice_devlink_reload_uptoice_devlink_reload_empr_finish. This is done to clarify their functionality. It is also done because any future support for devlink reload with driver reinit will want to continue re-using these functions to support firmware activation.
* Increase the maximum wait time for EMP reset to complete to 2 minutes. It turns out that in practice the reset might take a while (longer than the original 20 seconds I had in v4 and earlier).
* Move the clearing offw_emp_reset_disabledinto theice_rebuildlogic. This ensures the flag is properly cleared even when the EMP reset was caused by another physical function.
* Add comments explaining the various reset levels that the firmware can report.Changes since v3
* correctly read response of NVM write activate from synchronous reply value instead of from the ARQ event. This fixes a bug where we never reported that EMP reset is available.Changes since v2
* ensureDEVLINK_F_RELOADgets set
* rebase to avoid conflicts
Quoted 13 lines
Documentation/networking/devlink/ice.rst | 24 ++- drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 7 + drivers/net/ethernet/intel/ice/ice_common.c | 12 ++ drivers/net/ethernet/intel/ice/ice_devlink.c | 99 ++++++++++ .../net/ethernet/intel/ice/ice_fw_update.c | 181 +++++++++++++++--- .../net/ethernet/intel/ice/ice_fw_update.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 8 + drivers/net/ethernet/intel/ice/ice_nvm.c | 19 +- drivers/net/ethernet/intel/ice/ice_nvm.h | 2 +- drivers/net/ethernet/intel/ice/ice_type.h | 4 + 11 files changed, 330 insertions(+), 29 deletions(-)
G
PATCH v7 1/2 ice: reduce time to read Option ROM CIVD data
In reply to Jacob KellerQuoted 54 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Thursday, October 28, 2021 4:53 AM
To: Nguyen, Anthony L <[email protected]>; Intel Wired LAN <intel- wired-lan at lists.osuosl.org>
Cc: pmenzel at molgen.mpg.de
Subject: [Intel-wired-lan] [PATCH v7 1/2] ice: reduce time to read Option ROM CIVD dataDuring probe and device reset, the ice driver reads some data from the NVM image as part of
ice_init_nvm. Part of this data includes a section of the Option ROM which contains version information.The function
ice_get_orom_civd_datais used to locate the '$CIV' data section of the Option ROM.Timing of
ice_probeandice_rebuildindicate that theice_get_orom_civd_datafunction takes about 10 seconds to finish executing.The function locates the section by scanning the Option ROM every 512 bytes. This requires a significant number of NVM read accesses, since the Option ROM bank is 500KB. In the worst case it would take about 1000 reads. Worse, all PFs serialize this operation during reload because of acquiring the NVM semaphore.
The CIVD section is located at the end of the Option ROM image data. Unfortunately, the driver has no easy method to determine the offset manually. Practical experiments have shown that the data could be at a variety of locations, so simply reversing the scanning order is not sufficient to reduce the overall read time.
Instead, copy the entire contents of the Option ROM into memory. This allows reading the data using 4Kb pages instead of 512 bytes at a time. This reduces the total number of firmware commands by a factor of 8. In addition, reading the whole section together at once allows better indication to firmware of when we're "done".
Re-write
ice_get_orom_civd_datato allocate virtual memory to store the Option ROM data. Copy the entire OptionROM contents at once usingice_read_flash_module. Finally, use this memory copy to scan for the '$CIV' section.This change significantly reduces the time to read the Option ROM CIVD section from ~10 seconds down to ~1 second. This has a significant impact on the total time to complete a driver rebuild or probe.
Signed-off-by Jacob Keller <[email protected]>---
Changes since v6
* fix a memory leak
Quoted 6 lines
Changes since v5
* new patchdrivers/net/ethernet/intel/ice/ice_nvm.c | 48 ++++++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-)