diff mbox series

Fix kernel panic issue after removing igb driver

Message ID 20230811120225.4133-1-marshall.shao@dell.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series Fix kernel panic issue after removing igb driver | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers warning 1 maintainers not CCed: richardcochran@gmail.com
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

marshall.shao@dell.com Aug. 11, 2023, 12:02 p.m. UTC
From: Marshall Shao <Marshall.Shao@dell.com>

This patch fixes a kernel panic issue after removing the igb driver 
from the usermode.

A delayed work will be schedule in igb_ptp_init(),

	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
		INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
				  igb_ptp_overflow_check);

If CONFIG_PTP_1588_CLOCK is not enabled, the delayed work cannot be
cancelled when igb_ptp_suspend is called.

Signed-off-by: Marshall Shao <Marshall.Shao@dell.com>
---
 drivers/net/ethernet/intel/igb/igb_ptp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Vadim Fedorenko Aug. 11, 2023, 4:12 p.m. UTC | #1
On 11/08/2023 13:02, marshall.shao@dell.com wrote:
> From: Marshall Shao <Marshall.Shao@dell.com>
> 
> This patch fixes a kernel panic issue after removing the igb driver
> from the usermode.
> 
> A delayed work will be schedule in igb_ptp_init(),
> 
> 	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
> 		INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
> 				  igb_ptp_overflow_check);
> 
> If CONFIG_PTP_1588_CLOCK is not enabled, the delayed work cannot be
> cancelled when igb_ptp_suspend is called.

But should this work be inited in case there is no PTP support in the
kernel? Maybe it's better to avoid any driver threads in this case and
move the initialization to the if block where we know that PHC device
is created and working?

> 
> Signed-off-by: Marshall Shao <Marshall.Shao@dell.com>
> ---
>   drivers/net/ethernet/intel/igb/igb_ptp.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
> index 405886ee5261..b21822ea1c7d 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ptp.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
> @@ -1435,12 +1435,12 @@ void igb_ptp_sdp_init(struct igb_adapter *adapter)
>    */
>   void igb_ptp_suspend(struct igb_adapter *adapter)
>   {
> -	if (!(adapter->ptp_flags & IGB_PTP_ENABLED))
> -		return;
> -
>   	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
>   		cancel_delayed_work_sync(&adapter->ptp_overflow_work);
>   
> +	if (!(adapter->ptp_flags & IGB_PTP_ENABLED))
> +		return;
> +
>   	cancel_work_sync(&adapter->ptp_tx_work);
>   	if (adapter->ptp_tx_skb) {
>   		dev_kfree_skb_any(adapter->ptp_tx_skb);
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 405886ee5261..b21822ea1c7d 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -1435,12 +1435,12 @@  void igb_ptp_sdp_init(struct igb_adapter *adapter)
  */
 void igb_ptp_suspend(struct igb_adapter *adapter)
 {
-	if (!(adapter->ptp_flags & IGB_PTP_ENABLED))
-		return;
-
 	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
 		cancel_delayed_work_sync(&adapter->ptp_overflow_work);
 
+	if (!(adapter->ptp_flags & IGB_PTP_ENABLED))
+		return;
+
 	cancel_work_sync(&adapter->ptp_tx_work);
 	if (adapter->ptp_tx_skb) {
 		dev_kfree_skb_any(adapter->ptp_tx_skb);