All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gagandeep Singh <g.singh@nxp.com>
To: ferruh.yigit@amd.com, dev@dpdk.org
Cc: Rohit Raj <rohit.raj@nxp.com>, Hemant Agrawal <hemant.agrawal@nxp.com>
Subject: [PATCH v2 09/16] bus/fslmc: add timeout in MC send command API
Date: Fri,  7 Oct 2022 08:57:36 +0530	[thread overview]
Message-ID: <20221007032743.2129353-10-g.singh@nxp.com> (raw)
In-Reply-To: <20221007032743.2129353-1-g.singh@nxp.com>

From: Rohit Raj <rohit.raj@nxp.com>

Adding one second timeout in MC send command API to ensure it doesn't
gets stuck in case of failure.

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/mc/mc_sys.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
index efafdc3101..ab9a074835 100644
--- a/drivers/bus/fslmc/mc/mc_sys.c
+++ b/drivers/bus/fslmc/mc/mc_sys.c
@@ -1,13 +1,14 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2013-2015 Freescale Semiconductor Inc.
- * Copyright 2017 NXP
+ * Copyright 2017,2022 NXP
  *
  */
 #include <fsl_mc_sys.h>
 #include <fsl_mc_cmd.h>
 
 #include <rte_spinlock.h>
+#include <rte_cycles.h>
 
 /** User space framework uses MC Portal in shared mode. Following change
  * introduces lock in MC FLIB
@@ -54,7 +55,7 @@ static int mc_status_to_error(enum mc_cmd_status status)
 int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
 {
 	enum mc_cmd_status status;
-	uint64_t response;
+	uint64_t response, start_time, total_time, time_to_wait;
 
 	if (!mc_io || !mc_io->regs)
 		return -EACCES;
@@ -64,15 +65,20 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
 
 	mc_write_command(mc_io->regs, cmd);
 
+	/* Wait for one second. rte_get_timer_hz() returns frequency of CPU */
+	time_to_wait = rte_get_timer_hz();
+	total_time = 0;
+	start_time = rte_get_timer_cycles();
+
 	/* Spin until status changes */
 	do {
 		response = ioread64(mc_io->regs);
 		status = mc_cmd_read_status((struct mc_command *)&response);
+		total_time = rte_get_timer_cycles() - start_time;
+	} while (status == MC_CMD_STATUS_READY && total_time <= time_to_wait);
 
-		/* --- Call wait function here to prevent blocking ---
-		 * Change the loop condition accordingly to exit on timeout.
-		 */
-	} while (status == MC_CMD_STATUS_READY);
+	if (status == MC_CMD_STATUS_READY)
+		return mc_status_to_error(MC_CMD_STATUS_TIMEOUT);
 
 	/* Read the response back into the command buffer */
 	mc_read_response(mc_io->regs, cmd);
-- 
2.25.1


  parent reply	other threads:[~2022-10-07  3:29 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  5:25 [PATCH 00/15] DPAA and DPAA2 driver changes Gagandeep Singh
2022-09-28  5:25 ` [PATCH 01/15] bus/dpaa: use non-block mode for FD open Gagandeep Singh
2022-09-28  5:25 ` [PATCH 02/15] net/enetfec: fix restart issue Gagandeep Singh
2022-09-28  5:25 ` [PATCH 03/15] net/enetfec: fix buffer leak issue Gagandeep Singh
2022-09-28  5:25 ` [PATCH 04/15] net/dpaa2: fix dpdmux configuration for error behaviour Gagandeep Singh
2022-09-28  5:25 ` [PATCH 05/15] net/dpaa2: check free enqueue descriptors before Tx Gagandeep Singh
2022-10-05 14:30   ` Ferruh Yigit
2022-09-28  5:25 ` [PATCH 06/15] net/dpaa: support ESP packet type in packet parsing Gagandeep Singh
2022-10-05 14:20   ` Ferruh Yigit
2022-10-06  8:48     ` Gagandeep Singh
2022-09-28  5:25 ` [PATCH 07/15] net/dpaa2: use internal mempool for SG table Gagandeep Singh
2022-10-05 14:20   ` Ferruh Yigit
2022-10-06  8:49     ` Gagandeep Singh
2022-10-06  9:38       ` Ferruh Yigit
2022-10-06 11:18         ` Gagandeep Singh
2022-09-28  5:25 ` [PATCH 08/15] net/dpaa2: fix buffer free on transmit SG packets Gagandeep Singh
2022-10-06  7:48   ` Ferruh Yigit
2022-09-28  5:25 ` [PATCH 09/15] bus/fslmc: add timeout in MC send command API Gagandeep Singh
2022-09-28  5:25 ` [PATCH 10/15] net/dpaa: fix Jumbo packet Rx in case of VSP Gagandeep Singh
2022-09-28  5:25 ` [PATCH 11/15] bus/dpaa: pass interface name as a string instead of pointer Gagandeep Singh
2022-10-05 14:21   ` Ferruh Yigit
2022-10-06  8:51     ` Gagandeep Singh
2022-10-06  9:39       ` Ferruh Yigit
2022-10-06 11:18         ` Gagandeep Singh
2022-09-28  5:25 ` [PATCH 12/15] net/dpaa: use internal mempool for SG table Gagandeep Singh
2022-09-28  5:25 ` [PATCH 13/15] bus/dpaa: mempool ops registration change Gagandeep Singh
2022-09-28  5:25 ` [PATCH 14/15] net/dpaa: fix buffer free on transmit SG packets Gagandeep Singh
2022-09-28  5:25 ` [PATCH 15/15] net/dpaa: fix buffer free in slow path Gagandeep Singh
2022-10-05 14:21   ` Ferruh Yigit
2022-10-06  8:51     ` Gagandeep Singh
2022-10-06  9:42       ` Ferruh Yigit
2022-10-06 11:19         ` Gagandeep Singh
2022-10-05 14:27 ` [PATCH 00/15] DPAA and DPAA2 driver changes Ferruh Yigit
2022-10-06 11:15 ` Hemant Agrawal
2022-10-07  3:27 ` [PATCH v2 00/16] " Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 01/16] bus/dpaa: use non-block mode for FD open Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 02/16] net/enetfec: fix restart issue Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 03/16] net/enetfec: fix buffer leak issue Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 04/16] net/dpaa2: fix dpdmux configuration for error behaviour Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 05/16] net/dpaa2: check free enqueue descriptors before Tx Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 06/16] net/dpaa: support ESP packet type in packet parsing Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 07/16] net/dpaa2: use internal mempool for SG table Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 08/16] net/dpaa2: fix buffer free on transmit SG packets Gagandeep Singh
2022-10-07  3:27   ` Gagandeep Singh [this message]
2022-10-07  3:27   ` [PATCH v2 10/16] net/dpaa: fix Jumbo packet Rx in case of VSP Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 11/16] doc: add kernel version compatible information Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 12/16] bus/dpaa: pass interface name as a string instead of pointer Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 13/16] net/dpaa: use internal mempool for SG table Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 14/16] bus/dpaa: mempool ops registration change Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 15/16] net/dpaa: fix buffer free on transmit SG packets Gagandeep Singh
2022-10-07  3:27   ` [PATCH v2 16/16] net/dpaa: fix buffer free in slow path Gagandeep Singh
2022-10-07 15:22   ` [PATCH v2 00/16] DPAA and DPAA2 driver changes Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221007032743.2129353-10-g.singh@nxp.com \
    --to=g.singh@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=rohit.raj@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.