Linux-kernel mailing list archive 2000-06,: Re: ANN: Slides on writing portable kernel drivers (from Linux Expo)

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

Jeff Garzik (jgarzik@mandrakesoft.com)
Tue, 08 Feb 2000 07:08:16 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Alan Cox: "Re: How to create hard reboots through software"
- Previous message: Ashutosh S. Rajekar: "spinlocks"
- Maybe in reply to: Jeff Garzik: "ANN: Slides on writing portable kernel drivers (from Linux Expo)"

Jes Sorensen wrote:
>
> >>>>> "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.

I'll clear this up too, as it was the gist of the entire slide

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

I knew that but you're right it should be more clear

> 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 ;-)

True enough. Most of this was covered in the verbal comments on the
slide.

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

Need to get more familiar with semaphores first :)

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

Thanks much for the reference, and the review.

Jeff

    --
    Jeff Garzik         | Only so many songs can be sung
    Building 1024       | with two lips, two lungs, and
    MandrakeSoft, Inc.  | one tongue.

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

- Next message: Alan Cox: "Re: How to create hard reboots through software"
- Previous message: Ashutosh S. Rajekar: "spinlocks"
- Maybe in reply to: Jeff Garzik: "ANN: Slides on writing portable kernel drivers (from Linux Expo)"