From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4C09C433EF for ; Wed, 13 Apr 2022 03:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbiDMD5r (ORCPT ); Tue, 12 Apr 2022 23:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232126AbiDMD4t (ORCPT ); Tue, 12 Apr 2022 23:56:49 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDC3F273A; Tue, 12 Apr 2022 20:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649822068; x=1681358068; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=qWnHsji0gnh/xDp7MQF81PbKycXAQAQAMMGE3n28kdA=; b=YlhoMOngZDWEyJon07RvXTvrthpaDc+N+wS0AqTD8UqmyKrHA2Jzq+eP bCxsTEddmO2VWcKEjnfypmWBBOU2QV+rgQY9mWqqwDBwT+azVS6dpvewZ rxMJx2vrHHs8Ltx59uEj83UlNpeG3Yc33hD/0BTUDuZL2CLFwWFjP+XE9 VQz33zcwXCmHdnaIPm0rkHBD8lhZMW60qbGBa2TAoWH5UYejoZUD5ujEY eSwJP6GiQNO/VUioeEgUoawKVLeI5ObmJCKWgLMbe7rHVcJDUOXhz1DQM NAj0Jp5iSZxHPK15nkEKWcmizwabXjhZ4xHiFF2/4deaBj+Gi7+u6A0cJ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="249852148" X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="249852148" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 20:54:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="724733855" Received: from p12hl01tmin.png.intel.com ([10.158.65.75]) by orsmga005.jf.intel.com with ESMTP; 12 Apr 2022 20:54:23 -0700 From: Tan Tee Min To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Rayagond Kokatanur , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Voon Wei Feng , Wong Vee Khee , Song Yoong Siang , Tan Tee Min Subject: [PATCH net 1/1] net: stmmac: add fsleep() in HW Rx timestamp checking loop Date: Wed, 13 Apr 2022 12:01:15 +0800 Message-Id: <20220413040115.2351987-1-tee.min.tan@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a possibility that the context descriptor still owned by the DMA even the previous normal descriptor own bit is already cleared. Checking the context descriptor readiness without delay might be not enough time for the DMA to update the descriptor field, which causing failure in getting HW Rx timestamp. This patch introduces a 1us fsleep() in HW Rx timestamp checking loop to give time for DMA to update/complete the context descriptor. ptp4l Timestamp log without this patch: ----------------------------------------------------------- $ echo 10000 > /sys/class/net/enp0s30f4/gro_flush_timeout $ echo 10000 > /sys/class/net/enp0s30f4/napi_defer_hard_irqs $ ptp4l -P2Hi enp0s30f4 --step_threshold=1 -m ptp4l: selected /dev/ptp2 as PTP clock ptp4l: port 1: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l: selected local clock 901210.fffe.b57df7 as best master ptp4l: port 1: new foreign master 22bb22.fffe.bb22bb-1 ptp4l: selected best master clock 22bb22.fffe.bb22bb ptp4l: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l: port 1: received SYNC without timestamp ptp4l: rms 49 max 63 freq -9573 +/- 34 delay 71 +/- 1 ptp4l: rms 15 max 25 freq -9553 +/- 20 delay 72 +/- 0 ptp4l: port 1: received SYNC without timestamp ptp4l: rms 9 max 18 freq -9540 +/- 11 delay 70 +/- 0 ptp4l: port 1: received PDELAY_REQ without timestamp ptp4l: rms 16 max 29 freq -9519 +/- 12 delay 72 +/- 0 ptp4l: port 1: received PDELAY_REQ without timestamp ptp4l: rms 9 max 18 freq -9527 +/- 12 delay 72 +/- 0 ptp4l: rms 5 max 9 freq -9530 +/- 7 delay 70 +/- 0 ptp4l: rms 11 max 20 freq -9530 +/- 16 delay 72 +/- 0 ptp4l: rms 5 max 11 freq -9530 +/- 7 delay 74 +/- 0 ptp4l: rms 6 max 9 freq -9522 +/- 7 delay 72 +/- 0 ptp4l: port 1: received PDELAY_REQ without timestamp ----------------------------------------------------------- ptp4l Timestamp log with this patch: ----------------------------------------------------------- $ echo 10000 > /sys/class/net/enp0s30f4/gro_flush_timeout $ echo 10000 > /sys/class/net/enp0s30f4/napi_defer_hard_irqs $ ptp4l -P2Hi enp0s30f4 --step_threshold=1 -m ptp4l: selected /dev/ptp2 as PTP clock ptp4l: port 1: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l: selected local clock 901210.fffe.b57df7 as best master ptp4l: port 1: new foreign master 22bb22.fffe.bb22bb-1 ptp4l: selected best master clock 22bb22.fffe.bb22bb ptp4l: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l: rms 30 max 45 freq -9400 +/- 23 delay 72 +/- 0 ptp4l: rms 7 max 16 freq -9414 +/- 10 delay 70 +/- 0 ptp4l: rms 6 max 9 freq -9422 +/- 6 delay 72 +/- 0 ptp4l: rms 13 max 20 freq -9436 +/- 13 delay 74 +/- 0 ptp4l: rms 12 max 27 freq -9446 +/- 11 delay 72 +/- 0 ptp4l: rms 9 max 12 freq -9453 +/- 6 delay 74 +/- 0 ptp4l: rms 9 max 15 freq -9438 +/- 11 delay 74 +/- 0 ptp4l: rms 10 max 16 freq -9435 +/- 12 delay 74 +/- 0 ptp4l: rms 8 max 18 freq -9428 +/- 8 delay 72 +/- 0 ptp4l: rms 8 max 18 freq -9423 +/- 8 delay 72 +/- 0 ptp4l: rms 9 max 16 freq -9431 +/- 12 delay 70 +/- 0 ptp4l: rms 9 max 18 freq -9441 +/- 9 delay 72 +/- 0 ----------------------------------------------------------- Fixes: ba1ffd74df74 ("stmmac: fix PTP support for GMAC4") Cc: # 5.4.x Signed-off-by: Song Yoong Siang Signed-off-by: Tan Tee Min --- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index d3b4765c1a5b..289bf26a6105 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -279,10 +279,11 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, void *next_desc, /* Check if timestamp is OK from context descriptor */ do { ret = dwmac4_rx_check_timestamp(next_desc); - if (ret < 0) + if (ret <= 0) goto exit; i++; + fsleep(1); } while ((ret == 1) && (i < 10)); if (i == 10) -- 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 1C623C433EF for ; Wed, 13 Apr 2022 03:56:10 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=UnTZ3/BlPisdVzETVCEzpANGObetCR7xLXsEs5U4l98=; b=yxEDRuvRiHfFY0 LDNF+Fua8UH2sGbgnoBX6WXzy84iPigKRrrbdVZwnBPzw7uUCyJRSFUcanxBGASDR7rcu2ZJ4pU3V 73bZkxAveNxRzbasYEwExCUjyt9tZQ2MOeMTzK30uy22gu8suU4Q08BA2HnG/doks0Yi7tFtnKvsv daOPPx51+3jb/wg/pIufcGns6gNX5XhUZxoK1UtY8A/53G2CmVipmKDLLVdS/K3Ln/3ezZypQ/6Vr yvx8eUpARUx8b54qGAoSbF9g6gV+WEwOnKKW0m5Mbsd/Au4i15rfAXYD8JLe5FBMgR1utantUdrn1 mTwAIMpr32NAqWAZCjiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neU5s-00Gcsq-9I; Wed, 13 Apr 2022 03:55:00 +0000 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neU5O-00GcZk-Pm for linux-arm-kernel@lists.infradead.org; Wed, 13 Apr 2022 03:54:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649822070; x=1681358070; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=qWnHsji0gnh/xDp7MQF81PbKycXAQAQAMMGE3n28kdA=; b=VkqOjtYKeJWOspsTz5wXkexGk9zudYr7OlWGsIFIcRfRfKXPV0gRaMWe bvgxN4hXIgRoJASQw1PEELKU9hQ4U9DBywyvx51oEYCO0jci5NsGh/QYt Pcr5NGmmvaEm2OPBws1vaJT7nae9d0UxEl1hJZe6eHWaOsTQKZoWkKDOO 4GidUiohS0jiIdC4Wqqe6a2dkFFBLEhcne4xZNTQJg6A2U9Gi3PM9Pb6v 7khPob4CHO5Mv2g2NM4y3RzwCZG2gW09PuwT7JJdCeCDruTrPlC+0LzqJ r8N/nJOpQSes/Bk7SghzHh0GiAgINSOvSPE5Zdd1Ce7oIO7xgi/oOmZAB A==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="323007871" X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="323007871" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 20:54:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="724733855" Received: from p12hl01tmin.png.intel.com ([10.158.65.75]) by orsmga005.jf.intel.com with ESMTP; 12 Apr 2022 20:54:23 -0700 From: Tan Tee Min To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Rayagond Kokatanur , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Voon Wei Feng , Wong Vee Khee , Song Yoong Siang , Tan Tee Min Subject: [PATCH net 1/1] net: stmmac: add fsleep() in HW Rx timestamp checking loop Date: Wed, 13 Apr 2022 12:01:15 +0800 Message-Id: <20220413040115.2351987-1-tee.min.tan@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220412_205430_953161_259F678F X-CRM114-Status: GOOD ( 11.27 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a possibility that the context descriptor still owned by the DMA even the previous normal descriptor own bit is already cleared. Checking the context descriptor readiness without delay might be not enough time for the DMA to update the descriptor field, which causing failure in getting HW Rx timestamp. This patch introduces a 1us fsleep() in HW Rx timestamp checking loop to give time for DMA to update/complete the context descriptor. ptp4l Timestamp log without this patch: ----------------------------------------------------------- $ echo 10000 > /sys/class/net/enp0s30f4/gro_flush_timeout $ echo 10000 > /sys/class/net/enp0s30f4/napi_defer_hard_irqs $ ptp4l -P2Hi enp0s30f4 --step_threshold=1 -m ptp4l: selected /dev/ptp2 as PTP clock ptp4l: port 1: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l: selected local clock 901210.fffe.b57df7 as best master ptp4l: port 1: new foreign master 22bb22.fffe.bb22bb-1 ptp4l: selected best master clock 22bb22.fffe.bb22bb ptp4l: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l: port 1: received SYNC without timestamp ptp4l: rms 49 max 63 freq -9573 +/- 34 delay 71 +/- 1 ptp4l: rms 15 max 25 freq -9553 +/- 20 delay 72 +/- 0 ptp4l: port 1: received SYNC without timestamp ptp4l: rms 9 max 18 freq -9540 +/- 11 delay 70 +/- 0 ptp4l: port 1: received PDELAY_REQ without timestamp ptp4l: rms 16 max 29 freq -9519 +/- 12 delay 72 +/- 0 ptp4l: port 1: received PDELAY_REQ without timestamp ptp4l: rms 9 max 18 freq -9527 +/- 12 delay 72 +/- 0 ptp4l: rms 5 max 9 freq -9530 +/- 7 delay 70 +/- 0 ptp4l: rms 11 max 20 freq -9530 +/- 16 delay 72 +/- 0 ptp4l: rms 5 max 11 freq -9530 +/- 7 delay 74 +/- 0 ptp4l: rms 6 max 9 freq -9522 +/- 7 delay 72 +/- 0 ptp4l: port 1: received PDELAY_REQ without timestamp ----------------------------------------------------------- ptp4l Timestamp log with this patch: ----------------------------------------------------------- $ echo 10000 > /sys/class/net/enp0s30f4/gro_flush_timeout $ echo 10000 > /sys/class/net/enp0s30f4/napi_defer_hard_irqs $ ptp4l -P2Hi enp0s30f4 --step_threshold=1 -m ptp4l: selected /dev/ptp2 as PTP clock ptp4l: port 1: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l: selected local clock 901210.fffe.b57df7 as best master ptp4l: port 1: new foreign master 22bb22.fffe.bb22bb-1 ptp4l: selected best master clock 22bb22.fffe.bb22bb ptp4l: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l: rms 30 max 45 freq -9400 +/- 23 delay 72 +/- 0 ptp4l: rms 7 max 16 freq -9414 +/- 10 delay 70 +/- 0 ptp4l: rms 6 max 9 freq -9422 +/- 6 delay 72 +/- 0 ptp4l: rms 13 max 20 freq -9436 +/- 13 delay 74 +/- 0 ptp4l: rms 12 max 27 freq -9446 +/- 11 delay 72 +/- 0 ptp4l: rms 9 max 12 freq -9453 +/- 6 delay 74 +/- 0 ptp4l: rms 9 max 15 freq -9438 +/- 11 delay 74 +/- 0 ptp4l: rms 10 max 16 freq -9435 +/- 12 delay 74 +/- 0 ptp4l: rms 8 max 18 freq -9428 +/- 8 delay 72 +/- 0 ptp4l: rms 8 max 18 freq -9423 +/- 8 delay 72 +/- 0 ptp4l: rms 9 max 16 freq -9431 +/- 12 delay 70 +/- 0 ptp4l: rms 9 max 18 freq -9441 +/- 9 delay 72 +/- 0 ----------------------------------------------------------- Fixes: ba1ffd74df74 ("stmmac: fix PTP support for GMAC4") Cc: # 5.4.x Signed-off-by: Song Yoong Siang Signed-off-by: Tan Tee Min --- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index d3b4765c1a5b..289bf26a6105 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -279,10 +279,11 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, void *next_desc, /* Check if timestamp is OK from context descriptor */ do { ret = dwmac4_rx_check_timestamp(next_desc); - if (ret < 0) + if (ret <= 0) goto exit; i++; + fsleep(1); } while ((ret == 1) && (i < 10)); if (i == 10) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel