Re: ANN: Slides on writing portable kernel drivers (from Linux Expo)

From: Jes Sorensen (Jes.Sorensen@cern.ch)
Date: Tue Feb 08 2000 - 06:58:52 EST


>>>>> "Jeff" == Jeff Garzik <jgarzik@mandrakesoft.com> writes:

Jeff> The link directly to the slides is
Jeff> http://gtf.org/garzik/drivers/LinuxExpo2000_Paris/

Jeff> Even if you are familiar with the new device driver facilities
Jeff> in 2.3.42 kernels, this should provide a handy reference to
Jeff> hacking device drivers.

Couple of problems and comments:

readl()/writel() are meant to be ordered on all
architectures, you kinda describe them as not being so. This _was_ the
case on the Alpha until recently (and is so in 2.2.x), but it's not
meant to be so anylonger. The __raw_ versions of the functions are
_not_ pure endianess, they are there for providing raw access (non
ordered, CPU native byte order etc etc.), ie. it makes a lot of sense
to use these on little endian boxes as well. These are the ones that
are meant to be used carefully and with explicit memory barrier's.

Your description of spin_lock() isn't very clear, though I suspect the
intention is (I asume the comments at the talk were). When inside an
interrupt handler you use the non irqsave version since you are
guaranteed that no interrupt will be generated on the particular CPU
while running the interrupt handler. You want to use the irqsave one
outside of interrupt context - so it's quite common to actually use
both the irqsave and the non irqsave versions to grab the same
lock. Now of course the trick is not having to use any spin locks at
all ;-)

Semaphores: you should mention down_interruptible() as well and
explain why it's good.

kmalloc(): basically it's limited to 128KB

Last, you are missing a few important points that I think you should
mention in a talk on writing portable code. Ie. #ifdef __alpha__ is a
lot less portable than #ifdef __LITTLE_ENDIAN and
#if (BITS_PER_LONG == 64).

You may want to take a look at my kernel hacking tutorial slides at
http://home.cern.ch/~jes/ols-kernel.ps.gz. They are a bit outdated
since thats the version I used for my talk in Ottawa last July.

Jes

-
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/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:12 EST