From 9bde29db50f71ccfa46ee5d8043a9f91be50ad5e Mon Sep 17 00:00:00 2001 From: Sagar Dharia Date: Thu, 26 Jul 2012 16:56:44 -0600 Subject: [PATCH] slimbus: Fix channel concurrent usage during reconfiguration sequence Reconfiguration sequence can lead to changes in channel segment distribution and state. Since multiple clients can use 1 channel, make sure channels cannot be manipulated when reconfiguration sequence is in progress, and make sure that client doesn't send reconfiguration sequence when no changes are pending to be sent in the sequence from it. CRs-Fixed: 383406 Change-Id: Ib5f0bc32f67f51f118fa417a2e580c8dc87ef0d0 Signed-off-by: Sagar Dharia --- drivers/slimbus/slimbus.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/slimbus/slimbus.c b/drivers/slimbus/slimbus.c index 72564b00334..219895458e9 100644 --- a/drivers/slimbus/slimbus.c +++ b/drivers/slimbus/slimbus.c @@ -2516,6 +2516,18 @@ int slim_reconfigure_now(struct slim_device *sb) u32 segdist; struct slim_pending_ch *pch; + /* + * If there are no pending changes from this client, avoid sending + * the reconfiguration sequence + */ + if (sb->pending_msgsl == sb->cur_msgsl && + list_empty(&sb->mark_define) && + list_empty(&sb->mark_removal) && + list_empty(&sb->mark_suspend)) { + pr_debug("SLIM_CL: skip reconfig sequence"); + return 0; + } + mutex_lock(&ctrl->sched.m_reconf); mutex_lock(&ctrl->m_ctrl); ctrl->sched.pending_msgsl += sb->pending_msgsl - sb->cur_msgsl; @@ -2538,7 +2550,6 @@ int slim_reconfigure_now(struct slim_device *sb) struct slim_ich *slc = &ctrl->chans[pch->chan]; slc->state = SLIM_CH_SUSPENDED; } - mutex_unlock(&ctrl->m_ctrl); ret = slim_allocbw(sb, &subframe, &clkgear); @@ -2688,7 +2699,6 @@ int slim_reconfigure_now(struct slim_device *sb) NULL, 0, 3, NULL, 0, NULL); dev_dbg(&ctrl->dev, "reconfig now:ret:%d\n", ret); if (!ret) { - mutex_lock(&ctrl->m_ctrl); ctrl->sched.subfrmcode = subframe; ctrl->clkgear = clkgear; ctrl->sched.msgsl = ctrl->sched.pending_msgsl; @@ -2700,7 +2710,6 @@ int slim_reconfigure_now(struct slim_device *sb) } revert_reconfig: - mutex_lock(&ctrl->m_ctrl); /* Revert channel changes */ slim_chan_changes(sb, true); mutex_unlock(&ctrl->m_ctrl);