Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH] igb: Unconditionally deallocate workqueues as allocation already does
@ 2023-07-18 13:45 Alessio Igor Bogani
  2023-07-19 21:18 ` Tony Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Alessio Igor Bogani @ 2023-07-18 13:45 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Alessio Igor Bogani

The workqueues ptp_tx_work and ptp_overflow_work are unconditionally allocated
by igb_ptp_init() but, at the moment, are deallocated only if the flag
IGB_PTP_ENABLED is on which isn't the case if there are errors or
if CONFIG_PTP is disabled.

Otherwise, when we unbind the igb driver with vfio-pci we receive a stack trace:
BUG: unable to handle page fault for address: ffffc9000440b6f8
[...]
Workqueue: events igb_ptp_overflow_check
RIP: 0010:igb_rd32+0x1f/0x60
[...]
Call Trace:
 igb_ptp_read_82580+0x20/0x50
 timecounter_read+0x15/0x60
 igb_ptp_overflow_check+0x1a/0x50
 process_one_work+0x1cb/0x3c0
 worker_thread+0x53/0x3f0
 ? rescuer_thread+0x370/0x370
 kthread+0x142/0x160
 ? kthread_associate_blkcg+0xc0/0xc0
 ret_from_fork+0x1f/0x30
---
 drivers/net/ethernet/intel/igb/igb_ptp.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 6f471b91f562..56839bf65c13 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -1440,9 +1440,6 @@ 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);
 
-- 
2.17.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* Re: [Intel-wired-lan] [PATCH] igb: Unconditionally deallocate workqueues as allocation already does
  2023-07-18 13:45 [Intel-wired-lan] [PATCH] igb: Unconditionally deallocate workqueues as allocation already does Alessio Igor Bogani
@ 2023-07-19 21:18 ` Tony Nguyen
  2023-07-20 14:50   ` [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues Alessio Igor Bogani
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Nguyen @ 2023-07-19 21:18 UTC (permalink / raw)
  To: Alessio Igor Bogani, intel-wired-lan

On 7/18/2023 6:45 AM, Alessio Igor Bogani wrote:
> The workqueues ptp_tx_work and ptp_overflow_work are unconditionally allocated
> by igb_ptp_init() but, at the moment, are deallocated only if the flag
> IGB_PTP_ENABLED is on which isn't the case if there are errors or
> if CONFIG_PTP is disabled.
> 
> Otherwise, when we unbind the igb driver with vfio-pci we receive a stack trace:
> BUG: unable to handle page fault for address: ffffc9000440b6f8
> [...]
> Workqueue: events igb_ptp_overflow_check
> RIP: 0010:igb_rd32+0x1f/0x60
> [...]
> Call Trace:
>   igb_ptp_read_82580+0x20/0x50
>   timecounter_read+0x15/0x60
>   igb_ptp_overflow_check+0x1a/0x50
>   process_one_work+0x1cb/0x3c0
>   worker_thread+0x53/0x3f0
>   ? rescuer_thread+0x370/0x370
>   kthread+0x142/0x160
>   ? kthread_associate_blkcg+0xc0/0xc0
>   ret_from_fork+0x1f/0x30

Process-wise. If you can please specify the tree you are targeting and, 
as this is a fix, you should add a Fixes: tag.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#netdev-faq

This is also missing your sign-off

> ---
>   drivers/net/ethernet/intel/igb/igb_ptp.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
> index 6f471b91f562..56839bf65c13 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ptp.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
> @@ -1440,9 +1440,6 @@ 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;
> -

There are cases where the workqueues are not setup (and IGB_PTP_ENABLED 
not set); this safeguards against those situations. I think the better 
fix would be to not have the workqueues if PTP is not enabled.

>   	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
>   		cancel_delayed_work_sync(&adapter->ptp_overflow_work);
>   
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues
  2023-07-19 21:18 ` Tony Nguyen
@ 2023-07-20 14:50   ` Alessio Igor Bogani
  2023-07-21 17:15     ` Tony Nguyen
  2023-08-21  5:47     ` Arland, ArpanaX
  0 siblings, 2 replies; 5+ messages in thread
From: Alessio Igor Bogani @ 2023-07-20 14:50 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Alessio Igor Bogani

if ptp_clock_register() fails or CONFIG_PTP isn't enabled avoid starting PTP related workqueues.

In this way we can fix this:
 BUG: unable to handle page fault for address: ffffc9000440b6f8
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 100000067 P4D 100000067 PUD 1001e0067 PMD 107dc5067 PTE 0
 Oops: 0000 [#1] PREEMPT SMP
 [...]
 Workqueue: events igb_ptp_overflow_check
 RIP: 0010:igb_rd32+0x1f/0x60
 [...]
 Call Trace:
  igb_ptp_read_82580+0x20/0x50
  timecounter_read+0x15/0x60
  igb_ptp_overflow_check+0x1a/0x50
  process_one_work+0x1cb/0x3c0
  worker_thread+0x53/0x3f0
  ? rescuer_thread+0x370/0x370
  kthread+0x142/0x160
  ? kthread_associate_blkcg+0xc0/0xc0
  ret_from_fork+0x1f/0x30

Fixes: 1f6e8178d685 ("igb: Prevent dropped Tx timestamps via work items and interrupts.")
Fixes: d339b1331616 ("igb: add PTP Hardware Clock code")
Signed-off-by: Alessio Igor Bogani <alessio.bogani@elettra.eu>
---
 drivers/net/ethernet/intel/igb/igb_ptp.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 6f471b91f562..8165232052c8 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -1390,18 +1390,6 @@ void igb_ptp_init(struct igb_adapter *adapter)
 		return;
 	}
 
-	spin_lock_init(&adapter->tmreg_lock);
-	INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
-
-	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
-		INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
-				  igb_ptp_overflow_check);
-
-	adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
-	adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
-
-	igb_ptp_reset(adapter);
-
 	adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
 						&adapter->pdev->dev);
 	if (IS_ERR(adapter->ptp_clock)) {
@@ -1411,6 +1399,18 @@ void igb_ptp_init(struct igb_adapter *adapter)
 		dev_info(&adapter->pdev->dev, "added PHC on %s\n",
 			 adapter->netdev->name);
 		adapter->ptp_flags |= IGB_PTP_ENABLED;
+
+		spin_lock_init(&adapter->tmreg_lock);
+		INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
+
+		if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
+			INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
+					  igb_ptp_overflow_check);
+
+		adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
+		adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
+
+		igb_ptp_reset(adapter);
 	}
 }
 
-- 
2.17.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* Re: [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues
  2023-07-20 14:50   ` [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues Alessio Igor Bogani
@ 2023-07-21 17:15     ` Tony Nguyen
  2023-08-21  5:47     ` Arland, ArpanaX
  1 sibling, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2023-07-21 17:15 UTC (permalink / raw)
  To: Alessio Igor Bogani, intel-wired-lan

On 7/20/2023 7:50 AM, Alessio Igor Bogani wrote:

Please designate a tree for your patch (net or net-next). As you have a 
Fixes, I assume it's net, but please be explicit.

> if ptp_clock_register() fails or CONFIG_PTP isn't enabled avoid starting PTP related workqueues.
> 
> In this way we can fix this:
>   BUG: unable to handle page fault for address: ffffc9000440b6f8
>   #PF: supervisor read access in kernel mode
>   #PF: error_code(0x0000) - not-present page
>   PGD 100000067 P4D 100000067 PUD 1001e0067 PMD 107dc5067 PTE 0
>   Oops: 0000 [#1] PREEMPT SMP
>   [...]
>   Workqueue: events igb_ptp_overflow_check
>   RIP: 0010:igb_rd32+0x1f/0x60
>   [...]
>   Call Trace:
>    igb_ptp_read_82580+0x20/0x50
>    timecounter_read+0x15/0x60
>    igb_ptp_overflow_check+0x1a/0x50
>    process_one_work+0x1cb/0x3c0
>    worker_thread+0x53/0x3f0
>    ? rescuer_thread+0x370/0x370
>    kthread+0x142/0x160
>    ? kthread_associate_blkcg+0xc0/0xc0
>    ret_from_fork+0x1f/0x30
> 
> Fixes: 1f6e8178d685 ("igb: Prevent dropped Tx timestamps via work items and interrupts.")
> Fixes: d339b1331616 ("igb: add PTP Hardware Clock code")
> Signed-off-by: Alessio Igor Bogani <alessio.bogani@elettra.eu>
> ---
>   drivers/net/ethernet/intel/igb/igb_ptp.c | 24 ++++++++++++------------
>   1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
> index 6f471b91f562..8165232052c8 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ptp.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
> @@ -1390,18 +1390,6 @@ void igb_ptp_init(struct igb_adapter *adapter)
>   		return;
>   	}
>   
> -	spin_lock_init(&adapter->tmreg_lock);
> -	INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
> -
> -	if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
> -		INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
> -				  igb_ptp_overflow_check);
> -
> -	adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
> -	adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
> -
> -	igb_ptp_reset(adapter);
> -
>   	adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
>   						&adapter->pdev->dev);
>   	if (IS_ERR(adapter->ptp_clock)) {
> @@ -1411,6 +1399,18 @@ void igb_ptp_init(struct igb_adapter *adapter)
>   		dev_info(&adapter->pdev->dev, "added PHC on %s\n",
>   			 adapter->netdev->name);
>   		adapter->ptp_flags |= IGB_PTP_ENABLED;
> +
> +		spin_lock_init(&adapter->tmreg_lock);
> +		INIT_WORK(&adapter->ptp_tx_work, igb_ptp_tx_work);
> +
> +		if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
> +			INIT_DELAYED_WORK(&adapter->ptp_overflow_work,
> +					  igb_ptp_overflow_check);
> +
> +		adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
> +		adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
> +
> +		igb_ptp_reset(adapter);

This concerns me that the PTP clock will be registered before 
initialization is complete/ready. I would prefer to see cleanup being 
done for the error case; have everything setup for the register, but 
remove the workqueues if we failed.

>   	}
>   }
>   
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* Re: [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues
  2023-07-20 14:50   ` [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues Alessio Igor Bogani
  2023-07-21 17:15     ` Tony Nguyen
@ 2023-08-21  5:47     ` Arland, ArpanaX
  1 sibling, 0 replies; 5+ messages in thread
From: Arland, ArpanaX @ 2023-08-21  5:47 UTC (permalink / raw)
  To: Alessio Igor Bogani, intel-wired-lan@lists.osuosl.org

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Alessio Igor Bogani
> Sent: Thursday, July 20, 2023 8:20 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: Alessio Igor Bogani <alessio.bogani@elettra.eu>
> Subject: [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues
>
> if ptp_clock_register() fails or CONFIG_PTP isn't enabled avoid starting PTP related workqueues.
>
> In this way we can fix this:
>  BUG: unable to handle page fault for address: ffffc9000440b6f8
>  #PF: supervisor read access in kernel mode
>  #PF: error_code(0x0000) - not-present page  PGD 100000067 P4D 100000067 PUD 1001e0067 PMD 107dc5067 PTE 0
>  Oops: 0000 [#1] PREEMPT SMP
>  [...]
>  Workqueue: events igb_ptp_overflow_check
>  RIP: 0010:igb_rd32+0x1f/0x60
>  [...]
>  Call Trace:
>   igb_ptp_read_82580+0x20/0x50
>   timecounter_read+0x15/0x60
>   igb_ptp_overflow_check+0x1a/0x50
>   process_one_work+0x1cb/0x3c0
>   worker_thread+0x53/0x3f0
>   ? rescuer_thread+0x370/0x370
>   kthread+0x142/0x160
>   ? kthread_associate_blkcg+0xc0/0xc0
>   ret_from_fork+0x1f/0x30
>
> Fixes: 1f6e8178d685 ("igb: Prevent dropped Tx timestamps via work items and interrupts.")
> Fixes: d339b1331616 ("igb: add PTP Hardware Clock code")
> Signed-off-by: Alessio Igor Bogani <alessio.bogani@elettra.eu>
> ---
>  drivers/net/ethernet/intel/igb/igb_ptp.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>

Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
_______________________________________________
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

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

end of thread, other threads:[~2023-08-21  5:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 13:45 [Intel-wired-lan] [PATCH] igb: Unconditionally deallocate workqueues as allocation already does Alessio Igor Bogani
2023-07-19 21:18 ` Tony Nguyen
2023-07-20 14:50   ` [Intel-wired-lan] [PATCH] igb: Avoid starting unnecessary workqueues Alessio Igor Bogani
2023-07-21 17:15     ` Tony Nguyen
2023-08-21  5:47     ` Arland, ArpanaX

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