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=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT 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 F3777C169C4 for ; Thu, 31 Jan 2019 04:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8A08218AF for ; Thu, 31 Jan 2019 04:26:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IUVMLN13" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731253AbfAaE0L (ORCPT ); Wed, 30 Jan 2019 23:26:11 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46987 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbfAaE0K (ORCPT ); Wed, 30 Jan 2019 23:26:10 -0500 Received: by mail-pf1-f193.google.com with SMTP id c73so870985pfe.13 for ; Wed, 30 Jan 2019 20:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=f5oJgL3wk0TkwCt2ujrDKnBfb8YTSiFk09swDWI+Jfo=; b=IUVMLN130lhf2SQTG2PakyqwFJA6IvY6GP6aFBdNGMjFanqp83gyA6UQbVSXKktVP5 hNmAfwvLuZQ5iiMU83JKWd/2+XOa8Ua6XRL64l+VdOWBfwG5Ksp1518U494+jU8t4hzj fmDTcrs7NB+N7yuVCYyVui5hPsIVdPBNUh9f9/Ze4mOJTWsJIXEzKUA1LvHQcd/UbE99 3LdXN5YNDZa8VWxXKnCLRPmNqWN3GLshIwb3t6P2e42tzYbDGc2yAG1a2cqNidbj6C+u KckOIRAHMLv8jfaKGCdndvSJFItz6MgS4tu4+vKGmoboWIRsj8eoqvqkm81o0TNN/2dT 1C2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=f5oJgL3wk0TkwCt2ujrDKnBfb8YTSiFk09swDWI+Jfo=; b=B1CfUQRlMpyX0/s+CAArf++XsYmGMpWD3rbMrzdiVALP/C6aINv4h9CBfCEH6d9a7e I5H5wxljyIg/SEu2G7RUwxj0elK6jiQfS5ohS45psNT7kfjZ99sPPoqjObRZLqLXcEiy r6IvwOm9XfRuI15Hsst0hZHiZqWpLtgGJvqNB+5tfSZAuNHWK3hSnzBdXUJUoemqHIiM X75rUiVegjGSz/IJfeSexBOtIweVdNTH6x/VA7TvCDej1+lA2Z5AFbJE4ev+Phya3BwY WfZ21SY4C9EJ6uYuOl+ASgCxsLyqOckdVB6UCjk9neCqQpQUAOfNjK3YERVqHYlJzvNh ov4A== X-Gm-Message-State: AJcUukfsgH56t1L1UVHuBK0otWxEgmGeiWPy5GLlgc4Dze3nLsJ+ktVr w5TPkeJGT7lwewApH1Uh8o4= X-Google-Smtp-Source: ALg8bN4w5zvo6zrV2WzSWEbr16hHcxvw3/oh+cl9bh0a0RrsfYwMmkcoWCm505wbsIiG39vgXtbcIA== X-Received: by 2002:aa7:8542:: with SMTP id y2mr33784341pfn.83.1548908769389; Wed, 30 Jan 2019 20:26:09 -0800 (PST) Received: from localhost (c-71-198-144-65.hsd1.ca.comcast.net. [71.198.144.65]) by smtp.gmail.com with ESMTPSA id d11sm4631709pgi.25.2019.01.30.20.26.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 20:26:08 -0800 (PST) Date: Wed, 30 Jan 2019 20:26:06 -0800 From: Richard Cochran To: Sebastian Andrzej Siewior Cc: Andrew Lunn , Florian Fainelli , Heiner Kallweit , netdev@vger.kernel.org Subject: Re: [RFC] net: dp83640: expire old TX-skb Message-ID: <20190131042606.zkinycpnbjpsm3dg@localhost> References: <20190128174547.twhwv64y2k5xx5x7@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190128174547.twhwv64y2k5xx5x7@linutronix.de> User-Agent: NeoMutt/20170113 (1.7.2) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Jan 28, 2019 at 06:45:47PM +0100, Sebastian Andrzej Siewior wrote: > During sendmsg() a cloned skb is saved via dp83640_txtstamp() in > ->tx_queue. After the NIC sends this packet, the PHY will reply with a > timestamp for that TX packet. If the cable is pulled at the right time I > don't see that packet. It might gets flushed as part of queue shutdown > on NIC's side. > Once the link is up again then after the next sendmsg() we enqueue > another skb in dp83640_txtstamp() and have two on the list. Then the PHY > will send a reply and decode_txts() attaches it to the first skb on the > list. > No crash occurs since refcounting works but we are one packet behind. > linuxptp/ptp4l usually closes the socket and opens a new one (in such a > timeout case) so those "stale" replies never get there. However it does > not resume normal operation anymore. Thanks for the detailed explanation. This sounds like a really rare bug, but maybe you guys were able to trigger it reliably? > Purge old skbs in decode_txts(). It is too bad that the Tx timestamp from the HW doesn't provide matching fields. Using the timeout is probably the best that we can do. > Reviewed-by: Kurt Kanzenbach > Signed-off-by: Sebastian Andrzej Siewior Order: signed-off goes before reviewed-by. > --- > drivers/net/phy/dp83640.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c > index 1dc043d0bc875..a50e0680a0322 100644 > --- a/drivers/net/phy/dp83640.c > +++ b/drivers/net/phy/dp83640.c > @@ -920,13 +920,13 @@ static void decode_txts(struct dp83640_private *dp83640, > { > struct skb_shared_hwtstamps shhwtstamps; > struct sk_buff *skb; > + struct dp83640_skb_info *skb_info; Reverse Christmas tree please, > u64 ns; > u8 overflow; and fix ^^^ while you are at it. > > /* We must already have the skb that triggered this. */ > - > +again: > skb = skb_dequeue(&dp83640->tx_queue); > - > if (!skb) { > pr_debug("have timestamp but tx_queue empty\n"); > return; > @@ -941,6 +941,11 @@ static void decode_txts(struct dp83640_private *dp83640, > } > return; > } > + skb_info = (struct dp83640_skb_info *)skb->cb; > + if (time_after(jiffies, skb_info->tmo)) { > + kfree_skb(skb); > + goto again; > + } > > ns = phy2txts(phy_txts); > memset(&shhwtstamps, 0, sizeof(shhwtstamps)); > @@ -1489,6 +1494,7 @@ static void dp83640_txtstamp(struct phy_device *phydev, > struct sk_buff *skb, int type) > { > struct dp83640_private *dp83640 = phydev->priv; > + struct dp83640_skb_info *skb_info = (struct dp83640_skb_info *)skb->cb; Reverse Christmas tree. Thanks, Richard > > switch (dp83640->hwts_tx_en) { > > @@ -1500,6 +1506,7 @@ static void dp83640_txtstamp(struct phy_device *phydev, > /* fall through */ > case HWTSTAMP_TX_ON: > skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; > + skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT; > skb_queue_tail(&dp83640->tx_queue, skb); > break; > > -- > 2.20.1 >