Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Semaphore and interrupt

21 views
Skip to first unread message

Nick Nygaard

unread,
Oct 24, 2003, 2:03:14 PM10/24/03
to
Hi
Am developing a simple char device driver, and want the Read function remain
blocked until an interrupt is received.
Im initalizing a semaphore locked, and trying to decrease its value in
function Read which results in a wait state. Now we're waiting for an irq to
occur and increase/release the semaphore. So far so good...

#include <asm/semaphore.h>
static struct semaphore press_sem;

ssize_t Read(struct file *filp, char *userbuf, size_t count, loff_t *offp) {
sema_init(&press_sem, 0); // init_MUTEX_LOCKED

// and now wait for interrupt (release)
down(&press_sem);

// return to userland.....
}

static void IntmodInterrupt(int irq, void *devid, struct pt_regs *regs) { //
SA_INTERRUPT
up(&press_sem);
}

Its not pretty to initalized the semaphore each time I Read, but it makes my
problem easier to understand.

When driver inserted, calling userspace thread blocked and the irq occurs,
following kernel panic error messages is displayed:
---------------
Unable to handle kernel NULL pointer dereference at virtual address 00000001
printing eip:
c010edbb
*pde = 00000000
Oops: 0000
CPU: 0
EIP: 0010:[<c010edbb>] Not tainted
EFLAGS: 00010097
eax: c2a0b594 ebx: c2a0b590 ecx: 00000001 edx: 00000003
esi: 00000001 edi: 00000001 ebp: c10afee8 esp: c10afed0
ds: 0018 es: 0018 ss: 0018
Process ksoftirqd_CPU0 (pid: 3, stackpage=c10af000)
Stack: c05ca360 00000001 0000000a c2a0b594 00000286 00000003 c10aff88
c0105bc6
c0105da8 c2a0b588 c10aff88 00000001 c2a0b352 00000001 00000000
c0117c6d
c10ae000 00000000 00000001 00000000 c2a0b192 00000001 00000046
c10aff88
Call Trace: [<c2a0b594>] [<c0105bc6>] [<c0105da8>] [<c2a0b588>] [<c2a0b352>]
[<c0117c6d>] [<c2a0b192>] [<c0117fcf>] [<c010af36>] [<c01081ef>]
[<c010836e>]
[<c010a178>] [<c0114f08>] [<c0110010>] [<c0114d5a>] [<c011519d>]
[<c01056e8>]

Code: 8b 01 85 45 fc 74 4e 31 c0 9c 5e fa c7 01 00 00 00 00 83 79
<0>Kernel panic: Aiee, killing interrupt handler!
In interrupt handler - not syncing
---------------

Something goes wrong when using up() in interrupt. Is somebody able to help?

/Nick


wb

unread,
Oct 27, 2003, 7:04:46 AM10/27/03
to
Nick Nygaard wrote:

Looks Ok to me. I'm assumomh your added printk statements

to ensure the press_sem struct is valid.

Is the eip ( c010edbb ) in your driver ?

Build your drivers with -g, then use
objdump -d -S <driver> > driver.S to disassemble
it. You may what to give a kernel debugging try too
(kdb) from www.sgi.com/linux. .

0 new messages