ソースを参照

qcacmn: correct napi bucket calculation

NAPI bucket calculation was resulting in bucket number which was out of
bounds for the number of buckets.
Calculate bucket index correctly and check for out of bound
condition.

CRs-Fixed: 1091483
Change-Id: Ieb81b2eeec546a6128c6b878db4c65ccb8b62bda
Mohit Khanna 8 年 前
コミット
200e660f21
1 ファイル変更6 行追加1 行削除
  1. 6 1
      hif/src/hif_napi.c

+ 6 - 1
hif/src/hif_napi.c

@@ -758,7 +758,12 @@ int hif_napi_poll(struct hif_opaque_softc *hif_ctx, struct napi_struct *napi,
 	 */
 	 */
 	if (rc)
 	if (rc)
 		normalized++;
 		normalized++;
-	bucket   = (normalized / QCA_NAPI_DEF_SCALE);
+	bucket = normalized / (QCA_NAPI_BUDGET / QCA_NAPI_NUM_BUCKETS);
+	if (bucket >= QCA_NAPI_NUM_BUCKETS) {
+		bucket = QCA_NAPI_NUM_BUCKETS - 1;
+		HIF_ERROR("Bad bucket#(%d) > QCA_NAPI_NUM_BUCKETS(%d)",
+			bucket, QCA_NAPI_NUM_BUCKETS);
+	}
 	napi_info->stats[cpu].napi_budget_uses[bucket]++;
 	napi_info->stats[cpu].napi_budget_uses[bucket]++;
 
 
 	/* if ce_per engine reports 0, then poll should be terminated */
 	/* if ce_per engine reports 0, then poll should be terminated */