Re: [EXT] Re: [net v4 PATCH 1/1] net: mvpp2: clear BM pool before initialization

From: Maxime Chevallier
Date: Tue Jan 23 2024 - 04:15:29 EST


Hi,

On Mon, 22 Jan 2024 06:02:07 +0000
"Jenishkumar Patel [C]" <jpatel2@xxxxxxxxxxx> wrote:

> > > +/* Cleanup pool before actual initialization in the OS */ static void
> > > +mvpp2_bm_pool_cleanup(struct mvpp2 *priv, int pool_id) {
> > > + unsigned int thread = mvpp2_cpu_to_thread(priv, get_cpu());
> > > + u32 val;
> > > + int i;
> > > +
> > > + /* Drain the BM from all possible residues left by firmware */
> > > + for (i = 0; i < MVPP2_BM_POOL_SIZE_MAX; i++)
> > > + mvpp2_thread_read(priv, thread, MVPP2_BM_PHY_ALLOC_REG(pool_id));
> >
> > ... I think you didn't answer Antoine's comment on that loop from the V2, regarding what this does exactly. From the other sites this is used, it seems to perform an allocation from the pool, can you clarify how safe it is to do so here, if for example the BM was never configured by the firmware beforehand and is therefore already in a Stopped state ?
>
> Reading the register provides a pointer to buffer that is already allocated during BM initialization. When multiple reading is done on the register, it will drain all the pointers that are stored by previous firmware. Also reading this register does not perform any allocation as it is only performing register read operation, thus when the BM is not configured earlier then it will not lead to any stop state.
>
> > And are we not risking any leak if there was something in the pool that we don't release ?
>
> The data on the pointer given by register read is written after the read operation is preformed, which means the pointer does not contain any data, thus there is no leak.

Thanks for your answers, I think that's clear to me then.

Reviewed-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>

Maxime