Skip to contentSkip to conversation

ice: Fix entering Safe Mode

PATCH Superseded Marcin Szycik 2 participants 4 messages Sep 20, 2024 – Sep 23, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 ice: Fix entering Safe Mode

If DDP package is missing or corrupted, the driver should enter Safe Mode. Instead, an error is returned and probe fails.

Don't check return value of ice_init_ddp_config() to fix this.

Change ice_init_ddp_config() type to void, as now its return is never checked.

Repro:
* Remove or rename DDP package (/lib/firmware/intel/ice/ddp/ice.pkg)
* Load ice

Fixes cc5776fe1832 ("ice: Enable switching default Tx scheduler topology")

---
v2: Change ice_init_ddp_config() type to void

---
 drivers/net/ethernet/intel/ice/ice_main.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +3 -12
index 0f5c9d347806..aeebf4ae25ae 100644
@@ -4548,34 +4548,27 @@ ice_init_tx_topology(struct ice_hw *hw, const struct firmware *firmware)
  *
  * This function loads DDP file from the disk, then initializes Tx
  * topology. At the end DDP package is loaded on the card.
- *
- * Return: zero when init was successful, negative values otherwise.
  */
-static int ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf)
+static void ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf)
 {
 	struct device *dev = ice_pf_to_dev(pf);
 	const struct firmware *firmware = NULL;
 	int err;
 
 	err = ice_request_fw(pf, &firmware);
-	if (err) {
+	if (err)
 		dev_err(dev, "Fail during requesting FW: %d\n", err);
-		return err;
-	}
 
 	err = ice_init_tx_topology(hw, firmware);
 	if (err) {
 		dev_err(dev, "Fail during initialization of Tx topology: %d\n",
 			err);
 		release_firmware(firmware);
-		return err;
 	}
 
 	/* Download firmware to device */
 	ice_load_pkg(firmware, pf);
 	release_firmware(firmware);
-
-	return 0;
 }
 
 /**
@@ -4748,9 +4741,7 @@ int ice_init_dev(struct ice_pf *pf)
 
 	ice_init_feature_support(pf);
 
-	err = ice_init_ddp_config(hw, pf);
-	if (err)
-		return err;
+	ice_init_ddp_config(hw, pf);
 
 	/* if ice_init_ddp_config fails, ICE_FLAG_ADV_FEATURES bit won't be
 	 * set in pf->state, which will cause ice_is_safe_mode to return
Signature · 1 line
2.45.0
#1 lore raw

PATCH v2 2/2 ice: Fix netif_is_ice() in Safe Mode

netif_is_ice() works by checking the pointer to netdev ops. However, it only checks for the default ice_netdev_ops, not ice_netdev_safe_mode_ops, so in Safe Mode it always returns false, which is unintuitive. While it doesn't look like netif_is_ice() is currently being called anywhere in Safe Mode, this could change and potentially lead to unexpected behaviour.

Fixes df006dd4b1dc ("ice: Add initial support framework for LAG")
---
 drivers/net/ethernet/intel/ice/ice_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -1
index aeebf4ae25ae..f0f27e78bde9 100644
@@ -87,7 +87,8 @@ ice_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch,
 
 bool netif_is_ice(const struct net_device *dev)
 {
-	return dev && (dev->netdev_ops == &ice_netdev_ops);
+	return dev && (dev->netdev_ops == &ice_netdev_ops ||
+		       dev->netdev_ops == &ice_netdev_safe_mode_ops);
 }
 
 /**
Signature · 1 line
2.45.0
#2 lore raw
In reply to Marcin Szycik
Quoted 66 lines · Marcin Szycik

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

If DDP package is missing or corrupted, the driver should enter Safe Mode. Instead, an error is returned and probe fails.

Don't check return value of ice_init_ddp_config() to fix this.

Change ice_init_ddp_config() type to void, as now its return is never checked.

Repro:
* Remove or rename DDP package (/lib/firmware/intel/ice/ddp/ice.pkg)
* Load ice

Fixes cc5776fe1832 ("ice: Enable switching default Tx scheduler topology")

---
v2: Change ice_init_ddp_config() type to void

---
  drivers/net/ethernet/intel/ice/ice_main.c | 15 +++------------
  1 file changed, 3 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -9
index 0f5c9d347806..aeebf4ae25ae 100644
@@ -4548,34 +4548,27 @@ ice_init_tx_topology(struct ice_hw *hw, const struct firmware *firmware)
   *
   * This function loads DDP file from the disk, then initializes Tx
   * topology. At the end DDP package is loaded on the card.
- *
- * Return: zero when init was successful, negative values otherwise.
   */
