OSDN Git Service

msm: ipa3: fix a race condition on clock vote from suspend
authorSkylar Chang <chiaweic@codeaurora.org>
Fri, 24 Feb 2017 19:22:03 +0000 (11:22 -0800)
committerSkylar Chang <chiaweic@codeaurora.org>
Mon, 1 May 2017 18:13:35 +0000 (11:13 -0700)
There is a potential race condition where suspend interrupt
handling might be running from two different context in parallel.
Add a mutex to ensure mutual exclusion when voting for IPA clocks.

CRs-Fixed: 2037199
Change-Id: I7f14866696b6c9f5e239f3de2c4bad6991097ecb
Acked-by: Ady Abraham <adya@qti.qualcomm.com>
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
drivers/platform/msm/ipa/ipa_v2/ipa.c
drivers/platform/msm/ipa/ipa_v3/ipa.c

index f01743d..0629d6b 100644 (file)
@@ -3685,6 +3685,7 @@ void ipa_suspend_handler(enum ipa_irq_type interrupt,
                                 * pipe will be unsuspended as part of
                                 * enabling IPA clocks
                                 */
+                               mutex_lock(&ipa_ctx->sps_pm.sps_pm_lock);
                                if (!atomic_read(
                                        &ipa_ctx->sps_pm.dec_clients)
                                        ) {
@@ -3697,6 +3698,7 @@ void ipa_suspend_handler(enum ipa_irq_type interrupt,
                                                1);
                                        ipa_sps_process_irq_schedule_rel();
                                }
+                               mutex_unlock(&ipa_ctx->sps_pm.sps_pm_lock);
                        } else {
                                resource = ipa2_get_rm_resource_from_ep(i);
                                res = ipa_rm_request_resource_with_timer(
index 5ee6e5d..5a7a0e5 100644 (file)
@@ -3614,6 +3614,8 @@ void ipa3_suspend_handler(enum ipa_irq_type interrupt,
                                 * pipe will be unsuspended as part of
                                 * enabling IPA clocks
                                 */
+                               mutex_lock(&ipa3_ctx->transport_pm.
+                                       transport_pm_mutex);
                                if (!atomic_read(
                                        &ipa3_ctx->transport_pm.dec_clients)
                                        ) {
@@ -3626,6 +3628,8 @@ void ipa3_suspend_handler(enum ipa_irq_type interrupt,
                                        1);
                                        ipa3_sps_process_irq_schedule_rel();
                                }
+                               mutex_unlock(&ipa3_ctx->transport_pm.
+                                       transport_pm_mutex);
                        } else {
                                resource = ipa3_get_rm_resource_from_ep(i);
                                res =