From: Matthew Wilcox <matthew@wil.cx>
To: Helge Deller <deller@gmx.de>
Cc: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] memcpy_fromio() seems partially broken [with patch]
Date: Sat, 9 Jun 2001 02:39:17 +0100 [thread overview]
Message-ID: <20010609023917.C28264@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20010608213850.B827A482A@dsl2.external.hp.com>; from deller@gmx.de on Fri, Jun 08, 2001 at 11:37:31PM +0200
On Fri, Jun 08, 2001 at 11:37:31PM +0200, Helge Deller wrote:
> while I was playing with a few network-cards in the c3k I found a strange
> behaviour when copying unaligned data with memcpy_fromio() off the PCI bus.
>
> Background:
> I wanted to copy data off the network-card (HP J2585A) from an 4-byte aligned
> PCI address to an 2-byte aligned (b/c of skb_reserve(skb, 2)) memory-address
> with memcpy_fromio().
> The current code in CVS for memcpy_fromio() copied byteswapped and/or
> completely wrong data for all copied values, while the following
> memcpy_fromio() worked without problems:
This is very bizarre. Following the codepaths, the current code does:
if (((unsigned long)dest & 3) != (src & 3))
goto bytecopy;
bytecopy:
while (count--) {
*(char *)dest = readb(src++);
((char *)dest)++;
}
and i don't see how that can possibly do byteswapping. unless byteswapping
is necessary and this code is failing to do that? Your code is doing:
if (((unsigned long)dest & 3) != (src & 3))
goto wordcopy;
wordcopy:
if (src & 3)
goto bytecopy;
wordcopy_loop:
value = readl(src);
*((char*)dest) = (char) (value >> 24); dest++;
if (--count == 0) return;
*((char*)dest) = (char) (value >> 16); dest++;
if (--count == 0) return;
*((char*)dest) = (char) (value >> 8); dest++;
if (--count == 0) return;
*((char*)dest) = (char) (value); dest++;
if (count) goto wordcopy_loop;
return;
which is doing a byteswap on the value returned from readl! This seems
pretty grotesque to me. I want to hear from someone (eg grant) who can
say what's actually going on here..
--
Revolutions do not require corporate support.
next prev parent reply other threads:[~2001-06-09 1:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-08 21:37 [parisc-linux] memcpy_fromio() seems partially broken [with patch] Helge Deller
2001-06-09 1:39 ` Matthew Wilcox [this message]
2001-06-11 0:03 ` Grant Grundler
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=20010609023917.C28264@parcelfarce.linux.theplanet.co.uk \
--to=matthew@wil.cx \
--cc=deller@gmx.de \
--cc=parisc-linux@lists.parisc-linux.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.