Skip to contentSkip to conversation

sm8550: Add support for eUSB2 repeater

PATCH Applied Abel Vesa 7 participants 16 messages Feb 8, 2023 – Jun 25, 2024

Subsystems (5)

v5 of 6 Applied Latest is v6 →

lore
Share & tools
lore

Abel Vesa

author
#0 lore raw

v5 cover sm8550: Add support for eUSB2 repeater

This patchset adds support for the eUSB2 repeater found in pmic PM8550B, used along with SM8550. Since there is no dedicated generic framework for eUSB2 repeaters, the most appropriate subsystem to model it is the generic phy. This patchset also adds support for such repeater to the eUSB2 PHY found in SM8550. Basically, the eUSB2 PHY will have its own "phy" which is actually a repeater.

This patchset is based on the following patchset:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* added Krzysztof's R-b tag got patch #1 and A-b tag to patch #3

Changes since v3:
* This time is a normal patchset, rather than an RFC

Changes since v2:
* moved the bindings qcom,spmi-pmic patch before the repeater schema patch in order to avoid the repeater schema validation failure due to phy pattern property not being found in qcom,spmi-pmic schema

Changes since v1:
* the repeater driver is implemented now as a PHY rather than adding a new generic framework for USB repeaters

Abel Vesa (5):
dt-bindings: phy: Add qcom,snps-eusb2-repeater schema file
dt-bindings: mfd: qcom,spmi-pmic: Add pattern property for phy
dt-bindings: phy: qcom,snps-eusb2-phy: Add phys property for the
repeater
phy: qcom: Add QCOM SNPS eUSB2 repeater driver
arm64: dts: qcom: sm8550-mtp: Add eUSB2 repeater node

Neil Armstrong (2):
phy: qcom: phy-qcom-snps-eusb2: Add support for eUSB2 repeater
arm64: dts: qcom: pm8550b: Add eUSB2 repeater node

 .../bindings/mfd/qcom,spmi-pmic.yaml          |   4 +
 .../bindings/phy/qcom,snps-eusb2-phy.yaml     |   5 +
 .../phy/qcom,snps-eusb2-repeater.yaml         |  52 ++++
 arch/arm64/boot/dts/qcom/pm8550b.dtsi         |   6 +
 arch/arm64/boot/dts/qcom/sm8550-mtp.dts       |   7 +
 drivers/phy/qualcomm/Kconfig                  |   9 +
 drivers/phy/qualcomm/Makefile                 |   1 +
 .../phy/qualcomm/phy-qcom-eusb2-repeater.c    | 259 ++++++++++++++++++
 drivers/phy/qualcomm/phy-qcom-snps-eusb2.c    |  19 +-
 9 files changed, 361 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml
 create mode 100644 drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v5 1/7 dt-bindings: phy: Add qcom,snps-eusb2-repeater schema file

The SM8550 SoC uses Synopsis eUSB2 repeater found in PM8550b. Add a dt-binding schema for the new driver.

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* added Krzysztof R-b tag
* added description about what the eUSB repeater does

Changes since v3:
* made this patch the first one in the series to fix the binding check for the 2nd patch.
* dropped the compatible for pmic in the example. This is due to the dependency between this patch and the next one.

 .../phy/qcom,snps-eusb2-repeater.yaml         | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml
Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml new file +52 -0
new file mode 100644
index 000000000000..083fda530b48
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/qcom,snps-eusb2-repeater.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Synopsis eUSB2 to USB 2.0 repeater
+
+maintainers:
+  - Abel Vesa <[email protected]>
+
+description:
+  eUSB2 repeater converts between eUSB2 and USB 2.0 signaling levels and
+  allows a eUSB2 PHY to connect to legacy USB 2.0 products
+
+properties:
+  compatible:
+    const: qcom,pm8550b-eusb2-repeater
+
+  reg:
+    maxItems: 1
+
+  "#phy-cells":
+    const: 0
+
+  vdd18-supply: true
+
+  vdd3-supply: true
+
+required:
+  - compatible
+  - reg
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/spmi/spmi.h>
+
+    pmic@7 {
+      reg = <0x7 SPMI_USID>;
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      pm8550b_eusb2_repeater: phy@fd00 {
+        compatible = "qcom,pm8550b-eusb2-repeater";
+        reg = <0xfd00>;
+        #phy-cells = <0>;
+      };
+    };
+...
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v5 2/7 dt-bindings: mfd: qcom,spmi-pmic: Add pattern property for phy

