public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Selvin Xavier <selvin.xavier@broadcom.com>
Cc: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH rdma-next 1/4] RDMA/bnxt_re: Simplify bnxt_re_init_depth() callers and implementation
Date: Mon, 23 Mar 2026 13:14:01 +0200	[thread overview]
Message-ID: <20260323111401.GH814676@unreal> (raw)
In-Reply-To: <CA+sbYW0vhjp49vngMs21DXErN=tMRN3M8uxqSSjOHL+H0uAbvw@mail.gmail.com>

On Mon, Mar 23, 2026 at 11:46:43AM +0530, Selvin Xavier wrote:
> On Wed, Mar 18, 2026 at 3:39 PM Leon Romanovsky <leon@kernel.org> wrote:
> >
> > From: Leon Romanovsky <leonro@nvidia.com>
> >
> > All callers of bnxt_re_init_depth() compute the minimum between its return
> > value and another internal variable, often mixing variable types in the
> > process. Clean this up by making the logic simpler and more readable.
> >
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > ---
> >  drivers/infiniband/hw/bnxt_re/ib_verbs.c | 81 ++++++++++++++------------------
> >  drivers/infiniband/hw/bnxt_re/ib_verbs.h |  9 ++--
> >  2 files changed, 42 insertions(+), 48 deletions(-)

<...>

> > -static inline u32 bnxt_re_init_depth(u32 ent, struct bnxt_re_ucontext *uctx)
> > +static inline u32 bnxt_re_init_depth(u32 ent, u32 max,
> > +                                    struct bnxt_re_ucontext *uctx)
> >  {
> > -       return uctx ? (uctx->cmask & BNXT_RE_UCNTX_CAP_POW2_DISABLED) ?
> > -               ent : roundup_pow_of_two(ent) : ent;
> > +       if (uctx && !(uctx->cmask & BNXT_RE_UCNTX_CAP_POW2_DISABLED))
> > +               return min(roundup_pow_of_two(ent), max);
> Looks like the min setting is missing in the else case. shouldn't we add that?

I did not add it because all callers of bnxt_re_init_depth() already check  
that ent is less than max. However, roundup_pow_of_two() requires a  
min() guard because it can overflow the prior range check.

Thanks

> 
> > +
> > +       return ent;
> >  }
> >
> >  static inline bool bnxt_re_is_var_size_supported(struct bnxt_re_dev *rdev,
> >
> > --
> > 2.53.0
> >



  reply	other threads:[~2026-03-23 11:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 10:08 [PATCH rdma-next 0/4] RDMA/bnxt_re: Miscellaneous cleanups Leon Romanovsky
2026-03-18 10:08 ` [PATCH rdma-next 1/4] RDMA/bnxt_re: Simplify bnxt_re_init_depth() callers and implementation Leon Romanovsky
2026-03-23  6:16   ` Selvin Xavier
2026-03-23 11:14     ` Leon Romanovsky [this message]
2026-03-23 17:08       ` Selvin Xavier
2026-03-18 10:08 ` [PATCH rdma-next 2/4] RDMA/bnxt_re: Remove unnecessary checks in kernel CQ creation path Leon Romanovsky
2026-03-23  6:21   ` Selvin Xavier
2026-03-18 10:08 ` [PATCH rdma-next 3/4] RDMA/bnxt_re: Replace kcalloc() with kzalloc_objs() Leon Romanovsky
2026-03-23  6:45   ` Selvin Xavier
2026-03-18 10:08 ` [PATCH rdma-next 4/4] RDMA/bnxt_re: Clean up uverbs CQ creation path Leon Romanovsky
2026-03-23  6:45   ` Selvin Xavier
2026-03-23 19:25 ` [PATCH rdma-next 0/4] RDMA/bnxt_re: Miscellaneous cleanups Leon Romanovsky

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=20260323111401.GH814676@unreal \
    --to=leon@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=selvin.xavier@broadcom.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