Skip to content

Commit 86aae43

Browse files
jacob-kelleranguy11
authored andcommitted
ice: don't leave device non-functional if Tx scheduler config fails
The ice_cfg_tx_topo function attempts to apply Tx scheduler topology configuration based on NVM parameters, selecting either a 5 or 9 layer topology. As part of this flow, the driver acquires the "Global Configuration Lock", which is a hardware resource associated with programming the DDP package to the device. This "lock" is implemented by firmware as a way to guarantee that only one PF can program the DDP for a device. Unlike a traditional lock, once a PF has acquired this lock, no other PF will be able to acquire it again (including that PF) until a CORER of the device. Future requests to acquire the lock report that global configuration has already completed. The following flow is used to program the Tx topology: * Read the DDP package for scheduler configuration data * Acquire the global configuration lock * Program Tx scheduler topology according to DDP package data * Trigger a CORER which clears the global configuration lock This is followed by the flow for programming the DDP package: * Acquire the global configuration lock (again) * Download the DDP package to the device * Release the global configuration lock. However, if configuration of the Tx topology fails, (i.e. ice_get_set_tx_topo returns an error code), the driver exits ice_cfg_tx_topo() immediately, and fails to trigger CORER. While the global configuration lock is held, the firmware rejects most AdminQ commands, as it is waiting for the DDP package download (or Tx scheduler topology programming) to occur. The current driver flows assume that the global configuration lock has been reset by CORER after programming the Tx topology. Thus, the same PF attempts to acquire the global lock again, and fails. This results in the driver reporting "an unknown error occurred when loading the DDP package". It then attempts to enter safe mode, but ultimately fails to finish ice_probe() since nearly all AdminQ command report error codes, and the driver stops loading the device at some point during its initialization. The only currently known way that ice_get_set_tx_topo() can fail is with certain older DDP packages which contain invalid topology configuration, on firmware versions which strictly validate this data. The most recent releases of the DDP have resolved the invalid data. However, it is still poor practice to essentially brick the device, and prevent access to the device even through safe mode or recovery mode. It is also plausible that this command could fail for some other reason in the future. We cannot simply release the global lock after a failed call to ice_get_set_tx_topo(). Releasing the lock indicates to firmware that global configuration (downloading of the DDP) has completed. Future attempts by this or other PFs to load the DDP will fail with a report that the DDP package has already been downloaded. Then, PFs will enter safe mode as they realize that the package on the device does not meet the minimum version requirement to load. The reported error messages are confusing, as they indicate the version of the default "safe mode" package in the NVM, rather than the version of the file loaded from /lib/firmware. Instead, we need to trigger CORER to clear global configuration. This is the lowest level of hardware reset which clears the global configuration lock and related state. It also clears any already downloaded DDP. Crucially, it does *not* clear the Tx scheduler topology configuration. Refactor ice_cfg_tx_topo() to always trigger a CORER after acquiring the global lock, regardless of success or failure of the topology configuration. We need to re-initialize the HW structure when we trigger the CORER. Thus, it makes sense for this to be the responsibility of ice_cfg_tx_topo() rather than its caller, ice_init_tx_topology(). This avoids needless re-initialization in cases where we don't attempt to update the Tx scheduler topology, such as if it has already been programmed. There is one catch: failure to re-initialize the HW struct should stop ice_probe(). If this function fails, we won't have a valid HW structure and cannot ensure the device is functioning properly. To handle this, ensure ice_cfg_tx_topo() returns a limited set of error codes. Set aside one specifically, -ENODEV, to indicate that the ice_init_tx_topology() should fail and stop probe. Other error codes indicate failure to apply the Tx scheduler topology. This is treated as a non-fatal error, with an informational message informing the system administrator that the updated Tx topology did not apply. This allows the device to load and function with the default Tx scheduler topology, rather than failing to load entirely. Note that this use of CORER will not result in loops with future PFs attempting to also load the invalid Tx topology configuration. The first PF will acquire the global configuration lock as part of programming the DDP. Each PF after this will attempt to acquire the global lock as part of programming the Tx topology, and will fail with the indication from firmware that global configuration is already complete. Tx scheduler topology configuration is only performed during driver init (probe or devlink reload) and not during cleanup for a CORER that happens after probe completes. Fixes: 91427e6 ("ice: Support 5 layer topology") Signed-off-by: Jacob Keller <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Rinitha S <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 60dfe24 commit 86aae43

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