-static int ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf)
+static void ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf)
  {
         struct device *dev = ice_pf_to_dev(pf);
         const struct firmware *firmware = NULL;
         int err;
 
         err = ice_request_fw(pf, &firmware);
-       if (err) {
+       if (err)
                 dev_err(dev, "Fail during requesting FW: %d\n", err);
-               return err;
-       }
 
         err = ice_init_tx_topology(hw, firmware);
         if (err) {
                 dev_err(dev, "Fail during initialization of Tx topology: %d\n",
                         err);
                 release_firmware(firmware);
-               return err;
         }
 
         /* Download firmware to device */
         ice_load_pkg(firmware, pf);
         release_firmware(firmware);
-
-       return 0;
  }
 
  /**

drivers/net/ethernet/intel/ice/ice_main.c int ice_init_dev(struct ice_pf *pf) · line 4744

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +1 -3
@@ -4748,9 +4741,7 @@ int ice_init_dev(struct ice_pf *pf)
 
         ice_init_feature_support(pf);
 
-       err = ice_init_ddp_config(hw, pf);
-       if (err)
-               return err;
+       ice_init_ddp_config(hw, pf);

I just commented this on v1 as I didn't expect it to be resent. I'm also okay with Maciej's suggestion, but I wanted to offer an alternative option.

As an alternative solution you could potentially do the following, which would make the flow more readable:

err = ice_init_ddp_config(hw, pf);
if (err || ice_is_safe_mode(pf))

       ice_set_safe_mode_caps(hw);

Also, should there be some sort of messaging if the device goes into
safe mode? I wonder if a dev_dbg() would be better than nothing. If ice_init_ddp_config() fails, then it will print an error message, so maybe a dev_warn/info() is warranted if (err)? Of course this would depend on ice_init_ddp_config() to return a non-void value.

Thanks,

Brett

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +0 -1
         /* if ice_init_ddp_config fails, ICE_FLAG_ADV_FEATURES bit won't be
          * set in pf->state, which will cause ice_is_safe_mode to return
--

2.45.0

#3 lore raw
Quoted 79 lines · Brett Creeley
Quoted 66 lines · Marcin Szycik

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

If DDP package is missing or corrupted, the driver should enter Safe Mode. Instead, an error is returned and probe fails.

Don't check return value of ice_init_ddp_config() to fix this.

Change ice_init_ddp_config() type to void, as now its return is never checked.

Repro:
* Remove or rename DDP package (/lib/firmware/intel/ice/ddp/ice.pkg)
* Load ice

Fixes cc5776fe1832 ("ice: Enable switching default Tx scheduler topology")

---
v2: Change ice_init_ddp_config() type to void
---
  drivers/net/ethernet/intel/ice/ice_main.c | 15 +++------------

  1 file changed, 3 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -9
index 0f5c9d347806..aeebf4ae25ae 100644
@@ -4548,34 +4548,27 @@ ice_init_tx_topology(struct ice_hw *hw, const struct firmware *firmware)
    *
    * This function loads DDP file from the disk, then initializes Tx
    * topology. At the end DDP package is loaded on the card.
- *
- * Return: zero when init was successful, negative values otherwise.
    */
-static int ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf)
+static void ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf)
   {
          struct device *dev = ice_pf_to_dev(pf);
          const struct firmware *firmware = NULL;
          int err;
 
          err = ice_request_fw(pf, &firmware);
-       if (err) {
+       if (err)
                  dev_err(dev, "Fail during requesting FW: %d\n", err);
-               return err;
-       }
 
          err = ice_init_tx_topology(hw, firmware);
          if (err) {
                  dev_err(dev, "Fail during initialization of Tx topology: %d\n",
                          err);
                  release_firmware(firmware);
-               return err;
          }
 
          /* Download firmware to device */
          ice_load_pkg(firmware, pf);
          release_firmware(firmware);
-
-       return 0;
   }
 
   /**

drivers/net/ethernet/intel/ice/ice_main.c int ice_init_dev(struct ice_pf *pf) · line 4744

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +1 -3
@@ -4748,9 +4741,7 @@ int ice_init_dev(struct ice_pf *pf)
 
          ice_init_feature_support(pf);
 
-       err = ice_init_ddp_config(hw, pf);
-       if (err)
-               return err;
+       ice_init_ddp_config(hw, pf);

I just commented this on v1 as I didn't expect it to be resent. I'm also okay with Maciej's suggestion, but I wanted to offer an alternative option.

Quoted 6 lines

As an alternative solution you could potentially do the following, which would make the flow more readable:

err = ice_init_ddp_config(hw, pf);
if (err || ice_is_safe_mode(pf))
       ice_set_safe_mode_caps(hw);

This sounds reasonable, I'll change it if there will be no more comments.

Quoted 2 lines

Also, should there be some sort of messaging if the device goes into
safe mode? I wonder if a dev_dbg() would be better than nothing. If ice_init_ddp_config() fails, then it will print an error message, so maybe a dev_warn/info() is warranted if (err)? Of course this would depend on ice_init_ddp_config() to return a non-void value.

ice_request_fw() already prints a dev_err() message when entering safe mode, so I don't think it's necessary here.

Thanks,
Marcin

Quoted 12 lines

Thanks,

Brett

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +0 -0
          /* if ice_init_ddp_config fails, ICE_FLAG_ADV_FEATURES bit won't be
           * set in pf->state, which will cause ice_is_safe_mode to return
Signature · 1 line
2.45.0