From patchwork Wed Jun 7 07:01:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13270065 X-Patchwork-Delegate: geert@linux-m68k.org 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 5545AC7EE29 for ; Wed, 7 Jun 2023 07:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237478AbjFGHBr (ORCPT ); Wed, 7 Jun 2023 03:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234882AbjFGHBq (ORCPT ); Wed, 7 Jun 2023 03:01:46 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55ED811A; Wed, 7 Jun 2023 00:01:45 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.00,223,1681138800"; d="scan'208";a="166060454" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 07 Jun 2023 16:01:44 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A9E31419B1BB; Wed, 7 Jun 2023 16:01:44 +0900 (JST) From: Yoshihiro Shimoda To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda , Phong Hoang Subject: [PATCH net v2] net: renesas: rswitch: Fix timestamp feature after all descriptors are used Date: Wed, 7 Jun 2023 16:01:41 +0900 Message-Id: <20230607070141.1795982-1-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The timestamp descriptors were intended to act cyclically. Descriptors from index 0 through gq->ring_size - 1 contain actual information, and the last index (gq->ring_size) should have LINKFIX to indicate the first index 0 descriptor. However, thie LINKFIX value is missing, causing the timestamp feature to stop after all descriptors are used. To resolve this issue, set the LINKFIX to the timestamp descritors. Reported-by: Phong Hoang Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy") Signed-off-by: Yoshihiro Shimoda Reviewed-by: Hao Lan --- Since I got this report locally, I didn't add Closes: tag. Changes from v1: https://lore.kernel.org/all/20230607064402.1795548-1-yoshihiro.shimoda.uh@renesas.com/ - Fix typo in the subject. drivers/net/ethernet/renesas/rswitch.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index aace87139cea..049adbf5a642 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -420,7 +420,7 @@ static int rswitch_gwca_queue_format(struct net_device *ndev, } static void rswitch_gwca_ts_queue_fill(struct rswitch_private *priv, - int start_index, int num) + int start_index, int num, bool last) { struct rswitch_gwca_queue *gq = &priv->gwca.ts_queue; struct rswitch_ts_desc *desc; @@ -431,6 +431,12 @@ static void rswitch_gwca_ts_queue_fill(struct rswitch_private *priv, desc = &gq->ts_ring[index]; desc->desc.die_dt = DT_FEMPTY_ND | DIE; } + + if (last) { + desc = &gq->ts_ring[gq->ring_size]; + rswitch_desc_set_dptr(&desc->desc, gq->ring_dma); + desc->desc.die_dt = DT_LINKFIX; + } } static int rswitch_gwca_queue_ext_ts_fill(struct net_device *ndev, @@ -941,7 +947,7 @@ static void rswitch_ts(struct rswitch_private *priv) } num = rswitch_get_num_cur_queues(gq); - rswitch_gwca_ts_queue_fill(priv, gq->dirty, num); + rswitch_gwca_ts_queue_fill(priv, gq->dirty, num, false); gq->dirty = rswitch_next_queue_index(gq, false, num); } @@ -1780,7 +1786,7 @@ static int rswitch_init(struct rswitch_private *priv) if (err < 0) goto err_ts_queue_alloc; - rswitch_gwca_ts_queue_fill(priv, 0, TS_RING_SIZE); + rswitch_gwca_ts_queue_fill(priv, 0, TS_RING_SIZE, true); INIT_LIST_HEAD(&priv->gwca.ts_info_list); for (i = 0; i < RSWITCH_NUM_PORTS; i++) {