From: "H. Peter Anvin" <hpa@zytor.com>
To: Chuck Ebbert <76306.1226@compuserve.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Chris Lesiak <chris.lesiak@licor.com>,
Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>
Subject: Re: [patch 2.6.17-rc5 1/2] i386 memcpy: use as few moves as possible for I/O
Date: Tue, 30 May 2006 20:42:12 -0700 [thread overview]
Message-ID: <447D1094.20409@zytor.com> (raw)
In-Reply-To: <200605302103_MC3-1-BF0E-59B@compuserve.com>
[-- Attachment #1: Type: text/plain, Size: 978 bytes --]
Chuck Ebbert wrote:
> Chris Lesiak reported that changes to i386's __memcpy() broke his device
> because it can't handle byte moves and the new code uses them for
> all trailing bytes when the length is not divisible by four. The old
> code tried to use a 16-bit move and/or a byte move as needed.
>
> H. Peter Anvin:
> "There are only a few semantics that make sense: fixed 8, 16, 32, or 64
> bits, plus "optimal"; the latter to be used for anything that doesn't
> require a specific transfer size. Logically, an unqualified
> "memcpy_to/fromio" should be the optimal size (as few transfers as
> possible)"
>
> So add back the old code as __minimal_memcpy and have IO transfers
> use that.
>
I was thinking some more about that, and I suspect the "right" way to do
this looks something like the attached code. Note that it assymetric,
and that it's probably too long to inline.
I haven't tested this yet, and I probably won't have time to do so this
evening.
-hpa
[-- Attachment #2: memcpy_io.S --]
[-- Type: text/plain, Size: 1443 bytes --]
/*
* arch/i386/lib/memcpy_io.S
*
* The most general form of memory copy to/from I/O space, used for
* devices which can handle arbitrary transactions with appropriate
* handling of byte enables. The goal is to produce the minimum
* number of naturally aligned transactions on the bus.
*/
#include <linux/config.h>
.globl memcpy_toio
.type memcpy_toio, @function
memcpy_toio:
pushl %edi
pushl %esi
#ifdef CONFIG_REGPARM
movl %eax, %edi
movl %edx, %esi
#else
movl 12(%esp), %eax
movl 16(%esp), %edx
movl 20(%esp), %ecx
#endif
jecxz 1f
testl $1, %edi
jz 2f
movsb
decl %ecx
2:
cmpl $2, %ecx
jb 3f
testl $2, %edi
jz 4f
movsw
decl %ecx
decl %ecx
4:
movl %ecx, %edx
shrl $2, %ecx
jz 5f
rep ; movsl
5:
movl %edx, %ecx
testb $2, %cl
jz 3f
movsw
3:
testb $1, %cl
jz 1f
movsb
1:
pop %esi
pop %edi
ret
.size memcpy_toio, .-memcpy_toio
.globl memcpy_toio
.type memcpy_fromio, @function
memcpy_fromio:
pushl %edi
pushl %esi
#ifdef CONFIG_REGPARM
movl %eax, %edi
movl %edx, %esi
#else
movl 12(%esp), %eax
movl 16(%esp), %edx
movl 20(%esp), %ecx
#endif
jecxz 1f
testl $1, %esi
jz 2f
movsb
decl %ecx
2:
cmpl $2, %ecx
jb 3f
testl $2, %esi
jz 4f
movsw
decl %ecx
decl %ecx
4:
movl %ecx, %edx
shrl $2, %ecx
jz 5f
rep ; movsl
5:
movl %edx, %ecx
testb $2, %cl
jz 3f
movsw
3:
testb $1, %cl
jz 1f
movsb
1:
pop %esi
pop %edi
ret
.size memcpy_fromio, .-memcpy_fromio
next prev parent reply other threads:[~2006-05-31 3:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-31 0:59 [patch 2.6.17-rc5 1/2] i386 memcpy: use as few moves as possible for I/O Chuck Ebbert
2006-05-31 1:36 ` H. Peter Anvin
2006-05-31 3:42 ` H. Peter Anvin [this message]
2006-05-31 11:39 ` linux-os (Dick Johnson)
-- strict thread matches above, loose matches on Subject: below --
2006-05-31 23:01 Chuck Ebbert
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=447D1094.20409@zytor.com \
--to=hpa@zytor.com \
--cc=76306.1226@compuserve.com \
--cc=akpm@osdl.org \
--cc=chris.lesiak@licor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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