From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RESEND PATCH v2 4/5] net: pch_gbe: Add cache maintenance
Date: Sun, 30 Apr 2017 21:57:08 +0200 [thread overview]
Message-ID: <20170430195710.19713-5-daniel.schwierzeck@gmail.com> (raw)
In-Reply-To: <20170430195710.19713-1-daniel.schwierzeck@gmail.com>
From: Paul Burton <paul.burton@imgtec.com>
On MIPS systems DMA isn't coherent with the CPU caches unless an IOCU is
present. When there is no IOCU we need to writeback or invalidate the
data caches at appropriate points. Perform this cache maintenance in
the pch_gbe driver which is used on the MIPS Boston development board.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
---
Changes in v2: None
drivers/net/pch_gbe.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
index 14323512b0..8866f6632f 100644
--- a/drivers/net/pch_gbe.c
+++ b/drivers/net/pch_gbe.c
@@ -120,6 +120,8 @@ static void pch_gbe_rx_descs_init(struct udevice *dev)
rx_desc[i].buffer_addr = dm_pci_virt_to_mem(priv->dev,
priv->rx_buff[i]);
+ flush_dcache_range((ulong)rx_desc, (ulong)&rx_desc[PCH_GBE_DESC_NUM]);
+
writel(dm_pci_virt_to_mem(priv->dev, rx_desc),
&mac_regs->rx_dsc_base);
writel(sizeof(struct pch_gbe_rx_desc) * (PCH_GBE_DESC_NUM - 1),
@@ -137,6 +139,8 @@ static void pch_gbe_tx_descs_init(struct udevice *dev)
memset(tx_desc, 0, sizeof(struct pch_gbe_tx_desc) * PCH_GBE_DESC_NUM);
+ flush_dcache_range((ulong)tx_desc, (ulong)&tx_desc[PCH_GBE_DESC_NUM]);
+
writel(dm_pci_virt_to_mem(priv->dev, tx_desc),
&mac_regs->tx_dsc_base);
writel(sizeof(struct pch_gbe_tx_desc) * (PCH_GBE_DESC_NUM - 1),
@@ -245,6 +249,8 @@ static int pch_gbe_send(struct udevice *dev, void *packet, int length)
u32 int_st;
ulong start;
+ flush_dcache_range((ulong)packet, (ulong)packet + length);
+
tx_head = &priv->tx_desc[0];
tx_desc = &priv->tx_desc[priv->tx_idx];
@@ -258,6 +264,8 @@ static int pch_gbe_send(struct udevice *dev, void *packet, int length)
tx_desc->dma_status = 0;
tx_desc->gbec_status = 0;
+ flush_dcache_range((ulong)tx_desc, (ulong)&tx_desc[1]);
+
/* Test the wrap-around condition */
if (++priv->tx_idx >= PCH_GBE_DESC_NUM)
priv->tx_idx = 0;
@@ -295,8 +303,12 @@ static int pch_gbe_recv(struct udevice *dev, int flags, uchar **packetp)
if (virt_to_phys(rx_desc) == hw_desc)
return -EAGAIN;
+ /* Invalidate the descriptor */
+ invalidate_dcache_range((ulong)rx_desc, (ulong)&rx_desc[1]);
+
length = rx_desc->rx_words_eob - 3 - ETH_FCS_LEN;
buffer = dm_pci_mem_to_virt(priv->dev, rx_desc->buffer_addr, length, 0);
+ invalidate_dcache_range((ulong)buffer, (ulong)buffer + length);
*packetp = (uchar *)buffer;
return length;
--
2.11.0
next prev parent reply other threads:[~2017-04-30 19:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-30 19:57 [U-Boot] [RESEND PATCH v2 0/5] net/pch_gbe: updates for MIPS Boston board Daniel Schwierzeck
2017-04-30 19:57 ` [U-Boot] [RESEND PATCH v2 1/5] net: pch_gbe: Reset during probe Daniel Schwierzeck
2017-05-04 16:49 ` Simon Glass
2017-05-30 20:17 ` Joe Hershberger
2017-06-02 19:48 ` [U-Boot] " Joe Hershberger
2017-04-30 19:57 ` [U-Boot] [RESEND PATCH v2 2/5] net: pch_gbe: Fix rx descriptor buffer addresses Daniel Schwierzeck
2017-05-04 16:49 ` Simon Glass
2017-05-30 20:18 ` Joe Hershberger
2017-06-02 19:49 ` [U-Boot] " Joe Hershberger
2017-04-30 19:57 ` [U-Boot] [RESEND PATCH v2 3/5] net: pch_gbe: CPU accessible addresses are virtual Daniel Schwierzeck
2017-05-04 16:49 ` Simon Glass
2017-05-30 20:19 ` Joe Hershberger
2017-06-02 19:49 ` [U-Boot] " Joe Hershberger
2017-04-30 19:57 ` Daniel Schwierzeck [this message]
2017-05-04 16:49 ` [U-Boot] [RESEND PATCH v2 4/5] net: pch_gbe: Add cache maintenance Simon Glass
2017-05-30 20:20 ` Joe Hershberger
2017-06-02 19:49 ` [U-Boot] " Joe Hershberger
2017-04-30 19:57 ` [U-Boot] [RESEND PATCH v2 5/5] net: pch_gbe: Support PHY reset GPIOs Daniel Schwierzeck
2017-05-30 20:26 ` Joe Hershberger
2017-05-30 20:29 ` [U-Boot] [RESEND PATCH v2 0/5] net/pch_gbe: updates for MIPS Boston board Joe Hershberger
2017-05-31 12:45 ` Daniel Schwierzeck
2017-05-31 16:00 ` Joe Hershberger
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=20170430195710.19713-5-daniel.schwierzeck@gmail.com \
--to=daniel.schwierzeck@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox