All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lino Sanfilippo <LinoSanfilippo@gmx.de>
To: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>,
	ariel.elior@qlogic.com
Cc: netdev@vger.kernel.org, cascardo@linux.vnet.ibm.com,
	cascardo@cascardo.eti.br, brking@linux.vnet.ibm.com
Subject: Re: [PATCH v2] bnx2x: Alloc 4k fragment for each rx ring buffer element
Date: Sat, 25 Apr 2015 01:24:07 +0200	[thread overview]
Message-ID: <553AD097.4020209@gmx.de> (raw)
In-Reply-To: <1429908351-12262-1-git-send-email-krisman@linux.vnet.ibm.com>

Hi,

On 24.04.2015 22:45, Gabriel Krisman Bertazi wrote:
> @@ -544,30 +544,52 @@ static void bnx2x_set_gro_params(struct sk_buff *skb, u16 parsing_flags,
>  static int bnx2x_alloc_rx_sge(struct bnx2x *bp, struct bnx2x_fastpath *fp,
>  			      u16 index, gfp_t gfp_mask)
>  {
> -	struct page *page = alloc_pages(gfp_mask, PAGES_PER_SGE_SHIFT);
>  	struct sw_rx_page *sw_buf = &fp->rx_page_ring[index];
>  	struct eth_rx_sge *sge = &fp->rx_sge_ring[index];
> +	struct bnx2x_alloc_pool *pool = &fp->page_pool;
>  	dma_addr_t mapping;
>  
> -	if (unlikely(page == NULL)) {
> -		BNX2X_ERR("Can't alloc sge\n");
> -		return -ENOMEM;
> -	}
> +	if (!pool->page || pool->offset > pool->last_offset) {
>  
> -	mapping = dma_map_page(&bp->pdev->dev, page, 0,
> -			       SGE_PAGES, DMA_FROM_DEVICE);
> -	if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
> -		__free_pages(page, PAGES_PER_SGE_SHIFT);
> -		BNX2X_ERR("Can't map sge\n");
> -		return -ENOMEM;
> +		/* put page reference used by the memory pool, since we
> +		 * won't be using this page as the mempool anymore.
> +		 */
> +		if (pool->page)
> +			put_page(pool->page);
> +
> +		pool->page = alloc_pages(gfp_mask, PAGES_PER_SGE_SHIFT);
> +		if (unlikely(!pool->page)) {
> +			BNX2X_ERR("Can't alloc sge\n");
> +			return -ENOMEM;
> +		}
> +
> +		pool->dma = dma_map_page(&bp->pdev->dev, pool->page, 0,
> +					 PAGE_SIZE, DMA_FROM_DEVICE);
> +		if (unlikely(dma_mapping_error(&bp->pdev->dev,
> +					       pool->dma))) {
> +			__free_pages(pool->page, PAGES_PER_SGE_SHIFT);
> +			BNX2X_ERR("Can't map sge\n");
> +			return -ENOMEM;

Looks like setting pool->page to NULL is missing in case that dma
mapping failed. Otherwise put_page is called on the freed page the next
time bnx2x_alloc_rx_sge is called.

Regards,
Lino

  reply	other threads:[~2015-04-24 23:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 20:45 [PATCH v2] bnx2x: Alloc 4k fragment for each rx ring buffer element Gabriel Krisman Bertazi
2015-04-24 23:24 ` Lino Sanfilippo [this message]
2015-04-29 13:30   ` Gabriel Krisman Bertazi
2015-04-30 11:25     ` Yuval Mintz
2015-04-30 20:05       ` David Miller
2015-05-04 19:32         ` [PATCH v3] " Gabriel Krisman Bertazi
2015-05-04 19:58           ` Yuval Mintz
2015-05-15 20:43             ` Gabriel Krisman Bertazi
2015-05-17  7:14               ` Yuval Mintz
2015-05-21 13:20             ` [PATCH v4] " Gabriel Krisman Bertazi
2015-05-23 10:04               ` Yuval Mintz
2015-05-23 11:14               ` Lino Sanfilippo
2015-05-27  8:59               ` Michal Schmidt
2015-05-27 16:51                 ` [PATCH] " Gabriel Krisman Bertazi
2015-06-01 22:57                   ` David Miller
2015-05-28  7:24                 ` [PATCH v4] " Yuval Mintz
2015-05-28 13:26                   ` Gabriel Krisman Bertazi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=553AD097.4020209@gmx.de \
    --to=linosanfilippo@gmx.de \
    --cc=ariel.elior@qlogic.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=cascardo@cascardo.eti.br \
    --cc=cascardo@linux.vnet.ibm.com \
    --cc=krisman@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.