From patchwork Tue Aug 22 12:40:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=syn0S2I6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVD42xxz1yNm for ; Tue, 22 Aug 2023 22:41:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 453DF6066D; Tue, 22 Aug 2023 12:41:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 453DF6066D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708066; bh=rmuNoHvA/Byt3Vus8EKmt3Q/Rb6j1dR7mmWBfgJDrJ4=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=syn0S2I63K7x5HjzCQ6ztcJHgrd04fBPawhwDh8vRBh8ZD8tQfxGvSWav+e6xLPIF bq3rxYyCh7UfIfLrIs1nkpeZJMQGkZXD4PpQuJfvFhvm8bVnaDmij0Wwppg7rXS6k6 PrtjOFDo5GQjtIYIJiwktj212UEmIQZ0hIVWPtEbjJkqOgCuMvFzh4jOXjhR5743oz Bm3aX4Y7YRyHdk12tvwu7l/Uw7sw3S51zFj3BYTmtfY4vhMLFwgCBIaO8DYUkPtYky v/2iA9oJ+10nfmUTugz8ynjtPVzZ3ZVNKNIq++MDd+qh1O3jZb1QQsJctMgIlW1Ftr TeE8KcY10D9Eg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ccmn50yaYXSC; Tue, 22 Aug 2023 12:41:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 3547B611A1; Tue, 22 Aug 2023 12:41:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3547B611A1 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 934621BF296 for ; Tue, 22 Aug 2023 12:41:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6C6A96066D for ; Tue, 22 Aug 2023 12:41:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6C6A96066D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g64mLzn5FF0u for ; Tue, 22 Aug 2023 12:41:01 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id 52AB5607B0 for ; Tue, 22 Aug 2023 12:41:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 52AB5607B0 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604600" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604600" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342890" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342890" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:40:57 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:36 +0200 Message-Id: <20230822124044.301654-2-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708061; x=1724244061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Ufi43P3zynjx+wDKj2BMVqEurv8P54xkkFZtVzZheQ=; b=UfVx0axwCglka3rYZUhFwrH5bsLUisycjAyqy50fSRB0VDwyZC7BCtJT g72t5T9Nz6MTYHyrbWe1O4F2FbSeHejEndzh0iUkjpKrMpKMrcIk6txBf C/qNB7fMgzRHTbx9raiIPTiVFIkFDndVw5R/MTeHm8ILPvy/I2iAGcW/b Xb0jxqB6rtI+jBZ0xK6B58x9UxxsnF6QdFun81XMHrbFo309gFoSZcHH/ F8r3g6kUu/7xUgM2QbLU1jbiEbOiX6x3vbjckAi9b42MaesvqohetaY3p STJ1EgkwDEfw3oZT0r3KPJP0KrqLg62nkBABQnI/oP4l+cGqy3tKqitOd Q==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UfVx0axw Subject: [Intel-wired-lan] [PATCH v3 iwl-next 1/9] ice: use ice_pf_src_tmr_owned where available 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The ice_pf_src_tmr_owned() macro exists to check the function capability bit indicating if the current function owns the PTP hardware clock. This is slightly shorter than the more verbose access via hw.func_caps.ts_func_info.src_tmr_owned. Be consistent and use this where possible rather than open coding its equivalent. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index cc1f65781913..0d369e5e7441 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3159,7 +3159,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data) ena_mask &= ~PFINT_OICR_TSYN_EVNT_M; - if (hw->func_caps.ts_func_info.src_tmr_owned) { + if (ice_pf_src_tmr_owned(pf)) { /* Save EVENTs from GLTSYN register */ pf->ptp.ext_ts_irq |= gltsyn_stat & (GLTSYN_STAT_EVENT0_M | diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index ca40ca220cc9..2e3f0aaacddd 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2449,7 +2449,7 @@ void ice_ptp_reset(struct ice_pf *pf) if (test_bit(ICE_PFR_REQ, pf->state)) goto pfr; - if (!hw->func_caps.ts_func_info.src_tmr_owned) + if (!ice_pf_src_tmr_owned(pf)) goto reset_ts; err = ice_ptp_init_phc(hw); From patchwork Tue Aug 22 12:40:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=N9xc67Xd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVL4cjZz1yNm for ; Tue, 22 Aug 2023 22:41:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 42BAE611AF; Tue, 22 Aug 2023 12:41:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 42BAE611AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708072; bh=aUP1AntLh60SYIXYurTbtQnMLmeSRvi4aXxXDgYD7tM=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=N9xc67XdWQ6Nh9T2qGE1P0krG0EwMQA12VKnlYPpvcQrK10O6FYTQYq+DByzYu2Ek ZYeAKGrhGMQOF8v0ECPATu4vjiaFQE71+Pg4r8PJnB6M9JFkdYEsC5QXdTrh9AB5Jx 7sCagED78gyl+zkTa0t098OTVQE3JAi4T3sPIBc2RrD9nUBBqArNylj4A1zw07dUYc h6mchlREpMAvXJrTyh4T8RQZlOm8yUemogIass28mQxt1NesnAzTUMqii+ZCa3m90p TRwoFSmx3gHA9i9TXvEF2wUQ7YKRSlQJgPYbSYl9RvYIBfZqmaJb4aCqMYyjmMGQth DWrIB77zHmRmg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0zCMQ_HxZLP6; Tue, 22 Aug 2023 12:41:11 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id A0C5C611A5; Tue, 22 Aug 2023 12:41:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A0C5C611A5 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id C840A1BF296 for ; Tue, 22 Aug 2023 12:41:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 94237611B3 for ; Tue, 22 Aug 2023 12:41:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 94237611B3 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5woq6fC5BoUC for ; Tue, 22 Aug 2023 12:41:04 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id 723846066D for ; Tue, 22 Aug 2023 12:41:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 723846066D X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604611" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604611" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342899" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342899" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:40:59 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:37 +0200 Message-Id: <20230822124044.301654-3-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708064; x=1724244064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1UqkuZA6XJC0gPh98eoYGZXb9QqQPdNdE+riNUfakQ4=; b=CIZ2gAC0vNjxHGWWWPTXmbMJI7mUwLtCUyrZHI9BT5fU4P70wR1OGcuw JGkgdl0v8/YfeDXjDyNWQYgSD3KJnA8G9MuXnsWFXSJPQ2DLAwBC7ar8n lI9+poL47ZKz3qzaOLWMQuJE18g4drYHgZtksRelG95+P99xgLtSS3Trp WWxPBqHvdEkYN5I0be/WZSHuQgXu2AOiFA/DYBlinbgtsLrZsugzIk1+z X7705QDU12turdpuS+t7gvH0SaTqLVaPUT2krFg3Woy997em0rAFgCvVW 54WGlzt02qbLWHBC12E3TNO7LEhjVg2ovRl2C2BRZpFsRNF62kwJxY6ky Q==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CIZ2gAC0 Subject: [Intel-wired-lan] [PATCH v3 iwl-next 2/9] ice: introduce PTP state machine 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Add PTP state machine so that the driver can correctly identify PTP state around resets. When the driver got information about ungraceful reset, PTP was not prepared for reset and it returned error. When this situation occurs, prepare PTP before rebuilding its structures. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice.h | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 131 +++++++++++++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 10 ++ 4 files changed, 99 insertions(+), 45 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index cf6c961e8d9b..4c4b17ef99fa 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -489,7 +489,6 @@ enum ice_pf_flags { ICE_FLAG_DCB_ENA, ICE_FLAG_FD_ENA, ICE_FLAG_PTP_SUPPORTED, /* PTP is supported by NVM */ - ICE_FLAG_PTP, /* PTP is enabled by software */ ICE_FLAG_ADV_FEATURES, ICE_FLAG_TC_MQPRIO, /* support for Multi queue TC */ ICE_FLAG_CLS_FLOWER, diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index d3cb08e66dcb..7d57ecf48da0 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -3275,7 +3275,7 @@ ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) struct ice_pf *pf = ice_netdev_to_pf(dev); /* only report timestamping if PTP is enabled */ - if (!test_bit(ICE_FLAG_PTP, pf->flags)) + if (!test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) return ethtool_op_get_ts_info(dev, info); info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 2e3f0aaacddd..b138a895d0c9 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -255,6 +255,31 @@ ice_verify_pin_e810t(struct ptp_clock_info *info, unsigned int pin, return ice_ptp_set_sma_e810t(info, pin, func); } +/** + * ice_ptp_state_str - Convert PTP state to readable string + * @state: PTP state to convert + * + * Returns: the human readable string representation of the provided PTP + * state, used for printing error messages. + */ +static const char *ice_ptp_state_str(enum ice_ptp_state state) +{ + switch (state) { + case ICE_PTP_UNINIT: + return "UNINITIALIZED"; + case ICE_PTP_INITIALIZING: + return "INITIALIZING"; + case ICE_PTP_READY: + return "READY"; + case ICE_PTP_RESETTING: + return "RESETTING"; + case ICE_PTP_ERROR: + return "ERROR"; + } + + return "UNKNOWN"; +} + /** * ice_ptp_configure_tx_tstamp - Enable or disable Tx timestamp interrupt * @pf: The PF pointer to search in @@ -1285,7 +1310,7 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) struct ice_ptp_port *ptp_port; struct ice_hw *hw = &pf->hw; - if (!test_bit(ICE_FLAG_PTP, pf->flags)) + if (pf->ptp.state != ICE_PTP_READY) return; if (WARN_ON_ONCE(port >= ICE_NUM_EXTERNAL_PORTS)) @@ -2020,7 +2045,7 @@ int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) { struct hwtstamp_config *config; - if (!test_bit(ICE_FLAG_PTP, pf->flags)) + if (pf->ptp.state != ICE_PTP_READY) return -EIO; config = &pf->ptp.tstamp_config; @@ -2087,7 +2112,7 @@ int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) struct hwtstamp_config config; int err; - if (!test_bit(ICE_FLAG_PTP, pf->flags)) + if (pf->ptp.state != ICE_PTP_READY) return -EAGAIN; if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) @@ -2424,7 +2449,7 @@ static void ice_ptp_periodic_work(struct kthread_work *work) struct ice_pf *pf = container_of(ptp, struct ice_pf, ptp); int err; - if (!test_bit(ICE_FLAG_PTP, pf->flags)) + if (pf->ptp.state != ICE_PTP_READY) return; err = ice_ptp_update_cached_phctime(pf); @@ -2434,6 +2459,42 @@ static void ice_ptp_periodic_work(struct kthread_work *work) msecs_to_jiffies(err ? 10 : 500)); } +/** + * ice_ptp_prepare_for_reset - Prepare PTP for reset + * @pf: Board private structure + */ +void ice_ptp_prepare_for_reset(struct ice_pf *pf) +{ + struct ice_ptp *ptp = &pf->ptp; + u8 src_tmr; + + if (ptp->state == ICE_PTP_RESETTING) + return; + + ptp->state = ICE_PTP_RESETTING; + + /* Disable timestamping for both Tx and Rx */ + ice_ptp_cfg_timestamp(pf, false); + + kthread_cancel_delayed_work_sync(&ptp->work); + + if (test_bit(ICE_PFR_REQ, pf->state)) + return; + + ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); + + /* Disable periodic outputs */ + ice_ptp_disable_all_clkout(pf); + + src_tmr = ice_get_ptp_src_clock_index(&pf->hw); + + /* Disable source clock */ + wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); + + /* Acquire PHC and system timer to restore after reset */ + ptp->reset_time = ktime_get_real_ns(); +} + /** * ice_ptp_reset - Initialize PTP hardware clock support after reset * @pf: Board private structure @@ -2446,6 +2507,16 @@ void ice_ptp_reset(struct ice_pf *pf) int err, itr = 1; u64 time_diff; + if (ptp->state != ICE_PTP_RESETTING) { + if (ptp->state == ICE_PTP_READY) { + ice_ptp_prepare_for_reset(pf); + } else { + err = -EINVAL; + dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); + goto err; + } + } + if (test_bit(ICE_PFR_REQ, pf->state)) goto pfr; @@ -2512,7 +2583,7 @@ void ice_ptp_reset(struct ice_pf *pf) if (err) goto err; - set_bit(ICE_FLAG_PTP, pf->flags); + ptp->state = ICE_PTP_READY; /* Start periodic work going */ kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); @@ -2521,6 +2592,7 @@ void ice_ptp_reset(struct ice_pf *pf) return; err: + ptp->state = ICE_PTP_ERROR; dev_err(ice_pf_to_dev(pf), "PTP reset failed %d\n", err); } @@ -2727,39 +2799,6 @@ int ice_ptp_clock_index(struct ice_pf *pf) return clock ? ptp_clock_index(clock) : -1; } -/** - * ice_ptp_prepare_for_reset - Prepare PTP for reset - * @pf: Board private structure - */ -void ice_ptp_prepare_for_reset(struct ice_pf *pf) -{ - struct ice_ptp *ptp = &pf->ptp; - u8 src_tmr; - - clear_bit(ICE_FLAG_PTP, pf->flags); - - /* Disable timestamping for both Tx and Rx */ - ice_ptp_cfg_timestamp(pf, false); - - kthread_cancel_delayed_work_sync(&ptp->work); - - if (test_bit(ICE_PFR_REQ, pf->state)) - return; - - ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); - - /* Disable periodic outputs */ - ice_ptp_disable_all_clkout(pf); - - src_tmr = ice_get_ptp_src_clock_index(&pf->hw); - - /* Disable source clock */ - wr32(&pf->hw, GLTSYN_ENA(src_tmr), (u32)~GLTSYN_ENA_TSYN_ENA_M); - - /* Acquire PHC and system timer to restore after reset */ - ptp->reset_time = ktime_get_real_ns(); -} - /** * ice_ptp_init_owner - Initialize PTP_1588_CLOCK device * @pf: Board private structure @@ -3013,6 +3052,8 @@ void ice_ptp_init(struct ice_pf *pf) struct ice_hw *hw = &pf->hw; int err; + ptp->state = ICE_PTP_INITIALIZING; + ice_ptp_init_phy_model(hw); ice_ptp_init_tx_interrupt_mode(pf); @@ -3034,7 +3075,6 @@ void ice_ptp_init(struct ice_pf *pf) /* Start the PHY timestamping block */ ice_ptp_reset_phy_timestamping(pf); - set_bit(ICE_FLAG_PTP, pf->flags); err = ice_ptp_init_work(pf, ptp); if (err) goto err; @@ -3043,6 +3083,7 @@ void ice_ptp_init(struct ice_pf *pf) if (err) goto err; + ptp->state = ICE_PTP_READY; dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); return; @@ -3052,7 +3093,7 @@ void ice_ptp_init(struct ice_pf *pf) ptp_clock_unregister(ptp->clock); pf->ptp.clock = NULL; } - clear_bit(ICE_FLAG_PTP, pf->flags); + ptp->state = ICE_PTP_ERROR; dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err); } @@ -3065,9 +3106,15 @@ void ice_ptp_init(struct ice_pf *pf) */ void ice_ptp_release(struct ice_pf *pf) { - if (!test_bit(ICE_FLAG_PTP, pf->flags)) + if (pf->ptp.state == ICE_PTP_UNINIT) return; + if (pf->ptp.state != ICE_PTP_READY) + dev_warn(ice_pf_to_dev(pf), "PTP state machine is %s, tearing down PTP anyways\n", + ice_ptp_state_str(pf->ptp.state)); + + pf->ptp.state = ICE_PTP_UNINIT; + /* Disable timestamping for both Tx and Rx */ ice_ptp_cfg_timestamp(pf, false); @@ -3075,8 +3122,6 @@ void ice_ptp_release(struct ice_pf *pf) ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); - clear_bit(ICE_FLAG_PTP, pf->flags); - kthread_cancel_delayed_work_sync(&pf->ptp.work); ice_ptp_port_phy_stop(&pf->ptp.port); diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 8f6f94392756..674a0abe3cdd 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -201,8 +201,17 @@ struct ice_ptp_port_owner { #define GLTSYN_TGT_H_IDX_MAX 4 +enum ice_ptp_state { + ICE_PTP_UNINIT = 0, + ICE_PTP_INITIALIZING, + ICE_PTP_READY, + ICE_PTP_RESETTING, + ICE_PTP_ERROR, +}; + /** * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK + * @state: current state of PTP state machine * @tx_interrupt_mode: the TX interrupt mode for the PTP clock * @port: data for the PHY port initialization procedure * @ports_owner: data for the auxiliary driver owner @@ -225,6 +234,7 @@ struct ice_ptp_port_owner { * @late_cached_phc_updates: number of times cached PHC update is late */ struct ice_ptp { + enum ice_ptp_state state; enum ice_ptp_tx_interrupt tx_interrupt_mode; struct ice_ptp_port port; struct ice_ptp_port_owner ports_owner; From patchwork Tue Aug 22 12:40:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=jvahLmSn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVR3rrjz1yNm for ; Tue, 22 Aug 2023 22:41:19 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B7429611C0; Tue, 22 Aug 2023 12:41:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B7429611C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708077; bh=n7NJFVn/vkewiGS8f5RUH9/Hw4ZrD/7vySJnXdw0Jqw=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=jvahLmSn4lWqaQYJtUo3TXhiB4DqKL+pnW3E8wDQN6e07MA9OZfCUENuDhr22cdf+ diR/+3vsY2ay+nRXfWKkLI3kllBjVO7sjOP9rGFgHYEC+C4V2q+r2YWCV/46CwU/Tf eDExrJt/q9mOOcyVpipQYZyIj66d7M5MqxRh2+atgGr+3WcRuAYUnZFkU7O2vBzywT DIdxKu9yVn+3uGW28voQT8uJlJhFM2nCP5ujVV+ufVIp/oCJ97DiT+sip2Z3ZV13lo j8rcVhxXU8trleOv7t9Crnes7G7Z6G9w2DjGyE+fI19iSXjq2uHxWZYubXSlLbPNKS Ri1LNaqzqXcDA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m885WkDNiw7F; Tue, 22 Aug 2023 12:41:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 0F6E0611BA; Tue, 22 Aug 2023 12:41:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 0F6E0611BA X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 38E701BF296 for ; Tue, 22 Aug 2023 12:41:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 123A46066D for ; Tue, 22 Aug 2023 12:41:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 123A46066D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HQwrOOF0HMGd for ; Tue, 22 Aug 2023 12:41:05 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id D0FED60A91 for ; Tue, 22 Aug 2023 12:41:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D0FED60A91 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604613" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604613" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342906" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342906" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:02 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:38 +0200 Message-Id: <20230822124044.301654-4-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708064; x=1724244064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aqxGYt2fSeX3D8QiA73ZVKVQJwcjw3CaVT9U2In2Fng=; b=cHi6vR+5EpMAWVopP844e8oqctYS5j1/fQ9Has1zOc7eGVQgLfG75kKX ZfSzE+BRUFfMRtkLpTftzAjJcA5ix/ojQQcZrbL4q0iYN5xnXumWctwM+ BbrEU+AjwLu0jJYRJYk29XvmzzTymAVnLOzV1qNDHU8uL+xZO/UP8j6UA 5uLoQ9tcVNceh3iFZpzwovTJ169R86uTBlqNXlYJEUZt3O5D6ebYf3NoH njiKE+rTOUociGrt16mB5pACo+cRWh9zDCcrhZAl46k6fWAuksAVag1Y7 XueUxcnJ0DDnirNs3Mbju6EPjnrSLfLpUHJBeebUwh/yjKteg2FRSL1cV Q==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cHi6vR+5 Subject: [Intel-wired-lan] [PATCH v3 iwl-next 3/9] ice: pass reset type to PTP reset functions 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The ice_ptp_prepare_for_reset() and ice_ptp_reset() functions currently check the pf->flags ICE_FLAG_PFR_REQ bit to determine if the current reset is a PF reset or not. This is problematic, because it is possible that a PF reset and a higher level reset (CORE reset, GLOBAL reset, EMP reset) are requested simultaneously. In that case, the driver performs the highest level reset requested. However, the ICE_FLAG_PFR_REQ flag will still be set. The main driver reset functions take an enum ice_reset_req indicating which reset is actually being performed. Pass this data into the PTP functions and rely on this instead of relying on the driver flags. This ensures that the PTP code performs the proper level of reset that the driver is actually undergoing. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_main.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_ptp.c | 17 ++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 0d369e5e7441..ac6f241d0407 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -611,7 +611,7 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) ice_pf_dis_all_vsi(pf, false); if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) - ice_ptp_prepare_for_reset(pf); + ice_ptp_prepare_for_reset(pf, reset_type); if (ice_is_feature_supported(pf, ICE_F_GNSS)) ice_gnss_exit(pf); @@ -7356,7 +7356,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) * fail. */ if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) - ice_ptp_reset(pf); + ice_ptp_reset(pf, reset_type); if (ice_is_feature_supported(pf, ICE_F_GNSS)) ice_gnss_init(pf); diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index b138a895d0c9..bd94b42e19dd 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2462,8 +2462,10 @@ static void ice_ptp_periodic_work(struct kthread_work *work) /** * ice_ptp_prepare_for_reset - Prepare PTP for reset * @pf: Board private structure + * @reset_type: the reset type being performed */ -void ice_ptp_prepare_for_reset(struct ice_pf *pf) +void +ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) { struct ice_ptp *ptp = &pf->ptp; u8 src_tmr; @@ -2478,7 +2480,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf) kthread_cancel_delayed_work_sync(&ptp->work); - if (test_bit(ICE_PFR_REQ, pf->state)) + if (reset_type == ICE_RESET_PFR) return; ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); @@ -2498,8 +2500,9 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf) /** * ice_ptp_reset - Initialize PTP hardware clock support after reset * @pf: Board private structure + * @reset_type: the reset type being performed */ -void ice_ptp_reset(struct ice_pf *pf) +void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) { struct ice_ptp *ptp = &pf->ptp; struct ice_hw *hw = &pf->hw; @@ -2509,7 +2512,7 @@ void ice_ptp_reset(struct ice_pf *pf) if (ptp->state != ICE_PTP_RESETTING) { if (ptp->state == ICE_PTP_READY) { - ice_ptp_prepare_for_reset(pf); + ice_ptp_prepare_for_reset(pf, reset_type); } else { err = -EINVAL; dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); @@ -2517,12 +2520,9 @@ void ice_ptp_reset(struct ice_pf *pf) } } - if (test_bit(ICE_PFR_REQ, pf->state)) + if (reset_type == ICE_RESET_PFR || !ice_pf_src_tmr_owned(pf)) goto pfr; - if (!ice_pf_src_tmr_owned(pf)) - goto reset_ts; - err = ice_ptp_init_phc(hw); if (err) goto err; @@ -2566,7 +2566,6 @@ void ice_ptp_reset(struct ice_pf *pf) goto err; } -reset_ts: /* Restart the PHY timestamping block */ ice_ptp_reset_phy_timestamping(pf); diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 674a0abe3cdd..48c0d56c0568 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -311,8 +311,9 @@ enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf); void ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb); -void ice_ptp_reset(struct ice_pf *pf); -void ice_ptp_prepare_for_reset(struct ice_pf *pf); +void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type); +void ice_ptp_prepare_for_reset(struct ice_pf *pf, + enum ice_reset_req reset_type); void ice_ptp_init(struct ice_pf *pf); void ice_ptp_release(struct ice_pf *pf); void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup); @@ -343,8 +344,15 @@ static inline bool ice_ptp_process_ts(struct ice_pf *pf) static inline void ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb) { } -static inline void ice_ptp_reset(struct ice_pf *pf) { } -static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf) { } +static inline void ice_ptp_reset(struct ice_pf *pf, + enum ice_reset_req reset_type) +{ +} + +static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf, + enum ice_reset_req reset_type) +{ +} static inline void ice_ptp_init(struct ice_pf *pf) { } static inline void ice_ptp_release(struct ice_pf *pf) { } static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) From patchwork Tue Aug 22 12:40:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=yg7uK7ed; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVW2Bqcz1yNm for ; Tue, 22 Aug 2023 22:41:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9C7F7607B0; Tue, 22 Aug 2023 12:41:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9C7F7607B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708081; bh=7fLdFQ4WjT1fMsbRscvjZx08Zcn0xYTOKqLWCBMFuQo=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=yg7uK7edv4smzwQq5DoXP1VjphTQH+ZykPvxEDSmWkRXCmD/UVjvKIoJM7UyYbY3v J5xFlVkRsyg7WN6Y8wWb4yWtnPlO3HIlsHF5N6Q0OsKcwZEfisRA12KIdMPCP6Irjr oyqVSJ6tuezCMD/E8yyBvraqe0j4nYKbOJPoAlU7GJDkbHu5v+6Y1+iNGysHVE3WSX k1zaGFMpnsz+iLSR6ah2FCGhDDAkr4o4/iJeEahXo2ECZNc2orQX9cdqi/RaVkLW8+ Q/caL0ttZvo0SnwDeQ2R6vBVBoAvFAMdx9x8swRCcAgxR7n6O+iqNDZVXk0K6zrDHR GSzGglSme0P2g== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SLpv4ozMnroF; Tue, 22 Aug 2023 12:41:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 545A160A91; Tue, 22 Aug 2023 12:41:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 545A160A91 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 29BEA1BF296 for ; Tue, 22 Aug 2023 12:41:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0039A605EC for ; Tue, 22 Aug 2023 12:41:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 0039A605EC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AMTHh4W2VODz for ; Tue, 22 Aug 2023 12:41:07 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id E3E21611B5 for ; Tue, 22 Aug 2023 12:41:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E3E21611B5 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604618" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604618" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342925" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342925" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:04 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:39 +0200 Message-Id: <20230822124044.301654-5-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708066; x=1724244066; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JFFpJFgRP9psjZjtTTIrkkQCboX7wwHwX596ceyvvv4=; b=PS9dFX99Ukoix31A4++S2YqCbqYRq/OLhDcXRdKxm2dzrLKUCWzFQIfi pShgBt/lWminTmeT+K41KO+sZIYFAeM+duVx7HbuWhY3dl5a2/yDiKFnw ifdUYZt1NZvCF9jDxSAx8V7NQ63i6yMd2CDQaoCRc+/UqFgRbHLL4b6s7 lcO5+RNgrbvcEDsDAOu4gdnG5XHMlOUCRmG6BUp6+onYQkNd/2qaoRNp8 QIwtY0iqmk+fBZSRExNAlvUN0ivIm/bDdRvi7k2RcLvysQAOUPCa+B9h9 5EH42AyPlJKLqLQpOkT9hQ+u8o6s0iU5LLLw9PKA8A1UBun8l6ebddCEL w==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=PS9dFX99 Subject: [Intel-wired-lan] [PATCH v3 iwl-next 4/9] ice: rename PTP functions and fields 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The tx->verify_cached flag is used to inform the Tx timestamp tracking code whether it needs to verify the cached Tx timestamp value against a previous captured value. This is necessary on E810 hardware which does not have a Tx timestamp ready bitmap. In addition, we currently rely on the fact that the ice_get_phy_tx_tstamp_ready() function returns all 1s for E810 hardware. Instead of introducing a brand new flag, rename and verify_cached to has_ready_bitmap, inverting the relevant checks. The ice_ptp_tx_cfg_intr() function sends a control queue message to configure the PHY timestamp interrupt block. This is a very similar name to a function which is used to configure the MAC Other Interrupt Cause Enable register. Rename this function to ice_ptp_cfg_phy_interrupt in order to make it more obvious to the reader what action it performs, and distinguish it from other similarly named functions. The ice_ptp_configure_tx_tstamp function writes to PFINT_OICR_ENA to configure it with the PFINT_OICR_TX_TSYN_M bit. The name of this function is confusing because there are multiple other functions with almost identical names. Rename it to ice_ptp_cfg_tx_interrupt in order to make it more obvious to the reader what action it performs. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_ptp.c | 41 +++++++++++++----------- drivers/net/ethernet/intel/ice/ice_ptp.h | 6 +++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index bd94b42e19dd..393156b9b426 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -281,11 +281,11 @@ static const char *ice_ptp_state_str(enum ice_ptp_state state) } /** - * ice_ptp_configure_tx_tstamp - Enable or disable Tx timestamp interrupt - * @pf: The PF pointer to search in + * ice_ptp_cfg_tx_interrupt - Configure Tx timestamp interrupt for the device + * @pf: Board private structure * @on: bool value for whether timestamp interrupt is enabled or disabled */ -static void ice_ptp_configure_tx_tstamp(struct ice_pf *pf, bool on) +static void ice_ptp_cfg_tx_interrupt(struct ice_pf *pf, bool on) { u32 val; @@ -320,7 +320,7 @@ static void ice_set_tx_tstamp(struct ice_pf *pf, bool on) } if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_SELF) - ice_ptp_configure_tx_tstamp(pf, on); + ice_ptp_cfg_tx_interrupt(pf, on); pf->ptp.tstamp_config.tx_type = on ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; } @@ -591,9 +591,11 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) hw = &pf->hw; /* Read the Tx ready status first */ - err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); - if (err) - return; + if (tx->has_ready_bitmap) { + err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); + if (err) + return; + } /* Drop packets if the link went down */ link_up = ptp_port->link_up; @@ -621,7 +623,8 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) * If we do not, the hardware logic for generating a new * interrupt can get stuck on some devices. */ - if (!(tstamp_ready & BIT_ULL(phy_idx))) { + if (tx->has_ready_bitmap && + !(tstamp_ready & BIT_ULL(phy_idx))) { if (drop_ts) goto skip_ts_read; @@ -641,7 +644,7 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) * from the last cached timestamp. If it is not, skip this for * now assuming it hasn't yet been captured by hardware. */ - if (!drop_ts && tx->verify_cached && + if (!drop_ts && !tx->has_ready_bitmap && raw_tstamp == tx->tstamps[idx].cached_tstamp) continue; @@ -651,7 +654,7 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) skip_ts_read: spin_lock(&tx->lock); - if (tx->verify_cached && raw_tstamp) + if (!tx->has_ready_bitmap && raw_tstamp) tx->tstamps[idx].cached_tstamp = raw_tstamp; clear_bit(idx, tx->in_use); skb = tx->tstamps[idx].skb; @@ -895,7 +898,7 @@ ice_ptp_init_tx_e822(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) tx->block = port / ICE_PORTS_PER_QUAD; tx->offset = (port % ICE_PORTS_PER_QUAD) * INDEX_PER_PORT_E822; tx->len = INDEX_PER_PORT_E822; - tx->verify_cached = 0; + tx->has_ready_bitmap = 1; return ice_ptp_alloc_tx_tracker(tx); } @@ -918,7 +921,7 @@ ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx) * verify new timestamps against cached copy of the last read * timestamp. */ - tx->verify_cached = 1; + tx->has_ready_bitmap = 0; return ice_ptp_alloc_tx_tracker(tx); } @@ -1338,14 +1341,14 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) } /** - * ice_ptp_tx_ena_intr - Enable or disable the Tx timestamp interrupt + * ice_ptp_cfg_phy_interrupt - Configure PHY interrupt settings * @pf: PF private structure * @ena: bool value to enable or disable interrupt * @threshold: Minimum number of packets at which intr is triggered * * Utility function to enable or disable Tx timestamp interrupt and threshold */ -static int ice_ptp_tx_ena_intr(struct ice_pf *pf, bool ena, u32 threshold) +static int ice_ptp_cfg_phy_interrupt(struct ice_pf *pf, bool ena, u32 threshold) { struct ice_hw *hw = &pf->hw; int err = 0; @@ -2507,8 +2510,8 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) struct ice_ptp *ptp = &pf->ptp; struct ice_hw *hw = &pf->hw; struct timespec64 ts; - int err, itr = 1; u64 time_diff; + int err; if (ptp->state != ICE_PTP_RESETTING) { if (ptp->state == ICE_PTP_READY) { @@ -2561,7 +2564,7 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) if (!ice_is_e810(hw)) { /* Enable quad interrupts */ - err = ice_ptp_tx_ena_intr(pf, true, itr); + err = ice_ptp_cfg_phy_interrupt(pf, true, 1); if (err) goto err; } @@ -2847,13 +2850,13 @@ static int ice_ptp_init_owner(struct ice_pf *pf) /* The clock owner for this device type handles the timestamp * interrupt for all ports. */ - ice_ptp_configure_tx_tstamp(pf, true); + ice_ptp_cfg_tx_interrupt(pf, true); /* React on all quads interrupts for E82x */ wr32(hw, PFINT_TSYN_MSK + (0x4 * hw->pf_id), (u32)0x1f); /* Enable quad interrupts */ - err = ice_ptp_tx_ena_intr(pf, true, itr); + err = ice_ptp_cfg_phy_interrupt(pf, true, itr); if (err) goto err_exit; } @@ -2925,7 +2928,7 @@ static int ice_ptp_init_port(struct ice_pf *pf, struct ice_ptp_port *ptp_port) * neither on own quad nor on others */ if (!ice_ptp_pf_handles_tx_interrupt(pf)) { - ice_ptp_configure_tx_tstamp(pf, false); + ice_ptp_cfg_tx_interrupt(pf, false); wr32(hw, PFINT_TSYN_MSK + (0x4 * hw->pf_id), (u32)0x0); } kthread_init_delayed_work(&ptp_port->ov_work, diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 48c0d56c0568..30ad714a2a21 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -100,7 +100,7 @@ struct ice_perout_channel { * the last timestamp we read for a given index. If the current timestamp * value is the same as the cached value, we assume a new timestamp hasn't * been captured. This avoids reporting stale timestamps to the stack. This is - * only done if the verify_cached flag is set in ice_ptp_tx structure. + * only done if the has_ready_bitmap flag is not set in ice_ptp_tx structure. */ struct ice_tx_tstamp { struct sk_buff *skb; @@ -131,6 +131,9 @@ enum ice_tx_tstamp_work { * @calibrating: if true, the PHY is calibrating the Tx offset. During this * window, timestamps are temporarily disabled. * @verify_cached: if true, verify new timestamp differs from last read value + * @has_ready_bitmap: if true, the hardware has a valid Tx timestamp ready + * bitmap register. If false, fall back to verifying new + * timestamp values against previously cached copy. */ struct ice_ptp_tx { spinlock_t lock; /* lock protecting in_use bitmap */ @@ -143,6 +146,7 @@ struct ice_ptp_tx { u8 init : 1; u8 calibrating : 1; u8 verify_cached : 1; + u8 has_ready_bitmap : 1; }; /* Quad and port information for initializing timestamp blocks */ From patchwork Tue Aug 22 12:40:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sEEDFg9W; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVc0hxJz1yNm for ; Tue, 22 Aug 2023 22:41:28 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 48FFD611C2; Tue, 22 Aug 2023 12:41:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 48FFD611C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708086; bh=mIBe7D5984ZvxyHHPXJXFk/FPBN35UA9FYuKedHNMfE=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=sEEDFg9WpsRMGTcx7CIH51Bypm+GqRuzvwpZUXRtWLGAsgYv80AdR7/Suqvt6hRsq 5tc92UNCcg2/5ygcHEHrU+Rd+LtV2SicImWIZLXTb7SZQIv6GN4FCeW2KtdOVv8vlM Cq5XvWBwxruhgHvXWRvJ3LUzZ4tjd9XH7bIjCAvmR+cUEOVJwUAfEsmL0bjvj5X5mx KojkhhbTRvDXV5dmR4NLFwDzg/IKgWtJlyu64Raop/XEKS8KpBrTGyCnL9Y+uq7oaV 5yxCK9xh28AmMnL2lFXaazqnLSi+c3+aQmOzC8u6TTl4cSmuNITWL3wRIMI2sU5bDw ecYK2Ab8Fz1HA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q-WhzgVE0pBs; Tue, 22 Aug 2023 12:41:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 3724D611C7; Tue, 22 Aug 2023 12:41:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3724D611C7 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 1C79D1BF296 for ; Tue, 22 Aug 2023 12:41:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CFC6B611C0 for ; Tue, 22 Aug 2023 12:41:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CFC6B611C0 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id scrNmY5hzY6h for ; Tue, 22 Aug 2023 12:41:09 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1D8EC611CF for ; Tue, 22 Aug 2023 12:41:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1D8EC611CF X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604623" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604623" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342932" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342932" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:06 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:40 +0200 Message-Id: <20230822124044.301654-6-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708069; x=1724244069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6jGn2rHv15IvqP+2GjrvIDfvySDo4m9ZR/T81mbPz2M=; b=Q1NN9AbdvTIq/DFNGcAT/iJnwDQfa8x0/6LttC6kWd0jyzmu0wR/jMSt /u+vIiNIAWOL2ha+kcCnmVyjB0w/2oVM/G1Ab09nbeI72Say36zcKgUo6 DtI/LER/VrJc6vGp7KjZjjAjjvJMLaOuSezklAkmDWHCp+IHMoK0/Chbe Vkur5Pbghnfwfoxs3zub/xd8bOQVWu00hIfWcCX2Gix3m+VVZ5b6nUGF8 xJrjQiuCfayEqGA4/mMp7LLFvdzr2LmaCM78LPGJEbLEXx+AcXL9l2ME1 lyGT185/GMOu1vis9QP6+IXw/wJozdnngjs4S4v9wKX9SbC0MczR7Itlx g==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Q1NN9Abd Subject: [Intel-wired-lan] [PATCH v3 iwl-next 5/9] ice: factor out ice_ptp_rebuild_owner() 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The ice_ptp_reset() function uses a goto to skip past clock owner operations if performing a PF reset or if the device is not the clock owner. This is a bit confusing. Factor this out into ice_ptp_rebuild_owner() instead. The ice_ptp_reset() function is called by ice_rebuild() to restore PTP functionality after a device reset. Follow the convention set by the ice_main.c file and rename this function to ice_ptp_rebuild(), in the same way that we have ice_prepare_for_reset() and ice_ptp_prepare_for_reset(). Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 60 ++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 6 +-- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index ac6f241d0407..031f91fb2b0d 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7356,7 +7356,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) * fail. */ if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) - ice_ptp_reset(pf, reset_type); + ice_ptp_rebuild(pf, reset_type); if (ice_is_feature_supported(pf, ICE_F_GNSS)) ice_gnss_init(pf); diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 393156b9b426..5cc2d9c48a75 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2486,6 +2486,7 @@ ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) if (reset_type == ICE_RESET_PFR) return; + kthread_cancel_delayed_work_sync(&pf->ptp.port.ov_work); ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx); /* Disable periodic outputs */ @@ -2501,11 +2502,13 @@ ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) } /** - * ice_ptp_reset - Initialize PTP hardware clock support after reset + * ice_ptp_rebuild_owner - Initialize PTP clock owner after reset * @pf: Board private structure - * @reset_type: the reset type being performed + * + * Companion function for ice_ptp_rebuild() which handles tasks that only the + * PTP clock owner instance should perform. */ -void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) +static int ice_ptp_rebuild_owner(struct ice_pf *pf) { struct ice_ptp *ptp = &pf->ptp; struct ice_hw *hw = &pf->hw; @@ -2513,34 +2516,21 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) u64 time_diff; int err; - if (ptp->state != ICE_PTP_RESETTING) { - if (ptp->state == ICE_PTP_READY) { - ice_ptp_prepare_for_reset(pf, reset_type); - } else { - err = -EINVAL; - dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); - goto err; - } - } - - if (reset_type == ICE_RESET_PFR || !ice_pf_src_tmr_owned(pf)) - goto pfr; - err = ice_ptp_init_phc(hw); if (err) - goto err; + return err; /* Acquire the global hardware lock */ if (!ice_ptp_lock(hw)) { err = -EBUSY; - goto err; + return err; } /* Write the increment time value to PHY and LAN */ err = ice_ptp_write_incval(hw, ice_base_incval(pf)); if (err) { ice_ptp_unlock(hw); - goto err; + return err; } /* Write the initial Time value to PHY and LAN using the cached PHC @@ -2556,7 +2546,7 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) err = ice_ptp_write_init(pf, &ts); if (err) { ice_ptp_unlock(hw); - goto err; + return err; } /* Release the global hardware lock */ @@ -2566,13 +2556,37 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) /* Enable quad interrupts */ err = ice_ptp_cfg_phy_interrupt(pf, true, 1); if (err) + return err; + + ice_ptp_restart_all_phy(pf); + } + + return 0; +} + +/** + * ice_ptp_rebuild - Initialize PTP hardware clock support after reset + * @pf: Board private structure + * @reset_type: the reset type being performed + */ +void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) +{ + struct ice_ptp *ptp = &pf->ptp; + int err; + + if (ptp->state != ICE_PTP_RESETTING) { + if (ptp->state == ICE_PTP_READY) { + ice_ptp_prepare_for_reset(pf, reset_type); + } else { + err = -EINVAL; + dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); goto err; + } } - /* Restart the PHY timestamping block */ - ice_ptp_reset_phy_timestamping(pf); + if (ice_pf_src_tmr_owned(pf) && reset_type != ICE_RESET_PFR) + ice_ptp_rebuild_owner(pf); -pfr: /* Init Tx structures */ if (ice_is_e810(&pf->hw)) { err = ice_ptp_init_tx_e810(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 30ad714a2a21..210e2a1b35a5 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -315,7 +315,7 @@ enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf); void ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb); -void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type); +void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type); void ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type); void ice_ptp_init(struct ice_pf *pf); @@ -348,8 +348,8 @@ static inline bool ice_ptp_process_ts(struct ice_pf *pf) static inline void ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb) { } -static inline void ice_ptp_reset(struct ice_pf *pf, - enum ice_reset_req reset_type) +static inline void ice_ptp_rebuild(struct ice_pf *pf, + enum ice_reset_req reset_type) { } From patchwork Tue Aug 22 12:40:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=j7PxuAZQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVh0vZtz1yNm for ; Tue, 22 Aug 2023 22:41:32 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 71274611AF; Tue, 22 Aug 2023 12:41:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 71274611AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708090; bh=6DWY2CNsPBXlsjJOUSSwFybQ8dCQeqEWc/GAnshCfNU=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=j7PxuAZQQXrrUiVJWyXPJLwg/2O7C3LtvoAus9+VB4D/TXHVOn/Z4sU3gHYqncUI8 vFQ6a5HQIvM4uH4QMrzLAPpL5KwBCifDEvLHNCk8QhUtKyU82btfb3rSylPsG8CJHV OkcRp+KBS4IwX0jLrxRj8lCuznZ1iwkIdtSo1c+JK6seoWDO/R+Gdokh+f9qdKG1qN Kc3Zfkfnrzs5QQrnarDfA9dfz5BEiKke7IiF4d5pvlSaXBRpf5i6KZcsyyX1jDHHjF McuIPEBevUKcurGvZHhvQ3TMDgdGKwNMoFCz5KvGUXzlAK7wzg/86GTM38VpF8OB/V JRUB6sSyZiRRA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YxKt0JXQT1gQ; Tue, 22 Aug 2023 12:41:29 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 7672F611B7; Tue, 22 Aug 2023 12:41:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7672F611B7 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id B37A31BF296 for ; Tue, 22 Aug 2023 12:41:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7A378611D1 for ; Tue, 22 Aug 2023 12:41:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7A378611D1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iVFFAB0KWpBA for ; Tue, 22 Aug 2023 12:41:11 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id 772D0611D6 for ; Tue, 22 Aug 2023 12:41:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 772D0611D6 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604631" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604631" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342945" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342945" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:08 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:41 +0200 Message-Id: <20230822124044.301654-7-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708071; x=1724244071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VxvF5hcsmxvINUDrvwX0Eb148/6H6vNqYi2BtRrPhVU=; b=IXH3r7xbA9XFDrk6lWQlPjH4fdnksh4JjHk4ZVlNQr/iQHGTxgqpEwGB h4HRiwpSaLUaIPh2eVVyUTlL8PoTfsHfuKqfCQWOqCx7vxEmKjFGjzAaE 70oNeZdQl/iWpBrwJc51JwO0q2UXwTdFSivDzPxVnLcKtRn6ERf64g6nL bIN63kCmotRlzWSxjH9iILgwzwL2wDlrjep01hqXGFNsUwiJykixcthTH KZBC+pDnVaBa1Mrz7VBHT0OSyRl/XHUry7pfXLow/sthmPFw7BfZZJyBM PeRTP/H8EvaC58uSwCsGauuULlkHNMaGb3lygjDWmRM7XNh2gHtSyEPmI g==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IXH3r7xb Subject: [Intel-wired-lan] [PATCH v3 iwl-next 6/9] ice: remove ptp_tx ring parameter flag 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Before performing a Tx timestamp in ice_stamp(), the driver checks a ptp_tx ring variable to see if timestamping is enabled on that ring. This value is set for all rings whenever userspace configures Tx timestamping. Ostensibly this was done to avoid wasting cycles checking other fields when timestamping has not been enabled. However, for Tx timestamps we already get an individual per-SKB flag indicating whether userspace wants to request a timestamp on that packet. We do not gain much by also having a separate flag to check for whether timestamping was enabled. In fact, the driver currently fails to restore the field after a PF reset. Because of this, if a PF reset occurs, timestamps will be disabled. Since this flag doesn't add value in the hotpath, remove it and always provide a timestamp if the SKB flag has been set. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_ptp.c | 14 -------------- drivers/net/ethernet/intel/ice/ice_txrx.c | 3 --- drivers/net/ethernet/intel/ice/ice_txrx.h | 1 - 3 files changed, 18 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 5cc2d9c48a75..120d47356830 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -305,20 +305,6 @@ static void ice_ptp_cfg_tx_interrupt(struct ice_pf *pf, bool on) */ static void ice_set_tx_tstamp(struct ice_pf *pf, bool on) { - struct ice_vsi *vsi; - u16 i; - - vsi = ice_get_main_vsi(pf); - if (!vsi) - return; - - /* Set the timestamp enable flag for all the Tx rings */ - ice_for_each_txq(vsi, i) { - if (!vsi->tx_rings[i]) - continue; - vsi->tx_rings[i]->ptp_tx = on; - } - if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_SELF) ice_ptp_cfg_tx_interrupt(pf, on); diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c index 52d0a126eb61..9e97ea863068 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c @@ -2306,9 +2306,6 @@ ice_tstamp(struct ice_tx_ring *tx_ring, struct sk_buff *skb, if (likely(!(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))) return; - if (!tx_ring->ptp_tx) - return; - /* Tx timestamps cannot be sampled when doing TSO */ if (first->tx_flags & ICE_TX_FLAGS_TSO) return; diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h b/drivers/net/ethernet/intel/ice/ice_txrx.h index 166413fc33f4..daf7b9dbb143 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx.h +++ b/drivers/net/ethernet/intel/ice/ice_txrx.h @@ -380,7 +380,6 @@ struct ice_tx_ring { #define ICE_TX_FLAGS_RING_VLAN_L2TAG2 BIT(2) u8 flags; u8 dcb_tc; /* Traffic class of ring */ - u8 ptp_tx; } ____cacheline_internodealigned_in_smp; static inline bool ice_ring_uses_build_skb(struct ice_rx_ring *ring) From patchwork Tue Aug 22 12:40:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=GVnCtuYQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVm1zmcz1yg4 for ; Tue, 22 Aug 2023 22:41:36 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8859660A91; Tue, 22 Aug 2023 12:41:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8859660A91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708094; bh=sLZJYsFm0qTvDRtpuLncgQDHTtbmxUOKO0L6vHH6W4Q=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=GVnCtuYQCjY0Bs8TO0aTH2EOYknU8B5JWWDkjylWgXWmsg0+mgxGLuXNfC4lSdKZf oQKqaJ9Y89eskQ6Qmd7NZBDWMpK1n2T9tV2bPpVJC2R1EuI62lXAyEtl3ffKBdOYsx lusQPqm2jSLl+4sVnuXeSp3m4UCOrkHgApGFeV6o/SPrjWF1ZQdv1w4GAr7jZNyHiR zEY1q7eHiGMVyjMvIOybxzmzCE9cMvsyCVpdKhgqCZsR1hbVadtaALXYSKpr/HOWTH WU2Hqm+5xROeHDGcSyP7VIs6XDoZEJ4OAs7OoR+62XU3DZEAXS0mk3yCWc02j2gDmI jibPiTnP381bw== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BWR6Rlez3olx; Tue, 22 Aug 2023 12:41:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 8480B611B7; Tue, 22 Aug 2023 12:41:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8480B611B7 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 80EE31BF296 for ; Tue, 22 Aug 2023 12:41:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 66A83611F3 for ; Tue, 22 Aug 2023 12:41:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 66A83611F3 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TGvGEEm_r4Xc for ; Tue, 22 Aug 2023 12:41:13 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id 947AE611E4 for ; Tue, 22 Aug 2023 12:41:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 947AE611E4 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604636" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604636" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342962" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342962" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:11 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:42 +0200 Message-Id: <20230822124044.301654-8-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708073; x=1724244073; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bYKUU/xj0QxXFQ63kzSKlbFuP+Ql4C41o4hOcu7twBo=; b=MAJrhH5wy8Rse0F3ebxH/C+tGcFKLqmJpqpF/dYqLaiGabPraN1aPA48 pr3lURWwP95xyQep9Ckk8f0foT2l920kDJwxfCV+VP1Z6xA/I5g66E739 ifq6tQuj/Brh/I12KzQXozuBNwyYBDJH9enCCmPXlAKgNQQTbGxJbNtpd Z+lGuOybuTPsVSEybHBv5UKCdrC7y3W5MAbRCYfL1YiDNUoGxHnpK49ck C2IAtJivZSGYL2Kr+9RRX9F0SJsbKV1/lVawJTtQzR+T3m6zNJO7Juj7t vqocXyErQwXWojbf8pHkC2nG35hpD/crjd83K13vGjJHjOZfY6OPh20na A==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=MAJrhH5w Subject: [Intel-wired-lan] [PATCH v3 iwl-next 7/9] ice: modify tstamp_config only during TS mode set 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The driver stores the current Tx and Rx timestamping configuration in pf->ptp.tstamp_config. This structure is supposed to represent the currently requested configuration from userspace that we've applied to the device. The values of this structure are modified within the low level ice_set_tx_tstamp() and ice_set_rx_tstamp() functions. These functions *are* called by ice_ptp_set_timestamp_mode. However, they are also called during the driver reset and rebuild flow. Because of this, the driver overwrites user configuration during reset, preventing itself from being able to properly restore the configuration after a reset. Instead, stop modifying this saved configuration state outside of ice_ptp_set_timestamp_mode. Instead, set the values directly within this function. This avoids losing the configuration data. A following change will refactor the rebuild flow to properly restore the configuration after a PF reset. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_ptp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 120d47356830..dac77bff4d20 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -307,8 +307,6 @@ static void ice_set_tx_tstamp(struct ice_pf *pf, bool on) { if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_SELF) ice_ptp_cfg_tx_interrupt(pf, on); - - pf->ptp.tstamp_config.tx_type = on ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; } /** @@ -331,9 +329,6 @@ static void ice_set_rx_tstamp(struct ice_pf *pf, bool on) continue; vsi->rx_rings[i]->ptp_rx = on; } - - pf->ptp.tstamp_config.rx_filter = on ? HWTSTAMP_FILTER_ALL : - HWTSTAMP_FILTER_NONE; } /** @@ -2054,9 +2049,11 @@ ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) switch (config->tx_type) { case HWTSTAMP_TX_OFF: ice_set_tx_tstamp(pf, false); + pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; break; case HWTSTAMP_TX_ON: ice_set_tx_tstamp(pf, true); + pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; break; default: return -ERANGE; @@ -2065,6 +2062,7 @@ ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) switch (config->rx_filter) { case HWTSTAMP_FILTER_NONE: ice_set_rx_tstamp(pf, false); + pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE; break; case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: @@ -2081,6 +2079,7 @@ ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) case HWTSTAMP_FILTER_NTP_ALL: case HWTSTAMP_FILTER_ALL: ice_set_rx_tstamp(pf, true); + pf->ptp.tstamp_config.rx_filter = HWTSTAMP_FILTER_ALL; break; default: return -ERANGE; From patchwork Tue Aug 22 12:40:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=NrWeDTVI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVr5X6tz1yNm for ; Tue, 22 Aug 2023 22:41:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0B17B611B4; Tue, 22 Aug 2023 12:41:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 0B17B611B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708099; bh=CMnfXx8MIXL00QAzLQ8EFdylXGcxpN5Fio8N1lPpV5I=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=NrWeDTVIjcq8AzYvmQCu49Zk58/VXQP/PejshKaRVd76qEezEcl8ia+9tS3z9twfS BzXRH/w/szVcSLIEZrB1TtAMamxjsTxAItj5GvExdg/ZN/g7hs4o+fZNQLk30sydlX xKKWsVmsMrcyvP/Jfol+rIrjt6nwZtorNgvyOgDdRX0CNF5N4H+7Hp9vLkrH2lnPhB MGNv+bJRxmTPFK4e89nqSa9uTL4d5swC9PnWNfIVpSaLvNwJ0hTaZj4zXVrUAar5Jx SkoQwHSf3dzFttsoXH3cbpkRyC7Et8zkQGc62h3LHJ8nPVzWJcTRJUmZ0/BCwo1h9I akuSiVoxrSX2A== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NY8chTDWnp4T; Tue, 22 Aug 2023 12:41:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id D864E611C2; Tue, 22 Aug 2023 12:41:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D864E611C2 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id C1C3A1BF296 for ; Tue, 22 Aug 2023 12:41:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9B79960A91 for ; Tue, 22 Aug 2023 12:41:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9B79960A91 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eY3h27huUv6v for ; Tue, 22 Aug 2023 12:41:15 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id BA077611C8 for ; Tue, 22 Aug 2023 12:41:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org BA077611C8 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604644" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604644" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342977" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342977" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:13 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:43 +0200 Message-Id: <20230822124044.301654-9-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708075; x=1724244075; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wK8+5s8HXiTpD21pZhyS/8qlqAPmuFQMhZK+S0BCl+Q=; b=L3QI1aGyyfy10HgBWUvrP04DvDvtdHv4b0yhPV5U/7kd5I9RUHXEPqZ/ r1tu1Z2wDodvfiGX28LVxNt6EoFm+XJ79wU6WwB0kAQkI/EV9v91oPR3D ANhcWregnvg5qM9QnjkXA7qw1+Eu6Ocv3W5/cRCmVFbN/1KgUYlgq9Wps GHr7DP8rUpGWM1R6YOwe74YU3AJyo5nAdi/nGrU4/xYfviZazmiOFBJWQ wOTj3ElRyk+AKY22lGwr84h1hzNQRY/uqQ7EfT6aKTm1IX6SATIF9YU+l YIcHI5914q4pihRzRL7AzE/BFJWRi7aBh/tpeWlcip3cgI0lwLUewXgQK g==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=L3QI1aGy Subject: [Intel-wired-lan] [PATCH v3 iwl-next 8/9] ice: restore timestamp configuration after reset 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The driver calls ice_ptp_cfg_timestamp() during ice_ptp_prepare_for_reset() to disable timestamping while the device is resetting. It then attempts to restore timestamp configuration at the end of ice_rebuild(). However, it currently forcibly calls ice_ptp_cfg_timestamp() with a value of true when the device is not E810 and is the clock owner, while calling ice_ptp_cfg_timestamp() with a value of false for all other devices. This incorrectly forcibly disables timestamping on all ports except the clock owner. This was not detected previously due to a quirk of the LinuxPTP ptp4l application. If ptp4l detects a missing timestamp, it enters a fault state and performs recovery logic which includes executing SIOCSHWTSTAMP again, restoring the now accidentally cleared configuration. Not every application does this, and for these applications, timestamps will mysteriously stop after a PF reset, without being restored until an application restart. Fix this by replacing ice_ptp_cfg_timestamp() with two new functions: 1) ice_ptp_disable_timestamp_mode() which unconditionally disables the timestamping logic in ice_ptp_prepare_for_reset() and ice_ptp_release() 2) ice_ptp_restore_timestamp_mode() which calls ice_ptp_restore_tx_interrupt() to restore Tx timestamping configuration, calls ice_set_rx_tstamp() to restore Rx timestamping configuration, and issues an immediate TSYN_TX interrupt to ensure that timestamps which may have occurred during the device reset get processed. This obsoletes the ice_set_tx_tstamp() function which can now be safely removed. With this change, all devices should now restore Tx and Rx timestamping functionality correctly after a PF reset without application intervention. Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_main.c | 10 +--- drivers/net/ethernet/intel/ice/ice_ptp.c | 72 +++++++++++++++++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 4 +- 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 031f91fb2b0d..06b348f5dadb 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7368,14 +7368,8 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err_vsi_rebuild; } - /* configure PTP timestamping after VSI rebuild */ - if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) { - if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_SELF) - ice_ptp_cfg_timestamp(pf, false); - else if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_ALL) - /* for E82x PHC owner always need to have interrupts */ - ice_ptp_cfg_timestamp(pf, true); - } + /* Restore timestamp mode settings after VSI rebuild */ + ice_ptp_restore_timestamp_mode(pf); err = ice_vsi_rebuild_by_type(pf, ICE_VSI_SWITCHDEV_CTRL); if (err) { diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index dac77bff4d20..8f783004f4a9 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -299,14 +299,27 @@ static void ice_ptp_cfg_tx_interrupt(struct ice_pf *pf, bool on) } /** - * ice_set_tx_tstamp - Enable or disable Tx timestamping - * @pf: The PF pointer to search in - * @on: bool value for whether timestamps are enabled or disabled + * ice_ptp_restore_tx_interrupt - Restore Tx timestamp interrupt after reset + * @pf: Board private structure */ -static void ice_set_tx_tstamp(struct ice_pf *pf, bool on) +static void ice_ptp_restore_tx_interrupt(struct ice_pf *pf) { - if (pf->ptp.tx_interrupt_mode == ICE_PTP_TX_INTERRUPT_SELF) - ice_ptp_cfg_tx_interrupt(pf, on); + bool enable; + + switch (pf->ptp.tx_interrupt_mode) { + case ICE_PTP_TX_INTERRUPT_ALL: + enable = true; + break; + case ICE_PTP_TX_INTERRUPT_NONE: + enable = false; + break; + case ICE_PTP_TX_INTERRUPT_SELF: + default: + enable = pf->ptp.tstamp_config.tx_type == HWTSTAMP_TX_ON; + break; + } + + ice_ptp_cfg_tx_interrupt(pf, enable); } /** @@ -332,17 +345,41 @@ static void ice_set_rx_tstamp(struct ice_pf *pf, bool on) } /** - * ice_ptp_cfg_timestamp - Configure timestamp for init/deinit + * ice_ptp_disable_timestamp_mode - Disable current timestamp mode * @pf: Board private structure - * @ena: bool value to enable or disable time stamp * - * This function will configure timestamping during PTP initialization - * and deinitialization + * Called during preparation for reset to temporarily disable timestamping on + * the device. Called during remove to disable timestamping while cleaning up + * driver resources. */ -void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena) +static void ice_ptp_disable_timestamp_mode(struct ice_pf *pf) { - ice_set_tx_tstamp(pf, ena); - ice_set_rx_tstamp(pf, ena); + ice_ptp_cfg_tx_interrupt(pf, false); + ice_set_rx_tstamp(pf, false); +} + +/** + * ice_ptp_restore_timestamp_mode - Restore timestamp configuration + * @pf: Board private structure + * + * Called at the end of rebuild to restore timestamp configuration after + * a device reset. + */ +void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) +{ + struct ice_hw *hw = &pf->hw; + bool enable_rx; + + ice_ptp_restore_tx_interrupt(pf); + + enable_rx = pf->ptp.tstamp_config.rx_filter == HWTSTAMP_FILTER_ALL; + ice_set_rx_tstamp(pf, enable_rx); + + /* Trigger an immediate software interrupt to ensure that timestamps + * which occurred during reset are handled now. + */ + wr32(hw, PFINT_OICR, PFINT_OICR_TSYN_TX_M); + ice_flush(hw); } /** @@ -2048,11 +2085,9 @@ ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) { switch (config->tx_type) { case HWTSTAMP_TX_OFF: - ice_set_tx_tstamp(pf, false); pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_OFF; break; case HWTSTAMP_TX_ON: - ice_set_tx_tstamp(pf, true); pf->ptp.tstamp_config.tx_type = HWTSTAMP_TX_ON; break; default: @@ -2085,6 +2120,9 @@ ice_ptp_set_timestamp_mode(struct ice_pf *pf, struct hwtstamp_config *config) return -ERANGE; } + /* Make sure interrupt settings are restored */ + ice_ptp_restore_tx_interrupt(pf); + return 0; } @@ -2464,7 +2502,7 @@ ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) ptp->state = ICE_PTP_RESETTING; /* Disable timestamping for both Tx and Rx */ - ice_ptp_cfg_timestamp(pf, false); + ice_ptp_disable_timestamp_mode(pf); kthread_cancel_delayed_work_sync(&ptp->work); @@ -3117,7 +3155,7 @@ void ice_ptp_release(struct ice_pf *pf) pf->ptp.state = ICE_PTP_UNINIT; /* Disable timestamping for both Tx and Rx */ - ice_ptp_cfg_timestamp(pf, false); + ice_ptp_disable_timestamp_mode(pf); ice_ptp_remove_auxbus_device(pf); diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 210e2a1b35a5..bd5826ba3576 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -306,7 +306,7 @@ int ice_ptp_clock_index(struct ice_pf *pf); struct ice_pf; int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr); int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr); -void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena); +void ice_ptp_restore_timestamp_mode(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); @@ -332,7 +332,7 @@ static inline int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr) return -EOPNOTSUPP; } -static inline void ice_ptp_cfg_timestamp(struct ice_pf *pf, bool ena) { } +static inline void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) { } static inline void ice_ptp_extts_event(struct ice_pf *pf) { } static inline s8 From patchwork Tue Aug 22 12:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1824177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=6EUbbIyW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVTVx23cmz1yNm for ; Tue, 22 Aug 2023 22:41:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9C120611B5; Tue, 22 Aug 2023 12:41:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9C120611B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1692708103; bh=xk2lINUJ2xGk6fEzBnbYfgE5iemYk7lhW6gn+H92HTY=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=6EUbbIyWQ2P9PzxUWQwvM6xOEfbZEGKXdadZkZHK59T6EXkigO4cEGh8ObjKWZS+D qoFjadsnh8Rcu1f5FNeCVRMlD6O/+LJxSpJ1MyeZWiEQ4+0WDdigQhbvCOkS3te/uE 0TAg60vWyLT/N8G79+rndUIIbRdNDtwi88+V111CnR+ixXGV3EUWQySlXfGYNpHdR/ bumYudCMpaFvJyZMh2MwjRzonZ2zxix7eH3jTDhw2caydHupv1LxLKTJJBg0FykS+2 jyxgotDjRJLobBAnzjiNcDXUZrBtXuq3ImyDJyUgyoa3e4OzU9HMCHK9JMdEFkjCxi Yl9IXEQXMQ6Kg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eJYaoJ_8SQ5x; Tue, 22 Aug 2023 12:41:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id A2AC9611D2; Tue, 22 Aug 2023 12:41:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A2AC9611D2 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id E87DA1BF296 for ; Tue, 22 Aug 2023 12:41:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C17FE605EC for ; Tue, 22 Aug 2023 12:41:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C17FE605EC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EXFl-JBJNmqH for ; Tue, 22 Aug 2023 12:41:18 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by smtp3.osuosl.org (Postfix) with ESMTPS id 13B9360A91 for ; Tue, 22 Aug 2023 12:41:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 13B9360A91 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="376604654" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="376604654" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2023 05:41:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="771342982" X-IronPort-AV: E=Sophos;i="6.01,193,1684825200"; d="scan'208";a="771342982" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by orsmga001.jf.intel.com with ESMTP; 22 Aug 2023 05:41:15 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Tue, 22 Aug 2023 14:40:44 +0200 Message-Id: <20230822124044.301654-10-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124044.301654-1-karol.kolacinski@intel.com> References: <20230822124044.301654-1-karol.kolacinski@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 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=1692708078; x=1724244078; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nALQDjsAlhoRh/Kh6FVQIIifz0q70NovGLmQUl5KAsI=; b=cA+SqnGJ3mN0NFAysc2RlCaW60T3F1DHaukAjar6eBu0Ujkszb8cuZVY 31L8Thtl67lRiy1mhN2uELz7mzlOTE/LQpJ8QmybyPrxOw8TV+viou6jb /ZrTs+qtvrx4acED1rQZKV1abYBCdiHWG7VOUvpyx5nq71GsGN3FIePPU CEAewdBO9BINamF7b0IgnO6u6fhob+eaANvS7sQgcE3+naLj6qmLvZI3o /e+OlG2YDksYAdcBRg2vp7268ZahmcXPWGROMM5ft1cwWb6JhbiB4x0lI 0Vx4N5ye7lbDzLLdIHlhxtgRzOr6XD0qI5bBW2DCE+sjfAx7ge85vw+oU w==; X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cA+SqnGJ Subject: [Intel-wired-lan] [PATCH v3 iwl-next 9/9] ice: stop destroying and reinitalizing Tx tracker during reset 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: netdev@vger.kernel.org, Karol Kolacinski , anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller The ice driver currently attempts to destroy and re-initialize the Tx timestamp tracker during the reset flow. The release of the Tx tracker only happened during CORE reset or GLOBAL reset. The ice_ptp_rebuild() function always calls the ice_ptp_init_tx function which will allocate a new tracker data structure, resulting in memory leaks during PF reset. Certainly the driver should not be allocating a new tracker without removing the old tracker data, as this results in a memory leak. Additionally, there's no reason to remove the tracker memory during a reset. Remove this logic from the reset and rebuild flow. Instead of releasing the Tx tracker, flush outstanding timestamps just before we reset the PHY timestamp block in ice_ptp_cfg_phy_interrupt(). Signed-off-by: Jacob Keller Signed-off-by: Karol Kolacinski --- drivers/net/ethernet/intel/ice/ice_ptp.c | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 8f783004f4a9..5c8f3dda64b9 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -868,6 +868,22 @@ ice_ptp_mark_tx_tracker_stale(struct ice_ptp_tx *tx) spin_unlock(&tx->lock); } +/** + * ice_ptp_flush_all_tx_tracker - Flush all timestamp trackers on this clock + * @pf: Board private structure + * + * Called by the clock owner to flush all the Tx timestamp trackers associated + * with the clock. + */ +static void +ice_ptp_flush_all_tx_tracker(struct ice_pf *pf) +{ + struct ice_ptp_port *port; + + list_for_each_entry(port, &pf->ptp.ports_owner.ports, list_member) + ice_ptp_flush_tx_tracker(ptp_port_to_pf(port), &port->tx); +} + /** * ice_ptp_release_tx_tracker - Release allocated memory for Tx tracker * @pf: Board private structure @@ -2575,6 +2591,11 @@ static int ice_ptp_rebuild_owner(struct ice_pf *pf) /* Release the global hardware lock */ ice_ptp_unlock(hw); + /* Flush software tracking of any outstanding timestamps since we're + * about to flush the PHY timestamp block. + */ + ice_ptp_flush_all_tx_tracker(pf); + if (!ice_is_e810(hw)) { /* Enable quad interrupts */ err = ice_ptp_cfg_phy_interrupt(pf, true, 1); @@ -2610,18 +2631,6 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) if (ice_pf_src_tmr_owned(pf) && reset_type != ICE_RESET_PFR) ice_ptp_rebuild_owner(pf); - /* Init Tx structures */ - if (ice_is_e810(&pf->hw)) { - err = ice_ptp_init_tx_e810(pf, &ptp->port.tx); - } else { - kthread_init_delayed_work(&ptp->port.ov_work, - ice_ptp_wait_for_offsets); - err = ice_ptp_init_tx_e822(pf, &ptp->port.tx, - ptp->port.port_num); - } - if (err) - goto err; - ptp->state = ICE_PTP_READY; /* Start periodic work going */