All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prabhakar Kushwaha <prabhakar@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/12][v3] driver/ldpaa_eth: Retry enqueue if portal was busy
Date: Sun, 28 Jun 2015 10:08:59 +0530	[thread overview]
Message-ID: <1435466341-22901-10-git-send-email-prabhakar@freescale.com> (raw)
In-Reply-To: <1435466341-22901-1-git-send-email-prabhakar@freescale.com>

Do not immediately return if the enqueue function returns -EBUSY; re-try
mulitple times.

if timeout occures, release the buffer.

Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>

driver/ldpaa_eth:Avoid infinite loop in QBMAN buf release

Change infinite loop mechanism to timer based polling.

---
Changes for v2: Sending as it is for patchset
Changes for v3: Incorporated Joe Hershberger's comments
    - Squash with "driver/ldpaa_eth:Avoid infinite loop in QBMAN buf release"
    - use err instead of calling get_timer() again


 drivers/net/ldpaa_eth/ldpaa_eth.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 5636511..275e316 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -31,6 +31,8 @@ static void ldpaa_eth_rx(struct ldpaa_eth_priv *priv,
 	uint32_t fd_length;
 	struct ldpaa_fas *fas;
 	uint32_t status, err;
+	u32 timeo = (CONFIG_SYS_HZ * 2) / 1000;
+	u32 time_start;
 	struct qbman_release_desc releasedesc;
 	struct qbman_swp *swp = dflt_dpio->sw_portal;
 
@@ -65,10 +67,15 @@ error:
 	flush_dcache_range(fd_addr, fd_addr + LDPAA_ETH_RX_BUFFER_SIZE);
 	qbman_release_desc_clear(&releasedesc);
 	qbman_release_desc_set_bpid(&releasedesc, dflt_dpbp->dpbp_attr.bpid);
+	time_start = get_timer(0);
 	do {
 		/* Release buffer into the QBMAN */
 		err = qbman_swp_release(swp, &releasedesc, &fd_addr, 1);
-	} while (err == -EBUSY);
+	} while (get_timer(time_start) < timeo && err == -EBUSY);
+
+	if (err == -EBUSY)
+		printf("Rx frame: QBMAN buffer release fails\n");
+
 	return;
 }
 
@@ -221,8 +228,11 @@ static int ldpaa_eth_tx(struct eth_device *net_dev, void *buf, int len)
 	struct dpaa_fd fd;
 	u64 buffer_start;
 	int data_offset, err;
+	u32 timeo = (CONFIG_SYS_HZ * 10) / 1000;
+	u32 time_start;
 	struct qbman_swp *swp = dflt_dpio->sw_portal;
 	struct qbman_eq_desc ed;
+	struct qbman_release_desc releasedesc;
 
 	/* Setup the FD fields */
 	memset(&fd, 0, sizeof(fd));
@@ -258,9 +268,18 @@ static int ldpaa_eth_tx(struct eth_device *net_dev, void *buf, int len)
 	qbman_eq_desc_clear(&ed);
 	qbman_eq_desc_set_no_orp(&ed, 0);
 	qbman_eq_desc_set_qd(&ed, priv->tx_qdid, priv->tx_flow_id, 0);
-	err = qbman_swp_enqueue(swp, &ed, (const struct qbman_fd *)(&fd));
+
+	time_start = get_timer(0);
+
+	while (get_timer(time_start) < timeo) {
+		err = qbman_swp_enqueue(swp, &ed,
+				(const struct qbman_fd *)(&fd));
+		if (err != -EBUSY)
+			break;
+	}
+
 	if (err < 0)
-		printf("error enqueueing Tx frame\n");
+		goto error;
 
 	mdelay(1);
 
@@ -269,6 +288,20 @@ static int ldpaa_eth_tx(struct eth_device *net_dev, void *buf, int len)
 		printf("error Tx Conf frame\n");
 
 	return err;
+
+error:
+	qbman_release_desc_clear(&releasedesc);
+	qbman_release_desc_set_bpid(&releasedesc, dflt_dpbp->dpbp_attr.bpid);
+	time_start = get_timer(0);
+	do {
+		/* Release buffer into the QBMAN */
+		err = qbman_swp_release(swp, &releasedesc, &buffer_start, 1);
+	} while (get_timer(time_start) < timeo && err == -EBUSY);
+
+	if (err == -EBUSY)
+		printf("TX data: QBMAN buffer release fails\n");
+
+	return err;
 }
 
 static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
-- 
1.9.1

  parent reply	other threads:[~2015-06-28  4:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28  4:38 [U-Boot] [PATCH 01/12][v3] drivers/fsl-mc: Make MC boot error messages more readable Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 02/12][v3] driver/ldpaa_eth:Flush buffer before seeding BMAN after TX_conf Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 03/12][v3] drivers/fsl-mc: Autoload AOIP image from NOR flash Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 04/12][v3] drivers: fsl-mc: Update flibs to mc-0.6.0.1 Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 05/12][v3] drivers: fsl-mc: Update qbman driver Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 06/12][v3] drivers: fsl-mc: Return error for major version mismatch Prabhakar Kushwaha
2015-06-29 19:49   ` Joe Hershberger
2015-06-28  4:38 ` [U-Boot] [PATCH 07/12][v3] armv8/fsl-lsch3: partition stream IDs Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 08/12][v3] drivers/fsl-mc: dynamically create ICID pool in DPC Prabhakar Kushwaha
2015-06-28  4:38 ` [U-Boot] [PATCH 09/12][v3] armv8/fsl-lsch3: device tree fixups for PCI stream IDs Prabhakar Kushwaha
2015-06-28  4:38 ` Prabhakar Kushwaha [this message]
2015-06-29 19:55   ` [U-Boot] [PATCH 10/12][v3] driver/ldpaa_eth: Retry enqueue if portal was busy Joe Hershberger
2015-06-28  4:39 ` [U-Boot] [PATCH 11/12][v3] driver/ldpaa_eth: Add timeout handling DQRR entry read Prabhakar Kushwaha
2015-06-29 20:01   ` Joe Hershberger
2015-06-28  4:39 ` [U-Boot] [PATCH 12/12][v3] driver/ldpaa_eth: Avoid TX conf frames Prabhakar Kushwaha

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=1435466341-22901-10-git-send-email-prabhakar@freescale.com \
    --to=prabhakar@freescale.com \
    --cc=u-boot@lists.denx.de \
    /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.