[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <88d7863d-bf2f-4e32-b480-ae8d62df4818@linux.dev>
Date: Thu, 1 May 2025 00:28:33 +0100
From: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
To: Jijie Shao <shaojijie@...wei.com>, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
andrew+netdev@...n.ch, horms@...nel.org
Cc: shenjian15@...wei.com, wangpeiyang1@...wei.com, liuyonglong@...wei.com,
chenhao418@...wei.com, jonathan.cameron@...wei.com,
shameerali.kolothum.thodi@...wei.com, salil.mehta@...wei.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net 4/4] net: hns3: defer calling ptp_clock_register()
On 30/04/2025 10:30, Jijie Shao wrote:
> From: Jian Shen <shenjian15@...wei.com>
>
> 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: 0bf5eb788512 ("net: hns3: add support for PTP")
> Signed-off-by: Jian Shen <shenjian15@...wei.com>
> Signed-off-by: Jijie Shao <shaojijie@...wei.com>
> ---
> .../net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
> index 59cc9221185f..ec581d4b696f 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
> @@ -440,6 +440,13 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
> ptp->info.settime64 = hclge_ptp_settime;
>
> ptp->info.n_alarm = 0;
> +
> + spin_lock_init(&ptp->lock);
> + ptp->io_base = hdev->hw.hw.io_base + HCLGE_PTP_REG_OFFSET;
> + ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
> + ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF;
> + hdev->ptp = ptp;
> +
> ptp->clock = ptp_clock_register(&ptp->info, &hdev->pdev->dev);
> if (IS_ERR(ptp->clock)) {
> dev_err(&hdev->pdev->dev,
> @@ -451,12 +458,6 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
> return -ENODEV;
> }
>
> - spin_lock_init(&ptp->lock);
> - ptp->io_base = hdev->hw.hw.io_base + HCLGE_PTP_REG_OFFSET;
> - ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
> - ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF;
> - hdev->ptp = ptp;
> -
> return 0;
> }
>
LGTM,
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Powered by blists - more mailing lists