Skip to content

Commit

Permalink
libcxgb: fix incorrect ppmax calculation
Browse files Browse the repository at this point in the history
BITS_TO_LONGS() uses DIV_ROUND_UP() because of
this ppmax value can be greater than available
per cpu page pods.

This patch removes BITS_TO_LONGS() to fix this
issue.

Signed-off-by: Varun Prakash <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Varun Prakash authored and davem330 committed Apr 5, 2019
1 parent 0a89eb9 commit cc5a726
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,10 @@ static struct cxgbi_ppm_pool *ppm_alloc_cpu_pool(unsigned int *total,
ppmax = max;

/* pool size must be multiple of unsigned long */
bmap = BITS_TO_LONGS(ppmax);
bmap = ppmax / BITS_PER_TYPE(unsigned long);
if (!bmap)
return NULL;

ppmax = (bmap * sizeof(unsigned long)) << 3;

alloc_sz = sizeof(*pools) + sizeof(unsigned long) * bmap;
Expand Down Expand Up @@ -402,6 +405,10 @@ int cxgbi_ppm_init(void **ppm_pp, struct net_device *ndev,
if (reserve_factor) {
ppmax_pool = ppmax / reserve_factor;
pool = ppm_alloc_cpu_pool(&ppmax_pool, &pool_index_max);
if (!pool) {
ppmax_pool = 0;
reserve_factor = 0;
}

pr_debug("%s: ppmax %u, cpu total %u, per cpu %u.\n",
ndev->name, ppmax, ppmax_pool, pool_index_max);
Expand Down

0 comments on commit cc5a726

Please sign in to comment.