> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-boun...@osuosl.org> On Behalf Of
> Michal Schmidt
> Sent: Tuesday, October 10, 2023 2:25 AM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L <anthony.l.ngu...@intel.com>; Radoslaw Tyl
> <radoslawx....@intel.com>; Brandeburg, Jesse <jesse.brandeb...@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next 2/5] iavf: simplify
> mutex_trylock+sleep loops
> 
> This pattern appears in two places in the iavf source code:
>   while (!mutex_trylock(...))
>       usleep_range(...);

I found a few other places with similar pattern (iavf_configure_clsflower e.g).
Do you think we can fix them as well?

> 
> That's just mutex_lock with extra steps.
> The pattern is a leftover from when iavf used bit flags instead of
> mutexes for locking. Commit 5ac49f3c2702 ("iavf: use mutexes for locking
> of critical sections") replaced test_and_set_bit with !mutex_trylock,
> preserving the pattern.
> 
> Simplify it to mutex_lock.
> 
> Signed-off-by: Michal Schmidt <mschm...@redhat.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 98ecf5d5a2f2..03156ca523fe 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -3016,8 +3016,7 @@ static void iavf_reset_task(struct work_struct
> *work)
>               return;
>       }
> 
> -     while (!mutex_trylock(&adapter->client_lock))
> -             usleep_range(500, 1000);
> +     mutex_lock(&adapter->client_lock);
>       if (CLIENT_ENABLED(adapter)) {
>               adapter->flags &= ~(IAVF_FLAG_CLIENT_NEEDS_OPEN |
>                                   IAVF_FLAG_CLIENT_NEEDS_CLOSE |
> @@ -5069,8 +5068,7 @@ static int __maybe_unused iavf_suspend(struct
> device *dev_d)
> 
>       netif_device_detach(netdev);
> 
> -     while (!mutex_trylock(&adapter->crit_lock))
> -             usleep_range(500, 1000);
> +     mutex_lock(&adapter->crit_lock);
> 
>       if (netif_running(netdev)) {
>               rtnl_lock();
> --
> 2.41.0
> 
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Reply via email to