Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2212806imm; Mon, 28 May 2018 04:04:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZppjbJXCPIj5MX3IM4jOnd6DRHRDAbgDrdi7DdQL4Gn0/DBOsEeVzQOq8w95ZeRoe6Vu52C X-Received: by 2002:a63:9843:: with SMTP id l3-v6mr10390476pgo.208.1527505454586; Mon, 28 May 2018 04:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527505454; cv=none; d=google.com; s=arc-20160816; b=xpzUWQqOpomz1LtW5skMkQTO+GXdLNlnp8TZKQ/Kc/QMcO/r3e1Y6lloZOcQFI310O 7QUhka2Ebio3rVkdW+SFqE7S7NNem68NnYVHklULmPEwfKyNfzbrb+4tREjRvcs0B2e6 Oo5KUMG2LLEiGrysjq8htgmyCcwvb85PgzYpfBpkgd3rP1bEVvclgX8EVtGBzbutL7zw N7p5aSLiRUXbKnYYMyXuQ+r3lEJ4uBEWuHU2g4p1WPIOLafdHIihGAczae2oPprLbdrb br8ii9GoV62pBzZvG2pH7UrqBsaRyP2Xnz7pbkSe+/WAX4e9wxi+qQEGz2TQ2KlUnZy+ 6ykA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=HoHulxxilPSsrN3ioi6eq06qL9IeO9RAZbmrD3fFBI4=; b=IvgiPBPWGbgoBgiMNg+LqcZ00/RT1L2US3aFl2KQH7JyeGx3TEjv2FL8dgtYyZMkuj K+/xhHmmiq20HfOTbw6shraSpnvanqfb3fw7C0A5v5N8KI2xFVuwW4JO88KYa9sFVIRO e5ioQxNkYqOR5aAAgxdc8U2GFzSdkAXcJjOR7E/rdeT/5d/AVClBaXrrnfCzYir2MXv/ GKQM7RpyHpO2aKbibO0w6Vz4qg6YZyTuOryEdPH6FV/081pCnEhWJIUVmfU/xnqOKkoG iIAet6onmV1MQIg9RpXI0E2CEnR+oP9wBWk4E0EL2aVBPpEmHxbQkiaveBo2lTRtmuo6 Lshg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tE4UnADz; 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 h12-v6si7925533plk.535.2018.05.28.04.03.57; Mon, 28 May 2018 04:04:14 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=tE4UnADz; 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 S1422945AbeE1LDo (ORCPT + 99 others); Mon, 28 May 2018 07:03:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:50804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164664AbeE1LDj (ORCPT ); Mon, 28 May 2018 07:03:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC41A2088E; Mon, 28 May 2018 11:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505418; bh=rSMPK6FrOm9A0ozT6rf4kgyohZUWtGTaZXfgQyVWiLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tE4UnADzOQagpE02iBC84fImiWi6eP/ozyKQM4X3MxgmlABqLcVKo2Syra/+7ocsl PkDY3SVmwHFKHtnaR35ezeLgYpZn+m1oVhZoyamPXZaysOt5AC5Y5c3mex8iGhtf+Q ATTKBhgkpcEsz5O3VF1Bu2hQrF5OiZAj9b1viWhs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 459/496] net: stmmac: ensure that the MSS desc is the last desc to set the own bit Date: Mon, 28 May 2018 12:04:04 +0200 Message-Id: <20180528100339.262992649@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel [ Upstream commit 15d2ee42a3087089e73ad52fd8c1b37ab496b87c ] A dma_wmb() is used to guarantee the ordering, with respect to other writes, to cache coherent DMA memory. There is a dma_wmb() in prepare_tx_desc()/prepare_tso_tx_desc() which ensures that TDES0/1/2 is written before TDES3 (which contains the own bit), for First Desc. However, in the rare case that MSS changes, there will be a MSS context descriptor in front of the regular DMA descriptors: <- DMA Next Descriptor Thus, for this special case, we need a dma_wmb() after prepare_tso_tx_desc()/before writing the own bit to the MSS desc, so that we flush the write to TDES3 for First Desc, in order to ensure that the MSS descriptor is the last descriptor to set the own bit. Signed-off-by: Niklas Cassel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2923,8 +2923,15 @@ static netdev_tx_t stmmac_tso_xmit(struc tcp_hdrlen(skb) / 4, (skb->len - proto_hdr_len)); /* If context desc is used to change MSS */ - if (mss_desc) + if (mss_desc) { + /* Make sure that first descriptor has been completely + * written, including its own bit. This is because MSS is + * actually before first descriptor, so we need to make + * sure that MSS's own bit is the last thing written. + */ + dma_wmb(); priv->hw->desc->set_tx_owner(mss_desc); + } /* The own bit must be the latest setting done when prepare the * descriptor and then barrier is needed to make sure that