DSP is not supposed to return bad opp_indices which are not part of
the opp table we created for it. If it does, throw an error, and
refuse to switch the OPP.

Ref: discussion: http://marc.info/?t=126395196000002&r=1&w=2
Depends on: http://marc.info/?l=linux-omap&m=126402596424801&w=2

Cc: Ameya Palande <[email protected]>
Cc: Deepak Chitriki <[email protected]>
Cc: Felipe Contreras <[email protected]>
Cc: Hiroshi Doyu <[email protected]>
Cc: Omar Ramirez Luna <[email protected]>

Signed-off-by: Nishanth Menon <[email protected]>
---
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c 
b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
index 5dfbef8..a13e035 100644
--- a/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
+++ b/drivers/dsp/bridge/wmd/tiomap3430_pwr.c
@@ -73,6 +73,12 @@ DSP_STATUS handle_constraints_set(struct WMD_DEV_CONTEXT 
*pDevContext,
        /* pick up the opp index */
        opp_idx = *(((u32 *)(pArgs)) + 1);
 
+       /* Sanity check to ensure things are fine */
+       if (!opp_idx || (opp_idx > pdata->dsp_num_speeds)) {
+               pr_err("%s: DSP requested for an invalid OPP %d Vs %d->%d!\n",
+                       __func__, opp_idx, 1, pdata->dsp_num_speeds);
+               return DSP_EINVALIDARG;
+       }
        /* Read the target value requested by DSP  */
        DBG_Trace(DBG_LEVEL7, "handle_constraints_set:"
                "opp requested = 0x%x\n", opp_idx);
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to