I/O space write barrier
include/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 line 204
Quoted 12 lines
diff -Nru
a/include/asm-ppc/io.hb/include/asm-ppc/io.hinclude/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 +2
-0@@ -197,6 +197,8 @@ #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c)) +#define mmiowb() asm volatile ("eieio" ::: "memory") + /* * Map in an area of physical address space, for accessing * I/O devices etc.
I don't think this is right. For ppc, eieio is already included as part of the assembly for the IO operations. If you could delete that, great, but I suspect that nearly all drivers would break.
There's an existing eieio() inline function that you could use, instead of fresh assembly code.
BTW, the "eieio" name is better. The "wb" part of "mmiowb" looks like "write back" to me, as if it were some sort of cache push operation. It is also lacking an appropriate song. :-)
Quoted 7 lines · Albert Cahalan
Quoted 7 lines
diff -Nru
a/include/asm-ppc/io.hb/include/asm-ppc/io.hinclude/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 +0
-0@@ -197,6 +197,8 @@ #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
Quoted 10 lines
include/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 line 204
Quoted 5 lines
include/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 +2
-0+#define mmiowb() asm volatile ("eieio" ::: "memory") + /* * Map in an area of physical address space, for accessing * I/O devices etc.I don't think this is right. For ppc, eieio is already included as part of the assembly for the IO operations. If you could delete that, great, but I suspect that nearly all drivers would break.
Ok, if it's covered than mmiowb() can just be empty for ppc.
Quoted 4 lines
BTW, the "eieio" name is better. The "wb" part of "mmiowb" looks like "write back" to me, as if it were some sort of cache push operation. It is also lacking an appropriate song. :-)
It's supposed to be 'write barrier' just like wmb is a write memory barrier, so is mmiowb a memory-mapped I/O write barrier. Make sense?
Thanks,
Jesse
Quoted 19 lines · Jesse Barnes
Quoted 7 lines · Albert Cahalan
Quoted 7 lines
diff -Nru
a/include/asm-ppc/io.hb/include/asm-ppc/io.hinclude/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 +0
-0@@ -197,6 +197,8 @@ #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))Quoted 10 lines
include/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 line 204
Quoted 5 lines
include/asm-ppc/io.h 2004-09-27 10:48:41 -07:00 +2
-0+#define mmiowb() asm volatile ("eieio" ::: "memory") + /* * Map in an area of physical address space, for accessing * I/O devices etc.I don't think this is right. For ppc, eieio is already included as part of the assembly for the IO operations. If you could delete that, great, but I suspect that nearly all drivers would break.
Quoted 1 line
Ok, if it's covered than
mmiowb()can just be empty for ppc.
Ideally, it would be eieio, and the eieio in each of the IO operations would be removed. Finding and fixing all the drivers that break looks impossible though; most driver developers will be on x86 boxes.
Quoted 7 lines
Quoted 4 lines
BTW, the "eieio" name is better. The "wb" part of "mmiowb" looks like "write back" to me, as if it were some sort of cache push operation. It is also lacking an appropriate song. :-)
It's supposed to be 'write barrier' just like wmb is a write memory barrier, so is mmiowb a memory-mapped I/O write barrier. Make sense?
In that case: wmmiob
(or something longer, like mmio_write_fence maybe)
As a name, "wmb" sucks almost as much as "cli" and "sti" do. It dates back to the Alpha port, where it's an opcode.
Quoted 4 lines · Albert Cahalan
Ideally, it would be eieio, and the eieio in each of the IO operations would be removed. Finding and fixing all the drivers that break looks impossible though; most driver developers will be on x86 boxes.
I don't agree. IO operations shouldn't be relaxed by default. That's really asking too much of driver writers
Ben.
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 4 lines · Albert Cahalan
Ideally, it would be eieio, and the eieio in each of the IO operations would be removed. Finding and fixing all the drivers that break looks impossible though; most driver developers will be on x86 boxes.
I don't agree. IO operations shouldn't be relaxed by default. That's really asking too much of driver writers
I agree, it's hard to get right, especially when you've got a large base of drivers with hard to find assumptions about ordering.
What about mmiowb()? Should it be eieio? I don't want to post another patch if I don't have to...
Thanks,
Jesse
Quoted 6 lines
I agree, it's hard to get right, especially when you've got a large base of drivers with hard to find assumptions about ordering.
What about
mmiowb()? Should it be eieio? I don't want to post another patch if I don't have to...
I don't understand the whole story...
If normal accesses aren't relaxed (and I think they shouldn't be), then there is no point in a barrier here.... If you need an explicit barrier for explicitely relaxed accesses, then yes.
That doesn't solve my need of MMIO vs. memory unless you are trying to cover that as well, in which case it should be a sync.
Ben.
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 5 lines
I agree, it's hard to get right, especially when you've got a large base of drivers with hard to find assumptions about ordering.
What about
mmiowb()? Should it be eieio? I don't want to post another patch if I don't have to...I don't understand the whole story...
If normal accesses aren't relaxed (and I think they shouldn't be), then there is no point in a barrier here.... If you need an explicit barrier for explicitely relaxed accesses, then yes.
This macro is only supposed to deal with writes from different CPUs that may arrive out of order, nothing else. It sounds like PPC won't allow that normally, so I can be an empty definition.
Quoted 2 lines
That doesn't solve my need of MMIO vs. memory unless you are trying to cover that as well, in which case it should be a sync.
No, I think that has to be covered separately.
Jesse
Quoted 3 lines · Jesse Barnes
This macro is only supposed to deal with writes from different CPUs that may arrive out of order, nothing else. It sounds like PPC won't allow that normally, so I can be an empty definition.
I don't understand that neither. You can never guarantee any ordering between writes from different CPUs unless you have a sinlock. If you have an ordering problem with spinlocks, then it's a totally different issue, a bit more like MMIO vs. cacheable mem that we have on PPC. If this is the problem you are trying to chase, then we could use such a barrier on ppc too and make it a hard sync, but it has nothing to do with the write barrier we already have in our IO accessors...
Quoted 4 lines
Quoted 2 lines
That doesn't solve my need of MMIO vs. memory unless you are trying to cover that as well, in which case it should be a sync.
No, I think that has to be covered separately.
How so ? Again, this whole "ordering of writes between different CPU" makes absolutely no sense to me.
Ben.
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 3 lines · Jesse Barnes
This macro is only supposed to deal with writes from different CPUs that may arrive out of order, nothing else. It sounds like PPC won't allow that normally, so I can be an empty definition.
I don't understand that neither. You can never guarantee any ordering between writes from different CPUs unless you have a sinlock. If you have an ordering problem with spinlocks, then it's a totally different issue, a bit more like MMIO vs. cacheable mem that we have on PPC.
Right.
Quoted 4 lines
If
this is the problem you are trying to chase, then we could use such a barrier on ppc too and make it a hard sync, but it has nothing to do with the write barrier we already have in our IO accessors...
Ok.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
That doesn't solve my need of MMIO vs. memory unless you are trying to cover that as well, in which case it should be a sync.
No, I think that has to be covered separately.
How so ? Again, this whole "ordering of writes between different CPU" makes absolutely no sense to me.
It's like you said above. I meant that ordering of writes to I/O space and memory space should be dealt with differently on PPC, as you've said before. I guess you need new barrier types for that?
Jesse
Benjamin> I don't understand that neither. You can never guarantee Benjamin> any ordering between writes from different CPUs unless Benjamin> you have a sinlock. If you have an ordering problem with Benjamin> spinlocks, then it's a totally different issue, a bit Benjamin> more like MMIO vs. cacheable mem that we have on PPC. If Benjamin> this is the problem you are trying to chase, then we Benjamin> could use such a barrier on ppc too and make it a hard Benjamin> sync, but it has nothing to do with the write barrier we Benjamin> already have in our IO accessors...
As I understand it, the problem is that on some Itanium boxes, it's possible to have the following code run:
CPU 1 CPU 2
spin_lock(&devlock);
writel(foo);
spin_unlock(&devlock);
spin_lock(&devlock);
writel(bar);
spin_unlock(&devlock);and still have bar arrive at the device before foo. One possibility would be to add a read after the writel() to flush the posted write. The proposed mmiowb() function is somewhat lighter weight -- it guarantees that later writes will not hit the device before any writes already issued, but it doesn't say anything about writes making it all the way to the device.
I could be wrong but I think that the eieio in the ppc IO write functions should be strong enough that mmiowb() can be a no-op.
By the way, are the ordering rules different for ppc32 and ppc64? I notice that the ppc32 out_xxx() functions do eieio while the ppc64 versions do a full sync.
Thanks,
Roland
Quoted 6 lines · Roland Dreier
I could be wrong but I think that the eieio in the ppc IO write functions should be strong enough that
mmiowb()can be a no-op.By the way, are the ordering rules different for ppc32 and ppc64? I notice that the ppc32
out_xxx()functions do eieio while the ppc64 versions do a full sync.
ppc32 and ppc64 are identical by spec, but the current chips smaller store queues are such that we didn't epxerience on ppc32 the amount of issues we had on ppc64.
eieio will not order a cacheable store vs. a non-cacheable store by spec, which is the root of our problem on ppc and why we had to change some of these into sync's. Extended the semantics of mmiowb() to a more generic ordering of MMIO vs. "the rest of the world" would help us as I don't beleive in defining yet-another barrier and have it properly used by device driver writers.
Ben.
Quoted 4 lines · Albert Cahalan
Ideally, it would be eieio, and the eieio in each of the IO operations would be removed. Finding and fixing all the drivers that break looks impossible though; most driver developers will be on x86 boxes.
Well, I won't pretend to understand how the PPC ordering rules work, so I'll defer to benh on that one.
Quoted 6 lines
In that case: wmmiob
(or something longer, like
mmio_write_fencemaybe)As a name, "wmb" sucks almost as much as "cli" and "sti" do. It dates back to the Alpha port, where it's an opcode.
The other option I briefly considered was wwjd(), but I don't think He has an official position on posted write ordering.
Jesse