mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Jarzmik <robert.jarzmik@free.fr>
To: barebox@lists.infradead.org
Subject: [PATCH] net: smc1111: fix memory congestions
Date: Thu,  1 Jan 2015 21:04:22 +0100	[thread overview]
Message-ID: <1420142663-6243-2-git-send-email-robert.jarzmik@free.fr> (raw)
In-Reply-To: <1420142663-6243-1-git-send-email-robert.jarzmik@free.fr>

As the SMC1111 has a shared pool of 2k memory buckets for both
transmission and reception, and as there are variants which have as few
as 4 buckets in total, the memory pool can be hogged by unclaimed
receptions, and impeed any further transmission.

This happens on the zylonite pxa board, where 4 packets, most probably
icmp and arp, fill the 4 buckets, preventing any further ethernet
transmission, and stalling the driver.

The fix is rather rough : whenever all the buckets are filled by
reception packets, and if a transmission is required, the transmission
code path will empty up all received packets.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/net/smc91111.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 55d9367..91bb845 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -152,6 +152,7 @@
 /* Memory Information Register */
 /* BANK 0  */
 #define MIR_REG		0x0008
+#define MIR_FREE_MASK	0xff00
 
 /* Receive/Phy Control Register */
 /* BANK 0  */
@@ -916,6 +917,30 @@ static int smc91c111_eth_open(struct eth_device *edev)
 	return 0;
 }
 
+static void smc91c111_ensure_freemem(struct eth_device *edev)
+{
+	struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv;
+	u16 mir, rxfifo;
+
+	SMC_SELECT_BANK(priv, 0);
+	mir = SMC_inw(priv, MIR_REG);
+	SMC_SELECT_BANK(priv, 2);
+
+	if ((mir & MIR_FREE_MASK) == 0) {
+		do {
+			SMC_outw(priv, MC_RELEASE, MMU_CMD_REG);
+			smc_wait_mmu_release_complete(priv);
+
+			SMC_SELECT_BANK(priv, 0);
+			mir = SMC_inw(priv, MIR_REG);
+			SMC_SELECT_BANK(priv, 2);
+			rxfifo = SMC_inw(priv, RXFIFO_REG);
+			dev_dbg(&edev->dev, "%s: card memory saturated, tidying up (rx_tx_fifo=0x%04x mir=0x%04x)\n",
+				SMC_DEV_NAME, rxfifo, mir);
+		} while (!(rxfifo & RXFIFO_REMPTY));
+	}
+}
+
 static int smc91c111_eth_send(struct eth_device *edev, void *packet,
 				int packet_length)
 {
@@ -957,6 +982,7 @@ static int smc91c111_eth_send(struct eth_device *edev, void *packet,
 		return -EOVERFLOW;
 	}
 
+	smc91c111_ensure_freemem(edev);
 	/* now, try to allocate the memory */
 	SMC_SELECT_BANK(priv, 2);
 	SMC_outw(priv, MC_ALLOC | numPages, MMU_CMD_REG);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-01-01 20:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-01 20:04 [PATCH] commands: loady: fix bug with netconsole Robert Jarzmik
2015-01-01 20:04 ` Robert Jarzmik [this message]
2015-01-05 12:11   ` [PATCH] net: smc1111: fix memory congestions Sascha Hauer
2015-01-05 16:16     ` robert.jarzmik
2015-01-06 13:58       ` Sascha Hauer
2015-01-01 20:04 ` [PATCH] net: smc1111: move print_packet function Robert Jarzmik
2015-01-05 12:12   ` Sascha Hauer
2015-01-05 12:12 ` [PATCH] commands: loady: fix bug with netconsole Sascha Hauer

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=1420142663-6243-2-git-send-email-robert.jarzmik@free.fr \
    --to=robert.jarzmik@free.fr \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox