Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1781024pxj; Sat, 5 Jun 2021 02:56:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1+QfS5wxT8xpZHJ2Iu8PEuyLskcYfPUupMby/+WDQMH9ZGKHtkvWi7SrEUiJvGzdukY5j X-Received: by 2002:a17:906:3845:: with SMTP id w5mr8403164ejc.466.1622886999239; Sat, 05 Jun 2021 02:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622886999; cv=none; d=google.com; s=arc-20160816; b=P3B9eQVklT/4d70dv3ggRKic9POfF2ujs+SdKmk8mxbjgPfQ8sXw/w0VV2untCIl/j sPvxNhHmhu1/B4r2jx2sU+iZvbyZpQLP+oCCxuyA24EpJgPqJS/KuDyeDtm1cfhwS3mR ZxJJCg5RtJWpNlBZqGQ8HBK51qfpnlI++4E5evFgiiPH+fgJFfUGniD2hG3mJIt8SjjR Ld3wA4UUPMb9L0T+FwmGwtFfLk5MLo4+nsDP0xEw/K0QnhNtjKROp4PSYK/tp7N0Rb+N opDl7cLzfK0SWTNiNVnruNzexIUBJqdfWFNVGnGIP7+GD5zu2l3tcKzi1rzpuSWyrDjd GYCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=UYqwwvwqCM+XiAUFW1iDACrhCyXVbVIJb8EkIBK6n50=; b=SyuTVphorlXHysGAHOZ78nb/EawWYTt4P5J6jekDNattRW+z6WV69KviyLuqcM3+oB g3dLid5CuGTFKRC2uWe0Q4N1VFCx3aQVhQD+43BXYEVpWEL8Xsev6smZiPiRwfDq+ktX lRqNOiUv2tkot4vKjdjXMhYzGCsv4U2fy2sf7URhv/MteK/k869XRtuES5xRueegR+9/ 4eaGvusWE6Gfe3f4rDapjEVW+7zlJop7l+OSNQIcyiaKef6wO7FJc8tmA3sahFjczU/F FeHxCOD0/yrlCb0CUqCbqbCavF59E4KsWhf9fzopQDLJkvnU8g+2uPvXBmcOwaZ70AWe 440w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si7376764eje.327.2021.06.05.02.56.16; Sat, 05 Jun 2021 02:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbhFEJ4f (ORCPT + 99 others); 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: linux-kernel@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 > . >