From: Koichiro Den <den@valinux.co.jp>
To: Niklas Cassel <cassel@kernel.org>,
Marek Vasut <marek.vasut@mailbox.org>
Cc: "Rob Herring" <robh@kernel.org>,
linux-pci@vger.kernel.org,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
Date: Fri, 4 Dec 2026 11:26:03 +0900 [thread overview]
Message-ID: <axIRrVqGQm2I_23s@z790sl> (raw)
In-Reply-To: <axGea-ozOExpmTNX@ryzen>
On Thu, Dec 03, 2026 at 05:52:59PM +0100, Niklas Cassel wrote:
> Hello Koichiro,
>
> On Wed, Dec 02, 2026 at 11:54:51PM +0900, Koichiro Den wrote:
> > P.S. Just thinking out loud about S4 and Niklas's RFC v2...
> > As you might remember, I've got two Spiders connected at a remote site, one as
> > RC and the other as EP. Going by the schematic (around R377/R378 marked "Do not
> > stuff"), I'd expect each board to use its own REFCLK in the stock configuration.
> > The link still comes up with the S4 driver effectively following the "Common
> > REFCLK" branch in Figure 104.5 of the S4 UM. The same figure shows a single
> > "Separate REFCLK" branch for both SRNS and SRIS. The host can supply REFCLK at
> > the OcuLink connector (pls see c588e1c9846b for the GPIO control). Since a
> > different endpoint may use that clock, I'd imagine we'd leave refclk-mode
> > unspecified in the stock Spider host DTS with the binding as proposed in v2.
>
> Well, it depends.
>
> The normal case, e.g. for a PC, is that the the RC is running in common
> clock mode, with spread. For an add-in card that sources the clock from
> the slot, that is fine as the PC's spread would hit both ends the same
> way and be harmless. (Sometimes you can disable the clock spread in BIOS.)
>
> The problem comes when the endpoint uses its own clock.
> (E.g. RK3588 in EP mode cannot source the clock from the slot.)
>
>
> For RK3588 specifically (with the help of LLM parsing the TRM):
>
> What rxX_cmn_refclk_mode = 1 does on the RK3588 PCIe3 PHY. The TRM says
> that in this mode the elastic buffer runs in its "lowest latency mode",
> and that "SKP symbol manipulation is disabled". The reason given is that
> with a common refclk the local and recovered clocks have the same frequency,
> so nothing needs compensating. The reset value is 1, so the PHY assumes a
> common clock by default.
>
> What goes wrong if the clocks are actually separate. Two independent 100 MHz
> oscillators may differ by up to 600 ppm, ±300 ppm each. Even at 100 ppm, the
> buffer gains or loses a symbol roughly every 10,000 symbols, which at 8 GT/s
> is about every 10 µs. With SKP manipulation disabled, nothing corrects that,
> so the buffer quickly overflows or underflows. The result is corrupted data,
> errors and link recovery, or a link that doesn't work at all.
>
>
> With an ordinary M.2 SSD, the SSD uses the refclk the RC board drives onto
> the slot. That's a common clock, so the default mode is correct, and gives
> the lowest latency.
>
> With the second ROCK 5B as the endpoint, that board uses its own oscillator,
> but the RC board can't see this. Its PHY stays in common mode with SKP
> manipulation off, while the two oscillators drift apart, and the link breaks.
>
> rk3588-rock-5b-pcie-srns.dtso sets rockchip,rx-common-refclk-mode = <0 0 0 0>,
> which turns SKP manipulation back on. The RC receiver can then absorb the
> offset using the SKPs the endpoint sends.
>
>
>
> I don't know if the PHY on the S4 also disables SKP manipulation when running
> in common clock mode. If it does not, then it is fully possible that you can
> run the RC in the default (common clock) mode, and only modify the EP to run
> in SRNS or SRIS mode. (Because the normal SKP Ordered Set rate already covers
> +/- 300 ppm per side.)
Hi Niklas,
>
> Do you see any correctable errors on that Link?
No. With my AER patches [1] on the RC, I've checked that an injected LCRC error
shows up as a correctable error in dmesg. I haven't seen any under normal load
on the two Spiders. So the link looks _okayish_ with the default clock settings
here, but ...
>
>
>
> If you have a S4 RC connected to S4 EP, then selecting SRIS or SRNS even on the
> RC side is clearly more correct (assuming that S4 EP cannot run in common clock
> mode), even if it happens to work when you configure your S4 RC in common clock.
> Because, it really is a property of the link.
... I do agree that in such a setup it's more correct to describe the link as
SRNS or SRIS at both ends.
IMO there's no great rush on the S4 side. Once the binding is in, we can put
together a follow-up and try it out on real hardware to check for regressions.
>
> E.g. to run in SRNS mode, clock spread must be disabled on both sides
> (otherwise the link will not be stable).
> If either side spreads, then the link is SRIS, and e.g. for RK3588 you need to
> enable SRIS using a specific register write (regardless of RC / EP mode).
>
> This is the proper link DT configuration when using two ROCK 5Bs (or two S4):
>
> ┌────────────┬──────────┬──────┬───────────────────────────────────────┬─────────────────────────────────────┐
> │ Host clock │ EP clock │ Link │ Host DT │ EP DT │
> ├────────────┼──────────┼──────┼───────────────────────────────────────┼─────────────────────────────────────┤
> │ no SSC │ no SSC │ SRNS │ refclk-mode = "srns" │ refclk-mode = "srns" │
> ├────────────┼──────────┼──────┼───────────────────────────────────────┼─────────────────────────────────────┤
> │ SSC │ no SSC │ SRIS │ "sris" , plus the host's SSC setting │ "sris" │
> ├────────────┼──────────┼──────┼───────────────────────────────────────┼─────────────────────────────────────┤
> │ no SSC │ SSC │ SRIS │ "sris" │ "sris" , plus the EP's SSC setting │
> ├────────────┼──────────┼──────┼───────────────────────────────────────┼─────────────────────────────────────┤
> │ SSC │ SSC │ SRIS │ "sris" , plus the host's SSC setting │ "sris" , plus the EP's SSC setting │
> └────────────┴──────────┴──────┴───────────────────────────────────────┴─────────────────────────────────────┘
>
For S4, Figure 104.5 in S4 UM puts SRNS and SRIS in the same "Separate REFCLK"
branch. So I'd expect the S4 driver to use the same controller settings for
"srns" and "sris" at that step. That's where it seems to me to differ from
RK3588.
(Marek, I'm sure you know much better than I do. If I've missed a knob in the
controller or its PHY for selecting between SRIS and SRNS, please let me know.)
[1] https://lore.kernel.org/r/20261127031145.2521228-1-den@valinux.co.jp/
Best regards,
Koichiro Den
>
> "SSC setting" means DT property 'assigned-clock-sscs' on whichever clock
> does the spreading.
>
> With a common refclk (e.g. the endpoint uses the refclk the host supplies
> on the slot), it doesn't matter whether that clock spreads.
>
> Not sure if I should somehow add the above table in the RFC,
> or try to document it more clearly in the DT binding.
> It is already mentioned with words, but sometimes an table is easier
> to understand.
>
>
> Kind regards,
> Niklas
next prev parent reply other threads:[~2026-12-04 2:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 15:40 [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init() Marek Vasut
2026-11-30 8:34 ` Koichiro Den
2026-12-02 3:10 ` Marek Vasut
2026-12-02 14:54 ` Koichiro Den
2026-12-02 20:12 ` Marek Vasut
2026-12-03 4:57 ` Koichiro Den
2026-12-03 16:52 ` Niklas Cassel
2026-12-04 2:26 ` Koichiro Den [this message]
2026-11-30 20:22 ` Niklas Cassel
2026-12-02 20:15 ` Marek Vasut
2026-12-03 15:06 ` Niklas Cassel
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=axIRrVqGQm2I_23s@z790sl \
--to=den@valinux.co.jp \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=geert+renesas@glider.be \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mani@kernel.org \
--cc=marek.vasut@mailbox.org \
--cc=robh@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.