> -----Original Message----- > From: Sergey Shtylyov <s.shtylyov@xxxxxx> > Sent: Saturday, August 20, 2022 12:34 PM > To: Keller, Jacob E <jacob.e.keller@xxxxxxxxx>; netdev@xxxxxxxxxxxxxxx > Cc: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>; Haiyang Zhang > <haiyangz@xxxxxxxxxxxxx>; Stephen Hemminger <sthemmin@xxxxxxxxxxxxx>; > Wei Liu <wei.liu@xxxxxxxxxx>; Cui, Dexuan <decui@xxxxxxxxxxxxx>; Tom > Lendacky <thomas.lendacky@xxxxxxx>; Shyam Sundar S K <Shyam-sundar.S- > k@xxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Eric Dumazet > <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni > <pabeni@xxxxxxxxxx>; Siva Reddy Kallam <siva.kallam@xxxxxxxxxxxx>; > Prashant Sreedharan <prashant@xxxxxxxxxxxx>; Michael Chan > <mchan@xxxxxxxxxxxx>; Yisen Zhuang <yisen.zhuang@xxxxxxxxxx>; Salil > Mehta <salil.mehta@xxxxxxxxxx>; Brandeburg, Jesse > <jesse.brandeburg@xxxxxxxxx>; Nguyen, Anthony L > <anthony.l.nguyen@xxxxxxxxx>; Tariq Toukan <tariqt@xxxxxxxxxx>; Saeed > Mahameed <saeedm@xxxxxxxxxx>; Leon Romanovsky <leon@xxxxxxxxxx>; > Bryan Whitehead <bryan.whitehead@xxxxxxxxxxxxx>; Giuseppe Cavallaro > <peppe.cavallaro@xxxxxx>; Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx>; > Jose Abreu <joabreu@xxxxxxxxxxxx>; Maxime Coquelin > <mcoquelin.stm32@xxxxxxxxx>; Richard Cochran <richardcochran@xxxxxxxxx>; > Thampi, Vivek <vithampi@xxxxxxxxxx>; VMware PV-Drivers Reviewers <pv- > drivers@xxxxxxxxxx>; Jie Wang <wangjie125@xxxxxxxxxx>; Guangbin Huang > <huangguangbin2@xxxxxxxxxx>; Eran Ben Elisha <eranbe@xxxxxxxxxx>; Aya > Levin <ayal@xxxxxxxxxx>; Cai Huoqing <cai.huoqing@xxxxxxxxx>; Biju Das > <biju.das.jz@xxxxxxxxxxxxxx>; Lad Prabhakar <prabhakar.mahadev- > lad.rj@xxxxxxxxxxxxxx>; Phil Edworthy <phil.edworthy@xxxxxxxxxxx>; Jiasheng > Jiang <jiasheng@xxxxxxxxxxx>; Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>; Linus > Walleij <linus.walleij@xxxxxxxxxx>; Wan Jiabing <wanjiabing@xxxxxxxx>; Lv Ruyi > <lv.ruyi@xxxxxxxxxx>; Arnd Bergmann <arnd@xxxxxxxx>; linux-renesas- > soc@xxxxxxxxxxxxxxx > Subject: Re: [net-next 11/14] ptp: ravb: convert to .adjfine and > adjust_by_scaled_ppm > > Hello! > > On 8/19/22 1:27 AM, Jacob Keller wrote: > > > The ravb implementation of .adjfreq is implemented in terms of a > > straight forward "base * ppb / 1 billion" calculation. > > > > Convert this driver to .adjfine and use the adjust_by_scaled_ppm helper > > function to calculate the new addend. > > > > Signed-off-by: Jacob Keller <jacob.e.keller@xxxxxxxxx> > > Cc: Sergey Shtylyov <s.shtylyov@xxxxxx> > > Cc: Biju Das <biju.das.jz@xxxxxxxxxxxxxx> > > Cc: Phil Edworthy <phil.edworthy@xxxxxxxxxxx> > > Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> > > Cc: linux-renesas-soc@xxxxxxxxxxxxxxx > > --- > > > > I do not have this hardware, and have only compile tested the change. > > > > drivers/net/ethernet/renesas/ravb_ptp.c | 16 +++++----------- > > 1 file changed, 5 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c > b/drivers/net/ethernet/renesas/ravb_ptp.c > > index 87c4306d66ec..941aa3b0e8a0 100644 > > --- a/drivers/net/ethernet/renesas/ravb_ptp.c > > +++ b/drivers/net/ethernet/renesas/ravb_ptp.c > > @@ -88,24 +88,18 @@ static int ravb_ptp_update_compare(struct > ravb_private *priv, u32 ns) > > } > > > > /* PTP clock operations */ > > -static int ravb_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) > > +static int ravb_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) > > { > > struct ravb_private *priv = container_of(ptp, struct ravb_private, > > ptp.info); > > struct net_device *ndev = priv->ndev; > > unsigned long flags; > > - u32 diff, addend; > > - bool neg_adj = false; > > + u32 addend; > > u32 gccr; > > > > - if (ppb < 0) { > > - neg_adj = true; > > - ppb = -ppb; > > - } > > addend = priv->ptp.default_addend; > > I don't think we should keep this line -- it has no effect now... > Yea this can be dropped. > > - diff = div_u64((u64)addend * ppb, NSEC_PER_SEC); > > - > > - addend = neg_adj ? addend - diff : addend + diff; > > + addend = (u32)adjust_by_scaled_ppm(priv->ptp.default_addend, > > + scaled_ppm); > > > > spin_lock_irqsave(&priv->lock, flags); > > > [...] > > MBR, Sergey