From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796081938; b=o2PSwdesyviLdmA1F9I51wcgnqTgB92inZhU2v7g5SuUescWA83i9p2/bM00/qzMhHcl U3iHbO5/+TGJim5zb8NAEZ4dMT4+sS9gOgBLLW3AW8ivHwDzKCbcTLEBIlRZF5Em5le3k s4f+a5jXKd9VU2mPFYhRS1OdMuQFizSvTPdCcfucpA8HjhKxT1yTT05AmMAtHIur6IEtO MyoFLWKgWn5cJuZBzK1dpMaEdGSjIEk9HxTaX9lPMJ/wRHtHLWZUvTFGSPOa2uNQiwmCm TbrTYibE2Yzbja1AF4mL9cxDNzpuvwRD2UWMJEkYzQ87NWbR+YwPofnDTqq8J4GG3Mw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796081938; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=MWvRLxKUGvfud/2QHzQ+1Cb2sVlYmqOsUvli6Z+BMTM=; b=Ix8y99e3t+aCLXEw4S2OShK/fSaysaOIi9B4HZictscaIyk7934mSdPrtzC9PHESoO5/ L4f8dvLLiJ/pqJl4GjVjVTi+6U1n+cQ1bLOsCEZ+dFIKT9GfwBOp2PII3YU3W2MYUbbiI u3WqaKhD/3Nk8RWMcOp/VN9XHMBigKdtCFxxbZmttkG/ahGuAF5l2ims+Pm+K/kJQ9hNV UqBDGGfe/ah3QDZ/nxk6NCVUW7W037WezDGXjo7tD0kQyQKmRxl1wWp68b6G/Yf5BmrFY qSnoquWCJXEVVMtPywFKaJzUg+XYRdBIyPHTyhHLhQGSpEuZbSdx3NsYrydsTDTKq3g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y1pG79V1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4DA0606A31A; Mon, 30 Nov 2026 23:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y1pG79V1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0D101F00896; Mon, 30 Nov 2026 23:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796081938; bh=MWvRLxKUGvfud/2QHzQ+1Cb2sVlYmqOsUvli6Z+BMTM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Y1pG79V1aAdxjvZ+3V7BbTtWrvqptHaIpyus8fedV/XMlwvM2VQ2wU0nMIryNSMoh mSt1Zay/u/YopUw6ei1+gtOkDqHhEdOjfOru47n6ESjRGukzufd+KyWqZ4Bq2ji/pg aDywbE+0BnI6P66CzE5snSdEMaKpVJNCKIfdkBeVrOX/RMHexAUApMXUgup2D6HXZs oh7YTwlZEJXzexEou9ukm+JFx2tuFl8YS1rcrKEiFQCYvmnkApzrb/jn7ZIbV+XOr6 rIjpKN8Eumdw2j1tbBCDv4Bc9GmcG42UVK9PSkhPH4R+2Qk+iPp2cssKpaUTGOn0/X hMrTZJwMmN2hg== Date: Tue, 1 Dec 2026 00:38:53 +0100 From: Niklas Cassel To: Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, Bjorn Helgaas , Manivannan Sadhasivam , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Damien Le Moal , Vincent Guittot , Marek Vasut , Koichiro Den Subject: Re: [RFC PATCH v2 0/3] PCI: Describe the reference clock architecture of a Link Message-ID: References: <20261130225254.204664-5-cassel@kernel.org> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Y+AC4f7zv7ffiUyQ" Content-Disposition: inline In-Reply-To: <20261130225254.204664-5-cassel@kernel.org> --Y+AC4f7zv7ffiUyQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 30, 2026 at 11:52:55PM +0100, Niklas Cassel wrote: > i.e. Common Refclk, Separate Refclk with No SSC, and Separate Refclk > with Independent SSC. It can replace vendor specific properties like > "nvidia,enable-ext-refclk", "nvidia,enable-srns" and > "rockchip,rx-common-refclk-mode", and drivers keep their default when it > is absent. It also helps discoverability: an endpoint which does not use > the REFCLK of the slot can report Slot Clock Configuration = 0, so that > the host does not enable Common Clock Configuration. Since Krzysztof asked for a user of this property on the RFC v1: https://lore.kernel.org/linux-pci/51fa853a-61d6-4c8f-8636-80cce90d0a94@kernel.org/ Attaching a patch (compile tested only) that clears the Slot Clock Configuration bit in the Link Status register for the DWC driver (if the Link uses separate REFCLKs - i.e. SRNS or SRIS). This is what the Tegra194 driver already does for its vendor specific "nvidia,enable-srns" property, but this really ought to be done in common DWC code and not in the glue drivers themselves (using the new generic property). I should probably have included this as a 4/4 in this series, but as mentioned in the cover-letter, a generic binding is also needed for R-Car Gen4 and S32G, but I guess they would send follow-up series. Kind regards, Niklas --Y+AC4f7zv7ffiUyQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-PCI-dwc-Clear-Slot-Clock-Configuration-for-separate-.patch >From 4c610c4ede52abf25f8f5c3d17314b9a552c0b03 Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Tue, 1 Dec 2026 00:08:30 +0100 Subject: [PATCH] PCI: dwc: Clear Slot Clock Configuration for separate reference clocks The Slot Clock Configuration bit in the Link Status register indicates that a component uses the same physical reference clock (REFCLK) that the platform provides on the connector. The bit is HwInit, and in the DWC controller its value after reset is a synthesis parameter, so it can be wrong for a given board, e.g. for an endpoint which uses a REFCLK of its own instead of the REFCLK of the slot. If both ends of a Link report Slot Clock Configuration, the PCI core enables Common Clock Configuration (see pcie_aspm_configure_common_clock()), even if the REFCLKs are separate. Parse the generic refclk-mode property, from the controller node or from the Root Port node, and clear Slot Clock Configuration if the Link uses separate REFCLKs (SRNS or SRIS). For a multi-function endpoint, clear it for all functions, since all functions have to report the same value. Keep the value after reset if the property is absent or set to "common". The read-modify-write masks the RW1C status bits of the Link Status register, so that they are not cleared by accident. This is what the Tegra194 driver already does for its vendor specific "nvidia,enable-srns" property. Signed-off-by: Niklas Cassel --- .../pci/controller/dwc/pcie-designware-ep.c | 11 +++++ drivers/pci/controller/dwc/pcie-designware.c | 48 +++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 14 ++++++ 3 files changed, 73 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index e6060bb0bbbd..5dfa9ba26392 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -1251,6 +1251,7 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci) u8 funcs = ep->epc->max_functions; u32 func0_lnkcap, lnkcap; u8 func_no, offset; + u16 lnksta; dw_pcie_dbi_ro_wr_en(pci); @@ -1281,6 +1282,16 @@ static void dw_pcie_ep_init_non_sticky_registers(struct dw_pcie *pci) &lnkcap, func0_lnkcap); dw_pcie_ep_writel_dbi(ep, func_no, offset + PCI_EXP_LNKCAP, lnkcap); + + if (!dw_pcie_refclk_is_separate(pci)) + continue; + + lnksta = dw_pcie_ep_readw_dbi(ep, func_no, + offset + PCI_EXP_LNKSTA); + lnksta &= ~(PCI_EXP_LNKSTA_SLC | PCI_EXP_LNKSTA_LBMS | + PCI_EXP_LNKSTA_LABS); + dw_pcie_ep_writew_dbi(ep, func_no, + offset + PCI_EXP_LNKSTA, lnksta); } } diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 12f102f48d5d..985b248cb6c0 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -111,6 +112,38 @@ static int dw_pcie_get_resets(struct dw_pcie *pci) return 0; } +static enum dw_pcie_refclk_mode dw_pcie_of_get_refclk_mode(struct device *dev, + struct device_node *np) +{ + static const char * const modes[] = { "common", "srns", "sris" }; + const char *mode; + int ret; + + if (of_property_read_string(np, "refclk-mode", &mode)) + return DW_PCIE_REFCLK_MODE_UNSPECIFIED; + + ret = match_string(modes, ARRAY_SIZE(modes), mode); + if (ret < 0) { + dev_warn(dev, "Invalid refclk-mode \"%s\"\n", mode); + return DW_PCIE_REFCLK_MODE_UNSPECIFIED; + } + + return DW_PCIE_REFCLK_MODE_COMMON + ret; +} + +static void dw_pcie_get_refclk_mode(struct dw_pcie *pci) +{ + struct device_node *np = dev_of_node(pci->dev); + struct device_node *rp; + + pci->refclk_mode = dw_pcie_of_get_refclk_mode(pci->dev, np); + + rp = of_pci_find_child_device(np, 0); + if (rp && of_property_present(rp, "refclk-mode")) + pci->refclk_mode = dw_pcie_of_get_refclk_mode(pci->dev, rp); + of_node_put(rp); +} + int dw_pcie_get_resources(struct dw_pcie *pci) { struct platform_device *pdev = to_platform_device(pci->dev); @@ -198,6 +231,8 @@ int dw_pcie_get_resources(struct dw_pcie *pci) of_property_read_u32(np, "num-lanes", &pci->num_lanes); + dw_pcie_get_refclk_mode(pci); + if (of_property_read_bool(np, "snps,enable-cdm-check")) dw_pcie_cap_set(pci, CDM_CHECK); @@ -1268,6 +1303,16 @@ void dw_pcie_program_t_power_on(struct dw_pcie *pci, u32 t_power_on) dw_pcie_dbi_ro_wr_dis(pci); } +static void dw_pcie_clear_slot_clk_config(struct dw_pcie *pci) +{ + u8 offset = dw_pcie_get_pcie_cap(pci); + u16 val; + + val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA); + val &= ~(PCI_EXP_LNKSTA_SLC | PCI_EXP_LNKSTA_LBMS | PCI_EXP_LNKSTA_LABS); + dw_pcie_writew_dbi(pci, offset + PCI_EXP_LNKSTA, val); +} + void dw_pcie_setup(struct dw_pcie *pci) { u32 val; @@ -1304,6 +1349,9 @@ void dw_pcie_setup(struct dw_pcie *pci) dw_pcie_writel_dbi(pci, PORT_LINK_CTRL, val); dw_pcie_link_set_max_link_width(pci, pci->num_lanes); + + if (dw_pcie_refclk_is_separate(pci)) + dw_pcie_clear_slot_clk_config(pci); } resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci, diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 6d788aa00011..202c68dcf8db 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -340,6 +340,13 @@ enum dw_pcie_device_mode { DW_PCIE_RC_TYPE, }; +enum dw_pcie_refclk_mode { + DW_PCIE_REFCLK_MODE_UNSPECIFIED, + DW_PCIE_REFCLK_MODE_COMMON, + DW_PCIE_REFCLK_MODE_SRNS, + DW_PCIE_REFCLK_MODE_SRIS, +}; + enum dw_pcie_app_clk { DW_PCIE_DBI_CLK, DW_PCIE_MSTR_CLK, @@ -566,6 +573,7 @@ struct dw_pcie { unsigned long caps; int num_lanes; int max_link_speed; + enum dw_pcie_refclk_mode refclk_mode; u8 n_fts[2]; struct dw_edma_chip edma; phys_addr_t edma_reg_phys; @@ -660,6 +668,12 @@ static inline u16 dw_pcie_readw_dbi(struct dw_pcie *pci, u32 reg) return dw_pcie_read_dbi(pci, reg, 0x2); } +static inline bool dw_pcie_refclk_is_separate(struct dw_pcie *pci) +{ + return pci->refclk_mode == DW_PCIE_REFCLK_MODE_SRNS || + pci->refclk_mode == DW_PCIE_REFCLK_MODE_SRIS; +} + static inline void dw_pcie_writeb_dbi(struct dw_pcie *pci, u32 reg, u8 val) { dw_pcie_write_dbi(pci, reg, 0x1, val); -- 2.56.1 --Y+AC4f7zv7ffiUyQ--