From 2e9d68e174116394d0b11d17fcf8de5923698613 Mon Sep 17 00:00:00 2001 From: Sandeep Gangadharaiah Date: Mon, 29 Aug 2022 14:28:31 -0700 Subject: [PATCH] disp: msm: dp: free DP sim ports during DP sim disable DP sim ports created during DP sim enable aren't cleared during disable path. This would retain the last status of the DP sim port or the connector. This would impact the next iteration of DP sim test, if done without device reset. This change will set the port number to 0 during DP sim disable and clear the memory allocated for these ports. Change-Id: I386a62e87fcaf006db8dd18e5751b33bbe70fc9b Signed-off-by: Sandeep Gangadharaiah --- msm/dp/dp_debug.c | 2 ++ msm/dp/dp_mst_sim.c | 4 ++++ msm/dp/dp_mst_sim_helper.c | 13 ++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/msm/dp/dp_debug.c b/msm/dp/dp_debug.c index 1e1cb53b0e..c5cfb46e52 100644 --- a/msm/dp/dp_debug.c +++ b/msm/dp/dp_debug.c @@ -121,6 +121,8 @@ static void dp_debug_disable_sim_mode(struct dp_debug_private *debug, debug->sim_mode &= ~mode_mask; dp_sim_set_sim_mode(debug->sim_bridge, debug->sim_mode); + dp_sim_update_port_num(debug->sim_bridge, 0); + /* switch to normal mode */ if (!debug->sim_mode) debug->aux->set_sim_mode(debug->aux, NULL); diff --git a/msm/dp/dp_mst_sim.c b/msm/dp/dp_mst_sim.c index 2ed82571b0..2e3eb4031e 100644 --- a/msm/dp/dp_mst_sim.c +++ b/msm/dp/dp_mst_sim.c @@ -342,6 +342,10 @@ int dp_sim_update_port_num(struct dp_aux_bridge *bridge, u32 port_num) return -EINVAL; sim_dev = to_dp_sim_dev(bridge); + DP_INFO("Update port count from %d to %d\n", port_num, sim_dev->port_num); + + if (sim_dev->port_num > port_num && sim_dev->ports) + sim_dev->port_num = port_num; if (port_num > sim_dev->port_num) { ports = devm_kzalloc(sim_dev->dev, diff --git a/msm/dp/dp_mst_sim_helper.c b/msm/dp/dp_mst_sim_helper.c index 1fe4e916c0..1657c97535 100644 --- a/msm/dp/dp_mst_sim_helper.c +++ b/msm/dp/dp_mst_sim_helper.c @@ -1086,13 +1086,15 @@ int dp_mst_sim_update(void *mst_sim_context, u32 port_num, kfree(ctx->ports); ctx->port_num = 0; - ctx->ports = kcalloc(port_num, sizeof(*ports), GFP_KERNEL); - if (!ctx->ports) { - rc = -ENOMEM; - goto fail; + if (port_num) { + ctx->ports = kcalloc(port_num, sizeof(*ports), GFP_KERNEL); + if (!ctx->ports) { + rc = -ENOMEM; + goto fail; + } + ctx->port_num = port_num; } - ctx->port_num = port_num; for (i = 0; i < port_num; i++) { ctx->ports[i] = ports[i]; if (ports[i].edid_size) { @@ -1118,6 +1120,7 @@ fail: for (i = 0; i < ctx->port_num; i++) kfree(ctx->ports[i].edid); kfree(ctx->ports); + ctx->port_num = 0; } mutex_unlock(&ctx->session_lock);