[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<PAXPR04MB8510867173CB0A11998D875E88E22@PAXPR04MB8510.eurprd04.prod.outlook.com>
Date: Mon, 13 May 2024 12:18:29 +0000
From: Wei Fang <wei.fang@....com>
To: Eric Dumazet <edumazet@...gle.com>
CC: "davem@...emloft.net" <davem@...emloft.net>, "kuba@...nel.org"
<kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>, Shenwei Wang
<shenwei.wang@....com>, Clark Wang <xiaoning.wang@....com>,
"richardcochran@...il.com" <richardcochran@...il.com>, "andrew@...n.ch"
<andrew@...n.ch>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>
Subject: RE: [PATCH net] net: fec: avoid lock evasion when reading pps_enable
> -----Original Message-----
> From: Eric Dumazet <edumazet@...gle.com>
> Sent: 2024年5月13日 16:41
> To: Wei Fang <wei.fang@....com>
> Cc: davem@...emloft.net; kuba@...nel.org; pabeni@...hat.com; Shenwei
> Wang <shenwei.wang@....com>; Clark Wang <xiaoning.wang@....com>;
> richardcochran@...il.com; andrew@...n.ch; netdev@...r.kernel.org;
> linux-kernel@...r.kernel.org; imx@...ts.linux.dev
> Subject: Re: [PATCH net] net: fec: avoid lock evasion when reading
> pps_enable
>
> On Mon, May 13, 2024 at 9:53 AM Wei Fang <wei.fang@....com> wrote:
> >
> > > -----Original Message-----
> > > From: Eric Dumazet <edumazet@...gle.com>
> > > Sent: 2024年5月13日 15:29
> > > To: Wei Fang <wei.fang@....com>
> > > Cc: davem@...emloft.net; kuba@...nel.org; pabeni@...hat.com;
> Shenwei
> > > Wang <shenwei.wang@....com>; Clark Wang
> <xiaoning.wang@....com>;
> > > richardcochran@...il.com; andrew@...n.ch; netdev@...r.kernel.org;
> > > linux-kernel@...r.kernel.org; imx@...ts.linux.dev
> > > Subject: Re: [PATCH net] net: fec: avoid lock evasion when reading
> > > pps_enable
> > >
> > > On Mon, May 13, 2024 at 4:02 AM Wei Fang <wei.fang@....com>
> wrote:
> > > >
> > > > The assignment of pps_enable is protected by tmreg_lock, but the
> > > > read operation of pps_enable is not. So the Coverity tool reports
> > > > a lock evasion warning which may cause data race to occur when
> > > > running in a multithread environment. Although this issue is
> > > > almost impossible to occur, we'd better fix it, at least it seems
> > > > more logically reasonable, and it also prevents Coverity from continuing
> to issue warnings.
> > > >
> > > > Fixes: 278d24047891 ("net: fec: ptp: Enable PPS output based on
> > > > ptp
> > > > clock")
> > > > Signed-off-by: Wei Fang <wei.fang@....com>
> > > > ---
> > > > drivers/net/ethernet/freescale/fec_ptp.c | 8 +++++---
> > > > 1 file changed, 5 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/net/ethernet/freescale/fec_ptp.c
> > > > b/drivers/net/ethernet/freescale/fec_ptp.c
> > > > index 181d9bfbee22..8d37274a3fb0 100644
> > > > --- a/drivers/net/ethernet/freescale/fec_ptp.c
> > > > +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> > > > @@ -104,14 +104,16 @@ static int fec_ptp_enable_pps(struct
> > > fec_enet_private *fep, uint enable)
> > > > struct timespec64 ts;
> > > > u64 ns;
> > > >
> > > > - if (fep->pps_enable == enable)
> > > > - return 0;
> > > > -
> > > > fep->pps_channel = DEFAULT_PPS_CHANNEL;
> > > > fep->reload_period = PPS_OUPUT_RELOAD_PERIOD;
> > >
> > > Why are these writes left without the spinlock protection ?
> > For fec driver, the pps_channel and the reload_period of PPS request
> > are always fixed, and they were also not protected by the lock in the
> > original code.
>
> If this is the case, please move this initialization elsewhere, so that we can be
> absolutely sure of the claim.
>
Accept, thanks
> I see fep->reload_period being overwritten in this file, I do not see clear
> evidence this is all safe.
Powered by blists - more mailing lists