From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6FBFC47082 for ; Sat, 5 Jun 2021 09:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B9F3613F1 for ; Sat, 5 Jun 2021 09:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbhFEJ4f (ORCPT ); Sat, 5 Jun 2021 05:56:35 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:4318 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhFEJ4e (ORCPT ); Sat, 5 Jun 2021 05:56:34 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Fxvxg0nw2z1BGQj; Sat, 5 Jun 2021 17:49:59 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Sat, 5 Jun 2021 17:54:45 +0800 Received: from [10.67.102.67] (10.67.102.67) by dggemi759-chm.china.huawei.com (10.1.198.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sat, 5 Jun 2021 17:54:45 +0800 Subject: Re: [RESEND net-next 1/2] net: hns3: add support for PTP To: Richard Cochran CC: , , , , , , References: <1622602664-20274-1-git-send-email-huangguangbin2@huawei.com> <1622602664-20274-2-git-send-email-huangguangbin2@huawei.com> <20210603131452.GA6216@hoboy.vegasvil.org> From: "huangguangbin (A)" Message-ID: <4b2247bc-605e-3aca-3bcb-c06477cd2f2e@huawei.com> Date: Sat, 5 Jun 2021 17:54:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20210603131452.GA6216@hoboy.vegasvil.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.67] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggemi759-chm.china.huawei.com (10.1.198.145) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2021/6/3 21:14, Richard Cochran wrote: > On Wed, Jun 02, 2021 at 10:57:43AM +0800, Guangbin Huang wrote: > >> @@ -4342,12 +4352,34 @@ static void hclge_periodic_service_task(struct hclge_dev *hdev) >> hclge_task_schedule(hdev, delta); >> } >> >> +static void hclge_ptp_service_task(struct hclge_dev *hdev) >> +{ >> + if (!test_bit(HCLGE_STATE_PTP_EN, &hdev->state) || >> + !test_bit(HCLGE_STATE_PTP_TX_HANDLING, &hdev->state) || >> + !time_is_before_jiffies(hdev->ptp->tx_start + HZ)) >> + return; >> + >> + /* to prevent concurrence with the irq handler, disable vector0 >> + * before handling ptp service task. >> + */ >> + disable_irq(hdev->misc_vector.vector_irq); > > This won't work. After all, the ISR thread might already be running. > Use a proper spinlock instead. > Thanks for review. Using spinlock in irq_handler looks heavy, what about adding a new flag HCLGE_STATE_PTP_CLEANING_TX_HWTS for hclge_ptp_clean_tx_hwts()? Function hclge_ptp_clean_tx_hwts() test and set this flag at the beginning and clean it in the end. Do you think it is Ok? Thanks, Guangbin . >> + /* check HCLGE_STATE_PTP_TX_HANDLING here again, since the irq >> + * handler may handle it just before disable_irq(). >> + */ >> + if (test_bit(HCLGE_STATE_PTP_TX_HANDLING, &hdev->state)) >> + hclge_ptp_clean_tx_hwts(hdev); >> + >> + enable_irq(hdev->misc_vector.vector_irq); >> +} > > Thanks, > Richard > . >