mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Chou <thomas@wytron.com.tw>
To: thierry.reding@avionic-design.de
Cc: Nios2 development list <nios2-dev@sopc.et.ntust.edu.tw>,
	linux-kernel@vger.kernel.org, Thomas Chou <thomas@wytron.com.tw>
Subject: [PATCH 2/4] ethoc: fix buffer address mapping
Date: Mon,  5 Oct 2009 15:43:03 +0800	[thread overview]
Message-ID: <1254728585-31964-2-git-send-email-thomas@wytron.com.tw> (raw)
In-Reply-To: <1254728585-31964-1-git-send-email-thomas@wytron.com.tw>

The pointer address in buffer descriptors is physical address. The
pointer that processor used to access packet is virtual address.

Though the higher bits of pointer address used by the MAC may be
truncated to zero in special case, it is not always true in larger
designs.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 drivers/net/ethoc.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 7475620..f92747f 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -284,7 +284,7 @@ static int ethoc_init_ring(struct ethoc *dev)
 	dev->cur_rx = 0;
 
 	/* setup transmission buffers */
-	bd.addr = 0;
+	bd.addr = virt_to_phys(dev->membase);
 	bd.stat = TX_BD_IRQ | TX_BD_CRC;
 
 	for (i = 0; i < dev->num_tx; i++) {
@@ -295,7 +295,6 @@ static int ethoc_init_ring(struct ethoc *dev)
 		bd.addr += ETHOC_BUFSIZ;
 	}
 
-	bd.addr = dev->num_tx * ETHOC_BUFSIZ;
 	bd.stat = RX_BD_EMPTY | RX_BD_IRQ;
 
 	for (i = 0; i < dev->num_rx; i++) {
@@ -401,7 +400,7 @@ static int ethoc_rx(struct net_device *dev, int limit)
 			int size = bd.stat >> 16;
 			struct sk_buff *skb = netdev_alloc_skb(dev, size);
 			if (likely(skb)) {
-				void *src = priv->membase + bd.addr;
+				void *src = phys_to_virt(bd.addr);
 				memcpy_fromio(skb_put(skb, size), src, size);
 				skb->protocol = eth_type_trans(skb, dev);
 				priv->stats.rx_packets++;
@@ -823,7 +822,7 @@ static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	else
 		bd.stat &= ~TX_BD_PAD;
 
-	dest = priv->membase + bd.addr;
+	dest = phys_to_virt(bd.addr);
 	memcpy_toio(dest, skb->data, skb->len);
 
 	bd.stat &= ~(TX_BD_STATS | TX_BD_LEN_MASK);
-- 
1.6.2.5


  reply	other threads:[~2009-10-05  8:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05  7:43 [PATCH 1/4] ethoc: fix typo to compute number of tx descriptors Thomas Chou
2009-10-05  7:43 ` Thomas Chou [this message]
2009-10-05  7:43   ` [PATCH 3/4] ethoc: align received packet to make IP header at word boundary Thomas Chou
2009-10-05  7:43     ` [PATCH 4/4] ethoc: use system memory as buffer Thomas Chou
2009-10-05  8:50 ` [PATCH 1/4] ethoc: fix typo to compute number of tx descriptors David Miller

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=1254728585-31964-2-git-send-email-thomas@wytron.com.tw \
    --to=thomas@wytron.com.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nios2-dev@sopc.et.ntust.edu.tw \
    --cc=thierry.reding@avionic-design.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

all inboxes | Powered by JetHome®