Re: Specifying properly the PCI driver model on all linux architectur

Jeff Garzik (jgarzik@mandrakesoft.com)
Tue, 02 Nov 1999 13:55:39 -0500


Bret Indrelee wrote:
> I've been reading documentation and this list for the past 3 months. The
> problem is that there is a lot of conflicting documentation, spread between
> even more locations. Even the sources aren't always helpful, considering how
> lightly commented they are and how much of this area is architechure
> dependent.

c'est la vie this is a development kernel. It will always be a problem
that hackers want to hack not write docs. As Alan said, wrong docs are
a bug. The source will always be the best docs...

> In the 2.3 version of pci.txt (as viewed on kernel.org, since I don't have a
> local copy) it makes reference to needing to call pci_set_master(). What (if
> anything) do you have to do on a 2.2 kernel if you have a bus mastering
> device? What LINUX_VERSION_CODE added this new routine?

Well, to answer the specific question first, pci_set_master is in 2.2.x,
so presumeably you can call that, on 2.2.x and 2.3.x.

But... when docs for 2.3.x claim something, that never implies the same
on a previous version of the kernel. In general, Linus wants the
kernel, code and docs, to be forwarding looking and not contain a lot of
back compatibility cruft. Back compatibility is not evil, but for many
issues you cannot fully take advantages of new advances and fixes while
still being source compatible with older code.

> Based on a lot of reading between the lines, I believe you do not have to
> ever call check_region() or region_request() to claim your PCI address
> space. I think these routines are only used for ISA.

No. For I/O port addresses, you use {check,request}_region. For MMIO
addresses, you use {check,request}_mem_region. You _must_ do this.
Many old drivers do not do this, and this is also a bug. I dream of a
kernel with perfect resource allocation ;-) You can do lots of cool
things.

> Rules recently changed with respect to changing task state. Based on some
> bugs on MP systems, I believe you are now always supposed to use
> set_state(TASK_INTERRUPTIBLE);
> instead of
> current->state = TASK_INTERRUPTIBLE;
> which was previously recommended. I have to check back though the archives
> to find out exactly what the semantics are, above was from memory. I do
> remember there was a race condition that required a memory barrior
> instruction on MP systems.

Here is a message from Andrea describing this, but you are basically
correct here.
http://boudicca.tux.org/hypermail/linux-kernel/1999week43/0543.html

I have often thought of updating IO-mapping.txt with results of some
recent discussions. For example, readl() and friends should be
considered as only for PCI MMIO address space. For ISA devices there is
now isa_readl(), for sbus there is sbus_readl(), and for an extremely
few cases there is the raw PCI interface __raw_readl().

Jeff

P.S. Get an Alpha or PPC box. They are wonderful machines, and will
help ensure driver portability across the various PCI implementations.
A lot of x86-isms turn out to be stumbling blocks as the kernel
advances, it seems

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/