Skip to contentSkip to conversation

ice: fix locking in ice_dcb_rebuild()

PATCH In review Bart Van Assche via Intel-wired-lan 5 participants 6 messages Mar 20 – May 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ice: fix locking in ice_dcb_rebuild()

Move the mutex_lock() call up to prevent that DCB settings change after the first ice_query_port_ets() call. The second ice_query_port_ets() call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first "goto dcb_error" in the function jumped over mutex_lock() to mutex_unlock().

This bug has been detected by the clang thread-safety analyzer.

Cc Aleksandr Loktionov <[email protected]>
Fixes 242b5e068b25 ("ice: Fix DCB rebuild after reset")

---

v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".

v3 (2026-03-20): Modified patch description. See also
https://lore.kernel.org/all/[email protected]/#t

v2 (2026-02-23): Combined the two patches into one patch and
increased the amount of code covered by tc_mutex. See also
https://lore.kernel.org/all/[email protected]/

v1 (2025-02-06): Two patches. See also
https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +2 -2
index bd77f1c001ee..78ded6876581 100644
@@ -537,14 +537,14 @@ void ice_dcb_rebuild(struct ice_pf *pf)
 	struct ice_dcbx_cfg *err_cfg;
 	int ret;
 
+	mutex_lock(&pf->tc_mutex);
+
 	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
 	if (ret) {
 		dev_err(dev, "Query Port ETS failed\n");
 		goto dcb_error;
 	}
 
-	mutex_lock(&pf->tc_mutex);
-
 	if (!pf->hw.port_info->qos_cfg.is_sw_lldp)
 		ice_cfg_etsrec_defaults(pf->hw.port_info);
 
Reviewed-by on v4 1/1
#1 lore raw
Quoted 59 lines

-----Original Message-----
From: Bart Van Assche <[email protected]>
Sent: Friday, March 20, 2026 10:28 PM
To: Nguyen, Anthony L <[email protected]>
Cc: Kitszel, Przemyslaw <[email protected]>; intel-wired- [email protected]; Bart Van Assche <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()

Move the mutex_lock() call up to prevent that DCB settings change after the first ice_query_port_ets() call. The second ice_query_port_ets() call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first "goto dcb_error" in the function jumped over mutex_lock() to mutex_unlock().

This bug has been detected by the clang thread-safety analyzer.

Cc Aleksandr Loktionov <[email protected]>
Fixes 242b5e068b25 ("ice: Fix DCB rebuild after reset")

---

v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".

v3 (2026-03-20): Modified patch description. See also
https://lore.kernel.org/all/20260223220102.2158611-20-
[email protected]/#t

v2 (2026-02-23): Combined the two patches into one patch and
increased the amount of code covered by tc_mutex. See also
https://lore.kernel.org/all/20260223220102.2158611-20-
[email protected]/

v1 (2025-02-06): Two patches. See also
https://lore.kernel.org/all/20250206175114.1974171-16-
[email protected]/

 drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +2 -0
index bd77f1c001ee..78ded6876581 100644
@@ -537,14 +537,14 @@ void ice_dcb_rebuild(struct ice_pf *pf)
 	struct ice_dcbx_cfg *err_cfg;
 	int ret;
 
+	mutex_lock(&pf->tc_mutex);
+
 	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf),

drivers/net/ethernet/intel/ice/ice_dcb_lib.c void ice_dcb_rebuild(struct ice_pf *pf) · line 550

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +0 -2
 NULL);
 	if (ret) {
 		dev_err(dev, "Query Port ETS failed\n");
 		goto dcb_error;
 	}
 
-	mutex_lock(&pf->tc_mutex);
-
 	if (!pf->hw.port_info->qos_cfg.is_sw_lldp)
 		ice_cfg_etsrec_defaults(pf->hw.port_info);
maintainer Reviewed-by on v4 1/1
#2 lore raw
In reply to Bart Van Assche via Intel-wired-lan
Quoted 8 lines · Bart Van Assche

Move the mutex_lock() call up to prevent that DCB settings change after the first ice_query_port_ets() call. The second ice_query_port_ets() call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first "goto dcb_error" in the function jumped over mutex_lock() to mutex_unlock().

Quoted 7 lines

This bug has been detected by the clang thread-safety analyzer.

Cc Aleksandr Loktionov <[email protected]>
Fixes 242b5e068b25 ("ice: Fix DCB rebuild after reset")

---

thank you!

Quoted 5 lines

v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".

v3 (2026-03-20): Modified patch description. See also
https://lore.kernel.org/all/[email protected]/#t

this is a link to version from Feb, I would expect to see "v3" link here, not need to repost to fix that ofc

Quoted 32 lines

v2 (2026-02-23): Combined the two patches into one patch and
increased the amount of code covered by tc_mutex. See also
https://lore.kernel.org/all/[email protected]/

v1 (2025-02-06): Two patches. See also
https://lore.kernel.org/all/[email protected]/

  drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +2 -2
index bd77f1c001ee..78ded6876581 100644
@@ -537,14 +537,14 @@ void ice_dcb_rebuild(struct ice_pf *pf)
  	struct ice_dcbx_cfg *err_cfg;
  	int ret;
 
+	mutex_lock(&pf->tc_mutex);
+
  	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
  	if (ret) {
  		dev_err(dev, "Query Port ETS failed\n");
  		goto dcb_error;
  	}
 
-	mutex_lock(&pf->tc_mutex);
-
  	if (!pf->hw.port_info->qos_cfg.is_sw_lldp)
  		ice_cfg_etsrec_defaults(pf->hw.port_info);
 
