Skip to contentSkip to conversation

phy: qcom: qmp-pcie: Select MFD_SYSCON for the multi-PHY driver

PATCH Applied David Carlier 5 participants 8 messages Aug 25 – Oct 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 phy: qcom: qmp-pcie: Select MFD_SYSCON for the multi-PHY driver

The driver reads the active link mode through syscon_regmap_lookup_by_phandle_args(). Without CONFIG_MFD_SYSCON the stub returning -ENOTSUPP is compiled in instead, so probe fails for every device and no PHY is ever registered.

Nothing in the build catches this: the driver still compiles, and arm64 defconfig happens to enable MFD_SYSCON through an unrelated select.

Fixes 1781be3c8a5d ("phy: qcom: qmp-pcie: Add QMP PCIe Multi-PHY driver")
---
 drivers/phy/qualcomm/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/Kconfig +1 -0
index d910a5d1a1ac..9113e1099245 100644
@@ -81,6 +81,7 @@ config PHY_QCOM_QMP_PCIE_MULTIPHY
 	tristate "Qualcomm QMP PCIe Multi PHY Driver"
 	depends on PCI || COMPILE_TEST
 	select GENERIC_PHY
+	select MFD_SYSCON
 	help
 	  Enable this to support the QMP PCIe PHY transceiver that is used
 	  with PCIe controllers on Qualcomm chips. This PHY is a single
Signature · 1 line
2.55.0
#1 lore raw

PATCH 2/2 phy: qcom: qmp-pcie: Check clock-output-names count in the multi-PHY driver

of_property_count_strings() returns a negative errno when the property is missing or malformed. The value was passed straight to devm_kcalloc(), whose overflow check rejected it, turning a device tree problem into a bogus -ENOMEM with no diagnostic.

Fixes 1781be3c8a5d ("phy: qcom: qmp-pcie: Add QMP PCIe Multi-PHY driver")
---
 drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c +3 -0
index e93cba4369fb..e747ff9c3e5d 100644
@@ -555,6 +555,9 @@ static int qmp_pcie_multiphy_register_clocks(struct device *dev,
 	int i, ret;
 
 	num_pipe_outputs = of_property_count_strings(np, "clock-output-names");
+	if (num_pipe_outputs < 0)
+		return dev_err_probe(dev, num_pipe_outputs,
+				     "failed to read clock-output-names\n");
 
 	qmp_data->num_pipe_outputs = num_pipe_outputs;
 	qmp_data->pipe_out_clks = devm_kcalloc(dev, num_pipe_outputs,
Signature · 1 line
2.55.0
#4 lore raw
In reply to David Carlier
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] Unmet direct dependency warning caused by unconditionally selecting MFD_SYSCON in a driver supporting COMPILE_TEST without inheriting its HAS_IOMEM dependency.

Pre-existing issues:
- [High] Incomplete fix: The regular QMP PCIe driver (PHY_QCOM_QMP_PCIE) also unconditionally calls syscon_regmap_lookup_by_phandle_args() but still lacks a select for MFD_SYSCON, leaving it vulnerable to the exact same probe failure. --

commit ca7057ced5dd6d2650998c03785e590bdadcd6f2
Author: David Carlier <[email protected]>

phy: qcom: qmp-pcie: Select MFD_SYSCON for the multi-PHY driver

The driver reads the active link mode through syscon_regmap_lookup_by_phandle_args(). Without CONFIG_MFD_SYSCON, the stub returns -ENOTSUPP, causing probe failures. This patch adds the missing MFD_SYSCON selection to the PHY_QCOM_QMP_PCIE_MULTIPHY driver.

drivers/phy/qualcomm/Kconfig config PHY_QCOM_QMP_PCIE_MULTIPHY · line 84

Quoted 9 lines
drivers/phy/qualcomm/Kconfig +1 -0
index d910a5d1a1ac3..9113e10992457 100644
@@ -81,6 +81,7 @@ config PHY_QCOM_QMP_PCIE_MULTIPHY
 	tristate "Qualcomm QMP PCIe Multi PHY Driver"
 	depends on PCI || COMPILE_TEST
 	select GENERIC_PHY
+	select MFD_SYSCON

[Severity: Low]
Does this unconditionally select MFD_SYSCON without inheriting its hardware dependencies?

When configuring the kernel with COMPILE_TEST enabled on an architecture lacking HAS_IOMEM (such as s390 without PCI or UML without IOMEM), this can trigger Kconfig warnings for unmet direct dependencies and potential build failures.

[Severity: High]
This is a pre-existing issue, but does the regular PHY_QCOM_QMP_PCIE driver have the exact same probe failure vulnerability?

In drivers/phy/qualcomm/Kconfig, config PHY_QCOM_QMP_PCIE lacks a select for MFD_SYSCON:

config PHY_QCOM_QMP_PCIE

	tristate "Qualcomm QMP PCIe PHY Driver"
	depends on PCI || COMPILE_TEST
	select GENERIC_PHY

This driver unconditionally calls syscon_regmap_lookup_by_phandle_args() in drivers/phy/qualcomm/phy-qcom-qmp-pcie.c:qmp_pcie_get_4ln_config():

	tcsr = syscon_regmap_lookup_by_phandle_args(qmp->dev->of_node,
						    "qcom,4ln-config-sel",
						    ARRAY_SIZE(args), args);
	if (IS_ERR(tcsr)) {
		ret = PTR_ERR(tcsr);
		if (ret == -ENOENT)
			return 0;

		dev_err(qmp->dev, "failed to lookup syscon: %d\n", ret);
		return ret;
	}

If MFD_SYSCON is disabled, the stub returns -ENOTSUPP. Since this explicitly checks for -ENOENT but not -ENOTSUPP, wouldn't the probe fail unconditionally and leave the PCIe bus non-functional?

Quoted 3 lines
drivers/phy/qualcomm/Kconfig +0 -0
 	help
 	  Enable this to support the QMP PCIe PHY transceiver that is used
[ ... ]
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Reviewed-by on v1 1/2
#5 lore raw
In reply to David Carlier
Quoted 11 lines · David Carlier

The driver reads the active link mode through syscon_regmap_lookup_by_phandle_args(). Without CONFIG_MFD_SYSCON the stub returning -ENOTSUPP is compiled in instead, so probe fails for every device and no PHY is ever registered.

Nothing in the build catches this: the driver still compiles, and arm64 defconfig happens to enable MFD_SYSCON through an unrelated select.

Fixes 1781be3c8a5d ("phy: qcom: qmp-pcie: Add QMP PCIe Multi-PHY driver")

---

Konrad

Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] phy: qcom: qmp-pcie: Check clock-output-names count in the multi-PHY driver

