]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: qcom-qmp-combo: Extend phy_mutex to all phy_ops
authorBjorn Andersson <quic_bjorande@quicinc.com>
Mon, 15 May 2023 03:27:38 +0000 (20:27 -0700)
committerVinod Koul <vkoul@kernel.org>
Fri, 19 May 2023 17:47:19 +0000 (23:17 +0530)
The phy core ensures mutual exclusion across the ops for a given phy,
but the upcoming introduction of USB Type-C orientation switching might
race with the DisplayPort phy operations. So extend the mutual exclusion
to cover the remaining ops as well, to avoid concurrent reconfiguration
of the hardware.

Reported-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Link: https://lore.kernel.org/r/20230515032743.400170-4-quic_bjorande@quicinc.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/qualcomm/phy-qcom-qmp-combo.c

index 8918ba2b18a40e8a791a32364a45fa77114a4430..6baacdf3a4cbc5abc0041be2399eee3db7657e28 100644 (file)
@@ -2437,12 +2437,16 @@ static int qmp_combo_dp_configure(struct phy *phy, union phy_configure_opts *opt
        struct qmp_combo *qmp = phy_get_drvdata(phy);
        const struct qmp_phy_cfg *cfg = qmp->cfg;
 
+       mutex_lock(&qmp->phy_mutex);
+
        memcpy(&qmp->dp_opts, dp_opts, sizeof(*dp_opts));
        if (qmp->dp_opts.set_voltages) {
                cfg->configure_dp_tx(qmp);
                qmp->dp_opts.set_voltages = 0;
        }
 
+       mutex_unlock(&qmp->phy_mutex);
+
        return 0;
 }
 
@@ -2450,11 +2454,16 @@ static int qmp_combo_dp_calibrate(struct phy *phy)
 {
        struct qmp_combo *qmp = phy_get_drvdata(phy);
        const struct qmp_phy_cfg *cfg = qmp->cfg;
+       int ret = 0;
+
+       mutex_lock(&qmp->phy_mutex);
 
        if (cfg->calibrate_dp_phy)
-               return cfg->calibrate_dp_phy(qmp);
+               ret = cfg->calibrate_dp_phy(qmp);
 
-       return 0;
+       mutex_unlock(&qmp->phy_mutex);
+
+       return ret;
 }
 
 static int qmp_combo_com_init(struct qmp_combo *qmp)
@@ -2578,6 +2587,8 @@ static int qmp_combo_dp_power_on(struct phy *phy)
        void __iomem *tx = qmp->dp_tx;
        void __iomem *tx2 = qmp->dp_tx2;
 
+       mutex_lock(&qmp->phy_mutex);
+
        qmp_combo_dp_serdes_init(qmp);
 
        qmp_combo_configure_lane(tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1);
@@ -2589,6 +2600,8 @@ static int qmp_combo_dp_power_on(struct phy *phy)
        /* Configure link rate, swing, etc. */
        cfg->configure_dp_phy(qmp);
 
+       mutex_unlock(&qmp->phy_mutex);
+
        return 0;
 }
 
@@ -2596,9 +2609,13 @@ static int qmp_combo_dp_power_off(struct phy *phy)
 {
        struct qmp_combo *qmp = phy_get_drvdata(phy);
 
+       mutex_lock(&qmp->phy_mutex);
+
        /* Assert DP PHY power down */
        writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
 
+       mutex_unlock(&qmp->phy_mutex);
+
        return 0;
 }