Re: [Basics] spinlocks & copy_to_user

Linus Torvalds (torvalds@transmeta.com)
8 Feb 2000 15:52:33 -0800


In article <38A05F8A.204BDC50@inet.com>, ejc <eli.carter@inet.com> wrote:
>Summary:
>
>What is the Right Way(tm) for a driver (in read(), write(), or ioctl(),
>etc.) to copy data, possibly modified at interrupt time, to/from a user?

There are three:
(a) use a queue, where interrupts add to the end of the queue, but
leave the part you're copying from unmodified.
(b) copy to a temporary buffer with spinlocks, then copy from that temp
buffer to user space.
(c) don't do it.

There are _very_ few reasons to do what you suggest, almost no driver
I've ever seen depends on anything like that. You may just have a design
that is fundamentally flawed. So (c) is not just being facetious, I'm
serious.

Linus

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