From: Carsten Jacobi <carsten@ccac.rwth-aachen.de>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Florian Fainelli <florian.fainelli@telecomint.eu>,
netdev@vger.kernel.org
Subject: Re: [PATCH] lne390 and Jensen Alphas
Date: Sun, 20 Apr 2008 14:54:01 +0200 [thread overview]
Message-ID: <480B3CE9.7050901@ccac.rwth-aachen.de> (raw)
In-Reply-To: <20080413221144.GR9785@ZenIV.linux.org.uk>
Hello,
first thanks for the feedback, I am still willing to deliver
a "decent" patch.
Al Viro wrote:
> The last argument of __raw_writel() is void __iomem *, not unsigned long.
> WTF is that cast doing that? Besides, it looks like misspelled
> const __le32 *from = buf;
> ...
> __raw_writel(get_unaligned(from), shmem);
>
>
Tststs ... such strong words. But I see your point. As I look at it
myself it doesn't appear to be clean style.
>> + (unsigned long) shmem += 4;
>>
>
> Write in C, please. This isn't - you might as well write something like
> shmem * 2 -= 4;
> since result of cast is not an l-value.
>
I admit this must be done using appropriate types. The patch was
originally intended for kernel version 2.1.115 in 1998 and I just come
back with it every 5 years because it haven't made it into the official
source so far. Actually, I just took the memcpy_toio() function from
arch/alpha/lib/io.c did some modifications to let it read from unaligned
addresses and then just pasted it into the lne390.c source.
But for an official patch it should look better. Hmm, the
get_unaligned(from) function seems indeed to be exactly what I need
here. I guess that wasn't available 10 years before when I writed the
original patch.
> Finally, how much of that actually depends on Jensen and how much is
> actually "oh, on x86 we use rep movsl in memcpy_toio(), so it ends up
> with 32bit accesses"?
>
Only the lne390_block_output() routine has to be adjusted for all
systems that have EISA slots and which use a memcpy_toio() function that
copies 16bit aligned addresses with 16bit operations. I can't tell at
once which other systems than CONFIG_ALPHA_JENSEN would match here. I
guess HPPA and Silicon-Graphics (are there MIPS systems with EISA
slots?) would be candidates.
The other #ifdef allows choosing arbitrary memory spaces for the shared
mem buffer of the adapter. Also here I don't know how other non-x86
architectures map the EISA memory space into their CPU address space.
Here is my next patch. I have removed the misleading casts. I have taken
the memcpy_toio() function from arch/alpha/kernel/io.c (as I see the
source file has moved from lib/ to kernel/) and did my little
modification again:
--- lne390.c.orig 2008-04-20 14:25:32.000000000 +0200
+++ lne390.c 2008-04-20 14:49:21.000000000 +0200
@@ -242,6 +242,10 @@
printk("%dkB memory at physical address %#lx\n",
LNE390_STOP_PG/4, dev->mem_start);
+#ifdef CONFIG_ALPHA_JENSEN
+ /* On the Jensen board EISA cards will see their own address
+ * space */
+#else
/*
BEWARE!! Some dain-bramaged EISA SCUs will allow you to put
the card mem within the region covered by `normal' RAM !!!
@@ -260,6 +264,7 @@
LNE390_STOP_PG/4, ei_status.mem);
dev->mem_start = (unsigned long)ei_status.mem;
+#endif /* CONFIG_ALPHA_JENSEN */
dev->mem_end = dev->mem_start + (LNE390_STOP_PG -
LNE390_START_PG)*256;
/* The 8390 offset is zero for the LNE390 */
@@ -372,7 +377,25 @@
void __iomem *shmem = ei_status.mem + ((start_page -
LNE390_START_PG)<<8);
count = (count + 3) & ~3; /* Round up to doubleword */
+#ifndef CONFIG_ALPHA_JENSEN
memcpy_toio(shmem, buf, count);
+#else
+ /* The mylex lne390 adapter requires 32bit access (see above)
for every
+ * operation to the shared mem buffer. Since the block buffer is
hardly
+ * aligned to a 32bit boundary memcpy_toio() will use 16bit
+ * operations to access the buffer on alpha architectures (maybe
also
+ * for others ... we must use something else here. */
+
+ const void *from = buf;
+ count -= 4;
+ do {
+ __raw_writel(*(const u32 *)get_unaligned(from), shmem);
+ count -= 4;
+ shmem += 4;
+ from += 4;
+ } while (count >= 0);
+#endif
+
}
static int lne390_open(struct net_device *dev)
Regards,
Carsten Jacobi
prev parent reply other threads:[~2008-04-20 12:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-29 14:48 [PATCH] lne390 and Jensen Alphas Carsten Jacobi
2008-03-29 18:32 ` Florian Fainelli
2008-04-13 21:06 ` Carsten Jacobi
2008-04-13 22:11 ` Al Viro
2008-04-20 12:54 ` Carsten Jacobi [this message]
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=480B3CE9.7050901@ccac.rwth-aachen.de \
--to=carsten@ccac.rwth-aachen.de \
--cc=florian.fainelli@telecomint.eu \
--cc=netdev@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).