Bug 261355 - dwc(4) fails to attach on BananaPi A20
Summary: dwc(4) fails to attach on BananaPi A20
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mitchell Horne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-20 14:02 UTC by Maren
Modified: 2022-08-11 14:54 UTC (History)
1 user (show)

See Also:


Attachments
improve phy-mode detection (3.16 KB, patch)
2022-05-11 18:24 UTC, Mitchell Horne
no flags Details | Diff
aw_if_dwc tx clock detection v2 (2.53 KB, patch)
2022-05-11 18:38 UTC, Mitchell Horne
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maren 2022-01-20 14:02:33 UTC
It's running 14.0-CURRENT d106f982a54cd299671ccad58bc456138a22ae7b

dwc0: <A20 Gigabit Ethernet Controller> mem 0x1c50000-0x1c5ffff irq 72 on simplebus0
dwc0: MAC clock(ahb-gmac) freq: 160000000
dwc0: Can't reset DWC.
device_attach: dwc0 attach returned 6

after changing phy-mode back to rgmii in sun7i-a20-bananapi.dts, it works again.

diff --git a/sys/contrib/device-tree/src/arm/sun7i-a20-bananapi.dts b/sys/contrib/device-tree/src/arm/sun7i-a20-bananapi.dts
index 9d792d7a0f92..87cef1fc7dfd 100644
--- a/sys/contrib/device-tree/src/arm/sun7i-a20-bananapi.dts
+++ b/sys/contrib/device-tree/src/arm/sun7i-a20-bananapi.dts
@@ -132,7 +132,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&gmac_rgmii_pins>;
 	phy-handle = <&phy1>;
-	phy-mode = "rgmii-id";
+	phy-mode = "rgmii";
 	phy-supply = <&reg_gmac_3v3>;
 	status = "okay";
 };

dwc0: <A20 Gigabit Ethernet Controller> mem 0x1c50000-0x1c5ffff irq 72 on simplebus0
dwc0: MAC clock(ahb-gmac) freq: 160000000
miibus0: <MII bus> on dwc0
rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 0 on miibus0
rgephy0: OUI 0x00e04c, model 0x0011, rev. 5
rgephy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, auto
rgephy1: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0
rgephy1: OUI 0x00e04c, model 0x0011, rev. 5
rgephy1:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, auto
dwc0: bpf attached
Comment 1 Mitchell Horne freebsd_committer freebsd_triage 2022-05-11 18:24:29 UTC
Created attachment 233862 [details]
improve phy-mode detection

Hi, I've attached a patch which I believe will fix the issue. As you might expect we were doing a string comparison only for 'rgmii', not 'rgmii-id'. I do not have the hardware to test this, so if you can confirm it works that would be appreciated.
Comment 2 Mitchell Horne freebsd_committer freebsd_triage 2022-05-11 18:38:28 UTC
Created attachment 233863 [details]
aw_if_dwc tx clock detection v2

Actually, try this instead. It is slightly simpler based on fields already set in the generic driver code.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-06-23 18:16:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3428997cb398767655a5651b76eb177a56e4b00a

commit 3428997cb398767655a5651b76eb177a56e4b00a
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-06-21 13:22:53 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-06-23 18:15:10 +0000

    if_dwc: recognize additional rgmii phy-modes

    Per the reports, some Allwinner device trees now list the desired
    phy-mode as "rgmii-id". The manual string comparison fails to detect
    this, and we end up falling back to MII mode. Instead, select the clock
    name using the sc->phy_mode variable, which is set in the main attach
    function.

    The logic to actually handle rgmii-id mode delays will be added to the
    relevant PHY driver.

    PR:             261355, 264673
    Reported by:    Maren <marentoy@protonmail.com>
    Reported by:    Arie Bikker <src-2016@bikker.homeunix.net>
    Reviewed by:    manu
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35500

 sys/arm/allwinner/aw_if_dwc.c | 55 +++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 26 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-07-04 16:41:19 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1da82ebe499aec5f505b23238a231f01e77a17c3

commit 1da82ebe499aec5f505b23238a231f01e77a17c3
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-06-21 13:22:53 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-07-04 16:34:56 +0000

    if_dwc: recognize additional rgmii phy-modes

    Per the reports, some Allwinner device trees now list the desired
    phy-mode as "rgmii-id". The manual string comparison fails to detect
    this, and we end up falling back to MII mode. Instead, select the clock
    name using the sc->phy_mode variable, which is set in the main attach
    function.

    The logic to actually handle rgmii-id mode delays will be added to the
    relevant PHY driver.

    PR:             261355, 264673
    Reported by:    Maren <marentoy@protonmail.com>
    Reported by:    Arie Bikker <src-2016@bikker.homeunix.net>
    Reviewed by:    manu
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35500

    (cherry picked from commit 3428997cb398767655a5651b76eb177a56e4b00a)

 sys/arm/allwinner/aw_if_dwc.c | 55 +++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 26 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-08-11 14:53:27 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2870cfc456fd8133ca6b22abf3aa53e25808f87b

commit 2870cfc456fd8133ca6b22abf3aa53e25808f87b
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-06-21 13:22:53 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-08-11 14:52:03 +0000

    if_dwc: recognize additional rgmii phy-modes

    Per the reports, some Allwinner device trees now list the desired
    phy-mode as "rgmii-id". The manual string comparison fails to detect
    this, and we end up falling back to MII mode. Instead, select the clock
    name using the sc->phy_mode variable, which is set in the main attach
    function.

    The logic to actually handle rgmii-id mode delays will be added to the
    relevant PHY driver.

    PR:             261355, 264673
    Reported by:    Maren <marentoy@protonmail.com>
    Reported by:    Arie Bikker <src-2016@bikker.homeunix.net>
    Reviewed by:    manu
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35500

    (cherry picked from commit 3428997cb398767655a5651b76eb177a56e4b00a)

 sys/arm/allwinner/aw_if_dwc.c | 55 +++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 26 deletions(-)