All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: jgarzik@pobox.com
Cc: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org
Subject: [PATCH 5/9] fs_enet: Align receive buffers.
Date: Thu, 20 Sep 2007 17:01:20 -0500	[thread overview]
Message-ID: <20070920220120.GE28784@loki.buserror.net> (raw)
In-Reply-To: <20070920220043.GA28769@loki.buserror.net>

At least some hardware driven by this driver needs receive buffers
to be aligned on a 16-byte boundary.  This usually happens by chance,
but it breaks if slab debugging is enabled.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 drivers/net/fs_enet/fs_enet-main.c |   21 +++++++++++++++++++--
 drivers/net/fs_enet/fs_enet.h      |    3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index da79a45..a4b76cd 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -69,6 +69,14 @@ static void fs_set_multicast_list(struct net_device *dev)
 	(*fep->ops->set_multicast_list)(dev);
 }
 
+static void skb_align(struct sk_buff *skb, int align)
+{
+	int off = ((unsigned long)skb->data) & (align - 1);
+
+	if (off)
+		skb_reserve(skb, align - off);
+}
+
 /* NAPI receive function */
 static int fs_enet_rx_napi(struct net_device *dev, int *budget)
 {
@@ -166,9 +174,13 @@ static int fs_enet_rx_napi(struct net_device *dev, int *budget)
 					skb = skbn;
 					skbn = skbt;
 				}
-			} else
+			} else {
 				skbn = dev_alloc_skb(ENET_RX_FRSIZE);
 
+				if (skbn)
+					skb_align(skbn, ENET_RX_ALIGN);
+			}
+
 			if (skbn != NULL) {
 				skb_put(skb, pkt_len);	/* Make room */
 				skb->protocol = eth_type_trans(skb, dev);
@@ -300,9 +312,13 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
 					skb = skbn;
 					skbn = skbt;
 				}
-			} else
+			} else {
 				skbn = dev_alloc_skb(ENET_RX_FRSIZE);
 
+				if (skbn)
+					skb_align(skbn, ENET_RX_ALIGN);
+			}
+
 			if (skbn != NULL) {
 				skb_put(skb, pkt_len);	/* Make room */
 				skb->protocol = eth_type_trans(skb, dev);
@@ -512,6 +528,7 @@ void fs_init_bds(struct net_device *dev)
 			       dev->name);
 			break;
 		}
+		skb_align(skb, ENET_RX_ALIGN);
 		fep->rx_skbuff[i] = skb;
 		CBDW_BUFADDR(bdp,
 			dma_map_single(fep->dev, skb->data,
diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h
index 72a61e9..f8c7ee8 100644
--- a/drivers/net/fs_enet/fs_enet.h
+++ b/drivers/net/fs_enet/fs_enet.h
@@ -82,7 +82,8 @@ struct phy_info {
 /* Must be a multiple of 32 (to cover both FEC & FCC) */
 #define PKT_MAXBLR_SIZE		((PKT_MAXBUF_SIZE + 31) & ~31)
 /* This is needed so that invalidate_xxx wont invalidate too much */
-#define ENET_RX_FRSIZE		L1_CACHE_ALIGN(PKT_MAXBUF_SIZE)
+#define ENET_RX_ALIGN  16
+#define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE + ENET_RX_ALIGN - 1)
 
 struct fs_enet_mii_bus {
 	struct list_head list;
-- 
1.5.3.1

  parent reply	other threads:[~2007-09-20 22:01 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-20 22:00 [PATCH 0/9] fs enet and mdio bitbang patches Scott Wood
2007-09-20 22:01 ` [PATCH 1/9] fs_enet: Whitespace cleanup Scott Wood
2007-09-29  5:21   ` Jeff Garzik
2007-09-20 22:01 ` [PATCH 2/9] fs_enet: Include linux/string.h from linux/fs_enet_pd.h Scott Wood
2007-09-20 22:01 ` [PATCH 3/9] fs_enet: Don't share the interrupt Scott Wood
2007-09-29  5:18   ` Jeff Garzik
2007-09-20 22:01 ` [PATCH 4/9] fs_enet: mac-fcc: Eliminate __fcc-* macros Scott Wood
2007-09-20 22:01 ` Scott Wood [this message]
2007-09-20 22:01 ` [PATCH 6/9] fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set Scott Wood
2007-09-21  0:08   ` Stephen Rothwell
2007-09-21  0:08     ` Stephen Rothwell
2007-09-21  0:44     ` Scott Wood
2007-09-21  0:44       ` Scott Wood
2007-10-02  7:10   ` Esben Haabendal
2008-02-15 12:50   ` Laurent Pinchart
2008-02-15 12:50     ` Laurent Pinchart
2008-02-15 15:38     ` Sergej Stepanov
2008-02-15 15:38       ` Sergej Stepanov
2008-03-07 15:23       ` Laurent Pinchart
2008-03-07 15:23         ` Laurent Pinchart
2008-03-07 16:37         ` Scott Wood
2008-03-07 16:37           ` Scott Wood
2008-03-10  7:50           ` Sergej Stepanov
2008-03-10  7:50             ` Sergej Stepanov
2008-03-10 11:05             ` Laurent Pinchart
2008-03-10 13:17               ` Sergej Stepanov
2008-03-10 15:02               ` [PATCH v3] using mii-bitbang on different processor ports - update the booting-without-of.txt-file Sergej Stepanov
2007-09-20 22:01 ` [PATCH 7/9] Generic bitbanged MDIO library Scott Wood
2007-10-18 19:20   ` [PATCH] phy/bitbang: missing MODULE_LICENSE Randy Dunlap
2007-10-18 19:20     ` Randy Dunlap
2007-10-20  3:03     ` Jeff Garzik
2007-10-20  3:03       ` Jeff Garzik
2007-09-20 22:01 ` [PATCH 8/9] fs_enet: Convert mii-bitbang to use the generic bitbang MDIO code Scott Wood
2007-09-20 22:01 ` [PATCH 9/9] fs_enet: sparse fixes Scott Wood
  -- strict thread matches above, loose matches on Subject: below --
2007-10-01 19:20 [PATCH 1/9] fs_enet: Whitespace cleanup Scott Wood
2007-10-01 19:20 ` [PATCH 5/9] fs_enet: Align receive buffers Scott Wood

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=20070920220120.GE28784@loki.buserror.net \
    --to=scottwood@freescale.com \
    --cc=jgarzik@pobox.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=netdev@vger.kernel.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 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.