Skip to contentSkip to conversation

DSPBRIDGE: trivial opp constraint

PATCH New Nishanth Menon 1 participant 3 messages Jan 21, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [PATCH 1/2] DSPBRIDGE: remove dependency of mpu freq

#1 lore raw

cover DSPBRIDGE: trivial opp constraint

in continuation of the discussion in:
http://marc.info/?t=126395196000002&r=1&w=2
patch #2 in this series depends on:
http://marc.info/?l=linux-omap&m=126402596424801&w=2

Nishanth Menon (2):
DSPBRIDGE: improve constraint_value handling
DSPBRIDGE: sanitize opp_idx before passing to PM

 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
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]>

Regards,
Nishanth Menon

#2 lore raw

PATCH 1/2 DSPBRIDGE: improve constraint_value handling

currently pConstraint value is a pointer which is dereferenced twice(when debug is enabled) to get to the opp index. instead dereference it correctly once. since the meaning of the variable changes, rename it as opp_idx

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]>
---
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/dsp/bridge/wmd/tiomap3430_pwr.c +6 -4
index 084f406..5dfbef8 100644
@@ -66,18 +66,20 @@ DSP_STATUS handle_constraints_set(struct WMD_DEV_CONTEXT *pDevContext,
 				  IN void *pArgs)
 {
 #ifdef CONFIG_BRIDGE_DVFS
-	u32 *pConstraintVal;
+	u32 opp_idx;
 	struct dspbridge_platform_data *pdata =
 		omap_dspbridge_dev->dev.platform_data;
 
-	pConstraintVal = (u32 *)(pArgs);
+	/* pick up the opp index */
+	opp_idx = *(((u32 *)(pArgs)) + 1);
+
 	/* Read the target value requested by DSP  */
 	DBG_Trace(DBG_LEVEL7, "handle_constraints_set:"
-		"opp requested = 0x%x\n", (u32)*(pConstraintVal+1));
+		"opp requested = 0x%x\n", opp_idx);
 
 	/* Set the new opp value */
 	if (pdata->dsp_set_min_opp)
-		(*pdata->dsp_set_min_opp)((u32)*(pConstraintVal+1));
+		(*pdata->dsp_set_min_opp)(opp_idx);
 #endif /* #ifdef CONFIG_BRIDGE_DVFS */
 	return DSP_SOK;
 }
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 2/2 DSPBRIDGE: sanitize opp_idx before passing to PM

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]>
---
 drivers/dsp/bridge/wmd/tiomap3430_pwr.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/dsp/bridge/wmd/tiomap3430_pwr.c +6 -0
index 5dfbef8..a13e035 100644
@@ -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);
Signature · 1 line
1.6.3.3