In reply to Abel Vesa

The phy pattern property will be used for providing eUSB2 repeater functionality. This will be modelled as a Qualcomm PHY driver.

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* made this the second patch rather than the first in the series

 Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +4 -0
index adf88245c409..1e6fadec1301 100644
@@ -135,6 +135,10 @@ patternProperties:
     type: object
     $ref: /schemas/pinctrl/qcom,pmic-gpio.yaml#
 
+  "phy@[0-9a-f]+$":
+    type: object
+    $ref: /schemas/phy/qcom,snps-eusb2-repeater.yaml#
+
   "pon@[0-9a-f]+$":
     type: object
     $ref: /schemas/power/reset/qcom,pon.yaml#
Signature · 1 line
2.34.1
maintainer
#4 lore raw

Re: [PATCH v5 2/7] dt-bindings: mfd: qcom,spmi-pmic: Add pattern property for phy

In reply to Abel Vesa
Quoted 2 lines · Abel Vesa

The phy pattern property will be used for providing eUSB2 repeater functionality. This will be modelled as a Qualcomm PHY driver.

Lee,

Can I get your ack and merge this thru phy tree

Quoted 33 lines

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* made this the second patch rather than the first in the series

 Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +4 -0
index adf88245c409..1e6fadec1301 100644
@@ -135,6 +135,10 @@ patternProperties:
     type: object
     $ref: /schemas/pinctrl/qcom,pmic-gpio.yaml#
 
+  "phy@[0-9a-f]+$":
+    type: object
+    $ref: /schemas/phy/qcom,snps-eusb2-repeater.yaml#
+
   "pon@[0-9a-f]+$":
     type: object
     $ref: /schemas/power/reset/qcom,pon.yaml#
Signature · 1 line
2.34.1
Signature · 1 line
~Vinod
maintainer Acked-by
#5 lore raw

Re: [PATCH v5 2/7] dt-bindings: mfd: qcom,spmi-pmic: Add pattern property for phy

Quoted 7 lines · Vinod Koul
Quoted 2 lines · Abel Vesa

The phy pattern property will be used for providing eUSB2 repeater functionality. This will be modelled as a Qualcomm PHY driver.

Lee,

Can I get your ack and merge this thru phy tree

Quoted 35 lines
Quoted 32 lines

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* made this the second patch rather than the first in the series

 Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +4 -0
index adf88245c409..1e6fadec1301 100644
@@ -135,6 +135,10 @@ patternProperties:
     type: object
     $ref: /schemas/pinctrl/qcom,pmic-gpio.yaml#
 
+  "phy@[0-9a-f]+$":
+    type: object
+    $ref: /schemas/phy/qcom,snps-eusb2-repeater.yaml#
+
   "pon@[0-9a-f]+$":
     type: object
     $ref: /schemas/power/reset/qcom,pon.yaml#
Signature · 1 line
2.34.1
Signature · 1 line
~Vinod
Signature · 1 line
Lee Jones [李琼斯]
author
#6 lore raw

PATCH v5 3/7 dt-bindings: phy: qcom,snps-eusb2-phy: Add phys property for the repeater

In reply to Abel Vesa

The phys property is used for allowing the eusb2 to interface with the repeater, which is modelled as a phy driver.

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* added Krzysztof's A-b tag

Changes since v3:
* dropped the phy-names property and changed the commit message accordingly

 .../devicetree/bindings/phy/qcom,snps-eusb2-phy.yaml         | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/phy/qcom,snps-eusb2-phy.yaml +5 -0
index de72577e34a4..c53bab107b6d 100644
@@ -33,6 +33,11 @@ properties:
   resets:
     maxItems: 1
 
