Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
@ 2026-03-20 21:28 Bart Van Assche via Intel-wired-lan
  2026-03-20 21:35 ` Loktionov, Aleksandr
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Bart Van Assche via Intel-wired-lan @ 2026-03-20 21:28 UTC (permalink / raw)
  To: Tony Nguyen
  Cc: Przemek Kitszel, intel-wired-lan, Bart Van Assche,
	Aleksandr Loktionov

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 <aleksandr.loktionov@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---

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-bart.vanassche@linux.dev/#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-bart.vanassche@linux.dev/

v1 (2025-02-06): Two patches. See also
  https://lore.kernel.org/all/20250206175114.1974171-16-bvanassche@acm.org/

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

diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
index bd77f1c001ee..78ded6876581 100644
--- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
@@ -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);
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
  2026-03-20 21:28 [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild() Bart Van Assche via Intel-wired-lan
@ 2026-03-20 21:35 ` Loktionov, Aleksandr
  2026-03-26  4:26 ` Przemek Kitszel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Loktionov, Aleksandr @ 2026-03-20 21:35 UTC (permalink / raw)
  To: Bart Van Assche, Nguyen, Anthony L
  Cc: Kitszel, Przemyslaw, intel-wired-lan@lists.osuosl.org



> -----Original Message-----
> From: Bart Van Assche <bvanassche@acm.org>
> Sent: Friday, March 20, 2026 10:28 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Cc: Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>; intel-wired-
> lan@lists.osuosl.org; Bart Van Assche <bvanassche@acm.org>; Loktionov,
> Aleksandr <aleksandr.loktionov@intel.com>
> 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 <aleksandr.loktionov@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org
> Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> 
> 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-
> bart.vanassche@linux.dev/#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-
> bart.vanassche@linux.dev/
> 
> v1 (2025-02-06): Two patches. See also
>   https://lore.kernel.org/all/20250206175114.1974171-16-
> bvanassche@acm.org/
> 
>  drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> index bd77f1c001ee..78ded6876581 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> @@ -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: Aleksandr Loktionov <aleksandr.loktionov@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
  2026-03-20 21:28 [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild() Bart Van Assche via Intel-wired-lan
  2026-03-20 21:35 ` Loktionov, Aleksandr
@ 2026-03-26  4:26 ` Przemek Kitszel
  2026-04-22 12:18 ` Arland, ArpanaX
  2026-04-27 17:49 ` Bart Van Assche via Intel-wired-lan
  3 siblings, 0 replies; 6+ messages in thread
From: Przemek Kitszel @ 2026-03-26  4:26 UTC (permalink / raw)
  To: Bart Van Assche, Tony Nguyen; +Cc: intel-wired-lan, Aleksandr Loktionov

On 3/20/26 22:28, Bart Van Assche wrote:
> 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 <aleksandr.loktionov@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org
> Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---

thank you!
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

> 
> 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-bart.vanassche@linux.dev/#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

> 
> 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-bart.vanassche@linux.dev/
> 
> v1 (2025-02-06): Two patches. See also
>    https://lore.kernel.org/all/20250206175114.1974171-16-bvanassche@acm.org/
> 
>   drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> index bd77f1c001ee..78ded6876581 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> @@ -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);
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
  2026-03-20 21:28 [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild() Bart Van Assche via Intel-wired-lan
  2026-03-20 21:35 ` Loktionov, Aleksandr
  2026-03-26  4:26 ` Przemek Kitszel
@ 2026-04-22 12:18 ` Arland, ArpanaX
  2026-04-27 17:49 ` Bart Van Assche via Intel-wired-lan
  3 siblings, 0 replies; 6+ messages in thread
From: Arland, ArpanaX @ 2026-04-22 12:18 UTC (permalink / raw)
  To: Bart Van Assche, Nguyen, Anthony L
  Cc: Kitszel, Przemyslaw, intel-wired-lan@lists.osuosl.org,
	Loktionov, Aleksandr

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Bart Van Assche via Intel-wired-lan
> Sent: Saturday, March 21, 2026 2:58 AM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Cc: Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>; intel-wired-lan@lists.osuosl.org; Bart Van Assche <bvanassche@acm.org>; Loktionov, Aleksandr <aleksandr.loktionov@intel.com>
> 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 <aleksandr.loktionov@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org
> Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>
> 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-bart.vanassche@linux.dev/#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-bart.vanassche@linux.dev/
>
> v1 (2025-02-06): Two patches. See also
>   https://lore.kernel.org/all/20250206175114.1974171-16-bvanassche@acm.org/
>
>  drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
 
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
  2026-03-20 21:28 [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild() Bart Van Assche via Intel-wired-lan
                   ` (2 preceding siblings ...)
  2026-04-22 12:18 ` Arland, ArpanaX
@ 2026-04-27 17:49 ` Bart Van Assche via Intel-wired-lan
  2026-05-04 23:55   ` Jacob Keller
  3 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche via Intel-wired-lan @ 2026-04-27 17:49 UTC (permalink / raw)
  To: Tony Nguyen; +Cc: Przemek Kitszel, intel-wired-lan, Aleksandr Loktionov

On 3/20/26 2:28 PM, Bart Van Assche wrote:
> 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 <aleksandr.loktionov@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org
> Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> 
> 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-bart.vanassche@linux.dev/#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-bart.vanassche@linux.dev/
> 
> v1 (2025-02-06): Two patches. See also
>    https://lore.kernel.org/all/20250206175114.1974171-16-bvanassche@acm.org/
> 
>   drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> index bd77f1c001ee..78ded6876581 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
> @@ -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);
>   

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild()
  2026-04-27 17:49 ` Bart Van Assche via Intel-wired-lan
@ 2026-05-04 23:55   ` Jacob Keller
  0 siblings, 0 replies; 6+ messages in thread
From: Jacob Keller @ 2026-05-04 23:55 UTC (permalink / raw)
  To: Bart Van Assche, Tony Nguyen
  Cc: Przemek Kitszel, intel-wired-lan, Aleksandr Loktionov

On 4/27/2026 10:49 AM, Bart Van Assche via Intel-wired-lan wrote:
> On 3/20/26 2:28 PM, Bart Van Assche wrote:
>> 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 <aleksandr.loktionov@intel.com>
>> Cc: intel-wired-lan@lists.osuosl.org
>> Fixes: 242b5e068b25 ("ice: Fix DCB rebuild after reset")
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> ---
>>
>> 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-
>> bart.vanassche@linux.dev/#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-
>> bart.vanassche@linux.dev/
>>
>> v1 (2025-02-06): Two patches. See also
>>    https://lore.kernel.org/all/20250206175114.1974171-16-
>> bvanassche@acm.org/
>>
>>   drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/
>> net/ethernet/intel/ice/ice_dcb_lib.c
>> index bd77f1c001ee..78ded6876581 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
>> @@ -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);
>>   
> 
> 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.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-04 23:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 21:28 [Intel-wired-lan] [PATCH iwl-net v4] ice: fix locking in ice_dcb_rebuild() Bart Van Assche via Intel-wired-lan
2026-03-20 21:35 ` Loktionov, Aleksandr
2026-03-26  4:26 ` Przemek Kitszel
2026-04-22 12:18 ` Arland, ArpanaX
2026-04-27 17:49 ` Bart Van Assche via Intel-wired-lan
2026-05-04 23:55   ` Jacob Keller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox