From patchwork Wed Oct 25 12:13:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Kolacinski X-Patchwork-Id: 1855034 X-Patchwork-Delegate: anthony.l.nguyen@intel.com 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=w9P3zThd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 4SFnwv1ZVVz23jh for ; Wed, 25 Oct 2023 23:17:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 78D1443637; Wed, 25 Oct 2023 12:17:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 78D1443637 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1698236221; bh=kuT2/8Tbco11P6aUxvFpSF+33b/tGgwc5RV6ccFUzAA=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=w9P3zThdVgcj0ig9yJEXoepUbfYIMpFD2f+yqRKHspEgTpeIU6KuG4Gik7CpCdVo6 mUwMZjo8Q7UDIo9+lPFy2XG6xFD4gYYbXMooES9qAlyhzAMiH2zyc6LS1BhzOXVLMv JRRMcPm7/aGuNiRvGKLFnp1D+5Wz63PvMsGYECC9thVhLtg6SMzX1Z2fuZxaVwpGOs bIFOREutKPn330poKGDPUZPM1Jew+6CdmUpCym1817mwMhd8aUpkwdOP4ysRkVTP23 +Hj9zmIm9WZIOl3kitdxyq7zSwriX+UaJoN5Dt4plHAXHjpnTZ/VmwToy5EvpKxLqC 36kMr7ak9cGWg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lI-obQLkbLMg; Wed, 25 Oct 2023 12:17:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 3898B4362F; Wed, 25 Oct 2023 12:17:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3898B4362F X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 8CF041BF48B for ; Wed, 25 Oct 2023 12:16:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7302D84CD1 for ; Wed, 25 Oct 2023 12:16:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7302D84CD1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kgIj1zZIR5um for ; Wed, 25 Oct 2023 12:16:16 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by smtp1.osuosl.org (Postfix) with ESMTPS id B286284988 for ; Wed, 25 Oct 2023 12:16:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B286284988 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="418414376" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="418414376" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 05:16:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="824627941" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="824627941" Received: from kkolacin-desk1.igk.intel.com ([10.102.102.152]) by fmsmga008.fm.intel.com with ESMTP; 25 Oct 2023 05:16:14 -0700 From: Karol Kolacinski To: intel-wired-lan@lists.osuosl.org Date: Wed, 25 Oct 2023 14:13:30 +0200 Message-Id: <20231025121330.216300-11-karol.kolacinski@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231025121330.216300-1-karol.kolacinski@intel.com> References: <20231025121330.216300-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=1698236176; x=1729772176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f+mIIuAIUjoCTbKJ2S6y5jqIuddHyb98ZIKxlezDS7Y=; b=hIakP6pAnMbffzgrMuC3lhT8Gl1grEQWgezv4Epm/74JqgbIg//uVXTe Ev5Dp72GEQpdSYO6TEVPjwTEjxRFJ3u3i2CBwNQbZ39zgrlvdKbMUE+qg 5BC4tt2gAQBAXPJqs68Xm3LQ9ljFaees456ip33RSBTJ/sr7wKaN9GbfP k/taTMFHWqPPeQs3EUuxGkQo7h8FkzBXb3vFeSXadjB19XqWldw6XfL+C 2/n2JNLMSQca4w6Lp6ygjSWFBHRcwImL65keTquAkJheaAkikWnr+n1B2 eZSfRPV0zoW/w9RDEAJY5kZydAYPyYCcU9XCfuVGaoJ9XnYrjT9YzgfCD w==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=hIakP6pA Subject: [Intel-wired-lan] [PATCH iwl-next 10/10] 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: Jacob Keller , 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 Reviewed-by: Jacob Keller --- 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 fead06c60905..5fb9dbbdfc16 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -845,6 +845,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 @@ -2548,6 +2564,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); @@ -2586,18 +2607,6 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err; } - /* 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 */