From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/5] net i.MX fec: make multi instance safe
Date: Thu, 28 Jul 2011 12:08:29 +0200 [thread overview]
Message-ID: <1311847712-23515-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1311847712-23515-1-git-send-email-s.hauer@pengutronix.de>
The driver uses a static int once variable to alloc the
rx packets. remove this to make the driver multi instance
safe. While at it, remove the crappy selfmade alignment.
dma_alloc_coherent returns sufficiently aligned memory.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/fec_imx.c | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index fcb8cc5..552d281 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -200,25 +200,11 @@ static void imx28_fix_endianess_rd(uint32_t *buf, unsigned wlen)
static int fec_rbd_init(struct fec_priv *fec, int count, int size)
{
int ix;
- static int once = 0;
- unsigned long p = 0;
-
- if (!once) {
- /* reserve data memory and consider alignment */
- p = (unsigned long)dma_alloc_coherent(size * count + DB_DATA_ALIGNMENT);
- p += DB_DATA_ALIGNMENT - 1;
- p &= ~(DB_DATA_ALIGNMENT - 1);
- }
for (ix = 0; ix < count; ix++) {
- if (!once) {
- writel(virt_to_phys((void *)p), &fec->rbd_base[ix].data_pointer);
- p += size;
- }
writew(FEC_RBD_EMPTY, &fec->rbd_base[ix].status);
writew(0, &fec->rbd_base[ix].data_length);
}
- once = 1; /* malloc done now (and once) */
/*
* mark the last RBD to close the ring
*/
@@ -592,6 +578,24 @@ static int fec_recv(struct eth_device *dev)
return len;
}
+static int fec_alloc_receive_packets(struct fec_priv *fec, int count, int size)
+{
+ void *p;
+ int i;
+
+ /* reserve data memory and consider alignment */
+ p = dma_alloc_coherent(size * count);
+ if (!p)
+ return -ENOMEM;
+
+ for (i = 0; i < count; i++) {
+ writel(virt_to_phys(p), &fec->rbd_base[i].data_pointer);
+ p += size;
+ }
+
+ return 0;
+}
+
static int fec_probe(struct device_d *dev)
{
struct fec_platform_data *pdata = (struct fec_platform_data *)dev->platform_data;
@@ -638,6 +642,8 @@ static int fec_probe(struct device_d *dev)
writel((uint32_t)virt_to_phys(fec->tbd_base), fec->regs + FEC_ETDSR);
writel((uint32_t)virt_to_phys(fec->rbd_base), fec->regs + FEC_ERDSR);
+ fec_alloc_receive_packets(fec, FEC_RBD_NUM, FEC_MAX_PKT_SIZE);
+
fec->xcv_type = pdata->xcv_type;
if (fec->xcv_type != SEVENWIRE) {
--
1.7.5.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-07-28 10:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 10:08 i.MX fec cleanup Sascha Hauer
2011-07-28 10:08 ` [PATCH 1/5] ARM dma_alloc_coherent: Fix alignment for !MMU case Sascha Hauer
2011-07-28 10:08 ` Sascha Hauer [this message]
2011-07-28 10:08 ` [PATCH 3/5] net i.MX fec: remove unnecessary alignment Sascha Hauer
2011-07-28 10:08 ` [PATCH 4/5] net i.MX fec: embed ethernet device into priv Sascha Hauer
2011-07-28 10:08 ` [PATCH 5/5] net i.MX fec: rename driver struct to be generic 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=1311847712-23515-3-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.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