ptp: get ready for 2038
Subsystems (15)
Richard Cochran
maintainercover 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 18 ? drivers/net/ethernet/tile/tilegx.c 19 drivers/net/phy/dp83640.c
The commit log message documents how each driver is ready or why it is not ready. For patches 15 and 18, I could not easily find out the hardware representation of the time value, so I would ask the maintainers for a review.
Thanks,
Richard
Richard Cochran (22):
ptp: introduce get/set time methods with explicit 64 bit seconds.
ptp: use the 64 bit gettime method for the SYS_OFFSET ioctl.
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.
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 | 16 +++++---- drivers/net/phy/dp83640.c | 12 ++++--- 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 +++---- 22 files changed, 158 insertions(+), 140 deletions(-)
Signature · 1 line
1.7.10.4
Richard Cochran
maintainerRFC 1/22 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
maintainerRFC 2/22 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
maintainerRFC 3/22 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
maintainerRFC 4/22 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
maintainerRFC 5/22 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
Richard Cochran
maintainerRFC 6/22 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
maintainerRFC 7/22 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
maintainerRFC 8/22 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
maintainerRFC 9/22 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
maintainerRFC 10/22 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
maintainerRFC 11/22 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
maintainerRFC 12/22 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
Richard Cochran
maintainerRFC 13/22 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
maintainerRFC 14/22 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
maintainerRFC 15/22 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
maintainerRFC 16/22 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
maintainerRFC 17/22 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
maintainerRFC 18/22 ptp: tilegx: convert to the 64 bit get/set time methods.
In reply to Richard CochranThis driver calls code (via gxio_mpipe_get/set_timestamp) that makes the assumption that the tv_sec field is 64 bits wide. So apparently this driver is 64 bit only. So maybe this driver and device are ready for 2038, but maybe not.
Not even compile tested.
--- drivers/net/ethernet/tile/tilegx.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/ethernet/tile/tilegx.c +10 -6
@@ -838,24 +838,28 @@ 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 *ts64) {int ret =0 ; struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps); +struct timespec ts;mutex_lock (&md->ptp_lock); -if (gxio_mpipe_get_timestamp (&md->context, ts)) +if (gxio_mpipe_get_timestamp (&md->context, &ts)) ret = -EBUSY ;mutex_unlock (&md->ptp_lock); + *ts64 =timespec_to_timespec64 (ts);return ret; }static int ptp_mpipe_settime (struct ptp_clock_info *ptp, -const struct timespec *ts) +const struct timespec64 *ts64) {int ret =0 ; +struct timespec ts =timespec64_to_timespec (*ts64); struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);mutex_lock (&md->ptp_lock); -if (gxio_mpipe_set_timestamp (&md->context, ts)) +if (gxio_mpipe_set_timestamp (&md->context, &ts)) ret = -EBUSY ;mutex_unlock (&md->ptp_lock);return ret;
@@ -876,8 +880,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
Richard Cochran
maintainerRFC 19/22 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. So more work is needed on this driver before the year 2038 comes around.
Compile tested only.
--- drivers/net/phy/dp83640.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/phy/dp83640.c +7 -5
@@ -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,16 +453,17 @@ 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 *ts64) {struct dp83640_clock *clock = container_of(ptp, struct dp83640_clock, caps);struct phy_device *phydev = clock->chosen->phydev; +struct timespec ts =timespec64_to_timespec (*ts64);int err;mutex_lock (&clock->extreg_lock); - err =tdr_write (1 , phydev, ts,PTP_LOAD_CLK ); + err =tdr_write (1 , phydev, &ts,PTP_LOAD_CLK );mutex_unlock (&clock->extreg_lock);
@@ -998,8 +1000,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
maintainerRFC 20/22 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
maintainerRFC 21/22 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
maintainerRFC 22/22 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 | 12 ++++++++++-- include/linux/ptp_clock_kernel.h | 8 -------- 3 files changed, 11 insertions(+), 17 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 +10 -2
@@ -107,13 +107,21 @@ 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, &ts); }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; + + err = ptp->info->gettime64 (ptp->info, &ts); +if (!err) + *tp =timespec64_to_timespec (ts); +return err; }static int ptp_clock_adjtime (struct posix_clock *pc,struct timex *tx)
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
Richard Cochran
maintainerRe: [RFC net-next 22/22] ptp: remove 32 bit get/set methods.
Quoted 16 lines · Richard Cochran
drivers/ptp/ptp_clock.c +3
-1@@ -107,13 +107,21 @@ 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, &ts); }static int ptp_clock_gettime (struct posix_clock *pc,struct timespec *tp) {
drivers/ptp/ptp_clock.c static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp) · line 125
Quoted 10 lines
drivers/ptp/ptp_clock.c +7
-1struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); -return ptp->info->gettime (ptp->info, tp); +struct timespec64 ts; +int err; + + err = ptp->info->gettime64 (ptp->info, &ts); +if (!err) + *tp =timespec64_to_timespec (ts); +return err; }
Oops, both of these functions should have started using the new methods *before* migrating the drivers. Will fix in V2.
Thanks,
Richard