+  phys:
+    maxItems: 1
+    description:
+      Phandle to eUSB2 to USB 2.0 repeater
+
   vdd-supply:
     description:
       Phandle to 0.88V regulator supply to PHY digital circuit.
Signature · 7 lines
2.34.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author
#7 lore raw

PATCH v5 4/7 phy: qcom: Add QCOM SNPS eUSB2 repeater driver

In reply to Abel Vesa

PM8550B contains a eUSB2 repeater used for making the eUSB2 from SM8550 USB 2.0 compliant. This can be modelled SW-wise as a Phy. So add a new phy driver for it.

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* fixed all indentation issues and dropped a few blank lines to pass checkpatch
* dropped shift defines as they were not used
* dropped the repeater_mode as it was not used
* dropped the of_node_get and of_node_put for of_node
* dropped the comment related to regulators in eusb2_repeater_cfg, like Vinod suggested
* dropped the initialization of ret in eusb2_repeater_init

 drivers/phy/qualcomm/Kconfig                  |   9 +
 drivers/phy/qualcomm/Makefile                 |   1 +
 .../phy/qualcomm/phy-qcom-eusb2-repeater.c    | 259 ++++++++++++++++++
 3 files changed, 269 insertions(+)
 create mode 100644 drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c
drivers/phy/qualcomm/Kconfig +9 -0
index 513322cdf83c..4850d48f31fa 100644
@@ -121,6 +121,15 @@ config PHY_QCOM_SNPS_EUSB2
 	  chipsets. The PHY is paired with a Synopsys DWC3 USB controller
 	  on Qualcomm SOCs.
 
+config PHY_QCOM_EUSB2_REPEATER
+	tristate "Qualcomm SNPS eUSB2 Repeater Driver"
+	depends on OF && (ARCH_QCOM || COMPILE_TEST)
+	select GENERIC_PHY
+	help
+	  Enable support for the USB high-speed SNPS eUSB2 repeater on Qualcomm
+	  PMICs. The repeater is paired with a Synopsys eUSB2 Phy
+	  on Qualcomm SOCs.
+
 config PHY_QCOM_USB_HS
 	tristate "Qualcomm USB HS PHY module"
 	depends on USB_ULPI_BUS
drivers/phy/qualcomm/Makefile +1 -0
index b2c01665622b..de3dc9ccf067 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_PHY_QCOM_QMP_USB)		+= phy-qcom-qmp-usb.o
 
 obj-$(CONFIG_PHY_QCOM_QUSB2)		+= phy-qcom-qusb2.o
 obj-$(CONFIG_PHY_QCOM_SNPS_EUSB2)	+= phy-qcom-snps-eusb2.o
+obj-$(CONFIG_PHY_QCOM_EUSB2_REPEATER)	+= phy-qcom-eusb2-repeater.o
 obj-$(CONFIG_PHY_QCOM_USB_HS) 		+= phy-qcom-usb-hs.o
 obj-$(CONFIG_PHY_QCOM_USB_HSIC) 	+= phy-qcom-usb-hsic.o
 obj-$(CONFIG_PHY_QCOM_USB_HS_28NM)	+= phy-qcom-usb-hs-28nm.o
drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c new file +259 -0

259 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#8 lore raw

PATCH v5 5/7 phy: qcom: phy-qcom-snps-eusb2: Add support for eUSB2 repeater

In reply to Abel Vesa

From: Neil Armstrong <[email protected]>

For USB 2.0 compliance, eUSB2 needs a repeater. The PHY needs to initialize and reset it. So add repeater support

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* none

 drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-snps-eusb2.c +18 -1
index 40a421cf3dd9..ca1cfa53d90d 100644
@@ -128,6 +128,8 @@ struct qcom_snps_eusb2_hsphy {
 	struct regulator_bulk_data vregs[EUSB2_NUM_VREGS];
 
 	enum phy_mode mode;
+
+	struct phy *repeater;
 };
 
 static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode)
@@ -136,7 +138,7 @@ static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int
 
 	phy->mode = mode;
 
