Skip to content

gk-ephy: read as the GK7101 internal PHY does - #206

Merged
dimerr merged 1 commit into
OpenIPC:masterfrom
dimerr:goke-ephy-as-silicon
Oct 25, 2026
Merged

dimerr merged 1 commit into
OpenIPC:masterfrom
dimerr:goke-ephy-as-silicon

Conversation

@dimerr

@dimerr dimerr commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

The internal-PHY model reported an invented ID (0x0007c0f1) and set the BMSR link bit. A real GK7101, with a 100 Mb/s full-duplex link up, reads:

BMCR 3100  BMSR 78e9  ID1 0000  ID2 0000  ANAR 01e1  ANLPAR cde1

There is no ID, and BMSR shows autoneg complete but never the link bit. U-Boot's phylib therefore found no PHY on the camera, while it worked in qemu. The model now reads like the silicon, so that failure shows here too.

Checked:

The model gave the internal PHY an invented ID (0x0007c0f1) and set the
BMSR link bit, so that phylib would accept it. A GK7101 reads
otherwise, with a 100 Mb/s full-duplex link up:

    BMCR 3100  BMSR 78e9  ID1 0000  ID2 0000  ANAR 01e1  ANLPAR cde1

No ID, and autoneg complete but never the link bit. The vendor kernel
driver copes (it takes autoneg complete for link up, and prints mii id
= 0). OpenIPC U-Boot's phylib did not, and found no PHY on the camera,
while it worked here. Read as the silicon does, so it fails here too.

Boots of the gk7101 machine: the vendor-based kernel logs mii id = 0 and
reaches login; U-Boot without an ID workaround reports Could not get PHY,
with one it tftps. test-gk710x.py and test-gk710xs.py pass.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Match GK7101 internal PHY register reads

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Match measured GK7101 BMSR, PHY ID, and link-partner register values instead of reporting invented
 values.
• Expose the missing PHY ID and link bit so emulation reproduces U-Boot’s hardware failure.
Diagram

graph TD
  Guest["Guest PHY driver"] --> Read["EPHY MMIO read"] --> Select{"Register index"} -->|BMSR| Status["BMSR 0x78E9"]
  Select -->|PHY IDs| IDs["Zero PHY IDs"]
  Select -->|ANLPAR| Partner["ANLPAR 0xCDE1"]
  Select -->|Other| Stored["Stored registers"]
Loading
High-Level Assessment

Use the measured register values directly. Retaining or making the invented PHY ID configurable would preserve guest compatibility at the cost of hiding the U-Boot failure this hardware model needs to reproduce.

Files changed (1) +12 / -7

Bug fix (1) +12 / -7
gk-ephy.cReturn silicon-matched internal PHY register values +12/-7

Return silicon-matched internal PHY register values

• Changes BMSR to 0x78E9, clears both PHY ID responses, and sets ANLPAR to 0xCDE1 to match observed GK7101 reads. The comments explain why a guest driver cannot rely on a nonzero ID or the BMSR link bit.

qemu/hw/misc/gk-ephy.c

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. New PHY register values have no regression test 📘 Rule violation ⚙ Maintainability
Description
gk_ephy_read now returns BMSR 0x78E9, zero for both ID registers and ANLPAR 0xCDE1, but the PR
adds or changes no register-level test for gk-ephy. Neither test-gk710x.py nor test-gk710xs.py
reads the PHY window, so a later change that restores an ID or the link bit would pass both tests.
Code

qemu/hw/misc/gk-ephy.c[R49-55]

+    case 1:     /* BMSR: 100/10 FD/HD, preamble suppression, AN complete */
+        return 0x78E9;
+    case 2:     /* PHYID1 / PHYID2 */
   case 3:
-        return 0xC0F1;
-    case 5:     /* ANLPAR: the partner advertises the same */
-        return 0x45E1;
+        return 0;
+    case 5:     /* ANLPAR, as a switch advertised it to that GK7101 */
+        return 0xCDE1;
Evidence
Rule 9 requires regression coverage for changed device register behavior. A grep of the tests for
the PHY finds no check of the gk-ephy window in the GK710x test scripts, and the PR touches no
test file.

CLAUDE.md: Verify Device Wiring and Register Behavior with Tests: CLAUDE.md: Verify Device Wiring and Register Behavior with Tests
qemu/tests/test-gk710x.py[270-282]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `gk-ephy` read values (BMSR `0x78E9`, ID1/ID2 0, ANLPAR `0xCDE1`) are not covered by any register test.
## Fix Focus Areas
- qemu/tests/test-gk710x.py[121-290]
- qemu/hw/misc/gk-ephy.c[42-58]
## Recommended Fix
Add a `test_ephy` to `test-gk710x.py` that reads the PHY MMIO window (`ephy_base` from `qemu/hw/arm/goke.c`) at +0x4 (BMSR), +0x8 and +0xC (IDs), +0x10 (ANAR) and +0x14 (ANLPAR). It should assert `0x78E9`, 0, 0, `0x01E1` and `0xCDE1`, and that the link bit (`0x4`) is clear. Call it from `main`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread qemu/hw/misc/gk-ephy.c
Comment on lines +49 to +55
case 1: /* BMSR: 100/10 FD/HD, preamble suppression, AN complete */
return 0x78E9;
case 2: /* PHYID1 / PHYID2 */
case 3:
return 0xC0F1;
case 5: /* ANLPAR: the partner advertises the same */
return 0x45E1;
return 0;
case 5: /* ANLPAR, as a switch advertised it to that GK7101 */
return 0xCDE1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. New phy register values have no regression test 📘 Rule violation ⚙ Maintainability

gk_ephy_read now returns BMSR 0x78E9, zero for both ID registers and ANLPAR 0xCDE1, but the PR
adds or changes no register-level test for gk-ephy. Neither test-gk710x.py nor test-gk710xs.py
reads the PHY window, so a later change that restores an ID or the link bit would pass both tests.
Agent Prompt
## Issue description
The `gk-ephy` read values (BMSR `0x78E9`, ID1/ID2 0, ANLPAR `0xCDE1`) are not covered by any register test.

## Fix Focus Areas
- qemu/tests/test-gk710x.py[121-290]
- qemu/hw/misc/gk-ephy.c[42-58]

## Recommended Fix
Add a `test_ephy` to `test-gk710x.py` that reads the PHY MMIO window (`ephy_base` from `qemu/hw/arm/goke.c`) at +0x4 (BMSR), +0x8 and +0xC (IDs), +0x10 (ANAR) and +0x14 (ANLPAR). It should assert `0x78E9`, 0, 0, `0x01E1` and `0xCDE1`, and that the link bit (`0x4`) is clear. Call it from `main`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@dimerr
dimerr merged commit 057170f into OpenIPC:master Oct 25, 2026
23 checks passed
@dimerr
dimerr deleted the goke-ephy-as-silicon branch October 25, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant