Re: RFC: outb 0x80 in inb_p, outb_p harmful on some modern AMD64 with MCP51 laptops

David Newall
2007-12-12T22:19:12Z

Alan Cox wrote:
>> without need. Not surprising since it has such a vague specific
>> meaning. One could say, Linux on i386 is liberally sprinkled with
>>
>
> "vague specific" ? sorry don't follow you.
>

The _p variants are a universal fixture, defined as ending with a pause,
but without specifying the duration. (The duration is architecture
specific, mostly zero.) It really isn't a form that should be used in
generic code.

>> I really prefer accurate code, but I'm also pragmatic and realise that
>> it's far too much work to fix this any time soon. But if it were to be
>> fixed, then perhaps _p would take an additional parameter, measured in
>> cycles of delay.
>>
>
> measured in what, against what, for which bus.
>
> inb_p/outb_p are really only meaningful for ISA/LPC bus devices. In those
> cases it is precisely defined. Its use for PCI devices is a bit suspect
> and as a general rule probably wrong.

Yes, it's now clear that all of this is so. Regrettably, it's used in
dozens of drivers, most having nothing to do with an ISA/LPC bus.

If it really is specific to the ISA architecture, then it should only be
used in architecture specific code.

I think the solution is to remove it. Replace all _p calls with the
non-_p variant, and add an explicit udelay. Udelay can initially be set
conservatively until it's been properly calibrated, allowing it to be
used during early boot. The good news is that it's only used in a few
dozen drivers, so that actually might be doable. And then, who knows,
maybe Microsoft might have to scratch their corporate heads, trying to
find out how to compete with a suddenly much faster Linux! :-p