-	return 0;
+	return phy_set_mode_ext(phy->repeater, mode, submode);
 }
 
 static void qcom_snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset,
@@ -234,6 +236,12 @@ static int qcom_snps_eusb2_hsphy_init(struct phy *p)
 	if (ret)
 		return ret;
 
+	ret = phy_init(phy->repeater);
+	if (ret) {
+		dev_err(&p->dev, "repeater init failed. %d\n", ret);
+		goto disable_vreg;
+	}
+
 	ret = clk_prepare_enable(phy->ref_clk);
 	if (ret) {
 		dev_err(&p->dev, "failed to enable ref clock, %d\n", ret);
@@ -341,6 +349,8 @@ static int qcom_snps_eusb2_hsphy_exit(struct phy *p)
 
 	regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs);
 
+	phy_exit(phy->repeater);
+
 	return 0;
 }
 
@@ -354,6 +364,7 @@ static const struct phy_ops qcom_snps_eusb2_hsphy_ops = {
 static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
 	struct qcom_snps_eusb2_hsphy *phy;
 	struct phy_provider *phy_provider;
 	struct phy *generic_phy;
@@ -385,6 +396,12 @@ static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(dev, ret,
 				     "failed to get regulator supplies\n");
+
+	phy->repeater = devm_of_phy_get_by_index(dev, np, 0);
+	if (IS_ERR(phy->repeater))
+		return dev_err_probe(dev, PTR_ERR(phy->repeater),
+				     "failed to get repeater\n");
+
 	generic_phy = devm_phy_create(dev, NULL, &qcom_snps_eusb2_hsphy_ops);
 	if (IS_ERR(generic_phy)) {
 		dev_err(dev, "failed to create phy %d\n", ret);
Signature · 1 line
2.34.1
author
#9 lore raw

PATCH v5 6/7 arm64: dts: qcom: pm8550b: Add eUSB2 repeater node

In reply to Abel Vesa

From: Neil Armstrong <[email protected]>

Add nodes for the eUSB2 repeater found on the pm8550b SPMI PMIC.

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* none

 arch/arm64/boot/dts/qcom/pm8550b.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/pm8550b.dtsi +6 -0
index 16bcfb64d735..72609f31c890 100644
@@ -55,5 +55,11 @@ pm8550b_gpios: gpio@8800 {
 			interrupt-controller;
 			#interrupt-cells = <2>;
 		};
+
+		pm8550b_eusb2_repeater: phy@fd00 {
+			compatible = "qcom,pm8550b-eusb2-repeater";
+			reg = <0xfd00>;
+			#phy-cells = <0>;
+		};
 	};
 };
Signature · 7 lines
2.34.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author
#10 lore raw

PATCH v5 7/7 arm64: dts: qcom: sm8550-mtp: Add eUSB2 repeater node

In reply to Abel Vesa

Add the PMIC eUSB2 repeater node and add the usb-repeater property to the eUSB2 PHY to allow it to be controlled by the PHY driver.

---

The v4 is here:
https://lore.kernel.org/all/[email protected]/

Changes since v4:
* none

Changes since v3:
* Dropped the phy-names property from usb_1_hsphy, like Dmitry suggested

 arch/arm64/boot/dts/qcom/sm8550-mtp.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/qcom/sm8550-mtp.dts +7 -0
index 56aab7cafcbc..6b6ec0fe5e5e 100644
@@ -457,6 +457,11 @@ sdc2_card_det_n: sdc2-card-det-state {
 	};
 };
 
+&pm8550b_eusb2_repeater {
+	vdd18-supply = <&vreg_l15b_1p8>;
+	vdd3-supply = <&vreg_l5b_3p1>;
+};
+
 &qupv3_id_0 {
 	status = "okay";
 };
@@ -563,6 +568,8 @@ &usb_1_hsphy {
 	vdd-supply = <&vreg_l1e_0p88>;
 	vdda12-supply = <&vreg_l3e_1p2>;
 
+	phys = <&pm8550b_eusb2_repeater>;
+
 	status = "okay";
 };
 
