From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 738CA42C10 for ; Fri, 2 Jun 2023 12:55:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7046D42B8C; Fri, 2 Jun 2023 12:55:49 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id E2C34406B8; Fri, 2 Jun 2023 12:55:46 +0200 (CEST) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QXftY4DdkzqTPv; Fri, 2 Jun 2023 18:51:01 +0800 (CST) Received: from [10.67.103.235] (10.67.103.235) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 2 Jun 2023 18:55:43 +0800 Subject: Re: [PATCH 01/11] net/hns3: fix uninitialized RTC time To: Ferruh Yigit , , , , References: <20230529130940.1501-1-liudongdong3@huawei.com> <20230529130940.1501-2-liudongdong3@huawei.com> CC: , , , From: Dongdong Liu Message-ID: <069c14f1-75e5-ad3b-5bb8-a50b8dbf85d7@huawei.com> Date: Fri, 2 Jun 2023 18:55:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.235] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi Ferruh Many thanks for your review. On 2023/6/2 17:00, Ferruh Yigit wrote: > On 5/29/2023 2:09 PM, Dongdong Liu wrote: >> From: Huisong Li >> >> Driver doesn't initialize RTC time during probe phase, which >> lead to an inaccurate time. >> >> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") >> Cc: stable@dpdk.org >> >> Signed-off-by: Huisong Li >> Signed-off-by: Dongdong Liu >> --- >> drivers/net/hns3/hns3_ptp.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c >> index db3c007b12..fb834bb180 100644 >> --- a/drivers/net/hns3/hns3_ptp.c >> +++ b/drivers/net/hns3/hns3_ptp.c >> @@ -59,6 +59,8 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en) >> int >> hns3_ptp_init(struct hns3_hw *hw) >> { >> + struct timespec sys_time; >> + struct rte_eth_dev *dev; >> int ret; >> >> if (!hns3_dev_get_support(hw, PTP)) >> @@ -71,6 +73,11 @@ hns3_ptp_init(struct hns3_hw *hw) >> /* Start PTP timer */ >> hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1); >> >> + /* Initializing the RTC. */ >> + dev = &rte_eth_devices[hw->data->port_id]; > > > Better to not access 'rte_eth_devices[]' global array directly from the > driver, driver should keep reference to the eth_dev internally. > > 'hns3_timesync_write_time()' already gets 'hw' from 'eth_dev' and uses > it. Perhaps 'hns3_timesync_write_time()' should get 'hw' as paramter. > > Since 'hns3_timesync_write_time()' used for dev_ops, it is possible to > get internal version of it, like: > > ``` > hns3_timesync_write_time_(struct hns3_hw *hw, timespec *ts) { > } > > hns3_timesync_write_time(struct rte_eth_dev *dev, timespec *ts) { > struct hns3_hw *hw = ; > > hns3_timesync_write_time_(hw, ts); > } > ``` > > And this function can directly use internal version. Good point. Will fix in v2. Thanks, Dongdong > > >> + clock_gettime(CLOCK_REALTIME, &sys_time); >> + (void)hns3_timesync_write_time(dev, &sys_time); >> + >> return 0; >> } >> > > . >