Historically, the RGMII PHY modes specified in Device Trees have been
used inconsistently, often referring to the usage of delays on the PHY
side rather than describing the board; many drivers still implement this
incorrectly.
Require a comment in Devices Trees using these modes (usually mentioning
that the delay is realized on the PCB), so we can avoid adding more
incorrect uses (or will at least notice which drivers still need to be
fixed).
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
Documentation/dev-tools/checkpatch.rst | 9 +++++++++
scripts/checkpatch.pl | 12 ++++++++++++
2 files changed, 21 insertions(+)
diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
index 76bd0ddb00416..d5c47e560324f 100644
--- a/Documentation/dev-tools/checkpatch.rst
+++ b/Documentation/dev-tools/checkpatch.rst
@@ -495,6 +495,15 @@ Comments
See: https://lore.kernel.org/lkml/20131006222342.GT19510@leaf/
+ **UNCOMMENTED_RGMII_MODE**
+ Historically, the RGMII PHY modes specified in Device Trees have been
+ used inconsistently, often referring to the usage of delays on the PHY
+ side rather than describing the board.
+
+ PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" modes require the clock
+ signal to be delayed on the PCB; this unusual configuration should be
+ described in a comment. If they are not (meaning that the delay is realized
+ internally in the MAC or PHY), "rgmii-id" is the correct PHY mode.
Commit message
--------------
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 664f7b7a622c2..f597734d83cc0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3741,6 +3741,18 @@ sub process {
}
}
+# Check for RGMII phy-mode with delay on PCB
+ if ($realfile =~ /\.(dts|dtsi|dtso)$/ &&
+ $line =~ /^\+\s*(phy-mode|phy-connection-type)\s*=\s*"/ &&
+ !ctx_has_comment($first_line, $linenr)) {
+ my $prop = $1;
+ my $mode = get_quoted_string($line, $rawline);
+ if ($mode =~ /^"rgmii(?:|-rxid|-txid)"$/) {
+ WARN("UNCOMMENTED_RGMII_MODE",
+ "$prop $mode without comment -- delays on the PCB should be described, otherwise use \"rgmii-id\"\n" . $herecurr);
+ }
+ }
+
# check for using SPDX license tag at beginning of files
if ($realline == $checklicenseline) {
if ($rawline =~ /^[ \+]\s*\#\!\s*\//) {
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/
On Tue, Jun 24, 2025 at 12:53:34PM +0200, Matthias Schiffer wrote: > Historically, the RGMII PHY modes specified in Device Trees have been > used inconsistently, often referring to the usage of delays on the PHY > side rather than describing the board; many drivers still implement this > incorrectly. > > Require a comment in Devices Trees using these modes (usually mentioning > that the delay is realized on the PCB), so we can avoid adding more > incorrect uses (or will at least notice which drivers still need to be > fixed). > > Suggested-by: Andrew Lunn <andrew@lunn.ch> > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> One question, how should this be merged? The two DT patches might want to go via the TI DT Maintainer. And this patch via the checkpatch Maintainer? Or do you plan to merge it some other way? Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
On Thu, 2025-06-26 at 10:02 +0200, Andrew Lunn wrote: > > On Tue, Jun 24, 2025 at 12:53:34PM +0200, Matthias Schiffer wrote: > > Historically, the RGMII PHY modes specified in Device Trees have been > > used inconsistently, often referring to the usage of delays on the PHY > > side rather than describing the board; many drivers still implement this > > incorrectly. > > > > Require a comment in Devices Trees using these modes (usually mentioning > > that the delay is realized on the PCB), so we can avoid adding more > > incorrect uses (or will at least notice which drivers still need to be > > fixed). > > > > Suggested-by: Andrew Lunn <andrew@lunn.ch> > > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> > > One question, how should this be merged? The two DT patches might want > to go via the TI DT Maintainer. And this patch via the checkpatch > Maintainer? Or do you plan to merge it some other way? The first two patches should go via net-next I think (the first is DT bindings only, the second one modifies the AM65-CPSW driver), although I would prefer to get a review/ack from a TI maintainer, too. I don't know what tree checkpatch usually goes through, MAINTAINERS doesn't list a specific repo. The whole series could be merged via net-next if that's fine with the checkpatch maintainers. Best, Matthias > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > Andrew -- TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider https://www.tq-group.com/
On Thu, 2025-06-26 at 10:11 +0200, Matthias Schiffer wrote: > I don't know what tree checkpatch usually goes through, MAINTAINERS doesn't list > a specific repo. The whole series could be merged via net-next if that's fine > with the checkpatch maintainers. Merging via net-next is fine with me. Andrew Morton is the typical upstream path for random checkpatch changes.
© 2016 - 2025 Red Hat, Inc.