In reply to David Carlier
Quoted 8 lines · David Carlier

of_property_count_strings() returns a negative errno when the property is missing or malformed. The value was passed straight to devm_kcalloc(), whose overflow check rejected it, turning a device tree problem into a bogus -ENOMEM with no diagnostic.

Fixes 1781be3c8a5d ("phy: qcom: qmp-pcie: Add QMP PCIe Multi-PHY driver")

---

Konrad

reviewer Reviewed-by on v1 1/2
#6 lore raw
In reply to David Carlier
Quoted 10 lines · David Carlier

The driver reads the active link mode through syscon_regmap_lookup_by_phandle_args(). Without CONFIG_MFD_SYSCON the stub returning -ENOTSUPP is compiled in instead, so probe fails for every device and no PHY is ever registered.

Nothing in the build catches this: the driver still compiles, and arm64 defconfig happens to enable MFD_SYSCON through an unrelated select.

Fixes 1781be3c8a5d ("phy: qcom: qmp-pcie: Add QMP PCIe Multi-PHY driver")

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
reviewer Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] phy: qcom: qmp-pcie: Check clock-output-names count in the multi-PHY driver

In reply to David Carlier
Quoted 7 lines · David Carlier

of_property_count_strings() returns a negative errno when the property is missing or malformed. The value was passed straight to devm_kcalloc(), whose overflow check rejected it, turning a device tree problem into a bogus -ENOMEM with no diagnostic.

Fixes 1781be3c8a5d ("phy: qcom: qmp-pcie: Add QMP PCIe Multi-PHY driver")

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
maintainer Applied
#7 lore raw
In reply to David Carlier
Quoted 9 lines · David Carlier

The driver reads the active link mode through syscon_regmap_lookup_by_phandle_args(). Without CONFIG_MFD_SYSCON the stub returning -ENOTSUPP is compiled in instead, so probe fails for every device and no PHY is ever registered.

Nothing in the build catches this: the driver still compiles, and arm64 defconfig happens to enable MFD_SYSCON through an unrelated select.

[...]

Applied, thanks!

[1/2] phy: qcom: qmp-pcie: Select MFD_SYSCON for the multi-PHY driver

      commit: 77a0e6ae5dec54fb6049e3ab88288bc40c81f9fd
[2/2] phy: qcom: qmp-pcie: Check clock-output-names count in the multi-PHY driver
      commit: fb0f0e0e9e5dace7a6d9cde289537980ad35db3d

Best regards,

Signature · 1 line
~Vinod