From: "H. Peter Anvin" <hpa@zytor.com>
To: "John A. Gregor" <john.gregor@qlogic.com>
Cc: ralph.campbell@qlogic.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86_64/__iowrite32_copy: don't use string move for PIO writes
Date: Mon, 06 Jul 2009 17:03:17 -0700 [thread overview]
Message-ID: <4A5290C5.5040905@zytor.com> (raw)
In-Reply-To: <4a528c40.zpEvWzPTM5aCPBai%john.gregor@qlogic.com>
John A. Gregor wrote:
>
>> It's probably also worth nothing that with this change, there probably
>> is little point in writing this in assembly at all. This is especially
>> so since your implementation is buggy: by definition, __iowrite32_copy()
>> does the I/O operations 32 bits at a time, but you are using 64-bit
>> operations.
>
> The point of the routine is to make sure that transfers are *at least*
> 32-bit aligned and *at least* multiples of 32-bits in length. 64-bit
> transfers meet those conditions.
No. That may be what *you* want, but that's not what the function is
documented or specified to do.
/**
* __iowrite32_copy - copy data to MMIO space, in 32-bit units
* @to: destination, in MMIO space (must be 32-bit aligned)
* @from: source (must be 32-bit aligned)
* @count: number of 32-bit quantities to copy
*
* Copy data from kernel space to MMIO space, in units of 32 bits at a
* time. Order of access is not guaranteed, nor is a memory barrier
* performed afterwards.
*/
That is the generic version and the documented ABI, which the x86
version must mimic. This is not the function to use if you don't care
about access size, which you better not if you're accessing WC memory.
> Another, less clearly stated, condition (which is imposed by the adapter
> the code was written for(*)) is that we can't take multiple writes
> to the same memory location (i.e. the number of dwords written to the
> adapter's buffer must == the number of dwords in the transfer). It is
> this condition that rep mov doesn't always respect. It appears that
> (possibly due to the processor taking an interrupt) the rep mov can
> "back up" and redo part of the transfer. We've gotten PCIe analyzer
> traces that confirm this behavior.
[...]
> See above, 8-byte alignment and transfers (being a subset of 4-byte
> alignments) are fine. Since we are writing into a WC space, we don't
> have control over how many dwords get stuck together in a transfer
> anyway.
If you're doing this to WC memory, I believe your driver (or hardware)
is broken. WC does not guarantee this condition to the best of my
knowledge, although I haven't found anything that explicitly states that
WC memory has to be idempotent (it is documented, though, that it can
collapse stores to the same address, so it might have been considered a
resulting issue.)
Anyway, I'm fine simply removing the x86 assembly version of this
routine and simply using the generic routine. The checkin should
reference the observed behavior (which I would also suggest escalating
via your Intel FAEs if you can; I can try to investigate internally as
well.) If you want 64-bit transfers, you should use __iowrite64_copy();
if you want completely private behavior you should use your own routine
(and just write it in C) rather than changing the documented behavior of
an existing routine from one that might be useful for other drivers
(although currently aren't used as far as I can tell) to one which is
guaranteed not to be.
-hpa
-hpa
next prev parent reply other threads:[~2009-07-07 0:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-06 19:07 John Gregor
2009-07-06 21:30 ` H. Peter Anvin
2009-07-06 21:36 ` John A. Gregor
2009-07-06 22:47 ` H. Peter Anvin
2009-07-06 23:44 ` John A. Gregor
2009-07-07 0:03 ` H. Peter Anvin [this message]
2009-07-07 16:06 ` John A. Gregor
2009-07-08 0:46 ` H. Peter Anvin
2009-07-09 23:19 ` Pavel Machek
2009-07-10 15:07 ` H. Peter Anvin
2009-07-10 16:02 ` Lu, Hongjiu
2009-07-06 21:41 ` John A. Gregor
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=4A5290C5.5040905@zytor.com \
--to=hpa@zytor.com \
--cc=john.gregor@qlogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ralph.campbell@qlogic.com \
/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
Powered by JetHome