Signature · 7 lines
2.34.1


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer
#11 lore raw
In reply to Abel Vesa
Quoted 6 lines · Abel Vesa

This patchset adds support for the eUSB2 repeater found in pmic PM8550B, used along with SM8550. Since there is no dedicated generic framework for eUSB2 repeaters, the most appropriate subsystem to model it is the generic phy. This patchset also adds support for such repeater to the eUSB2 PHY found in SM8550. Basically, the eUSB2 PHY will have its own "phy" which is actually a repeater.

Applied phy patches, thanks

Signature · 1 line
~Vinod
maintainer Applied
#12 lore raw

Re: (subset) [PATCH v5 0/7] sm8550: Add support for eUSB2 repeater

In reply to Abel Vesa
Quoted 8 lines · Abel Vesa

This patchset adds support for the eUSB2 repeater found in pmic PM8550B, used along with SM8550. Since there is no dedicated generic framework for eUSB2 repeaters, the most appropriate subsystem to model it is the generic phy. This patchset also adds support for such repeater to the eUSB2 PHY found in SM8550. Basically, the eUSB2 PHY will have its own "phy" which is actually a repeater.

[...]

Applied, thanks!

[6/7] arm64: dts: qcom: pm8550b: Add eUSB2 repeater node

      commit: fdaa922585f4474c88fbfaa129f8114f38200660
[7/7] arm64: dts: qcom: sm8550-mtp: Add eUSB2 repeater node
      commit: 749078e38e1ee28357e8fdcd4eac382a465bd1e7

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>
#13 lore raw

Lockdep broken on x1e80100 (was: Re: [PATCH v5 0/7] sm8550: Add support for eUSB2 repeater)

In reply to Abel Vesa
Quoted 6 lines · Abel Vesa

This patchset adds support for the eUSB2 repeater found in pmic PM8550B, used along with SM8550. Since there is no dedicated generic framework for eUSB2 repeaters, the most appropriate subsystem to model it is the generic phy. This patchset also adds support for such repeater to the eUSB2 PHY found in SM8550. Basically, the eUSB2 PHY will have its own "phy" which is actually a repeater.

The decision to model the repeater as a PHY unfortunately breaks lockdep as you now have functions like phy_init() calling phy_init() for a second PHY (the repeater, see splat below).

As long as the locks are always taken in the same order there should be no risk for a deadlock, but can you please verify that and add the missing lockdep annotation so that lockdep can be used on platforms like x1e80100 (e.g. to prevent further locking issues from being introduced)?

Johan

[    8.613248] ============================================
[    8.669073] WARNING: possible recursive locking detected
[    8.669074] 6.10.0-rc5 #122 Not tainted
[    8.669075] --------------------------------------------
[    8.669075] kworker/u50:0/77 is trying to acquire lock:
[    8.669076] ffff5cae8733ecf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669087]
               but task is already holding lock:
[    8.669088] ffff5cae8a056cf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669092]
               other info that might help us debug this:
[    8.669092]  Possible unsafe locking scenario:
[    8.669093]        CPU0
[    8.669093]        ----
[    8.669094]   lock(&phy->mutex);
[    8.669095]   lock(&phy->mutex);
[    8.669097]
                *** DEADLOCK ***
[    8.669097]  May be due to missing lock nesting notation
[    8.669097] 4 locks held by kworker/u50:0/77:
[    8.669099]  #0: ffff5cae80010948 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x1a4/0x638
[    8.669108]  #1: ffff800080333de0 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work+0x1cc/0x638
[    8.669112]  #2: ffff5cae854038f8 (&dev->mutex){....}-{3:3}, at: __device_attach+0x38/0x1d4
[    8.669117]  #3: ffff5cae8a056cf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669121]
               stack backtrace:
