Skip to content

Commit 9ee3134

Browse files
jacob-kelleranguy11
authored andcommitted
ice: restart periodic outputs around time changes
When we enabled auxiliary input/output support for the E810 device, we forgot to add logic to restart the output when we change time. This is important as the periodic output will be incorrect after a time change otherwise. This unfortunately includes the adjust time function, even though it uses an atomic hardware interface. The atomic adjustment can still cause the pin output to stall permanently, so we need to stop and restart it. Introduce wrapper functions to temporarily disable and then re-enable the clock outputs. Fixes: 172db5f ("ice: add support for auxiliary input/output pins") Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Sunitha D Mekala <sunithax.d.mekala@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 4dd0d5c commit 9ee3134

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,41 @@ static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan,
688688
return -EFAULT;
689689
}
690690

691+
/**
692+
* ice_ptp_disable_all_clkout - Disable all currently configured outputs
693+
* @pf: pointer to the PF structure
694+
*
695+
* Disable all currently configured clock outputs. This is necessary before
696+
* certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to
697+
* re-enable the clocks again.
698+
*/
699+
static void ice_ptp_disable_all_clkout(struct ice_pf *pf)
700+
{
701+
uint i;
702+
703+
for (i = 0; i < pf->ptp.info.n_per_out; i++)
704+
if (pf->ptp.perout_channels[i].ena)
705+
ice_ptp_cfg_clkout(pf, i, NULL, false);
706+
}
707+
708+
/**
709+
* ice_ptp_enable_all_clkout - Enable all configured periodic clock outputs
710+
* @pf: pointer to the PF structure
711+
*
712+
* Enable all currently configured clock outputs. Use this after
713+
* ice_ptp_disable_all_clkout to reconfigure the output signals according to
714+
* their configuration.
715+
*/
716+
static void ice_ptp_enable_all_clkout(struct ice_pf *pf)
717+
{
718+
uint i;
719+
720+
for (i = 0; i < pf->ptp.info.n_per_out; i++)
721+
if (pf->ptp.perout_channels[i].ena)
722+
ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i],
723+
false);
724+
}
725+
691726
/**
692727
* ice_ptp_gpio_enable_e810 - Enable/disable ancillary features of PHC
693728
* @info: the driver's PTP info structure
@@ -783,12 +818,17 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
783818
goto exit;
784819
}
785820

821+
/* Disable periodic outputs */
822+
ice_ptp_disable_all_clkout(pf);
823+
786824
err = ice_ptp_write_init(pf, &ts64);
787825
ice_ptp_unlock(hw);
788826

789827
if (!err)
790828
ice_ptp_update_cached_phctime(pf);
791829

830+
/* Reenable periodic outputs */
831+
ice_ptp_enable_all_clkout(pf);
792832
exit:
793833
if (err) {
794834
dev_err(ice_pf_to_dev(pf), "PTP failed to set time %d\n", err);
@@ -842,8 +882,14 @@ static int ice_ptp_adjtime(struct ptp_clock_info *info, s64 delta)
842882
return -EBUSY;
843883
}
844884

885+
/* Disable periodic outputs */
886+
ice_ptp_disable_all_clkout(pf);
887+
845888
err = ice_ptp_write_adj(pf, delta);
846889

890+
/* Reenable periodic outputs */
891+
ice_ptp_enable_all_clkout(pf);
892+
847893
ice_ptp_unlock(hw);
848894

849895
if (err) {
@@ -1543,6 +1589,9 @@ void ice_ptp_release(struct ice_pf *pf)
15431589
if (!pf->ptp.clock)
15441590
return;
15451591

1592+
/* Disable periodic outputs */
1593+
ice_ptp_disable_all_clkout(pf);
1594+
15461595
ice_clear_ptp_clock_index(pf);
15471596
ptp_clock_unregister(pf->ptp.clock);
15481597
pf->ptp.clock = NULL;

0 commit comments

Comments
 (0)