> -----Original Message-----
> From: Zhang, Ke1X <ke1x.zh...@intel.com>
> Sent: Monday, February 13, 2023 3:03 PM
> To: Zhang, Qi Z <qi.z.zh...@intel.com>; Yang, Qiming
> <qiming.y...@intel.com>; dev@dpdk.org
> Cc: Zhang, Ke1X <ke1x.zh...@intel.com>
> Subject: [PATCH v2] net/ice: fix ice dcf contrl thread crash
> 
> The control thread accesses the hardware resources after the resources
> were released, resulting in a segment error.
> 
> This commit fixes the bug by exiting thread before resource released.
> 
> Signed-off-by: Ke Zhang <ke1x.zh...@intel.com>
> ---
> v2: add pthread_exit() for windows
> ---
>  drivers/net/ice/ice_dcf.c         | 4 ++++
>  lib/eal/windows/include/pthread.h | 5 +++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index
> 1c3d22ae0f..e58908caf5 100644
> --- a/drivers/net/ice/ice_dcf.c
> +++ b/drivers/net/ice/ice_dcf.c
> @@ -543,6 +543,8 @@ ice_dcf_handle_vsi_update_event(struct ice_dcf_hw
> *hw)
>       ice_dcf_disable_irq0(hw);
> 
>       for (;;) {
> +             if (hw->vc_event_msg_cb == NULL)
> +                     pthread_exit(NULL);
>               if (ice_dcf_get_vf_resource(hw) == 0 &&
>                   ice_dcf_get_vf_vsi_map(hw) >= 0) {
>                       err = 0;
> @@ -760,6 +762,8 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev,
> struct ice_dcf_hw *hw)
>       rte_intr_callback_unregister(intr_handle,
>                                    ice_dcf_dev_interrupt_handler, hw);
> 
> +     hw->vc_event_msg_cb = NULL;
> +
>       ice_dcf_mode_disable(hw);
>       iavf_shutdown_adminq(&hw->avf);
> 
> diff --git a/lib/eal/windows/include/pthread.h
> b/lib/eal/windows/include/pthread.h
> index 27fd2cca52..f0068ebd73 100644
> --- a/lib/eal/windows/include/pthread.h
> +++ b/lib/eal/windows/include/pthread.h

Suggest move this part into a separate patch.

> @@ -149,6 +149,11 @@ pthread_detach(__rte_unused pthread_t thread)
>       return 0;
>  }
> 
> +static inline void
> +pthread_exit(__rte_unused void *__retval) { }
> +
>  static inline int
>  pthread_join(__rte_unused pthread_t thread,
>       __rte_unused void **value_ptr)
> --
> 2.25.1

Reply via email to