From patchwork Tue Jan 17 18:15:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vacek X-Patchwork-Id: 44782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1927345wrn; Tue, 17 Jan 2023 10:57:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXvEO79UQC89OBWMUdORVMpBX5GQh5g3lGW+VjYpyODbp+tz4X1PByVeQTl+0VxqglsfoBtf X-Received: by 2002:a17:90b:48d0:b0:226:d7e8:e11f with SMTP id li16-20020a17090b48d000b00226d7e8e11fmr4625531pjb.12.1673981850668; Tue, 17 Jan 2023 10:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673981850; cv=none; d=google.com; s=arc-20160816; b=bCbZM7Bi4QKEe4B0ObAdZ3HjBBWUssI2JvNoK4l8VcP8h9NCs89HPBwIJW/VKD5AVv 5CkqkfjcZY9SS4B0RnGLVjc25cB0PJ3iX1HP5TJ6QYFHLd4j9NkBUfAenwtR4qjUttho bUTPZ2gQzoOA235ATnxaq9J3800q/gO9p6FZZmu17Uqr0dfdkcGKd+6jueTPmGV4wwOS hzMsxbbTFkHPedJMx0QC8RmnWVuAkKd15HYTeYkGFsU0fjTiY6/B24u/h8wMNbC0eME8 Gxjzw2Yj/xpK3tgS6diVSOSMet4rZGvJPMNSstwShKvAlnKAuf3a36T/AGC6wd+QApLM XhTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hoHrYOZi5AepvexSScpofKM1v72zsm9+pebsH147dPw=; b=nASRz8pJRjlIfkUqpCrT5nvlxaKJfAZTNpOv91w4IygAkpWLCno7V9CRKFho9GcedE tgru7lbm9lMDHrEjNqmeUj/SeWY6OMtLsUXaI4bui+BDejPQfzwrz3mrv/QLPt8f9CJ5 eSen8S5aUV3T/GEcuypH0zjUVkLn2KwsAOxhUjJDqkv/mo4OE0VO/Mqulngyt8KLanX2 ME2mQhnwuo6lZGtISqNTZbspOC+l5kyL7+5SeLK//EB+3ZCYH4JTk8Bof3nYrFkpE3yt s5jmG/aYzl5snIhsCbfqYQM9vgUcUbUEQCLhpSyA98LYjeBX1kUZOwfn9QK6Z2w9UU9L dHwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MmGczuIe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id on10-20020a17090b1d0a00b002270cd1cb8fsi30104047pjb.46.2023.01.17.10.57.16; Tue, 17 Jan 2023 10:57:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MmGczuIe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230168AbjAQSw4 (ORCPT + 99 others); Tue, 17 Jan 2023 13:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235513AbjAQSuN (ORCPT ); Tue, 17 Jan 2023 13:50:13 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A964DCFA for ; Tue, 17 Jan 2023 10:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673979343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hoHrYOZi5AepvexSScpofKM1v72zsm9+pebsH147dPw=; b=MmGczuIeAzksmWzYtCXrHg0tyDNjPW14GYi7MMQ6we8kPowOhyuNu5MjUrEnHfq9jjAcUU RTqu6eJbw0PNwQ5iHGXMS/+PPPAm2GL8ScLyH7FftDKX0LsxNgXOGAMBC0yoRWl7LuX1CZ LlsNC+X9Y40C9SRaH9+gYZL+6a+wBeY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-498-E6arC8fUMxqGHhfEb1Ibsg-1; Tue, 17 Jan 2023 13:15:40 -0500 X-MC-Unique: E6arC8fUMxqGHhfEb1Ibsg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 267BC3C0F42F; Tue, 17 Jan 2023 18:15:40 +0000 (UTC) Received: from metal.redhat.com (ovpn-192-69.brq.redhat.com [10.40.192.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id A90931415108; Tue, 17 Jan 2023 18:15:37 +0000 (UTC) From: Daniel Vacek To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Daniel Vacek , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ice/ptp: fix the PTP worker retrying indefinitely if the link went down Date: Tue, 17 Jan 2023 19:15:32 +0100 Message-Id: <20230117181533.2350335-1-neelx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755297193307428739?= X-GMAIL-MSGID: =?utf-8?q?1755297193307428739?= When the link goes down the ice_ptp_tx_tstamp_work() may loop forever trying to process the packets. In this case it makes sense to just drop them. Signed-off-by: Daniel Vacek --- drivers/net/ethernet/intel/ice/ice_ptp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index d63161d73eb16..c313177ba6676 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -680,6 +680,7 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) struct ice_pf *pf; struct ice_hw *hw; u64 tstamp_ready; + bool link_up; int err; u8 idx; @@ -695,6 +696,8 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) if (err) return false; + link_up = hw->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP; + for_each_set_bit(idx, tx->in_use, tx->len) { struct skb_shared_hwtstamps shhwtstamps = {}; u8 phy_idx = idx + tx->offset; @@ -702,6 +705,12 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) bool drop_ts = false; struct sk_buff *skb; + /* Drop packets if the link went down */ + if (!link_up) { + drop_ts = true; + goto skip_ts_read; + } + /* Drop packets which have waited for more than 2 seconds */ if (time_is_before_jiffies(tx->tstamps[idx].start + 2 * HZ)) { drop_ts = true;