public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <sgoutham@marvell.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<andrew+netdev@lunn.ch>, "Dan Carpenter" <error27@gmail.com>,
	Simon Horman <horms@kernel.org>
Subject: Re: [PATCH v4 net 03/10] octeontx2-af: npc: cn20k: Propagate errors in defrag MCAM alloc rollback
Date: Mon, 27 Apr 2026 15:26:35 +0530	[thread overview]
Message-ID: <ae8y0-w3KRGRME_B@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260427063213.3937451-4-rkannoth@marvell.com>

On 2026-04-27 at 12:02:06, Ratheesh Kannoth (rkannoth@marvell.com) wrote:
> npc_defrag_alloc_free_slots() allocates MCAM indexes in up to two passes
> on bank0 then bank1.  On failure it rolls back by freeing entries already
> placed in save[].
>
> __npc_subbank_alloc() can return a negative errno while only part of the
> indexes are valid.  The rollback loop used rc for
> npc_mcam_idx_2_subbank_idx() as well, so a successful lookup stored zero
> in rc and a later __npc_subbank_free() failure could still end with
> return 0 when the allocation path had also left rc at zero
> (for example shortfall after zero return values from the alloc helpers).
>
> Jump to the rollback path immediately when either __npc_subbank_alloc()
> call fails, preserving its errno.  If both calls succeed but the total
> allocated count is still less than cnt, set rc to -ENOSPC before rollback.
> Use a separate err variable for npc_mcam_idx_2_subbank_idx() so a
> successful lookup no longer clears a non-zero rc from the allocation
> phase.
>

>> @@ -3533,13 +3535,14 @@ static int npc_defrag_alloc_free_slots(struct rvu *rvu,
>>  			__func__, cnt, alloc_cnt1, alloc_cnt2);
>>  		goto fail_free_alloc;
>>  	}
>> +
>>  	return 0;
>>
>>  fail_free_alloc:
>>  	for (i = 0; i < alloc_cnt1 + alloc_cnt2; i++) {
>> -		rc =  npc_mcam_idx_2_subbank_idx(rvu, save[i],
>> -						 &sb, &sb_off);
>> -		if (rc) {
>> +		err =  npc_mcam_idx_2_subbank_idx(rvu, save[i],
>> +						  &sb, &sb_off);
>> +		if (err) {
>>  			dev_err(rvu->dev,
>>  				"%s: Error to find subbank for mcam idx=%u\n",
>>  				__func__, save[i]);
>Does the diff implement what the commit message describes?
>The commit message states:
>    Jump to the rollback path immediately when either __npc_subbank_alloc()
>    call fails, preserving its errno.  If both calls succeed but the total
>    allocated count is still less than cnt, set rc to -ENOSPC before
>    rollback.
>Looking at npc_defrag_alloc_free_slots() after the patch applies, there
>is no early jump after the first __npc_subbank_alloc() call, and no
>assignment of rc = -ENOSPC before the goto:

ACK.
pw-bot: changes-requested

>> @@ -3533,13 +3535,14 @@ static int npc_defrag_alloc_free_slots(struct rvu *rvu,
>>  			__func__, cnt, alloc_cnt1, alloc_cnt2);
>>  		goto fail_free_alloc;
>>  	}
>> +
>>  	return 0;
>>
>>  fail_free_alloc:
>>  	for (i = 0; i < alloc_cnt1 + alloc_cnt2; i++) {
>> -		rc =  npc_mcam_idx_2_subbank_idx(rvu, save[i],
>> -						 &sb, &sb_off);
>> -		if (rc) {
>> +		err =  npc_mcam_idx_2_subbank_idx(rvu, save[i],
>> +						  &sb, &sb_off);
>> +		if (err) {
>>  			dev_err(rvu->dev,
>>  				"%s: Error to find subbank for mcam idx=%u\n",
>>  				__func__, save[i]);
>Does the diff implement what the commit message describes?
>The commit message states:
>    Jump to the rollback path immediately when either __npc_subbank_alloc()
>    call fails, preserving its errno.  If both calls succeed but the total
>    allocated count is still less than cnt, set rc to -ENOSPC before
>    rollback.
>Looking at npc_defrag_alloc_free_slots() after the patch applies, there
>is no early jump after the first __npc_subbank_alloc() call, and no
>assignment of rc = -ENOSPC before the goto:

ACK.

  reply	other threads:[~2026-04-27  9:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  6:32 [PATCH v4 net 0/10] octeontx2-af: npc: cn20k: MCAM fixes Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 01/10] octeontx2-af: npc: cn20k: Propagate MCAM key-type errors on cn20k Ratheesh Kannoth
2026-04-27  9:45   ` Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 02/10] octeontx2-af: npc: cn20k: Drop debugfs_create_file() error checks in init Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 03/10] octeontx2-af: npc: cn20k: Propagate errors in defrag MCAM alloc rollback Ratheesh Kannoth
2026-04-27  9:56   ` Ratheesh Kannoth [this message]
2026-04-27  6:32 ` [PATCH v4 net 04/10] octeontx2-af: npc: cn20k: Fix target map and rule Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 05/10] octeontx2-af: npc: cn20k: Clear MCAM entries by index and key width Ratheesh Kannoth
2026-04-27 10:01   ` Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 06/10] octeontx2-af: npc: cn20k: Fix bank value Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 07/10] octeontx2-af: npc: cn20k: Fix MCAM actions read Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 08/10] octeontx2-af: npc: cn20k: Initialize default-rule index outputs up front Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 09/10] octeontx2-af: npc: cn20k: Tear down default MCAM rules explicitly on free Ratheesh Kannoth
2026-04-27 10:09   ` Ratheesh Kannoth
2026-04-27  6:32 ` [PATCH v4 net 10/10] octeontx2-af: npc: cn20k: Reject missing default-rule MCAM indices Ratheesh Kannoth
2026-04-27 10:13   ` Ratheesh Kannoth

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=ae8y0-w3KRGRME_B@rkannoth-OptiPlex-7090 \
    --to=rkannoth@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=error27@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sgoutham@marvell.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