[    8.669122] CPU: 9 PID: 77 Comm: kworker/u50:0 Not tainted 6.10.0-rc5 #122
[    8.669124] Hardware name: Qualcomm CRD, BIOS 6.0.231221.BOOT.MXF.2.4-00348.1-HAMOA-1 12/21/2023
[    8.669125] Workqueue: events_unbound deferred_probe_work_func
[    8.669128] Call trace:
[    8.669129]  dump_backtrace+0x9c/0x11c
[    8.870384]  show_stack+0x18/0x24
[    8.870386]  dump_stack_lvl+0x90/0xd0
[    8.870391]  dump_stack+0x18/0x24
[    8.870393]  print_deadlock_bug+0x25c/0x348
[    8.870396]  __lock_acquire+0x10a4/0x2064
[    8.870399]  lock_acquire.part.0+0xc8/0x20c
[    8.870401]  lock_acquire+0x68/0x84
[    8.870403]  __mutex_lock+0x98/0x428
[    8.870407]  mutex_lock_nested+0x24/0x30
[    8.870410]  phy_init+0x4c/0x12c
[    8.870412]  qcom_snps_eusb2_hsphy_init+0x54/0x420 [phy_qcom_snps_eusb2]
[    8.870416]  phy_init+0xe0/0x12c
[    8.870418]  dwc3_core_init+0x484/0x1214
[    8.870421]  dwc3_probe+0xe54/0x171c
[    8.870424]  platform_probe+0x68/0xd8
[    8.870426]  really_probe+0xc0/0x388
[    8.870427]  __driver_probe_device+0x7c/0x160
[    8.870429]  driver_probe_device+0x40/0x114
[    8.870430]  __device_attach_driver+0xbc/0x158
[    8.870432]  bus_for_each_drv+0x84/0xe0
[    8.870433]  __device_attach+0xa8/0x1d4
[    8.870435]  device_initial_probe+0x14/0x20
[    8.870436]  bus_probe_device+0xb0/0xb4
[    8.870437]  deferred_probe_work_func+0xa0/0xf4
[    8.870439]  process_one_work+0x224/0x638
[    8.870441]  worker_thread+0x268/0x3a8
[    8.870442]  kthread+0x124/0x128
[    8.870443]  ret_from_fork+0x10/0x20
author
#14 lore raw

Re: Lockdep broken on x1e80100 (was: Re: [PATCH v5 0/7] sm8550: Add support for eUSB2 repeater)

Quoted 8 lines · Johan Hovold
Quoted 6 lines · Abel Vesa

This patchset adds support for the eUSB2 repeater found in pmic PM8550B, used along with SM8550. Since there is no dedicated generic framework for eUSB2 repeaters, the most appropriate subsystem to model it is the generic phy. This patchset also adds support for such repeater to the eUSB2 PHY found in SM8550. Basically, the eUSB2 PHY will have its own "phy" which is actually a repeater.

Quoted 4 lines

The decision to model the repeater as a PHY unfortunately breaks lockdep as you now have functions like phy_init() calling phy_init() for a second PHY (the repeater, see splat below).

This was reported by Bjorn off-list a couple of months ago. I did check it then and the order is perfectly fine. The solution here should be to use mutex_lock_nested in the PHY framework. This would allow supporting chain-linked PHYs. The possibility of moving out the repeater out of PHY was also discussed. Unfortunately, I didn't have the bandwidth to circle back and properly investigate and fix it.

Quoted 70 lines

As long as the locks are always taken in the same order there should be no risk for a deadlock, but can you please verify that and add the missing lockdep annotation so that lockdep can be used on platforms like x1e80100 (e.g. to prevent further locking issues from being introduced)?

Johan

[    8.613248] ============================================
[    8.669073] WARNING: possible recursive locking detected
[    8.669074] 6.10.0-rc5 #122 Not tainted
[    8.669075] --------------------------------------------
[    8.669075] kworker/u50:0/77 is trying to acquire lock:
[    8.669076] ffff5cae8733ecf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669087]
               but task is already holding lock:
[    8.669088] ffff5cae8a056cf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669092]
               other info that might help us debug this:
[    8.669092]  Possible unsafe locking scenario:
[    8.669093]        CPU0
[    8.669093]        ----
[    8.669094]   lock(&phy->mutex);
[    8.669095]   lock(&phy->mutex);
[    8.669097]
                *** DEADLOCK ***
