From 200e660f21df5e6293f4b8a527e921a400771c83 Mon Sep 17 00:00:00 2001 From: Mohit Khanna Date: Thu, 17 Nov 2016 12:25:49 -0800 Subject: [PATCH] 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 --- hif/src/hif_napi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hif/src/hif_napi.c b/hif/src/hif_napi.c index 13d2bf301c84..8797aea9e6e4 100644 --- a/hif/src/hif_napi.c +++ b/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) 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]++; /* if ce_per engine reports 0, then poll should be terminated */