* [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code
@ 2023-06-01 21:15 Jacob Keller
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread Jacob Keller
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Jacob Keller @ 2023-06-01 21:15 UTC (permalink / raw)
To: Intel Wired LAN, Anthony Nguyen
This series improves the driver's use of the threaded IRQ and the
communication between ice_misc_intr() and the ice_misc_intr_thread_fn()
which was previously introduced by commit 1229b33973c7 ("ice: Add low
latency Tx timestamp read").
First, a new custom enumerated return value is used instead of a boolean for
ice_ptp_process_ts(). This significantly reduces the cognitive burden when
reviewing the logic for this function, as the expected action is clear from
the return value name.
Second, the unconditional loop in ice_misc_intr_thread_fn() is removed,
replacing it with a write to the Other Interrupt Cause register. This causes
the MAC to trigger the Tx timestamp interrupt again. This makes it possible
to safely use the ice_misc_intr_thread_fn() to handle other tasks beyond
just the Tx timestamps. It is also easier to reason about since the thread
function will exit cleanly if we do something like disable the interrupt and
call synchronize_irq().
Third, refactor the handling for external timestamp events to use the
miscellaneous thread function. This resolves an issue with the external
time stamps getting blocked while processing the periodic work function
task.
Fourth, a simplification of the ice_misc_intr() function to always return
IRQ_WAKE_THREAD, and schedule the ice service task in the
ice_misc_intr_thread_fn() instead.
Finally, the Other Interrupt Cause is kept disabled over the thread function
processing, rather than immediately re-enabled.
Special thanks to Michal Schmidt for the careful review of the series and
pointing out my misunderstandings of the kernel IRQ code. It has been
determined that the race outlined as being fixed in previous series was
actually introduced by this series itself, which I've since corrected.
Changes since v2:
* heavily re-ordered patches for clarity and a better flow of implementation
* used atomic bits when communicating between ice_misc_intr() and
ice_misc_intr_thread_fn()
* re-wrote commit messages to improve clarity and remove mistakes about how
threaded IRQs work.
Jacob Keller (3):
ice: introduce ICE_TX_TSTAMP_WORK enumeration
ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling
ice: do not re-enable miscellaneous interrupt until thread_fn
completes
Karol Kolacinski (2):
ice: handle extts in the miscellaneous interrupt thread
ice: always return IRQ_WAKE_THREAD in ice_misc_intr()
drivers/net/ethernet/intel/ice/ice.h | 7 +++
drivers/net/ethernet/intel/ice/ice_main.c | 47 +++++++++++------
drivers/net/ethernet/intel/ice/ice_ptp.c | 62 ++++++++++++-----------
drivers/net/ethernet/intel/ice/ice_ptp.h | 16 ++++--
4 files changed, 84 insertions(+), 48 deletions(-)
base-commit: f08ff053a47a51d4f391d407bdda6adb4e7ed499
--
2.40.0.471.gbd7f14d9353b
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
@ 2023-06-01 21:15 ` Jacob Keller
2023-06-08 12:12 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr() Jacob Keller
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Jacob Keller @ 2023-06-01 21:15 UTC (permalink / raw)
To: Intel Wired LAN, Anthony Nguyen; +Cc: Karol Kolacinski
From: Karol Kolacinski <karol.kolacinski@intel.com>
The ice_ptp_extts_work() and ice_ptp_periodic_work() functions are both
scheduled on the same kthread worker, pf.ptp.kworker. The
ice_ptp_periodic_work() function sends to the firmware to interact with the
PHY, and must block to wait for responses.
This can cause delay in responding to the PFINT_OICR_TSYN_EVNT interrupt
cause, ultimately resulting in disruption to processing an input signal of
the frequency is high enough. In our testing, even 100 Hz signals get
disrupted.
Fix this by instead processing the signal inside the miscellaneous
interrupt thread prior to handling Tx timestamps.
Use atomic bits in a new pf->misc_thread bitmap in order to safely
communicate which tasks require processing within the
ice_misc_intr_thread_fn(). This ensures the communication of desired tasks
from the ice_misc_intr() are correctly processed without racing even in the
event that the interrupt triggers again before the thread function exits.
Fixes: 172db5f91d5f ("ice: add support for auxiliary input/output pins")
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice.h | 7 ++++++
drivers/net/ethernet/intel/ice/ice_main.c | 29 ++++++++++++++++-------
drivers/net/ethernet/intel/ice/ice_ptp.c | 12 +++-------
drivers/net/ethernet/intel/ice/ice_ptp.h | 4 ++--
4 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 176e281dfa24..9109006336f0 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -509,6 +509,12 @@ enum ice_pf_flags {
ICE_PF_FLAGS_NBITS /* must be last */
};
+enum ice_misc_thread_tasks {
+ ICE_MISC_THREAD_EXTTS_EVENT,
+ ICE_MISC_THREAD_TX_TSTAMP,
+ ICE_MISC_THREAD_NBITS /* must be last */
+};
+
struct ice_switchdev_info {
struct ice_vsi *control_vsi;
struct ice_vsi *uplink_vsi;
@@ -552,6 +558,7 @@ struct ice_pf {
DECLARE_BITMAP(features, ICE_F_MAX);
DECLARE_BITMAP(state, ICE_STATE_NBITS);
DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);
+ DECLARE_BITMAP(misc_thread, ICE_MISC_THREAD_NBITS);
unsigned long *avail_txqs; /* bitmap to track PF Tx queue usage */
unsigned long *avail_rxqs; /* bitmap to track PF Rx queue usage */
unsigned long serv_tmr_period;
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index c7d7104dbadc..0beb6afc0b2d 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3139,20 +3139,28 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
if (oicr & PFINT_OICR_TSYN_TX_M) {
ena_mask &= ~PFINT_OICR_TSYN_TX_M;
- if (!hw->reset_ongoing)
+ if (!hw->reset_ongoing) {
+ set_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread);
ret = IRQ_WAKE_THREAD;
+ }
}
if (oicr & PFINT_OICR_TSYN_EVNT_M) {
u8 tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned;
u32 gltsyn_stat = rd32(hw, GLTSYN_STAT(tmr_idx));
- /* Save EVENTs from GTSYN register */
- pf->ptp.ext_ts_irq |= gltsyn_stat & (GLTSYN_STAT_EVENT0_M |
- GLTSYN_STAT_EVENT1_M |
- GLTSYN_STAT_EVENT2_M);
ena_mask &= ~PFINT_OICR_TSYN_EVNT_M;
- kthread_queue_work(pf->ptp.kworker, &pf->ptp.extts_work);
+
+ if (hw->func_caps.ts_func_info.src_tmr_owned) {
+ /* Save EVENTs from GLTSYN register */
+ pf->ptp.ext_ts_irq |= gltsyn_stat &
+ (GLTSYN_STAT_EVENT0_M |
+ GLTSYN_STAT_EVENT1_M |
+ GLTSYN_STAT_EVENT2_M);
+
+ set_bit(ICE_MISC_THREAD_EXTTS_EVENT, pf->misc_thread);
+ ret = IRQ_WAKE_THREAD;
+ }
}
#define ICE_AUX_CRIT_ERR (PFINT_OICR_PE_CRITERR_M | PFINT_OICR_HMC_ERR_M | PFINT_OICR_PE_PUSH_M)
@@ -3196,8 +3204,13 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
if (ice_is_reset_in_progress(pf->state))
return IRQ_HANDLED;
- while (!ice_ptp_process_ts(pf))
- usleep_range(50, 100);
+ if (test_and_clear_bit(ICE_MISC_THREAD_EXTTS_EVENT, pf->misc_thread))
+ ice_ptp_extts_event(pf);
+
+ if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) {
+ while (!ice_ptp_process_ts(pf))
+ usleep_range(50, 100);
+ }
return IRQ_HANDLED;
}
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index d4b6c997141d..6f51ebaf1d70 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -1458,15 +1458,11 @@ static int ice_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)
}
/**
- * ice_ptp_extts_work - Workqueue task function
- * @work: external timestamp work structure
- *
- * Service for PTP external clock event
+ * ice_ptp_extts_event - Process PTP external clock event
+ * @pf: Board private structure
*/
-static void ice_ptp_extts_work(struct kthread_work *work)
+void ice_ptp_extts_event(struct ice_pf *pf)
{
- struct ice_ptp *ptp = container_of(work, struct ice_ptp, extts_work);
- struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp);
struct ptp_clock_event event;
struct ice_hw *hw = &pf->hw;
u8 chan, tmr_idx;
@@ -2558,7 +2554,6 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf)
ice_ptp_cfg_timestamp(pf, false);
kthread_cancel_delayed_work_sync(&ptp->work);
- kthread_cancel_work_sync(&ptp->extts_work);
if (test_bit(ICE_PFR_REQ, pf->state))
return;
@@ -2656,7 +2651,6 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp)
/* Initialize work functions */
kthread_init_delayed_work(&ptp->work, ice_ptp_periodic_work);
- kthread_init_work(&ptp->extts_work, ice_ptp_extts_work);
/* Allocate a kworker for handling work required for the ports
* connected to the PTP hardware clock.
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h
index 9cda2f43e0e5..9f8902c1e743 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.h
@@ -169,7 +169,6 @@ struct ice_ptp_port {
* struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
* @port: data for the PHY port initialization procedure
* @work: delayed work function for periodic tasks
- * @extts_work: work function for handling external Tx timestamps
* @cached_phc_time: a cached copy of the PHC time for timestamp extension
* @cached_phc_jiffies: jiffies when cached_phc_time was last updated
* @ext_ts_chan: the external timestamp channel in use
@@ -190,7 +189,6 @@ struct ice_ptp_port {
struct ice_ptp {
struct ice_ptp_port port;
struct kthread_delayed_work work;
- struct kthread_work extts_work;
u64 cached_phc_time;
unsigned long cached_phc_jiffies;
u8 ext_ts_chan;
@@ -256,6 +254,7 @@ int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr);
void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena);
int ice_get_ptp_clock_index(struct ice_pf *pf);
+void ice_ptp_extts_event(struct ice_pf *pf);
s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);
bool ice_ptp_process_ts(struct ice_pf *pf);
@@ -284,6 +283,7 @@ static inline int ice_get_ptp_clock_index(struct ice_pf *pf)
return -1;
}
+static inline void ice_ptp_extts_event(struct ice_pf *pf) { }
static inline s8
ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb)
{
--
2.40.0.471.gbd7f14d9353b
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr()
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread Jacob Keller
@ 2023-06-01 21:15 ` Jacob Keller
2023-06-08 12:12 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration Jacob Keller
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Jacob Keller @ 2023-06-01 21:15 UTC (permalink / raw)
To: Intel Wired LAN, Anthony Nguyen; +Cc: Karol Kolacinski
From: Karol Kolacinski <karol.kolacinski@intel.com>
Refactor the ice_misc_intr() function to always return IRQ_WAKE_THREAD, and
schedule the service task during the soft IRQ thread function instead of at
the end of the hard IRQ handler.
Remove the duplicate call to ice_service_task_schedule() that happened when
we got a PCI exception.
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 0beb6afc0b2d..34599088633d 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3058,7 +3058,6 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
{
struct ice_pf *pf = (struct ice_pf *)data;
struct ice_hw *hw = &pf->hw;
- irqreturn_t ret = IRQ_NONE;
struct device *dev;
u32 oicr, ena_mask;
@@ -3139,10 +3138,8 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
if (oicr & PFINT_OICR_TSYN_TX_M) {
ena_mask &= ~PFINT_OICR_TSYN_TX_M;
- if (!hw->reset_ongoing) {
+ if (!hw->reset_ongoing)
set_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread);
- ret = IRQ_WAKE_THREAD;
- }
}
if (oicr & PFINT_OICR_TSYN_EVNT_M) {
@@ -3159,7 +3156,6 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
GLTSYN_STAT_EVENT2_M);
set_bit(ICE_MISC_THREAD_EXTTS_EVENT, pf->misc_thread);
- ret = IRQ_WAKE_THREAD;
}
}
@@ -3180,16 +3176,12 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
if (oicr & (PFINT_OICR_PCI_EXCEPTION_M |
PFINT_OICR_ECC_ERR_M)) {
set_bit(ICE_PFR_REQ, pf->state);
- ice_service_task_schedule(pf);
}
}
- if (!ret)
- ret = IRQ_HANDLED;
- ice_service_task_schedule(pf);
ice_irq_dynamic_ena(hw, NULL, NULL);
- return ret;
+ return IRQ_WAKE_THREAD;
}
/**
@@ -3204,6 +3196,8 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
if (ice_is_reset_in_progress(pf->state))
return IRQ_HANDLED;
+ ice_service_task_schedule(pf);
+
if (test_and_clear_bit(ICE_MISC_THREAD_EXTTS_EVENT, pf->misc_thread))
ice_ptp_extts_event(pf);
--
2.40.0.471.gbd7f14d9353b
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread Jacob Keller
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr() Jacob Keller
@ 2023-06-01 21:15 ` Jacob Keller
2023-06-08 12:13 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling Jacob Keller
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Jacob Keller @ 2023-06-01 21:15 UTC (permalink / raw)
To: Intel Wired LAN, Anthony Nguyen
The ice_ptp_process_ts() function and its various helper functions return a
boolean value indicating whether any work is remaining. This use of a
boolean has grown confusing as we have multiple helpers that pass status
between each other. Readers must be aware of what "true" and "false" mean,
and it is very easy to get their meaning inverted. The names of the
functions are not standard "yes/no" questions, which is the best practice
for boolean returns.
Replace this use of an enumeration with a custom type, enum
ice_tx_tstamp_work. This enumeration clearly indicates whether all work is
done, or if more work is pending.
To aid in readability, factor the actual list iteration and processing out
into ice_ptp_process_tx_tstamp(), making it void. Then call this in
ice_ptp_tx_tstamp() ensuring that we always check the Tracker list at the
end when determining the appropriate return value.
Now the return value is an explicit name instead of the true or false
value. This is easier to follow and makes reading the resulting callers
much simpler.
In addition, this paves the way for future work to allow E822 hardware to
process timestamps for all functions using a single interrupt on the clock
owning PF.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
drivers/net/ethernet/intel/ice/ice_ptp.c | 50 ++++++++++++++---------
drivers/net/ethernet/intel/ice/ice_ptp.h | 12 +++++-
3 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 34599088633d..9df53dd300a9 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3202,7 +3202,7 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
ice_ptp_extts_event(pf);
if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) {
- while (!ice_ptp_process_ts(pf))
+ while (ice_ptp_process_ts(pf) == ICE_TX_TSTAMP_WORK_PENDING)
usleep_range(50, 100);
}
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 6f51ebaf1d70..81d96a40d5a7 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -617,7 +617,7 @@ ice_ptp_is_tx_tracker_up(struct ice_ptp_tx *tx)
}
/**
- * ice_ptp_tx_tstamp - Process Tx timestamps for a port
+ * ice_ptp_process_tx_tstamp - Process Tx timestamps for a port
* @tx: the PTP Tx timestamp tracker
*
* Process timestamps captured by the PHY associated with this port. To do
@@ -633,15 +633,6 @@ ice_ptp_is_tx_tracker_up(struct ice_ptp_tx *tx)
* 6) extend the 40 bit timestamp value to get a 64 bit timestamp value
* 7) send this 64 bit timestamp to the stack
*
- * Returns true if all timestamps were handled, and false if any slots remain
- * without a timestamp.
- *
- * After looping, if we still have waiting SKBs, return false. This may cause
- * us effectively poll even when not strictly necessary. We do this because
- * it's possible a new timestamp was requested around the same time as the
- * interrupt. In some cases hardware might not interrupt us again when the
- * timestamp is captured.
- *
* Note that we do not hold the tracking lock while reading the Tx timestamp.
* This is because reading the timestamp requires taking a mutex that might
* sleep.
@@ -673,10 +664,9 @@ ice_ptp_is_tx_tracker_up(struct ice_ptp_tx *tx)
* the packet will never be sent by hardware and discard it without reading
* the timestamp register.
*/
-static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
+static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx)
{
struct ice_ptp_port *ptp_port;
- bool more_timestamps;
struct ice_pf *pf;
struct ice_hw *hw;
u64 tstamp_ready;
@@ -685,7 +675,7 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
u8 idx;
if (!tx->init)
- return true;
+ return;
ptp_port = container_of(tx, struct ice_ptp_port, tx);
pf = ptp_port_to_pf(ptp_port);
@@ -694,7 +684,7 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
/* Read the Tx ready status first */
err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready);
if (err)
- return false;
+ return;
/* Drop packets if the link went down */
link_up = ptp_port->link_up;
@@ -782,15 +772,34 @@ static bool ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
skb_tstamp_tx(skb, &shhwtstamps);
dev_kfree_skb_any(skb);
}
+}
- /* Check if we still have work to do. If so, re-queue this task to
- * poll for remaining timestamps.
- */
+/**
+ * ice_ptp_tx_tstamp - Process Tx timestamps for this function.
+ * @tx: Tx tracking structure to initialize
+ *
+ * Returns: ICE_TX_TSTAMP_WORK_PENDING if there are any outstanding incomplete
+ * Tx timestamps, or ICE_TX_TSTAMP_WORK_DONE otherwise.
+ */
+static enum ice_tx_tstamp_work ice_ptp_tx_tstamp(struct ice_ptp_tx *tx)
+{
+ bool more_timestamps;
+
+ if (!tx->init)
+ return ICE_TX_TSTAMP_WORK_DONE;
+
+ /* Process the Tx timestamp tracker */
+ ice_ptp_process_tx_tstamp(tx);
+
+ /* Check if there are outstanding Tx timestamps */
spin_lock(&tx->lock);
more_timestamps = tx->init && !bitmap_empty(tx->in_use, tx->len);
spin_unlock(&tx->lock);
- return !more_timestamps;
+ if (more_timestamps)
+ return ICE_TX_TSTAMP_WORK_PENDING;
+
+ return ICE_TX_TSTAMP_WORK_DONE;
}
/**
@@ -2426,9 +2435,10 @@ s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb)
* ice_ptp_process_ts - Process the PTP Tx timestamps
* @pf: Board private structure
*
- * Returns true if timestamps are processed.
+ * Returns: ICE_TX_TSTAMP_WORK_PENDING if there are any outstanding Tx
+ * timestamps that need processing, and ICE_TX_TSTAMP_WORK_DONE otherwise.
*/
-bool ice_ptp_process_ts(struct ice_pf *pf)
+enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf)
{
return ice_ptp_tx_tstamp(&pf->ptp.port.tx);
}
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h
index 9f8902c1e743..6c90775e1eb0 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.h
@@ -108,6 +108,16 @@ struct ice_tx_tstamp {
u64 cached_tstamp;
};
+/**
+ * enum ice_tx_tstamp_work - Status of Tx timestamp work function
+ * @ICE_TX_TSTAMP_WORK_DONE - Tx timestamp processing is complete
+ * @ICE_TX_TSTAMP_WORK_PENDING - More Tx timestamps are pending
+ */
+enum ice_tx_tstamp_work {
+ ICE_TX_TSTAMP_WORK_DONE = 0,
+ ICE_TX_TSTAMP_WORK_PENDING,
+};
+
/**
* struct ice_ptp_tx - Tracking structure for all Tx timestamp requests on a port
* @lock: lock to prevent concurrent access to fields of this struct
@@ -256,7 +266,7 @@ int ice_get_ptp_clock_index(struct ice_pf *pf);
void ice_ptp_extts_event(struct ice_pf *pf);
s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);
-bool ice_ptp_process_ts(struct ice_pf *pf);
+enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);
void
ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring,
--
2.40.0.471.gbd7f14d9353b
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
` (2 preceding siblings ...)
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration Jacob Keller
@ 2023-06-01 21:15 ` Jacob Keller
2023-06-08 12:14 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes Jacob Keller
2023-06-02 8:25 ` [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Michal Schmidt
5 siblings, 1 reply; 12+ messages in thread
From: Jacob Keller @ 2023-06-01 21:15 UTC (permalink / raw)
To: Intel Wired LAN, Anthony Nguyen
In ice_misc_intr_thread_fn(), if we do not complete all Tx timestamp work,
the thread function will poll continuously forever.
For E822 hardware, this wastes time as the return value from
ice_ptp_process_ts() is accurate and always reports correctly that the PHY
actually has new timestamp data.
In addition, if we receive enough timestamps with the right pacing, we may
never exit this polling. Should this occur, other tasks handled by the
ice_misc_intr_thread_fn() will never be processed.
Fix this by instead writing to PFINT_OICR, causing an emulated interrupt to
be triggered immediately. This does take slightly more processing than just
re-checking the timestamps. However, it allows all of the other interrupt
causes a chance to be processed first in the hard IRQ function.
Note that the OICR interrupt is configured to be throttled to no more than
once every 124 microseconds. This gives an effective interrupt rate of
~8000 interrupts per second. This should thus not cause a significant
increase in overall CPU usage when compared to sleeping.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 9df53dd300a9..8f3ddc8451bd 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3202,8 +3202,15 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
ice_ptp_extts_event(pf);
if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) {
- while (ice_ptp_process_ts(pf) == ICE_TX_TSTAMP_WORK_PENDING)
- usleep_range(50, 100);
+ struct ice_hw *hw = &pf->hw;
+
+ /* Process outstanding Tx timestamps. If there is more work,
+ * re-arm the interrupt to trigger again.
+ */
+ if (ice_ptp_process_ts(pf) == ICE_TX_TSTAMP_WORK_PENDING) {
+ wr32(hw, PFINT_OICR, PFINT_OICR_TSYN_TX_M);
+ ice_flush(hw);
+ }
}
return IRQ_HANDLED;
--
2.40.0.471.gbd7f14d9353b
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
` (3 preceding siblings ...)
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling Jacob Keller
@ 2023-06-01 21:15 ` Jacob Keller
2023-06-08 12:14 ` Arland, ArpanaX
2023-06-02 8:25 ` [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Michal Schmidt
5 siblings, 1 reply; 12+ messages in thread
From: Jacob Keller @ 2023-06-01 21:15 UTC (permalink / raw)
To: Intel Wired LAN, Anthony Nguyen
The ice driver uses threaded IRQ for managing Tx timestamps via the
devm_request_threaded_irq() interface. The ice_misc_intr() handler function
is responsible for processing the hard interrupt context, and can wake the
ice_misc_intr_thread_fn() by returning IRQ_WAKE_THREAD.
The request_threaded_irq() function comment says:
@handler is still called in hard interrupt context and has to check
whether the interrupt originates from the device. If yes, it needs to
disable the interrupt on the device and return IRQ_WAKE_THREAD which will
wake up the handler thread and run the @thread_fn.
We currently re-enable the Other Interrupt Cause Register (OCIR) at the end of
ice_misc_intr(). In practice, this seems to be ok, but it can make
communicating between the handler function and the thread function
difficult. This is because the interrupt can trigger again while the thread
function is still processing.
Move the OICR update to the end of the thread function, leaving the other
interrupt cause disabled in hardware until we complete one pass of the
thread function. This prevents the miscellaneous interrupt from firing
until after we finish the thread function.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 8f3ddc8451bd..6eae43828c46 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3179,8 +3179,6 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
}
}
- ice_irq_dynamic_ena(hw, NULL, NULL);
-
return IRQ_WAKE_THREAD;
}
@@ -3192,6 +3190,9 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
{
struct ice_pf *pf = data;
+ struct ice_hw *hw;
+
+ hw = &pf->hw;
if (ice_is_reset_in_progress(pf->state))
return IRQ_HANDLED;
@@ -3202,8 +3203,6 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
ice_ptp_extts_event(pf);
if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) {
- struct ice_hw *hw = &pf->hw;
-
/* Process outstanding Tx timestamps. If there is more work,
* re-arm the interrupt to trigger again.
*/
@@ -3213,6 +3212,8 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
}
}
+ ice_irq_dynamic_ena(hw, NULL, NULL);
+
return IRQ_HANDLED;
}
--
2.40.0.471.gbd7f14d9353b
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
` (4 preceding siblings ...)
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes Jacob Keller
@ 2023-06-02 8:25 ` Michal Schmidt
5 siblings, 0 replies; 12+ messages in thread
From: Michal Schmidt @ 2023-06-02 8:25 UTC (permalink / raw)
To: Jacob Keller; +Cc: Anthony Nguyen, Intel Wired LAN
On Thu, Jun 1, 2023 at 11:15 PM Jacob Keller <jacob.e.keller@intel.com> wrote:
>
> This series improves the driver's use of the threaded IRQ and the
> communication between ice_misc_intr() and the ice_misc_intr_thread_fn()
> which was previously introduced by commit 1229b33973c7 ("ice: Add low
> latency Tx timestamp read").
>
> First, a new custom enumerated return value is used instead of a boolean for
> ice_ptp_process_ts(). This significantly reduces the cognitive burden when
> reviewing the logic for this function, as the expected action is clear from
> the return value name.
>
> Second, the unconditional loop in ice_misc_intr_thread_fn() is removed,
> replacing it with a write to the Other Interrupt Cause register. This causes
> the MAC to trigger the Tx timestamp interrupt again. This makes it possible
> to safely use the ice_misc_intr_thread_fn() to handle other tasks beyond
> just the Tx timestamps. It is also easier to reason about since the thread
> function will exit cleanly if we do something like disable the interrupt and
> call synchronize_irq().
>
> Third, refactor the handling for external timestamp events to use the
> miscellaneous thread function. This resolves an issue with the external
> time stamps getting blocked while processing the periodic work function
> task.
>
> Fourth, a simplification of the ice_misc_intr() function to always return
> IRQ_WAKE_THREAD, and schedule the ice service task in the
> ice_misc_intr_thread_fn() instead.
>
> Finally, the Other Interrupt Cause is kept disabled over the thread function
> processing, rather than immediately re-enabled.
>
> Special thanks to Michal Schmidt for the careful review of the series and
> pointing out my misunderstandings of the kernel IRQ code. It has been
> determined that the race outlined as being fixed in previous series was
> actually introduced by this series itself, which I've since corrected.
>
> Changes since v2:
> * heavily re-ordered patches for clarity and a better flow of implementation
> * used atomic bits when communicating between ice_misc_intr() and
> ice_misc_intr_thread_fn()
> * re-wrote commit messages to improve clarity and remove mistakes about how
> threaded IRQs work.
>
> Jacob Keller (3):
> ice: introduce ICE_TX_TSTAMP_WORK enumeration
> ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling
> ice: do not re-enable miscellaneous interrupt until thread_fn
> completes
>
> Karol Kolacinski (2):
> ice: handle extts in the miscellaneous interrupt thread
> ice: always return IRQ_WAKE_THREAD in ice_misc_intr()
>
> drivers/net/ethernet/intel/ice/ice.h | 7 +++
> drivers/net/ethernet/intel/ice/ice_main.c | 47 +++++++++++------
> drivers/net/ethernet/intel/ice/ice_ptp.c | 62 ++++++++++++-----------
> drivers/net/ethernet/intel/ice/ice_ptp.h | 16 ++++--
> 4 files changed, 84 insertions(+), 48 deletions(-)
>
>
> base-commit: f08ff053a47a51d4f391d407bdda6adb4e7ed499
> --
> 2.40.0.471.gbd7f14d9353b
Thanks, it looks good now. To the series:
Reviewed-by: Michal Schmidt <mschmidt@redhat.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread Jacob Keller
@ 2023-06-08 12:12 ` Arland, ArpanaX
0 siblings, 0 replies; 12+ messages in thread
From: Arland, ArpanaX @ 2023-06-08 12:12 UTC (permalink / raw)
To: Keller, Jacob E, Intel Wired LAN, Nguyen, Anthony L; +Cc: Kolacinski, Karol
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jacob Keller
> Sent: Friday, June 2, 2023 2:45 AM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Cc: Kolacinski, Karol <karol.kolacinski@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread
>
> From: Karol Kolacinski <karol.kolacinski@intel.com>
>
> The ice_ptp_extts_work() and ice_ptp_periodic_work() functions are both scheduled on the same kthread worker, pf.ptp.kworker. The
> ice_ptp_periodic_work() function sends to the firmware to interact with the PHY, and must block to wait for responses.
>
> This can cause delay in responding to the PFINT_OICR_TSYN_EVNT interrupt cause, ultimately resulting in disruption to processing an input signal of the frequency is high enough. In our testing, even 100 Hz > signals get disrupted.
>
> Fix this by instead processing the signal inside the miscellaneous interrupt thread prior to handling Tx timestamps.
>
> Use atomic bits in a new pf->misc_thread bitmap in order to safely communicate which tasks require processing within the ice_misc_intr_thread_fn(). This ensures the communication of desired tasks from > the ice_misc_intr() are correctly processed without racing even in the event that the interrupt triggers again before the thread function exits.
>
> Fixes: 172db5f91d5f ("ice: add support for auxiliary input/output pins")
> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice.h | 7 ++++++
> drivers/net/ethernet/intel/ice/ice_main.c | 29 ++++++++++++++++------- drivers/net/ethernet/intel/ice/ice_ptp.c | 12 +++------- drivers/net/ethernet/intel/ice/ice_ptp.h | 4 ++--
> 4 files changed, 33 insertions(+), 19 deletions(-)
>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr()
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr() Jacob Keller
@ 2023-06-08 12:12 ` Arland, ArpanaX
0 siblings, 0 replies; 12+ messages in thread
From: Arland, ArpanaX @ 2023-06-08 12:12 UTC (permalink / raw)
To: Keller, Jacob E, Intel Wired LAN, Nguyen, Anthony L; +Cc: Kolacinski, Karol
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jacob Keller
> Sent: Friday, June 2, 2023 2:45 AM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Cc: Kolacinski, Karol <karol.kolacinski@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr()
>
> From: Karol Kolacinski <karol.kolacinski@intel.com>
>
> Refactor the ice_misc_intr() function to always return IRQ_WAKE_THREAD, and schedule the service task during the soft IRQ thread function instead of at the end of the hard IRQ handler.
>
> Remove the duplicate call to ice_service_task_schedule() that happened when we got a PCI exception.
>
> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration Jacob Keller
@ 2023-06-08 12:13 ` Arland, ArpanaX
0 siblings, 0 replies; 12+ messages in thread
From: Arland, ArpanaX @ 2023-06-08 12:13 UTC (permalink / raw)
To: Keller, Jacob E, Intel Wired LAN, Nguyen, Anthony L
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jacob Keller
> Sent: Friday, June 2, 2023 2:45 AM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration
>
> The ice_ptp_process_ts() function and its various helper functions return a boolean value indicating whether any work is remaining. This use of a boolean has grown confusing as we have multiple helpers that pass status between each other. Readers must be aware of what "true" and "false" mean, and it is very easy to get their meaning inverted. The names of the functions are not standard "yes/no" questions, which is the best practice for boolean returns.
>
> Replace this use of an enumeration with a custom type, enum ice_tx_tstamp_work. This enumeration clearly indicates whether all work is done, or if more work is pending.
>
> To aid in readability, factor the actual list iteration and processing out into ice_ptp_process_tx_tstamp(), making it void. Then call this in
> ice_ptp_tx_tstamp() ensuring that we always check the Tracker list at the end when determining the appropriate return value.
>
> Now the return value is an explicit name instead of the true or false value. This is easier to follow and makes reading the resulting callers much simpler.
>
> In addition, this paves the way for future work to allow E822 hardware to process timestamps for all functions using a single interrupt on the clock owning PF.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 50 ++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 12 +++++-
> 3 files changed, 42 insertions(+), 22 deletions(-)
>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling Jacob Keller
@ 2023-06-08 12:14 ` Arland, ArpanaX
0 siblings, 0 replies; 12+ messages in thread
From: Arland, ArpanaX @ 2023-06-08 12:14 UTC (permalink / raw)
To: Keller, Jacob E, Intel Wired LAN, Nguyen, Anthony L
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jacob Keller
> Sent: Friday, June 2, 2023 2:45 AM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling
>
> In ice_misc_intr_thread_fn(), if we do not complete all Tx timestamp work, the thread function will poll continuously forever.
>
> For E822 hardware, this wastes time as the return value from
> ice_ptp_process_ts() is accurate and always reports correctly that the PHY actually has new timestamp data.
>
> In addition, if we receive enough timestamps with the right pacing, we may never exit this polling. Should this occur, other tasks handled by the
> ice_misc_intr_thread_fn() will never be processed.
>
> Fix this by instead writing to PFINT_OICR, causing an emulated interrupt to be triggered immediately. This does take slightly more processing than just re-checking the timestamps. However, it allows all of the other interrupt causes a chance to be processed first in the hard IRQ function.
>
> Note that the OICR interrupt is configured to be throttled to no more than once every 124 microseconds. This gives an effective interrupt rate of
> ~8000 interrupts per second. This should thus not cause a significant increase in overall CPU usage when compared to sleeping.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes Jacob Keller
@ 2023-06-08 12:14 ` Arland, ArpanaX
0 siblings, 0 replies; 12+ messages in thread
From: Arland, ArpanaX @ 2023-06-08 12:14 UTC (permalink / raw)
To: Keller, Jacob E, Intel Wired LAN, Nguyen, Anthony L
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jacob Keller
> Sent: Friday, June 2, 2023 2:45 AM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes
>
> The ice driver uses threaded IRQ for managing Tx timestamps via the
> devm_request_threaded_irq() interface. The ice_misc_intr() handler function is responsible for processing the hard interrupt context, and can wake the
> ice_misc_intr_thread_fn() by returning IRQ_WAKE_THREAD.
>
> The request_threaded_irq() function comment says:
>
> @handler is still called in hard interrupt context and has to check
> whether the interrupt originates from the device. If yes, it needs to
> disable the interrupt on the device and return IRQ_WAKE_THREAD which will
> wake up the handler thread and run the @thread_fn.
>
> We currently re-enable the Other Interrupt Cause Register (OCIR) at the end of ice_misc_intr(). In practice, this seems to be ok, but it can make communicating between the handler function and the thread > function difficult. This is because the interrupt can trigger again while the thread function is still processing.
>
> Move the OICR update to the end of the thread function, leaving the other interrupt cause disabled in hardware until we complete one pass of the thread function. This prevents the miscellaneous interrupt > from firing until after we finish the thread function.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-06-08 12:14 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01 21:15 [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Jacob Keller
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 1/5] ice: handle extts in the miscellaneous interrupt thread Jacob Keller
2023-06-08 12:12 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 2/5] ice: always return IRQ_WAKE_THREAD in ice_misc_intr() Jacob Keller
2023-06-08 12:12 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration Jacob Keller
2023-06-08 12:13 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling Jacob Keller
2023-06-08 12:14 ` Arland, ArpanaX
2023-06-01 21:15 ` [Intel-wired-lan] [PATCH iwl-next v3 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes Jacob Keller
2023-06-08 12:14 ` Arland, ArpanaX
2023-06-02 8:25 ` [Intel-wired-lan] [PATCH iwl-next v3 0/5] ice: Improve miscellaneous interrupt code Michal Schmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox