Re: [PATCH rdma-next 1/4] RDMA/bnxt_re: Simplify bnxt_re_init_depth() callers and implementation
From: Selvin Xavier
Date: Mon Mar 23 2026 - 13:19:55 EST
On Mon, Mar 23, 2026 at 4:44 PM Leon Romanovsky <leon@xxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxx> wrote:
> > >
> > > From: Leon Romanovsky <leonro@xxxxxxxxxx>
> > >
> > > 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@xxxxxxxxxx>
> > > ---
> > > 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.
Oh. ok. i missed that. Thanks
Acked-by: Selvin Xavier <selvin.xavier@xxxxxxxxxxxx>
>
> Thanks
>
> >
> > > +
> > > + return ent;
> > > }
> > >
> > > static inline bool bnxt_re_is_var_size_supported(struct bnxt_re_dev *rdev,
> > >
> > > --
> > > 2.53.0
> > >
>
>
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature