Skip to content

Commit 77cbca3

Browse files
quic-bjorandevinodkoul
authored andcommitted
phy: qcom-qmp-combo: Extend phy_mutex to all phy_ops
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 <[email protected]> Reviewed-by: Johan Hovold <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 02545aa commit 77cbca3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

drivers/phy/qualcomm/phy-qcom-qmp-combo.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,24 +2437,33 @@ static int qmp_combo_dp_configure(struct phy *phy, union phy_configure_opts *opt
24372437
struct qmp_combo *qmp = phy_get_drvdata(phy);
24382438
const struct qmp_phy_cfg *cfg = qmp->cfg;
24392439

2440+
mutex_lock(&qmp->phy_mutex);
2441+
24402442
memcpy(&qmp->dp_opts, dp_opts, sizeof(*dp_opts));
24412443
if (qmp->dp_opts.set_voltages) {
24422444
cfg->configure_dp_tx(qmp);
24432445
qmp->dp_opts.set_voltages = 0;
24442446
}
24452447

2448+
mutex_unlock(&qmp->phy_mutex);
2449+
24462450
return 0;
24472451
}
24482452

24492453
static int qmp_combo_dp_calibrate(struct phy *phy)
24502454
{
24512455
struct qmp_combo *qmp = phy_get_drvdata(phy);
24522456
const struct qmp_phy_cfg *cfg = qmp->cfg;
2457+
int ret = 0;
2458+
2459+
mutex_lock(&qmp->phy_mutex);
24532460

24542461
if (cfg->calibrate_dp_phy)
2455-
return cfg->calibrate_dp_phy(qmp);
2462+
ret = cfg->calibrate_dp_phy(qmp);
24562463

2457-
return 0;
2464+
mutex_unlock(&qmp->phy_mutex);
2465+
2466+
return ret;
24582467
}
24592468

24602469
static int qmp_combo_com_init(struct qmp_combo *qmp)
@@ -2578,6 +2587,8 @@ static int qmp_combo_dp_power_on(struct phy *phy)
25782587
void __iomem *tx = qmp->dp_tx;
25792588
void __iomem *tx2 = qmp->dp_tx2;
25802589

2590+
mutex_lock(&qmp->phy_mutex);
2591+
25812592
qmp_combo_dp_serdes_init(qmp);
25822593

25832594
qmp_combo_configure_lane(tx, cfg->dp_tx_tbl, cfg->dp_tx_tbl_num, 1);
@@ -2589,16 +2600,22 @@ static int qmp_combo_dp_power_on(struct phy *phy)
25892600
/* Configure link rate, swing, etc. */
25902601
cfg->configure_dp_phy(qmp);
25912602

2603+
mutex_unlock(&qmp->phy_mutex);
2604+
25922605
return 0;
25932606
}
25942607

25952608
static int qmp_combo_dp_power_off(struct phy *phy)
25962609
{
25972610
struct qmp_combo *qmp = phy_get_drvdata(phy);
25982611

2612+
mutex_lock(&qmp->phy_mutex);
2613+
25992614
/* Assert DP PHY power down */
26002615
writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
26012616

2617+
mutex_unlock(&qmp->phy_mutex);
2618+
26022619
return 0;
26032620
}
26042621

0 commit comments

Comments
 (0)