OSDN Git Service

msm: gsi: check channel state on timeout
authorSkylar Chang <chiaweic@codeaurora.org>
Thu, 3 Aug 2017 00:55:23 +0000 (17:55 -0700)
committerSkylar Chang <chiaweic@codeaurora.org>
Thu, 10 Aug 2017 18:05:12 +0000 (11:05 -0700)
In some cases of stopping a channel,
the CH CTRL interrupt arrives late even though the channel is
already stopped. This change will check the channel state after
timeout occurs.

CRs-Fixed: 2090459
Change-Id: I4b99e8fb6710dca16047025a614fb734995934a1
Acked-by: Ady Abraham <adya@qti.qualcomm.com>
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
drivers/platform/msm/gsi/gsi.c

index b111a59..2ae2438 100644 (file)
@@ -1901,6 +1901,20 @@ int gsi_stop_channel(unsigned long chan_hdl)
        res = wait_for_completion_timeout(&ctx->compl,
                        msecs_to_jiffies(GSI_STOP_CMD_TIMEOUT_MS));
        if (res == 0) {
+               /*
+                * check channel state here in case the channel is stopped but
+                * the interrupt was not handled yet.
+                */
+               val = gsi_readl(gsi_ctx->base +
+                       GSI_EE_n_GSI_CH_k_CNTXT_0_OFFS(chan_hdl,
+                       gsi_ctx->per.ee));
+               ctx->state = (val &
+                       GSI_EE_n_GSI_CH_k_CNTXT_0_CHSTATE_BMSK) >>
+                       GSI_EE_n_GSI_CH_k_CNTXT_0_CHSTATE_SHFT;
+               if (ctx->state == GSI_CHAN_STATE_STOPPED) {
+                       res = GSI_STATUS_SUCCESS;
+                       goto free_lock;
+               }
                GSIDBG("chan_hdl=%lu timed out\n", chan_hdl);
                res = -GSI_STATUS_TIMED_OUT;
                goto free_lock;