From: Simon Kagstrom <simon.kagstrom@netinsight.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] [repost]: arm: kirkwood: See to it that sent data is 8-byte aligned
Date: Thu, 20 Aug 2009 10:14:11 +0200 [thread overview]
Message-ID: <20090820101411.6217f211@marrow.netinsight.se> (raw)
In-Reply-To: <20090820101142.6474a0fc@marrow.netinsight.se>
U-boot might use non-8-byte-aligned addresses for sending data, which
the kwgbe_send doesn't accept (bootp does this for me). This patch
copies the data to be sent to a malloced temporary buffer if it is
non-aligned.
v2: Malloc send buffer
v3: No need to use jumbo frames, use 1518 bytes buffer instead
v4: Correct alignment passed to memalign (should be 8!),
allocate buffer at initialization(), use PKTSIZE_ALIGN
Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
---
drivers/net/kirkwood_egiga.c | 21 +++++++++++++++++----
drivers/net/kirkwood_egiga.h | 1 +
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index 9f36633..479035d 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -500,18 +500,26 @@ static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
struct kwgbe_registers *regs = dkwgbe->regs;
struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
+ void *p = (void *)dataptr;
u32 cmd_sts;
+ /* Copy buffer if it's misaligned */
if ((u32) dataptr & 0x07) {
- printf("Err..(%s) xmit dataptr not 64bit aligned\n",
- __FUNCTION__);
- return -1;
+ if (datasize > PKTSIZE_ALIGN) {
+ printf("Non-aligned data too large (%d)\n",
+ datasize);
+ return -1;
+ }
+
+ memcpy(dkwgbe->p_aligned_txbuf, p, datasize);
+ p = dkwgbe->p_aligned_txbuf;
}
+
p_txdesc->cmd_sts = KWGBE_ZERO_PADDING | KWGBE_GEN_CRC;
p_txdesc->cmd_sts |= KWGBE_TX_FIRST_DESC | KWGBE_TX_LAST_DESC;
p_txdesc->cmd_sts |= KWGBE_BUFFER_OWNED_BY_DMA;
p_txdesc->cmd_sts |= KWGBE_TX_EN_INTERRUPT;
- p_txdesc->buf_ptr = (u8 *) dataptr;
+ p_txdesc->buf_ptr = (u8 *) p;
p_txdesc->byte_cnt = datasize;
/* Apply send command using zeroth RXUQ */
@@ -628,8 +636,13 @@ int kirkwood_egiga_initialize(bd_t * bis)
* PKTSIZE_ALIGN + 1)))
goto error3;
+ if (!(dkwgbe->p_aligned_txbuf = memalign(8, PKTSIZE_ALIGN)))
+ goto error4;
+
if (!(dkwgbe->p_txdesc = (struct kwgbe_txdesc *)
memalign(PKTALIGN, sizeof(struct kwgbe_txdesc) + 1))) {
+ free(dkwgbe->p_aligned_txbuf);
+ error4:
free(dkwgbe->p_rxbuf);
error3:
free(dkwgbe->p_rxdesc);
diff --git a/drivers/net/kirkwood_egiga.h b/drivers/net/kirkwood_egiga.h
index 9c893d1..16d5214 100644
--- a/drivers/net/kirkwood_egiga.h
+++ b/drivers/net/kirkwood_egiga.h
@@ -499,6 +499,7 @@ struct kwgbe_device {
struct kwgbe_rxdesc *p_rxdesc;
struct kwgbe_rxdesc *p_rxdesc_curr;
u8 *p_rxbuf;
+ u8 *p_aligned_txbuf;
};
#endif /* __EGIGA_H__ */
--
1.6.0.4
next prev parent reply other threads:[~2009-08-20 8:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 8:11 [U-Boot] [PATCH 0/3]: arm:Kirkwood network driver fixes Simon Kagstrom
2009-08-20 8:12 ` [U-Boot] [PATCH 1/3]: arm:kirkwood Define kirkwood phy address magic number Simon Kagstrom
2009-08-20 9:40 ` Prafulla Wadaskar
2009-08-20 11:47 ` Simon Kagstrom
2009-08-21 3:20 ` Prafulla Wadaskar
2009-08-21 8:52 ` Simon Kagstrom
2009-08-21 16:59 ` Ben Warren
2009-08-20 8:13 ` [U-Boot] [PATCH 2/3]: Wait for the link to come up on kirkwood network init Simon Kagstrom
2009-08-20 8:14 ` Simon Kagstrom [this message]
2009-08-20 9:25 ` [U-Boot] [PATCH 3/3] [repost]: arm: kirkwood: See to it that sent data is 8-byte aligned Prafulla Wadaskar
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=20090820101411.6217f211@marrow.netinsight.se \
--to=simon.kagstrom@netinsight.net \
--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 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.