phy: qcom-qmp: more fixes and cleanups
Subsystems (2)
PATCH 6/11 phy: qcom-qmp-usb: fix memleak on probe deferral
In reply to Johan HovoldSwitch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind.
Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 32 +++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +17 -15
@@ -2627,17 +2627,17 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id,* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =of_iomap (np,0 ); -if (!qphy->tx) -return -ENOMEM ; + qphy->tx =devm_of_iomap (dev, np,0 ,NULL ); +if (IS_ERR (qphy->tx)) +return PTR_ERR (qphy->tx); - qphy->rx =of_iomap (np,1 ); -if (!qphy->rx) -return -ENOMEM ; + qphy->rx =devm_of_iomap (dev, np,1 ,NULL ); +if (IS_ERR (qphy->rx)) +return PTR_ERR (qphy->rx); - qphy->pcs =of_iomap (np,2 ); -if (!qphy->pcs) -return -ENOMEM ; + qphy->pcs =devm_of_iomap (dev, np,2 ,NULL ); +if (IS_ERR (qphy->pcs)) +return PTR_ERR (qphy->pcs);if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset;
@@ -2649,9 +2649,9 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id,* offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 =of_iomap (np,3 ); - qphy->rx2 =of_iomap (np,4 ); -if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) {dev_warn (dev,"Underspecified device tree, falling back to legacy register regions\n" );
@@ -2661,15 +2661,17 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; }else { - qphy->pcs_misc =of_iomap (np,5 ); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); } }else { - qphy->pcs_misc =of_iomap (np,3 ); + qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); } -if (!qphy->pcs_misc) +if (IS_ERR (qphy->pcs_misc)) {dev_vdbg (dev,"PHY pcs_misc-reg not used\n" ); + qphy->pcs_misc =NULL ; + } qphy->pipe_clk =devm_get_clk_from_child (dev, np,NULL );if (IS_ERR (qphy->pipe_clk)) {
Signature · 1 line
2.35.1
PATCH 4/11 phy: qcom-qmp-combo: fix memleak on probe deferral
In reply to Johan HovoldSwitch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind.
Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +17 -15
@@ -2714,17 +2714,17 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id,* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =of_iomap (np,0 ); -if (!qphy->tx) -return -ENOMEM ; + qphy->tx =devm_of_iomap (dev, np,0 ,NULL ); +if (IS_ERR (qphy->tx)) +return PTR_ERR (qphy->tx); - qphy->rx =of_iomap (np,1 ); -if (!qphy->rx) -return -ENOMEM ; + qphy->rx =devm_of_iomap (dev, np,1 ,NULL ); +if (IS_ERR (qphy->rx)) +return PTR_ERR (qphy->rx); - qphy->pcs =of_iomap (np,2 ); -if (!qphy->pcs) -return -ENOMEM ; + qphy->pcs =devm_of_iomap (dev, np,2 ,NULL ); +if (IS_ERR (qphy->pcs)) +return PTR_ERR (qphy->pcs);if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset;
@@ -2736,9 +2736,9 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id,* offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 =of_iomap (np,3 ); - qphy->rx2 =of_iomap (np,4 ); -if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) {dev_warn (dev,"Underspecified device tree, falling back to legacy register regions\n" );
@@ -2748,15 +2748,17 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; }else { - qphy->pcs_misc =of_iomap (np,5 ); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); } }else { - qphy->pcs_misc =of_iomap (np,3 ); + qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); } -if (!qphy->pcs_misc) +if (IS_ERR (qphy->pcs_misc)) {dev_vdbg (dev,"PHY pcs_misc-reg not used\n" ); + qphy->pcs_misc =NULL ; + }/* * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3
Signature · 1 line
2.35.1
PATCH 3/11 phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral
In reply to Johan HovoldSwitch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind.
Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory.
--- .../phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +11 -12
@@ -796,21 +796,20 @@ static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, i* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =of_iomap (np,0 ); -if (!qphy->tx) -return -ENOMEM ; - - qphy->rx =of_iomap (np,1 ); -if (!qphy->rx) -return -ENOMEM ; + qphy->tx =devm_of_iomap (dev, np,0 ,NULL ); +if (IS_ERR (qphy->tx)) +return PTR_ERR (qphy->tx); - qphy->pcs =of_iomap (np,2 ); -if (!qphy->pcs) -return -ENOMEM ; + qphy->rx =devm_of_iomap (dev, np,1 ,NULL ); +if (IS_ERR (qphy->rx)) +return PTR_ERR (qphy->rx); - qphy->pcs_misc =of_iomap (np,3 ); + qphy->pcs =devm_of_iomap (dev, np,2 ,NULL ); +if (IS_ERR (qphy->pcs)) +return PTR_ERR (qphy->pcs); -if (!qphy->pcs_misc) + qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); +if (IS_ERR (qphy->pcs_misc))dev_vdbg (dev,"PHY pcs_misc-reg not used\n" ); qphy->pipe_clk =devm_get_clk_from_child (dev, np,NULL );
Signature · 1 line
2.35.1
PATCH 5/11 phy: qcom-qmp-ufs: fix memleak on probe deferral
In reply to Johan HovoldSwitch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind.
Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory.
--- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +15 -15
@@ -1125,17 +1125,17 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id,* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =of_iomap (np,0 ); -if (!qphy->tx) -return -ENOMEM ; + qphy->tx =devm_of_iomap (dev, np,0 ,NULL ); +if (IS_ERR (qphy->tx)) +return PTR_ERR (qphy->tx); - qphy->rx =of_iomap (np,1 ); -if (!qphy->rx) -return -ENOMEM ; + qphy->rx =devm_of_iomap (dev, np,1 ,NULL ); +if (IS_ERR (qphy->rx)) +return PTR_ERR (qphy->rx); - qphy->pcs =of_iomap (np,2 ); -if (!qphy->pcs) -return -ENOMEM ; + qphy->pcs =devm_of_iomap (dev, np,2 ,NULL ); +if (IS_ERR (qphy->pcs)) +return PTR_ERR (qphy->pcs);/* * If this is a dual-lane PHY, then there should be registers for the
@@ -1144,9 +1144,9 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id,* offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 =of_iomap (np,3 ); - qphy->rx2 =of_iomap (np,4 ); -if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) {dev_warn (dev,"Underspecified device tree, falling back to legacy register regions\n" );
@@ -1156,14 +1156,14 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; }else { - qphy->pcs_misc =of_iomap (np,5 ); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); } }else { - qphy->pcs_misc =of_iomap (np,3 ); + qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); } -if (!qphy->pcs_misc) +if (IS_ERR (qphy->pcs_misc))dev_vdbg (dev,"PHY pcs_misc-reg not used\n" ); generic_phy =devm_phy_create (dev, np, &qcom_qmp_ufs_ops);
Signature · 1 line
2.35.1
PATCH 10/11 phy: qcom-qmp-ufs: drop legacy DT workaround
In reply to Johan HovoldCommit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs.
At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy" and they had been added to the binding less than six months before the binding was fixed.
Presumably no one is using four-year old SDM845 dtbs with mainline anymore so drop the workaround for malformed devicetrees. In the unlikely event that anyone complains, we can consider reverting.
--- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 27 ++++++------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +6 -21
@@ -38,9 +38,6 @@#define PHY_INIT_COMPLETE_TIMEOUT 10000 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 -struct qmp_phy_init_tbl {unsigned int offset;unsigned int val;
@@ -1137,28 +1134,16 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id,if (IS_ERR (qphy->pcs))return PTR_ERR (qphy->pcs); -/* -* If this is a dual-lane PHY, then there should be registers for the -* second lane. Some old device trees did not specify this, so fall -* back to old legacy behavior of assuming they can be reached at an -* offset from the first lane. -*/ if (cfg->is_dual_lane_phy) { qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); - qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); -if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) { -dev_warn (dev, -"Underspecified device tree, falling back to legacy register regions\n" ); +if (IS_ERR (qphy->tx2)) +return PTR_ERR (qphy->tx2); -/* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx +QMP_PHY_LEGACY_LANE_STRIDE ; - qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; - - }else { - qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); - } + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->rx2)) +return PTR_ERR (qphy->rx2); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); }else { qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); }
Signature · 1 line
2.35.1
PATCH 1/11 phy: qcom-qmp-pcie: add pcs_misc sanity check
In reply to Johan HovoldMake sure that the (otherwise) optional pcs_misc IO region has been provided in case the configuration specifies a corresponding initialisation table to avoid crashing with malformed devicetrees.
Note that the related debug message is now superfluous as the region is only used when the configuration has a pcs_misc table.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +4 -2
@@ -2300,8 +2300,10 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) qphy->pcs_misc = qphy->pcs + 0x400; -if (!qphy->pcs_misc) -dev_vdbg (dev,"PHY pcs_misc-reg not used\n" ); +if (!qphy->pcs_misc) { +if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) +return -EINVAL ; + } qphy->pipe_clk =devm_get_clk_from_child (dev, np,NULL );if (IS_ERR (qphy->pipe_clk)) {
Signature · 1 line
2.35.1
PATCH 2/11 phy: qcom-qmp-pcie: fix memleak on probe deferral
In reply to Johan HovoldSwitch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind.
Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +17 -17
@@ -2258,17 +2258,17 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =of_iomap (np,0 ); -if (!qphy->tx) -return -ENOMEM ; + qphy->tx =devm_of_iomap (dev, np,0 ,NULL ); +if (IS_ERR (qphy->tx)) +return PTR_ERR (qphy->tx); - qphy->rx =of_iomap (np,1 ); -if (!qphy->rx) -return -ENOMEM ; + qphy->rx =devm_of_iomap (dev, np,1 ,NULL ); +if (IS_ERR (qphy->rx)) +return PTR_ERR (qphy->rx); - qphy->pcs =of_iomap (np,2 ); -if (!qphy->pcs) -return -ENOMEM ; + qphy->pcs =devm_of_iomap (dev, np,2 ,NULL ); +if (IS_ERR (qphy->pcs)) +return PTR_ERR (qphy->pcs);/* * If this is a dual-lane PHY, then there should be registers for the
@@ -2277,9 +2277,9 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,* offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 =of_iomap (np,3 ); - qphy->rx2 =of_iomap (np,4 ); -if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) {dev_warn (dev,"Underspecified device tree, falling back to legacy register regions\n" );
@@ -2289,20 +2289,20 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; }else { - qphy->pcs_misc =of_iomap (np,5 ); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); } }else { - qphy->pcs_misc =of_iomap (np,3 ); + qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); } -if (!qphy->pcs_misc && +if (IS_ERR (qphy->pcs_misc) &&of_device_is_compatible (dev->of_node,"qcom,ipq6018-qmp-pcie-phy" )) qphy->pcs_misc = qphy->pcs +0x400 ; -if (!qphy->pcs_misc) { +if (IS_ERR (qphy->pcs_misc)) {if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) -return -EINVAL ; +return PTR_ERR (qphy->pcs_misc); } qphy->pipe_clk =devm_get_clk_from_child (dev, np,NULL );
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
cover phy: qcom-qmp: more fixes and cleanups
Here's the next set of QMP PHY cleanups including some non-critical fixes of tiny memory leaks on probe deferral (I didn't add a stable tag for any of them on purpose).
Note that the UFS PHY driver does not use the pcs_misc region either currently, but I decided to leave the register mapping code in as, unlike for msm8996, the bindings do include this region.
These apply on top of the previous clean up series, which has been reviewed by Dmitry and is ready to be merged (apart from possibly a tiny fixup of the last patch):
https://lore.kernel.org/all/[email protected]/
Johan
Johan Hovold (11):
phy: qcom-qmp-pcie: add pcs_misc sanity check
phy: qcom-qmp-pcie: fix memleak on probe deferral
phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral
phy: qcom-qmp-combo: fix memleak on probe deferral
phy: qcom-qmp-ufs: fix memleak on probe deferral
phy: qcom-qmp-usb: fix memleak on probe deferral
phy: qcom-qmp-pcie-msm8996: drop unused pcs_misc handling
phy: qcom-qmp-pcie: drop unused legacy DT workaround
phy: qcom-qmp-combo: drop unused legacy DT workaround
phy: qcom-qmp-ufs: drop legacy DT workaround
phy: qcom-qmp-usb: drop legacy DT workaround
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 53 +++++++---------- .../phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 33 +++-------- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 59 ++++++++----------- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 53 ++++++----------- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 55 +++++++---------- 5 files changed, 92 insertions(+), 161 deletions(-)
Signature · 1 line
2.35.1
PATCH 8/11 phy: qcom-qmp-pcie: drop unused legacy DT workaround
Commit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs.
At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy", neither of which is a PCIe PHY.
Drop the workaround for malformed devicetrees, which should no longer be needed since the QMP driver split.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 27 ++++++------------------ 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +6 -21
@@ -38,9 +38,6 @@#define PHY_INIT_COMPLETE_TIMEOUT 10000 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 -struct qmp_phy_init_tbl {unsigned int offset;unsigned int val;
@@ -2270,28 +2267,16 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id,if (IS_ERR (qphy->pcs))return PTR_ERR (qphy->pcs); -/* -* If this is a dual-lane PHY, then there should be registers for the -* second lane. Some old device trees did not specify this, so fall -* back to old legacy behavior of assuming they can be reached at an -* offset from the first lane. -*/ if (cfg->is_dual_lane_phy) { qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); - qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); -if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) { -dev_warn (dev, -"Underspecified device tree, falling back to legacy register regions\n" ); +if (IS_ERR (qphy->tx2)) +return PTR_ERR (qphy->tx2); -/* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx +QMP_PHY_LEGACY_LANE_STRIDE ; - qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; - - }else { - qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); - } + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->rx2)) +return PTR_ERR (qphy->rx2); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); }else { qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); }
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 7/11 phy: qcom-qmp-pcie-msm8996: drop unused pcs_misc handling
In reply to Johan HovoldThe MSM8996 QMP PHY driver does not use the PCS_MISC IO region (and neither do the DT binding specify it) so remove the corresponding code from the driver.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +0 -14
@@ -202,8 +202,6 @@ struct qmp_phy_cfg {int rx_tbl_num;const struct qmp_phy_init_tbl *pcs_tbl;int pcs_tbl_num; -const struct qmp_phy_init_tbl *pcs_misc_tbl; -int pcs_misc_tbl_num;/* clock ids to be requested */ const char *const *clk_list;
@@ -240,7 +238,6 @@ struct qmp_phy_cfg {* @tx: iomapped memory space for lane's tx * @rx: iomapped memory space for lane's rx * @pcs: iomapped memory space for lane's pcs -* @pcs_misc: iomapped memory space for lane's pcs_misc * @pipe_clk: pipe clock * @index: lane index * @qmp: QMP phy to which this lane belongs
@@ -254,7 +251,6 @@ struct qmp_phy {void __iomem *tx;void __iomem *rx;void __iomem *pcs; -void __iomem *pcs_misc;struct clk *pipe_clk;unsigned int index;struct qcom_qmp *qmp;
@@ -523,7 +519,6 @@ static int qmp_pcie_msm8996_power_on(struct phy *phy)void __iomem *tx = qphy->tx;void __iomem *rx = qphy->rx;void __iomem *pcs = qphy->pcs; -void __iomem *pcs_misc = qphy->pcs_misc;void __iomem *status;unsigned int mask, val, ready;int ret;
@@ -552,9 +547,6 @@ static int qmp_pcie_msm8996_power_on(struct phy *phy)qmp_pcie_msm8996_configure (pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); -qmp_pcie_msm8996_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl, - cfg->pcs_misc_tbl_num); -/* * Pull out PHY from POWER DOWN state. * This is active low enable signal to power-down PHY.
@@ -793,8 +785,6 @@ static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, i/* * Get memory resources for each phy lane: * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. -* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 -* For single lane PHYs: pcs_misc (optional) -> 3. */ qphy->tx =devm_of_iomap (dev, np,0 ,NULL );if (IS_ERR (qphy->tx))
@@ -808,10 +798,6 @@ static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, iif (IS_ERR (qphy->pcs))return PTR_ERR (qphy->pcs); - qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); -if (IS_ERR (qphy->pcs_misc)) -dev_vdbg (dev,"PHY pcs_misc-reg not used\n" ); - qphy->pipe_clk =devm_get_clk_from_child (dev, np,NULL );if (IS_ERR (qphy->pipe_clk)) { return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk),
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 9/11 phy: qcom-qmp-combo: drop unused legacy DT workaround
In reply to Johan HovoldCommit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs.
At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy", neither of which is a combo PHY.
Drop the workaround for malformed devicetrees, which should no longer be needed since the QMP driver split.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 27 +++++------------------ 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +6 -21
@@ -66,9 +66,6 @@#define POWER_DOWN_DELAY_US_MIN 10#define POWER_DOWN_DELAY_US_MAX 11 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 -struct qmp_phy_init_tbl {unsigned int offset;unsigned int val;
@@ -2729,28 +2726,16 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id,if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; -/* -* If this is a dual-lane PHY, then there should be registers for the -* second lane. Some old device trees did not specify this, so fall -* back to old legacy behavior of assuming they can be reached at an -* offset from the first lane. -*/ if (cfg->is_dual_lane_phy) { qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); - qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); -if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) { -dev_warn (dev, -"Underspecified device tree, falling back to legacy register regions\n" ); +if (IS_ERR (qphy->tx2)) +return PTR_ERR (qphy->tx2); -/* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx +QMP_PHY_LEGACY_LANE_STRIDE ; - qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; - - }else { - qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); - } + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->rx2)) +return PTR_ERR (qphy->rx2); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); }else { qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); }
Signature · 7 lines
2.35.1 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 11/11 phy: qcom-qmp-usb: drop legacy DT workaround
In reply to Johan HovoldCommit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs.
At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy" and they had been added to the binding less than six months before the binding was fixed.
Presumably no one is using four-year old SDM845 dtbs with mainline anymore so drop the workaround for malformed devicetrees. In the unlikely event that anyone complains, we can consider reverting.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 27 ++++++------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +6 -21
@@ -66,9 +66,6 @@#define POWER_DOWN_DELAY_US_MIN 10#define POWER_DOWN_DELAY_US_MAX 11 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 -struct qmp_phy_init_tbl {unsigned int offset;unsigned int val;
@@ -2642,28 +2639,16 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id,if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; -/* -* If this is a dual-lane PHY, then there should be registers for the -* second lane. Some old device trees did not specify this, so fall -* back to old legacy behavior of assuming they can be reached at an -* offset from the first lane. -*/ if (cfg->is_dual_lane_phy) { qphy->tx2 =devm_of_iomap (dev, np,3 ,NULL ); - qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); -if (IS_ERR (qphy->tx2) ||IS_ERR (qphy->rx2)) { -dev_warn (dev, -"Underspecified device tree, falling back to legacy register regions\n" ); +if (IS_ERR (qphy->tx2)) +return PTR_ERR (qphy->tx2); -/* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx +QMP_PHY_LEGACY_LANE_STRIDE ; - qphy->rx2 = qphy->rx +QMP_PHY_LEGACY_LANE_STRIDE ; - - }else { - qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); - } + qphy->rx2 =devm_of_iomap (dev, np,4 ,NULL ); +if (IS_ERR (qphy->rx2)) +return PTR_ERR (qphy->rx2); + qphy->pcs_misc =devm_of_iomap (dev, np,5 ,NULL ); }else { qphy->pcs_misc =devm_of_iomap (dev, np,3 ,NULL ); }
Signature · 1 line
2.35.1
Quoted 4 lines · Johan Hovold
Here's the next set of QMP PHY cleanups including some non-critical fixes of tiny memory leaks on probe deferral (I didn't add a stable tag for any of them on purpose).
Quoted 12 lines
Johan Hovold (11):
phy: qcom-qmp-pcie: addpcs_miscsanity check
phy: qcom-qmp-pcie: fix memleak on probe deferral
phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral
phy: qcom-qmp-combo: fix memleak on probe deferral
phy: qcom-qmp-ufs: fix memleak on probe deferral
phy: qcom-qmp-usb: fix memleak on probe deferral
phy: qcom-qmp-pcie-msm8996: drop unusedpcs_mischandling
phy: qcom-qmp-pcie: drop unused legacy DT workaround
phy: qcom-qmp-combo: drop unused legacy DT workaround
phy: qcom-qmp-ufs: drop legacy DT workaround
phy: qcom-qmp-usb: drop legacy DT workaround
Please hold off with applying this series. I realised that we have a couple devicetrees in mainline with overlapping register regions for which the drivers would fail to bind if we start checking checking for that.
I'll see to fixing those up and look into how to handle backward compatibility first.
Johan
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Quoted 18 lines · Johan Hovold
Quoted 4 lines · Johan Hovold
Here's the next set of QMP PHY cleanups including some non-critical fixes of tiny memory leaks on probe deferral (I didn't add a stable tag for any of them on purpose).
Quoted 12 lines
Johan Hovold (11):
phy: qcom-qmp-pcie: addpcs_miscsanity check
phy: qcom-qmp-pcie: fix memleak on probe deferral
phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral
phy: qcom-qmp-combo: fix memleak on probe deferral
phy: qcom-qmp-ufs: fix memleak on probe deferral
phy: qcom-qmp-usb: fix memleak on probe deferral
phy: qcom-qmp-pcie-msm8996: drop unusedpcs_mischandling
phy: qcom-qmp-pcie: drop unused legacy DT workaround
phy: qcom-qmp-combo: drop unused legacy DT workaround
phy: qcom-qmp-ufs: drop legacy DT workaround
phy: qcom-qmp-usb: drop legacy DT workaround
Quoted 7 lines
Please hold off with applying this series. I realised that we have a couple devicetrees in mainline with overlapping register regions for which the drivers would fail to bind if we start checking checking for that.
I'll see to fixing those up and look into how to handle backward compatibility first.
So we had four devicetrees (one is new in 6.0) with incorrect serdes region sizes that included the adjacent regions. I've sent fixes for those now, and I don't think we need to add workarounds for booting older malformed dtbs in this case, at least not until someone complains.
We do however have two USB PHY bindings that currently rely on overlapping regions which would require some more work to be fixed up.
Specifically, the USB PHY driver uses two separate PCS regions but the binding treats them as one and the driver ends up mapping everything in between. This sort of works on all platforms but two where the TX and RX regions lie in between.
The binding and driver should probably be fixed up to define this PCS_USB region explicitly, but that work is left for another day.
Meanwhile, I've implemented a workaround that fall back to using non-exclusive mappings for these platforms. I'll send a v2 with this.
Finally, note that new sc8280xp USB4/USB3/DP binding is also broken, but that's really a separate issue and we're working on fixing that up.
Johan