소스 검색

mmrm-driver: Throttle other clients if callback function fails

If Callback function for throtteling to MMRM client fails,
try to loop for other clients and throttle instead of bailing
out with error.

Change-Id: Ie6c25638c2576be597c2262a2aa1877a443769a3
Signed-off-by: Vedang Nagar <[email protected]>
Vedang Nagar 1 년 전
부모
커밋
95e20a96a0
1개의 변경된 파일29개의 추가작업 그리고 35개의 파일을 삭제
  1. 29 35
      driver/src/mmrm_clk_rsrc_mgr_sw.c

+ 29 - 35
driver/src/mmrm_clk_rsrc_mgr_sw.c

@@ -621,7 +621,6 @@ static int mmrm_sw_throttle_low_priority_client(
 {
 {
 	int rc = 0, i;
 	int rc = 0, i;
 	u64 start_ts = 0, end_ts = 0;
 	u64 start_ts = 0, end_ts = 0;
-	bool found_client_throttle = false;
 	struct mmrm_sw_clk_client_tbl_entry *tbl_entry_throttle_client;
 	struct mmrm_sw_clk_client_tbl_entry *tbl_entry_throttle_client;
 	struct mmrm_client_notifier_data notifier_data;
 	struct mmrm_client_notifier_data notifier_data;
 	struct completion timeout;
 	struct completion timeout;
@@ -636,37 +635,32 @@ static int mmrm_sw_throttle_low_priority_client(
 	for (i = 0; i < sinfo->throttle_clients_data_length ; i++) {
 	for (i = 0; i < sinfo->throttle_clients_data_length ; i++) {
 		tbl_entry_throttle_client =
 		tbl_entry_throttle_client =
 			&sinfo->clk_client_tbl[sinfo->throttle_clients_info[i].tbl_entry_id];
 			&sinfo->clk_client_tbl[sinfo->throttle_clients_info[i].tbl_entry_id];
-		if (!IS_ERR_OR_NULL(tbl_entry_throttle_client)) {
-			now_cur_ma = tbl_entry_throttle_client->current_ma
-				[tbl_entry_throttle_client->vdd_level]
-				[peak_data->aggreg_level];
-			min_cur_ma = tbl_entry_throttle_client->current_ma[clk_min_level]
-				[peak_data->aggreg_level];
-
-			d_mpr_h("%s:csid(0x%x) name(%s)\n",
-				__func__, tbl_entry_throttle_client->clk_src_id,
-				tbl_entry_throttle_client->name);
-			d_mpr_h("%s:now_cur_ma(%llu) min_cur_ma(%llu) delta_cur(%d)\n",
-				__func__, now_cur_ma, min_cur_ma, *delta_cur);
-
-			if ((now_cur_ma > min_cur_ma)
-				&& (now_cur_ma - min_cur_ma > *delta_cur)) {
-				found_client_throttle = true;
-				d_mpr_h("%s: Throttle client csid(0x%x) name(%s)\n",
-					__func__, tbl_entry_throttle_client->clk_src_id,
-					tbl_entry_throttle_client->name);
-				d_mpr_h("%s:now_cur_ma %llu-min_cur_ma %llu>delta_cur %d\n",
-					__func__, now_cur_ma, min_cur_ma, *delta_cur);
-				/* found client to throttle, break from here. */
-				break;
-			}
-		}
-	}
 
 
-	/*Client to throttle is found, Throttle this client now to minimum clock rate*/
-	if (found_client_throttle) {
-		/* Setup notifier */
+		if (IS_ERR_OR_NULL(tbl_entry_throttle_client))
+			continue;
+
+		now_cur_ma = tbl_entry_throttle_client->current_ma
+			[tbl_entry_throttle_client->vdd_level]
+			[peak_data->aggreg_level];
+		min_cur_ma = tbl_entry_throttle_client->current_ma[clk_min_level]
+			[peak_data->aggreg_level];
+
+		d_mpr_h("%s:csid(0x%x) name(%s)\n",
+			__func__, tbl_entry_throttle_client->clk_src_id,
+			tbl_entry_throttle_client->name);
+		d_mpr_h("%s:now_cur_ma(%llu) min_cur_ma(%llu) delta_cur(%d)\n",
+			__func__, now_cur_ma, min_cur_ma, *delta_cur);
+
+		if ((now_cur_ma <= min_cur_ma) || (now_cur_ma - min_cur_ma <= *delta_cur))
+			continue;
 
 
+		d_mpr_h("%s: Throttle client csid(0x%x) name(%s)\n",
+			__func__, tbl_entry_throttle_client->clk_src_id,
+			tbl_entry_throttle_client->name);
+		d_mpr_h("%s:now_cur_ma %llu-min_cur_ma %llu>delta_cur %d\n",
+			__func__, now_cur_ma, min_cur_ma, *delta_cur);
+
+		/* Setup notifier */
 		notifier_data.cb_type = MMRM_CLIENT_RESOURCE_VALUE_CHANGE;
 		notifier_data.cb_type = MMRM_CLIENT_RESOURCE_VALUE_CHANGE;
 		notifier_data.cb_data.val_chng.old_val =
 		notifier_data.cb_data.val_chng.old_val =
 			tbl_entry_throttle_client->freq[tbl_entry_throttle_client->vdd_level];
 			tbl_entry_throttle_client->freq[tbl_entry_throttle_client->vdd_level];
@@ -685,8 +679,7 @@ static int mmrm_sw_throttle_low_priority_client(
 		if (rc) {
 		if (rc) {
 			d_mpr_e("%s: Client failed to send SUCCESS in callback(%d)\n",
 			d_mpr_e("%s: Client failed to send SUCCESS in callback(%d)\n",
 				__func__, tbl_entry_throttle_client->clk_src_id);
 				__func__, tbl_entry_throttle_client->clk_src_id);
-			rc = -EINVAL;
-			goto err_clk_set_fail;
+			continue;
 		}
 		}
 
 
 		if ((end_ts - start_ts) > NOTIFY_TIMEOUT)
 		if ((end_ts - start_ts) > NOTIFY_TIMEOUT)
@@ -699,8 +692,7 @@ static int mmrm_sw_throttle_low_priority_client(
 			if (rc) {
 			if (rc) {
 				d_mpr_e("%s: Failed to throttle the clk csid(%d)\n",
 				d_mpr_e("%s: Failed to throttle the clk csid(%d)\n",
 					__func__, tbl_entry_throttle_client->clk_src_id);
 					__func__, tbl_entry_throttle_client->clk_src_id);
-				rc = -EINVAL;
-				goto err_clk_set_fail;
+				continue;
 			}
 			}
 		}
 		}
 
 
@@ -730,8 +722,10 @@ static int mmrm_sw_throttle_low_priority_client(
 
 
 		/* Clearing the reserve flag */
 		/* Clearing the reserve flag */
 		tbl_entry_throttle_client->reserve = false;
 		tbl_entry_throttle_client->reserve = false;
+
+		break;
 	}
 	}
-err_clk_set_fail:
+
 	return rc;
 	return rc;
 }
 }