Message ID | 20220818222742.1070935-15-jacob.e.keller@intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ptp: convert drivers to .adjfine | expand |
On 8/18/22 17:27, Jacob Keller wrote: > The xgbe implementation of .adjfreq is implemented in terms of a > straight forward "base * ppb / 1 billion" calculation. > > Convert this driver to .adjfine and use adjust_by_scaled_ppm to calculate > the new addend value. > > Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> > Cc: Tom Lendacky <thomas.lendacky@amd.com> > Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> > --- > > I do not have this hardware, and have only compile tested the change. > > drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 20 ++++---------------- > 1 file changed, 4 insertions(+), 16 deletions(-) > > diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > index d06d260cf1e2..7051bd7cf6dc 100644 > --- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > @@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter *cc) > return nsec; > } > > -static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) > +static int xgbe_adjfine(struct ptp_clock_info *info, long scaled_ppm) > { > struct xgbe_prv_data *pdata = container_of(info, > struct xgbe_prv_data, > ptp_clock_info); > unsigned long flags; > - u64 adjust; > - u32 addend, diff; > - unsigned int neg_adjust = 0; > + u64 addend; > > - if (delta < 0) { > - neg_adjust = 1; > - delta = -delta; > - } > - > - adjust = pdata->tstamp_addend; > - adjust *= delta; > - diff = div_u64(adjust, 1000000000UL); > - > - addend = (neg_adjust) ? pdata->tstamp_addend - diff : > - pdata->tstamp_addend + diff; > + addend = adjust_by_scaled_ppm(pdata->tstamp_addend, scaled_ppm); Since addend is now a u64, but the called function just afterwards, xgbe_update_tstamp_addend(), expects an unsigned int, won't this generate a compiler warning depending on the flags used? Thanks, Tom > > spin_lock_irqsave(&pdata->tstamp_lock, flags); > > @@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) > netdev_name(pdata->netdev)); > info->owner = THIS_MODULE; > info->max_adj = pdata->ptpclk_rate; > - info->adjfreq = xgbe_adjfreq; > + info->adjfine = xgbe_adjfine; > info->adjtime = xgbe_adjtime; > info->gettime64 = xgbe_gettime; > info->settime64 = xgbe_settime;
> -----Original Message----- > From: Tom Lendacky <thomas.lendacky@amd.com> > Sent: Friday, August 19, 2022 9:05 AM > To: Keller, Jacob E <jacob.e.keller@intel.com>; netdev@vger.kernel.org > Cc: K. Y. Srinivasan <kys@microsoft.com>; Haiyang Zhang > <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>; > Wei Liu <wei.liu@kernel.org>; Cui, Dexuan <decui@microsoft.com>; Shyam > Sundar S K <Shyam-sundar.S-k@amd.com>; David S. Miller > <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski > <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Siva Reddy Kallam > <siva.kallam@broadcom.com>; Prashant Sreedharan > <prashant@broadcom.com>; Michael Chan <mchan@broadcom.com>; Yisen > Zhuang <yisen.zhuang@huawei.com>; Salil Mehta <salil.mehta@huawei.com>; > Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com>; Tariq Toukan <tariqt@nvidia.com>; Saeed > Mahameed <saeedm@nvidia.com>; Leon Romanovsky <leon@kernel.org>; > Bryan Whitehead <bryan.whitehead@microchip.com>; Sergey Shtylyov > <s.shtylyov@omp.ru>; Giuseppe Cavallaro <peppe.cavallaro@st.com>; > Alexandre Torgue <alexandre.torgue@foss.st.com>; Jose Abreu > <joabreu@synopsys.com>; Maxime Coquelin <mcoquelin.stm32@gmail.com>; > Richard Cochran <richardcochran@gmail.com>; Thampi, Vivek > <vithampi@vmware.com>; VMware PV-Drivers Reviewers <pv- > drivers@vmware.com>; Jie Wang <wangjie125@huawei.com>; Guangbin Huang > <huangguangbin2@huawei.com>; Eran Ben Elisha <eranbe@nvidia.com>; Aya > Levin <ayal@nvidia.com>; Cai Huoqing <cai.huoqing@linux.dev>; Biju Das > <biju.das.jz@bp.renesas.com>; Lad Prabhakar <prabhakar.mahadev- > lad.rj@bp.renesas.com>; Phil Edworthy <phil.edworthy@renesas.com>; Jiasheng > Jiang <jiasheng@iscas.ac.cn>; Gustavo A. R. Silva <gustavoars@kernel.org>; Linus > Walleij <linus.walleij@linaro.org>; Wan Jiabing <wanjiabing@vivo.com>; Lv Ruyi > <lv.ruyi@zte.com.cn>; Arnd Bergmann <arnd@arndb.de> > Subject: Re: [net-next 14/14] ptp: xgbe: convert to .adjfine and > adjust_by_scaled_ppm > > On 8/18/22 17:27, Jacob Keller wrote: > > The xgbe implementation of .adjfreq is implemented in terms of a > > straight forward "base * ppb / 1 billion" calculation. > > > > Convert this driver to .adjfine and use adjust_by_scaled_ppm to calculate > > the new addend value. > > > > Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> > > Cc: Tom Lendacky <thomas.lendacky@amd.com> > > Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> > > --- > > > > I do not have this hardware, and have only compile tested the change. > > > > drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 20 ++++---------------- > > 1 file changed, 4 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > > index d06d260cf1e2..7051bd7cf6dc 100644 > > --- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > > +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > > @@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter > *cc) > > return nsec; > > } > > > > -static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) > > +static int xgbe_adjfine(struct ptp_clock_info *info, long scaled_ppm) > > { > > struct xgbe_prv_data *pdata = container_of(info, > > struct xgbe_prv_data, > > ptp_clock_info); > > unsigned long flags; > > - u64 adjust; > > - u32 addend, diff; > > - unsigned int neg_adjust = 0; > > + u64 addend; > > > > - if (delta < 0) { > > - neg_adjust = 1; > > - delta = -delta; > > - } > > - > > - adjust = pdata->tstamp_addend; > > - adjust *= delta; > > - diff = div_u64(adjust, 1000000000UL); > > - > > - addend = (neg_adjust) ? pdata->tstamp_addend - diff : > > - pdata->tstamp_addend + diff; > > + addend = adjust_by_scaled_ppm(pdata->tstamp_addend, scaled_ppm); > > Since addend is now a u64, but the called function just afterwards, > xgbe_update_tstamp_addend(), expects an unsigned int, won't this generate > a compiler warning depending on the flags used? > It doesn't seem to generate anything with W=1 or W=2 on my system. Its possible that the compiler can deduce that this won't overflow a u32? We could add a check to ensure it doesn't overflow the u32 size? > Thanks, > Tom > > > > > spin_lock_irqsave(&pdata->tstamp_lock, flags); > > > > @@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) > > netdev_name(pdata->netdev)); > > info->owner = THIS_MODULE; > > info->max_adj = pdata->ptpclk_rate; > > - info->adjfreq = xgbe_adjfreq; > > + info->adjfine = xgbe_adjfine; > > info->adjtime = xgbe_adjtime; > > info->gettime64 = xgbe_gettime; > > info->settime64 = xgbe_settime;
On 8/19/22 16:04, Keller, Jacob E wrote: >> -----Original Message----- >> From: Tom Lendacky <thomas.lendacky@amd.com> >> Sent: Friday, August 19, 2022 9:05 AM >> To: Keller, Jacob E <jacob.e.keller@intel.com>; netdev@vger.kernel.org >> Cc: K. Y. Srinivasan <kys@microsoft.com>; Haiyang Zhang >> <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>; >> Wei Liu <wei.liu@kernel.org>; Cui, Dexuan <decui@microsoft.com>; Shyam >> Sundar S K <Shyam-sundar.S-k@amd.com>; David S. Miller >> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski >> <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Siva Reddy Kallam >> <siva.kallam@broadcom.com>; Prashant Sreedharan >> <prashant@broadcom.com>; Michael Chan <mchan@broadcom.com>; Yisen >> Zhuang <yisen.zhuang@huawei.com>; Salil Mehta <salil.mehta@huawei.com>; >> Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L >> <anthony.l.nguyen@intel.com>; Tariq Toukan <tariqt@nvidia.com>; Saeed >> Mahameed <saeedm@nvidia.com>; Leon Romanovsky <leon@kernel.org>; >> Bryan Whitehead <bryan.whitehead@microchip.com>; Sergey Shtylyov >> <s.shtylyov@omp.ru>; Giuseppe Cavallaro <peppe.cavallaro@st.com>; >> Alexandre Torgue <alexandre.torgue@foss.st.com>; Jose Abreu >> <joabreu@synopsys.com>; Maxime Coquelin <mcoquelin.stm32@gmail.com>; >> Richard Cochran <richardcochran@gmail.com>; Thampi, Vivek >> <vithampi@vmware.com>; VMware PV-Drivers Reviewers <pv- >> drivers@vmware.com>; Jie Wang <wangjie125@huawei.com>; Guangbin Huang >> <huangguangbin2@huawei.com>; Eran Ben Elisha <eranbe@nvidia.com>; Aya >> Levin <ayal@nvidia.com>; Cai Huoqing <cai.huoqing@linux.dev>; Biju Das >> <biju.das.jz@bp.renesas.com>; Lad Prabhakar <prabhakar.mahadev- >> lad.rj@bp.renesas.com>; Phil Edworthy <phil.edworthy@renesas.com>; Jiasheng >> Jiang <jiasheng@iscas.ac.cn>; Gustavo A. R. Silva <gustavoars@kernel.org>; Linus >> Walleij <linus.walleij@linaro.org>; Wan Jiabing <wanjiabing@vivo.com>; Lv Ruyi >> <lv.ruyi@zte.com.cn>; Arnd Bergmann <arnd@arndb.de> >> Subject: Re: [net-next 14/14] ptp: xgbe: convert to .adjfine and >> adjust_by_scaled_ppm >> >> On 8/18/22 17:27, Jacob Keller wrote: >>> The xgbe implementation of .adjfreq is implemented in terms of a >>> straight forward "base * ppb / 1 billion" calculation. >>> >>> Convert this driver to .adjfine and use adjust_by_scaled_ppm to calculate >>> the new addend value. >>> >>> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> >>> Cc: Tom Lendacky <thomas.lendacky@amd.com> >>> Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> >>> --- >>> >>> I do not have this hardware, and have only compile tested the change. >>> >>> drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 20 ++++---------------- >>> 1 file changed, 4 insertions(+), 16 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c >> b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c >>> index d06d260cf1e2..7051bd7cf6dc 100644 >>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c >>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c >>> @@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter >> *cc) >>> return nsec; >>> } >>> >>> -static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) >>> +static int xgbe_adjfine(struct ptp_clock_info *info, long scaled_ppm) >>> { >>> struct xgbe_prv_data *pdata = container_of(info, >>> struct xgbe_prv_data, >>> ptp_clock_info); >>> unsigned long flags; >>> - u64 adjust; >>> - u32 addend, diff; >>> - unsigned int neg_adjust = 0; >>> + u64 addend; >>> >>> - if (delta < 0) { >>> - neg_adjust = 1; >>> - delta = -delta; >>> - } >>> - >>> - adjust = pdata->tstamp_addend; >>> - adjust *= delta; >>> - diff = div_u64(adjust, 1000000000UL); >>> - >>> - addend = (neg_adjust) ? pdata->tstamp_addend - diff : >>> - pdata->tstamp_addend + diff; >>> + addend = adjust_by_scaled_ppm(pdata->tstamp_addend, scaled_ppm); >> >> Since addend is now a u64, but the called function just afterwards, >> xgbe_update_tstamp_addend(), expects an unsigned int, won't this generate >> a compiler warning depending on the flags used? >> > > It doesn't seem to generate anything with W=1 or W=2 on my system. Its possible that the compiler can deduce that this won't overflow a u32? > > We could add a check to ensure it doesn't overflow the u32 size? As long as we don't see a warning, I'm ok with it. Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Thanks, Tom > >> Thanks, >> Tom >> >>> >>> spin_lock_irqsave(&pdata->tstamp_lock, flags); >>> >>> @@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) >>> netdev_name(pdata->netdev)); >>> info->owner = THIS_MODULE; >>> info->max_adj = pdata->ptpclk_rate; >>> - info->adjfreq = xgbe_adjfreq; >>> + info->adjfine = xgbe_adjfine; >>> info->adjtime = xgbe_adjtime; >>> info->gettime64 = xgbe_gettime; >>> info->settime64 = xgbe_settime;
> -----Original Message----- > From: Tom Lendacky <thomas.lendacky@amd.com> > Sent: Monday, August 22, 2022 1:48 PM > To: Keller, Jacob E <jacob.e.keller@intel.com>; netdev@vger.kernel.org > Cc: K. Y. Srinivasan <kys@microsoft.com>; Haiyang Zhang > <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>; > Wei Liu <wei.liu@kernel.org>; Cui, Dexuan <decui@microsoft.com>; Shyam > Sundar S K <Shyam-sundar.S-k@amd.com>; David S. Miller > <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski > <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Siva Reddy Kallam > <siva.kallam@broadcom.com>; Prashant Sreedharan > <prashant@broadcom.com>; Michael Chan <mchan@broadcom.com>; Yisen > Zhuang <yisen.zhuang@huawei.com>; Salil Mehta <salil.mehta@huawei.com>; > Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com>; Tariq Toukan <tariqt@nvidia.com>; Saeed > Mahameed <saeedm@nvidia.com>; Leon Romanovsky <leon@kernel.org>; > Bryan Whitehead <bryan.whitehead@microchip.com>; Sergey Shtylyov > <s.shtylyov@omp.ru>; Giuseppe Cavallaro <peppe.cavallaro@st.com>; > Alexandre Torgue <alexandre.torgue@foss.st.com>; Jose Abreu > <joabreu@synopsys.com>; Maxime Coquelin <mcoquelin.stm32@gmail.com>; > Richard Cochran <richardcochran@gmail.com>; Thampi, Vivek > <vithampi@vmware.com>; VMware PV-Drivers Reviewers <pv- > drivers@vmware.com>; Jie Wang <wangjie125@huawei.com>; Guangbin Huang > <huangguangbin2@huawei.com>; Eran Ben Elisha <eranbe@nvidia.com>; Aya > Levin <ayal@nvidia.com>; Cai Huoqing <cai.huoqing@linux.dev>; Biju Das > <biju.das.jz@bp.renesas.com>; Lad Prabhakar <prabhakar.mahadev- > lad.rj@bp.renesas.com>; Phil Edworthy <phil.edworthy@renesas.com>; Jiasheng > Jiang <jiasheng@iscas.ac.cn>; Gustavo A. R. Silva <gustavoars@kernel.org>; Linus > Walleij <linus.walleij@linaro.org>; Wan Jiabing <wanjiabing@vivo.com>; Lv Ruyi > <lv.ruyi@zte.com.cn>; Arnd Bergmann <arnd@arndb.de> > Subject: Re: [net-next 14/14] ptp: xgbe: convert to .adjfine and > adjust_by_scaled_ppm > > On 8/19/22 16:04, Keller, Jacob E wrote: > >> -----Original Message----- > >> From: Tom Lendacky <thomas.lendacky@amd.com> > >> Sent: Friday, August 19, 2022 9:05 AM > >> To: Keller, Jacob E <jacob.e.keller@intel.com>; netdev@vger.kernel.org > >> Cc: K. Y. Srinivasan <kys@microsoft.com>; Haiyang Zhang > >> <haiyangz@microsoft.com>; Stephen Hemminger > <sthemmin@microsoft.com>; > >> Wei Liu <wei.liu@kernel.org>; Cui, Dexuan <decui@microsoft.com>; Shyam > >> Sundar S K <Shyam-sundar.S-k@amd.com>; David S. Miller > >> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub > Kicinski > >> <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Siva Reddy Kallam > >> <siva.kallam@broadcom.com>; Prashant Sreedharan > >> <prashant@broadcom.com>; Michael Chan <mchan@broadcom.com>; Yisen > >> Zhuang <yisen.zhuang@huawei.com>; Salil Mehta > <salil.mehta@huawei.com>; > >> Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L > >> <anthony.l.nguyen@intel.com>; Tariq Toukan <tariqt@nvidia.com>; Saeed > >> Mahameed <saeedm@nvidia.com>; Leon Romanovsky <leon@kernel.org>; > >> Bryan Whitehead <bryan.whitehead@microchip.com>; Sergey Shtylyov > >> <s.shtylyov@omp.ru>; Giuseppe Cavallaro <peppe.cavallaro@st.com>; > >> Alexandre Torgue <alexandre.torgue@foss.st.com>; Jose Abreu > >> <joabreu@synopsys.com>; Maxime Coquelin > <mcoquelin.stm32@gmail.com>; > >> Richard Cochran <richardcochran@gmail.com>; Thampi, Vivek > >> <vithampi@vmware.com>; VMware PV-Drivers Reviewers <pv- > >> drivers@vmware.com>; Jie Wang <wangjie125@huawei.com>; Guangbin > Huang > >> <huangguangbin2@huawei.com>; Eran Ben Elisha <eranbe@nvidia.com>; Aya > >> Levin <ayal@nvidia.com>; Cai Huoqing <cai.huoqing@linux.dev>; Biju Das > >> <biju.das.jz@bp.renesas.com>; Lad Prabhakar <prabhakar.mahadev- > >> lad.rj@bp.renesas.com>; Phil Edworthy <phil.edworthy@renesas.com>; > Jiasheng > >> Jiang <jiasheng@iscas.ac.cn>; Gustavo A. R. Silva <gustavoars@kernel.org>; > Linus > >> Walleij <linus.walleij@linaro.org>; Wan Jiabing <wanjiabing@vivo.com>; Lv > Ruyi > >> <lv.ruyi@zte.com.cn>; Arnd Bergmann <arnd@arndb.de> > >> Subject: Re: [net-next 14/14] ptp: xgbe: convert to .adjfine and > >> adjust_by_scaled_ppm > >> > >> On 8/18/22 17:27, Jacob Keller wrote: > >>> The xgbe implementation of .adjfreq is implemented in terms of a > >>> straight forward "base * ppb / 1 billion" calculation. > >>> > >>> Convert this driver to .adjfine and use adjust_by_scaled_ppm to calculate > >>> the new addend value. > >>> > >>> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> > >>> Cc: Tom Lendacky <thomas.lendacky@amd.com> > >>> Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> > >>> --- > >>> > >>> I do not have this hardware, and have only compile tested the change. > >>> > >>> drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 20 ++++---------------- > >>> 1 file changed, 4 insertions(+), 16 deletions(-) > >>> > >>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > >> b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > >>> index d06d260cf1e2..7051bd7cf6dc 100644 > >>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > >>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c > >>> @@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter > >> *cc) > >>> return nsec; > >>> } > >>> > >>> -static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) > >>> +static int xgbe_adjfine(struct ptp_clock_info *info, long scaled_ppm) > >>> { > >>> struct xgbe_prv_data *pdata = container_of(info, > >>> struct xgbe_prv_data, > >>> ptp_clock_info); > >>> unsigned long flags; > >>> - u64 adjust; > >>> - u32 addend, diff; > >>> - unsigned int neg_adjust = 0; > >>> + u64 addend; > >>> > >>> - if (delta < 0) { > >>> - neg_adjust = 1; > >>> - delta = -delta; > >>> - } > >>> - > >>> - adjust = pdata->tstamp_addend; > >>> - adjust *= delta; > >>> - diff = div_u64(adjust, 1000000000UL); > >>> - > >>> - addend = (neg_adjust) ? pdata->tstamp_addend - diff : > >>> - pdata->tstamp_addend + diff; > >>> + addend = adjust_by_scaled_ppm(pdata->tstamp_addend, scaled_ppm); > >> > >> Since addend is now a u64, but the called function just afterwards, > >> xgbe_update_tstamp_addend(), expects an unsigned int, won't this generate > >> a compiler warning depending on the flags used? > >> > > > > It doesn't seem to generate anything with W=1 or W=2 on my system. Its > possible that the compiler can deduce that this won't overflow a u32? > > > > We could add a check to ensure it doesn't overflow the u32 size? > > As long as we don't see a warning, I'm ok with it. > > Acked-by: Tom Lendacky <thomas.lendacky@amd.com> > > Thanks, > Tom > Thanks. Since I'll need to send a v2 to fix some other drivers, I will double check this doesn't produce a warning carefully when I send the v2. Thanks, Jake > > > >> Thanks, > >> Tom > >> > >>> > >>> spin_lock_irqsave(&pdata->tstamp_lock, flags); > >>> > >>> @@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) > >>> netdev_name(pdata->netdev)); > >>> info->owner = THIS_MODULE; > >>> info->max_adj = pdata->ptpclk_rate; > >>> - info->adjfreq = xgbe_adjfreq; > >>> + info->adjfine = xgbe_adjfine; > >>> info->adjtime = xgbe_adjtime; > >>> info->gettime64 = xgbe_gettime; > >>> info->settime64 = xgbe_settime;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c index d06d260cf1e2..7051bd7cf6dc 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-ptp.c @@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter *cc) return nsec; } -static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) +static int xgbe_adjfine(struct ptp_clock_info *info, long scaled_ppm) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data, ptp_clock_info); unsigned long flags; - u64 adjust; - u32 addend, diff; - unsigned int neg_adjust = 0; + u64 addend; - if (delta < 0) { - neg_adjust = 1; - delta = -delta; - } - - adjust = pdata->tstamp_addend; - adjust *= delta; - diff = div_u64(adjust, 1000000000UL); - - addend = (neg_adjust) ? pdata->tstamp_addend - diff : - pdata->tstamp_addend + diff; + addend = adjust_by_scaled_ppm(pdata->tstamp_addend, scaled_ppm); spin_lock_irqsave(&pdata->tstamp_lock, flags); @@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) netdev_name(pdata->netdev)); info->owner = THIS_MODULE; info->max_adj = pdata->ptpclk_rate; - info->adjfreq = xgbe_adjfreq; + info->adjfine = xgbe_adjfine; info->adjtime = xgbe_adjtime; info->gettime64 = xgbe_gettime; info->settime64 = xgbe_settime;
The xgbe implementation of .adjfreq is implemented in terms of a straight forward "base * ppb / 1 billion" calculation. Convert this driver to .adjfine and use adjust_by_scaled_ppm to calculate the new addend value. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> --- I do not have this hardware, and have only compile tested the change. drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)