Tested-by on v4 1/1
#3 lore raw
In reply to Bart Van Assche via Intel-wired-lan
Quoted 28 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Bart Van Assche via Intel-wired-lan
Sent: Saturday, March 21, 2026 2:58 AM
To: Nguyen, Anthony L <[email protected]>
Cc: Kitszel, Przemyslaw <[email protected]>; [email protected]; Bart Van Assche <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()

Move the mutex_lock() call up to prevent that DCB settings change after the first ice_query_port_ets() call. The second ice_query_port_ets() call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first "goto dcb_error" in the function jumped over mutex_lock() to mutex_unlock().

This bug has been detected by the clang thread-safety analyzer.

Cc Aleksandr Loktionov <[email protected]>
Fixes 242b5e068b25 ("ice: Fix DCB rebuild after reset")

---

v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".

v3 (2026-03-20): Modified patch description. See also
https://lore.kernel.org/all/[email protected]/#t

v2 (2026-02-23): Combined the two patches into one patch and
increased the amount of code covered by tc_mutex. See also
https://lore.kernel.org/all/[email protected]/

Quoted 6 lines

v1 (2025-02-06): Two patches. See also
https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#4 lore raw
In reply to Bart Van Assche via Intel-wired-lan
Quoted 42 lines · Bart Van Assche

Move the mutex_lock() call up to prevent that DCB settings change after the first ice_query_port_ets() call. The second ice_query_port_ets() call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first "goto dcb_error" in the function jumped over mutex_lock() to mutex_unlock().

This bug has been detected by the clang thread-safety analyzer.

Cc Aleksandr Loktionov <[email protected]>
Fixes 242b5e068b25 ("ice: Fix DCB rebuild after reset")

---

v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".

v3 (2026-03-20): Modified patch description. See also
https://lore.kernel.org/all/[email protected]/#t

v2 (2026-02-23): Combined the two patches into one patch and
increased the amount of code covered by tc_mutex. See also
https://lore.kernel.org/all/[email protected]/

v1 (2025-02-06): Two patches. See also
https://lore.kernel.org/all/[email protected]/

  drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +2 -0
index bd77f1c001ee..78ded6876581 100644
@@ -537,14 +537,14 @@ void ice_dcb_rebuild(struct ice_pf *pf)
  	struct ice_dcbx_cfg *err_cfg;
  	int ret;
 
+	mutex_lock(&pf->tc_mutex);
+
  	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);

drivers/net/ethernet/intel/ice/ice_dcb_lib.c void ice_dcb_rebuild(struct ice_pf *pf) · line 550

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +0 -2
  	if (ret) {
  		dev_err(dev, "Query Port ETS failed\n");
  		goto dcb_error;
  	}
 
-	mutex_lock(&pf->tc_mutex);
-
  	if (!pf->hw.port_info->qos_cfg.is_sw_lldp)
  		ice_cfg_etsrec_defaults(pf->hw.port_info);
 

Hi Tony,

It seems like this patch has not made it into Linux kernel v7.1-rc. Do you agree that this patch is ready to be merged? I checked that it still applies to Linus' master branch.

Thanks,

Bart.

#5 lore raw
Quoted 59 lines · Bart Van Assche via Intel-wired-lan
Quoted 54 lines · Bart Van Assche

Move the mutex_lock() call up to prevent that DCB settings change after the first ice_query_port_ets() call. The second ice_query_port_ets() call in ice_dcb_rebuild() is already protected by pf->tc_mutex.

This also fixes a bug in an error path, as before taking the first "goto dcb_error" in the function jumped over mutex_lock() to mutex_unlock().

This bug has been detected by the clang thread-safety analyzer.

Cc Aleksandr Loktionov <[email protected]>
Fixes 242b5e068b25 ("ice: Fix DCB rebuild after reset")

---

v4 (this patch): Changed "[PATCH] iwl-net:" into "[PATCH iwl-net]".

v3 (2026-03-20): Modified patch description. See also
   https://lore.kernel.org/all/20260223220102.2158611-20-
[email protected]/#t

v2 (2026-02-23): Combined the two patches into one patch and increased the amount of code covered by tc_mutex. See also
   https://lore.kernel.org/all/20260223220102.2158611-20-
[email protected]/

v1 (2025-02-06): Two patches. See also
   https://lore.kernel.org/all/20250206175114.1974171-16-
[email protected]/

  drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ renamed from drivers/net/ethernet/intel/ice/ice_dcb_lib.c +0 -0

net/ethernet/intel/ice/ice_dcb_lib.c
index bd77f1c001ee..78ded6876581 100644

drivers/net/ethernet/intel/ice/ice_dcb_lib.c +1 -1
@@ -537,14 +537,14 @@ void ice_dcb_rebuild(struct ice_pf *pf)
       struct ice_dcbx_cfg *err_cfg;
       int ret;
   +    mutex_lock(&pf->tc_mutex);
+
       ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf),
 NULL);
       if (ret) {
           dev_err(dev, "Query Port ETS failed\n");
           goto dcb_error;
       }
   -    mutex_lock(&pf->tc_mutex);
-
       if (!pf->hw.port_info->qos_cfg.is_sw_lldp)
           ice_cfg_etsrec_defaults(pf->hw.port_info);
Quoted 1 line

Hi Tony,

Quoted 7 lines

It seems like this patch has not made it into Linux kernel v7.1-rc. Do you agree that this patch is ready to be merged? I checked that it still applies to Linus' master branch.

Thanks,

Bart.

Hi Bart,

I am covering for Tony while he is on vacation. This patch only recently completed our internal testing round. It unfortunately took a while to complete testing due to our existing backlog of patches.

I'm preparing to include it in my next round of patches to submit to netdev's net tree.

Thanks,
Jake