Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB3A0C47096 for ; Thu, 3 Jun 2021 16:09:45 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55E47613E4 for ; Thu, 3 Jun 2021 16:09:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55E47613E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAAF982B1B; Thu, 3 Jun 2021 18:09:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="Vj3e9wob"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B95F82B8E; Thu, 3 Jun 2021 18:09:36 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1350E82AC3 for ; Thu, 3 Jun 2021 18:09:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622736566; bh=rhWycybIiImeutulWiNv6j6PfBm6bxbCGeoayZ7JmYE=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=Vj3e9wobEIs8OxhSxhkIibXVVViGhuRbnw0ef4jgCQiDxyo40zvriPODMdBc9DtqF D/qD26XHxkVo7nyigiCIjZ9VVRoYDoxcr1/m1E8BseSTRH/NhwJyvQkKBRbYBIB2+9 I+j3YNZtgKEEVTfP4Lq9FUkf5kj2YLc2byNsNQzc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([62.143.247.63]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MmUHj-1l6wVD0yNV-00iPlB; Thu, 03 Jun 2021 18:09:26 +0200 Subject: Re: [BUG] network is broken on Orange Pi PC To: Andre Przywara Cc: Ramon Fried , Joe Hershberger , Jagan Teki , U-Boot Mailing List , Andreas Rehn References: <20210603100351.4b45ed0a@slackpad.fritz.box> <73958455-9745-399a-6562-f31ee5f40cd5@gmx.de> <20210603120453.6bc4df7e@slackpad.fritz.box> From: Heinrich Schuchardt Message-ID: <12247d72-1e6d-ed07-efa4-0874ea37f558@gmx.de> Date: Thu, 3 Jun 2021 18:09:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210603120453.6bc4df7e@slackpad.fritz.box> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:v1SRLrTHy8KweccCvPwHJ9jG6zbi8HfWBJWki5In69W61Tzkzft 7CE1vtnncEQtB3u6t3+Yaob6CP6jDERSUIYNfJ/DaGmjyOcYn5M1dytVj765zoR/moPLWnJ /2kt1FScxzAKtXzgqkhq15v95tce+yJS9z6HUqPWz4OjNyHQnJRtbyDop8ybDwx9OWkT3Tx t2gL80tdCIxkwp77IbUqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:JJglNeSy/Lw=:Bgx35I8TbeWl999ANUFAnB MK3EhZSFszJ64CHk3352VhW/TnPsPLDG+vRnax1PTeZxRJZESVD5s9rGrpqvCEQwlGfXaA4M0 j360xUePa2nPWF6HO4G/oXwImurlQNhtTNxR+MnT9/ovDyULHjkw2Ng7kwPC5kWJoJwa5uqtB 57UqMTHWH/ZEPM3NycfCPEJVDr2pj3lSFktzuzB6ZeeMlNq3WQVowJrBNIh9My96bQRpgN1fI TIpFP63LOdu4IpUAqXglVvyOeBX3V7kEIyheDwoms5OoCxF1lpGfV7ciGvDOeR99fB7kjgw8c bnVjqVIaP+tbDqrpB0NHpY/nX9Ypa2aTHUBnUayzYjDlI2U2nWhj9OIzDQJOVCHXTvOLZPAnh x3IX6M2poX7qQsG3zpcyvwyVu9l6H0CrMeuUOmcdReaBXHm+IerVaMhFxJZ8Jd4b4UBMkdZJM SELbmLrF4pI2sfxTUdzcSweUca9/dI/V0oSCipp6bVI2RaToDv9khSMUR6HEvpk+izvJUnej8 8u/iaskUb+rJlZamUowVq8A7FgIs/x/6HF1hKk9lVKCA/W5xyM0EFopjOncjvwV7EEqHC1lq1 9eB/B8uFFGEzc7AreDkIic4yw8lmlGMmfaAa+dSrQYefJlmAfPZX/RMwYkEq/gzWR3ngf0VoY NxMF50zsiGXXkLVpjnGAdOITQ6Ogvn6r9bYoOT/EhMOTEiW+6inZcgNz3ginLH77SDebF15Su DH6C3buuseL4F425thkxvH3KlW6rhnRDLESQ9Im1SZOFUBQfKXBkO4tHf5xUvUlu8SMUFVjwz LSozweLcp4P5upUeIjImhLZkcXbEX/Hlx4++/2Ct4bgP+2caQlbMSnnwSwJAlW5PAEhsWZ7C5 Y/uSYxl5SbxEx8+AFRJY15GA6gMbXn8HCkG2l5GX24OZIhwnlge2zIW8Z/p96Y8yWUKNX5D5J vakgBQgIYxIRqsOcvBZzSONdgLdXLe0hMKyJDAQ36dP5VpkXhuiakVhKJ2TuH1I7g4GLesatk DeIfB06mUq8duKBkPk+nz2P8C/hxotlbO1P+DOdv4K+rLnA+cBdeDcM5WI99jnU7MWaP/o9y5 3XkwZ8uScPjSnEGPJdtLwb3YKLgOnZCQuj3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean On 6/3/21 1:04 PM, Andre Przywara wrote: > On Thu, 3 Jun 2021 12:20:34 +0200 > Heinrich Schuchardt wrote: > > Hi, > >> On 6/3/21 11:04 AM, Andre Przywara wrote: >>> On Thu, 3 Jun 2021 09:46:48 +0200 >>> Heinrich Schuchardt wrote: >>> >>> Hi Heinrich, >>> >>>> On 6/2/21 3:08 PM, Ramon Fried wrote: >>>>> On Tue, Jun 1, 2021 at 12:35 AM Heinrich Schuchardt wrote: >>>>>> >>>>>> Dear all, >>>>>> >>>>>> network is broken in U-Boot on orangepi_pc_defconfig: >>> >>> Thanks for the report! >>> >>>>>> >>>>>> U-Boot 2021.07-rc3-00059-gd8729a114e (May 31 2021 - 21:26:56 +0000) >>>>>> Allwinner Technology >>>>>> eth0: ethernet@1c30000 >>>>>> =3D> dhcp >>>>>> sun8i_emac_eth_start: Timeout >>>>>> >>>>>> Best regards >>>>>> >>>>>> Heinrich >>>>>> >>>>> Hi Heinrich, I don't have OrangePi. can you bisect and tell me when = it broke ? >>>>> Thanks. >>>>> Ramon. >>>>> >>>> >>>> Git bisect points to: >>>> >>>> commit 4f0278dac56a658ef1e0967fec0bb95372a875bd >>>> Author: Andre Przywara >>>> Date: Mon Jul 6 01:40:45 2020 +0100 >>>> >>>> net: sun8i-emac: Lower MDIO frequency >>>> >>>> Reverting the patch solves the problem for the OrangePi PC. >>>> >>>> According to the commit message the change was only needed for needed >>>> for external PHYs. >>> >>> The external PHY on the Pine64 (non-plus) was the trigger, however >>> both the manual and the Linux driver point to that we definitely need = a >>> higher divider. From what I can see, AHB2 (the EMAC clock) runs at 200 >>> MHz (AHB2=3DAHB1/1=3DPLL6/3=3D200 MHz). So just having "/ 16" results = in 12.5 >>> MHz MDIO frequency. Can you check whether any other divider values fix >>> this for you as well? >> >> MDIO_CMD_MII_CLK_CSR_DIV_16 =3D 0 and this is the value that was used >> before your patch. >> >> MDIO_CMD_MII_CLK_CSR_DIV_16 =3D 0 =3D> >> Waiting for PHY auto negotiation to complete. done >> MDIO_CMD_MII_CLK_CSR_DIV_32 =3D 1 =3D> sun8i_emac_eth_start: Timeout >> MDIO_CMD_MII_CLK_CSR_DIV_64 =3D 2 =3D> sun8i_emac_eth_start: Timeout >> MDIO_CMD_MII_CLK_CSR_DIV_128 =3D 3 =3D> sun8i_emac_eth_start: Timeout >> >> What is wrong about the approach in >> >> [PATCH 1/1] net: sun8i-emac: fix MDIO frequency >> https://lists.denx.de/pipermail/u-boot/2021-June/451305.html ? > > The MDIO spec says that the maximum frequency on the MDIO bus should be > 2.5 MHz. On the H3 with 200 MHz AHB and with a divider of 16 it's 12.5 The dts says for the MDIO: int_mii_phy: ethernet-phy@1 { clocks =3D <&ccu CLK_BUS_EPHY>; "ahb" refers to CLK_BUS_SPI1: spi1: spi@1c69000 { clocks =3D <&ccu CLK_BUS_SPI1>, <&ccu CLK_SPI1>; clock-names =3D "ahb", "mod"; Why are you mentioning AHB? > MHz. Apparently the internal H3 PHY can tolerate those high > frequencies, but it's beyond the spec. And certainly it should not fail > with lower frequencies. And indeed it works for me on the H2+ (which I > understand is just a binned version of the H3). > >> The Linux 5.10 driver runs fine no matter what value we choose for the >> divider in U-Boot. > > Because it programs the divider correctly: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/= drivers/net/ethernet/stmicro/stmmac/stmmac_main.c#n316 > I take it you have no problems with Linux, so the divider being too > high cannot be the root cause of the problem. Function stmmac_clk_csr_set() depends on the rate of the clock named "stmmaceth": ethernet@1c30000 { clocks =3D <&ccu CLK_BUS_EMAC>; clock-names =3D "stmmaceth"; How do we get the frequency of this clock? Best regards Heinrich > > So I'd rather fix this problem properly and correctly, especially as it > seems to be more related to the EMAC soft reset (where your error > message comes from). > >> But I see a message: >> >> dwmac-sun8i 1c30000.ethernet: >> Current syscon value is not the default 148000 (expect 58000) >> >> @default_syscon_value: >> The default value of the EMAC register in syscon >> This value is used for disabling properly EMAC >> and used as a good starting value in case of the >> boot process(uboot) leave some stuff. > > Yeah, I never got the reason for this message. If Linux wants a > certain value, it should program that. Whatever was left by someone > else (be it U-Boot or some other software/OS) should not matter. > > Cheers, > Andre > >> >> Best regards >> >> Heinrich >> >>> >>>> Can't we let the change depend on priv->use_internal_phy? >>>> >>>> diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c >>>> index 5a1b38bf80..d7553fe163 100644 >>>> --- a/drivers/net/sun8i_emac.c >>>> +++ b/drivers/net/sun8i_emac.c >>>> @@ -211,7 +211,9 @@ static int sun8i_mdio_read(struct mii_dev *bus, i= nt >>>> addr, int devad, int reg) >>>> * The EMAC clock is either 200 or 300 MHz, so we need a d= ivider >>>> * of 128 to get the MDIO frequency below the required 2.5= MHz. >>>> */ >>>> - mii_cmd |=3D MDIO_CMD_MII_CLK_CSR_DIV_128 << >>>> MDIO_CMD_MII_CLK_CSR_SHIFT; >>>> + if (!priv->use_internal_phy) >>>> + mii_cmd |=3D MDIO_CMD_MII_CLK_CSR_DIV_128 << >>>> + MDIO_CMD_MII_CLK_CSR_SHIFT; >>>> >>>> mii_cmd |=3D MDIO_CMD_MII_BUSY; >>>> >>>> @@ -242,7 +244,9 @@ static int sun8i_mdio_write(struct mii_dev *bus, = int >>>> addr, int devad, int reg, >>>> * The EMAC clock is either 200 or 300 MHz, so we need a d= ivider >>>> * of 128 to get the MDIO frequency below the required 2.5= MHz. >>>> */ >>>> - mii_cmd |=3D MDIO_CMD_MII_CLK_CSR_DIV_128 << >>>> MDIO_CMD_MII_CLK_CSR_SHIFT; >>>> + if (!priv->use_internal_phy) >>>> + mii_cmd |=3D MDIO_CMD_MII_CLK_CSR_DIV_128 << >>>> + MDIO_CMD_MII_CLK_CSR_SHIFT; >>>> >>>> mii_cmd |=3D MDIO_CMD_MII_WRITE; >>>> mii_cmd |=3D MDIO_CMD_MII_BUSY; >>>> >>>> Best regards >>>> >>>> Heinrich >>>> >>>> I would assume the problem hits all H3 boards. >>> >>> And that's the confusing part: it does not. I tested this on my >>> OrangePi Zero (H2+ with internal PHY), both back then with the origina= l >>> MDIO frequency patch and also now after your report. It always worked >>> reliably for me. >>> Also: I am still puzzled how one influences the other: The error you >>> get is from the *MAC* soft reset: I would think this is an independent >>> operation from any communication attempts with the PHY. >>> >>> There is this thread here about the same symptom on a V3s: >>> https://lists.denx.de/pipermail/u-boot/2021-May/450315.html >>> v2 of this original patch (in the same thread) proposes some other >>> solution, which I am also not very happy with. But just to get some mo= re >>> data points: can you check whether skipping the soft reset fixes this >>> for you? I will have a closer look tonight to check the order of soft >>> reset and PHY communication. Maybe we should only do the soft reset >>> *once* when the MAC probes, and not on every .start call? >>> >>> Thanks, >>> Andre >>> >> >