Subject: Re: [PATCH v4] bnx2x: Alloc 4k fragment for each rx ring buffer element

From: Michal Schmidt <[email-masked]>
Date: Wed, 27 May 2015 10:59:45 +0200

On 05/21/2015 03:20 PM, Gabriel Krisman Bertazi wrote:
> +#define SGE_PAGE_SHIFT		12
> +#define SGE_PAGE_SIZE		(1 << SGE_PAGE_SHIFT)
...
> +struct bnx2x_alloc_pool {
> +	struct page	*page;
> +	dma_addr_t	dma;
> +	u8		offset;
> +	u8		frag_count;
> +};
...
>  static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
>  			      u16 index, gfp_t gfp_mask)
>  {
        ...
> +	pool->offset += SGE_PAGE_SIZE;
> +	pool->frag_count--;
> +
>  	return 0;
>  }

One SGE_PAGE_SIZE is already bigger than representable by u8, so offset
will overflow.

Isn't storing both 'offset' and 'frag_count' redundant? There is a
simple linear relationship between the two.

Regards,
Michal