From patchwork Mon Jan 24 09:59:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Athari Bin Ismail X-Patchwork-Id: 12721842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8462C433EF for ; Mon, 24 Jan 2022 10:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3BivVhkC7mOasfpy3zfXhklriF4YMIHPZ7ERVD8DDpg=; b=ies9J9bXHXxeTe CmE05w1hjAaYsEao9/xAXOeBE3qZF2OFKbjT8ObOMAnV/0flMH39QQfTerdrpI6EQmz5yyvB2Q3km 1xdNRO/U1JjCLsgLA3Inb7GdOBOzJ4rcy9kzNwvlH9kSBcud37DF8xGVF3a06P/c+3Xz12mhF9jEN TkRe/Tk3+1iMnISwcHWgbbclW5XL2tBs86wokWa68HrG3Wh3ZW3KDU8ueVfzM8yq+X4tFV3e4/Vdz qzNQ0HXXEjODH23k+yVghH3QS2cOaYZtoAvzk2lmfSt2eMk2WBoxcUAa6fiqzHbaB8/77SG+Nhif7 0N46pVdBlUYPAoaSrCgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBw9g-002tC9-Dp; Mon, 24 Jan 2022 10:00:56 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBw9T-002t8e-Rz for linux-arm-kernel@lists.infradead.org; Mon, 24 Jan 2022 10:00:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643018443; x=1674554443; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Tz1WJ/YY3EwQM6gWrJzFBZDFZsZ1MNsURDEDEz1XInA=; b=Tt/maD7kFD8rzO29BXWvY+n+9FM57q/kVadd9QR/b8zGklLJGMJ2eQUS R+wTpVJTxwGkRpJ4GyeW8c/Usu4vbQc0yQzv01/mKr94BC0Z+na6R+awc DRTxgVR/kRr2DWa+TNj1h75yHF+QWUTcCC1vLVhoQfghNF42zeRh0ZGMY BZ8+QW0ZowKereSjc3g4e1UCxZpjrKiy7fvDty+vsHY9G482VPGygbPDK yncIjymCUT0OOjjfpvl8x5xMgQ0KruUhWtq3tkfQDkIfuj97OtS4ReqFi qMpFhDHHhPO6adjei0bbaHO7D/eQL1JWPPa2eVrxofk3VmUaEqT8+AUzz Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="233370284" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="233370284" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 02:00:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="519886948" Received: from mismail5-ilbpg0.png.intel.com ([10.88.229.13]) by orsmga007.jf.intel.com with ESMTP; 24 Jan 2022 02:00:40 -0800 From: Mohammad Athari Bin Ismail To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Ong Boon Leong , Voon Weifeng , Wong Vee Khee , Huacai Chen Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mohammad.athari.ismail@intel.com Subject: [PATCH net 1/2] net: stmmac: configure PTP clock source prior to PTP initialization Date: Mon, 24 Jan 2022 17:59:50 +0800 Message-Id: <20220124095951.23845-2-mohammad.athari.ismail@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124095951.23845-1-mohammad.athari.ismail@intel.com> References: <20220124095951.23845-1-mohammad.athari.ismail@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_020043_974141_822329FF X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For Intel platform, it is required to configure PTP clock source prior PTP initialization in MAC. So, need to move ptp_clk_freq_config execution from stmmac_ptp_register() to stmmac_init_ptp(). Fixes: 76da35dc99af ("stmmac: intel: Add PSE and PCH PTP clock source selection") Cc: # 5.15.x Signed-off-by: Mohammad Athari Bin Ismail --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 6708ca2aa4f7..d7e261768f73 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -889,6 +889,9 @@ static int stmmac_init_ptp(struct stmmac_priv *priv) bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; int ret; + if (priv->plat->ptp_clk_freq_config) + priv->plat->ptp_clk_freq_config(priv); + ret = stmmac_init_tstamp_counter(priv, STMMAC_HWTS_ACTIVE); if (ret) return ret; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index 0d24ebd37873..1c9f02f9c317 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -297,9 +297,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv) { int i; - if (priv->plat->ptp_clk_freq_config) - priv->plat->ptp_clk_freq_config(priv); - for (i = 0; i < priv->dma_cap.pps_out_num; i++) { if (i >= STMMAC_PPS_MAX) break; From patchwork Mon Jan 24 09:59:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Athari Bin Ismail X-Patchwork-Id: 12721843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBEF5C433F5 for ; Mon, 24 Jan 2022 10:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2wbUSNQxVP6vJqSL57afc/QOXl27xMY7hj/Ovp4PhJY=; b=x9MCPqdtqXTG4b cRXNGkaIZMePfVzZP97PXMrrmhRBP6puJddBiy0WFufvkdnydAdnD90aNbH/6U7Ptqju4mhPyq4FM FcHWtaG/4JwXNY6Re7fllHqzhaxth5wjhewGNqYYofN1JxAELeXAchVqlIiHOdN+fwkK8uGaY/qPV yXE/pd+6hcgt9Uy4ZsAI/CxjTG+orJLHOohD/q7e3RMgh4z8jtwEDytDc5euPE5c8H6ukD/c/Qs7C Re+t50kTcgWZAlwMhjqXktM/1++2ajKuOjbBGU8fdGIaQ34nYxMCfrXNPEHHVTEPeMOQEcKFpMIgX 623nAC4Ot586bDP0iRZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBw9p-002tF6-TW; Mon, 24 Jan 2022 10:01:06 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBw9X-002t8e-R3 for linux-arm-kernel@lists.infradead.org; Mon, 24 Jan 2022 10:00:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643018447; x=1674554447; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=fcP5Mi3E+ddUCuSeWk/h23NjNWIPP76BCXW3Nop8uuI=; b=MdEK5zcULVYibo9ff5fygzkppYsXwK/+9FPjL8RHksHS61CJIerq4/se 5WcxMkN2Z5F+YHcvVK07/qPnqY6L1xbQlQuzOj4Qqsr7rD/sGlZ3r1R4J S5qtNanvvqqIJm/PW8S3n9uKywluaVEegm5hT2mpoQL9jox9jhLXQzvDR WyLzFBeWyJHlJkAFaCF6+jj1VwCjsOrxWgbmPJqvYDHTzJCyVPY1iRHcC aIGgCeczUQcKOyHCHN1aUvUs1i0FeeZLkGsNyvLwxGIgEIBTd7k+mqxQp 1oE35X9sHpkZWCD7H9Zx0YPJFxf7+5VvumTEfrVFrqi2rf3LplHONOT/S A==; X-IronPort-AV: E=McAfee;i="6200,9189,10236"; a="233370304" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="233370304" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 02:00:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="519886979" Received: from mismail5-ilbpg0.png.intel.com ([10.88.229.13]) by orsmga007.jf.intel.com with ESMTP; 24 Jan 2022 02:00:43 -0800 From: Mohammad Athari Bin Ismail To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Ong Boon Leong , Voon Weifeng , Wong Vee Khee , Huacai Chen Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mohammad.athari.ismail@intel.com Subject: [PATCH net 2/2] net: stmmac: skip only stmmac_ptp_register when resume from suspend Date: Mon, 24 Jan 2022 17:59:51 +0800 Message-Id: <20220124095951.23845-3-mohammad.athari.ismail@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220124095951.23845-1-mohammad.athari.ismail@intel.com> References: <20220124095951.23845-1-mohammad.athari.ismail@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_020047_975344_4D477210 X-CRM114-Status: GOOD ( 13.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When resume from suspend, besides skipping PTP registration, it also skipping PTP HW initialization. This could cause PTP clock not able to operate properly when resume from suspend. To fix this, only stmmac_ptp_register() is skipped when resume from suspend. Fixes: fe1319291150 ("stmmac: Don't init ptp again when resume from suspend/hibernation") Cc: # 5.15.x Signed-off-by: Mohammad Athari Bin Ismail --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d7e261768f73..cfea38a50a73 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -884,7 +884,7 @@ EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter); * This is done by looking at the HW cap. register. * This function also registers the ptp driver. */ -static int stmmac_init_ptp(struct stmmac_priv *priv) +static int stmmac_init_ptp(struct stmmac_priv *priv, bool ptp_register) { bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; int ret; @@ -914,7 +914,8 @@ static int stmmac_init_ptp(struct stmmac_priv *priv) priv->hwts_tx_en = 0; priv->hwts_rx_en = 0; - stmmac_ptp_register(priv); + if (ptp_register) + stmmac_ptp_register(priv); return 0; } @@ -3251,7 +3252,7 @@ static int stmmac_fpe_start_wq(struct stmmac_priv *priv) * 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ -static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) +static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) { struct stmmac_priv *priv = netdev_priv(dev); u32 rx_cnt = priv->plat->rx_queues_to_use; @@ -3308,13 +3309,11 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) stmmac_mmc_setup(priv); - if (init_ptp) { - ret = stmmac_init_ptp(priv); - if (ret == -EOPNOTSUPP) - netdev_warn(priv->dev, "PTP not supported by HW\n"); - else if (ret) - netdev_warn(priv->dev, "PTP init failed\n"); - } + ret = stmmac_init_ptp(priv, ptp_register); + if (ret == -EOPNOTSUPP) + netdev_warn(priv->dev, "PTP not supported by HW\n"); + else if (ret) + netdev_warn(priv->dev, "PTP init failed\n"); priv->eee_tw_timer = STMMAC_DEFAULT_TWT_LS;