From patchwork Fri May 26 22:21:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1786679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=JUZExZVh; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QSfZR43yjz20Q1 for ; Sat, 27 May 2023 08:23:11 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D370D84D9E; Fri, 26 May 2023 22:23:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D370D84D9E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1685139789; bh=K9ziKSrW5DEminbr8HZ1Q1oIda9Zu2q7R0Ab2pIvet8=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=JUZExZVhuPSyXJEpfVn5lkwdtcMWXmBdS+8ir/mPxzg762EARnk05NsPCGeK4hrND wumTfU7JyYtIiw14LhS4tgY5F3NoVHj85mJkgOZR8vrSETYAdw96oxCikCIspX3rXZ 5HE2K6yVabcv6otoN0slnHMQGvRsQu1x+rw4cBUu1THejHRv2OnI1zY6I1qm3rlJ9s nNaLHzBdMjrdfqMCSifWF4y+WJLhT+THNWcckGdbeM5ELiUDU0lTY81ZNi0mlp8Lbl Hx3Hwth7imyhTYMnpnf74sx8rYw1rjIV9W01CfKtb79C4mMg0XA66qbNGtt0YBSWcu BZMX1C4YHAWUQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oawvfkdUcMKK; Fri, 26 May 2023 22:23:08 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 9577D84DC3; Fri, 26 May 2023 22:23:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 9577D84DC3 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id A81DE1BF33D for ; Fri, 26 May 2023 22:22:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C97DD42A97 for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C97DD42A97 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zMhQ5LJRxHYn for ; Fri, 26 May 2023 22:22:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 89A7842A99 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp4.osuosl.org (Postfix) with ESMTPS id 89A7842A99 for ; Fri, 26 May 2023 22:22:53 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="338912478" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="338912478" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="1035510109" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="1035510109" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:04 -0700 From: Jacob Keller To: Intel Wired LAN , Anthony Nguyen Date: Fri, 26 May 2023 15:21:54 -0700 Message-ID: <20230526222158.2685796-2-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.40.0.471.gbd7f14d9353b In-Reply-To: <20230526222158.2685796-1-jacob.e.keller@intel.com> References: <20230526222158.2685796-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685139773; x=1716675773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mJe2erO/PmyqV4YC1+IcvL9L/L7WE7SNPEJmQ7avJIw=; b=KaH6l96Qja4MA0/xwSV+YSZbYSwlIETM9/kci88+kIPUuliMgApuH5iy qSXR2IOj/8VrocHwsyNbt0k7dB/Fx5ZJVbcSKQxfO2yRUiGmpQp7LcBNV qSBSfB/E+G93LgjNuvyigrMqNVgvu7mHPmS3cf/lgs8ouefv4VotVRF5r v3VwUJnM7uNfiteJT9rk2gi2tvRq8fB2TNeYMTZHYXOE/XILByJhMM2Fa V2nbxd0NSt8Z60vOzQG1xFMUZttUj7gUuvROcuzP4oc79rCsjX1Lhwjjv iXJBA3a0BGfNM8C+5Uf/etpU5F5GtEjtlw39jPuqM68/ZGbKjUHpUJuvQ w==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KaH6l96Q Subject: [Intel-wired-lan] [PATCH iwl-next 1/5] ice: handle extts in the miscellaneous interrupt thread X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Karol Kolacinski Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Karol Kolacinski 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. Note the unconditional usleep_range loop in ice_mics_intr_thread_fn() is pre-existing. While concerning, it will be removed in the last change in a following chance that refactors to use a software-triggered interrupt instead. Fixes: 172db5f91d5f ("ice: add support for auxiliary input/output pins") Signed-off-by: Karol Kolacinski Signed-off-by: Jacob Keller --- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_main.c | 33 +++++++++++++++++------ drivers/net/ethernet/intel/ice/ice_ptp.c | 12 +++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 4 +-- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 176e281dfa24..4256b9f5a25f 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -580,6 +580,7 @@ struct ice_pf { u32 hw_csum_rx_error; u32 oicr_err_reg; struct msi_map oicr_irq; /* Other interrupt cause MSIX vector */ + u16 oicr_misc; /* Misc interrupts to handle in bottom half */ u16 max_pf_txqs; /* Total Tx queues PF wide */ u16 max_pf_rxqs; /* Total Rx queues PF wide */ u16 num_lan_msix; /* Total MSIX vectors for base driver */ diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index c7d7104dbadc..9e4d7d884115 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) { + pf->oicr_misc |= PFINT_OICR_TSYN_TX_M; 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); + + pf->oicr_misc |= PFINT_OICR_TSYN_EVNT_M; + 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,16 @@ 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 (pf->oicr_misc & PFINT_OICR_TSYN_EVNT_M) { + ice_ptp_extts_event(pf); + pf->oicr_misc &= ~PFINT_OICR_TSYN_EVNT_M; + } + + if (pf->oicr_misc & PFINT_OICR_TSYN_TX_M) { + while (!ice_ptp_process_ts(pf)) + usleep_range(50, 100); + pf->oicr_misc &= ~PFINT_OICR_TSYN_TX_M; + } return IRQ_HANDLED; } @@ -4958,6 +4974,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) pf = ice_allocate_pf(dev); if (!pf) return -ENOMEM; + pf->oicr_misc = 0; /* initialize Auxiliary index to invalid value */ pf->aux_idx = -1; 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) { From patchwork Fri May 26 22:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1786680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=IITbkhlw; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QSfZX0n2dz20Q1 for ; Sat, 27 May 2023 08:23:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 55C6A84DCF; Fri, 26 May 2023 22:23:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 55C6A84DCF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1685139794; bh=cE0twRmMyfvlCEKQkzGhSbZMsJDtaGiIwE5oyJvuW5w=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=IITbkhlwJakMEhnd7s5R9VkbFoCmB8r9hd3tZj8+56Tb+sg9RszvGd5y0YqX2yUHg x+LA4Ve3nZAq/6cHwMLkJ5H/5wBahtDdQsFAV035BjvuWxOcRqGZwN9+A2WswiHzyu 0hhsbr3uiXvNiuwLtu2bKqaylFse2XudkTdThiAr/rGlxy5IwOhDK7ugjiGZ/sNbLW 8D9i0FacgjYpAyR83LuNATHpaflITgVpaShqCebLrfuVx0+thON2brdz35qLnQ5pVg tCrJueFeVyW00F2g7dMLDooalPp5+tHfskQyMBP1H6fYcp42cLbUUNfBRBQwlNTmHL cL44MpdQ+uh6A== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tx7jVM2jtVSe; Fri, 26 May 2023 22:23:13 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 6269084DD7; Fri, 26 May 2023 22:23:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6269084DD7 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id B9A221BF33D for ; Fri, 26 May 2023 22:22:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1157A42A99 for ; Fri, 26 May 2023 22:22:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1157A42A99 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SRfQHqPsYU9Z for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 13EE342A96 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp4.osuosl.org (Postfix) with ESMTPS id 13EE342A96 for ; Fri, 26 May 2023 22:22:53 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="338912481" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="338912481" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="1035510114" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="1035510114" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:04 -0700 From: Jacob Keller To: Intel Wired LAN , Anthony Nguyen Date: Fri, 26 May 2023 15:21:55 -0700 Message-ID: <20230526222158.2685796-3-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.40.0.471.gbd7f14d9353b In-Reply-To: <20230526222158.2685796-1-jacob.e.keller@intel.com> References: <20230526222158.2685796-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685139774; x=1716675774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L0UuBNTgAOi93CyN9tZhW2ZvyE5yIYyTkv5UvBAXmSg=; b=Gu4MdxeGcz055H16VLs7Z8KG6sCcOQOvUtBpBu/68yZMJMIgugdsh03i ZaSOi5rJNI/gPecxhw7ER6gRkFBhTCcWs1lv2mEFgoiuKo3IpP33MuLYW XF9GN062szptyf5mS9AuNe43Pnve2brNw9zoZ1g7wALz9XgEGyC8zgYY9 vX9vuw+Vk/Gvzu75fQSziTpY4I/JxW9b16Uw+o1NO0S/31Xe1MGjhXTkm DrCyLIdTZ2unqE0qo2pYqt3v1/cvfKsv++JxjHq0t/E7v6HwVf3fEaeQY jhWO0eLlW2enORdQzoeFjIMe9H4qTlwOFc1uLkt/1ErxUQ/6pWa9uTH0d g==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Gu4MdxeG Subject: [Intel-wired-lan] [PATCH iwl-next 2/5] ice: schedule service task in IRQ thread_fn X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Karol Kolacinski Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Karol Kolacinski If the kernel is configured with CONFIG_PREEMPT_RT, scheduling the service task in interrupt context can result in a kernel panic. This is a result of ice_service_task_schedule calling queue_work. Move the ice_service_task_schedule() call into the miscellaneous IRQ thread that functions as the interrupt bottom half. Signed-off-by: Karol Kolacinski Signed-off-by: Jacob Keller --- 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 9e4d7d884115..8b59632ec6b1 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) pf->oicr_misc |= PFINT_OICR_TSYN_TX_M; - 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); pf->oicr_misc |= PFINT_OICR_TSYN_EVNT_M; - 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 (pf->oicr_misc & PFINT_OICR_TSYN_EVNT_M) { ice_ptp_extts_event(pf); pf->oicr_misc &= ~PFINT_OICR_TSYN_EVNT_M; From patchwork Fri May 26 22:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1786678 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=H2wvSxOX; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QSfZM2plVz20Q1 for ; Sat, 27 May 2023 08:23:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 90DB084DBE; Fri, 26 May 2023 22:23:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 90DB084DBE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1685139785; bh=tCxUmUA9gqAN6jlmt5kOmAF7VYYfsAbQD3BhuoFLdwE=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=H2wvSxOXZ3/NIpUh4vLZPTiep1RIki0azdpuZy7Qt38dh/ka2TePnB3FmcoPu6WEd YrDFZwsFBKe8fJGazF8ExNZny7wr+YT4tFF7Ns/Tqk3mdqzSfIcpCMdP8+Hts7Ww2i 6vuNvy8FgieFW/EhUJ2k9uWikwXRHXXdTGWhgIQUZseJf3QEclxkoVx/RZU38rpVTh Jk9IYLnPdhNPemjYUd/QxunteV+VR26umSVFequtaJamAZ1dbuJAQ4iIq3LWsq1VV7 DtSaTAncjW0Pi5Zgdr5kpCK5lXRgtQ3VW1wMoPt5sjqab0K78KLjLwzadkZXQCZu2z bGEUcqdE5rf7Q== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mVPyOrlnbhqp; Fri, 26 May 2023 22:23:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 67CCC84DCE; Fri, 26 May 2023 22:23:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 67CCC84DCE X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 39D801BF97A for ; Fri, 26 May 2023 22:22:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5EC8542A9A for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5EC8542A9A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t0KaKSF9OnVR for ; Fri, 26 May 2023 22:22:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2290742A97 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2290742A97 for ; Fri, 26 May 2023 22:22:53 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="338912485" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="338912485" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="1035510118" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="1035510118" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:04 -0700 From: Jacob Keller To: Intel Wired LAN , Anthony Nguyen Date: Fri, 26 May 2023 15:21:56 -0700 Message-ID: <20230526222158.2685796-4-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.40.0.471.gbd7f14d9353b In-Reply-To: <20230526222158.2685796-1-jacob.e.keller@intel.com> References: <20230526222158.2685796-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685139773; x=1716675773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WDXmIC+0MFoDefRZ0T1ape7L4u8Kyy6sBieml5HCLvM=; b=IfH2Vg6FG/wvvIi7eGXEn7vuqMUrd7jp6TqF0Mi9EMkaaefPdFrOaf2C mBlEUY+DIkBcWVYpYdrGj8vEFu+G2Ft3zmIyIx146rnpck85SAdErTNi5 SUtIOzNW0mk7kEWh5mBlgso01XwF/hvzdmXgUBXlJO2id3KYIEhy7z4d2 uOzi73sK+xGswS2ZOIK2/y2xMIju3r5BrQURju63Et9PHrFhPE7JbTIIK 93540CKo7aFi+Gt/tZbeecBu04GCQFNjLiUlAY9R52ycYWE/oqRUFREtP ndY031EEg9+mN2atfOwRJqRaigDhGDHMtIgAKTyqPrh4kWCrsFbErkjr/ w==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IfH2Vg6F Subject: [Intel-wired-lan] [PATCH iwl-next 3/5] ice: introduce ICE_TX_TSTAMP_WORK enumeration X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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 --- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 49 ++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 12 +++++- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 8b59632ec6b1..481dccdb95cd 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3204,7 +3204,7 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data) } if (pf->oicr_misc & PFINT_OICR_TSYN_TX_M) { - while (!ice_ptp_process_ts(pf)) + while (ice_ptp_process_ts(pf) == ICE_TX_TSTAMP_WORK_PENDING) usleep_range(50, 100); pf->oicr_misc &= ~PFINT_OICR_TSYN_TX_M; } diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 6f51ebaf1d70..bbb9a44c5616 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,7 +664,7 @@ 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; @@ -685,7 +676,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 +685,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 +773,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 +2436,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, From patchwork Fri May 26 22:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1786677 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=3xPLAC2F; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QSfZG6dvBz20Q1 for ; Sat, 27 May 2023 08:23:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2F47684DC2; Fri, 26 May 2023 22:23:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2F47684DC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1685139781; bh=n+GmH1tnDCehqqnveEsTiHI4BL4EbVFbmTJvO82gFAA=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=3xPLAC2FHrHG5/DlWw6X+VibFWWuDRtw1Db+B/PaAVXwwRsMig8ZcVrmrylzywPXK gJHuTd8dYfvHOSDPHBzax2PiMGRZsgnqHQOw04QK82Jz42FiFcmaxgF06uIHKsTaFj xQ202LDOLJ44Q+9JiNc3+pU/63mG0JzTLOlWNr8yPrCl4SOdjxdLwe9YXT4I6XBORB VB/7nL0aZKAiZRG4GvC43y0nlP6qVWUVS2zgSxvETHIlkTsJ7syxNvZpBTzA6j7+Em FxcRDsxInj8xxUT5H+JM+HYEn0wkhJ4fSVHr1ymBrvmzMtSaKsvitasjro+3ngnsJz k2rDR0plVDSJg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 25Pp3U49JNLM; Fri, 26 May 2023 22:23:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 3AEEE84DCE; Fri, 26 May 2023 22:23:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3AEEE84DCE X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 0FF021BF33D for ; Fri, 26 May 2023 22:22:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EA04984D9E for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EA04984D9E X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DDJci15cycEw for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 31C3384D99 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 31C3384D99 for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="338912492" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="338912492" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="1035510123" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="1035510123" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:04 -0700 From: Jacob Keller To: Intel Wired LAN , Anthony Nguyen Date: Fri, 26 May 2023 15:21:57 -0700 Message-ID: <20230526222158.2685796-5-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.40.0.471.gbd7f14d9353b In-Reply-To: <20230526222158.2685796-1-jacob.e.keller@intel.com> References: <20230526222158.2685796-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685139774; x=1716675774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRfyBLCTze/CBY8sOdhy62bTvmqiq3bi4OPOpd7PceA=; b=LLH6qUGBTHwzs3nxhsj4yyse6MfzB9W/mwGstOkVh/sbq7akMIYiSQ9m zSYkYNBPN9xxkO4DSpSAlnaIxqOtwDJ+AOH63mmBAV5CvW4R24ZkYw7J1 DFoAkvqqxJrCwntXtjfXJfgGkCJ2DyQ3MOvMctwsp1zLXfAyZcRgtuKkb TY3/OK/d/smRAJ4pATIDB2PBbITX7ywMwxHZzHWTakYMBfjmDcHL9wm8L vVEF+w2Jo/4rRx847yRaqwXPlgmH915iisYQTDIYzW2txOmgIC89DHVHH Zl6hfWJchcTN59Nv/vjqyuW9LUGOHEJw/Z96eJS7dGEpYKNRuAbWX51/y g==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LLH6qUGB Subject: [Intel-wired-lan] [PATCH iwl-next 4/5] ice: trigger PFINT_OICR_TSYN_TX interrupt instead of polling X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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 at the right pacing, we might never exit this polling and thus prevent other interrupt tasks from being 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 throttled to 8K per second, so the hardware will not let the interrupt trigger more often than once every 124 microseconds, so this should not cause a significant increase in CPU usage vs the sleeping method. Signed-off-by: Jacob Keller --- drivers/net/ethernet/intel/ice/ice_main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 481dccdb95cd..72e1b919b2d3 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3204,8 +3204,16 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data) } if (pf->oicr_misc & PFINT_OICR_TSYN_TX_M) { - 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); + } + pf->oicr_misc &= ~PFINT_OICR_TSYN_TX_M; } From patchwork Fri May 26 22:21:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 1786681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=D4vZfSZh; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QSfZd10f8z20Q1 for ; Sat, 27 May 2023 08:23:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8476084DDE; Fri, 26 May 2023 22:23:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8476084DDE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1685139798; bh=uGWDscdbbFBgrbVTaIGEDY3D6+W3HFqVJDZQqysL+j4=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D4vZfSZhxBgPMiT3JScIGaWMCqJTkTAO0hr2n7mEWx/xYicxxZmtKyd8ZaoFlr7hj 9VoLF5PvVmcX3+T4wpkDZmN692Z5CAHyqsao2ldn/Y8TcYQ9TOTINiM/48U8GtI8C1 OITvNOlP0UEisf4+lUok9bF1GXHLeMHzv0YWF50fnmE1iWVZ+NZScjBl1O3vgZjZFd MHwXgfkUUiyj15YMmMfbewaa/6AKf+zmCqtzDz0v57/ijUC6+ZtxIUSewMR5iwVRid ncZj0kSn2Juk60v5Y2z96Ono2S000xphCeHfE5Z3hvVZuOTQH9mkIoeH0pLrXPC404 ZoUWzvQfycj+Q== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OVoXAJs4T9cJ; Fri, 26 May 2023 22:23:17 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 7FA0184DD5; Fri, 26 May 2023 22:23:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7FA0184DD5 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id CC6A81BF33D for ; Fri, 26 May 2023 22:22:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7CEE142A96 for ; Fri, 26 May 2023 22:22:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7CEE142A96 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RHyN8xnc05OW for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 64B2F42A9B Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp4.osuosl.org (Postfix) with ESMTPS id 64B2F42A9B for ; Fri, 26 May 2023 22:22:54 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="338912493" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="338912493" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10722"; a="1035510127" X-IronPort-AV: E=Sophos;i="6.00,195,1681196400"; d="scan'208";a="1035510127" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2023 15:22:04 -0700 From: Jacob Keller To: Intel Wired LAN , Anthony Nguyen Date: Fri, 26 May 2023 15:21:58 -0700 Message-ID: <20230526222158.2685796-6-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.40.0.471.gbd7f14d9353b In-Reply-To: <20230526222158.2685796-1-jacob.e.keller@intel.com> References: <20230526222158.2685796-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685139774; x=1716675774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jHIkguiVSGtmHbTx0JYDuHTTM4tGO/SGwOcDufN+LSk=; b=kk3ZVVdh0MesxsDd+SBfmVXzFEWLG7bzY4Obmu6y69tAk7NK910qgI5U bYJZAUrr0CaGREwBhfwx6ZGSLr7E0wp6fp5D+Bk7ULxvbykMghU6IK/Y/ hN8Avk6UOGqeMMlZ0lFIdi9xVEfVI8zSZIWVAlTBRZ/8nVJNTAgCrgk6B R1f7hI4/KWa1Vh14Theo2iSIacV6aXdAkw/pxSSjTvC5d0V5IplPJU+Kh MUk0j6pMBwslP4HNgFXdDSgdkDlDXhLZpmxp2iNMPbnF1CzZs0Ct7qn/5 4k14UmqSjUa5hAedsSu+/H/U7jAoOctrcILwVzUWPEXVVWgB2RIir37jv g==; X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=kk3ZVVdh Subject: [Intel-wired-lan] [PATCH iwl-next 5/5] ice: do not re-enable miscellaneous interrupt until thread_fn completes X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" At the end of ice_misc_intr() the driver calls ice_irq_dynamic_ena() to re-enable the miscellaneous interrupt. This is done before the ice_misc_intr_thread_fn can run and complete. According to the kernel function comment documentation for request_threaded_irq(), the interrupt should remain disabled until the thread function completes its task. By re-enabling the interrupt at the end of the hard IRQ, it is possible for a new interrupt to trigger while the thread function is processing. This is problematic for PTP Tx timestamps. For E822 devices, the hardware in the PHY keeps track of how many outstanding timestamps are generated and how many timestamps are read from the PHY. This counter is incremented once for each timestamp that is captured by hardware, and decremented once each time a timestamp is read from the PHY. The PHY will not generate a new interrupt unless this internal counter is zero before the most recently captured timestamp. Because of this counter behavior, a race with the hard IRQ and threaded IRQ function can result in the potential for the counter to get stuck such that no new interrupts will be triggered until the device is reset. Consider the following flow: 1 -> Tx timestamp completes in hardware 2 -> timestamp interrupt occurs 3 -> ice_misc_intr() re-enables timestamp interrupt, and wakes the thread_fn 4 -> thread_fn is running and processing Tx timestamp 5 -> the Tx timestamp is read from PHY, clearing the counter 6 -> a new Tx timestamp completes in hardware, triggering interrupt 7 -> the thread_fn hasn't exited and reported IRQ handled 8 -> ice_misc_intr() triggers and sees PTP interrupt, so tries to wake thread 9 -> thread_fn is already running (IRQTF_RUNTHREAD is set still!) so we skip running the thread... 10 -> an outstanding timestamp is remaining but we never read it 11 -> interrupt never triggers again The fix for this complicated race condition is simple: do not re-enable the miscellaneous interrupt until *after* the thread function completes. If a new timestamp event triggers while the interrupt is disabled, it will be remembered and should cause the interrupt to trigger again immediately after we re-enable the interrupt. Fixes: 1229b33973c7 ("ice: Add low latency Tx timestamp read") Signed-off-by: Jacob Keller --- 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 72e1b919b2d3..51fe3da0d54f 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; @@ -3204,8 +3205,6 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data) } if (pf->oicr_misc & PFINT_OICR_TSYN_TX_M) { - struct ice_hw *hw = &pf->hw; - /* Process outstanding Tx timestamps. If there is more work, * re-arm the interrupt to trigger again. */ @@ -3217,6 +3216,8 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data) pf->oicr_misc &= ~PFINT_OICR_TSYN_TX_M; } + ice_irq_dynamic_ena(hw, NULL, NULL); + return IRQ_HANDLED; }