Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are ioctl driver functions executed from an atomic context under linux 2.6?

I am tracking down a "scheduling while atomic" error in one of our drivers, and am wondering if ioctl's are an atomic context. Also if any one has anything to share on how to get into and out of atomic contexts, and common places they occur, it would be helpful.

like image 412
Seamus Connor Avatar asked Sep 02 '10 16:09

Seamus Connor


People also ask

What is ioctl in Linux drivers?

An ioctl , which means "input-output control" is a kind of device-specific system call. There are only a few system calls in Linux (300-400), which are not enough to express all the unique functions devices may have. So a driver can define an ioctl which allows a userspace application to send it orders.

What is the role of ioctl in the OS kernel?

IOCTL is referred as Input and Output Control, which is used to talk with device drivers. IOCTL is a system call where system call is the programmatic way in which a computer program in user space requests a service from the kernel space of the operating system.

Is ioctl deprecated?

Adding more to confuse :" ioctl : However, ioctl is deprecated in the kernel, and you will find it hard to get any drivers with new uses of ioctl accepted upstream.

What are ioctl commands?

The ioctl() function manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g. terminals) may be controlled with ioctl() requests. The argument d must be an open file descriptor.


2 Answers

No, ioctls generally run in process context. If a driver grabs a spinlock during the ioctl processing then the driver will enter atomic context and will remain in atomic context until it releases the spinlock.

See: http://lwn.net/Articles/274695/ for a good discussion on atomic context in Linux

like image 131
Stephen Doyle Avatar answered Oct 11 '22 17:10

Stephen Doyle


Have you turned on CONFIG_DEBUG_SPINLOCK_SLEEP, that might give you more info, including a stack trace, of where the error is.

The other angle to look at is what sleeping functions are you calling. Examples are msleep(), mutex_lock(), copy_to_user() etc.

like image 33
mpe Avatar answered Oct 11 '22 17:10

mpe