Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17935667ybl; Thu, 2 Jan 2020 15:07:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwPNYgmElL4P3zICLH6V64Bxyfym7SUmTWscFvQqwZzXv7b6cltOBfqPF4Sbeh/qhjshclr X-Received: by 2002:aca:d6c4:: with SMTP id n187mr3344731oig.29.1578006479429; Thu, 02 Jan 2020 15:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006479; cv=none; d=google.com; s=arc-20160816; b=C9rUDNUZGGAXrRFXhUIjQ3c66ayRl70JZqNsONBSY0vOA5yrpcvnvyCIbV+TfmRG2x FmvwKWlpffrq8LnUW8vMq3wI0OWHYTHnA9jmVPjp0Nqvm7pYJg3bCjcO02ERaJWTylji 1eBvF4MbyMyhUXU/ZpsV+F0jiHeHx/3Sct3Q+Y+OdDQoQeRd9Cx//Nld3EHRMLJmhKgG 7kzHFC/GMq1EhquthexTuCFSHG8A26X/YHrKmL0qLaQyLkGF6iJylOsifbiiXr4Kz89l qmKICfmj6sR4xqd1msij/LuPtfPCxd3xShCMgVyJ/O6zzT/DEjXNJn3spe8w3dfoww8W yv4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N7erUAJD+lflq8nCVzXcuEqOB/I+Lepplst4KerPylk=; b=Q8KDhQoSBrQ08xQsGgJibIjtQiFTyCAqwqfeAMHc/XLaBjHF4gTd385WmOWzsVqhvz jJYTpJSNRzJuz04wPUg5FQGpvsOoR1mpD77D+Ki0Kdtpx02QC/SHTZUCkcuK/JTTHDvC yQ5XYHF3rY4dgr878SbCyPVtpESRMT+g+1BNVyZ6FBpHHaH1RfChfXCVajSmUN5dTUXq l6my7UwFv7sX0UDDW3fEqy0knx9haSBO68KPUoQDL4NdISiD1TanUk6KPpxGM8EwZQBB 7HSJRL8el19E9LPOX/1gfxfNUgq9DuIjki9Z1llcYZtmSSHcwXCYFF1DK8MPQTjqGrgX 48Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=losBAUmA; 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 a10si26532393oia.232.2020.01.02.15.07.47; Thu, 02 Jan 2020 15:07:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=losBAUmA; 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 S1727563AbgABWWS (ORCPT + 99 others); Thu, 2 Jan 2020 17:22:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:42536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbgABWWQ (ORCPT ); Thu, 2 Jan 2020 17:22:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 DE48C21D7D; Thu, 2 Jan 2020 22:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003735; bh=9N5Do3eHMPg3N2LbGNZ8XxcUabmcnKwWjINHbtRGIks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=losBAUmAa45ehbKG0PGIm2M501Yfm+a4Cnu9XHkaMZ935ZVEmojbw2fbqqw9Y5Hvm dB1DoklQ+ulgqewouNbFcPJWdHZWv+9scdbJmlldv7yy+4ECdQ8WXnIJN9ljmvCu6d 4oU2qVAdaUS4c+E01Z5qE8iecGLCLKD/4MTvT0P8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Blumenstingl , Andrew Lunn , "David S. Miller" Subject: [PATCH 4.19 092/114] net: stmmac: dwmac-meson8b: Fix the RGMII TX delay on Meson8b/8m2 SoCs Date: Thu, 2 Jan 2020 23:07:44 +0100 Message-Id: <20200102220038.435278242@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Blumenstingl [ Upstream commit bd6f48546b9cb7a785344fc78058c420923d7ed8 ] GXBB and newer SoCs use the fixed FCLK_DIV2 (1GHz) clock as input for the m250_sel clock. Meson8b and Meson8m2 use MPLL2 instead, whose rate can be adjusted at runtime. So far we have been running MPLL2 with ~250MHz (and the internal m250_div with value 1), which worked enough that we could transfer data with an TX delay of 4ns. Unfortunately there is high packet loss with an RGMII PHY when transferring data (receiving data works fine though). Odroid-C1's u-boot is running with a TX delay of only 2ns as well as the internal m250_div set to 2 - no lost (TX) packets can be observed with that setting in u-boot. Manual testing has shown that the TX packet loss goes away when using the following settings in Linux (the vendor kernel uses the same settings): - MPLL2 clock set to ~500MHz - m250_div set to 2 - TX delay set to 2ns on the MAC side Update the m250_div divider settings to only accept dividers greater or equal 2 to fix the TX delay generated by the MAC. iperf3 results before the change: [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 182 MBytes 153 Mbits/sec 514 sender [ 5] 0.00-10.00 sec 182 MBytes 152 Mbits/sec receiver iperf3 results after the change (including an updated TX delay of 2ns): [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-10.00 sec 927 MBytes 778 Mbits/sec 0 sender [ 5] 0.00-10.01 sec 927 MBytes 777 Mbits/sec receiver Fixes: 4f6a71b84e1afd ("net: stmmac: dwmac-meson8b: fix internal RGMII clock configuration") Signed-off-by: Martin Blumenstingl Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -118,6 +118,14 @@ static int meson8b_init_rgmii_tx_clk(str struct device *dev = dwmac->dev; const char *parent_name, *mux_parent_names[MUX_CLK_NUM_PARENTS]; struct meson8b_dwmac_clk_configs *clk_configs; + static const struct clk_div_table div_table[] = { + { .div = 2, .val = 2, }, + { .div = 3, .val = 3, }, + { .div = 4, .val = 4, }, + { .div = 5, .val = 5, }, + { .div = 6, .val = 6, }, + { .div = 7, .val = 7, }, + }; clk_configs = devm_kzalloc(dev, sizeof(*clk_configs), GFP_KERNEL); if (!clk_configs) @@ -152,9 +160,9 @@ static int meson8b_init_rgmii_tx_clk(str clk_configs->m250_div.reg = dwmac->regs + PRG_ETH0; clk_configs->m250_div.shift = PRG_ETH0_CLK_M250_DIV_SHIFT; clk_configs->m250_div.width = PRG_ETH0_CLK_M250_DIV_WIDTH; - clk_configs->m250_div.flags = CLK_DIVIDER_ONE_BASED | - CLK_DIVIDER_ALLOW_ZERO | - CLK_DIVIDER_ROUND_CLOSEST; + clk_configs->m250_div.table = div_table; + clk_configs->m250_div.flags = CLK_DIVIDER_ALLOW_ZERO | + CLK_DIVIDER_ROUND_CLOSEST; clk = meson8b_dwmac_register_clk(dwmac, "m250_div", &parent_name, 1, &clk_divider_ops, &clk_configs->m250_div.hw);