Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2239618imm; Mon, 28 May 2018 04:34:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpWVDoevUxeQew2UkR++zq8PadNK77MAko7Q7lJYK9TYjDCcw22QvmB9Clu3XGxorTLrcRq X-Received: by 2002:aa7:819a:: with SMTP id g26-v6mr13213978pfi.210.1527507250046; Mon, 28 May 2018 04:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527507250; cv=none; d=google.com; s=arc-20160816; b=HH0qY5fOw9o78cFtoj+/3mJQzhLorXsZGGiF0tJREnlBcUVoouSRB1B9VjmMRxVG6w dmD5jAKFTv5D/Mdqt6s/JuJISKfrOkxA+jL4BDQt4hG8eNhhJ9g25m8Wg4ZnpJpfcmwi qx3PgNB98RWIOQIGnCCuR90l1galeA0te9XVkVT4HfA4N0bibegoR0XktX78mIRf9q7t v/hqNfCq3KFZ2muPi59+tS59KdkQlTKE+TYi0g7+/0nNRqzTy9sUIQ19wx+3qKTjFCfm Xvfn/J9PgvGa4fhl7Zssv3W6ZBvGKSDrbItifxIxtLYahl+9bYcKbNtVHtBlRp5eKNXV XsuQ== 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=yybwK1OpNOeHVbvmjIBYk49VtLEyZaF435i4Blf8G64=; b=AxXqCNHx3pvQMUb0otcfAjhWa3rIqQtTXrmo5PxsJy/MvkCD27ewK90viuR/IbNbsP dh0L2Ur3ootkRCa4tsiShWvIE7TOrmEjdyKAyKlpXViheq5boP8sviEZkhRVuIuQjGvN Y/7xaVgaJlAU+eqRTdAlDG3nP1l6phHSYn5BnQ0CVMo242hYXyYmBKKY/JMtAZ+NqP3C /9WwCSE55OeTod/Tiy+yUZ5nIRQxLU7lX5UHI/tHwKPr7+BzVDXsEuqpRJMrOVIoLRN4 z6JlfyCmpZMlYHDViriVt6GYO1jroJiHG1xRNbuw+R94SCo3Ch8dZLQhJVzNIj/PyQDk eyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wzCszZJD; 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 f1-v6si30783116plf.453.2018.05.28.04.33.55; Mon, 28 May 2018 04:34:10 -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=wzCszZJD; 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 S1424403AbeE1LOX (ORCPT + 99 others); Mon, 28 May 2018 07:14:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:33608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424393AbeE1LOS (ORCPT ); Mon, 28 May 2018 07:14:18 -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 279FE2087E; Mon, 28 May 2018 11:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527506057; bh=jBXFN0xbs7/itnrvhPoxf5aF69fwSrtNqlwbsZvo7Vw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wzCszZJD7xGhgBCcPugVE7aDp/yr7xG0YtltItPY28F4Z7uz6jX4F/Bj5IVzHk9Zn RN19dKYMXrd/pYDAi2c1UdO/PpOR1OGM+b2gtCe+BdzuNusDY6Y8S/S8UU22pqjZBF i/p6C+JwTe2cYP/04a8d+qkzSOLM6E9Vf7+q3ya8= 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.16 226/272] net: stmmac: ensure that the MSS desc is the last desc to set the own bit Date: Mon, 28 May 2018 12:04:19 +0200 Message-Id: <20180528100259.430446112@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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 @@ -2985,8 +2985,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