Skip to content

Commit 4971394

Browse files
IronShenkuba-moo
authored andcommitted
net: hns3: defer calling ptp_clock_register()
Currently the ptp_clock_register() is called before relative ptp resource ready. It may cause unexpected result when upper layer called the ptp API during the timewindow. Fix it by moving the ptp_clock_register() to the function end. Fixes: 0bf5eb7 ("net: hns3: add support for PTP") Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/20250430093052.2400464-5-shaojijie@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent e317aeb commit 4971394

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,13 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
440440
ptp->info.settime64 = hclge_ptp_settime;
441441

442442
ptp->info.n_alarm = 0;
443+
444+
spin_lock_init(&ptp->lock);
445+
ptp->io_base = hdev->hw.hw.io_base + HCLGE_PTP_REG_OFFSET;
446+
ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
447+
ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF;
448+
hdev->ptp = ptp;
449+
443450
ptp->clock = ptp_clock_register(&ptp->info, &hdev->pdev->dev);
444451
if (IS_ERR(ptp->clock)) {
445452
dev_err(&hdev->pdev->dev,
@@ -451,12 +458,6 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
451458
return -ENODEV;
452459
}
453460

454-
spin_lock_init(&ptp->lock);
455-
ptp->io_base = hdev->hw.hw.io_base + HCLGE_PTP_REG_OFFSET;
456-
ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
457-
ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF;
458-
hdev->ptp = ptp;
459-
460461
return 0;
461462
}
462463

0 commit comments

Comments
 (0)