* [PATCH 0/2] PCI: ultrarisc: Add DP1000 PCIe clock support
@ 2026-06-29 5:59 Jia Wang via B4 Relay
2026-06-29 5:59 ` [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks Jia Wang via B4 Relay
2026-06-29 5:59 ` [PATCH 2/2] PCI: ultrarisc: get and enable " Jia Wang via B4 Relay
0 siblings, 2 replies; 6+ messages in thread
From: Jia Wang via B4 Relay @ 2026-06-29 5:59 UTC (permalink / raw)
To: Xincheng Zhang, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-pci, devicetree, linux-kernel, Jia Wang
Add clock handling for the UltraRISC DP1000 DesignWare PCIe host
controller.
The DP1000 PCIe controller depends on three input clocks: core, dbi, and
aux. The driver accesses DBI registers during host initialization, so the
clocks must be enabled before the controller registers are touched.
This series documents the required clocks in the device tree binding and
updates the driver to get and enable them during probe. The driver keeps
the clock data alongside struct dw_pcie, uses the bulk clock API to
acquire and enable the clocks, and registers a managed cleanup action to
disable them on failure or detach.
Testing:
- Build and module build tested with ARCH=riscv.
- Boot tested on UltraRISC DP1000.
- Validated the PCIe binding with dt_binding_check and dtbs_check.
Signed-off-by: Jia Wang <wangjia@ultrarisc.com>
---
Jia Wang (2):
dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks
PCI: ultrarisc: get and enable DP1000 PCIe clocks
.../bindings/pci/ultrarisc,dp1000-pcie.yaml | 16 +++++
drivers/pci/controller/dwc/pcie-ultrarisc.c | 74 ++++++++++++++++++++--
2 files changed, 83 insertions(+), 7 deletions(-)
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260617-ultrarisc-pci-clk-ac19047af1ea
Best regards,
--
Jia Wang <wangjia@ultrarisc.com>
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks 2026-06-29 5:59 [PATCH 0/2] PCI: ultrarisc: Add DP1000 PCIe clock support Jia Wang via B4 Relay @ 2026-06-29 5:59 ` Jia Wang via B4 Relay 2026-06-29 8:07 ` sashiko-bot 2026-06-29 15:27 ` Conor Dooley 2026-06-29 5:59 ` [PATCH 2/2] PCI: ultrarisc: get and enable " Jia Wang via B4 Relay 1 sibling, 2 replies; 6+ messages in thread From: Jia Wang via B4 Relay @ 2026-06-29 5:59 UTC (permalink / raw) To: Xincheng Zhang, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Krzysztof Kozlowski, Conor Dooley Cc: linux-pci, devicetree, linux-kernel, Jia Wang From: Jia Wang <wangjia@ultrarisc.com> Require the DP1000 PCIe controller nodes to provide clocks and clock-names, using the standard DesignWare clock names "core", "dbi", and "aux". Signed-off-by: Jia Wang <wangjia@ultrarisc.com> --- .../devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml b/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml index 512b935bf5d1..d9d1488e915a 100644 --- a/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml @@ -43,6 +43,18 @@ properties: - description: Legacy INTC interrupt - description: Legacy INTD interrupt + clocks: + items: + - description: PCIe core clock + - description: Data Bus Interface (DBI) clock + - description: Auxiliary clock + + clock-names: + items: + - const: core + - const: dbi + - const: aux + interrupt-names: items: - const: msi @@ -55,6 +67,8 @@ required: - compatible - reg - reg-names + - clocks + - clock-names - interrupts - interrupt-names @@ -71,6 +85,8 @@ examples: reg = <0x0 0x21000000 0x0 0x01000000>, <0x0 0x4fff0000 0x0 0x00010000>; reg-names = "dbi", "config"; + clocks = <&clkc 9>, <&clkc 7>, <&clkc 10>; + clock-names = "core", "dbi", "aux"; ranges = <0x81000000 0x0 0x4fbf0000 0x0 0x4fbf0000 0x0 0x00400000>, <0x82000000 0x0 0x40000000 0x0 0x40000000 0x0 0x0fbf0000>, <0xc3000000 0x40 0x00000000 0x40 0x00000000 0xd 0x00000000>; -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks 2026-06-29 5:59 ` [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks Jia Wang via B4 Relay @ 2026-06-29 8:07 ` sashiko-bot 2026-06-29 15:27 ` Conor Dooley 1 sibling, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-06-29 8:07 UTC (permalink / raw) To: Jia Wang via B4 Relay; +Cc: conor+dt, robh, linux-pci, devicetree > From: Jia Wang <wangjia@ultrarisc.com> > > Require the DP1000 PCIe controller nodes to provide clocks and > clock-names, using the standard DesignWare clock names "core", > "dbi", and "aux". > > Signed-off-by: Jia Wang <wangjia@ultrarisc.com> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/20260629-ultrarisc-pci-clk-v1-0-5ea3308fdab3@ultrarisc.com?part=1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks 2026-06-29 5:59 ` [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks Jia Wang via B4 Relay 2026-06-29 8:07 ` sashiko-bot @ 2026-06-29 15:27 ` Conor Dooley 1 sibling, 0 replies; 6+ messages in thread From: Conor Dooley @ 2026-06-29 15:27 UTC (permalink / raw) To: wangjia Cc: Xincheng Zhang, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Krzysztof Kozlowski, Conor Dooley, linux-pci, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2184 bytes --] On Mon, Jun 29, 2026 at 01:59:50PM +0800, Jia Wang via B4 Relay wrote: > From: Jia Wang <wangjia@ultrarisc.com> > > Require the DP1000 PCIe controller nodes to provide clocks and > clock-names, using the standard DesignWare clock names "core", > "dbi", and "aux". > > Signed-off-by: Jia Wang <wangjia@ultrarisc.com> Probably should have a fixes tag here because the clocks are mandatory and were missing. With one, Acked-by: Conor Dooley <conor.dooley@microchip.com> pw-bot: not-applicable Thanks, Conor. > --- > .../devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml b/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml > index 512b935bf5d1..d9d1488e915a 100644 > --- a/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml > +++ b/Documentation/devicetree/bindings/pci/ultrarisc,dp1000-pcie.yaml > @@ -43,6 +43,18 @@ properties: > - description: Legacy INTC interrupt > - description: Legacy INTD interrupt > > + clocks: > + items: > + - description: PCIe core clock > + - description: Data Bus Interface (DBI) clock > + - description: Auxiliary clock > + > + clock-names: > + items: > + - const: core > + - const: dbi > + - const: aux > + > interrupt-names: > items: > - const: msi > @@ -55,6 +67,8 @@ required: > - compatible > - reg > - reg-names > + - clocks > + - clock-names > - interrupts > - interrupt-names > > @@ -71,6 +85,8 @@ examples: > reg = <0x0 0x21000000 0x0 0x01000000>, > <0x0 0x4fff0000 0x0 0x00010000>; > reg-names = "dbi", "config"; > + clocks = <&clkc 9>, <&clkc 7>, <&clkc 10>; > + clock-names = "core", "dbi", "aux"; > ranges = <0x81000000 0x0 0x4fbf0000 0x0 0x4fbf0000 0x0 0x00400000>, > <0x82000000 0x0 0x40000000 0x0 0x40000000 0x0 0x0fbf0000>, > <0xc3000000 0x40 0x00000000 0x40 0x00000000 0xd 0x00000000>; > > -- > 2.34.1 > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] PCI: ultrarisc: get and enable DP1000 PCIe clocks 2026-06-29 5:59 [PATCH 0/2] PCI: ultrarisc: Add DP1000 PCIe clock support Jia Wang via B4 Relay 2026-06-29 5:59 ` [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks Jia Wang via B4 Relay @ 2026-06-29 5:59 ` Jia Wang via B4 Relay 2026-06-29 6:09 ` sashiko-bot 1 sibling, 1 reply; 6+ messages in thread From: Jia Wang via B4 Relay @ 2026-06-29 5:59 UTC (permalink / raw) To: Xincheng Zhang, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Krzysztof Kozlowski, Conor Dooley Cc: linux-pci, devicetree, linux-kernel, Jia Wang From: Jia Wang <wangjia@ultrarisc.com> Add the required core, dbi, and aux clocks for the DP1000 PCIe controller and enable them before initializing the DesignWare host. Also manage the clocks across system suspend and resume. Signed-off-by: Jia Wang <wangjia@ultrarisc.com> --- drivers/pci/controller/dwc/pcie-ultrarisc.c | 74 ++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-ultrarisc.c b/drivers/pci/controller/dwc/pcie-ultrarisc.c index 6ee661ceff67..74010a86244e 100644 --- a/drivers/pci/controller/dwc/pcie-ultrarisc.c +++ b/drivers/pci/controller/dwc/pcie-ultrarisc.c @@ -5,6 +5,7 @@ * Copyright (C) 2026 UltraRISC Technology (Shanghai) Co., Ltd. */ +#include <linux/clk.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of_device.h> @@ -23,6 +24,11 @@ #define ULTRARISC_PCIE_COMP_TIMEOUT_65_210MS 0x6 +struct ultrarisc_pcie { + struct dw_pcie pci; + struct clk_bulk_data clks[3]; +}; + static struct pci_ops ultrarisc_pci_ops = { .map_bus = dw_pcie_own_conf_map_bus, .read = pci_generic_config_read32, @@ -98,17 +104,46 @@ static const struct dw_pcie_ops dw_pcie_ops = { .start_link = ultrarisc_pcie_start_link, }; +static void ultrarisc_pcie_disable_clks(void *data) +{ + struct ultrarisc_pcie *ultra = data; + + clk_bulk_disable_unprepare(ARRAY_SIZE(ultra->clks), ultra->clks); +} + +static int ultrarisc_pcie_init_clks(struct ultrarisc_pcie *ultra) +{ + struct device *dev = ultra->pci.dev; + int ret; + + ultra->clks[0].id = "core"; + ultra->clks[1].id = "dbi"; + ultra->clks[2].id = "aux"; + + ret = devm_clk_bulk_get(dev, ARRAY_SIZE(ultra->clks), ultra->clks); + if (ret) + return dev_err_probe(dev, ret, "Failed to get clocks\n"); + + ret = clk_bulk_prepare_enable(ARRAY_SIZE(ultra->clks), ultra->clks); + if (ret) + return dev_err_probe(dev, ret, "Failed to enable clocks\n"); + + return devm_add_action_or_reset(dev, ultrarisc_pcie_disable_clks, ultra); +} + static int ultrarisc_pcie_probe(struct platform_device *pdev) { + struct ultrarisc_pcie *ultra; struct device *dev = &pdev->dev; struct dw_pcie_rp *pp; struct dw_pcie *pci; int ret; - pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); - if (!pci) + ultra = devm_kzalloc(dev, sizeof(*ultra), GFP_KERNEL); + if (!ultra) return -ENOMEM; + pci = &ultra->pci; pci->dev = dev; pci->ops = &dw_pcie_ops; @@ -117,7 +152,11 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev) pp = &pci->pp; - platform_set_drvdata(pdev, pci); + platform_set_drvdata(pdev, ultra); + + ret = ultrarisc_pcie_init_clks(ultra); + if (ret) + return ret; pp->num_vectors = MAX_MSI_IRQS; /* No L2/L3 Ready indication is available on this platform */ @@ -135,16 +174,37 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev) static int ultrarisc_pcie_suspend_noirq(struct device *dev) { - struct dw_pcie *pci = dev_get_drvdata(dev); + struct ultrarisc_pcie *ultra = dev_get_drvdata(dev); + struct dw_pcie *pci = &ultra->pci; + int ret; + + ret = dw_pcie_suspend_noirq(pci); + if (ret) + return ret; - return dw_pcie_suspend_noirq(pci); + if (pci->suspended) + clk_bulk_disable_unprepare(ARRAY_SIZE(ultra->clks), ultra->clks); + + return 0; } static int ultrarisc_pcie_resume_noirq(struct device *dev) { - struct dw_pcie *pci = dev_get_drvdata(dev); + struct ultrarisc_pcie *ultra = dev_get_drvdata(dev); + struct dw_pcie *pci = &ultra->pci; + int ret; + + if (pci->suspended) { + ret = clk_bulk_prepare_enable(ARRAY_SIZE(ultra->clks), ultra->clks); + if (ret) + return ret; + } + + ret = dw_pcie_resume_noirq(pci); + if (ret && pci->suspended) + clk_bulk_disable_unprepare(ARRAY_SIZE(ultra->clks), ultra->clks); - return dw_pcie_resume_noirq(pci); + return ret; } static const struct dev_pm_ops ultrarisc_pcie_pm_ops = { -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] PCI: ultrarisc: get and enable DP1000 PCIe clocks 2026-06-29 5:59 ` [PATCH 2/2] PCI: ultrarisc: get and enable " Jia Wang via B4 Relay @ 2026-06-29 6:09 ` sashiko-bot 0 siblings, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-06-29 6:09 UTC (permalink / raw) To: Jia Wang via B4 Relay; +Cc: conor+dt, linux-pci, devicetree, robh Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] If dw_pcie_resume_noirq() fails, the driver disables the clocks, which will cause a bus fault and kernel crash on the next system suspend when the DWC core attempts to read the DBI registers. -- commit 7bdde7bd97edc4ae25c337b51b52e18bb46e6424 Author: Jia Wang <wangjia@ultrarisc.com> PCI: ultrarisc: get and enable DP1000 PCIe clocks This commit adds the required core, dbi, and aux clocks for the DP1000 PCIe controller and enables them before initializing the DesignWare host. It also manages the clocks across system suspend and resume. > diff --git a/drivers/pci/controller/dwc/pcie-ultrarisc.c b/drivers/pci/controller/dwc/pcie-ultrarisc.c > index 6ee661ceff67a..74010a86244e7 100644 > --- a/drivers/pci/controller/dwc/pcie-ultrarisc.c > +++ b/drivers/pci/controller/dwc/pcie-ultrarisc.c [ ... ] > @@ -135,16 +174,37 @@ static int ultrarisc_pcie_probe(struct platform_device *pdev) [ ... ] > static int ultrarisc_pcie_suspend_noirq(struct device *dev) > { > - struct dw_pcie *pci = dev_get_drvdata(dev); > + struct ultrarisc_pcie *ultra = dev_get_drvdata(dev); > + struct dw_pcie *pci = &ultra->pci; > + int ret; > + > + ret = dw_pcie_suspend_noirq(pci); > + if (ret) > + return ret; > > - return dw_pcie_suspend_noirq(pci); > + if (pci->suspended) > + clk_bulk_disable_unprepare(ARRAY_SIZE(ultra->clks), ultra->clks); > + > + return 0; > } > > static int ultrarisc_pcie_resume_noirq(struct device *dev) > { > - struct dw_pcie *pci = dev_get_drvdata(dev); > + struct ultrarisc_pcie *ultra = dev_get_drvdata(dev); > + struct dw_pcie *pci = &ultra->pci; > + int ret; > + > + if (pci->suspended) { > + ret = clk_bulk_prepare_enable(ARRAY_SIZE(ultra->clks), ultra->clks); > + if (ret) > + return ret; > + } > + > + ret = dw_pcie_resume_noirq(pci); > + if (ret && pci->suspended) > + clk_bulk_disable_unprepare(ARRAY_SIZE(ultra->clks), ultra->clks); [Severity: High] Will this cause a kernel crash on the next system suspend if dw_pcie_resume_noirq() fails? If dw_pcie_resume_noirq() fails (for example, due to a link training timeout), it returns an error but leaves pci->suspended as true. This error path then disables the clocks. However, the PM core continues and marks the device as resumed. On the next system suspend, ultrarisc_pcie_suspend_noirq() will unconditionally call dw_pcie_suspend_noirq(). Since dw_pcie_suspend_noirq() accesses DBI registers by calling dw_pcie_link_up(), and the clocks were left disabled, does this read trigger a synchronous external abort and crash the kernel? -- Sashiko AI review · https://sashiko.dev/#/patchset/20260629-ultrarisc-pci-clk-v1-0-5ea3308fdab3@ultrarisc.com?part=2 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-29 15:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-29 5:59 [PATCH 0/2] PCI: ultrarisc: Add DP1000 PCIe clock support Jia Wang via B4 Relay 2026-06-29 5:59 ` [PATCH 1/2] dt-bindings: pci: ultrarisc: add required DP1000 PCIe clocks Jia Wang via B4 Relay 2026-06-29 8:07 ` sashiko-bot 2026-06-29 15:27 ` Conor Dooley 2026-06-29 5:59 ` [PATCH 2/2] PCI: ultrarisc: get and enable " Jia Wang via B4 Relay 2026-06-29 6:09 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox