Many drivers use in_be16(), in_be32(), out_be16(), out_be32(), etc .... to access to registrers in IO mapped memory.
What is the real purpose of those functions, and are they really needed ?
ioremap() maps the related areas as GUARDED, which means that accesses can't be speculative. So what is the benefit of using in_beXX() and out_beXX() over simple memory accesses in the area ?
Christophe
RnJvbTogbGVyb3kgY2hyaXN0b3BoZQ0KPiBNYW55IGRyaXZlcnMgdXNlIGluX2JlMTYoKSwgaW5f
YmUzMigpLCBvdXRfYmUxNigpLCBvdXRfYmUzMigpLCBldGMgLi4uLg0KPiB0byBhY2Nlc3MgdG8g
cmVnaXN0cmVycyBpbiBJTyBtYXBwZWQgbWVtb3J5Lg0KPiANCj4gV2hhdCBpcyB0aGUgcmVhbCBw
dXJwb3NlIG9mIHRob3NlIGZ1bmN0aW9ucywgYW5kIGFyZSB0aGV5IHJlYWxseSBuZWVkZWQgPw0K
PiANCj4gaW9yZW1hcCgpIG1hcHMgdGhlIHJlbGF0ZWQgYXJlYXMgYXMgR1VBUkRFRCwgd2hpY2gg
bWVhbnMgdGhhdCBhY2Nlc3Nlcw0KPiBjYW4ndCBiZSBzcGVjdWxhdGl2ZS4gU28gd2hhdCBpcyB0
aGUgYmVuZWZpdCBvZiB1c2luZyBpbl9iZVhYKCkgYW5kDQo+IG91dF9iZVhYKCkgb3ZlciBzaW1w
bGUgbWVtb3J5IGFjY2Vzc2VzIGluIHRoZSBhcmVhID8NCg0KU29tZSBhcmNoaXRlY3R1cmVzIG1p
Z2h0IG5lZWQgdG8gdXNlIHNwZWNpZmljIGluc3RydWN0aW9uIHRvIGFjY2Vzcw0KaW8gc3BhY2Ug
KGVnIHNwYXJjIG1pZ2h0IG5lZWQgdG8gc3VwcGx5IGEgc3BlY2lmaWMgJ2FkZHJlc3MgbW9kaWZp
ZXInKS4NCg0KU3BlY2lhbCBpbnN0cnVjdGlvbnMgbWlnaHQgYmUgbmVlZGVkIHRvIHBlcmZvcm0g
YSAnYmlnIGVuZGlhbicgYWNjZXNzLg0KDQpVbmZvcnR1bmF0ZWx5IHRoZSBmdW5jdGlvbnMgc29t
ZXRpbWVzIGNvbnRhaW4gYWRkaXRpb25hbCAob2Z0ZW4gdW5uZWVkZWQpDQpzZXF1ZW5jaW5nIGlu
c3RydWN0aW9ucyAtIHRoZSBkcml2ZXIgbWF5IGJlIGFibGUgdG8gcGVyZm9ybSBtdWx0aXBsZQ0K
b3BlcmF0aW9ucyBiZXR3ZWVuIHRoZSBzZXF1ZW5jaW5nIGluc3RydWN0aW9ucy4NCg0KCURhdmlk
DQoNCg==
On Mon, 2014-10-27 at 13:52 +0100, leroy christophe wrote:
Many drivers use in_be16(), in_be32(), out_be16(), out_be32(), etc ....
to access to registrers in IO mapped memory.
What is the real purpose of those functions, and are they really needed ?
ioremap() maps the related areas as GUARDED, which means that accesses
can't be speculative. So what is the benefit of using in_beXX() and
out_beXX() over simple memory accesses in the area ?
Speculative accesses aren't the only issue -- there's also hardware
reordering (some implementations may not do this on guarded regions, but
I don't think it's architecturally guaranteed), and of course you need
to make sure the compiler doesn't do anything funny.
-Scott
On Mon, 2014-10-27 at 15:05 +0000, David Laight wrote:
Unfortunately the functions sometimes contain additional (often
unneeded)
sequencing instructions - the driver may be able to perform multiple
operations between the sequencing instructions.
That's in part why some folks are working on proper relaxed accessors
(see Will Deacon's stuff)
Cheers,
Ben.