drivers/net/ethernet/intel/ice/ice_ddp.c

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,13 @@ ice_get_set_tx_topo(struct ice_hw *hw, u8 *buf, u16 buf_size,
23772377
* The function will apply the new Tx topology from the package buffer
23782378
* if available.
23792379
*
2380-
* Return: zero when update was successful, negative values otherwise.
2380+
* Return:
2381+
* * 0 - Successfully applied topology configuration.
2382+
* * -EBUSY - Failed to acquire global configuration lock.
2383+
* * -EEXIST - Topology configuration has already been applied.
2384+
* * -EIO - Unable to apply topology configuration.
2385+
* * -ENODEV - Failed to re-initialize device after applying configuration.
2386+
* * Other negative error codes indicate unexpected failures.
23812387
*/
23822388
int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
23832389
{
@@ -2410,7 +2416,7 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
24102416

24112417
if (status) {
24122418
ice_debug(hw, ICE_DBG_INIT, "Get current topology is failed\n");
2413-
return status;
2419+
return -EIO;
24142420
}
24152421

24162422
/* Is default topology already applied ? */
@@ -2497,31 +2503,45 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
24972503
ICE_GLOBAL_CFG_LOCK_TIMEOUT);
24982504
if (status) {
24992505
ice_debug(hw, ICE_DBG_INIT, "Failed to acquire global lock\n");
2500-
return status;
2506+
return -EBUSY;
25012507
}
25022508

25032509
/* Check if reset was triggered already. */
25042510
reg = rd32(hw, GLGEN_RSTAT);
25052511
if (reg & GLGEN_RSTAT_DEVSTATE_M) {
2506-
/* Reset is in progress, re-init the HW again */
25072512
ice_debug(hw, ICE_DBG_INIT, "Reset is in progress. Layer topology might be applied already\n");
25082513
ice_check_reset(hw);
2509-
return 0;
2514+
/* Reset is in progress, re-init the HW again */
2515+
goto reinit_hw;
25102516
}
25112517

25122518
/* Set new topology */
25132519
status = ice_get_set_tx_topo(hw, new_topo, size, NULL, NULL, true);
25142520
if (status) {
2515-
ice_debug(hw, ICE_DBG_INIT, "Failed setting Tx topology\n");
2516-
return status;
2521+
ice_debug(hw, ICE_DBG_INIT, "Failed to set Tx topology, status %pe\n",
2522+
ERR_PTR(status));
2523+
/* only report -EIO here as the caller checks the error value
2524+
* and reports an informational error message informing that
2525+
* the driver failed to program Tx topology.
2526+
*/
2527+
status = -EIO;
25172528
}
25182529

2519-
/* New topology is updated, delay 1 second before issuing the CORER */
2530+
/* Even if Tx topology config failed, we need to CORE reset here to
2531+
* clear the global configuration lock. Delay 1 second to allow
2532+
* hardware to settle then issue a CORER
2533+
*/
25202534
msleep(1000);
25212535
ice_reset(hw, ICE_RESET_CORER);
2522-
/* CORER will clear the global lock, so no explicit call
2523-
* required for release.
2524-
*/
2536+
ice_check_reset(hw);
2537+
2538+
reinit_hw:
2539+
/* Since we triggered a CORER, re-initialize hardware */
2540+
ice_deinit_hw(hw);
2541+
if (ice_init_hw(hw)) {
2542+
ice_debug(hw, ICE_DBG_INIT, "Failed to re-init hardware after setting Tx topology\n");
2543+
return -ENODEV;
2544+
}
25252545

2526-
return 0;
2546+
return status;
25272547
}

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4536,17 +4536,23 @@ ice_init_tx_topology(struct ice_hw *hw, const struct firmware *firmware)
45364536
dev_info(dev, "Tx scheduling layers switching feature disabled\n");
45374537
else
45384538
dev_info(dev, "Tx scheduling layers switching feature enabled\n");
4539-
/* if there was a change in topology ice_cfg_tx_topo triggered
4540-
* a CORER and we need to re-init hw
4539+
return 0;
4540+
} else if (err == -ENODEV) {
4541+
/* If we failed to re-initialize the device, we can no longer
4542+
* continue loading.
45414543
*/
4542-
ice_deinit_hw(hw);
4543-
err = ice_init_hw(hw);
4544-
4544+
dev_warn(dev, "Failed to initialize hardware after applying Tx scheduling configuration.\n");
45454545
return err;
45464546
} else if (err == -EIO) {
45474547
dev_info(dev, "DDP package does not support Tx scheduling layers switching feature - please update to the latest DDP package and try again\n");
4548+
return 0;
4549+
} else if (err == -EEXIST) {
4550+
return 0;
45484551
}
45494552

4553+
/* Do not treat this as a fatal error. */
4554+
dev_info(dev, "Failed to apply Tx scheduling configuration, err %pe\n",
4555+
ERR_PTR(err));
45504556
return 0;
45514557
}
45524558

0 commit comments

Comments
 (0)