[    8.669097]  May be due to missing lock nesting notation
[    8.669097] 4 locks held by kworker/u50:0/77:
[    8.669099]  #0: ffff5cae80010948 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x1a4/0x638
[    8.669108]  #1: ffff800080333de0 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work+0x1cc/0x638
[    8.669112]  #2: ffff5cae854038f8 (&dev->mutex){....}-{3:3}, at: __device_attach+0x38/0x1d4
[    8.669117]  #3: ffff5cae8a056cf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669121]
               stack backtrace:
[    8.669122] CPU: 9 PID: 77 Comm: kworker/u50:0 Not tainted 6.10.0-rc5 #122
[    8.669124] Hardware name: Qualcomm CRD, BIOS 6.0.231221.BOOT.MXF.2.4-00348.1-HAMOA-1 12/21/2023
[    8.669125] Workqueue: events_unbound deferred_probe_work_func
[    8.669128] Call trace:
[    8.669129]  dump_backtrace+0x9c/0x11c
[    8.870384]  show_stack+0x18/0x24
[    8.870386]  dump_stack_lvl+0x90/0xd0
[    8.870391]  dump_stack+0x18/0x24
[    8.870393]  print_deadlock_bug+0x25c/0x348
[    8.870396]  __lock_acquire+0x10a4/0x2064
[    8.870399]  lock_acquire.part.0+0xc8/0x20c
[    8.870401]  lock_acquire+0x68/0x84
[    8.870403]  __mutex_lock+0x98/0x428
[    8.870407]  mutex_lock_nested+0x24/0x30
[    8.870410]  phy_init+0x4c/0x12c
[    8.870412]  qcom_snps_eusb2_hsphy_init+0x54/0x420 [phy_qcom_snps_eusb2]
[    8.870416]  phy_init+0xe0/0x12c
[    8.870418]  dwc3_core_init+0x484/0x1214
[    8.870421]  dwc3_probe+0xe54/0x171c
[    8.870424]  platform_probe+0x68/0xd8
[    8.870426]  really_probe+0xc0/0x388
[    8.870427]  __driver_probe_device+0x7c/0x160
[    8.870429]  driver_probe_device+0x40/0x114
[    8.870430]  __device_attach_driver+0xbc/0x158
[    8.870432]  bus_for_each_drv+0x84/0xe0
[    8.870433]  __device_attach+0xa8/0x1d4
[    8.870435]  device_initial_probe+0x14/0x20
[    8.870436]  bus_probe_device+0xb0/0xb4
[    8.870437]  deferred_probe_work_func+0xa0/0xf4
[    8.870439]  process_one_work+0x224/0x638
[    8.870441]  worker_thread+0x268/0x3a8
[    8.870442]  kthread+0x124/0x128
[    8.870443]  ret_from_fork+0x10/0x20
#15 lore raw

Re: Lockdep broken on x1e80100

Quoted 14 lines · Abel Vesa
Quoted 8 lines · Johan Hovold
Quoted 6 lines · Abel Vesa

This patchset adds support for the eUSB2 repeater found in pmic PM8550B, used along with SM8550. Since there is no dedicated generic framework for eUSB2 repeaters, the most appropriate subsystem to model it is the generic phy. This patchset also adds support for such repeater to the eUSB2 PHY found in SM8550. Basically, the eUSB2 PHY will have its own "phy" which is actually a repeater.

Quoted 4 lines

The decision to model the repeater as a PHY unfortunately breaks lockdep as you now have functions like phy_init() calling phy_init() for a second PHY (the repeater, see splat below).

Quoted 6 lines

This was reported by Bjorn off-list a couple of months ago. I did check it then and the order is perfectly fine. The solution here should be to use mutex_lock_nested in the PHY framework. This would allow supporting chain-linked PHYs. The possibility of moving out the repeater out of PHY was also discussed. Unfortunately, I didn't have the bandwidth to circle back and properly investigate and fix it.

