net: ftgmac100: Add AST2700 support
Subsystems (4)
v7 cover net: ftgmac100: Add AST2700 support
Add the pieces needed for the FTGMAC100 driver to run on Aspeed AST2700 systems.
AST2700 keeps using the FTGMAC100 MAC IP, but the enablement is not limited to a new compatible string. The SoC can boot with the MAC on ARM64, needs the Aspeed-specific RMII mode bit programmed when a port is wired for RMII, and requires the driver to use the upper DMA address fields in the ring base registers and packet descriptors. Those fields expose a 35-bit DMA address range on AST2700, so the driver must request a mask that matches the address bits the hardware can encode.
The series first documents and wires up the aspeed,ast2700-mac compatible. It then treats AST2700 as an Aspeed MAC in the driver, enables the RMII mode programming, writes the AST2700 high descriptor-ring base registers, carries the RX/TX descriptor high address bits, rebuilds full DMA addresses before unmapping buffers, and requests a 35-bit DMA mask. The high ring base registers are only touched for AST2700 so older Aspeed device tree register windows remain unchanged. With that in place, the FTGMAC100 Kconfig entry can be made available on ARM64 while keeping the existing Aspeed MDIO dependency for AST2600 and newer ARCH_ASPEED systems.
RGMII delay is configured at the bootloader stage, the same way it is handled for AST2600, not by this driver. Aspeed's SDK bootloader configures both AST2600 and AST2700 boards with the RGMII delay disabled and advertises "phy-mode = rgmii-id" to match, mirroring the OpenBMC bootloader change that stopped inserting delays on AST2600 so its device trees could use the correct "rgmii-id" setting. On AST2700, every on-chip MAC is likewise configured by the bootloader with RGMII delay disabled and "rgmii-id" phy-mode. Because the delay is already resolved before Linux boots, the ftgmac100 driver does not need to program any RGMII delay for either AST2600 or AST2700.
This series has been validated on AST2700 EVB and AST2600 EVB.
Patch layout:
- patch 1 makes the existing aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles standalone, dropping the requirement to pair them with the generic "faraday,ftgmac100" fallback compatible, and constrains the clocks/clock-names properties per compatible instead of leaving them generically optional.
- patch 2 adds the aspeed,ast2700-mac compatible to the binding, with its RMII RCLK gate, reset support, the "phy-mode" requirement, and extends the clocks/clock-names validation to cover it as well.
- patch 3 adds the AST2700 match data and OF compatible.
- patch 4 programs the AST2700 RMII enable bit and documents why netdev->phydev can never be NULL at that point for AST2700.
- patch 5 makes "phy-mode" a required device tree property for AST2700 and fails probe if it is missing.
- patch 6 adds AST2700 upper DMA address handling for rings and descriptors.
- patch 7 enables the Faraday/FTGMAC100 Kconfig options on ARM64 and selects MDIO_ASPEED for ARCH_ASPEED.
---
Changes in v7:
- Require exactly one of "phy-mode" or "use-ncsi" for the AST2700
compatible in the devicetree binding, instead of unconditionally
requiring "phy-mode". The driver's use-ncsi path never reaches the
phy-mode check, and the binding's own first example (use-ncsi, no
phy-mode) was valid but failed the previous schema.
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Constrain the clocks and clock-names properties per compatible in the devicetree binding instead of leaving them generically optional:
aspeed,ast2400-mac takes exactly one clock, aspeed,ast2500-mac/ aspeed,ast2600-mac/aspeed,ast2700-mac take one or two, and the plain faraday,ftgmac100 compatible takes none. Require clock-names whenever
two clocks are listed. Split across patch 1 (base rule) and patch 2
(extended to AST2700), matching how the compatible additions
themselves are already split.
- Simplify the compatible schema from oneOf: [const: faraday,ftgmac100,
enum: [...]] to a single flat enum, since neither branch needs
multi-string matching.
- Drop Reviewed-by from Rob Herring on patch 2 since its content
changed again.
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Pick up Reviewed-by from Rob Herring on the AST2700 binding
patch.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Split the dt-bindings patch into two: one making the existing aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac
compatibles standalone, and a second adding the new
aspeed,ast2700-mac compatible, per review feedback that these are
two separate concerns.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Require "phy-mode" in the devicetree binding when the AST2700
compatible is used, matching the driver's probe-time requirement
added in v2.
- Drop the "faraday,ftgmac100" fallback compatible requirement for
AST2700; "aspeed,ast2700-mac" now stands on its own in the binding,
matching how the driver already matches it independently.
- Drop the same "faraday,ftgmac100" fallback requirement for
aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac as
well, per review feedback. The same EDORR/EDOTR bit mismatch applies
to all of them if a node ever bound through the generic
faraday,ftgmac100 entry alone; there is no evidence this has ever
happened in practice since ftgmac100_of_match[] has had dedicated
entries for these SoCs since commit 03a2aba50b2c, but keeping the
binding correct avoids leaving the same landmine in place. Folded
into this series rather than sent as a follow-up, to avoid
self-conflicting with a later series touching the same "compatible"
block. Note this makes make dtbs_check warn against arch/arm/boot/dts/aspeed/aspeed-g4.dtsi, aspeed-g5.dtsi, and
aspeed-g6.dtsi, which still declare the two-string compatible; that
.dtsi change will be sent separately through the Aspeed/arm-soc tree,
since dt-bindings changes don't go through that tree.
- Document in the RMII-enable patch why netdev->phydev is always
non-NULL by the time ftgmac100_start_hw() checks phydev->interface
for AST2700: ftgmac100_probe_dt() always attaches a phy_device
before register_netdev() can succeed, via a discrete PHY
(phy-handle), a fixed-link node, or NC-SI's internal fixed 100Mbit
PHY, and any failure in that setup aborts probe first.
- Drop Reviewed-by from Krzysztof Kozlowski on the dt-bindings patch
since its content changed.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Make "phy-mode" a required device tree property for AST2700 and fail
probe if it is missing, instead of silently defaulting to RGMII.
- Document in the cover letter how RGMII delay is configured at the
bootloader stage for AST2600 and AST2700.
- Simplify the MDIO_ASPEED Kconfig select to ARCH_ASPEED only, dropping
the redundant MACH_ASPEED_G6 condition, and update its help text to
mention AST2700.
- Pick up Reviewed-by from Krzysztof Kozlowski on the dt-bindings patch.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jacky Chou (7):
dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
dt-bindings: net: ftgmac100: Add AST2700 compatible
net: ftgmac100: Add AST2700 compatible support
net: ftgmac100: Enable AST2700 RMII support
net: ftgmac100: Require phy-mode for AST2700
net: ftgmac100: Add AST2700 upper DMA address support
net: ftgmac100: Allow building on ARM64
.../devicetree/bindings/net/faraday,ftgmac100.yaml | 88 ++++++++++++++++--- drivers/net/ethernet/faraday/Kconfig | 7 +- drivers/net/ethernet/faraday/ftgmac100.c | 98 +++++++++++++++++++--- drivers/net/ethernet/faraday/ftgmac100.h | 7 ++ drivers/net/mdio/Kconfig | 16 ++-- 5 files changed, 183 insertions(+), 33 deletions(-)
---
base-commit: 66726ba54a01a2951688a56f5eb4d13d063acbea
change-id: 20260623-support_ast2700-68fb164da45c
Best regards,
Signature · 1 line
Jacky Chou <[email protected]>
PATCH v7 1/7 dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone, ftgmac100_probe() would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.
Make each of them a standalone compatible instead, so none of the Aspeed compatibles require the generic fallback alongside them.
Now that the Aspeed compatibles no longer need the generic fallback, also constrain the clocks and clock-names properties per compatible instead of leaving them generically optional: aspeed,ast2400-mac takes exactly one clock, aspeed,ast2500-mac and aspeed,ast2600-mac take one or two, and the plain faraday,ftgmac100 compatible takes none. Require clock-names whenever two clocks are listed.
---
ftgmac100_of_match[] has had dedicated entries for AST2400, AST2500, and AST2600 since commit 03a2aba50b2c ("net: ftgmac100: List all compatibles"), so there is no known kernel + devicetree combination where a node has actually bound through the generic entry and gotten the wrong EDORR bit. This part is a binding correctness fix, not a fix for an observed failure.
Note that arch/arm/boot/dts/aspeed/aspeed-g4.dtsi, aspeed-g5.dtsi, and aspeed-g6.dtsi still declare their MAC nodes with the two-string "aspeed,astXXXX-mac", "faraday,ftgmac100" compatible, so this will make dtbs_check warn against those files until the redundant fallback compatible is dropped there as well. That .dtsi change will be sent as a separate series through the Aspeed/arm-soc tree, since dt-bindings changes don't go through that tree.
--- .../devicetree/bindings/net/faraday,ftgmac100.yaml | 71 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +61 -10
@@ -11,14 +11,11 @@ maintainers: properties: compatible: - oneOf: - - const: faraday,ftgmac100 - - items: - - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + enum: + - faraday,ftgmac100 + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac reg: maxItems: 1
@@ -88,22 +85,76 @@ allOf: else: properties: resets: false + - if: + properties: + compatible: + contains: + const: aspeed,ast2400-mac + then: + properties: + clocks: + maxItems: 1 + clock-names: + maxItems: 1 + required: + - clocks + - if: + properties: + compatible: + contains: + enum: + - aspeed,ast2500-mac + - aspeed,ast2600-mac + then: + properties: + clocks: + minItems: 1 + maxItems: 2 + clock-names: + minItems: 1 + maxItems: 2 + required: + - clocks + - if: + not: + properties: + compatible: + contains: + enum: + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac + then: + properties: + clocks: false + clock-names: false + - if: + properties: + clocks: + minItems: 2 + then: + required: + - clock-names unevaluatedProperties: false examples: - | + #include <dt-bindings/clock/aspeed-clock.h> + ethernet@1e660000 { - compatible = "aspeed,ast2500-mac", "faraday,ftgmac100"; + compatible = "aspeed,ast2500-mac"; reg = <0x1e660000 0x180>; interrupts = <2>; + clocks = <&syscon ASPEED_CLK_GATE_MAC1CLK>; use-ncsi; }; ethernet@1e680000 { - compatible = "aspeed,ast2500-mac", "faraday,ftgmac100"; + compatible = "aspeed,ast2500-mac"; reg = <0x1e680000 0x180>; interrupts = <2>; + clocks = <&syscon ASPEED_CLK_GATE_MAC2CLK>; phy-handle = <&phy>; phy-mode = "rgmii";
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] dt-bindings: net: ftgmac100: dropping fallback compatible breaks dtbs_check - [Low] dt-bindings…
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [Medium] dt-bindings: net: ftgmac100: dropping fallback compatible breaks dtbs_check
- [Low] dt-bindings: net: ftgmac100: broken two-clock conditional in schema
- [Low] dt-bindings: net: ftgmac100: unwieldy per-compatible conditionals in schema
- [Low] dt-bindings: net: ftgmac100: inaccurate DMA mask claim in commit message
--
commit 9fe0301cae72065a7d7965c7e6fd35afb67ceddd
Author: Jacky Chou <[email protected]>
dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
This commit updates the Faraday FTGMAC100 binding schema to make the Aspeed MAC compatibles standalone and constrains the clocks and clock-names properties per compatible.
Quoted 6 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.
[Severity: Low]
Is the commit message claim about the DMA mask accurate for these three compatibles?
ftgmac100_probe() configures the descriptor ring end-of-ring masks and Aspeed clocks for FTGMAC100_AST2400, FTGMAC100_AST2500, and FTGMAC100_AST2600, but does not configure a DMA mask for any of them.
Quoted 11 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-3@@ -11,14 +11,11 @@ maintainers: properties: compatible: - oneOf: - - const: faraday,ftgmac100 - - items:
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml maintainers: · line 18
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +5
-5- - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + enum: + - faraday,ftgmac100 + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac
[Severity: Medium]
As reported by Rob Herring on v4 [1], does removing the two-string compatible combination break DT schema backward compatibility and cause dtbs_check errors on existing device trees?
All MAC nodes in arch/arm/boot/dts/aspeed/aspeed-g4.dtsi, arch/arm/boot/dts/aspeed/aspeed-g5.dtsi, and arch/arm/boot/dts/aspeed/aspeed-g6.dtsi still pair the Aspeed compatible with "faraday,ftgmac100". Retaining the two-string entry (with
deprecated: true) alongside the standalone compatibles would preserve compatibility without introducing validation regressions.
Quoted 37 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +33
-0@@ -88,22 +85,76 @@ allOf: else: properties: resets: false + - if: + properties: + compatible: + contains: + const: aspeed,ast2400-mac + then: + properties: + clocks: + maxItems: 1 + clock-names: + maxItems: 1 + required: + - clocks + - if: + properties: + compatible: + contains: + enum: + - aspeed,ast2500-mac + - aspeed,ast2600-mac + then: + properties: + clocks: + minItems: 1 + maxItems: 2 + clock-names: + minItems: 1 + maxItems: 2 + required: + - clocks + - if: + not: + properties:
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 130
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +10
-0+ compatible: + contains: + enum: + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac + then: + properties: + clocks: false + clock-names: false
[Severity: Low]
This isn't a bug, but now that the Aspeed compatibles are standalone and do not share resets, clocks, or clock-names with plain faraday,ftgmac100, would splitting the Aspeed MAC binding into its own schema document be cleaner than piling per-compatible if/then conditionals and duplicated minItems/maxItems constraints into faraday,ftgmac100.yaml?
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 137
Quoted 7 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +7
-0+ - if: + properties: + clocks: + minItems: 2 + then: + required: + - clock-names
[Severity: Low]
Does omitting required: [clocks] from this if block cause nodes without a clocks property to require clock-names?
In JSON Schema, a properties constraint succeeds when the tested property is absent, so a plain faraday,ftgmac100 node without clocks matches this if condition and hits required: [clock-names] even though the previous rule sets clock-names: false. In addition, because clock-names allows
minItems: 1, the then branch needs properties: clock-names: minItems: 2 so a node with two clocks cannot pass validation with only a single clock-names entry while ftgmac100_setup_clk() looks up the second clock by the name "RCLK".
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH net-next v7 1/7] dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
In reply to Jacky ChouThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The binding no longer accepts the established two-string compatible form ("aspeed,ast2400/2500/2600-mac", "faraday,ftgmac100"),…
- [Medium] With the new allOf conditionals, no node using the plain "faraday,ftgmac100" compatible can pass validation, even though the…
- [Low] The commit message says that binding the AST2400/2500/2600 MACs through the generic entry would 'leave the DMA mask too narrow'.
- [Low] For aspeed,ast2500-mac and aspeed,ast2600-mac, the new per- compatible block (lines 101-117) limits clocks (1-2) and `clock-…
--
dt-bindings: net: ftgmac100: Make Aspeed compatibles standalone
This patch makes aspeed,ast2400-mac, aspeed,ast2500-mac and aspeed,ast2600-mac standalone compatibles. They no longer need the "faraday,ftgmac100" fallback. It also adds per-compatible constraints on clocks and clock-names, and requires clock-names when two clocks are listed.
Quoted 6 lines
The aspeed,ast2400-mac, aspeed,ast2500-mac, and aspeed,ast2600-mac compatibles are currently only valid when paired with the generic "faraday,ftgmac100" fallback: if a node ever bound through the generic entry alone,
ftgmac100_probe()would set rxdes0_edorr_mask/txdes0_edotr_mask to BIT(15) instead of the Aspeed BIT(30), skip Aspeed clock setup, and leave the DMA mask too narrow.
[Severity: Low]
Is the DMA mask part accurate for these three compatibles?
At this commit, drivers/net/ethernet/faraday/ftgmac100.c has no dma_set_mask*() or DMA_BIT_MASK() call. ftgmac100_probe() uses mac_id for only three things: picking the EDORR/EDOTR bits, setting is_aspeed, and calling ftgmac100_setup_clk():
if (priv->mac_id == FTGMAC100_AST2400 ||
priv->mac_id == FTGMAC100_AST2500 ||
priv->mac_id == FTGMAC100_AST2600) {
priv->rxdes0_edorr_mask = BIT(30);
priv->txdes0_edotr_mask = BIT(30);
priv->is_aspeed = true;Later in the series, the only DMA mask call is dma_set_mask_and_coherent(..., DMA_BIT_MASK(35)), and it is gated by FTGMAC100_QUIRK_DMA_35BIT. That quirk is set only for the AST2700 match data.
Could the "leave the DMA mask too narrow" clause be dropped from the commit message?
Quoted 11 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-3@@ -11,14 +11,11 @@ maintainers: properties: compatible: - oneOf: - - const: faraday,ftgmac100 - - items:
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml maintainers: · line 18
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +5
-5- - enum: - - aspeed,ast2400-mac - - aspeed,ast2500-mac - - aspeed,ast2600-mac - - const: faraday,ftgmac100 + enum: + - faraday,ftgmac100 + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac
[Severity: Medium]
With the oneOf/items branch removed, does the established two-string form ("aspeed,astXXXX-mac", "faraday,ftgmac100") become invalid?
Every MAC node in aspeed-g4.dtsi, aspeed-g5.dtsi and aspeed-g6.dtsi uses that form, for example:
arch/arm/boot/dts/aspeed/aspeed-g6.dtsi:
compatible = "aspeed,ast2600-mac", "faraday,ftgmac100";
All eight of those nodes would fail dtbs_check as soon as this lands.
The planned follow-up dtsi change would then drop the fallback. Before commit 03a2aba50b2c ("net: ftgmac100: List all compatibles"), ftgmac100_of_match[] had only:
{ .compatible = "faraday,ftgmac100" },Those kernels told the Aspeed variants apart afterwards with of_device_is_compatible().
Wouldn't a DTB without the fallback leave those older kernels, including current LTS kernels, with no Ethernet driver bound at all?
The commit message calls binding through the generic entry a hypothetical hazard ("if a node ever bound through the generic entry alone"). On kernels before 03a2aba50b2c, that was the only way these nodes bound, and it worked.
With the current driver, of_match scoring already prefers the more specific Aspeed string over the fallback. So the two-string form doesn't run into the problem the commit message describes either.
The impact is mentioned only below the --- line, which is dropped when the patch is applied. That note also covers only the dtbs_check warnings.
Would keeping the two-string form as a deprecated: true oneOf branch avoid breaking older kernels? This is still the case at the end of the series.
Quoted 4 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +0
-0reg: maxItems: 1@@ -88,22 +85,76 @@ allOf:
[ ... ]
Quoted 7 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +7
-0+ - if: + properties: + compatible: + contains: + enum: + - aspeed,ast2500-mac + - aspeed,ast2600-mac
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 117
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +10
-0+ then: + properties: + clocks: + minItems: 1 + maxItems: 2 + clock-names: + minItems: 1 + maxItems: 2 + required: + - clocks
[Severity: Low]
Should the clocks and clock-names counts be tied together here?
The two limits are set separately. The later rule only requires clock-names to be present when two clocks are listed. So this passes:
clocks = <&a>, <&b>;
clock-names = "MACCLK";However, the driver looks up the second clock by name:
drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_setup_clk() {
...
priv->rclk = devm_clk_get_optional_enabled(priv->dev, "RCLK");
...
}The missing name returns -ENOENT, which the optional API turns into NULL. Probe then succeeds without enabling the RCLK gate.
The reverse mismatch also passes, and an in-tree example exists. &mac3 in aspeed-bmc-ampere-mtmitchell.dts has:
clock-names = "MACCLK", "RCLK";
but it inherits only one clock from aspeed-g6.dtsi. The old schema already accepted that case, so it isn't new with this patch. Both cases assume dt-schema has no generic check that a *-names list matches the length of its property.
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +10
-0+ - if: + not: + properties: + compatible: + contains: + enum: + - aspeed,ast2400-mac + - aspeed,ast2500-mac + - aspeed,ast2600-mac + then:
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 137
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +10
-0+ properties: + clocks: false + clock-names: false + - if: + properties: + clocks: + minItems: 2 + then: + required: + - clock-names
[Severity: Medium]
Can a node using the plain "faraday,ftgmac100" compatible pass validation with these two blocks?
The not-Aspeed block forbids both clocks and clock-names for that compatible. This last if has no required: [clocks]. When clocks is absent, the properties check is vacuously true, so the then branch still applies.
The commit message says a faraday,ftgmac100 node should have no clocks ("the plain faraday,ftgmac100 compatible takes none"). Such a node would get:
'clock-names' is a required property
even though the block above forbids clock-names.
The driver still binds this compatible through ftgmac100_match_data_faraday. The examples only cover ast2500 nodes with clocks, so dt_binding_check doesn't catch this. The blocks are unchanged at the end of the series.
Would adding required inside the if fix this? For example:
- if:
required:
- clocks
properties:
clocks:
minItems: 2
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com
PATCH v7 2/7 dt-bindings: net: ftgmac100: Add AST2700 compatible
In reply to Jacky ChouAdd AST2700 to the FTGMAC100 compatible list and document that its RMII RCLK gate matches the earlier Aspeed SoCs. Allow the reset line for AST2700 as it follows the same reset requirements as AST2600.
Require exactly one of "phy-mode" or "use-ncsi" in the device tree when the AST2700 compatible is used. The driver only enforces "phy-mode" when NC-SI is not in use: ftgmac100_probe_dt() takes the NC-SI path before ftgmac100_mii_probe(), where the AST2700 phy-mode check lives, is ever reached. Requiring "phy-mode" unconditionally would have rejected the valid use-ncsi configuration shown in this file's own first example.
Add aspeed,ast2700-mac as a standalone compatible, consistent with the other Aspeed compatibles.
Extend the per-compatible clocks/clock-names validation to also cover AST2700, since it shares the same one-or-two-clock layout as AST2500/2600.
--- .../devicetree/bindings/net/faraday,ftgmac100.yaml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +16 -1
@@ -16,6 +16,7 @@ properties: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac reg: maxItems: 1
@@ -27,7 +28,7 @@ properties: minItems: 1 items: - description: MAC IP clock - - description: RMII RCLK gate for AST2500/2600 + - description: RMII RCLK gate for AST2500/2600/2700 resets: maxItems: 1
@@ -79,12 +80,24 @@ allOf: contains: enum: - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: resets: true else: properties: resets: false + - if: + properties: + compatible: + contains: + const: aspeed,ast2700-mac + then: + oneOf: + - required: + - phy-mode + - required: + - use-ncsi - if: properties: compatible:
@@ -105,6 +118,7 @@ allOf: enum: - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: clocks:
@@ -124,6 +138,7 @@ allOf: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: clocks: false
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 2/7] dt-bindings: net: ftgmac100: Add AST2700 compatible
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] Concern: the commit message for "dt-bindings: net: ftgmac100: Add AST2700 compatible" says "ftgmac100_probe_dt() takes the NC-SI path…
- [Low] In "dt-bindings: net: ftgmac100: Add AST2700 compatible", the new AST2700 conditional in…
- [Low] Concern: the binding adds aspeed,ast2700-mac as a standalone compatible, but at this commit…
--
dt-bindings: net: ftgmac100: Add AST2700 compatible
This commit adds aspeed,ast2700-mac to the ftgmac100 binding. It allows the reset line for it and adds it to the clocks/clock-names conditionals. It also adds an AST2700-only rule that requires exactly one of phy-mode or use-ncsi.
Quoted 5 lines
Require exactly one of "phy-mode" or "use-ncsi" in the device tree when the AST2700 compatible is used. The driver only enforces "phy-mode" when NC-SI is not in use:
ftgmac100_probe_dt()takes the NC-SI path beforeftgmac100_mii_probe(), where the AST2700 phy-mode check lives, is ever reached.
[Severity: Low]
At this commit, ftgmac100_mii_probe() in drivers/net/ethernet/faraday/ftgmac100.c has no AST2700 phy-mode check. It falls back to RGMII when phy-mode is missing.
Does this paragraph refer to the check added later in the series by "net: ftgmac100: Require phy-mode for AST2700"?
ftgmac100_mii_probe() {
...
err = of_get_phy_mode(np, &phy_intf);
if (err) {
if (priv->mac_id == FTGMAC100_AST2700) {
dev_err(priv->dev, "phy-mode is required for this SoC\n");
return -EINVAL;
}
...
}After the full series is applied, the description matches the code. That is because ftgmac100_probe_dt() returns through ftgmac100_probe_ncsi() before it reaches ftgmac100_mii_probe(). Could the message say that a following patch adds the check, so it is also accurate at this commit?
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml properties: · line 19
Quoted 9 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +1
-0@@ -16,6 +16,7 @@ properties: - aspeed,ast2400-mac - aspeed,ast2500-mac - aspeed,ast2600-mac + - aspeed,ast2700-mac
[Severity: Low]
At this commit, ftgmac100_of_match[] in drivers/net/ethernet/faraday/ftgmac100.c has no entry for aspeed,ast2700-mac. There is also no FTGMAC100_AST2700 mac_id and no is_aspeed handling. Can a schema-valid AST2700 node bind to the driver at this point?
The next patch in the series, "net: ftgmac100: Add AST2700 compatible support", appears to fix this by adding:
{ .compatible = "aspeed,ast2700-mac",
.data = &ftgmac100_match_data_ast2700 },It also adds FTGMAC100_AST2700 to the is_aspeed branch of ftgmac100_probe(). Adding the binding before the driver is the usual order, and no in-tree DTS uses this compatible yet. I'm mentioning it only for completeness.
[ ... ]
Quoted 12 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +2
-0@@ -79,12 +80,24 @@ allOf: contains: enum: - aspeed,ast2600-mac + - aspeed,ast2700-mac then: properties: resets: true else: properties: resets: false + - if:
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml allOf: · line 100
Quoted 10 lines
Documentation/devicetree/bindings/net/faraday,ftgmac100.yaml +10
-0+ properties: + compatible: + contains: + const: aspeed,ast2700-mac + then: + oneOf: + - required: + - phy-mode + - required: + - use-ncsi
[Severity: Low]
oneOf fails when both subschemas match. Will an AST2700 node with both phy-mode = "rmii" and use-ncsi then fail dtbs_check?
The driver accepts that combination. ftgmac100_probe_dt() checks use-ncsi first:
if (of_get_property(np, "use-ncsi", NULL)) return ftgmac100_probe_ncsi(netdev, priv, pdev);
ftgmac100_probe_ncsi() then always connects with RMII and never reads phy-mode:
err = phy_connect_direct(netdev, phydev, ftgmac100_adjust_link, PHY_INTERFACE_MODE_RMII);
Existing nodes for this binding already use this pairing, for example &mac2 and &mac3 in aspeed-bmc-asus-x4tf.dts:
phy-mode = "rmii"; use-ncsi;
The same pattern appears in aspeed-bmc-inventec-starscream.dts, aspeed-bmc-nvidia-gb200nvl-bmc.dts and aspeed-bmc-quanta-s6q.dts.
The commit message's stated reason is to avoid rejecting nodes that only have use-ncsi, and anyOf would do that too. Would anyOf fit better here?
If the goal is to stop a non-RMII mode from being used with NC-SI, a rule like "if: required: [use-ncsi] then: properties: phy-mode: const: rmii" could express that instead.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com
PATCH v7 3/7 net: ftgmac100: Add AST2700 compatible support
In reply to Jacky ChouAdd match data for the Aspeed AST2700 FTGMAC100 controller and wire its compatible string into the OF match table. This lets AST2700 device tree nodes bind to the ftgmac100 driver.
--- drivers/net/ethernet/faraday/ftgmac100.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +10 -2
@@ -37,7 +37,8 @@ enum ftgmac100_mac_id {FTGMAC100_FARADAY =1 ,FTGMAC100_AST2400 ,FTGMAC100_AST2500 , -FTGMAC100_AST2600 +FTGMAC100_AST2600 , +FTGMAC100_AST2700 }; struct ftgmac100_match_data {
@@ -2017,7 +2018,8 @@ static int ftgmac100_probe(struct platform_device *pdev)if (priv->mac_id ==FTGMAC100_AST2400 || priv->mac_id ==FTGMAC100_AST2500 || - priv->mac_id ==FTGMAC100_AST2600 ) { + priv->mac_id ==FTGMAC100_AST2600 || + priv->mac_id ==FTGMAC100_AST2700 ) { priv->rxdes0_edorr_mask =BIT (30 ); priv->txdes0_edotr_mask =BIT (30 ); priv->is_aspeed = true;
@@ -2131,6 +2133,10 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = { .mac_id = FTGMAC100_AST2600 }; +static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { + .mac_id =FTGMAC100_AST2700 +}; +static const struct ftgmac100_match_data ftgmac100_match_data_faraday = { .mac_id =FTGMAC100_FARADAY };
@@ -2142,6 +2148,8 @@ static const struct of_device_id ftgmac100_of_match[] = { .data = &ftgmac100_match_data_ast2500 }, { .compatible = "aspeed,ast2600-mac", .data = &ftgmac100_match_data_ast2600 }, + { .compatible = "aspeed,ast2700-mac", + .data = &ftgmac100_match_data_ast2700 }, { .compatible = "faraday,ftgmac100", .data = &ftgmac100_match_data_faraday }, { }
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 3/7] net: ftgmac100: Add AST2700 compatible support
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] net: ftgmac100: missing MAC reset deassertion for AST2700 in ftgmac100_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] net: ftgmac100: missing MAC reset deassertion for AST2700 in ftgmac100_probe()
--
commit bc0b615a5df5edb854a72ea5c88c72e247810b61
Author: Jacky Chou <[email protected]>
net: ftgmac100: Add AST2700 compatible support
This commit adds match data and the "aspeed,ast2700-mac" compatible string so AST2700 FTGMAC100 device tree nodes can bind to the driver.
Quoted 4 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_probe(struct platform_device *pdev) · line 2025
Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-1@@ -2017,7 +2018,8 @@ static int ftgmac100_probe(struct platform_device *pdev)if (priv->mac_id ==FTGMAC100_AST2400 || priv->mac_id ==FTGMAC100_AST2500 || - priv->mac_id ==FTGMAC100_AST2600 ) { + priv->mac_id ==FTGMAC100_AST2600 || + priv->mac_id ==FTGMAC100_AST2700 ) { priv->rxdes0_edorr_mask =BIT (30 ); priv->txdes0_edotr_mask =BIT (30 ); priv->is_aspeed = true;
[Severity: High]
Does ftgmac100_probe() leave the AST2700 MAC held in hardware reset?
On AST2400, AST2500, and AST2600, the MAC clock gates define a coupled reset_idx, so enabling the clock in ftgmac100_setup_clk() automatically deasserts the MAC reset. On AST2700, ast2700_clk_enable() only clears the clock stop bit in SCU1_CLK_STOP and does not release the separate SCU1_RESET_MAC0..2 resets:
drivers/clk/aspeed/clk-ast2700.c:ast2700_clk_enable() {
struct clk_gate *gate = to_clk_gate(hw);
u32 clk = BIT(gate->bit_idx);
if (readl(gate->reg) & clk)
writel(clk, gate->reg + 0x04);
return 0;
}Unless the bootloader has already enabled the clock and released the reset, ftgmac100_initial_mac() reads FTGMAC100_OFFSET_MAC_MADR and FTGMAC100_OFFSET_MAC_LADR before priv->clk is enabled and before priv->rst is acquired. Moreover, ftgmac100_probe() never calls reset_control_deassert(priv->rst), and ftgmac100_reset_and_config_mac() only toggles priv->rst for PHY_INTERFACE_MODE_RMII, leaving RGMII interfaces in reset so ftgmac100_reset_mac() fails with -EIO.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH net-next v7 3/7] net: ftgmac100: Add AST2700 compatible support
In reply to Jacky ChouThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The binding and the driver disagree on how an AST2700 PHY is wired up.
- [Low] At this revision AST2700 gets the 32-bit Aspeed handling and nothing more.
- [Low] Several driver comments that list which Aspeed generations share a behaviour were not updated when this patch put AST2700 in the…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but this patch extends it to AST2700.
--
net: ftgmac100: Add AST2700 compatible support
This commit adds an FTGMAC100_AST2700 mac_id with matching match data, and adds the "aspeed,ast2700-mac" compatible to the OF match table. AST2700 gets the same Aspeed descriptor masks and is_aspeed handling as AST2400/2500/2600.
drivers/net/ethernet/faraday/ftgmac100.c enum ftgmac100_mac_id { · line 42
Quoted 12 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-1@@ -37,7 +37,8 @@ enum ftgmac100_mac_id {FTGMAC100_FARADAY =1 ,FTGMAC100_AST2400 ,FTGMAC100_AST2500 , - FTGMAC100_AST2600 +FTGMAC100_AST2600 , + FTGMAC100_AST2700 };
[Severity: Low]
This isn't a bug, but FTGMAC100_AST2700 now sits in the same class as AST2600. Should the comments that list the Aspeed generations be updated to match?
The rclk field in struct ftgmac100 still says:
/* AST2500/AST2600 RMII ref clock gate */ struct clk *rclk;
is_aspeed is now set for AST2700, so ftgmac100_setup_clk() fetches RCLK for AST2700 as well.
The comment in ftgmac100_probe_dt() ("2600 has an independent MDIO controller, not part of the MAC") and the one in ftgmac100_setup_mdio() ("The AST2600 has a separate MDIO controller") also apply to AST2700 now, but neither mentions it.
These comments are still unchanged at the end of the series.
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_probe(struct platform_device *pdev) · line 2025
Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-1@@ -2017,7 +2018,8 @@ static int ftgmac100_probe(struct platform_device *pdev)if (priv->mac_id ==FTGMAC100_AST2400 || priv->mac_id ==FTGMAC100_AST2500 || - priv->mac_id ==FTGMAC100_AST2600 ) { + priv->mac_id ==FTGMAC100_AST2600 || + priv->mac_id ==FTGMAC100_AST2700 ) { priv->rxdes0_edorr_mask =BIT (30 ); priv->txdes0_edotr_mask =BIT (30 ); priv->is_aspeed = true;
[Severity: High]
This is a pre-existing issue that was not introduced by this patch, but setting is_aspeed for AST2700 carries it over to the new compatible.
ftgmac100_reset_and_config_mac() dereferences phydev without checking for NULL:
if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {ftgmac100_probe_dt() can return 0 with no PHY attached. This happens when the node has no use-ncsi, no fixed-link and no phy-handle, but does have an mdio child:
if (!ftgmac100_has_child_node(np, "mdio")) {
...
err = ftgmac100_mii_probe(netdev);
...
}
return 0;In that case register_netdev() succeeds with netdev->phydev == NULL, and the first open runs:
ftgmac100_open()
ftgmac100_reset_and_config_mac()
priv->netdev->phydev->interface
ftgmac100_open(), ftgmac100_stop() and ftgmac100_phy_disconnect() all check netdev->phydev for NULL already. So a NULL phydev after probe seems to be an expected state.
The binding accepts such a node, since an mdio child is allowed and phy-handle is optional.
Can this oops in ndo_open, with rtnl held, for an AST2700 node like this?
There is also a later patch in the series, "net: ftgmac100: Enable AST2700 RMII support". It says that ftgmac100_probe_dt() always attaches a phy_device before register_netdev() can succeed, and it adds another unguarded phydev->interface dereference in ftgmac100_start_hw(). Does that assumption still hold given the path above?
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.c static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = { · line 2139
Quoted 8 lines
drivers/net/ethernet/faraday/ftgmac100.c +4
-0@@ -2131,6 +2133,10 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = { .mac_id = FTGMAC100_AST2600 }; +static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { + .mac_id =FTGMAC100_AST2700 +}; +
[Severity: Low]
At this revision AST2700 only gets the 32-bit Aspeed handling. The driver never calls dma_set_mask*(). ftgmac100_init_hw() writes only the low 32 bits of the ring bases:
iowrite32(priv->rxdes_dma, priv->base + FTGMAC100_OFFSET_RXR_BADR);
ftgmac100_alloc_rx_buf() also keeps only the low 32 bits in the descriptor:
rxdes->rxdes3 = cpu_to_le32(map);
AST2700 DRAM starts at 0x400000000 (memory@400000000 in ast2700-evb.dts). Would the MAC be able to DMA at all on AST2700 at this point in the series?
A later patch in the series, "net: ftgmac100: Add AST2700 upper DMA address support", seems to fix this. It adds FTGMAC100_QUIRK_DMA_35BIT, the 35-bit DMA mask, the high ring base registers and the descriptor high address bits.
The Kconfig dependencies also prevent building the driver for arm64 until "net: ftgmac100: Allow building on ARM64":
depends on ARM || COMPILE_TEST depends on !64BIT || BROKEN
So this state probably can't be reached on real hardware during bisection. Would it still make sense to wire up the compatible after the DMA support lands in the series?
drivers/net/ethernet/faraday/ftgmac100.c static const struct of_device_id ftgmac100_of_match[] = { · line 2152
Quoted 9 lines
drivers/net/ethernet/faraday/ftgmac100.c +2
-0static const struct ftgmac100_match_data ftgmac100_match_data_faraday = { .mac_id =FTGMAC100_FARADAY };@@ -2142,6 +2148,8 @@ static const struct of_device_id ftgmac100_of_match[] = { .data = &ftgmac100_match_data_ast2500 }, { .compatible = "aspeed,ast2600-mac", .data = &ftgmac100_match_data_ast2600 }, + { .compatible = "aspeed,ast2700-mac", + .data = &ftgmac100_match_data_ast2700 },
[Severity: Medium]
Do the binding and the driver agree on how an AST2700 PHY gets connected?
ftgmac100_probe() only calls ftgmac100_setup_mdio() for FARADAY, AST2400 and AST2500. For AST2700, priv->mii_bus is therefore always NULL:
if (priv->mac_id == FTGMAC100_FARADAY ||
priv->mac_id == FTGMAC100_AST2400 ||
priv->mac_id == FTGMAC100_AST2500) {
err = ftgmac100_setup_mdio(netdev);This means a non-NC-SI AST2700 node only probes successfully if it has phy-handle or fixed-link. Otherwise one of two things happens.
Without an mdio child, ftgmac100_probe_dt() calls ftgmac100_mii_probe(), which always fails here:
if (!priv->mii_bus) {
dev_err(priv->dev, "No MDIO bus available\n");
return -ENODEV;
}With an mdio child, ftgmac100_probe_dt() returns 0 with no PHY attached. That leads to the NULL phydev dereference described above.
At the end of the series, faraday,ftgmac100.yaml only requires one of phy-mode or use-ncsi for aspeed,ast2700-mac. It leaves phy-handle optional and allows an mdio child. So a node such as compatible = "aspeed,ast2700-mac"; phy-mode = "rgmii"; passes dt_binding_check, but then either fails to probe or binds with no PHY.
The binding patch justifies the phy-mode requirement by pointing at the AST2700 phy-mode check in ftgmac100_mii_probe(). That check is added by "net: ftgmac100: Require phy-mode for AST2700", and it sits after the !priv->mii_bus guard, which always returns -ENODEV for AST2700. Can that check ever run?
On the phy-handle/fixed-link path, of_phy_get_and_connect() already returns NULL when of_get_phy_mode() fails.
Should the binding require phy-handle or fixed-link for AST2700 when use-ncsi is absent?
Quoted 3 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0{ .compatible = "faraday,ftgmac100", .data = &ftgmac100_match_data_faraday }, { }
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com
PATCH v7 4/7 net: ftgmac100: Enable AST2700 RMII support
In reply to Jacky ChouSet the RMII enable bit when an AST2700 port uses RMII so the MAC is programmed for the selected interface mode. Describe the requirement as a match-data quirk instead of checking the MAC generation in the data path, allowing later compatible controllers to opt into the behavior.
phydev is always populated by the time this runs: ftgmac100_start_hw() is only reached once the device has been opened, and ftgmac100_probe_dt() always attaches a phy_device before register_netdev() can succeed -- via a discrete PHY ("phy-handle"), a "fixed-link" node, or NC-SI's internal fixed 100Mbit PHY (ftgmac100_probe_ncsi()). Any failure in that setup aborts probe before register_netdev(), so an opened AST2700 netdev always has phydev set. This mirrors the same assumption ftgmac100_reset_and_config_mac() already makes for every Aspeed SoC earlier in the open path.
--- drivers/net/ethernet/faraday/ftgmac100.c | 21 +++++++++++++++++++-- drivers/net/ethernet/faraday/ftgmac100.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +19 -2
@@ -41,8 +41,11 @@ enum ftgmac100_mac_id { FTGMAC100_AST2700 }; +#define FTGMAC100_QUIRK_RMII_ENABLE BIT(0) +struct ftgmac100_match_data {enum ftgmac100_mac_id mac_id; +u32 quirks; };/* Arbitrary values, I am not sure the HW has limits */
@@ -79,6 +82,7 @@ struct ftgmac100 {void __iomem *base;enum ftgmac100_mac_id mac_id; +u32 quirks;/* Rx ring */ unsigned int rx_q_entries;
@@ -355,6 +359,12 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)static void ftgmac100_start_hw (struct ftgmac100 *priv) {u32 maccr =ioread32 (priv->base +FTGMAC100_OFFSET_MACCR ); +/* +* Only reached once the device is open, so a phy_device is already +* attached: a discrete PHY via "phy-handle", a "fixed-link" node, or +* NC-SI's internal fixed 100M PHY. +*/ +struct phy_device *phydev = priv->netdev->phydev;/* Keep the original GMAC and FAST bits */ maccr &= (FTGMAC100_MACCR_FAST_MODE |FTGMAC100_MACCR_GIGA_MODE );
@@ -383,6 +393,11 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)if (priv->netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) maccr |=FTGMAC100_MACCR_RM_VLAN ; +if ((priv->quirks &FTGMAC100_QUIRK_RMII_ENABLE ) && + phydev->interface ==PHY_INTERFACE_MODE_RMII ) { + maccr |=FTGMAC100_MACCR_RMII_ENABLE ; + } +/* Hit the HW */ iowrite32 (maccr, priv->base +FTGMAC100_OFFSET_MACCR ); }
@@ -1942,7 +1957,7 @@ static int ftgmac100_probe_dt(struct net_device *netdev,static int ftgmac100_probe (struct platform_device *pdev) { -const struct ftgmac100_match_data *match_data; +const struct ftgmac100_match_data *match_data =NULL ;enum ftgmac100_mac_id mac_id;struct resource *res;int irq;
@@ -1987,6 +2002,7 @@ static int ftgmac100_probe(struct platform_device *pdev) priv->netdev = netdev; priv->dev = &pdev->dev; priv->mac_id = mac_id; + priv->quirks = match_data ? match_data->quirks :0 ;INIT_WORK (&priv->reset_task, ftgmac100_reset_task);/* map io memory */
@@ -2134,7 +2150,8 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = { };static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { - .mac_id =FTGMAC100_AST2700 + .mac_id =FTGMAC100_AST2700 , + .quirks =FTGMAC100_QUIRK_RMII_ENABLE , };static const struct ftgmac100_match_data ftgmac100_match_data_faraday = {
drivers/net/ethernet/faraday/ftgmac100.h +1 -0
@@ -167,6 +167,7 @@#define FTGMAC100_MACCR_RX_BROADPKT (1 << 17)#define FTGMAC100_MACCR_DISCARD_CRCERR (1 << 18)#define FTGMAC100_MACCR_FAST_MODE (1 << 19) +#define FTGMAC100_MACCR_RMII_ENABLE BIT(20)#define FTGMAC100_MACCR_SW_RST (1 << 31)/*
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 4/7] net: ftgmac100: Enable AST2700 RMII support
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The commit message says "ftgmac100_probe_dt() always attaches a phy_device before register_netdev() can succeed", and a new comment…
- [Medium] Speculative hardware-sequencing risk.
--
net: ftgmac100: Enable AST2700 RMII support
This adds a FTGMAC100_QUIRK_RMII_ENABLE match-data quirk for AST2700. It also sets the new MACCR RMII enable bit (bit 20) in ftgmac100_start_hw() when the attached PHY interface is RMII. The commit message argues that netdev->phydev is always populated by the time ftgmac100_start_hw() runs.
Quoted 4 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.c static void ftgmac100_init_hw(struct ftgmac100 *priv) · line 367
Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +6
-0@@ -355,6 +359,12 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)static void ftgmac100_start_hw (struct ftgmac100 *priv) {u32 maccr =ioread32 (priv->base +FTGMAC100_OFFSET_MACCR ); +/* +* Only reached once the device is open, so a phy_device is already +* attached: a discrete PHY via "phy-handle", a "fixed-link" node, or +* NC-SI's internal fixed 100M PHY. +*/ +struct phy_device *phydev = priv->netdev->phydev;
[Severity: Medium]
Is this invariant actually guaranteed? The commit message says:
ftgmac100_probe_dt() always attaches a phy_device before register_netdev() can succeed
But ftgmac100_probe_dt() has a path that returns 0 without attaching a PHY:
drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_probe_dt() {
...
if (!ftgmac100_has_child_node(np, "mdio")) {
...
err = ftgmac100_mii_probe(netdev);
...
}
return 0;
}Take a node with an mdio child and none of use-ncsi, fixed-link or phy-handle. It skips both of_phy_get_and_connect() and ftgmac100_mii_probe(), and register_netdev() then succeeds with netdev->phydev == NULL.
The ast2700-mac binding seems to allow this. It only requires one of phy-mode or use-ncsi, phy-handle is optional and an mdio child is allowed. So phy-mode = "rmii" plus an mdio node with no phy-handle passes schema validation.
The rest of the driver also treats a NULL phydev as a valid state. For example, ftgmac100_open() does:
if (netdev->phydev) {
/* If we have a PHY, start polling */
phy_start(netdev->phydev);ftgmac100_stop(), ftgmac100_reset() and ftgmac100_phy_disconnect() check for NULL in the same way.
The commit message cites ftgmac100_reset_and_config_mac() as precedent. That check has the same latent problem, and it runs before every path into ftgmac100_start_hw():
if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {So with such a DT, ftgmac100_open()->ftgmac100_reset_and_config_mac() would oops first, and that NULL dereference predates this patch.
This patch does write the false invariant into both the commit message and the source. It also adds a second unguarded phydev->interface dereference that would need fixing too if the one in ftgmac100_reset_and_config_mac() were made NULL safe. The final patch in this series doesn't seem to change either dereference or ftgmac100_probe_dt().
Would it make sense to guard this with a phydev check, or to cache the DT phy-mode at probe time? Another option would be for ftgmac100_probe_dt() to fail on Aspeed parts when no PHY gets attached.
drivers/net/ethernet/faraday/ftgmac100.c static void ftgmac100_start_hw(struct ftgmac100 *priv) · line 399
Quoted 11 lines
drivers/net/ethernet/faraday/ftgmac100.c +4
-0/* Keep the original GMAC and FAST bits */ maccr &= (FTGMAC100_MACCR_FAST_MODE |FTGMAC100_MACCR_GIGA_MODE );@@ -383,6 +393,11 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv)if (priv->netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) maccr |=FTGMAC100_MACCR_RM_VLAN ; +if ((priv->quirks &FTGMAC100_QUIRK_RMII_ENABLE ) && + phydev->interface ==PHY_INTERFACE_MODE_RMII ) { + maccr |=FTGMAC100_MACCR_RMII_ENABLE ; + }
[Severity: Medium]
Does the AST2700 need the RMII interface select to be in place across the MAC soft reset?
FTGMAC100_MACCR_RMII_ENABLE is set only here, in the same MACCR write that turns on TXDMA/RXDMA/TXMAC/RXMAC. The maccr that ftgmac100_reset_and_config_mac() passes to ftgmac100_reset_mac() holds only the speed bits:
/* The doc says reset twice with 10us interval */ if (ftgmac100_reset_mac(priv, maccr)) return -EIO; usleep_range(10, 1000); return ftgmac100_reset_mac(priv, maccr);
ftgmac100_start_hw() also masks MACCR down to FAST_MODE | GIGA_MODE before rebuilding it.
So on every open, reset_task or link change, an RMII AST2700 port goes through the SCU reset, both SW_RST cycles and ftgmac100_init_hw() in the default non-RMII mode. That includes NC-SI ports, which connect with PHY_INTERFACE_MODE_RMII. The port switches to RMII only when the MAC and DMA are enabled.
On AST2500/AST2600 the RMII selection is in the SCU, so it is already set before the MAC reset.
If the interface select (and its clock source mux) must be stable during SW_RST or before MAC enable, the SW_RST poll in ftgmac100_reset_mac() could time out with "Hardware reset failed". The MAC could also start with inconsistent clock domains. This depends on AST2700 hardware behaviour that can't be confirmed from the code alone.
phydev->interface doesn't change after probe. Could the bit be added to the maccr built in ftgmac100_reset_and_config_mac() and kept by the mask in ftgmac100_start_hw()?
Quoted 4 lines
drivers/net/ethernet/faraday/ftgmac100.c +1
-0+/* Hit the HW */ iowrite32 (maccr, priv->base +FTGMAC100_OFFSET_MACCR ); }
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com
PATCH v7 5/7 net: ftgmac100: Require phy-mode for AST2700
In reply to Jacky ChouThe driver currently defaults to RGMII when the "phy-mode" property is missing from the device tree. This default is no longer valid for AST2700, which also supports RMII via FTGMAC100_QUIRK_RMII_ENABLE.
Make "phy-mode" a required property for AST2700 and fail probe with an error message if it is not specified, instead of silently defaulting to RGMII.
--- drivers/net/ethernet/faraday/ftgmac100.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/faraday/ftgmac100.c +6 -1
@@ -1526,8 +1526,13 @@ static int ftgmac100_mii_probe(struct net_device *netdev)/* Default to RGMII. It's a gigabit part after all */ err =of_get_phy_mode (np, &phy_intf); -if (err) +if (err) { +if (priv->mac_id ==FTGMAC100_AST2700 ) { +dev_err (priv->dev,"phy-mode is required for this SoC\n" ); +return -EINVAL ; + } phy_intf =PHY_INTERFACE_MODE_RGMII ; + }/* Aspeed only supports these. I don't know about other IP * block vendors so I'm going to just let them through for
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 5/7] net: ftgmac100: Require phy-mode for AST2700
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] net: ftgmac100: unreachable AST2700 phy-mode check in ftgmac100_mii_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] net: ftgmac100: unreachable AST2700 phy-mode check in ftgmac100_mii_probe()
--
commit b86b29199842bf4516e7a704118276e8a5eb8767
Author: Jacky Chou <[email protected]>
net: ftgmac100: Require phy-mode for AST2700
This commit requires the device tree "phy-mode" property to be specified on AST2700 in ftgmac100_mii_probe(), returning -EINVAL instead of defaulting to RGMII.
Quoted 6 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0@@ -1526,8 +1526,13 @@ static int ftgmac100_mii_probe(struct net_device *netdev)
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_mii_probe(struct net_device *netdev) · line 1535
Quoted 10 lines
drivers/net/ethernet/faraday/ftgmac100.c +6
-1/* Default to RGMII. It's a gigabit part after all */ err =of_get_phy_mode (np, &phy_intf); -if (err) +if (err) { +if (priv->mac_id ==FTGMAC100_AST2700 ) { +dev_err (priv->dev,"phy-mode is required for this SoC\n" ); +return -EINVAL ; + } phy_intf =PHY_INTERFACE_MODE_RGMII ; + }
[Severity: Medium]
Can this FTGMAC100_AST2700 check ever be reached?
ftgmac100_mii_probe() returns -ENODEV right above this when !priv->mii_bus, and priv->mii_bus is only allocated by ftgmac100_setup_mdio(), which ftgmac100_probe() only calls for FTGMAC100_FARADAY, FTGMAC100_AST2400, and FTGMAC100_AST2500:
drivers/net/ethernet/faraday/ftgmac100.c:ftgmac100_probe() {
...
if (priv->mac_id == FTGMAC100_FARADAY ||
priv->mac_id == FTGMAC100_AST2400 ||
priv->mac_id == FTGMAC100_AST2500) {
err = ftgmac100_setup_mdio(netdev);
if (err)
return err;
}
...
}For FTGMAC100_AST2700, priv->mii_bus is always NULL, so ftgmac100_mii_probe() always exits with "No MDIO bus available" before reaching of_get_phy_mode().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH net-next v7 5/7] net: ftgmac100: Require phy-mode for AST2700
In reply to Jacky ChouThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] The new AST2700 phy-mode check in ftgmac100_mii_probe() (drivers/net/ethernet/faraday/ftgmac100.c, lines 1529-1533) can never…
- [Medium] The commit message says "The driver currently defaults to RGMII when the phy-mode property is missing" and describes the patch…
- [Medium] One AST2700 configuration can still probe without phy-mode: a node with an 'mdio' child but no 'phy-handle', 'fixed-link' or 'use-…
- [Low] The comment above of_get_phy_mode() in ftgmac100_mii_probe() (line 1527) still says "Default to RGMII.
--
net: ftgmac100: Require phy-mode for AST2700
This commit makes phy-mode a required property for AST2700. When of_get_phy_mode() fails in ftgmac100_mii_probe(), probe now returns -EINVAL for that SoC instead of falling back to RGMII.
Quoted 3 lines
The driver currently defaults to RGMII when the "phy-mode" property is missing from the device tree. This default is no longer valid for AST2700, which also supports RMII via
FTGMAC100_QUIRK_RMII_ENABLE.
[Severity: Medium]
Is this description accurate for AST2700? No AST2700 probe path seems to reach the RGMII default.
With use-ncsi, ftgmac100_probe_ncsi() connects with PHY_INTERFACE_MODE_RMII and never reads phy-mode.
With phy-handle or fixed-link, of_phy_get_and_connect() already fails when phy-mode is missing:
ret = of_get_phy_mode(np, &iface); if (ret) return NULL;
With the legacy MDIO scan, ftgmac100_mii_probe() returns -ENODEV on the NULL mii_bus before it reads phy-mode.
The RGMII fallback only applies to FARADAY, AST2400 and AST2500. Could the commit message say that this patch does not change AST2700 behaviour? As written, it suggests a silent RGMII default on AST2700 has been fixed.
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_mii_probe(struct net_device *netdev) · line 1527
Quoted 7 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0@@ -1526,8 +1526,13 @@ static int ftgmac100_mii_probe(struct net_device *netdev)/* Default to RGMII. It's a gigabit part after all */
[Severity: Low]
This isn't a bug, but this comment no longer matches the code. On FTGMAC100_AST2700 a missing phy-mode now returns -EINVAL instead of defaulting to RGMII.
drivers/net/ethernet/faraday/ftgmac100.c static int ftgmac100_mii_probe(struct net_device *netdev) · line 1533
Quoted 7 lines
drivers/net/ethernet/faraday/ftgmac100.c +5
-1err =of_get_phy_mode (np, &phy_intf); -if (err) +if (err) { +if (priv->mac_id ==FTGMAC100_AST2700 ) { +dev_err (priv->dev,"phy-mode is required for this SoC\n" ); +return -EINVAL ; + }
[Severity: High]
Can this check ever run on AST2700? Before it reaches of_get_phy_mode(), ftgmac100_mii_probe() checks priv->mii_bus:
if (!priv->mii_bus) {
dev_err(priv->dev, "No MDIO bus available\n");
return -ENODEV;
}priv->mii_bus is only assigned in ftgmac100_setup_mdio(). ftgmac100_probe() only calls that for the older MACs:
if (priv->mac_id == FTGMAC100_FARADAY ||
priv->mac_id == FTGMAC100_AST2400 ||
priv->mac_id == FTGMAC100_AST2500) {
err = ftgmac100_setup_mdio(netdev);priv comes zeroed from devm_alloc_etherdev(), so priv->mii_bus is always NULL on AST2700. ftgmac100_mii_probe() therefore returns -ENODEV before the new FTGMAC100_AST2700 test.
Here is what ftgmac100_probe_dt() does for an AST2700 node without phy-mode:
use-ncsi: ftgmac100_probe_ncsi() hardcodes RMII, which the binding allows.
phy-handle or fixed-link: of_phy_get_and_connect() already returns NULL, so probe fails with "Failed to connect to phy" with or without this patch.
mdio child, no phy-handle: ftgmac100_mii_probe() is skipped and ftgmac100_probe_dt() returns 0 without checking phy-mode.
no mdio child, no phy-handle: ftgmac100_mii_probe() fails with "No MDIO bus available" before the new check.
This patch changes the result of none of these paths. The check is still unreachable, and unchanged, at the end of the series in "net: ftgmac100:
Allow building on ARM64".
Also, "dt-bindings: net: ftgmac100: Add AST2700 compatible" justifies its oneOf(phy-mode, use-ncsi) rule by pointing to "ftgmac100_mii_probe(), where the AST2700 phy-mode check lives".
Would this check work better in ftgmac100_probe_dt(), after the use-ncsi branch and before the fixed-link/phy-handle/mdio split?
[Severity: Medium]
Related to the above: an AST2700 node with an mdio child node but no phy-handle, fixed-link or use-ncsi still probes without phy-mode.
ftgmac100_probe_dt() {
...
if (!ftgmac100_has_child_node(np, "mdio")) {
...
err = ftgmac100_mii_probe(netdev);
...
}
return 0;
}The device then registers with netdev->phydev == NULL. On open, would ftgmac100_reset_and_config_mac() dereference a NULL phydev here for any is_aspeed device?
if (priv->is_aspeed && priv->netdev->phydev->interface == PHY_INTERFACE_MODE_RMII) {ftgmac100_start_hw() makes a similar read for the RMII quirk added in "net: ftgmac100: Enable AST2700 RMII support". That commit says "ftgmac100_probe_dt() always attaches a phy_device", which does not seem to hold for this path.
The NULL phydev read on open can also be reached on AST2600 with the same DT layout. For AST2700, moving the phy-mode check into ftgmac100_probe_dt() right after the use-ncsi branch would cover this case.
Quoted 2 lines
drivers/net/ethernet/faraday/ftgmac100.c +1
-0phy_intf =PHY_INTERFACE_MODE_RGMII ; + }
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com
PATCH v7 6/7 net: ftgmac100: Add AST2700 upper DMA address support
In reply to Jacky ChouProgram the high RX and TX descriptor ring base registers and carry the upper DMA address bits in RX and TX descriptors. Rebuild full buffer DMA addresses in a 64-bit type before unmapping them so bits 34:32 are not lost to 32-bit arithmetic.
The descriptor format provides three upper buffer address bits, so request a 35-bit DMA mask instead of advertising an address range that the hardware cannot encode. Gate all extended address handling with a match-data quirk so older register layouts remain untouched and later compatible controllers can opt into the same capability.
--- drivers/net/ethernet/faraday/ftgmac100.c | 62 +++++++++++++++++++++++++++----- drivers/net/ethernet/faraday/ftgmac100.h | 6 ++++ 2 files changed, 59 insertions(+), 9 deletions(-)
drivers/net/ethernet/faraday/ftgmac100.c +53 -9
@@ -8,6 +8,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/reset.h> #include <linux/dma-mapping.h>
@@ -42,6 +43,7 @@ enum ftgmac100_mac_id { };#define FTGMAC100_QUIRK_RMII_ENABLE BIT(0) +#define FTGMAC100_QUIRK_DMA_35BIT BIT(1)struct ftgmac100_match_data {enum ftgmac100_mac_id mac_id;
@@ -303,10 +305,16 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)iowrite32 (reg, priv->base +FTGMAC100_OFFSET_ISR );/* Setup RX ring buffer base */ -iowrite32 (priv->rxdes_dma, priv->base +FTGMAC100_OFFSET_RXR_BADR ); +iowrite32 (lower_32_bits (priv->rxdes_dma), priv->base +FTGMAC100_OFFSET_RXR_BADR ); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) +iowrite32 (upper_32_bits (priv->rxdes_dma), + priv->base +FTGMAC100_OFFSET_RXR_BADDR_HIGH );/* Setup TX ring buffer base */ -iowrite32 (priv->txdes_dma, priv->base +FTGMAC100_OFFSET_NPTXR_BADR ); +iowrite32 (lower_32_bits (priv->txdes_dma), priv->base +FTGMAC100_OFFSET_NPTXR_BADR ); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) +iowrite32 (upper_32_bits (priv->txdes_dma), + priv->base +FTGMAC100_OFFSET_TXR_BADDR_HIGH );/* Configure RX buffer size */ iowrite32(FTGMAC100_RBSR_SIZE(RX_BUF_SIZE),
@@ -474,7 +482,10 @@ static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry, priv->rx_skbs[entry] = skb;/* Store DMA address into RX desc */ - rxdes->rxdes3 =cpu_to_le32 (map); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + rxdes->rxdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_RXDES2_RXBUF_BADR_HI , +upper_32_bits (map))); + rxdes->rxdes3 =cpu_to_le32 (lower_32_bits (map));/* Ensure the above is ordered vs clearing the OWN bit */ dma_wmb ();
@@ -601,6 +612,9 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)/* Tear down DMA mapping, do necessary cache management */ map =le32_to_cpu (rxdes->rxdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_RXDES2_RXBUF_BADR_HI , +le32_to_cpu (rxdes->rxdes2)) <<32 ;#if defined(CONFIG_ARM ) && !defined(CONFIG_ARM_DMA_USE_IOMMU )/* When we don't have an iommu, we can save cycles by not
@@ -677,9 +691,14 @@ static void ftgmac100_free_tx_packet(struct ftgmac100 *priv, struct ftgmac100_txdes *txdes, u32 ctl_stat) { -dma_addr_t map =le32_to_cpu (txdes->txdes3); +dma_addr_t map;size_t len; + map =le32_to_cpu (txdes->txdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_TXDES2_TXBUF_BADR_HI , +le32_to_cpu (txdes->txdes2)) <<32 ; +if (ctl_stat &FTGMAC100_TXDES0_FTS ) { len =skb_headlen (skb);dma_unmap_single (priv->dev, map, len,DMA_TO_DEVICE );
@@ -833,7 +852,10 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, f_ctl_stat |=FTGMAC100_TXDES0_FTS ;if (nfrags ==0 ) f_ctl_stat |=FTGMAC100_TXDES0_LTS ; - txdes->txdes3 =cpu_to_le32 (map); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + txdes->txdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_TXDES2_TXBUF_BADR_HI , +upper_32_bits (map))); + txdes->txdes3 =cpu_to_le32 (lower_32_bits (map)); txdes->txdes1 =cpu_to_le32 (csum_vlan);/* Next descriptor */
@@ -861,7 +883,10 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, ctl_stat |=FTGMAC100_TXDES0_LTS ; txdes->txdes0 =cpu_to_le32 (ctl_stat); txdes->txdes1 =0 ; - txdes->txdes3 =cpu_to_le32 (map); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + txdes->txdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_TXDES2_TXBUF_BADR_HI , +upper_32_bits (map))); + txdes->txdes3 =cpu_to_le32 (lower_32_bits (map));/* Next one */ pointer =ftgmac100_next_tx_pointer (priv, pointer);
@@ -936,7 +961,12 @@ static void ftgmac100_free_buffers(struct ftgmac100 *priv)for (i =0 ; i < priv->rx_q_entries; i++) {struct ftgmac100_rxdes *rxdes = &priv->rxdes[i];struct sk_buff *skb = priv->rx_skbs[i]; -dma_addr_t map =le32_to_cpu (rxdes->rxdes3); +dma_addr_t map; + + map =le32_to_cpu (rxdes->rxdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_RXDES2_RXBUF_BADR_HI , +le32_to_cpu (rxdes->rxdes2)) <<32 ;if (!skb)continue ;
@@ -1055,7 +1085,12 @@ static void ftgmac100_init_rings(struct ftgmac100 *priv)for (i =0 ; i < priv->rx_q_entries; i++) { rxdes = &priv->rxdes[i]; rxdes->rxdes0 =0 ; - rxdes->rxdes3 =cpu_to_le32 (priv->rx_scratch_dma); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) { +u32 hi =upper_32_bits (priv->rx_scratch_dma); + + rxdes->rxdes2 =cpu_to_le32 (FIELD_PREP (FTGMAC100_RXDES2_RXBUF_BADR_HI , hi)); + } + rxdes->rxdes3 =cpu_to_le32 (lower_32_bits (priv->rx_scratch_dma)); }/* Mark the end of the ring */ rxdes->rxdes0 |=cpu_to_le32 (priv->rxdes0_edorr_mask);
@@ -2104,6 +2139,14 @@ static int ftgmac100_probe(struct platform_device *pdev) netdev->hw_features &= ~(NETIF_F_HW_CSUM |NETIF_F_RXCSUM ); netdev->features |= netdev->hw_features; +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) { + err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (35 )); +if (err) { +dev_err (&pdev->dev,"35-bit DMA enable failed\n" ); + goto err; + } + } +/* register network device */ err =register_netdev (netdev);if (err) {
@@ -2156,7 +2199,8 @@ static const struct ftgmac100_match_data ftgmac100_match_data_ast2600 = {static const struct ftgmac100_match_data ftgmac100_match_data_ast2700 = { .mac_id =FTGMAC100_AST2700 , - .quirks =FTGMAC100_QUIRK_RMII_ENABLE , + .quirks =FTGMAC100_QUIRK_RMII_ENABLE | +FTGMAC100_QUIRK_DMA_35BIT , };static const struct ftgmac100_match_data ftgmac100_match_data_faraday = {
drivers/net/ethernet/faraday/ftgmac100.h +6 -0
@@ -57,6 +57,9 @@#define FTGMAC100_OFFSET_RX_RUNT 0xc0#define FTGMAC100_OFFSET_RX_CRCER_FTL 0xc4#define FTGMAC100_OFFSET_RX_COL_LOST 0xc8 +/* reserved 0xcc - 0x178 */ +#define FTGMAC100_OFFSET_TXR_BADDR_HIGH 0x17c +#define FTGMAC100_OFFSET_RXR_BADDR_HIGH 0x18c/* * Interrupt status register & interrupt enable register
@@ -226,6 +229,7 @@ struct ftgmac100_txdes {#define FTGMAC100_TXDES1_TX2FIC (1 << 30)#define FTGMAC100_TXDES1_TXIC (1 << 31) +#define FTGMAC100_TXDES2_TXBUF_BADR_HI GENMASK(18, 16)/* * Receive descriptor, aligned to 16 bytes */
@@ -272,4 +276,6 @@ struct ftgmac100_rxdes {#define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)#define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27) +#define FTGMAC100_RXDES2_RXBUF_BADR_HI GENMASK(18, 16) +#endif /* __FTGMAC100_H */
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 6/7] net: ftgmac100: Add AST2700 upper DMA address support
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] When FTGMAC100_QUIRK_DMA_35BIT is set (AST2700), ftgmac100_rx_packet() (drivers/net/ethernet/faraday/ftgmac100.c lines…
- [Low] This patch gives txdes2 and rxdes2 a new role: on AST2700, bits 18:16 (FTGMAC100_TXDES2_TXBUF_BADR_HI /…
--
net: ftgmac100: Add AST2700 upper DMA address support
This commit adds 35-bit DMA address support for AST2700. It programs the high RX/TX ring base registers and stores buffer address bits 34:32 in bits 18:16 of txdes2/rxdes2. It also rebuilds the full address before unmapping and sets a 35-bit DMA mask, all gated by the new FTGMAC100_QUIRK_DMA_35BIT quirk.
Quoted 4 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.c static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed) · line 617
Quoted 7 lines
drivers/net/ethernet/faraday/ftgmac100.c +3
-0@@ -601,6 +612,9 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)/* Tear down DMA mapping, do necessary cache management */ map =le32_to_cpu (rxdes->rxdes3); +if (priv->quirks &FTGMAC100_QUIRK_DMA_35BIT ) + map |= (u64 )FIELD_GET (FTGMAC100_RXDES2_RXBUF_BADR_HI , +le32_to_cpu (rxdes->rxdes2)) <<32 ;
[Severity: Medium]
Is it safe to rebuild the unmap address from rxdes2 after the hardware has completed the descriptor?
Before this patch the driver never wrote rxdes2, and the header describes it as a word the hardware writes:
__le32 rxdes2; /* length/type on AST2500 */
Suppose the AST2700 RX engine writes rxdes2 back on completion and does not preserve bits 18:16. Then map would end up with the wrong bits 34:32. AST2700 DRAM is above 4 GiB, so those bits are non-zero for every buffer. dma_unmap_single() would then sync and unmap the wrong address. ftgmac100_free_buffers() rebuilds the address the same way.
The drop path in ftgmac100_rx_packet() also hands the descriptor back to the hardware by rewriting only rxdes0:
drop:
/* Clean rxdes0 (which resets own bit) */ rxdes->rxdes0 = cpu_to_le32(status & priv->rxdes0_edorr_mask);
If rxdes2[18:16] was changed, would the next DMA into that slot go to the wrong physical address? Frames with RX errors or missing FRS/LRS take this path, and they can come from the network.
Does the AST2700 documentation guarantee that the MAC never writes rxdes2[18:16]? If it doesn't, two changes would avoid relying on that:
- keep a per-slot software copy of the dma_addr_t and use it for unmapping
- rewrite rxdes2 on the drop path
Quoted 3 lines
drivers/net/ethernet/faraday/ftgmac100.c +0
-0#if defined(CONFIG_ARM ) && !defined(CONFIG_ARM_DMA_USE_IOMMU )/* When we don't have an iommu, we can save cycles by not
[ ... ]
Quoted 4 lines
drivers/net/ethernet/faraday/ftgmac100.h +0
-0
[ ... ]
drivers/net/ethernet/faraday/ftgmac100.h struct ftgmac100_rxdes { · line 279
Quoted 13 lines
drivers/net/ethernet/faraday/ftgmac100.h +2
-0@@ -226,6 +229,7 @@ struct ftgmac100_txdes {#define FTGMAC100_TXDES1_TX2FIC (1 << 30)#define FTGMAC100_TXDES1_TXIC (1 << 31) +#define FTGMAC100_TXDES2_TXBUF_BADR_HI GENMASK(18, 16)/* * Receive descriptor, aligned to 16 bytes */ @@ -272,4 +276,6 @@ struct ftgmac100_rxdes {#define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)#define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27) +#define FTGMAC100_RXDES2_RXBUF_BADR_HI GENMASK(18, 16)
[Severity: Low]
This isn't a bug, but the struct comments for these words weren't updated:
struct ftgmac100_txdes {
...
__le32 txdes2; /* Reserved */
...struct ftgmac100_rxdes {
...
__le32 rxdes2; /* length/type on AST2500 */
...With this patch, bits 18:16 of both words hold buffer address bits 34:32 on AST2700. Could these comments be updated to say so?
Quoted 2 lines
drivers/net/ethernet/faraday/ftgmac100.h +1
-0+#endif /* __FTGMAC100_H */
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com
PATCH v7 7/7 net: ftgmac100: Allow building on ARM64
In reply to Jacky ChouAllow the Faraday vendor menu and FTGMAC100 driver to be selected on ARM64 so AST2700 platforms can enable the MAC. The driver now programs the upper DMA address fields, so it no longer needs to be marked BROKEN for 64-bit builds.
AST2700 has no dedicated MACH_ASPEED_G7 symbol; unlike the 32-bit generations it is only gated by the common ARCH_ASPEED symbol. On 32-bit Aspeed platforms, arch/arm/mach-aspeed/Kconfig nests MACH_ASPEED_G4/G5/G6 under "if ARCH_ASPEED", so MACH_ASPEED_G6 already implies ARCH_ASPEED and is redundant once ARCH_ASPEED is part of the condition. Drop it and select MDIO_ASPEED directly on ARCH_ASPEED.
This does widen the MDIO_ASPEED select beyond AST2600: it is now also selected for AST2400/AST2500, which keep driving their embedded MDIO controller from FTGMAC100 itself and have no MDIO node for this driver to bind to, so it is built but stays unused there. Update the MDIO_ASPEED help text to describe this.
--- drivers/net/ethernet/faraday/Kconfig | 7 +++---- drivers/net/mdio/Kconfig | 16 ++++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/ethernet/faraday/Kconfig +3 -4
@@ -6,7 +6,7 @@ config NET_VENDOR_FARADAY bool "Faraday devices" default y - depends on ARM || COMPILE_TEST + depends on ARM || ARM64 || COMPILE_TEST help If you have a network (Ethernet) card belonging to this class, say Y.
@@ -28,11 +28,10 @@ config FTMAC100 config FTGMAC100 tristate "Faraday FTGMAC100 Gigabit Ethernet support" - depends on ARM || COMPILE_TEST - depends on !64BIT || BROKEN + depends on ARM || ARM64 || COMPILE_TEST select PHYLIB select FIXED_PHY - select MDIO_ASPEED if MACH_ASPEED_G6 + select MDIO_ASPEED if ARCH_ASPEED select CRC32 help This driver supports the FTGMAC100 Gigabit Ethernet controller
drivers/net/mdio/Kconfig +10 -6
@@ -50,12 +50,16 @@ config MDIO_ASPEED depends on OF_MDIO && HAS_IOMEM help This module provides a driver for the independent MDIO bus - controllers found in the ASPEED AST2600 SoC. This is a driver for the - third revision of the ASPEED MDIO register interface - the first two - revisions are the "old" and "new" interfaces found in the AST2400 and - AST2500, embedded in the MAC. For legacy reasons, FTGMAC100 driver - continues to drive the embedded MDIO controller for the AST2400 and - AST2500 SoCs, so say N if AST2600 support is not required. + controllers found in the ASPEED AST2600 and AST2700 SoCs. This is a + driver for the third revision of the ASPEED MDIO register interface - + the first two revisions are the "old" and "new" interfaces found in + the AST2400 and AST2500, embedded in the MAC. For legacy reasons, + FTGMAC100 driver continues to drive the embedded MDIO controller for + the AST2400 and AST2500 SoCs. AST2700 has no dedicated MACH_ASPEED_G7 + symbol and is only gated by ARCH_ASPEED, so FTGMAC100 now + unconditionally selects this driver on every ARCH_ASPEED platform, + including the older AST2400/AST2500 SoCs where it has no MDIO node to + bind to. config MDIO_BITBANG tristate "Bitbanged MDIO buses"
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH net-next v7 7/7] net: ftgmac100: Allow building on ARM64
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] This commit removes depends on !64BIT || BROKEN from FTGMAC100.
- [Low] The new MDIO_ASPEED help text in drivers/net/mdio/Kconfig reads like a changelog and is imprecise.
--
net: ftgmac100: Allow building on ARM64
This commit lets the Faraday vendor menu and the FTGMAC100 driver be selected on ARM64 for AST2700, and drops the !64BIT || BROKEN dependency. It also changes the MDIO_ASPEED select condition from MACH_ASPEED_G6 to ARCH_ASPEED and updates the MDIO_ASPEED help text.
Quoted 4 lines
drivers/net/ethernet/faraday/Kconfig +0
-0
[ ... ]
drivers/net/ethernet/faraday/Kconfig config FTMAC100 · line 31
Quoted 7 lines
drivers/net/ethernet/faraday/Kconfig +1
-2@@ -28,11 +28,10 @@ config FTMAC100 config FTGMAC100 tristate "Faraday FTGMAC100 Gigabit Ethernet support" - depends on ARM || COMPILE_TEST - depends on !64BIT || BROKEN + depends on ARM || ARM64 || COMPILE_TEST
[Severity: Medium]
Without the BROKEN gate, RX buffers on AST2700 (FTGMAC100_QUIRK_DMA_35BIT, 35-bit DMA mask) can be mapped above 4 GiB. Has it been confirmed that the MAC never writes RXDES2[18:16] when it completes an RX descriptor?
The driver header says that RXDES2 is written by hardware on an earlier Aspeed MAC:
drivers/net/ethernet/faraday/ftgmac100.h:
struct ftgmac100_rxdes {
...
__le32 rxdes2; /* length/type on AST2500 */
...
};After the MAC hands the descriptor back, ftgmac100_rx_packet() rebuilds the unmap address from RXDES2:
map = le32_to_cpu(rxdes->rxdes3); if (priv->quirks & FTGMAC100_QUIRK_DMA_35BIT) map |= (u64)FIELD_GET(FTGMAC100_RXDES2_RXBUF_BADR_HI, le32_to_cpu(rxdes->rxdes2)) << 32;
ftgmac100_free_buffers() does the same thing at teardown.
Fragmented (FRS/LRS) or errored frames take the drop path in ftgmac100_rx_packet(). That path gives the descriptor back to hardware but only rewrites RXDES0:
drop:
/* Clean rxdes0 (which resets own bit) */ rxdes->rxdes0 = cpu_to_le32(status & priv->rxdes0_edorr_mask);
The upper address bits are only programmed in ftgmac100_alloc_rx_buf() and during ring init.
Suppose the AST2700 MAC writes length/type, or anything else, into RXDES2 bits 18:16 on completion. Could dma_unmap_single() then be called with the wrong address? And after a dropped frame, could the MAC DMA the next frame on that recycled descriptor into the wrong physical memory?
If the hardware can change those bits, would it be safer to keep each entry's full dma_addr_t in software? RXDES2/RXDES3 could then be rewritten every time a descriptor goes back to hardware, including on the drop path.
Quoted 12 lines
drivers/net/ethernet/faraday/Kconfig +1
-1select PHYLIB select FIXED_PHY - select MDIO_ASPEED if MACH_ASPEED_G6 + select MDIO_ASPEED if ARCH_ASPEED select CRC32 help This driver supports the FTGMAC100 Gigabit Ethernet controllerdrivers/net/mdio/Kconfig +0
-0@@ -50,12 +50,16 @@ config MDIO_ASPEED
[ ... ]
drivers/net/mdio/Kconfig config MDIO_ASPEED · line 62
Quoted 6 lines
drivers/net/mdio/Kconfig +6
-0+ FTGMAC100 driver continues to drive the embedded MDIO controller for + the AST2400 and AST2500 SoCs. AST2700 has no dedicated MACH_ASPEED_G7 + symbol and is only gated by ARCH_ASPEED, so FTGMAC100 now + unconditionally selects this driver on every ARCH_ASPEED platform, + including the older AST2400/AST2500 SoCs where it has no MDIO node to + bind to.
[Severity: Low]
This isn't a bug, but is "unconditionally selects this driver on every ARCH_ASPEED platform" accurate? The select in FTGMAC100 is:
select MDIO_ASPEED if ARCH_ASPEED
That only forces MDIO_ASPEED when FTGMAC100 itself is enabled, and only to m when FTGMAC100=m. With ARCH_ASPEED=y and FTGMAC100=n, MDIO_ASPEED can still be N.
The new text also reads like changelog history ("now", "no dedicated MACH_ASPEED_G7 symbol") rather than guidance for the user. It also drops the old "say N if AST2600 support is not required" advice.
Could the help text say when to enable the option instead? That would keep it from going stale if a MACH_ASPEED_G7 symbol is added later.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-support_ast2700-v7-0-33c8ca2d0dd7%40aspeedtech.com