Skip to contentSkip to conversation

sfc: create PPS workqueue before registering phc

PATCH In review Alex Austin 3 participants 4 messages Nov 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sfc: create PPS workqueue before registering phc

Registering the PHC before creating the PPS workqueue leaves a small window for PTP_CLK_REQ_PPS to be requested and a NIC generated PPS event to arrive before the workqueue exists. Create the PPS workqueue before registering the PHC.

Fixes 7c236c43b838 ("sfc: Add support for IEEE-1588 PTP")
---
 drivers/net/ethernet/sfc/ptp.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/sfc/ptp.c +13 -13
index 37511f234d76..ad6a4e7d990f 100644
@@ -1633,26 +1633,26 @@ int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel)
 
 	if (efx->mcdi->fn_flags &
 	    (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY)) {
+		INIT_WORK(&ptp->pps_work, efx_ptp_pps_worker);
+		ptp->pps_workwq = create_singlethread_workqueue("sfc_pps");
+		if (!ptp->pps_workwq) {
+			rc = -ENOMEM;
+			goto fail3;
+		}
+
 		ptp->phc_clock_info = efx_phc_clock_info;
 		ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info,
 						    &efx->pci_dev->dev);
 		if (IS_ERR(ptp->phc_clock)) {
 			rc = PTR_ERR(ptp->phc_clock);
-			goto fail3;
-		} else if (ptp->phc_clock) {
-			INIT_WORK(&ptp->pps_work, efx_ptp_pps_worker);
-			ptp->pps_workwq = create_singlethread_workqueue("sfc_pps");
-			if (!ptp->pps_workwq) {
-				rc = -ENOMEM;
-				goto fail4;
-			}
+			goto fail4;
 		}
 	}
 	ptp->nic_ts_enabled = false;
 
 	return 0;
 fail4:
-	ptp_clock_unregister(efx->ptp_data->phc_clock);
+	destroy_workqueue(efx->ptp_data->pps_workwq);
 
 fail3:
 	destroy_workqueue(efx->ptp_data->workwq);
@@ -1702,16 +1702,16 @@ void efx_ptp_remove(struct efx_nic *efx)
 
 	cancel_work_sync(&efx->ptp_data->work);
 	cancel_delayed_work_sync(&efx->ptp_data->cleanup_work);
-	if (efx->ptp_data->pps_workwq)
+	if (efx->ptp_data->pps_workwq) {
 		cancel_work_sync(&efx->ptp_data->pps_work);
+		destroy_workqueue(efx->ptp_data->pps_workwq);
+	}
 
 	skb_queue_purge(&efx->ptp_data->rxq);
 	skb_queue_purge(&efx->ptp_data->txq);
 
-	if (efx->ptp_data->phc_clock) {
-		destroy_workqueue(efx->ptp_data->pps_workwq);
+	if (efx->ptp_data->phc_clock)
 		ptp_clock_unregister(efx->ptp_data->phc_clock);
-	}
 
 	destroy_workqueue(efx->ptp_data->workwq);
 

---
base-commit: 9068e05d35f3b02a802f520e664032f802bcd2e9
change-id: 20261120-sfc_pps_wq_fix-2ed4ecc4c345

Best regards,

Signature · 1 line
Alex Austin <[email protected]>
#1 lore raw
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
#2 lore raw
Quoted 22 lines · On 20/11/2026 08:47, [email protected] wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

Quoted 5 lines

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. --
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.

This issue is theoretical and was found by manual code inspection. Tested on AMD Solarflare X2522-25G.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Alex Austin
Quoted 77 lines · Alex Austin

Registering the PHC before creating the PPS workqueue leaves a small window for PTP_CLK_REQ_PPS to be requested and a NIC generated PPS event to arrive before the workqueue exists. Create the PPS workqueue before registering the PHC.

Fixes 7c236c43b838 ("sfc: Add support for IEEE-1588 PTP")
---
 drivers/net/ethernet/sfc/ptp.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/sfc/ptp.c +13 -14
index 37511f234d76..ad6a4e7d990f 100644
@@ -1633,26 +1633,26 @@ int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel)
 
 	if (efx->mcdi->fn_flags &
 	    (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY)) {
+		INIT_WORK(&ptp->pps_work, efx_ptp_pps_worker);
+		ptp->pps_workwq = create_singlethread_workqueue("sfc_pps");
+		if (!ptp->pps_workwq) {
+			rc = -ENOMEM;
+			goto fail3;
+		}
+
 		ptp->phc_clock_info = efx_phc_clock_info;
 		ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info,
 						    &efx->pci_dev->dev);
 		if (IS_ERR(ptp->phc_clock)) {
 			rc = PTR_ERR(ptp->phc_clock);
-			goto fail3;
-		} else if (ptp->phc_clock) {
-			INIT_WORK(&ptp->pps_work, efx_ptp_pps_worker);
-			ptp->pps_workwq = create_singlethread_workqueue("sfc_pps");
-			if (!ptp->pps_workwq) {
-				rc = -ENOMEM;
-				goto fail4;
-			}
+			goto fail4;
 		}
 	}
 	ptp->nic_ts_enabled = false;
 
 	return 0;
 fail4:
-	ptp_clock_unregister(efx->ptp_data->phc_clock);
+	destroy_workqueue(efx->ptp_data->pps_workwq);
 
 fail3:
 	destroy_workqueue(efx->ptp_data->workwq);
@@ -1702,16 +1702,16 @@ void efx_ptp_remove(struct efx_nic *efx)
 
 	cancel_work_sync(&efx->ptp_data->work);
 	cancel_delayed_work_sync(&efx->ptp_data->cleanup_work);
-	if (efx->ptp_data->pps_workwq)
+	if (efx->ptp_data->pps_workwq) {
 		cancel_work_sync(&efx->ptp_data->pps_work);
+		destroy_workqueue(efx->ptp_data->pps_workwq);
+	}
 
 	skb_queue_purge(&efx->ptp_data->rxq);
 	skb_queue_purge(&efx->ptp_data->txq);
 
-	if (efx->ptp_data->phc_clock) {
-		destroy_workqueue(efx->ptp_data->pps_workwq);
+	if (efx->ptp_data->phc_clock)
 		ptp_clock_unregister(efx->ptp_data->phc_clock);
-	}
 
 	destroy_workqueue(efx->ptp_data->workwq);
 
 
---

base-commit: 9068e05d35f3b02a802f520e664032f802bcd2e9
change-id: 20261120-sfc_pps_wq_fix-2ed4ecc4c345

Quoted 4 lines

Best regards,

Signature · 1 line
Alex Austin <[email protected]>