netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>, Roi Dayan <roid@mellanox.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: Re: [PATCH net-next 1/7] net/mlx5e: Implement Fragmented Work Queue (WQ)
Date: Wed, 30 Nov 2016 12:02:05 +0200	[thread overview]
Message-ID: <0d8cf1b0-a152-aedc-e475-503727feb723@gmail.com> (raw)
In-Reply-To: <1480462282.18162.161.camel@edumazet-glaptop3.roam.corp.google.com>


On 30/11/2016 1:31 AM, Eric Dumazet wrote:
> On Wed, 2016-11-30 at 00:19 +0200, Saeed Mahameed wrote:
>> From: Tariq Toukan <tariqt@mellanox.com>
>>
>> Add new type of struct mlx5_frag_buf which is used to allocate fragmented
>> buffers rather than contiguous, and make the Completion Queues (CQs) use
>> it as they are big (default of 2MB per CQ in Striding RQ).
>>
>> This fixes the failures of type:
>> "mlx5e_open_locked: mlx5e_open_channels failed, -12"
>> due to dma_zalloc_coherent insufficient contiguous coherent memory to
>> satisfy the driver's request when the user tries to setup more or larger
>> rings.
>>
>> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
>> Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
>> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
>> ---
>>   drivers/net/ethernet/mellanox/mlx5/core/alloc.c   | 66 +++++++++++++++++++++++
>>   drivers/net/ethernet/mellanox/mlx5/core/en.h      |  2 +-
>>   drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 ++--
>>   drivers/net/ethernet/mellanox/mlx5/core/wq.c      | 26 ++++++---
>>   drivers/net/ethernet/mellanox/mlx5/core/wq.h      | 18 +++++--
>>   include/linux/mlx5/driver.h                       | 11 ++++
>>   6 files changed, 116 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
>> index 2c6e3c7..bc8357d 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
>> @@ -106,6 +106,63 @@ void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf)
>>   }
>>   EXPORT_SYMBOL_GPL(mlx5_buf_free);
>>   
>> +int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
>> +			     struct mlx5_frag_buf *buf, int node)
>> +{
>> +	int i;
>> +
>> +	buf->size = size;
>> +	buf->npages = 1 << get_order(size);
>> +	buf->page_shift = PAGE_SHIFT;
>> +	buf->frags = kcalloc(buf->npages, sizeof(struct mlx5_buf_list),
>> +			     GFP_KERNEL);
>> +	if (!buf->frags)
>> +		goto err_out;
>> +
>> +	for (i = 0; i < buf->npages; i++) {
>> +		struct mlx5_buf_list *frag = &buf->frags[i];
>> +		int frag_sz = min_t(int, size, PAGE_SIZE);
>> +
>> +		frag->buf = mlx5_dma_zalloc_coherent_node(dev, frag_sz,
>> +							  &frag->map, node);
>> +		if (!frag->buf)
>> +			goto err_free_buf;
>> +		if (frag->map & ((1 << buf->page_shift) - 1)) {
>> +			dma_free_coherent(&dev->pdev->dev, frag_sz,
>> +					  buf->frags[i].buf, buf->frags[i].map);
> There is a bug if this happens with i = 0
>
>> +			mlx5_core_warn(dev, "unexpected map alignment: 0x%p, page_shift=%d\n",
>> +				       (void *)frag->map, buf->page_shift);
>> +			goto err_free_buf;
>> +		}
>> +		size -= frag_sz;
>> +	}
>> +
>> +	return 0;
>> +
>> +err_free_buf:
>> +	while (--i)
> Because this loop will be done about 2^32 times.
Right. I'll fix this.

Thanks,
Tariq.
>
>> +		dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, buf->frags[i].buf,
>> +				  buf->frags[i].map);
>> +	kfree(buf->frags);
>> +err_out:
>> +	return -ENOMEM;
>> +}
>
>
>

  reply	other threads:[~2016-11-30 10:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29 22:19 [PATCH net-next 0/7] Mellanox 100G mlx5 updates 2016-11-29 Saeed Mahameed
2016-11-29 22:19 ` [PATCH net-next 1/7] net/mlx5e: Implement Fragmented Work Queue (WQ) Saeed Mahameed
2016-11-29 23:31   ` Eric Dumazet
2016-11-30 10:02     ` Tariq Toukan [this message]
2016-11-29 22:19 ` [PATCH net-next 2/7] net/mlx5e: Move function mlx5e_create_umr_mkey Saeed Mahameed
2016-11-29 22:19 ` [PATCH net-next 3/7] net/mlx5e: Create UMR MKey per RQ Saeed Mahameed
2016-11-29 22:19 ` [PATCH net-next 4/7] net/mlx5e: Remove redundant hashtable lookup in configure flower Saeed Mahameed
2016-11-29 22:19 ` [PATCH net-next 5/7] net/mlx5e: Correct cleanup order when deleting offloaded TC rules Saeed Mahameed
2016-11-29 22:19 ` [PATCH net-next 6/7] net/mlx5e: Refactor tc del flow to accept mlx5e_tc_flow instance Saeed Mahameed
2016-11-29 22:19 ` [PATCH net-next 7/7] net/mlx5e: Remove flow encap entry in the correct place Saeed Mahameed

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=0d8cf1b0-a152-aedc-e475-503727feb723@gmail.com \
    --to=ttoukan.linux@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=roid@mellanox.com \
    --cc=saeedm@mellanox.com \
    --cc=sebott@linux.vnet.ibm.com \
    --cc=tariqt@mellanox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).