Received: by 10.223.185.116 with SMTP id b49csp4239296wrg; Mon, 26 Feb 2018 13:50:34 -0800 (PST) X-Google-Smtp-Source: AH8x226nrN5RQNpXIslUKW+CO4NpNWGVA70o4hqs5V5y10sTvPNxct1yg3D7xQ/7y8TYTd5t2plj X-Received: by 10.98.14.70 with SMTP id w67mr11957373pfi.1.1519681834335; Mon, 26 Feb 2018 13:50:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519681834; cv=none; d=google.com; s=arc-20160816; b=FNadCLWtidc647t9dsTkeNzUUDBrBvfqy3jK9X9QFYb43HZdgrzu7KPGwOWV7wFAPc hlxWDd6WCe9Gega4JwXISxx6LS3AkhT7Oqkce6w4Er6xi/NSCp5fVeU5mfgk9yxE8w6M 9YY/lb7ambrpJHxBJVmrPTZKh2qZiJ/6H8jlFGJLAlEFsJOTCYjMoWjpLs2Syv0wDE6z PP8bsP92MT1W/8MHaIoxSUqw0F/Vst2TH8AEMhQTb7pa6mhFReCOVxnRnFQMb8Yc9VfU OpETBX9fmsIadFF5JfFEYIQVHqIujkztz6Zvcz67xzloDi39fqOHXiP+7TLYb6bpn41s XIMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=3b1I1eBl1T9t5F6rjQF3JxswOyVCbfTBl5vWbN03GdQ=; b=chccj3LVdXRNBASL5Mmf/41xnOQchgao+ekMv+xzKJkxY+1zbB7kHD1DZk35XT0GkT /uJ11pKflvx0eny4kKToHBVkFPRcVpAvGKUr69juv7MFbGhaLtO7gqtKIx69MI708Jhf J08GzOmaBpl5VvY170o2F1ir4MNkMXzDLlR8YrgvnYSgrktCigVjk4bY5NAIWtwIu28Z QPx1IMFdbnES4dVTwVQIJS/Jns0uTv9Rix76GcorH/Q5WzYsSRq8Zb7zqYNJKvDe8oRc rJfW6gdc34e1proUE9k+ISezXEgF507LCsdMuuRyIusZ31OBDt2G4oEI/SF1o/F9wtBO g1Uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14si6027937pgp.812.2018.02.26.13.50.17; Mon, 26 Feb 2018 13:50:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893AbeBZVrw (ORCPT + 99 others); Mon, 26 Feb 2018 16:47:52 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:54832 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487AbeBZVrh (ORCPT ); Mon, 26 Feb 2018 16:47:37 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id D5950181D8; Mon, 26 Feb 2018 22:47:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id d9Yj_wFLc64u; Mon, 26 Feb 2018 22:47:34 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 5204D1835B; Mon, 26 Feb 2018 22:47:34 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40C831A08D; Mon, 26 Feb 2018 22:47:34 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35C8E1A08C; Mon, 26 Feb 2018 22:47:34 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Mon, 26 Feb 2018 22:47:34 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id 2A0EE6DD; Mon, 26 Feb 2018 22:47:34 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 2487E401A5; Mon, 26 Feb 2018 22:47:34 +0100 (CET) From: Niklas Cassel To: Giuseppe Cavallaro , Alexandre Torgue Cc: Jose.Abreu@synopsys.com, pavel@ucw.cz, Niklas Cassel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/4] net: stmmac: make dwmac4_release_tx_desc() clear all descriptor fields Date: Mon, 26 Feb 2018 22:47:09 +0100 Message-Id: <20180226214709.4359-5-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180226214709.4359-1-niklas.cassel@axis.com> References: <20180226214709.4359-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make dwmac4_release_tx_desc() clear all descriptor fields, not just TDES2 and TDES3. I'm suspecting that TDES0 and TDES1 wasn't cleared because the DMA engine uses them to store the tx hardware timestamp (if PTP is enabled). However, stmmac_tx_clean() calls stmmac_get_tx_hwtstamp(), which reads and saves the timestamp, before it calls release_tx_desc(), so this is not an issue. stmmac_xmit() and stmmac_tso_xmit() both always overwrite TDES0, however, stmmac_tso_xmit() sometimes sets TDES1, and since neither stmmac_xmit() nor stmmac_tso_xmit() explicitly clears TDES1, both functions might reuse a DMA descriptor with old TDES1 data. I haven't observed any misbehavior even though TDES1 sometimes point to an old skb, however, explicitly clearing both TDES0 and TDES1 in dwmac4_release_tx_desc() minimizes the chances of undefined behavior. Signed-off-by: Niklas Cassel --- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index c728ffa095de..2a6521d33e43 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -389,6 +389,8 @@ static void dwmac4_rd_prepare_tso_tx_desc(struct dma_desc *p, int is_fs, static void dwmac4_release_tx_desc(struct dma_desc *p, int mode) { + p->des0 = 0; + p->des1 = 0; p->des2 = 0; p->des3 = 0; } -- 2.14.2