Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp10074773ybl; Thu, 26 Dec 2019 10:19:11 -0800 (PST) X-Google-Smtp-Source: APXvYqy9G79tMNSQIhFkV2yNxclv4M6kCgoIYsyumAV0V8i1PCDcE6y1/k+J2Tt+PVK5TTm074XE X-Received: by 2002:a9d:4796:: with SMTP id b22mr48881474otf.353.1577384351398; Thu, 26 Dec 2019 10:19:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577384351; cv=none; d=google.com; s=arc-20160816; b=cAIFGDblh3W3JzXOcXqPalHi/n+Xhyo1NMFhQZGDQC1Z7pHyiSZEcLC/VESD8yAmb1 WEb9Fv6cizq+85fFnPTCursVFARM7L0g8PlYARx0YmqyFRWOLcQu04KDv6NiW4rXI911 4cqHlDprFt9kM15f5CYNSTLMFZpQWY4HiXsiF+Aa88t/NhfB7sUHQagvVVSM6xkSurcV PRs48unlkfnoa/qRbrdcnvHaBnDaVT73pZd+mJKc5QOcaNla/g2TAqh31hTXqTeZe+ik B8PP21wK2rHgG0L9mzTsPy04F3K/qtg52mk4teyxWduBF2a67lLC+BlJImv9GILeH64M MEwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/kVUvUUlIv+S4KgB8PAilg5eRolltdkQ40GkTlROLJs=; b=BT3X0bBJ8heB0s22R6Wef57zqvQNptO1A1oqQTxbGGwTxT2AB5eBkUR+9IFHU/2pWB g6/OG3KKWvIDs8/+jHI5g2Hmk2imqjkGnx6C7ObJWDmTzd6HZxc8LrdT9X4mlyZCJ3Ez 57lLSUuu+HHcxZS5MQvmYdPF31qZzpDYFi6GoXR+ERrVzifVxxVl4Z9lot0R6F8a2uey aZGSHM9Fwc37QaRm6GLsbDW0tnog/YHXRyQKjskoDs2DtKcHstpG638xd41pO8m5jzDM XCsy5DrjYyXWIYTshd2vx1WSLBdIf9l72sxwh+mYLj1sneps9yzyDHkvkKKLOg55ca9g D48g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=bdk9f8SU; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x142si12640626oia.220.2019.12.26.10.18.59; Thu, 26 Dec 2019 10:19:11 -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=@googlemail.com header.s=20161025 header.b=bdk9f8SU; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbfLZSRT (ORCPT + 99 others); Thu, 26 Dec 2019 13:17:19 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36770 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbfLZSRT (ORCPT ); Thu, 26 Dec 2019 13:17:19 -0500 Received: by mail-ed1-f67.google.com with SMTP id j17so23341889edp.3; Thu, 26 Dec 2019 10:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/kVUvUUlIv+S4KgB8PAilg5eRolltdkQ40GkTlROLJs=; b=bdk9f8SUF43t/ZpP5zxB4uQXnDLufOuMHu/wIWWmDxL7aVjosImu7uDnGwroYAo9hR eJCnfI7jptFKeuPCfVOoo7DiYO5i6BKr4kO6hw5GyLhjfhklx2fPmTYgv6vRDCEfICc6 N3X3vUhbgwMXiacZqdUHI4AqL0uF0koIJCoO4qJCciRnbmP6Jx5g3AXukI/Fw4JQ/wAv o4aL+uNzuC/mo44CJ2xatye3EAhKVbrD6a4UjOkCtB4+olUufm7vbM6mvjvPR9c991vv jaTnyHZiCSrclPaFEMixAatFZ8y0GsfV++VqW1GaPDsCrplp7O/+sv4lIfufoL5CcUB6 HCRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/kVUvUUlIv+S4KgB8PAilg5eRolltdkQ40GkTlROLJs=; b=bwfyVlAoOrRWq+cDkp9kZYWlhz9mL4OaCP9j7HNzb9K+hi6LLJ58fnVGDvzt6cpwGF fScYdWLLSSrpYYQpek9WYSfdcANZKwysH9h8HVQLaGgvnR0oH6fwPNaTr8Lhnxs1nh/d ZSGv/edPASV53Yx+uVVJxdbDNKF/8Adnhpu+KcMdNNkBwppL/D2WNkQwCbvfJBSklNmn HqVrgJBSsvgstEsYfcl03lhpmxLiH1R1WzIhAgPahCwL5HzYDABMTBn7OdGERvQs2qCY WHy0lAl/dBebWqzF45etgzePi1ZywNVHyeY0cJo3Qlw1qVh4/3lPmsnY7ZsZp1VwxUfU 4jjg== X-Gm-Message-State: APjAAAVudn+0q2f2JmMub2zjXdPAEAaHlco3PIiLKBtZlRMCouLAP7xb DJ1NjU759/AsRGvWxAyktHybTf4XS8hVL0i3rE4= X-Received: by 2002:a17:906:260b:: with SMTP id h11mr49327361ejc.327.1577384236409; Thu, 26 Dec 2019 10:17:16 -0800 (PST) MIME-Version: 1.0 References: <20191225005655.1502037-1-martin.blumenstingl@googlemail.com> <20191225005655.1502037-2-martin.blumenstingl@googlemail.com> <20191225150845.GA16671@lunn.ch> <20191226105044.GC1480@lunn.ch> <20191226120133.GI1480@lunn.ch> In-Reply-To: <20191226120133.GI1480@lunn.ch> From: Martin Blumenstingl Date: Thu, 26 Dec 2019 19:17:05 +0100 Message-ID: Subject: Re: [PATCH 1/3] net: stmmac: dwmac-meson8b: Fix the RGMII TX delay on Meson8b/8m2 SoCs To: Andrew Lunn Cc: linux-amlogic@lists.infradead.org, netdev@vger.kernel.org, davem@davemloft.net, khilman@baylibre.com, linus.luessing@c0d3.blue, balbes-150@yandex.ru, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ingrassia@epigenesys.com, jbrunet@baylibre.com, Florian Fainelli 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 Hi Andrew, On Thu, Dec 26, 2019 at 1:01 PM Andrew Lunn wrote: > > > the MAC is not capable of generating an RX delay (at least as far as I know). > > So that immediately means rgmii is invalid as a phy-mode, since the > documentation implies the MAC needs to add RX delay. things turned out even more confusing thanks to your persistence (keep reading, it will get better though) :-) I have tested the following on my Odroid-C1 which has an RTL8211F PHY. With patch #1 from this series I knew that the following was working: - phy-mode = "rgmii" and 2ns TX delay on the MAC (RX delay is seemingly not configured anywhere) - phy-mode = "rgmii-txid" (again, the RX delay is seemingly not configured anywhere) with the patch to change the RX delay on the RTL8211F PHY I decided to try out phy-mode = "rgmii-id": this broke Ethernet. then I looked at the MAC registers and spotted that bits 13 (adj_enable) and 14 (adj_setup) are set (first time I'm noticing this). unsetting them makes phy-mode = "rgmii-id" work! I also confirmed the opposite case: unsetting bit 13 and 14 breaks Ethernet with phy-mode = "rgmii-txid". so it seems that there *is* a way to configure the RX delay on Meson8b and Meson8m2 SoCs (at least). I will spin up a RfC patch to discuss this with the Amlogic team and because I don't know what these bits do exactly > > it's mostly "broken" (high TX packet loss, slow TX speeds) for the two > > supported boards with an RGMII PHY (meson8b-odroidc1.dts and > > meson8m2-mxiii-plus.dts) > > examples on the many ways it was broken will follow - feel free to > > skip this part > > That is actually good. If it never worked, we don't need to worry > about breaking it! We can spend our time getting this correct, and not > have to worry about backwards compatibility, etc. ACK > > > What we normally say is make the MAC add no delays, and pass the > > > correct configuration to the PHY so it adds the delay. But due to the > > > strapping pin on the rtl8211f, we are in a bit of a grey area. I would > > > suggest the MAC adds no delay, phy-mode is set to rmgii-id, the PHY > > > driver adds TX delay in software, we assume the strapping pin is set > > > to add RX delay, and we add a big fat comment in the DT. > > > > > > For the Micrel PHY, we do the same, plus add the vendor properties to > > > configure the clock skew. > > > > > > But as i said, we are in a bit of a grey area. We can consider other > > > options, but everything needs to be self consistent, between what the > > > MAC is doing, what the PHY is doing, and what phy-mode is set to in > > > DT. > > > do you think it's worth the effort to get clarification from Realtek > > on the RX delay behavior (and whether there's a register to control > > it)? > > You can ask. There are also datasheet here: > > http://files.pine64.org/doc/datasheet/rock64/RTL8211F-CG-Realtek.pdf > https://datasheet.lcsc.com/szlcsc/1909021205_Realtek-Semicon-RTL8211F-CG_C187932.pdf > > It looks like both RX and TX delay can be controlled via > strapping. But the register for controlling the TX delay is not > documented. I checked the mails I got from Realtek I while ago and they even included the RX delay bits! I even sent a patch two years ago but I must have dropped it at some point (maybe I assumed that it wasn't relevant anymore - I don't remember): [0] > > you mentioned that there was breakage earlier this year, so I'm not sure anymore > > (that leaves me thinking: asking them is still useful to get out of > > this grey area) > > It was an Atheros PHY with breakage. > > If we can fully control the RX and TX delays, that would be great. It > would also be useful if there was a way to determine how the PHY has > been strapped. If we cannot fully control the delays but we can find > out what delays it is using, we can check the requested configuration > against the strapped configuration, and warn if they are different. I am currently testing whether the pin strapping configuration can be read back by the RX and TX delay registers my Odroid-C1 has both strapped to GND which means off but my Khadas VIM2 has TX delay strapped to ETH_VDDIO which means on (RX delay is still strapped to GND) once I am done testing I will send patches for the RTL8211F PHY driver Martin [0] https://patchwork.ozlabs.org/patch/843946/