From: Jacob Keller <jacob.e.keller@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [net-next v3 04/13] ice: restart periodic outputs around time changes
Date: Wed, 7 Jul 2021 16:40:59 -0700 [thread overview]
Message-ID: <20210707234108.4071506-5-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20210707234108.4071506-1-jacob.e.keller@intel.com>
Wen 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: 172db5f91d5f ("ice: add support for auxiliary input/output pins")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_ptp.c | 49 ++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 83ba0bf2817a..7fe17898cbdf 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -688,6 +688,41 @@ static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan,
return -EFAULT;
}
+/**
+ * ice_ptp_disable_all_clkout - Disable all currently configured outputs
+ * @pf: pointer to the PF structure
+ *
+ * Disable all currently configured clock outputs. This is necessary before
+ * certain changes to the PTP hardware clock. Use ice_ptp_enable_all_clkout to
+ * re-enable the clocks again.
+ */
+static void ice_ptp_disable_all_clkout(struct ice_pf *pf)
+{
+ uint i;
+
+ for (i = 0; i < pf->ptp.info.n_per_out; i++)
+ if (pf->ptp.perout_channels[i].ena)
+ ice_ptp_cfg_clkout(pf, i, NULL, false);
+}
+
+/**
+ * ice_ptp_enable_all_clkout - Enable all configured periodic clock outputs
+ * @pf: pointer to the PF structure
+ *
+ * Enable all currently configured clock outputs. Use this after
+ * ice_ptp_disable_all_clkout to reconfigure the output signals according to
+ * their configuration.
+ */
+static void ice_ptp_enable_all_clkout(struct ice_pf *pf)
+{
+ uint i;
+
+ for (i = 0; i < pf->ptp.info.n_per_out; i++)
+ if (pf->ptp.perout_channels[i].ena)
+ ice_ptp_cfg_clkout(pf, i, &pf->ptp.perout_channels[i],
+ false);
+}
+
/**
* ice_ptp_gpio_enable_e810 - Enable/disable ancillary features of PHC
* @info: the driver's PTP info structure
@@ -783,12 +818,17 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
goto exit;
}
+ /* Disable periodic outputs */
+ ice_ptp_disable_all_clkout(pf);
+
err = ice_ptp_write_init(pf, &ts64);
ice_ptp_unlock(hw);
if (!err)
ice_ptp_update_cached_phctime(pf);
+ /* Reenable periodic outputs */
+ ice_ptp_enable_all_clkout(pf);
exit:
if (err) {
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)
return -EBUSY;
}
+ /* Disable periodic outputs */
+ ice_ptp_disable_all_clkout(pf);
+
err = ice_ptp_write_adj(pf, delta);
+ /* Reenable periodic outputs */
+ ice_ptp_enable_all_clkout(pf);
+
ice_ptp_unlock(hw);
if (err) {
@@ -1543,6 +1589,9 @@ void ice_ptp_release(struct ice_pf *pf)
if (!pf->ptp.clock)
return;
+ /* Disable periodic outputs */
+ ice_ptp_disable_all_clkout(pf);
+
ice_clear_ptp_clock_index(pf);
ptp_clock_unregister(pf->ptp.clock);
pf->ptp.clock = NULL;
--
2.31.1.331.gb0c09ab8796f
next prev parent reply other threads:[~2021-07-07 23:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 23:40 [Intel-wired-lan] [net-next v3 00/13] implement support for PTP on E822 hardware Jacob Keller
2021-07-07 23:40 ` [Intel-wired-lan] [net-next v3 01/13] ice: fix Tx queue iteration for Tx timestamp enablement Jacob Keller
2021-07-07 23:40 ` [Intel-wired-lan] [net-next v3 02/13] ice: remove dead code for allocating pin_config Jacob Keller
2021-07-07 23:40 ` [Intel-wired-lan] [net-next v3 03/13] ice: add lock around Tx timestamp tracker flush Jacob Keller
2021-07-07 23:40 ` Jacob Keller [this message]
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 05/13] ice: introduce ice_base_incval function Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 06/13] ice: PTP: move setting of tstamp_config Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 07/13] ice: use 'int err' instead of 'int status' Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 08/13] ice: introduce ice_ptp_init_phc function Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 09/13] ice: convert clk_freq capability into time_ref Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 10/13] ice: implement basic E822 PTP support Jacob Keller
2021-08-23 23:43 ` Keller, Jacob E
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 11/13] ice: ensure the hardware Clock Generation Unit is configured Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 12/13] ice: exit bypass mode once hardware finishes timestamp calibration Jacob Keller
2021-07-07 23:41 ` [Intel-wired-lan] [net-next v3 13/13] ice: support crosstimestamping on E822 devices if supported Jacob Keller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210707234108.4071506-5-jacob.e.keller@intel.com \
--to=jacob.e.keller@intel.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox