PCI: qcom: Align PHY init sequence with HPG
Subsystems (6)
cover PCI: qcom: Align PHY init sequence with HPG
HPG requires the controller/PHY GDSCs to be powered up and all clocks enabled, then the controller's reset and the PHY's reset toggled together as one group, with PARF_DEVICE_TYPE set right after. This series adds the callbacks needed on both sides to realize that sequence: a phy_reset() call the controller makes as part of its own reset, and matching phy_ops::init/phy_ops::reset on the PHY side.
Patches 1-2 move phy_init()/phy_exit() into the RC and EP controllers' own init/deinit paths, add a phy_reset() call grouped with each controller's own reset, and move the PARF_DEVICE_TYPE write to right after that reset group.
Patches 3-4 update the two PHY drivers these controllers can use (phy-qcom-qmp-pcie[-multiphy].c) to implement phy_ops::init/reset, matching phy_ops::power_on to what's left once phy_ops::init/phy_ops::reset are pulled out.
phy_init()/phy_reset() are no-ops against a phy_ops without phy_ops::init/phy_ops::reset, so patches 1-2 don't change behavior on any platform by themselves; patches 3-4 are what actually change the sequence for the platforms using those two PHY drivers. Other PHY drivers this series doesn't touch (phy-qcom-qmp-pcie-msm8996.c, phy-qcom-uniphy-pcie-28lp.c, phy-qcom-pcie2.c) are either unaffected (no phy_ops::init/phy_ops::reset) or only see their phy_init()/phy_exit() call site moved without a sequence change.
---
Qiang Yu (4):
PCI: qcom: Move PHY init and add PHY reset call to align with HPG
PCI: qcom-ep: Move PHY init and drive PHY reset to align with HPG
phy: qcom-qmp-pcie-multiphy: Split phy_ops into init/exit/reset/power_on
phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
drivers/pci/controller/dwc/pcie-qcom-ep.c | 26 +-- drivers/pci/controller/dwc/pcie-qcom.c | 165 ++++++++++++++----- drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c | 94 ++++------- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 184 ++++++++++------------ 4 files changed, 257 insertions(+), 212 deletions(-)
---
base-commit: e6e35979777d646fe3c7c94dca7dd32fb25d45f4
change-id: 20260915-align_pcie_init_sequence_0916-571190abea56
Best regards,
Signature · 1 line
Qiang Yu <[email protected]>
PATCH 1/4 PCI: qcom: Move PHY init and add PHY reset call to align with HPG
HPG requires the controller/PHY GDSCs powered up and all controller/PHY clocks enabled first, then the controller's reset and the PHY's reset toggled together as a group, PARF_DEVICE_TYPE set right after, and the rest of the PARF/DBI config left until the PHY is ready.
Make use of phy_init() and phy_reset(), and change the call flow to:
qcom_pcie_host_init():
phy_init() (PHY GDSCs/regulators/clocks up)
qcom_pcie_ops::init:
enable controller clocks
assert controller reset
phy_reset() (toggle the PHY's own reset)
deassert controller reset
write PARF_DEVICE_TYPE
phy_power_on()
qcom_pcie_ops::post_init (rest of the PHY/PARF/DBI setup)
phy_init() moves into qcom_pcie_host_init() and phy_exit() into qcom_pcie_host_deinit(), right before and right after they call qcom_pcie_ops::init/qcom_pcie_ops::deinit.
Apply this to qcom_pcie_init_2_7_0()/_2_9_0()/_2_3_2()/_2_3_3(). qcom_pcie_init_2_3_3() was enabling clocks after the reset deassert; move that ahead of the reset assert to match the same ordering. Also add or move the PARF_DEVICE_TYPE write to right after the reset group in each of those four functions.
For most platforms phy_init()/phy_exit()/phy_reset() are no-ops against their phy_ops, so moving the calls around has no effect yet; the PHY's clocks/reset actually start being driven this way once a later PHY driver change implements phy_ops::init/phy_ops::exit/phy_ops::reset. phy-qcom-pcie2.c does implement phy_init()/phy_exit(), but moving the call site into qcom_pcie_host_init()/qcom_pcie_host_deinit() keeps them at the same point relative to that platform's own clock/reset programming, so its init sequence doesn't change either.
--- drivers/pci/controller/dwc/pcie-qcom.c | 165 +++++++++++++++++++++++++-------- 1 file changed, 126 insertions(+), 39 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +126 -39
@@ -508,6 +508,58 @@ static enum dw_pcie_ltssm qcom_pcie_2_1_0_get_ltssm(struct qcom_pcie *pcie)return (enum dw_pcie_ltssm )FIELD_GET (ELBI_SYS_STTS_LTSSM_STATE_MASK , val); } +static void qcom_pcie_phy_exit (struct qcom_pcie *pcie) +{ +struct qcom_pcie_port *port; + +list_for_each_entry (port, &pcie->ports, list) +phy_exit (port->phy); +} + +static int qcom_pcie_phy_init (struct qcom_pcie *pcie) +{ +struct qcom_pcie_port *port, *failed_port =NULL ; +struct device *dev = pcie->pci->dev; +int ret; + +list_for_each_entry (port, &pcie->ports, list) { + ret =phy_init (port->phy); +if (ret) { +dev_err (dev,"phy init failed (%d)\n" , ret); + failed_port = port; + goto err_exit_phy; + } + } + +return 0 ; + +err_exit_phy: +list_for_each_entry (port, &pcie->ports, list) { +if (port == failed_port) +break ; +phy_exit (port->phy); + } + +return ret; +} + +static int qcom_pcie_phy_reset (struct qcom_pcie *pcie) +{ +struct qcom_pcie_port *port; +struct device *dev = pcie->pci->dev; +int ret; + +list_for_each_entry (port, &pcie->ports, list) { + ret =phy_reset (port->phy); +if (ret) { +dev_err (dev,"phy reset failed (%d)\n" , ret); +return ret; + } + } + +return 0 ; +} +static int qcom_pcie_get_resources_2_1_0 (struct qcom_pcie *pcie) {struct qcom_pcie_resources_2_1_0 *res = &pcie->res.v2_1_0;
@@ -791,11 +843,23 @@ static int qcom_pcie_init_2_3_2(struct qcom_pcie *pcie) ret =clk_bulk_prepare_enable (res->num_clks, res->clks);if (ret) {dev_err (dev,"cannot prepare/enable clocks\n" ); -regulator_bulk_disable (ARRAY_SIZE (res->supplies), res->supplies); -return ret; + goto err_disable_regulators; } + ret =qcom_pcie_phy_reset (pcie); +if (ret) + goto err_disable_clocks; + +writel (DEVICE_TYPE_RC , pcie->parf +PARF_DEVICE_TYPE ); +return 0 ; + +err_disable_clocks: +clk_bulk_disable_unprepare (res->num_clks, res->clks); +err_disable_regulators: +regulator_bulk_disable (ARRAY_SIZE (res->supplies), res->supplies); + +return ret; }static int qcom_pcie_post_init_2_3_2 (struct qcom_pcie *pcie)
@@ -957,18 +1021,28 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie)struct device *dev = pci->dev;int ret; + ret =clk_bulk_prepare_enable (res->num_clks, res->clks); +if (ret) { +dev_err (dev,"cannot prepare/enable clocks\n" ); +return ret; + } + ret =reset_control_bulk_assert (ARRAY_SIZE (res->rst), res->rst);if (ret <0 ) {dev_err (dev,"cannot assert resets\n" ); -return ret; + goto err_disable_clocks; }usleep_range (2000 ,2500 ); + ret =qcom_pcie_phy_reset (pcie); +if (ret) + goto err_assert_resets; + ret =reset_control_bulk_deassert (ARRAY_SIZE (res->rst), res->rst);if (ret <0 ) {dev_err (dev,"cannot deassert resets\n" ); -return ret; + goto err_assert_resets; }/*
@@ -977,11 +1051,7 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie)*/ usleep_range (2000 ,2500 ); - ret =clk_bulk_prepare_enable (res->num_clks, res->clks); -if (ret) { -dev_err (dev,"cannot prepare/enable clocks\n" ); - goto err_assert_resets; - } +writel (DEVICE_TYPE_RC , pcie->parf +PARF_DEVICE_TYPE );return 0 ;
@@ -991,6 +1061,8 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie)* the original failure in 'ret'. */ reset_control_bulk_assert (ARRAY_SIZE (res->rst), res->rst); +err_disable_clocks: +clk_bulk_disable_unprepare (res->num_clks, res->clks);return ret; }
@@ -1066,7 +1138,6 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)struct qcom_pcie_resources_2_7_0 *res = &pcie->res.v2_7_0;struct dw_pcie *pci = pcie->pci;struct device *dev = pci->dev; -u32 val;int ret; ret =regulator_bulk_enable (ARRAY_SIZE (res->supplies), res->supplies);
@@ -1085,6 +1156,10 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie) goto err_disable_clocks; } + ret =qcom_pcie_phy_reset (pcie); +if (ret) + goto err_disable_clocks; +usleep_range (1000 ,1500 ); ret =reset_control_deassert (res->rst);
@@ -1099,6 +1174,21 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)/* configure PCIe to RC mode */ writel (DEVICE_TYPE_RC , pcie->parf +PARF_DEVICE_TYPE ); +return 0 ; +err_disable_clocks: +clk_bulk_disable_unprepare (res->num_clks, res->clks); +err_disable_regulators: +regulator_bulk_disable (ARRAY_SIZE (res->supplies), res->supplies); + +return ret; +} + +static int qcom_pcie_post_init_2_7_0 (struct qcom_pcie *pcie) +{ +const struct qcom_pcie_cfg *pcie_cfg = pcie->cfg; +struct dw_pcie *pci = pcie->pci; +u32 val; +/* Force PHY out of lowest power state */ val =readl (pcie->parf +PARF_PHY_CTRL ); val &= ~PHY_TEST_PWR_DOWN ;
@@ -1126,19 +1216,6 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie) val |=EN ;writel (val, pcie->parf +PARF_AXI_MSTR_WR_ADDR_HALT_V2 ); -return 0 ; -err_disable_clocks: -clk_bulk_disable_unprepare (res->num_clks, res->clks); -err_disable_regulators: -regulator_bulk_disable (ARRAY_SIZE (res->supplies), res->supplies); - -return ret; -} - -static int qcom_pcie_post_init_2_7_0 (struct qcom_pcie *pcie) -{ -const struct qcom_pcie_cfg *pcie_cfg = pcie->cfg; -if (pcie_cfg->override_no_snoop)writel (WR_NO_SNOOP_OVERRIDE_EN |RD_NO_SNOOP_OVERRIDE_EN , pcie->parf +PARF_NO_SNOOP_OVERRIDE );
@@ -1298,10 +1375,14 @@ static int qcom_pcie_init_2_9_0(struct qcom_pcie *pcie)struct device *dev = pcie->pci->dev;int ret; + ret =clk_bulk_prepare_enable (res->num_clks, res->clks); +if (ret) +return ret; + ret =reset_control_assert (res->rst);if (ret) {dev_err (dev,"reset assert failed (%d)\n" , ret); -return ret; + goto err_disable_clocks; }/*
@@ -1310,15 +1391,26 @@ static int qcom_pcie_init_2_9_0(struct qcom_pcie *pcie)*/ usleep_range (2000 ,2500 ); + ret =qcom_pcie_phy_reset (pcie); +if (ret) + goto err_disable_clocks; + ret =reset_control_deassert (res->rst);if (ret) {dev_err (dev,"reset deassert failed (%d)\n" , ret); -return ret; + goto err_disable_clocks; }usleep_range (2000 ,2500 ); -return clk_bulk_prepare_enable (res->num_clks, res->clks); +writel (DEVICE_TYPE_RC , pcie->parf +PARF_DEVICE_TYPE ); + +return 0 ; + +err_disable_clocks: +clk_bulk_disable_unprepare (res->num_clks, res->clks); + +return ret; }static int qcom_pcie_post_init_2_9_0 (struct qcom_pcie *pcie)
@@ -1335,7 +1427,6 @@ static int qcom_pcie_post_init_2_9_0(struct qcom_pcie *pcie)qcom_pcie_configure_dbi_atu_base (pcie); -writel (DEVICE_TYPE_RC , pcie->parf +PARF_DEVICE_TYPE );writel (BYPASS |MSTR_AXI_CLK_EN |AHB_CLK_EN , pcie->parf +PARF_MHI_CLOCK_RESET_CTRL ); writel(GEN3_RELATED_OFF_RXEQ_RGRDLESS_RXTS |
@@ -1447,10 +1538,14 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)qcom_pcie_perst_assert (pcie); - ret = pcie->cfg->ops->init (pcie); + ret =qcom_pcie_phy_init (pcie);if (ret)return ret; + ret = pcie->cfg->ops->init (pcie); +if (ret) + goto err_exit_phy; + ret =qcom_pcie_phy_power_on (pcie);if (ret) goto err_deinit;
@@ -1503,6 +1598,8 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)qcom_pcie_phy_power_off (pcie); err_deinit: pcie->cfg->ops->deinit (pcie); +err_exit_phy: +qcom_pcie_phy_exit (pcie);return ret; }
@@ -1524,6 +1621,7 @@ static void qcom_pcie_host_deinit(struct dw_pcie_rp *pp)qcom_pcie_phy_power_off (pcie); pcie->cfg->ops->deinit (pcie); +qcom_pcie_phy_exit (pcie); }static void qcom_pcie_host_post_init (struct dw_pcie_rp *pp)
@@ -2109,10 +2207,6 @@ static int qcom_pcie_parse_port(struct qcom_pcie *pcie, struct device_node *nodeif (!port)return -ENOMEM ; - ret =phy_init (phy); -if (ret) -return ret; -INIT_LIST_HEAD (&port->perst); ret =qcom_pcie_parse_perst (pcie, port, node);
@@ -2157,7 +2251,6 @@ static int qcom_pcie_parse_ports(struct qcom_pcie *pcie)list_for_each_entry_safe (port, tmp_port, &pcie->ports, list) {list_for_each_entry_safe (perst, tmp_perst, &port->perst, list)list_del (&perst->list); -phy_exit (port->phy);list_del (&port->list); }
@@ -2170,16 +2263,11 @@ static int qcom_pcie_parse_legacy_binding(struct qcom_pcie *pcie)struct qcom_pcie_perst *perst;struct qcom_pcie_port *port;struct phy *phy; -int ret; phy =devm_phy_optional_get (dev,"pciephy" );if (IS_ERR (phy))return PTR_ERR (phy); - ret =phy_init (phy); -if (ret) -return ret; - port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL );if (!port)return -ENOMEM ;
@@ -2398,7 +2486,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)list_for_each_entry_safe (port, tmp_port, &pcie->ports, list) {list_for_each_entry_safe (perst, tmp_perst, &port->perst, list)list_del (&perst->list); -phy_exit (port->phy);list_del (&port->list); } err_pm_runtime_put:
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 1/4] PCI: qcom: Move PHY init and add PHY reset call to align with HPG
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 20 lines
HPG requires the controller/PHY GDSCs powered up and all controller/PHY clocks enabled first, then the controller's reset and the PHY's reset toggled together as a group,
PARF_DEVICE_TYPEset right after, and the rest of the PARF/DBI config left until the PHY is ready.Make use of
phy_init()andphy_reset(), and change the call flow to:
qcom_pcie_host_init():
phy_init()(PHY GDSCs/regulators/clocks up)
qcom_pcie_ops::init:
enable controller clocks
assert controller reset
phy_reset()(toggle the PHY's own reset)
deassert controller reset
writePARF_DEVICE_TYPE
[ ... ]
site into qcom_pcie_host_init()/qcom_pcie_host_deinit() keeps them at the same point relative to that platform's own clock/reset programming, so its init sequence doesn't change either.
Quoted 1 line
Signed-off-by Qiang Yu <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-align_pcie_init_sequence_0916-v1-0-0b2195836f30@oss.qualcomm.com?part=1
Re: [PATCH 1/4] PCI: qcom: Move PHY init and add PHY reset call to align with HPG
In reply to Qiang YuQuoted 37 lines · Qiang Yu
HPG requires the controller/PHY GDSCs powered up and all controller/PHY clocks enabled first, then the controller's reset and the PHY's reset toggled together as a group,
PARF_DEVICE_TYPEset right after, and the rest of the PARF/DBI config left until the PHY is ready.Make use of
phy_init()andphy_reset(), and change the call flow to:
qcom_pcie_host_init():
phy_init()(PHY GDSCs/regulators/clocks up)
qcom_pcie_ops::init:
enable controller clocks
assert controller reset
phy_reset()(toggle the PHY's own reset)
deassert controller reset
writePARF_DEVICE_TYPE
phy_power_on()
qcom_pcie_ops::post_init(rest of the PHY/PARF/DBI setup)
phy_init()moves intoqcom_pcie_host_init()andphy_exit()intoqcom_pcie_host_deinit(), right before and right after they call qcom_pcie_ops::init/qcom_pcie_ops::deinit.Apply this to qcom_pcie_init_2_7_0()/_2_9_0()/_2_3_2()/_2_3_3().
qcom_pcie_init_2_3_3()was enabling clocks after the reset deassert; move that ahead of the reset assert to match the same ordering. Also add or move thePARF_DEVICE_TYPEwrite to right after the reset group in each of those four functions.For most platforms phy_init()/phy_exit()/phy_reset() are no-ops against their
phy_ops, so moving the calls around has no effect yet; the PHY's clocks/reset actually start being driven this way once a later PHY driver change implements phy_ops::init/phy_ops::exit/phy_ops::reset.phy-qcom-pcie2.cdoes implement phy_init()/phy_exit(), but moving the call site into qcom_pcie_host_init()/qcom_pcie_host_deinit() keeps them at the same point relative to that platform's own clock/reset programming, so its init sequence doesn't change either.
Quoted 4 lines
Signed-off-by Qiang Yu<[email protected]>--- drivers/pci/controller/dwc/pcie-qcom.c | 165 +++++++++++++++++++++++++-------- 1 file changed, 126 insertions(+), 39 deletions(-)
Verified the PCIe enumeration in IPQ9574 and IPQ5424 and it works fine. So,
PATCH 2/4 PCI: qcom-ep: Move PHY init and drive PHY reset to align with HPG
In reply to Qiang YuHPG requires the GDSC to be powered up and all PHY/controller clocks enabled before the controller's core reset and the PHY's reset are toggled together as one atomic group, with PARF_DEVICE_TYPE set right after that reset group, same as the RC-mode change.
Move phy_init() ahead of the controller's own clock enable, and fold phy_reset() into the core reset assert/deassert. phy_power_on() keeps running afterwards. Also move the PARF_DEVICE_TYPE write out of qcom_pcie_perst_deassert() to right after the reset group, in qcom_pcie_enable_resources().
phy_reset() and phy_init are currently a no-op against the PHY this driver uses, so the init sequence doesn't change yet; it actually changes once the PHY driver later implements .reset.
--- drivers/pci/controller/dwc/pcie-qcom-ep.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/pci/controller/dwc/pcie-qcom-ep.c +16 -10
@@ -228,7 +228,7 @@ struct qcom_pcie_ep {int perst_irq; }; -static int qcom_pcie_ep_core_reset (struct qcom_pcie_ep *pcie_ep) +static int qcom_pcie_ep_phy_core_reset (struct qcom_pcie_ep *pcie_ep) {struct dw_pcie *pci = &pcie_ep->pci;struct device *dev = pci->dev;
@@ -242,6 +242,12 @@ static int qcom_pcie_ep_core_reset(struct qcom_pcie_ep *pcie_ep)usleep_range (CORE_RESET_TIME_US_MIN ,CORE_RESET_TIME_US_MAX ); + ret =phy_reset (pcie_ep->phy); +if (ret) { +dev_err (dev,"Cannot reset phy\n" ); +return ret; + } + ret =reset_control_deassert (pcie_ep->core_reset);if (ret) {dev_err (dev,"Cannot de-assert core reset\n" );
@@ -332,25 +338,25 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)struct dw_pcie *pci = &pcie_ep->pci;int ret; - ret =clk_bulk_prepare_enable (pcie_ep->num_clks, pcie_ep->clks); + ret =phy_init (pcie_ep->phy);if (ret)return ret; - ret =qcom_pcie_ep_core_reset (pcie_ep); + ret =clk_bulk_prepare_enable (pcie_ep->num_clks, pcie_ep->clks);if (ret) - goto err_disable_clk; + goto err_phy_exit; - ret =phy_init (pcie_ep->phy); + ret =qcom_pcie_ep_phy_core_reset (pcie_ep);if (ret) goto err_disable_clk; ret =phy_set_mode_ext (pcie_ep->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_EP );if (ret) - goto err_phy_exit; + goto err_disable_clk; ret =phy_power_on (pcie_ep->phy);if (ret) - goto err_phy_exit; + goto err_disable_clk;/* * Some Qualcomm platforms require interconnect bandwidth constraints
@@ -370,10 +376,10 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep) err_phy_off:phy_power_off (pcie_ep->phy); -err_phy_exit: -phy_exit (pcie_ep->phy); err_disable_clk:clk_bulk_disable_unprepare (pcie_ep->num_clks, pcie_ep->clks); +err_phy_exit: +phy_exit (pcie_ep->phy);return ret; }
@@ -390,8 +396,8 @@ static void qcom_pcie_disable_resources(struct qcom_pcie_ep *pcie_ep)icc_set_bw (pcie_ep->icc_mem,0 ,0 );phy_power_off (pcie_ep->phy); -phy_exit (pcie_ep->phy);clk_bulk_disable_unprepare (pcie_ep->num_clks, pcie_ep->clks); +phy_exit (pcie_ep->phy); }static int qcom_pcie_perst_deassert (struct dw_pcie *pci)
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 2/4] PCI: qcom-ep: Move PHY init and drive PHY reset to align with HPG
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] pci: qcom-ep: missing PARF_DEVICE_TYPE relocation --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] pci: qcom-ep: missing PARF_DEVICE_TYPE relocation
--
commit 5b56bf58f9d475d704bc41d4161818703cac582d
Author: Qiang Yu <[email protected]>
PCI: qcom-ep: Move PHY init and drive PHY reset to align with HPG
This patch rearranges the PHY initialization and reset sequences to align with the hardware programming guide (HPG). It moves phy_init() before the controller clock enable and folds phy_reset() into the core reset assert/deassert sequence.
Quoted 7 lines
PCI: qcom-ep: Move PHY init and drive PHY reset to align with HPG
HPG requires the GDSC to be powered up and all PHY/controller clocks enabled before the controller's core reset and the PHY's reset are toggled together as one atomic group, with
PARF_DEVICE_TYPEset right after that reset group, same as the RC-mode change.
Quoted 5 lines
Move
phy_init()ahead of the controller's own clock enable, and foldphy_reset()into the core reset assert/deassert.phy_power_on()keeps running afterwards. Also move thePARF_DEVICE_TYPEwrite out ofqcom_pcie_perst_deassert()to right after the reset group, inqcom_pcie_enable_resources().
[Severity: Medium]
The commit message explicitly states the PARF_DEVICE_TYPE write is being moved out of qcom_pcie_perst_deassert() to right after the reset group in qcom_pcie_enable_resources(). However, the diff does not seem to include this change.
Quoted 4 lines
drivers/pci/controller/dwc/pcie-qcom-ep.c +0
-0
[ ... ]
Quoted 11 lines
drivers/pci/controller/dwc/pcie-qcom-ep.c +2
-2@@ -332,25 +338,25 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)struct dw_pcie *pci = &pcie_ep->pci;int ret; - ret =clk_bulk_prepare_enable (pcie_ep->num_clks, pcie_ep->clks); + ret =phy_init (pcie_ep->phy);if (ret)return ret; - ret =qcom_pcie_ep_core_reset (pcie_ep); + ret =clk_bulk_prepare_enable (pcie_ep->num_clks, pcie_ep->clks);
drivers/pci/controller/dwc/pcie-qcom-ep.c static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep) · line 353
Quoted 10 lines
drivers/pci/controller/dwc/pcie-qcom-ep.c +2
-2if (ret) - goto err_disable_clk; + goto err_phy_exit; - ret =phy_init (pcie_ep->phy); + ret =qcom_pcie_ep_phy_core_reset (pcie_ep);if (ret) goto err_disable_clk; ret =phy_set_mode_ext (pcie_ep->phy,PHY_MODE_PCIE ,PHY_MODE_PCIE_EP );
[Severity: Medium]
Was the write to PARF_DEVICE_TYPE accidentally omitted from this patch?
Based on the commit message and HPG requirements, it looks like a write to PARF_DEVICE_TYPE was intended to be inserted right here in qcom_pcie_enable_resources().
Looking at the code in qcom_pcie_perst_deassert(), the write remains untouched:
drivers/pci/controller/dwc/pcie-qcom-ep.c:qcom_pcie_perst_deassert() {
...
/* Configure PCIe to endpoint mode */
writel_relaxed(PARF_DEVICE_TYPE_EP, pcie_ep->parf + PARF_DEVICE_TYPE);
...
}Could this mismatch between the HPG sequence and the actual implemented code cause endpoint initialization failures when the hardware requires the device type to be set immediately after reset?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-align_pcie_init_sequence_0916-v1-0-0b2195836f30@oss.qualcomm.com?part=2
Manivannan Sadhasivam
maintainerRe: [PATCH 2/4] PCI: qcom-ep: Move PHY init and drive PHY reset to align with HPG
In reply to Qiang YuQuoted 11 lines · Qiang Yu
HPG requires the GDSC to be powered up and all PHY/controller clocks enabled before the controller's core reset and the PHY's reset are toggled together as one atomic group, with
PARF_DEVICE_TYPEset right after that reset group, same as the RC-mode change.Move
phy_init()ahead of the controller's own clock enable, and foldphy_reset()into the core reset assert/deassert.phy_power_on()keeps running afterwards. Also move thePARF_DEVICE_TYPEwrite out ofqcom_pcie_perst_deassert()to right after the reset group, inqcom_pcie_enable_resources().
Sashiko pointed out that PARF_DEVICE_TYPE change is not present in this patch.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH 3/4 phy: qcom-qmp-pcie-multiphy: Split phy_ops into init/exit/reset/power_on
In reply to Qiang YuPer HPG, the controller now calls phy_init() from qcom_pcie_host_init() and phy_reset() from inside its own core reset assert/deassert. Making that actually happen here needs phy_ops::init and phy_ops::reset implemented, and phy_ops::power_on adjusted to match. Split the combined phy_ops::power_on/power_off into phy_ops::init/exit/reset/power_on to do that.
phy_ops::init enables power domains, regulators, and all PHY clocks (pipe clock first). phy_ops::reset does the no-CSR reset assert/ delay/deassert/delay. phy_ops::power_on is left with just the PCS status poll. phy_ops::exit mirrors phy_ops::init in reverse; phy_ops::power_off is dropped since nothing remains for it to do.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c | 94 +++++++++-------------- 1 file changed, 35 insertions(+), 59 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c +35 -59
@@ -280,20 +280,18 @@ static int qmp_pcie_init(struct phy *phy) goto err_pd_power_off; } - ret =reset_control_bulk_assert (qmp->cfg->num_nocsr_resets, qmp->nocsr_resets); -if (ret) { -dev_err (qmp->dev,"no-csr reset assert failed: %d\n" , ret); + ret =clk_bulk_prepare_enable (qmp->cfg->num_pipe_clks, qmp->pipe_clks); +if (ret) goto err_disable_regulators; - } - -usleep_range (200 ,300 ); ret =clk_bulk_prepare_enable (qmp->cfg->num_clks, qmp->clks);if (ret) - goto err_disable_regulators; + goto err_disable_pipe_clks;return 0 ; +err_disable_pipe_clks: +clk_bulk_disable_unprepare (qmp->cfg->num_pipe_clks, qmp->pipe_clks); err_disable_regulators:regulator_bulk_disable (cfg->num_vregs, qmp->vregs); err_pd_power_off:
@@ -310,31 +308,47 @@ static int qmp_pcie_exit(struct phy *phy)reset_control_bulk_assert (qmp->cfg->num_nocsr_resets, qmp->nocsr_resets);clk_bulk_disable_unprepare (qmp->cfg->num_clks, qmp->clks); +clk_bulk_disable_unprepare (qmp->cfg->num_pipe_clks, qmp->pipe_clks);regulator_bulk_disable (cfg->num_vregs, qmp->vregs);qmp_pcie_pd_power_off (qmp);return 0 ; } -static int qmp_pcie_power_on (struct phy *phy) +static int qmp_pcie_reset (struct phy *phy) {struct qmp_pcie *qmp =phy_get_drvdata (phy);const struct qmp_phy_cfg *cfg = qmp->cfg; -const struct qmp_pcie_offsets *offs = cfg->offsets; -void __iomem *status; -unsigned int val; -int i, ret; +int ret; - ret =clk_bulk_prepare_enable (qmp->cfg->num_pipe_clks, qmp->pipe_clks); -if (ret) + ret =reset_control_bulk_assert (cfg->num_nocsr_resets, qmp->nocsr_resets); +if (ret) { +dev_err (qmp->dev,"no-csr reset assert failed: %d\n" , ret);return ret; + } - ret =reset_control_bulk_deassert (qmp->cfg->num_nocsr_resets, qmp->nocsr_resets); +udelay (5 ); + + ret =reset_control_bulk_deassert (cfg->num_nocsr_resets, qmp->nocsr_resets);if (ret) {dev_err (qmp->dev,"no-csr reset deassert failed: %d\n" , ret); - goto err_disable_pipe_clk; +return ret; } +udelay (5 ); + +return 0 ; +} + +static int qmp_pcie_power_on (struct phy *phy) +{ +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg; +const struct qmp_pcie_offsets *offs = cfg->offsets; +void __iomem *status; +unsigned int val; +int i, ret; +for (i =0 ; i < cfg->num_regs; i++) { status = qmp->base[i] + offs->pcs + cfg->regs[QPHY_PCS_STATUS ]; ret = readl_poll_timeout(status, val, !(val & cfg->phy_status), 200,
@@ -342,56 +356,18 @@ static int qmp_pcie_power_on(struct phy *phy)if (ret) {dev_err (qmp->dev,"PHY power on timed-out (%s): %d\n" , cfg->reg_names[i], ret); - goto err_disable_pipe_clk; +return ret; } }return 0 ; - -err_disable_pipe_clk: -clk_bulk_disable_unprepare (qmp->cfg->num_pipe_clks, qmp->pipe_clks); - -return ret; -} - -static int qmp_pcie_power_off (struct phy *phy) -{ -struct qmp_pcie *qmp =phy_get_drvdata (phy); - -clk_bulk_disable_unprepare (qmp->cfg->num_pipe_clks, qmp->pipe_clks); - -return 0 ; -} - -static int qmp_pcie_enable (struct phy *phy) -{ -int ret; - - ret =qmp_pcie_init (phy); -if (ret) -return ret; - - ret =qmp_pcie_power_on (phy); -if (ret) -qmp_pcie_exit (phy); - -return ret; -} - -static int qmp_pcie_disable (struct phy *phy) -{ -int ret; - - ret =qmp_pcie_power_off (phy); -if (ret) -return ret; - -return qmp_pcie_exit (phy); }static const struct phy_ops qmp_pcie_phy_ops = { - .power_on = qmp_pcie_enable, - .power_off = qmp_pcie_disable, + .init = qmp_pcie_init, + .exit = qmp_pcie_exit, + .power_on = qmp_pcie_power_on, + .reset = qmp_pcie_reset, .owner =THIS_MODULE , };
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 3/4] phy: qcom-qmp-pcie-multiphy: Split phy_ops into init/exit/reset/power_on
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
Per HPG, the controller now calls
phy_init()fromqcom_pcie_host_init()andphy_reset()from inside its own core reset assert/deassert. Making that actually happen here needsphy_ops::initandphy_ops::resetimplemented, andphy_ops::power_onadjusted to match. Split the combined phy_ops::power_on/power_off into phy_ops::init/exit/reset/power_on to do that.
Quoted 7 lines
phy_ops::initenables power domains, regulators, and all PHY clocks (pipe clock first).phy_ops::resetdoes the no-CSR reset assert/ delay/deassert/delay.phy_ops::power_onis left with just the PCS status poll.phy_ops::exitmirrorsphy_ops::initin reverse;phy_ops::power_offis dropped since nothing remains for it to do.Signed-off-by Qiang Yu <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-align_pcie_init_sequence_0916-v1-0-0b2195836f30@oss.qualcomm.com?part=3
Re: [PATCH 3/4] phy: qcom-qmp-pcie-multiphy: Split phy_ops into init/exit/reset/power_on
In reply to Qiang YuQuoted 7 lines · Qiang Yu
Per HPG, the controller now calls
phy_init()fromqcom_pcie_host_init()andphy_reset()from inside its own core reset assert/deassert. Making that actually happen here needsphy_ops::initandphy_ops::resetimplemented, andphy_ops::power_onadjusted to match. Split the combined phy_ops::power_on/power_off into phy_ops::init/exit/reset/power_on to do that.
Quoted 7 lines
phy_ops::initenables power domains, regulators, and all PHY clocks (pipe clock first).phy_ops::resetdoes the no-CSR reset assert/ delay/deassert/delay.phy_ops::power_onis left with just the PCS status poll.phy_ops::exitmirrorsphy_ops::initin reverse;phy_ops::power_offis dropped since nothing remains for it to do.Signed-off-by Qiang Yu <[email protected]>
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH 4/4 phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
In reply to Qiang YuThe controller now calls phy_init() from qcom_pcie_host_init()/qcom_pcie_enable_resources() and phy_reset() from inside its own core reset assert/deassert, so the PHY's reset toggles alongside the controller's core reset as HPG requires. Making that actually happen here needs phy_ops::init and phy_ops::reset implemented, and phy_ops::power_on adjusted to match. Split the combined phy_ops::power_on/power_off into phy_ops::init/exit/reset/power_on to do that.
phy_ops::init enables regulators and all clocks (pipe clock first) and determines skip_init/skip_reset. phy_ops::reset toggles the reset that skip_init picked. Register-table programming used to run while the no-CSR reset was still asserted; now it runs afterwards, in phy_ops::power_on.
Adds skip_reset to struct qmp_pcie so phy_ops::reset and phy_ops::power_on share the value phy_ops::init determined instead of re-reading PCS registers.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 184 ++++++++++++++----------------- 1 file changed, 80 insertions(+), 104 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +80 -104
@@ -4058,6 +4058,7 @@ struct qmp_pcie {const struct qmp_phy_cfg *cfg;bool tcsr_4ln_config;bool skip_init; +bool skip_reset;void __iomem *serdes;void __iomem *pcs;
@@ -5747,9 +5748,22 @@ static int qmp_pcie_init(struct phy *phy)struct qmp_pcie *qmp =phy_get_drvdata (phy);const struct qmp_phy_cfg *cfg = qmp->cfg;void __iomem *pcs = qmp->pcs; -bool skip_reset;int ret; + ret =regulator_bulk_enable (cfg->num_vregs, qmp->vregs); +if (ret) { +dev_err (qmp->dev,"failed to enable regulators, err=%d\n" , ret); +return ret; + } + + ret =clk_bulk_prepare_enable (qmp->num_pipe_clks, qmp->pipe_clks); +if (ret) + goto err_disable_regulators; + + ret =clk_bulk_prepare_enable (ARRAY_SIZE (qmp_pciephy_clk_l), qmp->clks); +if (ret) + goto err_disable_pipe_clks; +/* * We can skip PHY initialization if all of the following conditions * are met:
@@ -5763,59 +5777,21 @@ static int qmp_pcie_init(struct phy *phy)qphy_checkbits (pcs, cfg->regs[QPHY_START_CTRL ],SERDES_START |PCS_START ) &&qphy_checkbits (pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], cfg->pwrdn_ctrl); - skip_reset = qmp->skip_init && !qphy_checkbits (pcs, cfg->regs[QPHY_PCS_STATUS ], + qmp->skip_reset = qmp->skip_init && !qphy_checkbits (pcs, cfg->regs[QPHY_PCS_STATUS ], cfg->phy_status);if (!qmp->skip_init && !cfg->tbls.serdes_num) {dev_err (qmp->dev,"Init sequence not available\n" ); -return -ENODATA ; - } - - ret =regulator_bulk_enable (cfg->num_vregs, qmp->vregs); -if (ret) { -dev_err (qmp->dev,"failed to enable regulators, err=%d\n" , ret); -return ret; - } - -/* -* Toggle BCR reset for PHY that doesn't support no_csr reset or has not -* been initialized. -*/ -if (!qmp->skip_init) { - ret =reset_control_bulk_assert (cfg->num_resets, qmp->resets); -if (ret) { -dev_err (qmp->dev,"reset assert failed\n" ); - goto err_disable_regulators; - } - } - -if (!skip_reset) { - ret =reset_control_assert (qmp->nocsr_reset); -if (ret) { -dev_err (qmp->dev,"no-csr reset assert failed\n" ); - goto err_assert_reset; - } - -usleep_range (200 ,300 ); - } - -if (!qmp->skip_init) { - ret =reset_control_bulk_deassert (cfg->num_resets, qmp->resets); -if (ret) { -dev_err (qmp->dev,"reset deassert failed\n" ); - goto err_assert_reset; - } + ret = -ENODATA ; + goto err_disable_clks; } - ret =clk_bulk_prepare_enable (ARRAY_SIZE (qmp_pciephy_clk_l), qmp->clks); -if (ret) - goto err_assert_reset; -return 0 ; -err_assert_reset: -if (!qmp->skip_init) -reset_control_bulk_assert (cfg->num_resets, qmp->resets); +err_disable_clks: +clk_bulk_disable_unprepare (ARRAY_SIZE (qmp_pciephy_clk_l), qmp->clks); +err_disable_pipe_clks: +clk_bulk_disable_unprepare (qmp->num_pipe_clks, qmp->pipe_clks); err_disable_regulators:regulator_bulk_disable (cfg->num_vregs, qmp->vregs);
@@ -5833,12 +5809,62 @@ static int qmp_pcie_exit(struct phy *phy)reset_control_bulk_assert (cfg->num_resets, qmp->resets);clk_bulk_disable_unprepare (ARRAY_SIZE (qmp_pciephy_clk_l), qmp->clks); +clk_bulk_disable_unprepare (qmp->num_pipe_clks, qmp->pipe_clks);regulator_bulk_disable (cfg->num_vregs, qmp->vregs);return 0 ; } +static int qmp_pcie_reset (struct phy *phy) +{ +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg; +int ret; + +if (qmp->skip_reset) +return 0 ; + +if (qmp->skip_init) { + ret =reset_control_assert (qmp->nocsr_reset); +if (ret) { +dev_err (qmp->dev,"no-csr reset assert failed\n" ); +return ret; + } + +usleep_range (200 ,300 ); + + ret =reset_control_deassert (qmp->nocsr_reset); +if (ret) { +dev_err (qmp->dev,"no-csr reset deassert failed\n" ); +return ret; + } + +return 0 ; + } + +/* +* Toggle BCR reset for PHY that doesn't support no_csr reset or has not +* been initialized. +*/ + ret =reset_control_bulk_assert (cfg->num_resets, qmp->resets); +if (ret) { +dev_err (qmp->dev,"reset assert failed\n" ); +return ret; + } + +usleep_range (200 ,300 ); + + ret =reset_control_bulk_deassert (cfg->num_resets, qmp->resets); +if (ret) { +dev_err (qmp->dev,"reset deassert failed\n" ); +reset_control_bulk_assert (cfg->num_resets, qmp->resets); +return ret; + } + +return 0 ; +} +static int qmp_pcie_power_on (struct phy *phy) {struct qmp_pcie *qmp =phy_get_drvdata (phy);
@@ -5847,17 +5873,14 @@ static int qmp_pcie_power_on(struct phy *phy)void __iomem *pcs = qmp->pcs;void __iomem *status;unsigned int mask, val; -bool skip_reset;int ret; - skip_reset = qmp->skip_init && !qphy_checkbits (pcs, cfg->regs[QPHY_PCS_STATUS ], - cfg->phy_status);/* * Write CSR register for PHY that doesn't support no_csr reset or has not * been initialized. */ if (qmp->skip_init) - goto skip_tbls_init; + goto skip_serdes_start;qphy_setbits (pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], cfg->pwrdn_ctrl);
@@ -5870,22 +5893,6 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_init_registers (qmp, &cfg->tbls);qmp_pcie_init_registers (qmp, mode_tbls); -skip_tbls_init: - ret =clk_bulk_prepare_enable (qmp->num_pipe_clks, qmp->pipe_clks); -if (ret) -return ret; - -if (!skip_reset) { - ret =reset_control_deassert (qmp->nocsr_reset); -if (ret) { -dev_err (qmp->dev,"no-csr reset deassert failed\n" ); - goto err_disable_pipe_clk; - } - } - -if (qmp->skip_init) - goto skip_serdes_start; -/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
@@ -5902,15 +5909,10 @@ static int qmp_pcie_power_on(struct phy *phy) PHY_INIT_COMPLETE_TIMEOUT);if (ret) {dev_err (qmp->dev,"phy initialization timed-out\n" ); - goto err_disable_pipe_clk; +return ret; }return 0 ; - -err_disable_pipe_clk: -clk_bulk_disable_unprepare (qmp->num_pipe_clks, qmp->pipe_clks); - -return ret; }static int qmp_pcie_power_off (struct phy *phy)
@@ -5918,8 +5920,6 @@ static int qmp_pcie_power_off(struct phy *phy)struct qmp_pcie *qmp =phy_get_drvdata (phy);const struct qmp_phy_cfg *cfg = qmp->cfg; -clk_bulk_disable_unprepare (qmp->num_pipe_clks, qmp->pipe_clks); -/* * While powering off the PHY, only qmp->nocsr_reset needs to be checked. In * this way, no matter whether the PHY settings were initially programmed by
@@ -5927,7 +5927,7 @@ static int qmp_pcie_power_off(struct phy *phy)* next time. */ if (qmp->nocsr_reset) - goto skip_phy_deinit; +return 0 ;/* PHY reset */ qphy_setbits (qmp->pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
@@ -5940,36 +5940,9 @@ static int qmp_pcie_power_off(struct phy *phy)qphy_clrbits (qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], cfg->pwrdn_ctrl); -skip_phy_deinit:return 0 ; } -static int qmp_pcie_enable (struct phy *phy) -{ -int ret; - - ret =qmp_pcie_init (phy); -if (ret) -return ret; - - ret =qmp_pcie_power_on (phy); -if (ret) -qmp_pcie_exit (phy); - -return ret; -} - -static int qmp_pcie_disable (struct phy *phy) -{ -int ret; - - ret =qmp_pcie_power_off (phy); -if (ret) -return ret; - -return qmp_pcie_exit (phy); -} -static int qmp_pcie_set_mode (struct phy *phy,enum phy_mode mode,int submode) {struct qmp_pcie *qmp =phy_get_drvdata (phy);
@@ -5988,8 +5961,11 @@ static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode) }static const struct phy_ops qmp_pcie_phy_ops = { - .power_on = qmp_pcie_enable, - .power_off = qmp_pcie_disable, + .init = qmp_pcie_init, + .exit = qmp_pcie_exit, + .power_on = qmp_pcie_power_on, + .power_off = qmp_pcie_power_off, + .reset = qmp_pcie_reset, .set_mode = qmp_pcie_set_mode, .owner =THIS_MODULE , };
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 4/4] phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] phy: qcom-qmp-pcie: nocsr_reset left asserted when skip_init is false --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] phy: qcom-qmp-pcie: nocsr_reset left asserted when skip_init is false --
commit 09fee607f4ad44d50cee755a3e356ff08d5879e2
Author: Qiang Yu <[email protected]>
phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
This commit splits the combined power_on and power_off operations into separate init, exit, reset, and power_on functions. It reorders regulator, clock, and reset toggling to align with HPG requirements. It also introduces a skip_reset field to share the initialization state between functions.
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-0
[ ... ]
Quoted 33 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +23
-0@@ -5833,12 +5809,62 @@ static int qmp_pcie_exit(struct phy *phy)reset_control_bulk_assert (cfg->num_resets, qmp->resets);clk_bulk_disable_unprepare (ARRAY_SIZE (qmp_pciephy_clk_l), qmp->clks); +clk_bulk_disable_unprepare (qmp->num_pipe_clks, qmp->pipe_clks);regulator_bulk_disable (cfg->num_vregs, qmp->vregs);return 0 ; } +static int qmp_pcie_reset (struct phy *phy) +{ +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg; +int ret; + +if (qmp->skip_reset) +return 0 ; + +if (qmp->skip_init) { + ret =reset_control_assert (qmp->nocsr_reset); +if (ret) { +dev_err (qmp->dev,"no-csr reset assert failed\n" ); +return ret; + } + +usleep_range (200 ,300 ); + + ret =reset_control_deassert (qmp->nocsr_reset); +if (ret) { +dev_err (qmp->dev,"no-csr reset deassert failed\n" ); +return ret;
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_exit(struct phy *phy) · line 5850
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +10
-0+ } + +return 0 ; + } + +/* +* Toggle BCR reset for PHY that doesn't support no_csr reset or has not +* been initialized. +*/ + ret =reset_control_bulk_assert (cfg->num_resets, qmp->resets);
[Severity: High]
Does this fallback path in qmp_pcie_reset() fail to deassert nocsr_reset when skip_init evaluates to false?
Since qmp_pcie_exit() explicitly asserts nocsr_reset on exit, if skip_init is false on the next initialization (for example, after a system suspend or resume where power loss clears PHY CSRs like QPHY_START_CTRL), wouldn't this execution path only toggle the bulk resets and leave nocsr_reset stuck in the asserted state?
Quoted 20 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +17
-0+if (ret) { +dev_err (qmp->dev,"reset assert failed\n" ); +return ret; + } + +usleep_range (200 ,300 ); + + ret =reset_control_bulk_deassert (cfg->num_resets, qmp->resets); +if (ret) { +dev_err (qmp->dev,"reset deassert failed\n" ); +reset_control_bulk_assert (cfg->num_resets, qmp->resets); +return ret; + } + +return 0 ; +} +static int qmp_pcie_power_on (struct phy *phy) {struct qmp_pcie *qmp =phy_get_drvdata (phy);
[ ... ]
Quoted 12 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-8@@ -5870,22 +5893,6 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_init_registers (qmp, &cfg->tbls);qmp_pcie_init_registers (qmp, mode_tbls); -skip_tbls_init: - ret =clk_bulk_prepare_enable (qmp->num_pipe_clks, qmp->pipe_clks); -if (ret) -return ret; - -if (!skip_reset) { - ret =reset_control_deassert (qmp->nocsr_reset); -if (ret) {
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_power_on(struct phy *phy) · line 5897
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0
-8-dev_err (qmp->dev,"no-csr reset deassert failed\n" ); - goto err_disable_pipe_clk; - } - } - -if (qmp->skip_init) - goto skip_serdes_start; -/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
[Severity: High]
With the explicit nocsr_reset deassertion removed from qmp_pcie_power_on(), does the code now rely entirely on qmp_pcie_reset() to deassert it?
Since qmp_pcie_reset() doesn't seem to deassert nocsr_reset when skip_init is false, this appears to set the PHY up to silently fail or time out on initialization.
Quoted 1 line
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260915-align_pcie_init_sequence_0916-v1-0-0b2195836f30@oss.qualcomm.com?part=4
Manivannan Sadhasivam
maintainerRe: [PATCH 4/4] phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
Quoted 2 lines · On Wed, Sep 16, 2026 at 06:17:02AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] phy: qcom-qmp-pcie:nocsr_resetleft asserted whenskip_initis false
Please take a look at the reported issues.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH 4/4] phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
In reply to Qiang YuQuoted 15 lines · Qiang Yu
The controller now calls
phy_init()from qcom_pcie_host_init()/qcom_pcie_enable_resources() andphy_reset()from inside its own core reset assert/deassert, so the PHY's reset toggles alongside the controller's core reset as HPG requires. Making that actually happen here needsphy_ops::initandphy_ops::resetimplemented, andphy_ops::power_onadjusted to match. Split the combined phy_ops::power_on/power_off into phy_ops::init/exit/reset/power_on to do that.
phy_ops::initenables regulators and all clocks (pipe clock first) and determines skip_init/skip_reset.phy_ops::resettoggles the reset thatskip_initpicked. Register-table programming used to run while the no-CSR reset was still asserted; now it runs afterwards, inphy_ops::power_on.
Quoted 8 lines
Adds
skip_resetto structqmp_pciesophy_ops::resetandphy_ops::power_onshare the valuephy_ops::initdetermined instead of re-reading PCS registers.Signed-off-by Qiang Yu<[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 184 ++++++++++++++----------------- 1 file changed, 80 insertions(+), 104 deletions(-)
Verified the PCIe enumeration in IPQ9574 and IPQ5424 and it works fine. So,
Re: [PATCH 4/4] phy: qcom-qmp-pcie: Split phy_ops into init/exit/reset/power_on
In reply to Qiang YuQuoted 3 lines · Qiang Yu
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1
-1- skip_reset = qmp->skip_init && !qphy_checkbits (pcs, cfg->regs[QPHY_PCS_STATUS ], + qmp->skip_reset = qmp->skip_init && !qphy_checkbits (pcs, cfg->regs[QPHY_PCS_STATUS ], cfg->phy_status);
[...]
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c static int qmp_pcie_exit(struct phy *phy) · line 5826
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +8
-0+static int qmp_pcie_reset (struct phy *phy) +{ +struct qmp_pcie *qmp =phy_get_drvdata (phy); +const struct qmp_phy_cfg *cfg = qmp->cfg; +int ret; + +if (qmp->skip_reset) +return 0 ;
This keeps the skip from 910b828b22b7 ("phy: qcom: qmp-pcie: Skip PHY reset if already up"). That skip stops v7.3-rc7 from booting on the Dell XPS 13 9345 (X1E80100), and I've sent a revert [1].
UEFI boots from the NVMe behind pcie6a, so the PHY is already up when Linux probes it and the no-csr reset is skipped. pcie-qcom still asserts PERST# and resets the controller, so the link has to train again, and it doesn't:
qcom-pcie 1bf8000.pcie: Device found, but not active
910b828b22b7 only changes whether that reset runs, and reverting it fixes boot.
With patch 1/4, X1E (qcom_pcie_init_2_7_0()) would run:
qcom_pcie_perst_assert()
phy_init() skip_reset = true
reset_control_assert(res->rst)
phy_reset() returns 0, PHY not reset
reset_control_deassert(res->rst)
phy_power_on() skip_init: no tables, no SERDES start
That is the same sequence as 910b828b22b7, so this series would bring the failure back. It also doesn't follow the HPG order in the cover
letter: the controller reset is toggled, the PHY reset isn't.
Could qmp_pcie_reset() always toggle the reset that skip_init selects, with qmp->skip_reset dropped? If link retention comes back, the controller knows whether it is keeping the link, so it can skip both its own reset and phy_reset() then.
[1] https://lore.kernel.org/r/[email protected]
Michael
Quoted 7 lines · Qiang Yu
HPG requires the controller/PHY GDSCs to be powered up and all clocks enabled, then the controller's reset and the PHY's reset toggled together as one group, with
PARF_DEVICE_TYPEset right after. This series adds the callbacks needed on both sides to realize that sequence: aphy_reset()call the controller makes as part of its own reset, and matching phy_ops::init/phy_ops::reset on the PHY side.
This observation is not related to this series; it's a question about PCI host controller initialization ordering in general because it seems like this is a perennial issue. Is there anything we can do to converge on some sort of generic standard or typical ordering across drivers?
For example, while looking at a patch that changed ordering in a different driver (not qcom), I asked Gemini for some guidance and it came up with the following ordering recommendations, which seem pretty generic:
- assert downstream PERST# so physical lanes remain quiet while setting up the host
- assert local resets (core & PHY)
- enable and stabilize power (IP core, I/O rails, PHYs)
- enable and stabilize clocks, including refclk and T_PERST_CLK
- initialize PHYs
- deassert PHY reset or allow register access to PHY
- wait for PHY PLL lock to refclk
- program PHY parameters & calibration
- verify PHY ready
- deassert local core reset
- configure RC (device type, MPS, max link speed, width, etc)
- deassert downstream PERST#
- enable LTSSM
If this could be made generic enough, maybe something like it could be included in Documentation/PCI/controller/pci-controller-drivers.rst?
Manivannan Sadhasivam
maintainerQuoted 41 lines · Bjorn Helgaas
Quoted 7 lines · Qiang Yu
HPG requires the controller/PHY GDSCs to be powered up and all clocks enabled, then the controller's reset and the PHY's reset toggled together as one group, with
PARF_DEVICE_TYPEset right after. This series adds the callbacks needed on both sides to realize that sequence: aphy_reset()call the controller makes as part of its own reset, and matching phy_ops::init/phy_ops::reset on the PHY side.This observation is not related to this series; it's a question about PCI host controller initialization ordering in general because it seems like this is a perennial issue. Is there anything we can do to converge on some sort of generic standard or typical ordering across drivers?
For example, while looking at a patch that changed ordering in a different driver (not qcom), I asked Gemini for some guidance and it came up with the following ordering recommendations, which seem pretty generic:
- assert downstream PERST# so physical lanes remain quiet while setting up the host
- assert local resets (core & PHY)
- enable and stabilize power (IP core, I/O rails, PHYs)
- enable and stabilize clocks, including refclk and
T_PERST_CLK- initialize PHYs
- deassert PHY reset or allow register access to PHY
- wait for PHY PLL lock to refclk
- program PHY parameters & calibration
- verify PHY ready
- deassert local core reset
Quoted 8 lines
- configure RC (device type, MPS, max link speed, width, etc)
- deassert downstream PERST#
- enable LTSSM
If this could be made generic enough, maybe something like it could be included in
Documentation/PCI/controller/pci-controller-drivers.rst?
Some of these sequences could be generalised, but the problem is, pretty much each controller sequence follow a hardware reference manual and those recommend a specific sequence. So if we diverge from that recommended sequence, then getting help from the hardware team for any issue would be tricky. Atleast, this is the case with Qcom controllers.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்