All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
@ 2026-11-29 15:40 Marek Vasut
  2026-11-30  8:34 ` Koichiro Den
  2026-11-30 20:22 ` Niklas Cassel
  0 siblings, 2 replies; 11+ messages in thread
From: Marek Vasut @ 2026-11-29 15:40 UTC (permalink / raw)
  To: linux-pci
  Cc: Marek Vasut, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Koichiro Den, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
	linux-renesas-soc

Except for R-Car S4 variant of this controller, all other variants of
this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
.link_up callback. Simplify this, introduce .sris_mode flag in driver
data and set it for all but R-Car S4 controller, and then set PCIEMSR0
APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
already. Removes one read-modify-write round. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Koichiro Den <den@valinux.co.jp>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: linux-pci@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/pci/controller/dwc/pcie-rcar-gen4.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
index 2e640110e3910..6fd745099103c 100644
--- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
+++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
@@ -100,6 +100,7 @@ struct rcar_gen4_pcie_drvdata {
 	int (*speed_control)(struct rcar_gen4_pcie *rcar);
 	enum dw_pcie_device_mode mode;
 	bool mrrs_256b_limit;
+	bool sris_mode;
 };
 
 struct rcar_gen4_pcie {
@@ -265,6 +266,9 @@ static int rcar_gen4_pcie_common_init(struct rcar_gen4_pcie *rcar)
 	if (dw->num_lanes < 4)
 		val |= BIFUR_MOD_SET_ON;
 
+	if (rcar->drvdata->sris_mode)
+		val |= APP_SRIS_MODE;
+
 	writel(val, rcar->base + PCIEMSR0);
 
 	ret = reset_control_deassert(dw->core_rsts[DW_PCIE_PWR_RST].rstc);
@@ -1070,10 +1074,6 @@ static int rcar_gen4_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable
 	val |= PORT_FORCE_LINK_DDFS;
 	dw_pcie_writel_dbi(dw, PORT_FORCE_LINK, val);
 
-	val = readl(rcar->base + PCIEMSR0);
-	val |= APP_SRIS_MODE;
-	writel(val, rcar->base + PCIEMSR0);
-
 	/*
 	 * The R-Car Gen4 datasheet doesn't describe the PHY registers' name.
 	 * But, the initialization procedure describes these offsets. So,
@@ -1157,6 +1157,7 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie = {
 	.speed_control = rcar_gen4_pcie_speed_control,
 	.mode = DW_PCIE_RC_TYPE,
 	.mrrs_256b_limit = true,
+	.sris_mode = true,
 };
 
 static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie_ep = {
@@ -1166,6 +1167,7 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie_ep = {
 	.speed_control = rcar_gen4_pcie_speed_control,
 	.mode = DW_PCIE_EP_TYPE,
 	.mrrs_256b_limit = true,
+	.sris_mode = true,
 };
 
 static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen5_pcie = {
@@ -1174,6 +1176,7 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen5_pcie = {
 	.ltssm_control = rcar_gen5_pcie_ltssm_control,
 	.speed_control = rcar_gen5_pcie_speed_control,
 	.mode = DW_PCIE_RC_TYPE,
+	.sris_mode = true,
 };
 
 static const struct of_device_id rcar_gen4_pcie_of_match[] = {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  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-11-30 20:22 ` Niklas Cassel
  1 sibling, 1 reply; 11+ messages in thread
From: Koichiro Den @ 2026-11-30  8:34 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
	linux-renesas-soc

Hi Marek, thanks for informing me via cc.

On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
> Except for R-Car S4 variant of this controller, all other variants of
> this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
> .link_up callback. Simplify this, introduce .sris_mode flag in driver
  ^^^^^^^^
nit: is this a typo for .ltssm_control?

> data and set it for all but R-Car S4 controller, and then set PCIEMSR0
> APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
> already. Removes one read-modify-write round. No functional change.

For R-Car Gen5 PCIe4, is this really no functional change? If not, would it be
better to split the Gen5 change into a separate patch?

> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Koichiro Den <den@valinux.co.jp>
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Manivannan Sadhasivam <mani@kernel.org>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Cc: linux-pci@vger.kernel.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---

I'm not sure if everyone involved except me already knows, but is this patch
meant to go on top of the three patches below? (no functional dependency but.)
- https://lore.kernel.org/r/20261028172133.20903-1-marek.vasut+renesas@mailbox.org/
- https://lore.kernel.org/r/20261028172133.20903-2-marek.vasut+renesas@mailbox.org/
- https://lore.kernel.org/r/20261028172208.20948-1-marek.vasut+renesas@mailbox.org/

Best regards,
Koichiro Den

>  drivers/pci/controller/dwc/pcie-rcar-gen4.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> index 2e640110e3910..6fd745099103c 100644
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> @@ -100,6 +100,7 @@ struct rcar_gen4_pcie_drvdata {
>  	int (*speed_control)(struct rcar_gen4_pcie *rcar);
>  	enum dw_pcie_device_mode mode;
>  	bool mrrs_256b_limit;
> +	bool sris_mode;
>  };
>  
>  struct rcar_gen4_pcie {
> @@ -265,6 +266,9 @@ static int rcar_gen4_pcie_common_init(struct rcar_gen4_pcie *rcar)
>  	if (dw->num_lanes < 4)
>  		val |= BIFUR_MOD_SET_ON;
>  
> +	if (rcar->drvdata->sris_mode)
> +		val |= APP_SRIS_MODE;
> +
>  	writel(val, rcar->base + PCIEMSR0);
>  
>  	ret = reset_control_deassert(dw->core_rsts[DW_PCIE_PWR_RST].rstc);
> @@ -1070,10 +1074,6 @@ static int rcar_gen4_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable
>  	val |= PORT_FORCE_LINK_DDFS;
>  	dw_pcie_writel_dbi(dw, PORT_FORCE_LINK, val);
>  
> -	val = readl(rcar->base + PCIEMSR0);
> -	val |= APP_SRIS_MODE;
> -	writel(val, rcar->base + PCIEMSR0);
> -
>  	/*
>  	 * The R-Car Gen4 datasheet doesn't describe the PHY registers' name.
>  	 * But, the initialization procedure describes these offsets. So,
> @@ -1157,6 +1157,7 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie = {
>  	.speed_control = rcar_gen4_pcie_speed_control,
>  	.mode = DW_PCIE_RC_TYPE,
>  	.mrrs_256b_limit = true,
> +	.sris_mode = true,
>  };
>  
>  static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie_ep = {
> @@ -1166,6 +1167,7 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen4_pcie_ep = {
>  	.speed_control = rcar_gen4_pcie_speed_control,
>  	.mode = DW_PCIE_EP_TYPE,
>  	.mrrs_256b_limit = true,
> +	.sris_mode = true,
>  };
>  
>  static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen5_pcie = {
> @@ -1174,6 +1176,7 @@ static struct rcar_gen4_pcie_drvdata drvdata_rcar_gen5_pcie = {
>  	.ltssm_control = rcar_gen5_pcie_ltssm_control,
>  	.speed_control = rcar_gen5_pcie_speed_control,
>  	.mode = DW_PCIE_RC_TYPE,
> +	.sris_mode = true,
>  };
>  
>  static const struct of_device_id rcar_gen4_pcie_of_match[] = {
> -- 
> 2.53.0
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  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-11-30 20:22 ` Niklas Cassel
  2026-12-02 20:15   ` Marek Vasut
  1 sibling, 1 reply; 11+ messages in thread
From: Niklas Cassel @ 2026-11-30 20:22 UTC (permalink / raw)
  To: Marek Vasut, Rob Herring, Vincent Guittot, Krzysztof Kozlowski,
	Conor Dooley, devicetree
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Koichiro Den, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Yoshihiro Shimoda, linux-renesas-soc

Hello Marek,

On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
> Except for R-Car S4 variant of this controller, all other variants of
> this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
> .link_up callback. Simplify this, introduce .sris_mode flag in driver
> data and set it for all but R-Car S4 controller, and then set PCIEMSR0
> APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
> already. Removes one read-modify-write round. No functional change.

Which clocking modes a controller supports is a property of the SoC,
but which mode (Common Clock, SRNS or SRIS) should actually be used is
a property of the board, i.e. it depends on how the board provides the
reference clock (from the slot, or from an on-board clock generator,
and in the latter case, with or without SSC).

So I don't think that per-compatible driver data is the right place to
decide this.

This is even more apparent in endpoint mode, where whether the refclk
is sourced from the PCIe slot or from an on-board clock generator is
entirely up to the board design.

We have discussed this a few times before, see:
https://lore.kernel.org/linux-pci/aCQ9ge1eROhh9RVE@ryzen/
https://lore.kernel.org/linux-pci/aMp0hNnBUwTV5cbp@ryzen/

In the first thread, Rob agreed that this information is needed in DT
(although he suggested to describe the clock source using the clock
binding, with SSC described separately):
https://lore.kernel.org/linux-pci/20250519145636.GA2090206-robh@kernel.org/

In the second thread, the S32G driver dropped its vendor specific
"nxp,phy-mode" property "until we agreed on a generic binding", and
simply uses CRNS for now:
https://lore.kernel.org/linux-pci/20251121164920.2008569-1-vincent.guittot@linaro.org/

So rather than adding more per-SoC hardcoding, I would much prefer if
we could finally agree on a generic DT property for this. At least
Tegra, Qcom, Rockchip and S32G would benefit from such a property as
well.


Kind regards,
Niklas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-11-30  8:34 ` Koichiro Den
@ 2026-12-02  3:10   ` Marek Vasut
  2026-12-02 14:54     ` Koichiro Den
  0 siblings, 1 reply; 11+ messages in thread
From: Marek Vasut @ 2026-12-02  3:10 UTC (permalink / raw)
  To: Koichiro Den
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
	linux-renesas-soc

On 11/30/26 9:34 AM, Koichiro Den wrote:
> Hi Marek, thanks for informing me via cc.

Hello Den-san, gladly, thank you for your good feedback.

> On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
>> Except for R-Car S4 variant of this controller, all other variants of
>> this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
>> .link_up callback. Simplify this, introduce .sris_mode flag in driver
>    ^^^^^^^^
> nit: is this a typo for .ltssm_control?

This should have been .start_link , which yes, invokes ->ltssm_control .

>> data and set it for all but R-Car S4 controller, and then set PCIEMSR0
>> APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
>> already. Removes one read-modify-write round. No functional change.
> 
> For R-Car Gen5 PCIe4, is this really no functional change? If not, would it be
> better to split the Gen5 change into a separate patch?
Looking at the input from Niklas, I think this entire patch will be 
superseded by something even better.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-12-02  3:10   ` Marek Vasut
@ 2026-12-02 14:54     ` Koichiro Den
  2026-12-02 20:12       ` Marek Vasut
  2026-12-03 16:52       ` Niklas Cassel
  0 siblings, 2 replies; 11+ messages in thread
From: Koichiro Den @ 2026-12-02 14:54 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
	linux-renesas-soc

On Wed, Dec 02, 2026 at 04:10:57AM +0100, Marek Vasut wrote:
> On 11/30/26 9:34 AM, Koichiro Den wrote:
> > Hi Marek, thanks for informing me via cc.
> 
> Hello Den-san, gladly, thank you for your good feedback.
> 
> > On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
> > > Except for R-Car S4 variant of this controller, all other variants of
> > > this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
> > > .link_up callback. Simplify this, introduce .sris_mode flag in driver
> >    ^^^^^^^^
> > nit: is this a typo for .ltssm_control?
> 
> This should have been .start_link , which yes, invokes ->ltssm_control .
> 
> > > data and set it for all but R-Car S4 controller, and then set PCIEMSR0
> > > APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
> > > already. Removes one read-modify-write round. No functional change.
> > 
> > For R-Car Gen5 PCIe4, is this really no functional change? If not, would it be
> > better to split the Gen5 change into a separate patch?
> Looking at the input from Niklas, I think this entire patch will be
> superseded by something even better.

Since I believe this was meant as a clean-up, I agree we can wait for the
generic binding to settle. Thanks!

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.

Best regards,
Koichiro Den

> 
> -- 
> Best regards,
> Marek Vasut

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  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
  1 sibling, 1 reply; 11+ messages in thread
From: Marek Vasut @ 2026-12-02 20:12 UTC (permalink / raw)
  To: Koichiro Den
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
	linux-renesas-soc

On 12/2/26 3:54 PM, Koichiro Den wrote:
> On Wed, Dec 02, 2026 at 04:10:57AM +0100, Marek Vasut wrote:
>> On 11/30/26 9:34 AM, Koichiro Den wrote:
>>> Hi Marek, thanks for informing me via cc.
>>
>> Hello Den-san, gladly, thank you for your good feedback.
>>
>>> On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
>>>> Except for R-Car S4 variant of this controller, all other variants of
>>>> this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
>>>> .link_up callback. Simplify this, introduce .sris_mode flag in driver
>>>     ^^^^^^^^
>>> nit: is this a typo for .ltssm_control?
>>
>> This should have been .start_link , which yes, invokes ->ltssm_control .
>>
>>>> data and set it for all but R-Car S4 controller, and then set PCIEMSR0
>>>> APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
>>>> already. Removes one read-modify-write round. No functional change.
>>>
>>> For R-Car Gen5 PCIe4, is this really no functional change? If not, would it be
>>> better to split the Gen5 change into a separate patch?
>> Looking at the input from Niklas, I think this entire patch will be
>> superseded by something even better.
> 
> Since I believe this was meant as a clean-up, I agree we can wait for the
> generic binding to settle. Thanks!

Likewise, thank you for keeping an eye on these patches!

> 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.

I was always wondering whether you modified those S4 Spiders somehow, or 
whether you simply connected them with an Oculink cable. I have multiple 
M.2-to-Oculink adapters here now, but I never got around to figuring out 
what to do about the clock lane, especially on the EP end.

> 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.

For Spider, I agree. Also, I think we might need to model the oculink 
connector in DT, with its clock (control) property to enable/disable the 
PCIe clock on the connector ?

[...]

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-11-30 20:22 ` Niklas Cassel
@ 2026-12-02 20:15   ` Marek Vasut
  2026-12-03 15:06     ` Niklas Cassel
  0 siblings, 1 reply; 11+ messages in thread
From: Marek Vasut @ 2026-12-02 20:15 UTC (permalink / raw)
  To: Niklas Cassel, Rob Herring, Vincent Guittot, Krzysztof Kozlowski,
	Conor Dooley, devicetree
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Koichiro Den, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Yoshihiro Shimoda, linux-renesas-soc

On 11/30/26 9:22 PM, Niklas Cassel wrote:

Hello Niklas,

> On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
>> Except for R-Car S4 variant of this controller, all other variants of
>> this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
>> .link_up callback. Simplify this, introduce .sris_mode flag in driver
>> data and set it for all but R-Car S4 controller, and then set PCIEMSR0
>> APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
>> already. Removes one read-modify-write round. No functional change.
> 
> Which clocking modes a controller supports is a property of the SoC,
> but which mode (Common Clock, SRNS or SRIS) should actually be used is
> a property of the board, i.e. it depends on how the board provides the
> reference clock (from the slot, or from an on-board clock generator,
> and in the latter case, with or without SSC).
> 
> So I don't think that per-compatible driver data is the right place to
> decide this.

I agree with this.

> This is even more apparent in endpoint mode, where whether the refclk
> is sourced from the PCIe slot or from an on-board clock generator is
> entirely up to the board design.
> 
> We have discussed this a few times before, see:
> https://lore.kernel.org/linux-pci/aCQ9ge1eROhh9RVE@ryzen/
> https://lore.kernel.org/linux-pci/aMp0hNnBUwTV5cbp@ryzen/
> 
> In the first thread, Rob agreed that this information is needed in DT
> (although he suggested to describe the clock source using the clock
> binding, with SSC described separately):
> https://lore.kernel.org/linux-pci/20250519145636.GA2090206-robh@kernel.org/
> 
> In the second thread, the S32G driver dropped its vendor specific
> "nxp,phy-mode" property "until we agreed on a generic binding", and
> simply uses CRNS for now:
> https://lore.kernel.org/linux-pci/20251121164920.2008569-1-vincent.guittot@linaro.org/
> 
> So rather than adding more per-SoC hardcoding, I would much prefer if
> we could finally agree on a generic DT property for this. At least
> Tegra, Qcom, Rockchip and S32G would benefit from such a property as
> well.

I agree with this as well. I think "[RFC PATCH v2 0/3] PCI: Describe the 
reference clock architecture of a Link" is the proposal ?

(I need to catch up on all the threads yet)

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-12-02 20:12       ` Marek Vasut
@ 2026-12-03  4:57         ` Koichiro Den
  0 siblings, 0 replies; 11+ messages in thread
From: Koichiro Den @ 2026-12-03  4:57 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Rob Herring, Yoshihiro Shimoda,
	linux-renesas-soc

On Wed, Dec 02, 2026 at 09:12:41PM +0100, Marek Vasut wrote:
> On 12/2/26 3:54 PM, Koichiro Den wrote:
> > On Wed, Dec 02, 2026 at 04:10:57AM +0100, Marek Vasut wrote:
> > > On 11/30/26 9:34 AM, Koichiro Den wrote:
> > > > Hi Marek, thanks for informing me via cc.
> > > 
> > > Hello Den-san, gladly, thank you for your good feedback.
> > > 
> > > > On Sun, Nov 29, 2026 at 04:40:52PM +0100, Marek Vasut wrote:
> > > > > Except for R-Car S4 variant of this controller, all other variants of
> > > > > this PCIe controller set PCIEMSR0 APP_SRIS_MODE bit as part of their
> > > > > .link_up callback. Simplify this, introduce .sris_mode flag in driver
> > > >     ^^^^^^^^
> > > > nit: is this a typo for .ltssm_control?
> > > 
> > > This should have been .start_link , which yes, invokes ->ltssm_control .
> > > 
> > > > > data and set it for all but R-Car S4 controller, and then set PCIEMSR0
> > > > > APP_SRIS_MODE bit based on this flag in rcar_gen4_pcie_common_init()
> > > > > already. Removes one read-modify-write round. No functional change.
> > > > 
> > > > For R-Car Gen5 PCIe4, is this really no functional change? If not, would it be
> > > > better to split the Gen5 change into a separate patch?
> > > Looking at the input from Niklas, I think this entire patch will be
> > > superseded by something even better.
> > 
> > Since I believe this was meant as a clean-up, I agree we can wait for the
> > generic binding to settle. Thanks!
> 
> Likewise, thank you for keeping an eye on these patches!
> 
> > 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.
> 
> I was always wondering whether you modified those S4 Spiders somehow, or
> whether you simply connected them with an Oculink cable.

Just the cable in my case. The two Spiders connected directly with a LINKUP
OCuLink cable. I was told this cable had already been tested with two Spiders.
(I suspect it's an Internal crossover cable, but I haven't checked the
plug-to-plug wiring myself.)

The boards weren't supplied as EP-only boards, and I'm not aware of any rework
around CN16 (including R377/R378). Per the schematic, OUT4 of U36 (the clock
generator) feeds the local PCIe0 PHY and OUT5 goes to CN16 on both boards.
So I'd expect the endpoint Spider to use its own REFCLK even when the host
supplies one at CN16. The link comes up fine in this setup.

> I have multiple
> M.2-to-Oculink adapters here now, but I never got around to figuring out
> what to do about the clock lane, especially on the EP end.

I was thinking of separate clocks for a two-board setup, but were you thinking
of having the endpoint take REFCLK from the host through the adapter? I've had a
quick glance at the White/Sparrow Hawk schematics, and the Sparrow Hawk one
appears to spell out which 0-ohm links to change for what.
I'm sure I'm not telling you anything new here. Also, I don't have either Hawk
to try it.

> 
> > 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.
> 
> For Spider, I agree. Also, I think we might need to model the oculink
> connector in DT, with its clock (control) property to enable/disable the
> PCIe clock on the connector ?

I'm not sure what that would look like on Spider. Do you have a particular use
case in mind for controlling the clock at CN16? E.g. leaving it off at boot in a
fixed setup where we know the peer EP uses its own REFCLK? I'd appreciate it if
you could elaborate a bit, maybe with a rough DTS snippet.

Thanks for taking your time to discuss with me.

Best regards,
Koichiro Den

> 
> [...]
> 
> -- 
> Best regards,
> Marek Vasut

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-12-02 20:15   ` Marek Vasut
@ 2026-12-03 15:06     ` Niklas Cassel
  0 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2026-12-03 15:06 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Rob Herring, Vincent Guittot, Krzysztof Kozlowski, Conor Dooley,
	devicetree, linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Koichiro Den, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Yoshihiro Shimoda, linux-renesas-soc

On Wed, Dec 02, 2026 at 09:15:34PM +0100, Marek Vasut wrote:
> On 11/30/26 9:22 PM, Niklas Cassel wrote:

(snip)

> > So rather than adding more per-SoC hardcoding, I would much prefer if
> > we could finally agree on a generic DT property for this. At least
> > Tegra, Qcom, Rockchip and S32G would benefit from such a property as
> > well.
> 
> I agree with this as well. I think "[RFC PATCH v2 0/3] PCI: Describe the
> reference clock architecture of a Link" is the proposal ?

Yes.

I can send a RFC v3 or a non-RFC version, but I would like some feedback
from DT maintainers first.


Kind regards,
Niklas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-12-02 14:54     ` Koichiro Den
  2026-12-02 20:12       ` Marek Vasut
@ 2026-12-03 16:52       ` Niklas Cassel
  2026-12-04  2:26         ` Koichiro Den
  1 sibling, 1 reply; 11+ messages in thread
From: Niklas Cassel @ 2026-12-03 16:52 UTC (permalink / raw)
  To: Koichiro Den, Rob Herring
  Cc: Marek Vasut, linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Yoshihiro Shimoda, linux-renesas-soc

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.)

Do you see any correctable errors on that Link?



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.

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 │
 └────────────┴──────────┴──────┴───────────────────────────────────────┴─────────────────────────────────────┘


"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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] PCI: rcar-gen4: Set SRIS mode in rcar_gen4_pcie_common_init()
  2026-12-03 16:52       ` Niklas Cassel
@ 2026-12-04  2:26         ` Koichiro Den
  0 siblings, 0 replies; 11+ messages in thread
From: Koichiro Den @ 2026-12-04  2:26 UTC (permalink / raw)
  To: Niklas Cassel, Marek Vasut
  Cc: Rob Herring, linux-pci, Krzysztof Wilczyński, Bjorn Helgaas,
	Geert Uytterhoeven, Lorenzo Pieralisi, Magnus Damm,
	Manivannan Sadhasivam, Yoshihiro Shimoda, linux-renesas-soc

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-12-04  2:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-11-30 20:22 ` Niklas Cassel
2026-12-02 20:15   ` Marek Vasut
2026-12-03 15:06     ` Niklas Cassel

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.