Forum Discussion
Altera_Forum
Honored Contributor
17 years agoDoes anyboy use "struct semaphore" and down(struct semaphore
Hello everyone,
I use the latest version of nios2-linux(nios2-linux-20090730),when I test the driver nios2-linux/linux-2.6/drivers/char/altera_pio_button.c,I found that the function down(struct semaphore *) never return.I think it's a serious problem,drivers can not work without semphare,wake_up(wait_queue_head_t *) seems not work too,I can not find their definitions,so I don't know why, could anybody help me. Thank you3 Replies
- Altera_Forum
Honored Contributor
Did I descript it clearly?The test process is las follows:
1.fd=open("/dev/pio_button",O_RDONLY); 2.ret=read(fd,&key_value,sizeof(key_value)); I had not press any button,so it blocked itself and called schedule(),then I pressed a button,so pio_button_isr() was called,in the end it schedule work_queue,(here the handle is button_handle_event()),in button_handle_event(),so down(&dev->mutex) appears,it never return!That's the problem! I don't think there are any dead lock! I have see some source code(NIOSSerial.c,altspi.c ),they don't use down()! - Altera_Forum
Honored Contributor
Maybe I should solve this problem by myself! :(
- Altera_Forum
Honored Contributor
The pio port base should remapped to uncached. Try# define PIO_BUTTON_BASE (na_button_pio | 0x80000000) I've never used that driver myself. It is just a personal taste. I prefer using gpio and input subsystem which supports polling instead of interrupt driven. Please see the example at linux-2.6/drivers/input/mouse/gpio_mouse.c . http://www.nioswiki.com/gpio (http://www.nioswiki.com/gpio) - Hippo