Well technically it's a PHY, and moving out from PHY will basically duplicate the PHY core code... so we should rather make sure we can call phy code from phy callbacks safely.

Neil

Quoted 71 lines
Quoted 71 lines

As long as the locks are always taken in the same order there should be no risk for a deadlock, but can you please verify that and add the missing lockdep annotation so that lockdep can be used on platforms like x1e80100 (e.g. to prevent further locking issues from being introduced)?

Johan

[    8.613248] ============================================
[    8.669073] WARNING: possible recursive locking detected
[    8.669074] 6.10.0-rc5 #122 Not tainted
[    8.669075] --------------------------------------------
[    8.669075] kworker/u50:0/77 is trying to acquire lock:
[    8.669076] ffff5cae8733ecf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669087]
                but task is already holding lock:
[    8.669088] ffff5cae8a056cf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669092]
                other info that might help us debug this:
[    8.669092]  Possible unsafe locking scenario:
[    8.669093]        CPU0
[    8.669093]        ----
[    8.669094]   lock(&phy->mutex);
[    8.669095]   lock(&phy->mutex);
[    8.669097]
                 *** DEADLOCK ***
[    8.669097]  May be due to missing lock nesting notation
[    8.669097] 4 locks held by kworker/u50:0/77:
[    8.669099]  #0: ffff5cae80010948 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work+0x1a4/0x638
[    8.669108]  #1: ffff800080333de0 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work+0x1cc/0x638
[    8.669112]  #2: ffff5cae854038f8 (&dev->mutex){....}-{3:3}, at: __device_attach+0x38/0x1d4
[    8.669117]  #3: ffff5cae8a056cf8 (&phy->mutex){+.+.}-{3:3}, at: phy_init+0x4c/0x12c
[    8.669121]
                stack backtrace:
[    8.669122] CPU: 9 PID: 77 Comm: kworker/u50:0 Not tainted 6.10.0-rc5 #122
[    8.669124] Hardware name: Qualcomm CRD, BIOS 6.0.231221.BOOT.MXF.2.4-00348.1-HAMOA-1 12/21/2023
[    8.669125] Workqueue: events_unbound deferred_probe_work_func
[    8.669128] Call trace:
[    8.669129]  dump_backtrace+0x9c/0x11c
[    8.870384]  show_stack+0x18/0x24
[    8.870386]  dump_stack_lvl+0x90/0xd0
[    8.870391]  dump_stack+0x18/0x24
[    8.870393]  print_deadlock_bug+0x25c/0x348
[    8.870396]  __lock_acquire+0x10a4/0x2064
[    8.870399]  lock_acquire.part.0+0xc8/0x20c
[    8.870401]  lock_acquire+0x68/0x84
[    8.870403]  __mutex_lock+0x98/0x428
[    8.870407]  mutex_lock_nested+0x24/0x30
[    8.870410]  phy_init+0x4c/0x12c
[    8.870412]  qcom_snps_eusb2_hsphy_init+0x54/0x420 [phy_qcom_snps_eusb2]
[    8.870416]  phy_init+0xe0/0x12c
[    8.870418]  dwc3_core_init+0x484/0x1214
[    8.870421]  dwc3_probe+0xe54/0x171c
[    8.870424]  platform_probe+0x68/0xd8
[    8.870426]  really_probe+0xc0/0x388
[    8.870427]  __driver_probe_device+0x7c/0x160
[    8.870429]  driver_probe_device+0x40/0x114
[    8.870430]  __device_attach_driver+0xbc/0x158
[    8.870432]  bus_for_each_drv+0x84/0xe0
[    8.870433]  __device_attach+0xa8/0x1d4
[    8.870435]  device_initial_probe+0x14/0x20
[    8.870436]  bus_probe_device+0xb0/0xb4
[    8.870437]  deferred_probe_work_func+0xa0/0xf4
[    8.870439]  process_one_work+0x224/0x638
[    8.870441]  worker_thread+0x268/0x3a8
[    8.870442]  kthread+0x124/0x128
[    8.870443]  ret_from_fork+0x10/0x20