Re: [net PATCH v2 6/7] octeontx2-af: Skip PFs if not enabled

From: Sai Krishna Gajula
Date: Fri Apr 14 2023 - 07:59:23 EST


Please see inline,

> -----Original Message-----
> From: Simon Horman <simon.horman@xxxxxxxxxxxx>
> Sent: Saturday, April 8, 2023 8:26 PM
> To: Sai Krishna Gajula <saikrishnag@xxxxxxxxxxx>
> Cc: davem@xxxxxxxxxxxxx; edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx;
> pabeni@xxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; Sunil Kovvuri Goutham <sgoutham@xxxxxxxxxxx>;
> Geethasowjanya Akula <gakula@xxxxxxxxxxx>; richardcochran@xxxxxxxxx;
> Linu Cherian <lcherian@xxxxxxxxxxx>; Jerin Jacob Kollanukkaran
> <jerinj@xxxxxxxxxxx>; Hariprasad Kelam <hkelam@xxxxxxxxxxx>;
> Subbaraya Sundeep Bhatta <sbhatta@xxxxxxxxxxx>; Ratheesh Kannoth
> <rkannoth@xxxxxxxxxxx>
> Subject: Re: [net PATCH v2 6/7] octeontx2-af: Skip PFs if not enabled
>
> On Fri, Apr 07, 2023 at 05:53:43PM +0530, Sai Krishna wrote:
> > From: Ratheesh Kannoth <rkannoth@xxxxxxxxxxx>
> >
> > Skip mbox initialization of disabled PFs. Firmware configures PFs and
> > allocate mbox resources etc. Linux should configure particular PFs,
> > which ever are enabled by firmware.
> >
> > Fixes: 9bdc47a6e328 ("octeontx2-af: Mbox communication support btw AF
> > and it's VFs")
> > Signed-off-by: Ratheesh Kannoth <rkannoth@xxxxxxxxxxx>
> > Signed-off-by: Sunil Kovvuri Goutham <sgoutham@xxxxxxxxxxx>
> > Signed-off-by: Sai Krishna <saikrishnag@xxxxxxxxxxx>
>
> ...
>
> > @@ -2343,8 +2349,27 @@ static int rvu_mbox_init(struct rvu *rvu, struct
> mbox_wq_info *mw,
> > int err = -EINVAL, i, dir, dir_up;
> > void __iomem *reg_base;
> > struct rvu_work *mwork;
> > + unsigned long *pf_bmap;
> > void **mbox_regions;
> > const char *name;
> > + u64 cfg;
> > +
> > + pf_bmap = devm_kcalloc(rvu->dev, BITS_TO_LONGS(num),
> sizeof(long),
> > +GFP_KERNEL);
>
> Hi Sai and Ratheesh,
>
> I am a little confused about the lifecycle of pf_bmap.
> It is a local variable of this function.
> But it is allocated using devm_kcalloc(), so it will persist for the life of the
> device.
>
> Also, I note that rvu_mbox_init() has too call sites.
> So is there a situation where a pf_bmap is allocated more than once for the
> same rvu->dev instance?
>
> It seems to me it would be more appropriate to allocate bf_bmap using
> kcalloc() take clear to free it before leaving rvu_mbox_init(), as is already
> done for mbox_regions.
>

We will prepare v3 patch according to the suggested changes using kcalloc().

> > + if (!pf_bmap)
> > + return -ENOMEM;
>
> ...