From: Lucas Stach <dev@lynxeye.de>
To: barebox@lists.infradead.org
Subject: [PATCH 02/13] net: rtl8169: clean receive buffer after net handler
Date: Sun, 2 Nov 2014 21:13:44 +0100 [thread overview]
Message-ID: <1414959235-18095-3-git-send-email-dev@lynxeye.de> (raw)
In-Reply-To: <1414959235-18095-1-git-send-email-dev@lynxeye.de>
The processing of the buffer might change some data, which
will eventually trigger a cache writeback later on, corrupting
data written by the network chip. Clean the cache range
to make sure there is no writeback pending.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/net/rtl8169.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 0cd5763..5702900 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -233,6 +233,8 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
priv->rx_desc = dma_alloc_coherent(NUM_RX_DESC *
sizeof(struct bufdesc));
priv->rx_buf = malloc(NUM_RX_DESC * PKT_BUF_SIZE);
+ dma_clean_range((unsigned long)priv->rx_buf,
+ (unsigned long)priv->rx_buf + NUM_RX_DESC * PKT_BUF_SIZE);
memset(priv->tx_desc, 0, NUM_TX_DESC * sizeof(struct bufdesc));
memset(priv->rx_desc, 0, NUM_RX_DESC * sizeof(struct bufdesc));
@@ -421,6 +423,15 @@ static int rtl8169_eth_rx(struct eth_device *edev)
net_receive(edev, priv->rx_buf + entry * PKT_BUF_SIZE,
pkt_size);
+ /*
+ * the buffer is going to be reused by HW, make sure to
+ * clean out any potentially modified data
+ */
+ dma_clean_range((unsigned long)priv->rx_buf
+ + entry * PKT_BUF_SIZE,
+ (unsigned long)priv->rx_buf
+ + entry * PKT_BUF_SIZE + pkt_size);
+
if (entry == NUM_RX_DESC - 1)
priv->rx_desc[entry].status = BD_STAT_OWN |
BD_STAT_EOR | PKT_BUF_SIZE;
--
1.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-11-02 20:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-02 20:13 [PATCH 00/13] Tegra124 PCIe Lucas Stach
2014-11-02 20:13 ` [PATCH 01/13] net: rtl8169: add support for RTL-8168/8111g Lucas Stach
2014-11-02 20:13 ` Lucas Stach [this message]
2014-11-02 20:13 ` [PATCH 03/13] tegra: defconfig: enable barebox OF drivers Lucas Stach
2014-11-02 20:13 ` [PATCH 04/13] pinctrl: tegra: try to select "boot" state Lucas Stach
2014-11-02 20:13 ` [PATCH 05/13] arm: dts: jetson-tk1: switch to upstream DT Lucas Stach
2014-11-02 20:13 ` [PATCH 06/13] clk: tegra: slow down MSELECT to 102MHz Lucas Stach
2014-11-02 20:13 ` [PATCH 07/13] tegra: pmc: work around power domain failure Lucas Stach
2014-11-02 20:13 ` [PATCH 08/13] tegra: jetson-tk1: enable 1.05V_RUN Lucas Stach
2014-11-02 20:13 ` [PATCH 09/13] clk: tegra124: add PLLE setup functions Lucas Stach
2014-11-02 20:13 ` [PATCH 10/13] clk: tegra124: add PCIe clocks Lucas Stach
2014-11-02 20:13 ` [PATCH 11/13] add generic PHY framework Lucas Stach
2014-11-02 20:13 ` [PATCH 12/13] pinctrl: tegra: add XUSB pad controller Lucas Stach
2014-11-02 20:13 ` [PATCH 13/13] pci: tegra: add tegra124 support Lucas Stach
2014-11-03 8:40 ` [PATCH 00/13] Tegra124 PCIe 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=1414959235-18095-3-git-send-email-dev@lynxeye.de \
--to=dev@lynxeye.de \
--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