Skip to content
Permalink
Browse files
qed: rework qed_rdma_bmap_free()
qed_rdma_bmap_free() is mostly an opencoded version of printk("%*pb").
Using %*pb format simplifies the code. While here, reorganize logic
to avois calculating bmap wheight if check == false.

The side effect of this change is that the the lines are printed in
bitmap format

Signed-off-by: Yury Norov <yury.norov@gmail.com>
  • Loading branch information
YuryNorov committed Feb 9, 2022
1 parent 0bc28b4 commit 8bca8c2ba1a83d9ebf601431dab6c4ab05d9ca27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
@@ -319,44 +319,23 @@ static int qed_rdma_alloc(struct qed_hwfn *p_hwfn)
void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
struct qed_bmap *bmap, bool check)
{
int weight = bitmap_weight(bmap->bitmap, bmap->max_count);
int last_line = bmap->max_count / (64 * 8);
int last_item = last_line * 8 +
DIV_ROUND_UP(bmap->max_count % (64 * 8), 64);
u64 *pmap = (u64 *)bmap->bitmap;
int line, item, offset;
u8 str_last_line[200] = { 0 };

if (!weight || !check)
unsigned int pos, weight, nbits;
unsigned long *b;

if (!check || !(weight = bitmap_weight(bmap->bitmap, bmap->max_count)))
goto end;

DP_NOTICE(p_hwfn,
"%s bitmap not free - size=%d, weight=%d, 512 bits per line\n",
bmap->name, bmap->max_count, weight);

/* print aligned non-zero lines, if any */
for (item = 0, line = 0; line < last_line; line++, item += 8)
if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
for (idx = 0; idx < bmap->max_count; idx += 512) {
b = bmap->bitmap + BITS_TO_LONGS(idx);
nbits = min(bmap->max_count - idx, 512);

if (!bitmap_empty(b, nbits))
DP_NOTICE(p_hwfn,
"line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
line,
pmap[item],
pmap[item + 1],
pmap[item + 2],
pmap[item + 3],
pmap[item + 4],
pmap[item + 5],
pmap[item + 6], pmap[item + 7]);

/* print last unaligned non-zero line, if any */
if ((bmap->max_count % (64 * 8)) &&
(bitmap_weight((unsigned long *)&pmap[item],
bmap->max_count - item * 64))) {
offset = sprintf(str_last_line, "line 0x%04x: ", line);
for (; item < last_item; item++)
offset += sprintf(str_last_line + offset,
"0x%016llx ", pmap[item]);
DP_NOTICE(p_hwfn, "%s\n", str_last_line);
"line 0x%04x: %*pb\n", idx / 512, nbits, b);
}

end:
@@ -76,7 +76,7 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn)
* We delay for a short while if an async destroy QP is still expected.
* Beyond the added delay we clear the bitmap anyway.
*/
while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) {
while (!bitmap_empty(rcid_map->bitmap, rcid_map->max_count)) {
/* If the HW device is during recovery, all resources are
* immediately reset without receiving a per-cid indication
* from HW. In this case we don't expect the cid bitmap to be

0 comments on commit 8bca8c2

Please sign in to comment.