Skip to content

Commit 2f68bee

Browse files
IronShenjfvogel
authored andcommitted
net: hns3: defer calling ptp_clock_register()
[ Upstream commit 4971394d9d624f91689d766f31ce668d169d9959 ] 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 <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 7f9c3e2213ad68334966cea47dc703b93b788548) Signed-off-by: Jack Vogel <[email protected]>
1 parent 560951e commit 2f68bee

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
@@ -439,6 +439,13 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
439439
ptp->info.settime64 = hclge_ptp_settime;
440440

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

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

0 commit comments

Comments
 (0)