ptp: get ready for 2038
Subsystems (15)
Richard Cochran
maintainerv3 cover ptp: get ready for 2038
This series converts the core driver methods of the PTP Hardware Clock (PHC) subsystem to use the 64 bit version of the timespec structure, making the core API ready for the year 2038.
In addition, I reviewed how each driver and device represents the time value at the hardware register level. Most of the drivers are ready, but a few will need some work before the year 2038, as shown:
Patch Driver
------------------------------------------------
12 drivers/net/ethernet/intel/igb/igb_ptp.c 15 ? drivers/net/ethernet/sfc/ptp.c 16 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
The commit log messages document how each driver is ready or why it is not ready. For patch 15, I could not easily find out the hardware representation of the time value, and so the SFC maintainers will have to review their low level code in order to resolve any remaining issues.
Thanks,
Richard
* ChangeLog
** V3
- dp83640: use timespec64 throughout per Arnd's suggestion
- tilegx: use timespec64 throughout per Chris' suggestion
- add Jeff's acked-bys
** V2
- use the new methods in the posix clock code right away (patch #3)
Richard Cochran (23):
ptp: introduce get/set time methods with explicit 64 bit seconds.
ptp: use the 64 bit gettime method for the SYS_OFFSET ioctl.
ptp: use the 64 bit get/set time methods for the posix clock.
ptp: blackfin: convert to the 64 bit get/set time methods.
ptp: xgbe: convert to the 64 bit get/set time methods.
ptp: bnx2x: convert to the 64 bit get/set time methods.
ptp: tg3: convert to the 64 bit get/set time methods.
ptp: fec: convert to the 64 bit get/set time methods.
ptp: gianfar: convert to the 64 bit get/set time methods.
ptp: e1000e: convert to the 64 bit get/set time methods.
ptp: fm10k: convert to the 64 bit get/set time methods.
ptp: i40e: convert to the 64 bit get/set time methods.
ptp: igb: convert to the 64 bit get/set time methods.
ptp: ixgbe: convert to the 64 bit get/set time methods.
ptp: mlx4: convert to the 64 bit get/set time methods.
ptp: sfc: convert to the 64 bit get/set time methods.
ptp: stmmac: convert to the 64 bit get/set time methods.
ptp: cpts: convert to the 64 bit get/set time methods.
ptp: tilegx: convert to the 64 bit get/set time methods.
ptp: dp83640: convert to the 64 bit get/set time methods.
ptp: ixp46x: convert to the 64 bit get/set time methods.
ptp: pch: convert to the 64 bit get/set time methods.
ptp: remove 32 bit get/set methods.
arch/tile/gxio/mpipe.c | 4 +-- arch/tile/include/gxio/mpipe.h | 4 +-- drivers/net/ethernet/adi/bfin_mac.c | 8 ++--- drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 13 +++---- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 ++--- drivers/net/ethernet/broadcom/tg3.c | 10 +++--- drivers/net/ethernet/freescale/fec_ptp.c | 8 ++--- drivers/net/ethernet/freescale/gianfar_ptp.c | 13 +++---- drivers/net/ethernet/intel/e1000e/ptp.c | 16 ++++----- drivers/net/ethernet/intel/fm10k/fm10k_ptp.c | 12 +++---- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 26 +++++++------- drivers/net/ethernet/intel/igb/igb_ptp.c | 41 +++++++++++----------- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 14 ++++---- drivers/net/ethernet/mellanox/mlx4/en_clock.c | 11 +++--- drivers/net/ethernet/sfc/ptp.c | 22 ++++++------ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 8 ++--- drivers/net/ethernet/ti/cpts.c | 12 +++---- drivers/net/ethernet/tile/tilegx.c | 9 ++--- drivers/net/phy/dp83640.c | 19 +++++----- drivers/ptp/ptp_chardev.c | 8 ++--- drivers/ptp/ptp_clock.c | 12 +++++-- drivers/ptp/ptp_ixp46x.c | 8 ++--- drivers/ptp/ptp_pch.c | 8 ++--- include/linux/ptp_clock_kernel.h | 12 +++---- 24 files changed, 160 insertions(+), 146 deletions(-)
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 1/23 ptp: introduce get/set time methods with explicit 64 bit seconds.
Converting the PHC drivers over to the new methods is one step along the way to making them ready for 2038. Once all the drivers are up to date, then the old methods will be removed.
--- include/linux/ptp_clock_kernel.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
include/linux/ptp_clock_kernel.h +10 -2
@@ -64,12 +64,18 @@ struct ptp_clock_request {* @adjtime: Shifts the time of the hardware clock. * parameter delta: Desired change in nanoseconds. * -* @gettime: Reads the current time from the hardware clock. +* @gettime: Reads the current time from the hardware clock. (deprecated) * parameter ts: Holds the result. * -* @settime: Set the current time on the hardware clock. +* @settime: Set the current time on the hardware clock. (deprecated) * parameter ts: Time value to set. * +* @gettime64: Reads the current time from the hardware clock. +* parameter ts: Holds the result. +* +* @settime64: Set the current time on the hardware clock. +* parameter ts: Time value to set. +* * @enable: Request driver to enable or disable an ancillary feature. * parameter request: Desired resource to enable or disable. * parameter on: Caller passes one to enable or zero to disable.
@@ -106,6 +112,8 @@ struct ptp_clock_info {int (*adjtime)(struct ptp_clock_info *ptp,s64 delta);int (*gettime)(struct ptp_clock_info *ptp,struct timespec *ts);int (*settime)(struct ptp_clock_info *ptp,const struct timespec *ts); +int (*gettime64)(struct ptp_clock_info *ptp,struct timespec64 *ts); +int (*settime64)(struct ptp_clock_info *p,const struct timespec64 *ts);int (*enable)(struct ptp_clock_info *ptp,struct ptp_clock_request *request,int on); int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 2/23 ptp: use the 64 bit gettime method for the SYS_OFFSET ioctl.
In reply to Richard CochranThis patch changes the code to use the new method whenever implemented by the PHC driver.
--- drivers/ptp/ptp_chardev.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/ptp/ptp_chardev.c +10 -4
@@ -124,7 +124,8 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);struct ptp_clock_info *ops = ptp->info;struct ptp_clock_time *pct; -struct timespec ts; +struct timespec64 ts; +struct timespec t2;int enable, err =0 ;unsigned int i, pin_index;
@@ -197,16 +198,21 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) } pct = &sysoff->ts[0 ];for (i =0 ; i < sysoff->n_samples; i++) { -getnstimeofday (&ts); +getnstimeofday64 (&ts); pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec; pct++; - ptp->info->gettime (ptp->info, &ts); +if (ptp->info->gettime64) { + ptp->info->gettime64 (ptp->info, &ts); + }else { + ptp->info->gettime (ptp->info, &t2); + ts =timespec_to_timespec64 (t2); + } pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec; pct++; } -getnstimeofday (&ts); +getnstimeofday64 (&ts); pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec;if (copy_to_user ((void __user *)arg, sysoff,sizeof (*sysoff)))
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 3/23 ptp: use the 64 bit get/set time methods for the posix clock.
In reply to Richard CochranThis patch changes the posix clock code to prefer the new methods whenever they are implemented by the PHC drivers.
--- drivers/ptp/ptp_clock.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/ptp/ptp_clock.c +17 -2
@@ -107,13 +107,28 @@ static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)static int ptp_clock_settime (struct posix_clock *pc,const struct timespec *tp) { struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); -return ptp->info->settime (ptp->info, tp); +struct timespec64 ts =timespec_to_timespec64 (*tp); + +return ptp->info->settime64 ? + ptp->info->settime64 (ptp->info, &ts) : + ptp->info->settime (ptp->info, tp); }static int ptp_clock_gettime (struct posix_clock *pc,struct timespec *tp) { struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); -return ptp->info->gettime (ptp->info, tp); +struct timespec64 ts; +int err; + +if (ptp->info->gettime64) { + err = ptp->info->gettime64 (ptp->info, &ts); +if (!err) + *tp =timespec64_to_timespec (ts); + }else { + err = ptp->info->gettime (ptp->info, tp); + } + +return err; }static int ptp_clock_adjtime (struct posix_clock *pc,struct timex *tx)
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 4/23 ptp: blackfin: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device uses 64 bit nanoseconds register, and so with this patch the driver is ready for the year 2038.
--- drivers/net/ethernet/adi/bfin_mac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/adi/bfin_mac.c +4 -4
@@ -983,7 +983,7 @@ static int bfin_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int bfin_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int bfin_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {u64 ns;u32 remainder;
@@ -1003,7 +1003,7 @@ static int bfin_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int bfin_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {u64 ns;unsigned long flags;
@@ -1039,8 +1039,8 @@ static struct ptp_clock_info bfin_ptp_caps = { .pps = 0, .adjfreq = bfin_ptp_adjfreq, .adjtime = bfin_ptp_adjtime, - .gettime = bfin_ptp_gettime, - .settime = bfin_ptp_settime, + .gettime64 = bfin_ptp_gettime, + .settime64 = bfin_ptp_settime, .enable = bfin_ptp_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 5/23 ptp: xgbe: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/amd/xgbe/xgbe-ptp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c +7 -6
@@ -179,7 +179,7 @@ static int xgbe_adjtime(struct ptp_clock_info *info, s64 delta)return 0 ; } -static int xgbe_gettime (struct ptp_clock_info *info,struct timespec *ts) +static int xgbe_gettime (struct ptp_clock_info *info,struct timespec64 *ts) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data,
@@ -193,12 +193,13 @@ static int xgbe_gettime(struct ptp_clock_info *info, struct timespec *ts)spin_unlock_irqrestore (&pdata->tstamp_lock, flags); - *ts =ns_to_timespec (nsec); + *ts =ns_to_timespec64 (nsec);return 0 ; } -static int xgbe_settime (struct ptp_clock_info *info,const struct timespec *ts) +static int xgbe_settime (struct ptp_clock_info *info, +const struct timespec64 *ts) { struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data,
@@ -206,7 +207,7 @@ static int xgbe_settime(struct ptp_clock_info *info, const struct timespec *ts)unsigned long flags;u64 nsec; - nsec =timespec_to_ns (ts); + nsec =timespec64_to_ns (ts);spin_lock_irqsave (&pdata->tstamp_lock, flags);
@@ -236,8 +237,8 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) info->max_adj = pdata->ptpclk_rate; info->adjfreq = xgbe_adjfreq; info->adjtime = xgbe_adjtime; - info->gettime = xgbe_gettime; - info->settime = xgbe_settime; + info->gettime64 = xgbe_gettime; + info->settime64 = xgbe_settime; info->enable = xgbe_enable; clock =ptp_clock_register (info, pdata->dev);
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 6/23 ptp: bnx2x: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +4 -4
@@ -13278,7 +13278,7 @@ static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int bnx2x_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int bnx2x_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) { struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);u64 ns;
@@ -13295,7 +13295,7 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int bnx2x_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);u64 ns;
@@ -13333,8 +13333,8 @@ static void bnx2x_register_phc(struct bnx2x *bp) bp->ptp_clock_info.pps =0 ; bp->ptp_clock_info.adjfreq = bnx2x_ptp_adjfreq; bp->ptp_clock_info.adjtime = bnx2x_ptp_adjtime; - bp->ptp_clock_info.gettime = bnx2x_ptp_gettime; - bp->ptp_clock_info.settime = bnx2x_ptp_settime; + bp->ptp_clock_info.gettime64 = bnx2x_ptp_gettime; + bp->ptp_clock_info.settime64 = bnx2x_ptp_settime; bp->ptp_clock_info.enable = bnx2x_ptp_enable; bp->ptp_clock =ptp_clock_register (&bp->ptp_clock_info, &bp->pdev->dev);
Signature · 1 line
1.7.10.4
RE: [PATCH net-next V3 06/23] ptp: bnx2x: convert to the 64 bit get/set time methods.
Quoted 54 lines
From: [email protected] [mailto:linux-kernel- [email protected]] On Behalf Of Richard Cochran
Sent: Sunday, March 29, 2015 2:12 PM
To: netdev
Cc: linux-kernel; Amir Vadai; Ariel Elior; Arnd Bergmann; Baolin Wang; Ben Hutchings; Bruce Allan; Carolyn Wyborny; Chris Metcalf; David Miller; Frank Li; Giuseppe Cavallaro; Jacob Keller; Jeff Kirsher; John Stultz; Luwei Zhou; Matthew Vick; Michael Chan; Prashant Sreedharan; Rayagond K; Shradha Shah; Solarflare linux maintainers; Sonic Zhang; Stefan Sørensen; Thomas Gleixner; Tom Lendacky
Subject: [PATCH net-next V3 06/23] ptp: bnx2x: convert to the 64 bit get/set time methods.This driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
Signed-off-by Richard Cochran <[email protected]>--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +2
-1@@ -13278,7 +13278,7 @@ static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) return 0; } -static int bnx2x_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int bnx2x_ptp_gettime (struct ptp_clock_info *ptp,struct +timespec64 *ts) { struct bnx2x *bp = container_of(ptp, struct bnx2x,
ptp_clock_info);drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1
-1u64 ns;@@ -13295,7 +13295,7 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int bnx2x_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +0
-0u64 ns;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c static void · line 13339
Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +2
-2@@ -13333,8 +13333,8 @@ static void bnx2x_register_phc(struct bnx2x *bp) bp->ptp_clock_info.pps = 0; bp->ptp_clock_info.adjfreq = bnx2x_ptp_adjfreq; bp->ptp_clock_info.adjtime = bnx2x_ptp_adjtime; - bp->ptp_clock_info.gettime = bnx2x_ptp_gettime; - bp->ptp_clock_info.settime = bnx2x_ptp_settime; + bp->ptp_clock_info.gettime64 = bnx2x_ptp_gettime; + bp->ptp_clock_info.settime64 = bnx2x_ptp_settime; bp->ptp_clock_info.enable = bnx2x_ptp_enable;
Thanks,
Sony
Richard Cochran
maintainerPATCH v3 7/23 ptp: tg3: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device appears to use a 64 bit nanoseconds register, and so with this patch the driver should be ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/broadcom/tg3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +5 -5
@@ -6217,7 +6217,7 @@ static int tg3_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int tg3_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int tg3_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {u64 ns;u32 remainder;
@@ -6235,12 +6235,12 @@ static int tg3_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int tg3_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {u64 ns; struct tg3 *tp = container_of(ptp, struct tg3, ptp_info); - ns =timespec_to_ns (ts); + ns =timespec64_to_ns (ts);tg3_full_lock (tp,0 );tg3_refclk_write (tp, ns);
@@ -6320,8 +6320,8 @@ static const struct ptp_clock_info tg3_ptp_caps = { .pps = 0, .adjfreq = tg3_ptp_adjfreq, .adjtime = tg3_ptp_adjtime, - .gettime = tg3_ptp_gettime, - .settime = tg3_ptp_settime, + .gettime64 = tg3_ptp_gettime, + .settime64 = tg3_ptp_settime, .enable = tg3_ptp_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 8/23 ptp: fec: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/freescale/fec_ptp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/freescale/fec_ptp.c +4 -4
@@ -390,7 +390,7 @@ static int fec_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)* read the timecounter and return the correct value on ns, * after converting it into a struct timespec. */ -static int fec_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int fec_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {struct fec_enet_private *adapter = container_of(ptp, struct fec_enet_private, ptp_caps);
@@ -417,7 +417,7 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)* wall timer value. */ static int fec_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {struct fec_enet_private *fep = container_of(ptp, struct fec_enet_private, ptp_caps);
@@ -584,8 +584,8 @@ void fec_ptp_init(struct platform_device *pdev) fep->ptp_caps.pps =1 ; fep->ptp_caps.adjfreq = fec_ptp_adjfreq; fep->ptp_caps.adjtime = fec_ptp_adjtime; - fep->ptp_caps.gettime = fec_ptp_gettime; - fep->ptp_caps.settime = fec_ptp_settime; + fep->ptp_caps.gettime64 = fec_ptp_gettime; + fep->ptp_caps.settime64 = fec_ptp_settime; fep->ptp_caps.enable = fec_ptp_enable; fep->cycle_speed =clk_get_rate (fep->clk_ptp);
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 9/23 ptp: gianfar: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device features a 64 bit nanoseconds register, and so with this patch the driver is ready for the year 2038.
--- drivers/net/ethernet/freescale/gianfar_ptp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/gianfar_ptp.c +7 -6
@@ -322,7 +322,8 @@ static int ptp_gianfar_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int ptp_gianfar_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int ptp_gianfar_gettime (struct ptp_clock_info *ptp, +struct timespec64 *ts) {u64 ns;u32 remainder;
@@ -341,7 +342,7 @@ static int ptp_gianfar_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int ptp_gianfar_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {u64 ns;unsigned long flags;
@@ -418,8 +419,8 @@ static struct ptp_clock_info ptp_gianfar_caps = { .pps = 1, .adjfreq = ptp_gianfar_adjfreq, .adjtime = ptp_gianfar_adjtime, - .gettime = ptp_gianfar_gettime, - .settime = ptp_gianfar_settime, + .gettime64 = ptp_gianfar_gettime, + .settime64 = ptp_gianfar_settime, .enable = ptp_gianfar_enable, };
@@ -440,7 +441,7 @@ static int gianfar_ptp_probe(struct platform_device *dev) {struct device_node *node = dev->dev.of_node;struct etsects *etsects; -struct timespec now; +struct timespec64 now;int err = -ENOMEM ;u32 tmr_ctrl;unsigned long flags;
@@ -495,7 +496,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)pr_err ("ioremap ptp registers failed\n" ); goto no_ioremap; } -getnstimeofday (&now); +getnstimeofday64 (&now);ptp_gianfar_settime (&etsects->caps, &now); tmr_ctrl =
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 10/23 ptp: e1000e: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/intel/e1000e/ptp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/e1000e/ptp.c +8 -8
@@ -106,7 +106,7 @@ static int e1000e_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)* Read the timecounter and return the correct value in ns after converting * it into a struct timespec. **/ -static int e1000e_phc_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int e1000e_phc_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) { struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, ptp_clock_info);
@@ -133,14 +133,14 @@ static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts)* wall timer value. **/ static int e1000e_phc_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, ptp_clock_info);unsigned long flags;u64 ns; - ns =timespec_to_ns (ts); + ns =timespec64_to_ns (ts);/* reset the timecounter */ spin_lock_irqsave (&adapter->systim_lock, flags);
@@ -171,11 +171,11 @@ static void e1000e_systim_overflow_work(struct work_struct *work) struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, systim_overflow_work.work);struct e1000_hw *hw = &adapter->hw; -struct timespec ts; +struct timespec64 ts; - adapter->ptp_clock_info.gettime (&adapter->ptp_clock_info, &ts); + adapter->ptp_clock_info.gettime64 (&adapter->ptp_clock_info, &ts); -e_dbg ("SYSTIM overflow check at %ld.%09lu\n" , ts.tv_sec, ts.tv_nsec); +e_dbg ("SYSTIM overflow check at %lld.%09lu\n" , ts.tv_sec, ts.tv_nsec);schedule_delayed_work (&adapter->systim_overflow_work,E1000_SYSTIM_OVERFLOW_PERIOD );
@@ -190,8 +190,8 @@ static const struct ptp_clock_info e1000e_ptp_clock_info = { .pps = 0, .adjfreq = e1000e_phc_adjfreq, .adjtime = e1000e_phc_adjtime, - .gettime = e1000e_phc_gettime, - .settime = e1000e_phc_settime, + .gettime64 = e1000e_phc_gettime, + .settime64 = e1000e_phc_settime, .enable = e1000e_phc_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerRe: [PATCH net-next V3 10/23] ptp: e1000e: convert to the 64 bit get/set time methods.
drivers/net/ethernet/intel/e1000e/ptp.c static void e1000e_systim_overflow_work(struct work_struct *work) · line 178
Quoted 12 lines · Richard Cochran
drivers/net/ethernet/intel/e1000e/ptp.c +3
-3@@ -171,11 +171,11 @@ static void e1000e_systim_overflow_work(struct work_struct *work) struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, systim_overflow_work.work);struct e1000_hw *hw = &adapter->hw; -struct timespec ts; +struct timespec64 ts; - adapter->ptp_clock_info.gettime (&adapter->ptp_clock_info, &ts); + adapter->ptp_clock_info.gettime64 (&adapter->ptp_clock_info, &ts); -e_dbg ("SYSTIM overflow check at %ld.%09lu\n" , ts.tv_sec, ts.tv_nsec); +e_dbg ("SYSTIM overflow check at %lld.%09lu\n" , ts.tv_sec, ts.tv_nsec);
On a 64 bit build, this triggers a new warning.
drivers/net/ethernet/intel/e1000e/ptp.c: In function ‘e1000e_systim_overflow_work’:drivers/net/ethernet/intel/e1000e/ptp.c:176:2: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘__kernel_time_t’ [-Wformat]
On 32 bit, timespec64.tv_sec is of type 'time64_t' or '__s64'.
On 64 bit, timespec64.tv_sec is of type '__kernel_time_t' or '__kernel_long_t' or 'long'.
How are we supposed to print that field? With a cast?
Thanks,
Richard
David Miller
maintainerRe: [PATCH net-next V3 10/23] ptp: e1000e: convert to the 64 bit get/set time methods.
From: Richard Cochran <[email protected]>
Date: Tue, 31 Mar 2015 23:48:15 +0200
Quoted 1 line
How are we supposed to print that field? With a cast?
I resolved this (and the one in igb) in my merge commit, maybe you should check it out.
Richard Cochran
maintainerPATCH v3 11/23 ptp: fm10k: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device appears to use a 64 bit nanoseconds register, and so with this patch the driver should be ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/intel/fm10k/fm10k_ptp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_ptp.c +6 -6
@@ -285,7 +285,7 @@ static int fm10k_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int fm10k_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int fm10k_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {struct fm10k_intfc *interface;unsigned long flags;
@@ -297,17 +297,17 @@ static int fm10k_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) now =fm10k_systime_read (interface) + interface->ptp_adjust;read_unlock_irqrestore (&interface->systime_lock, flags); - *ts =ns_to_timespec (now); + *ts =ns_to_timespec64 (now);return 0 ; }static int fm10k_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {struct fm10k_intfc *interface;unsigned long flags; -u64 ns =timespec_to_ns (ts); +u64 ns =timespec64_to_ns (ts); interface = container_of(ptp, struct fm10k_intfc, ptp_caps);
@@ -419,8 +419,8 @@ void fm10k_ptp_register(struct fm10k_intfc *interface) ptp_caps->max_adj =976562 ; ptp_caps->adjfreq = fm10k_ptp_adjfreq; ptp_caps->adjtime = fm10k_ptp_adjtime; - ptp_caps->gettime = fm10k_ptp_gettime; - ptp_caps->settime = fm10k_ptp_settime; + ptp_caps->gettime64 = fm10k_ptp_gettime; + ptp_caps->settime64 = fm10k_ptp_settime;/* provide pins if BAR4 is accessible */ if (interface->sw_addr) {
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 12/23 ptp: i40e: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device appears to use a 64 bit nanoseconds register, and so with this patch the driver should be ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ptp.c +13 -13
@@ -57,7 +57,7 @@* timespec. However, since the registers are 64 bits of nanoseconds, we must * convert the result to a timespec before we can return. **/ -static void i40e_ptp_read (struct i40e_pf *pf,struct timespec *ts) +static void i40e_ptp_read (struct i40e_pf *pf,struct timespec64 *ts) {struct i40e_hw *hw = &pf->hw;u32 hi, lo;
@@ -69,7 +69,7 @@ static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts) ns = (((u64 )hi) <<32 ) | lo; - *ts =ns_to_timespec (ns); + *ts =ns_to_timespec64 (ns); }/**
@@ -81,10 +81,10 @@ static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts)* we receive a timespec from the stack, we must convert that timespec into * nanoseconds before programming the registers. **/ -static void i40e_ptp_write (struct i40e_pf *pf,const struct timespec *ts) +static void i40e_ptp_write (struct i40e_pf *pf,const struct timespec64 *ts) {struct i40e_hw *hw = &pf->hw; -u64 ns =timespec_to_ns (ts); +u64 ns =timespec64_to_ns (ts);/* The timer will not update until the high register is written, so * write the low register first.
@@ -159,14 +159,14 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)static int i40e_ptp_adjtime (struct ptp_clock_info *ptp,s64 delta) { struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); -struct timespec now, then =ns_to_timespec (delta); +struct timespec64 now, then =ns_to_timespec64 (delta);unsigned long flags;spin_lock_irqsave (&pf->tmreg_lock, flags);i40e_ptp_read (pf, &now); - now =timespec_add (now, then); -i40e_ptp_write (pf, (const struct timespec *)&now); + now =timespec64_add (now, then); +i40e_ptp_write (pf, (const struct timespec64 *)&now);spin_unlock_irqrestore (&pf->tmreg_lock, flags);
@@ -181,7 +181,7 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)* Read the device clock and return the correct value on ns, after converting it * into a timespec struct. **/ -static int i40e_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int i40e_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) { struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);unsigned long flags;
@@ -202,7 +202,7 @@ static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)* to ns happens in the write function. **/ static int i40e_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);unsigned long flags;
@@ -613,8 +613,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf) pf->ptp_caps.pps =0 ; pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; pf->ptp_caps.adjtime = i40e_ptp_adjtime; - pf->ptp_caps.gettime = i40e_ptp_gettime; - pf->ptp_caps.settime = i40e_ptp_settime; + pf->ptp_caps.gettime64 = i40e_ptp_gettime; + pf->ptp_caps.settime64 = i40e_ptp_settime; pf->ptp_caps.enable = i40e_ptp_feature_enable;/* Attempt to register the clock before enabling the hardware. */
@@ -673,7 +673,7 @@ void i40e_ptp_init(struct i40e_pf *pf)dev_err (&pf->pdev->dev,"%s: ptp_clock_register failed\n" , __func__); }else { -struct timespec ts; +struct timespec64 ts;u32 regval; dev_info(&pf->pdev->dev, "%s: added PHC on %s\n", __func__,
@@ -695,7 +695,7 @@ void i40e_ptp_init(struct i40e_pf *pf)i40e_ptp_set_timestamp_mode (pf, &pf->tstamp_config);/* Set the clock value. */ - ts =ktime_to_timespec (ktime_get_real ()); + ts =ktime_to_timespec64 (ktime_get_real ());i40e_ptp_settime (&pf->ptp_caps, &ts); } }
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 13/23 ptp: igb: convert to the 64 bit get/set time methods.
In reply to Richard CochranFor the 82576, the driver's clock is implemented using a timecounter, and so with this patch that device is ready for the year 2038.
However, in the case of the i210, the device stores the number of seconds in a 32 bit register. Therefore, more work is needed on this driver before the year 2038 comes around.
Compile tested only.
--- drivers/net/ethernet/intel/igb/igb_ptp.c | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/net/ethernet/intel/igb/igb_ptp.c +21 -20
@@ -116,7 +116,8 @@ static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc) }/* SYSTIM read access for I210/I211 */ -static void igb_ptp_read_i210 (struct igb_adapter *adapter,struct timespec *ts) +static void igb_ptp_read_i210 (struct igb_adapter *adapter, +struct timespec64 *ts) {struct e1000_hw *hw = &adapter->hw;u32 sec, nsec;
@@ -134,7 +135,7 @@ static void igb_ptp_read_i210(struct igb_adapter *adapter, struct timespec *ts) }static void igb_ptp_write_i210 (struct igb_adapter *adapter, -const struct timespec *ts) +const struct timespec64 *ts) {struct e1000_hw *hw = &adapter->hw;
@@ -269,13 +270,13 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta) struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);unsigned long flags; -struct timespec now, then =ns_to_timespec (delta); +struct timespec64 now, then =ns_to_timespec64 (delta);spin_lock_irqsave (&igb->tmreg_lock, flags);igb_ptp_read_i210 (igb, &now); - now =timespec_add (now, then); -igb_ptp_write_i210 (igb, (const struct timespec *)&now); + now =timespec64_add (now, then); +igb_ptp_write_i210 (igb, (const struct timespec64 *)&now);spin_unlock_irqrestore (&igb->tmreg_lock, flags);
@@ -283,7 +284,7 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta) }static int igb_ptp_gettime_82576 (struct ptp_clock_info *ptp, -struct timespec *ts) +struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);
@@ -304,7 +305,7 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp, }static int igb_ptp_gettime_i210 (struct ptp_clock_info *ptp, -struct timespec *ts) +struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);
@@ -320,7 +321,7 @@ static int igb_ptp_gettime_i210(struct ptp_clock_info *ptp, }static int igb_ptp_settime_82576 (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);
@@ -340,7 +341,7 @@ static int igb_ptp_settime_82576(struct ptp_clock_info *ptp, }static int igb_ptp_settime_i210 (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);
@@ -627,11 +628,11 @@ static void igb_ptp_overflow_check(struct work_struct *work) {struct igb_adapter *igb = container_of(work, struct igb_adapter, ptp_overflow_work.work); -struct timespec ts; +struct timespec64 ts; - igb->ptp_caps.gettime (&igb->ptp_caps, &ts); + igb->ptp_caps.gettime64 (&igb->ptp_caps, &ts); -pr_debug ("igb overflow check at %ld.%09lu\n" , ts.tv_sec, ts.tv_nsec); +pr_debug ("igb overflow check at %lld.%09lu\n" , ts.tv_sec, ts.tv_nsec);schedule_delayed_work (&igb->ptp_overflow_work,IGB_SYSTIM_OVERFLOW_PERIOD );
@@ -989,8 +990,8 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.pps =0 ; adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82576; adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; - adapter->ptp_caps.gettime = igb_ptp_gettime_82576; - adapter->ptp_caps.settime = igb_ptp_settime_82576; + adapter->ptp_caps.gettime64 = igb_ptp_gettime_82576; + adapter->ptp_caps.settime64 = igb_ptp_settime_82576; adapter->ptp_caps.enable = igb_ptp_feature_enable; adapter->cc.read = igb_ptp_read_82576; adapter->cc.mask =CYCLECOUNTER_MASK (64 );
@@ -1009,8 +1010,8 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.pps =0 ; adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82580; adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; - adapter->ptp_caps.gettime = igb_ptp_gettime_82576; - adapter->ptp_caps.settime = igb_ptp_settime_82576; + adapter->ptp_caps.gettime64 = igb_ptp_gettime_82576; + adapter->ptp_caps.settime64 = igb_ptp_settime_82576; adapter->ptp_caps.enable = igb_ptp_feature_enable; adapter->cc.read = igb_ptp_read_82580; adapter->cc.mask =CYCLECOUNTER_MASK (IGB_NBITS_82580 );
@@ -1038,8 +1039,8 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.pin_config = adapter->sdp_config; adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82580; adapter->ptp_caps.adjtime = igb_ptp_adjtime_i210; - adapter->ptp_caps.gettime = igb_ptp_gettime_i210; - adapter->ptp_caps.settime = igb_ptp_settime_i210; + adapter->ptp_caps.gettime64 = igb_ptp_gettime_i210; + adapter->ptp_caps.settime64 = igb_ptp_settime_i210; adapter->ptp_caps.enable = igb_ptp_feature_enable_i210; adapter->ptp_caps.verify = igb_ptp_verify_pin;/* Enable the timer functions by clearing bit 31. */
@@ -1057,7 +1058,7 @@ void igb_ptp_init(struct igb_adapter *adapter)/* Initialize the clock and overflow work for devices that need it. */ if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) { -struct timespec ts =ktime_to_timespec (ktime_get_real ()); +struct timespec64 ts =ktime_to_timespec64 (ktime_get_real ());igb_ptp_settime_i210 (&adapter->ptp_caps, &ts); }else {
@@ -1171,7 +1172,7 @@ void igb_ptp_reset(struct igb_adapter *adapter)/* Re-initialize the timer. */ if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) { -struct timespec ts =ktime_to_timespec (ktime_get_real ()); +struct timespec64 ts =ktime_to_timespec64 (ktime_get_real ());igb_ptp_write_i210 (adapter, &ts); }else {
Signature · 1 line
1.7.10.4
Re: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.
Quoted 8 lines · Richard Cochran
For the 82576, the driver's clock is implemented using a timecounter, and so with this patch that device is ready for the year 2038.
However, in the case of the i210, the device stores the number of seconds in a 32 bit register. Therefore, more work is needed on this driver before the year 2038 comes around.
Compile tested only.
I assume we would want to use a time counter wrapper here to resolve this issue?
Regards,
Jake
Quoted 149 lines
Signed-off-by Richard Cochran <[email protected]>Acked-by Jeff Kirsher <[email protected]>--- drivers/net/ethernet/intel/igb/igb_ptp.c | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-)drivers/net/ethernet/intel/igb/igb_ptp.c +21
-20@@ -116,7 +116,8 @@ static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc) }/* SYSTIM read access for I210/I211 */ -static void igb_ptp_read_i210 (struct igb_adapter *adapter,struct timespec *ts) +static void igb_ptp_read_i210 (struct igb_adapter *adapter, +struct timespec64 *ts) {struct e1000_hw *hw = &adapter->hw;u32 sec, nsec;@@ -134,7 +135,7 @@ static void igb_ptp_read_i210(struct igb_adapter *adapter, struct timespec *ts) }static void igb_ptp_write_i210 (struct igb_adapter *adapter, -const struct timespec *ts) +const struct timespec64 *ts) {struct e1000_hw *hw = &adapter->hw;@@ -269,13 +270,13 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta) struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);unsigned long flags; -struct timespec now, then =ns_to_timespec (delta); +struct timespec64 now, then =ns_to_timespec64 (delta);spin_lock_irqsave (&igb->tmreg_lock, flags);igb_ptp_read_i210 (igb, &now); - now =timespec_add (now, then); -igb_ptp_write_i210 (igb, (const struct timespec *)&now); + now =timespec64_add (now, then); +igb_ptp_write_i210 (igb, (const struct timespec64 *)&now);spin_unlock_irqrestore (&igb->tmreg_lock, flags);@@ -283,7 +284,7 @@ static int igb_ptp_adjtime_i210(struct ptp_clock_info *ptp, s64 delta) }static int igb_ptp_gettime_82576 (struct ptp_clock_info *ptp, -struct timespec *ts) +struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);@@ -304,7 +305,7 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp, }static int igb_ptp_gettime_i210 (struct ptp_clock_info *ptp, -struct timespec *ts) +struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);@@ -320,7 +321,7 @@ static int igb_ptp_gettime_i210(struct ptp_clock_info *ptp, }static int igb_ptp_settime_82576 (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);@@ -340,7 +341,7 @@ static int igb_ptp_settime_82576(struct ptp_clock_info *ptp, }static int igb_ptp_settime_i210 (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps);@@ -627,11 +628,11 @@ static void igb_ptp_overflow_check(struct work_struct *work) {struct igb_adapter *igb = container_of(work, struct igb_adapter, ptp_overflow_work.work); -struct timespec ts; +struct timespec64 ts; - igb->ptp_caps.gettime (&igb->ptp_caps, &ts); + igb->ptp_caps.gettime64 (&igb->ptp_caps, &ts); -pr_debug ("igb overflow check at %ld.%09lu\n" , ts.tv_sec, ts.tv_nsec); +pr_debug ("igb overflow check at %lld.%09lu\n" , ts.tv_sec, ts.tv_nsec);schedule_delayed_work (&igb->ptp_overflow_work,IGB_SYSTIM_OVERFLOW_PERIOD );@@ -989,8 +990,8 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.pps =0 ; adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82576; adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; - adapter->ptp_caps.gettime = igb_ptp_gettime_82576; - adapter->ptp_caps.settime = igb_ptp_settime_82576; + adapter->ptp_caps.gettime64 = igb_ptp_gettime_82576; + adapter->ptp_caps.settime64 = igb_ptp_settime_82576; adapter->ptp_caps.enable = igb_ptp_feature_enable; adapter->cc.read = igb_ptp_read_82576; adapter->cc.mask =CYCLECOUNTER_MASK (64 );@@ -1009,8 +1010,8 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.pps =0 ; adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82580; adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; - adapter->ptp_caps.gettime = igb_ptp_gettime_82576; - adapter->ptp_caps.settime = igb_ptp_settime_82576; + adapter->ptp_caps.gettime64 = igb_ptp_gettime_82576; + adapter->ptp_caps.settime64 = igb_ptp_settime_82576; adapter->ptp_caps.enable = igb_ptp_feature_enable; adapter->cc.read = igb_ptp_read_82580; adapter->cc.mask =CYCLECOUNTER_MASK (IGB_NBITS_82580 );@@ -1038,8 +1039,8 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.pin_config = adapter->sdp_config; adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82580; adapter->ptp_caps.adjtime = igb_ptp_adjtime_i210; - adapter->ptp_caps.gettime = igb_ptp_gettime_i210; - adapter->ptp_caps.settime = igb_ptp_settime_i210; + adapter->ptp_caps.gettime64 = igb_ptp_gettime_i210; + adapter->ptp_caps.settime64 = igb_ptp_settime_i210; adapter->ptp_caps.enable = igb_ptp_feature_enable_i210; adapter->ptp_caps.verify = igb_ptp_verify_pin;/* Enable the timer functions by clearing bit 31. */ @@ -1057,7 +1058,7 @@ void igb_ptp_init(struct igb_adapter *adapter)/* Initialize the clock and overflow work for devices that need it. */ if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) { -struct timespec ts =ktime_to_timespec (ktime_get_real ()); +struct timespec64 ts =ktime_to_timespec64 (ktime_get_real ());igb_ptp_settime_i210 (&adapter->ptp_caps, &ts); }else {@@ -1171,7 +1172,7 @@ void igb_ptp_reset(struct igb_adapter *adapter)/* Re-initialize the timer. */ if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211)) { -struct timespec ts =ktime_to_timespec (ktime_get_real ()); +struct timespec64 ts =ktime_to_timespec64 (ktime_get_real ());igb_ptp_write_i210 (adapter, &ts); }else {
Richard Cochran
maintainerRe: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.
Quoted 4 lines · Jacob E
Quoted 3 lines · Richard Cochran
For the 82576, the driver's clock is implemented using a timecounter, and so with this patch that device is ready for the year 2038.
Quoted 8 lines
Quoted 5 lines
However, in the case of the i210, the device stores the number of seconds in a 32 bit register. Therefore, more work is needed on this driver before the year 2038 comes around.
Compile tested only.
I assume we would want to use a time counter wrapper here to resolve this issue?
I would just keep the seconds in software for settime() and adjtime(), but let the nanoseconds field go to the hardware. Then, the gettime() result, the periodic outputs, the external time stamps, and the skb time stamps will need to be corrected by that many seconds.
Thanks,
Richard
RE: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.
Quoted 30 lines
-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Tuesday, March 31, 2015 2:37 PM
To: Keller, Jacob E
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Allan, Bruce W; [email protected]; [email protected]; [email protected]; [email protected]; Vick, Matthew; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Wyborny, Carolyn; [email protected]; [email protected]; Kirsher, Jeffrey T; [email protected]; [email protected]
Subject: Re: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.Quoted 4 lines · Jacob E
Quoted 3 lines · Richard Cochran
For the 82576, the driver's clock is implemented using a timecounter, and so with this patch that device is ready for the year 2038.
Quoted 8 lines
Quoted 5 lines
However, in the case of the i210, the device stores the number of seconds in a 32 bit register. Therefore, more work is needed on this driver before the year 2038 comes around.
Compile tested only.
I assume we would want to use a time counter wrapper here to resolve this issue?
Quoted 7 lines
I would just keep the seconds in software for
settime()andadjtime(), but let the nanoseconds field go to the hardware. Then, thegettime()result, the periodic outputs, the external time stamps, and the skb time stamps will need to be corrected by that many seconds.Thanks,
Richard
That seems reasonable.
Regards,
Jake
Richard Cochran
maintainerRe: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.
In reply to Richard Cochrandrivers/net/ethernet/intel/igb/igb_ptp.c static void igb_ptp_overflow_check(struct work_struct *work) · line 635
Quoted 12 lines · Richard Cochran
drivers/net/ethernet/intel/igb/igb_ptp.c +3
-3@@ -627,11 +628,11 @@ static void igb_ptp_overflow_check(struct work_struct *work) {struct igb_adapter *igb = container_of(work, struct igb_adapter, ptp_overflow_work.work); -struct timespec ts; +struct timespec64 ts; - igb->ptp_caps.gettime (&igb->ptp_caps, &ts); + igb->ptp_caps.gettime64 (&igb->ptp_caps, &ts); -pr_debug ("igb overflow check at %ld.%09lu\n" , ts.tv_sec, ts.tv_nsec); +pr_debug ("igb overflow check at %lld.%09lu\n" , ts.tv_sec, ts.tv_nsec);
For a 64 bit build, this produces the same warning as e1000e.
What is the best way to deal with this warning?
Thanks,
Richard
RE: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.
Quoted 34 lines
-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Tuesday, March 31, 2015 2:53 PM
To: [email protected]
Cc: [email protected]; Amir Vadai; Ariel Elior; Arnd Bergmann; Baolin Wang; Ben Hutchings; Allan, Bruce W; Wyborny, Carolyn; Chris Metcalf; David Miller; Frank Li; Giuseppe Cavallaro; Keller, Jacob E; Kirsher, Jeffrey T; John Stultz; Luwei Zhou; Vick, Matthew; Michael Chan; Prashant Sreedharan; Rayagond K; Shradha Shah; Solarflare linux maintainers; Sonic Zhang; Stefan Sørensen; Thomas Gleixner; Tom Lendacky
Subject: Re: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.Review static void igb_ptp_overflow_check(struct
Quoted 1 line · Richard Cochran
(quoted diff) +0
-0@@ -627,11 +628,11 @@ static void igb_ptp_overflow_check(struct
work_struct*work)drivers/net/ethernet/intel/igb/igb_ptp.c static void igb_ptp_overflow_check(struct work_struct *work)
Quoted 3 lines
drivers/net/ethernet/intel/igb/igb_ptp.c +0
-0{struct igb_adapter *igb = container_of(work, struct igb_adapter,ptp_overflow_work.work);
drivers/net/ethernet/intel/igb/igb_ptp.c static void igb_ptp_overflow_check(struct work_struct *work)
Quoted 7 lines
drivers/net/ethernet/intel/igb/igb_ptp.c +2
-3-struct timespec ts; +struct timespec64 ts; - igb->ptp_caps.gettime (&igb->ptp_caps, &ts); + igb->ptp_caps.gettime64 (&igb->ptp_caps, &ts); - pr_debug("igb overflow check at %ld.%09lu\n", ts.tv_sec,ts.tv_nsec);
Review static void igb_ptp_overflow_check(struct · line 635
Quoted 1 line
(quoted diff) +1
-0+ pr_debug("igb overflow check at %lld.%09lu\n", ts.tv_sec,ts.tv_nsec);
Quoted 6 lines
For a 64 bit build, this produces the same warning as e1000e.
What is the best way to deal with this warning?
Thanks,
Richard
I don't know how kernel would fix this. Usually macros like PRI64d are used but I am not sure those are defined for the kernel builds
Regards,
Jake
Richard Cochran
maintainerRe: [PATCH net-next V3 13/23] ptp: igb: convert to the 64 bit get/set time methods.
Quoted 1 line · Jacob E
I don't know how kernel would fix this. Usually macros like PRI64d are used but I am not sure those are defined for the kernel builds
Davem fixed it by casting to (long long).
Thanks,
Richard
Richard Cochran
maintainerPATCH v3 14/23 ptp: ixgbe: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +7 -7
@@ -279,7 +279,7 @@ static int ixgbe_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)* read the timecounter and return the correct value on ns, * after converting it into a struct timespec. */ -static int ixgbe_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int ixgbe_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {struct ixgbe_adapter *adapter = container_of(ptp, struct ixgbe_adapter, ptp_caps);
@@ -306,7 +306,7 @@ static int ixgbe_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)* wall timer value. */ static int ixgbe_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {struct ixgbe_adapter *adapter = container_of(ptp, struct ixgbe_adapter, ptp_caps);
@@ -407,7 +407,7 @@ void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter) {bool timeout =time_is_before_jiffies (adapter->last_overflow_check +IXGBE_OVERFLOW_PERIOD ); -struct timespec ts; +struct timespec64 ts;if (timeout) {ixgbe_ptp_gettime (&adapter->ptp_caps, &ts);
@@ -874,8 +874,8 @@ static int ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) adapter->ptp_caps.pps =1 ; adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq; adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; - adapter->ptp_caps.gettime = ixgbe_ptp_gettime; - adapter->ptp_caps.settime = ixgbe_ptp_settime; + adapter->ptp_caps.gettime64 = ixgbe_ptp_gettime; + adapter->ptp_caps.settime64 = ixgbe_ptp_settime; adapter->ptp_caps.enable = ixgbe_ptp_feature_enable;break ;case ixgbe_mac_82599EB:
@@ -890,8 +890,8 @@ static int ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter) adapter->ptp_caps.pps =0 ; adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq; adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime; - adapter->ptp_caps.gettime = ixgbe_ptp_gettime; - adapter->ptp_caps.settime = ixgbe_ptp_settime; + adapter->ptp_caps.gettime64 = ixgbe_ptp_gettime; + adapter->ptp_caps.settime64 = ixgbe_ptp_settime; adapter->ptp_caps.enable = ixgbe_ptp_feature_enable;break ;default :
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 15/23 ptp: mlx4: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/mellanox/mlx4/en_clock.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_clock.c +6 -5
@@ -164,7 +164,8 @@ static int mlx4_en_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)* Read the timecounter and return the correct value in ns after converting * it into a struct timespec. **/ -static int mlx4_en_phc_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int mlx4_en_phc_gettime (struct ptp_clock_info *ptp, +struct timespec64 *ts) { struct mlx4_en_dev *mdev = container_of(ptp, struct mlx4_en_dev, ptp_clock_info);
@@ -191,11 +192,11 @@ static int mlx4_en_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts)* wall timer value. **/ static int mlx4_en_phc_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) { struct mlx4_en_dev *mdev = container_of(ptp, struct mlx4_en_dev, ptp_clock_info); -u64 ns =timespec_to_ns (ts); +u64 ns =timespec64_to_ns (ts);unsigned long flags;/* reset the timecounter */
@@ -232,8 +233,8 @@ static const struct ptp_clock_info mlx4_en_ptp_clock_info = { .pps = 0, .adjfreq = mlx4_en_phc_adjfreq, .adjtime = mlx4_en_phc_adjtime, - .gettime = mlx4_en_phc_gettime, - .settime = mlx4_en_phc_settime, + .gettime64 = mlx4_en_phc_gettime, + .settime64 = mlx4_en_phc_settime, .enable = mlx4_en_phc_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 16/23 ptp: sfc: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis patch changes the driver to use the newer API.
Depending on how the hardware represents a time value, this driver may or may not yet be ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/sfc/ptp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/sfc/ptp.c +11 -11
@@ -323,9 +323,9 @@ struct efx_ptp_data {static int efx_phc_adjfreq (struct ptp_clock_info *ptp,s32 delta);static int efx_phc_adjtime (struct ptp_clock_info *ptp,s64 delta); -static int efx_phc_gettime (struct ptp_clock_info *ptp,struct timespec *ts); +static int efx_phc_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts);static int efx_phc_settime (struct ptp_clock_info *ptp, -const struct timespec *e_ts); +const struct timespec64 *e_ts);static int efx_phc_enable (struct ptp_clock_info *ptp,struct ptp_clock_request *request,int on);
@@ -1198,8 +1198,8 @@ static const struct ptp_clock_info efx_phc_clock_info = { .pps = 1, .adjfreq = efx_phc_adjfreq, .adjtime = efx_phc_adjtime, - .gettime = efx_phc_gettime, - .settime = efx_phc_settime, + .gettime64 = efx_phc_gettime, + .settime64 = efx_phc_settime, .enable = efx_phc_enable, };
@@ -1837,7 +1837,7 @@ static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta) NULL, 0, NULL); } -static int efx_phc_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int efx_phc_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) { struct efx_ptp_data *ptp_data = container_of(ptp, struct efx_ptp_data,
@@ -1859,28 +1859,28 @@ static int efx_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts) kt = ptp_data->nic_to_kernel_time (MCDI_DWORD (outbuf,PTP_OUT_READ_NIC_TIME_MAJOR ),MCDI_DWORD (outbuf,PTP_OUT_READ_NIC_TIME_MINOR ),0 ); - *ts =ktime_to_timespec (kt); + *ts =ktime_to_timespec64 (kt);return 0 ; }static int efx_phc_settime (struct ptp_clock_info *ptp, -const struct timespec *e_ts) +const struct timespec64 *e_ts) {/* Get the current NIC time, efx_phc_gettime. * Subtract from the desired time to get the offset * call efx_phc_adjtime with the offset */ int rc; -struct timespec time_now; -struct timespec delta; +struct timespec64 time_now; +struct timespec64 delta; rc =efx_phc_gettime (ptp, &time_now);if (rc !=0 )return rc; - delta =timespec_sub (*e_ts, time_now); + delta =timespec64_sub (*e_ts, time_now); - rc =efx_phc_adjtime (ptp,timespec_to_ns (&delta)); + rc =efx_phc_adjtime (ptp,timespec64_to_ns (&delta));if (rc !=0 )return rc;
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 17/23 ptp: stmmac: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis device stores the number of seconds in a 32 bit register. So more work is needed on this driver before the year 2038 comes around.
Compile tested only.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +4 -4
@@ -105,7 +105,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)* Description: this function will read the current time from the * hardware clock and store it in @ts. */ -static int stmmac_get_time (struct ptp_clock_info *ptp,struct timespec *ts) +static int stmmac_get_time (struct ptp_clock_info *ptp,struct timespec64 *ts) {struct stmmac_priv *priv = container_of(ptp, struct stmmac_priv, ptp_clock_ops);
@@ -135,7 +135,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec *ts)* hardware clock. */ static int stmmac_set_time (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {struct stmmac_priv *priv = container_of(ptp, struct stmmac_priv, ptp_clock_ops);
@@ -168,8 +168,8 @@ static struct ptp_clock_info stmmac_ptp_clock_ops = { .pps = 0, .adjfreq = stmmac_adjust_freq, .adjtime = stmmac_adjust_time, - .gettime = stmmac_get_time, - .settime = stmmac_set_time, + .gettime64 = stmmac_get_time, + .settime64 = stmmac_set_time, .enable = stmmac_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 18/23 ptp: cpts: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver's clock is implemented using a timecounter, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/net/ethernet/ti/cpts.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/ti/cpts.c +6 -6
@@ -167,7 +167,7 @@ static int cpts_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int cpts_ptp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int cpts_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {u64 ns;u32 remainder;
@@ -185,7 +185,7 @@ static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int cpts_ptp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {u64 ns;unsigned long flags;
@@ -216,20 +216,20 @@ static struct ptp_clock_info cpts_info = { .pps = 0, .adjfreq = cpts_ptp_adjfreq, .adjtime = cpts_ptp_adjtime, - .gettime = cpts_ptp_gettime, - .settime = cpts_ptp_settime, + .gettime64 = cpts_ptp_gettime, + .settime64 = cpts_ptp_settime, .enable = cpts_ptp_enable, };static void cpts_overflow_check (struct work_struct *work) { -struct timespec ts; +struct timespec64 ts; struct cpts *cpts = container_of(work, struct cpts, overflow_work.work);cpts_write32 (cpts,CPTS_EN , control);cpts_write32 (cpts,TS_PEND_EN , int_enable);cpts_ptp_gettime (&cpts->info, &ts); -pr_debug ("cpts overflow check at %ld.%09lu\n" , ts.tv_sec, ts.tv_nsec); +pr_debug ("cpts overflow check at %lld.%09lu\n" , ts.tv_sec, ts.tv_nsec);schedule_delayed_work (&cpts->overflow_work,CPTS_OVERFLOW_PERIOD ); }
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 19/23 ptp: tilegx: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver is 64 bit only, and so this driver and device are ready for 2038. This patch changes the driver to the new PHC and also carries the timespec64 parameter on out to the gxio_mpipe_get- set_timestamp functions, making explicit the fact that the tv_sec field is 64 bits wide.
Not even compile tested.
--- arch/tile/gxio/mpipe.c | 4 ++-- arch/tile/include/gxio/mpipe.h | 4 ++-- drivers/net/ethernet/tile/tilegx.c | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-)
arch/tile/gxio/mpipe.c +2 -2
@@ -456,7 +456,7 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,EXPORT_SYMBOL_GPL (gxio_mpipe_equeue_init);int gxio_mpipe_set_timestamp (gxio_mpipe_context_t *context, -const struct timespec *ts) +const struct timespec64 *ts) {cycles_t cycles =get_cycles (); return gxio_mpipe_set_timestamp_aux(context, (uint64_t)ts->tv_sec,
@@ -466,7 +466,7 @@ int gxio_mpipe_set_timestamp(gxio_mpipe_context_t *context,EXPORT_SYMBOL_GPL (gxio_mpipe_set_timestamp);int gxio_mpipe_get_timestamp (gxio_mpipe_context_t *context, -struct timespec *ts) +struct timespec64 *ts) {int ret;cycles_t cycles_prev, cycles_now, clock_rate;
arch/tile/include/gxio/mpipe.h +2 -2
@@ -1830,7 +1830,7 @@ extern int gxio_mpipe_link_set_attr(gxio_mpipe_link_t *link, uint32_t attr,* code. */ extern int gxio_mpipe_get_timestamp (gxio_mpipe_context_t *context, -struct timespec *ts); +struct timespec64 *ts);/* Set the timestamp of mPIPE. *
@@ -1840,7 +1840,7 @@ extern int gxio_mpipe_get_timestamp(gxio_mpipe_context_t *context,* code. */ extern int gxio_mpipe_set_timestamp (gxio_mpipe_context_t *context, -const struct timespec *ts); +const struct timespec64 *ts);/* Adjust the timestamp of mPIPE. *
drivers/net/ethernet/tile/tilegx.c +5 -4
@@ -838,7 +838,8 @@ static int ptp_mpipe_adjtime(struct ptp_clock_info *ptp, s64 delta)return ret; } -static int ptp_mpipe_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int ptp_mpipe_gettime (struct ptp_clock_info *ptp, +struct timespec64 *ts) {int ret =0 ; struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);
@@ -850,7 +851,7 @@ static int ptp_mpipe_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int ptp_mpipe_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {int ret =0 ; struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);
@@ -876,8 +877,8 @@ static struct ptp_clock_info ptp_mpipe_caps = { .pps = 0, .adjfreq = ptp_mpipe_adjfreq, .adjtime = ptp_mpipe_adjtime, - .gettime = ptp_mpipe_gettime, - .settime = ptp_mpipe_settime, + .gettime64 = ptp_mpipe_gettime, + .settime64 = ptp_mpipe_settime, .enable = ptp_mpipe_enable, };
Signature · 1 line
1.7.10.4
Re: [PATCH net-next V3 19/23] ptp: tilegx: convert to the 64 bit get/set time methods.
Quoted 6 lines · Richard Cochran
This driver is 64 bit only, and so this driver and device are ready for 2038. This patch changes the driver to the new PHC and also carries the timespec64 parameter on out to the gxio_mpipe_get-
set_timestampfunctions, making explicit the fact that thetv_secfield is 64 bits wide.
Quoted 8 lines
Not even compile tested.
Signed-off-by Richard Cochran<[email protected]>--- arch/tile/gxio/mpipe.c | 4 ++-- arch/tile/include/gxio/mpipe.h | 4 ++-- drivers/net/ethernet/tile/tilegx.c | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-)
Signature · 2 lines
Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Richard Cochran
maintainerPATCH v3 20/23 ptp: dp83640: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis device stores the number of seconds in a 32 bit register, and the stored value is unsigned. Therefore this driver and device are ready for the year 2038. However, more work will be needed prior to 2106.
Compile tested only.
--- drivers/net/phy/dp83640.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/phy/dp83640.c +10 -9
@@ -257,7 +257,7 @@ static void ext_write(int broadcast, struct phy_device *phydev,/* Caller must hold extreg_lock. */ static int tdr_write (int bc,struct phy_device *dev, -const struct timespec *ts,u16 cmd) +const struct timespec64 *ts,u16 cmd) {ext_write (bc, dev,PAGE4 ,PTP_TDR , ts->tv_nsec &0xffff );/* ns[15:0] */ ext_write (bc, dev,PAGE4 ,PTP_TDR , ts->tv_nsec >>16 );/* ns[31:16] */
@@ -411,12 +411,12 @@ static int ptp_dp83640_adjtime(struct ptp_clock_info *ptp, s64 delta)struct dp83640_clock *clock = container_of(ptp, struct dp83640_clock, caps);struct phy_device *phydev = clock->chosen->phydev; -struct timespec ts; +struct timespec64 ts;int err; delta +=ADJTIME_FIX ; - ts =ns_to_timespec (delta); + ts =ns_to_timespec64 (delta);mutex_lock (&clock->extreg_lock);
@@ -427,7 +427,8 @@ static int ptp_dp83640_adjtime(struct ptp_clock_info *ptp, s64 delta)return err; } -static int ptp_dp83640_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int ptp_dp83640_gettime (struct ptp_clock_info *ptp, +struct timespec64 *ts) {struct dp83640_clock *clock = container_of(ptp, struct dp83640_clock, caps);
@@ -452,7 +453,7 @@ static int ptp_dp83640_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int ptp_dp83640_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {struct dp83640_clock *clock = container_of(ptp, struct dp83640_clock, caps);
@@ -605,7 +606,7 @@ static void recalibrate(struct dp83640_clock *clock) {s64 now, diff;struct phy_txts event_ts; -struct timespec ts; +struct timespec64 ts;struct list_head *this;struct dp83640_private *tmp;struct phy_device *master = clock->chosen->phydev;
@@ -697,7 +698,7 @@ static void recalibrate(struct dp83640_clock *clock) diff = now - (s64 )phy2txts (&event_ts);pr_info ("slave offset %lld nanoseconds\n" , diff); diff +=ADJTIME_FIX ; - ts =ns_to_timespec (diff); + ts =ns_to_timespec64 (diff);tdr_write (0 , tmp->phydev, &ts,PTP_STEP_CLK ); }
@@ -998,8 +999,8 @@ static void dp83640_clock_init(struct dp83640_clock *clock, struct mii_bus *bus) clock->caps.pps =0 ; clock->caps.adjfreq = ptp_dp83640_adjfreq; clock->caps.adjtime = ptp_dp83640_adjtime; - clock->caps.gettime = ptp_dp83640_gettime; - clock->caps.settime = ptp_dp83640_settime; + clock->caps.gettime64 = ptp_dp83640_gettime; + clock->caps.settime64 = ptp_dp83640_settime; clock->caps.enable = ptp_dp83640_enable; clock->caps.verify = ptp_dp83640_verify;/*
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 21/23 ptp: ixp46x: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device has a 64 bit clock register, where each clock tick is 16 nanoseconds, and so with this patch the driver is ready for the year 2038.
--- drivers/ptp/ptp_ixp46x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ptp/ptp_ixp46x.c +4 -4
@@ -175,7 +175,7 @@ static int ptp_ixp_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int ptp_ixp_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int ptp_ixp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {u64 ns;u32 remainder;
@@ -195,7 +195,7 @@ static int ptp_ixp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int ptp_ixp_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {u64 ns;unsigned long flags;
@@ -248,8 +248,8 @@ static struct ptp_clock_info ptp_ixp_caps = { .pps = 0, .adjfreq = ptp_ixp_adjfreq, .adjtime = ptp_ixp_adjtime, - .gettime = ptp_ixp_gettime, - .settime = ptp_ixp_settime, + .gettime64 = ptp_ixp_gettime, + .settime64 = ptp_ixp_settime, .enable = ptp_ixp_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 22/23 ptp: pch: convert to the 64 bit get/set time methods.
In reply to Richard CochranThe device has a 64 bit clock register, where each clock tick is 32 nanoseconds, and so with this patch the driver is ready for the year 2038.
Compile tested only.
--- drivers/ptp/ptp_pch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ptp/ptp_pch.c +4 -4
@@ -449,7 +449,7 @@ static int ptp_pch_adjtime(struct ptp_clock_info *ptp, s64 delta)return 0 ; } -static int ptp_pch_gettime (struct ptp_clock_info *ptp,struct timespec *ts) +static int ptp_pch_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) {u64 ns;u32 remainder;
@@ -467,7 +467,7 @@ static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec *ts) }static int ptp_pch_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts) {u64 ns;unsigned long flags;
@@ -518,8 +518,8 @@ static struct ptp_clock_info ptp_pch_caps = { .pps = 0, .adjfreq = ptp_pch_adjfreq, .adjtime = ptp_pch_adjtime, - .gettime = ptp_pch_gettime, - .settime = ptp_pch_settime, + .gettime64 = ptp_pch_gettime, + .settime64 = ptp_pch_settime, .enable = ptp_pch_enable, };
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerPATCH v3 23/23 ptp: remove 32 bit get/set methods.
In reply to Richard CochranAll of the PHC drivers have been converted to the new methods. This patch converts the three remaining callers within the core code and removes the older methods for good. As a result, the core PHC code is ready for the year 2038. However, some of the PHC drivers are not quite ready yet.
--- drivers/ptp/ptp_chardev.c | 8 +------- drivers/ptp/ptp_clock.c | 15 ++++----------- include/linux/ptp_clock_kernel.h | 8 -------- 3 files changed, 5 insertions(+), 26 deletions(-)
drivers/ptp/ptp_chardev.c +1 -7
@@ -125,7 +125,6 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)struct ptp_clock_info *ops = ptp->info;struct ptp_clock_time *pct;struct timespec64 ts; -struct timespec t2;int enable, err =0 ;unsigned int i, pin_index;
@@ -202,12 +201,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec; pct++; -if (ptp->info->gettime64) { - ptp->info->gettime64 (ptp->info, &ts); - }else { - ptp->info->gettime (ptp->info, &t2); - ts =timespec_to_timespec64 (t2); - } + ptp->info->gettime64 (ptp->info, &ts); pct->sec = ts.tv_sec; pct->nsec = ts.tv_nsec; pct++;
drivers/ptp/ptp_clock.c +4 -11
@@ -109,9 +109,7 @@ static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp) struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);struct timespec64 ts =timespec_to_timespec64 (*tp); -return ptp->info->settime64 ? - ptp->info->settime64 (ptp->info, &ts) : - ptp->info->settime (ptp->info, tp); +return ptp->info->settime64 (ptp->info, &ts); }static int ptp_clock_gettime (struct posix_clock *pc,struct timespec *tp)
@@ -120,14 +118,9 @@ static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)struct timespec64 ts;int err; -if (ptp->info->gettime64) { - err = ptp->info->gettime64 (ptp->info, &ts); -if (!err) - *tp =timespec64_to_timespec (ts); - }else { - err = ptp->info->gettime (ptp->info, tp); - } - + err = ptp->info->gettime64 (ptp->info, &ts); +if (!err) + *tp =timespec64_to_timespec (ts);return err; }
include/linux/ptp_clock_kernel.h +0 -8
@@ -64,12 +64,6 @@ struct ptp_clock_request {* @adjtime: Shifts the time of the hardware clock. * parameter delta: Desired change in nanoseconds. * -* @gettime: Reads the current time from the hardware clock. (deprecated) -* parameter ts: Holds the result. -* -* @settime: Set the current time on the hardware clock. (deprecated) -* parameter ts: Time value to set. -* * @gettime64: Reads the current time from the hardware clock. * parameter ts: Holds the result. *
@@ -110,8 +104,6 @@ struct ptp_clock_info {struct ptp_pin_desc *pin_config;int (*adjfreq)(struct ptp_clock_info *ptp,s32 delta);int (*adjtime)(struct ptp_clock_info *ptp,s64 delta); -int (*gettime)(struct ptp_clock_info *ptp,struct timespec *ts); -int (*settime)(struct ptp_clock_info *ptp,const struct timespec *ts);int (*gettime64)(struct ptp_clock_info *ptp,struct timespec64 *ts);int (*settime64)(struct ptp_clock_info *p,const struct timespec64 *ts); int (*enable)(struct ptp_clock_info *ptp,
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: Richard Cochran <[email protected]>
Date: Sun, 29 Mar 2015 23:11:50 +0200
Quoted 3 lines
This series converts the core driver methods of the PTP Hardware Clock (PHC) subsystem to use the 64 bit version of the timespec structure, making the core API ready for the year 2038.
Looks great, series applied, thanks Richard.