From: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Andrew Lunn <andrew@lunn.ch>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org,
Paolo Abeni <pabeni@redhat.com>, Vinod Koul <vkoul@kernel.org>
Subject: Re: [PATCH net-next 0/8] net: stmmac: improve PCS support
Date: Tue, 24 Mar 2026 01:53:31 +0530 [thread overview]
Message-ID: <acGhQ0oui+dVRdLY@oss.qualcomm.com> (raw)
In-Reply-To: <abwSHGw39FTJGNb7@shell.armlinux.org.uk>
Hi,
On Thu, Mar 19, 2026 at 03:11:24PM +0000, Russell King (Oracle) wrote:
> On Thu, Mar 19, 2026 at 02:50:29PM +0100, Konrad Dybcio wrote:
> > On 3/19/26 1:58 PM, Russell King (Oracle) wrote:
> > > On Thu, Mar 19, 2026 at 11:09:33AM +0100, Konrad Dybcio wrote:
> > >> On 3/19/26 10:24 AM, Russell King (Oracle) wrote:
> > >>> On Thu, Mar 19, 2026 at 12:35:58AM +0000, Russell King (Oracle) wrote:
> > >>>> On Thu, Mar 19, 2026 at 03:42:05AM +0530, Mohd Ayaan Anwar wrote:
> > >>>>> [ 8.650486] qcom-ethqos 23040000.ethernet: clk_csr value out of range (0xffffff00 exceeds mask 0x00000f00), truncating
> > >>>>
> > >>>> Please look into this first - with the MDIO bus operating at
> > >>>> who-knows-what frequency, this could make reading from the PHY
> > >>>> unreliable.
> > >>>
> > >>> My guess is clk_get_rate(priv->plat->stmmac_clk) is returning zero,
> > >>> which means we don't know the rate of the CSR clock.
> > >>>
> > >>> From what I can see in drivers/clk/qcom/gcc-qcs404.c and
> > >>> drivers/clk/qcom/gcc-sdx55.c, this looks like this case - the
> > >>> struct clk_branch makes no mention of any clock rate, nor does it
> > >>> have any parent. From what I can see, neither of these drivers
> > >>> specify any rates for any of their clocks, which likely means that
> > >>> clk_get_rate() will be zero for all of them.
> > >>>
> > >>> Sadly, when I designed the clk API, I didn't think that people would
> > >>> be stupid enough not to implement the API properly, more fool me.
> > >>>
> > >>> Under the old code, we would've used STMMAC_CSR_20_35M, which means
> > >>> we're assuming that the CSR clock is between 20 and 35MHz, even
> > >>> though the value is zero. Is that the case? If it's higher than
> > >>> 35MHz, then you've been operating the MDIO bus out of IEEE 802.3
> > >>> specification, which can make PHY access unrealible.
> > >>>
> > >>> In any case, please fix your clock drivers.
> > >>
> > >> I'm not 100% sure the currently-passed AXI clock is what we want
> > >> there and the docs aren't super helpful.. is there a synopsys-name
> > >> for it? What rates would you expect it to run at?
> > >
> > > There is no easy answer to that - it depends on the bus interfaces
> > > and whether the CSR (register) clock is separate.
> > >
> > > The likely possible names are hclk_i (for AHB master), aclk_i (for
> > > AXI master), or clk_csr_i.
> > >
> > > It does state that the CSR clock should have a minimum frequency of
> > > 25MHz to allow all statistics to be properly collected.
> > >
> > > The rate of the CSR clock needs to be known, as selecting the divider
> > > for generating MDC within IEEE 802.3 specifications is rather
> > > fundamental. You may find something there which hints at what rate
> > > the dwmac's CSR clock runs at.
> >
> > If it's either AXI or AHB, in both cases their direct parent is controlled
> > by an entity external to Linux and their rates may change at runtime,
> > based on aggregated needs of the bus. They're defined as levels/corners
> > (abstract term for a hidden volt+freq combo).
> >
> > It may be that the operating range for the EMAC removes that variability,
> > but with no concrete evidence and just anecdotal experience, that's only
> > the case for the AHB clock
>
> The important thing is that the MDC doesn't exceed the max clock
> frequency for the PHY and any other device connected to the MDIO
> bus. IEEE 802.3 specifies a max frequency of 2.5MHz (minimum period
> for MDC shall be 400 ns). Some PHYs can operate in excess of this,
> but one would need to confirm that all devices on the MDIO bus
> supports higher frequencies before using them. In the kernel, we
> generally err on the side of caution and stick to IEEE 802.3.
>
> There are two ways to achieve the divider value with stmmac.
>
> 1. if priv->plat->csr_clk is set to a value other than -1, this
> configures the hardware divisor (for "normal" cores, it takes
> STMMAC_CSR_* constants that can be found in include/linux/stmmac.h)
>
> 2. otherwise, the rate of priv->plat->stmmac_clk is used as the CSR
> clock value, which is the reference clock for the divider that
> generates the MDC clock, and an appropriate divider is selected.
> Given the available dividers, it works out at between 1.25MHz for
> a CSR clock of just over 20MHz and 2.47MHz for 800MHz. (I have a
> patch which documents the ranges for each of the STMMAC_CSR_xxx
> values.)
>
> Note that the dividier constants are not the actual divider itself,
> as can be seen in include/linux/stmmac.h
>
As noted by Konrad, the AXI and AHB clock rates are indeed unknown to
the Linux kernel:
[ 7.739389] [DBG] priv->plat->stmmac_clk rate = 0
[ 7.739391] [DBG] priv->plat->pclk rate = 0
Additionally, here's what I found (focusing on QCS9100 Ride R3, but
most of this should be applicable to all qcom-ethqos consumers):
1. clk_csr_i is connected to the SLV_AHB clock, named "pclk" in the
devicetree. This is the source for the MDC. The "stmmaceth" clock,
provided by AXI, is used for data transfers. It appears that the
devicetree gets it in reverse as per the stmmac clock
documentation added by Russell, i.e., the right order would be:
diff --git a/arch/arm64/boot/dts/qcom/lemans.dtsi b/arch/arm64/boot/dts/qcom/lemans.dtsi
index 147ebf9b1ac6..f1aa2490bf6b 100644
--- a/arch/arm64/boot/dts/qcom/lemans.dtsi
+++ b/arch/arm64/boot/dts/qcom/lemans.dtsi
@@ -7111,10 +7111,10 @@ ethernet0: ethernet@23040000 {
interrupts = <GIC_SPI 946 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 782 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "macirq", "sfty";
- clocks = <&gcc GCC_EMAC0_AXI_CLK>,
- <&gcc GCC_EMAC0_SLV_AHB_CLK>,
+ clocks = <&gcc GCC_EMAC0_SLV_AHB_CLK>,
+ <&gcc GCC_EMAC0_AXI_CLK>,
<&gcc GCC_EMAC0_PTP_CLK>,
<&gcc GCC_EMAC0_PHY_AUX_CLK>;
clock-names = "stmmaceth",
"pclk",
2. However, even with the correct naming, clk_get_rate() would return
0 for both clocks since they are firmware-managed.
3. For GCC_EMAC0_SLV_AHB_CLK, the hardware documentation mentions the
range of 50 - 100 MHz. I am trying to check if there's any chance
of it turboing to a higher rate. For now, I think we can assume
this to be the working range.
In view of this, would setting priv->plat->clk_csr to
STMMAC_CSR_60_100M from the glue layer be correct?
Ayaan
next prev parent reply other threads:[~2026-03-23 20:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 12:28 [PATCH net-next 0/8] net: stmmac: improve PCS support Russell King (Oracle)
2026-03-13 12:28 ` [PATCH net-next 1/8] net: stmmac: add struct stmmac_pcs_info Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 2/8] net: stmmac: add support for reading inband SGMII status Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 3/8] net: stmmac: add BASE-X support to integrated PCS Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 4/8] net: stmmac: use integrated PCS for BASE-X modes Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 5/8] net: stmmac: qcom-ethqos: enable 2500BASE-X Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 6/8] net: stmmac: qcom-ethqos: enable inband mode for SGMII Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 7/8] net: stmmac: configure SGMII AN control according to phylink Russell King (Oracle)
2026-03-13 12:29 ` [PATCH net-next 8/8] net: stmmac: report PCS configuration changes Russell King (Oracle)
2026-03-13 18:42 ` Russell King (Oracle)
2026-03-15 23:45 ` [PATCH net-next 0/8] net: stmmac: improve PCS support Mohd Ayaan Anwar
2026-03-16 1:11 ` Russell King (Oracle)
2026-03-17 14:48 ` Russell King (Oracle)
2026-03-18 22:12 ` Mohd Ayaan Anwar
2026-03-19 0:35 ` Russell King (Oracle)
2026-03-19 9:24 ` Russell King (Oracle)
2026-03-19 10:09 ` Konrad Dybcio
2026-03-19 12:58 ` Russell King (Oracle)
2026-03-19 13:50 ` Konrad Dybcio
2026-03-19 15:11 ` Russell King (Oracle)
2026-03-23 20:23 ` Mohd Ayaan Anwar [this message]
2026-03-24 9:14 ` Russell King (Oracle)
2026-03-18 21:59 ` Mohd Ayaan Anwar
2026-03-16 13:51 ` Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=acGhQ0oui+dVRdLY@oss.qualcomm.com \
--to=mohd.anwar@oss.qualcomm.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox