public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gregory CLEMENT <gregory.clement@free-electrons.com>
To: Marcin Wojtas <mw@semihalf.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	"linux-arm-kernel\@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Lior Amsalem <alior@marvell.com>,
	Nadav Haklai <nadavh@marvell.com>,
	Simon Guinot <simon.guinot@sequanux.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Willy Tarreau <w@1wt.eu>, Timor Kardashov <timork@marvell.com>,
	Sebastian Careba <nitroshift@yahoo.com>
Subject: Re: [PATCH v4 net-next 8/9] net: add a hardware buffer management helper API
Date: Mon, 07 Mar 2016 09:15:53 +0100	[thread overview]
Message-ID: <87pov666va.fsf@free-electrons.com> (raw)
In-Reply-To: <CAPv3WKeTGy+HfG=vyY04xi4Spy6eUTF_LX_X=V0=ZAGhxURdJg@mail.gmail.com> (Marcin Wojtas's message of "Sun, 6 Mar 2016 20:21:51 +0100")

Hi Marcin,
 
 On dim., mars 06 2016, Marcin Wojtas <mw@semihalf.com> wrote:

> Hi Gregory,
>
>
>> +int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num, gfp_t gfp)
>> +{
>> +       int err, i;
>> +       unsigned long flags;
>> +
>> +       spin_lock_irqsave(&bm_pool->lock, flags);
>> +       if (bm_pool->buf_num == bm_pool->size) {
>
> 'size' field is used as a 'frag_size' but here it means pool capacity.
> I think it's better to keep 'size' for pool capacity and add
> 'buf_size' field to struct hwbm_pool.


I thought I already added this field, but it seems that I didn't so. So
I will add it.

>
>> +               pr_warn("pool already filled\n");
>> +               return bm_pool->buf_num;
>> +       }
>> +
>> +       if (buf_num + bm_pool->buf_num > bm_pool->size) {
>> +               pr_warn("cannot allocate %d buffers for pool\n",
>> +                       buf_num);
>> +               return 0;
>> +       }
>> +
>> +       if ((buf_num + bm_pool->buf_num) < bm_pool->buf_num) {
>
> What is a point of this condition? How possibly after checking if
> capacity of pool is not exceeded, this one would ever be true?

see http://thread.gmane.org/gmane.linux.kernel/2125152/focus=2137421

this test is here to ensure that (buf_num + bm_pool->buf_nu doesn't
wrap.

Thanks,

Gregory

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

  reply	other threads:[~2016-03-07  8:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05 22:38 [PATCH v4 net-next 0/9] API set for HW Buffer management Gregory CLEMENT
2016-03-05 22:38 ` [PATCH v4 net-next 1/9] ARM: dts: armada-38x: add buffer manager nodes Gregory CLEMENT
2016-03-05 22:38 ` [PATCH v4 net-next 2/9] ARM: dts: armada-38x: enable buffer manager support on Armada 38x boards Gregory CLEMENT
2016-03-06 20:35   ` Russell King - ARM Linux
2016-03-05 22:38 ` [PATCH v4 net-next 3/9] ARM: dts: armada-xp: add buffer manager nodes Gregory CLEMENT
2016-03-05 22:38 ` [PATCH v4 net-next 4/9] ARM: dts: armada-xp: enable buffer manager support on Armada XP boards Gregory CLEMENT
2016-03-05 22:38 ` [PATCH v4 net-next 5/9] ARM: dts: armada-xp-openblocks-ax3-4: Add BM support Gregory CLEMENT
2016-03-05 22:38 ` [PATCH v4 net-next 6/9] bus: mvebu-mbus: provide api for obtaining IO and DRAM window information Gregory CLEMENT
2016-03-05 22:38 ` [PATCH v4 net-next 7/9] net: mvneta: bm: add support for hardware buffer management Gregory CLEMENT
2016-03-06 20:55   ` kbuild test robot
2016-03-05 22:38 ` [PATCH v4 net-next 8/9] net: add a hardware buffer management helper API Gregory CLEMENT
2016-03-06 19:21   ` Marcin Wojtas
2016-03-07  8:15     ` Gregory CLEMENT [this message]
2016-03-05 22:38 ` [PATCH v4 net-next 9/9] net: mvneta: Use the new hwbm framework Gregory CLEMENT

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=87pov666va.fsf@free-electrons.com \
    --to=gregory.clement@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=nitroshift@yahoo.com \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=simon.guinot@sequanux.org \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=timork@marvell.com \
    --cc=w@1wt.eu \
    /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