From nobody Sun Sep 14 22:30:59 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59C5DC54E76 for ; Tue, 17 Jan 2023 18:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233172AbjAQSxN (ORCPT ); Tue, 17 Jan 2023 13:53:13 -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 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/etherne= t/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; =20 @@ -695,6 +696,8 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) if (err) return false; =20 + link_up =3D 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 =3D {}; u8 phy_idx =3D idx + tx->offset; @@ -702,6 +705,12 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx) bool drop_ts =3D false; struct sk_buff *skb; =20 + /* Drop packets if the link went down */ + if (!link_up) { + drop_ts =3D 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 =3D true; --=20 2.39.0