Re: [PATCH net-next 04/11] bnxt_en: Improve bnxt_hwrm_func_backing_store_cfg_v2()
From: Michael Chan <michael.chan@broadcom.com>
Date: 2025-09-16 15:58:31
On Tue, Sep 16, 2025 at 4:19 AM Paolo Abeni [off-list ref] wrote:
On 9/15/25 5:04 AM, Michael Chan wrote:quoted
Optimize the loop inside this function that sends the FW message to configure backing store memory for each instance of a memory type. It uses 2 loop counters i and j, but both counters advance at the same time so we can eliminate one of them.The above statement does not look correct.quoted
@@ -9128,20 +9128,20 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp, req->subtype_valid_cnt = ctxm->split_entry_cnt; for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++) p[i] = cpu_to_le32(ctxm->split[i]); - for (i = 0, j = 0; j < n && !rc; i++) { + for (i = 0; i < n && !rc; i++) { struct bnxt_ctx_pg_info *ctx_pg; if (!(instance_bmap & (1 << i))) continue; req->instance = cpu_to_le16(i); - ctx_pg = &ctxm->pg_info[j++]; + ctx_pg = &ctxm->pg_info[i];`j` is incremented only for bit set in `instance_bmap`, AFAICS this does not introduces functional changes only if `instance_bmap` has all the bit set.
Yes, you are absolutely right. The original code will skip over zeros in the instance_bmap without incrementing j. Let me rethink this patch or drop this patch. Thanks for the review.