RTDM interrupt questions
Quoted 7 lines
Hi
I'm writing a RTDM driver that works with a PCI FPGA card. This card generates an interrupt when its calculation is done. To deal with
interrupts
Quoted 4 lines
I have to know the interrupt line number. I found this in Linux device drivers:
result =
pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &my_irq);
You should use "dev->irq". There is no need to read that PCI configuration register (have a look to the PCI drivers in drivers/net").
Quoted 9 lines
The result is 10, but the result of lspci -v is:
01:01.0 Bridge: Teradyne Inc Unknown device fa56
Subsystem: Unknown device 0004:0299 Flags: medium devsel, IRQ 22 Memory at fc000000 (32-bit, non-prefetchable) [size=32M]So the interrupt line number is now 22. If I use this interrupt line
number
Quoted 11 lines
in the function
rtdm_irq_request, than the interrupt handler is working. When I use the interrupt line number received from theread_config_bytefunction nothing happens.
In linux device drivers they write that the value ofPCI_INTERRUPT_LINEis guaranteed to be the right one, but why is it not working?The intention of the driver is that an user space application writes some data to the PCI card, the card does something with it. The user space application have to wait until an interrupt occures, than it reads the result from the PCI card. How can the driver informs the user space application that an interrupt occurred?
Even if it is not needed by the PCI card, the IRQ vector is normally written to the card. What does the following command for your card show:
$ od -t x4 /proc/bus/pci/01/08.0
Wolfgang.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Wolfgang Grandegger
Quoted 7 lines
Hi
I'm writing a RTDM driver that works with a PCI FPGA card. This card generates an interrupt when its calculation is done. To deal with
Quoted 9 lines
interrupts
Quoted 4 lines
I have to know the interrupt line number. I found this in Linux device drivers:
result =
pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &my_irq);You should use "
dev->irq". There is no need to read that PCI configuration register (have a look to the PCI drivers indrivers/net").
Ok, dev->irq gives number 22 and interrupt is working.
Quoted 25 lines
Quoted 9 lines
The result is 10, but the result of lspci -v is:
01:01.0 Bridge: Teradyne Inc Unknown device fa56
Subsystem: Unknown device 0004:0299 Flags: medium devsel, IRQ 22 Memory at fc000000 (32-bit, non-prefetchable) [size=32M]So the interrupt line number is now 22. If I use this interrupt line
number
Quoted 5 lines
in the function
rtdm_irq_request, than the interrupt handler is working.When I use the interrupt line number received from the
read_config_bytefunction nothing happens.
In linux device drivers they write that the value ofPCI_INTERRUPT_LINEis
Quoted 3 lines
guaranteed to be the right one, but why is it not working?
The intention of the driver is that an user space application writes
some
Quoted 4 lines
data to the PCI card, the card does something with it. The user space application have to wait until an interrupt occures, than it reads the result from the PCI card. How can the driver informs the user space application that an interrupt occurred?
Quoted 5 lines
Even if it is not needed by the PCI card, the IRQ vector is normally written to the card. What does the following command for your card show:
$ od -t x4 /proc/bus/pci/01/08.0
The last number should be 01.0 instead of 08.0 I think or am I wrong? lspci give this result:
lspci
01:01.0 Bridge: Teradyne Inc Unknown device fa56
01:08.0 Ethernet controller: Intel Corporation 82562EZ 10/100 Ethernet Controller (rev 02)
od -t x4 /proc/bus/pci/01/01.0
0000000 fa561316 02000102 06800000 00000000
0000020 fc000000 00000000 00000000 00000000
0000040 00000000 00000000 00000000 02990004
0000060 00000000 00000000 00000000 0000010a
0000100 00000000 00000000 00000000 00000000
*
0000400
Is there not something like a signal I can set in the interrupt routine of the driver. The user space application have to wait its execution until the signal is set?
Steven
Quoted 50 lines · Steven Kauffmann
Quoted 5 lines · On Oct 31, 2007 4:42 PM, Wolfgang Grandegger <[email protected]…
Hi
I'm writing a RTDM driver that works with a PCI FPGA card. This card generates an interrupt when its calculation is done. To deal with
interrupts > I have to know the interrupt line number. I found this in Linux device > drivers: > > result = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &my_irq); You should use "dev->irq". There is no need to read that PCI configuration register (have a look to the PCI drivers in drivers/net").Ok,
dev->irqgives number 22 and interrupt is working.Quoted 9 lines
The result is 10, but the result of lspci -v is:
01:01.0 Bridge: Teradyne Inc Unknown device fa56
Subsystem: Unknown device 0004:0299 Flags: medium devsel, IRQ 22 Memory at fc000000 (32-bit, non-prefetchable) [size=32M]So the interrupt line number is now 22. If I use this interrupt line
number
> in the functionrtdm_irq_request, than the interrupt handler is working.
> When I use the interrupt line number received from theread_config_byte
> function nothing happens.
> In linux device drivers they write that the value ofPCI_INTERRUPT_LINEis
> guaranteed to be the right one, but why is it not working? >
> The intention of the driver is that an user space application writes some
> data to the PCI card, the card does something with it. The user space > application have to wait until an interrupt occures, than it reads the
> result from the PCI card. How can the driver informs the user space > application that an interrupt occurred?
Quoted 8 lines
Even if it is not needed by the PCI card, the IRQ vector is normally written to the card. What does the following command for your card show:
$ od -t x4
/proc/bus/pci/01/08.0The last number should be 01.0 instead of 08.0 I think or am I wrong?
You are right, of course.
Quoted 8 lines
lspci give this result:
lspci
01:01.0 Bridge: Teradyne Inc Unknown device fa56
01:08.0 Ethernet controller: Intel Corporation 82562EZ 10/100 Ethernet Controller (rev 02)
Quoted 5 lines
od -t x4
/proc/bus/pci/01/01.0
0000000fa56131602000102 06800000 00000000
0000020fc00000000000000 00000000 00000000
0000040 00000000 00000000 00000000 02990004
0000060 00000000 00000000 000000000000010a
^^
The interrupt line written to the device is 10 and therefore wrong. Don't know why, but you do not need it anyhow.
Quoted 7 lines
0000100 00000000 00000000 00000000 00000000
*
0000400Is there not something like a signal I can set in the interrupt routine of the driver. The user space application have to wait its execution until the signal is set?
I'm not sure if I understand your question. You can send an asynchronous signal from the driver to a user space application. It's documented in the Linux devic drivers book, IIRC.
Wolfgang.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 51 lines · Jeroen Van den Keybus
Ok,
dev->irqgives number 22 and interrupt is working.Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
The result is 10, but the result of lspci -v is:
As far as I know, the IRQ value field in the PCI config area is rather a scratch pad memory, and intended to be set correctly by the BIOS after PCI device enumeration. When interrupts are changed from the BIOS defaults during e.g. ACPI config, no one seems to care about this value anymore. As pointed out earlier, use
dev->irq, which is always correct.Quoted 2 lines
Is there not something like a signal I can set in the interrupt routine of the driver. The user space application have to wait its execution until the signal is set?
Yes, you could use the following code:
#include <
rtdm/rtdm_driver.h>static
rtdm_event_tevt;static int
realtime_intr(rtdm_irq_t *irq_context){ acknowledge_irq_on_fpga_card(); rtdm_event_signal(&evt); }static int
realtime_read(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, void *buf, size_t nbyte){ // ... err = rtdm_event_wait(&evt); get_data_from_fpga_card(); // ... }static int
realtime_open(){ // ... evt = rtdm_evt_init(&evt); enable_irq_from_fpga_card(); // ... }
Quoted 3 lines
This is assuming use of the RTDM. You can do the
rtdm_event_waitfrom a user task equally, I would think.
The RTDM code is compiled as a kernel module, so I can't use the rtdm_event_wait function in the driver. That part should be in the user space application which is a real-time task. The API documentation says that the rtdm_event_wait function can be called from an user-space task(RT). How do I have to use it in an user-space task(RT) if rtdm_event_wait is not defined in rtdm.h?
For the moment I have the kernel module(driver that communicates with the FPGA card), 1 user space applications(real-time tasks). For example the FPGA implements a multiplier. The user space task sends 2 values to the driver, after that it should wait (rtdm_event_wait if it is possible). When the multiplier on the FPGA is done, it generates an interrupt. The RTDM driver receives this interrupt and sends a signal to the user space task that it can stop waiting and read the result of the multiplying.
I hope that this makes it easier to understand my problem.
Steven
Quoted 48 lines · Steven Kauffmann
Quoted 45 lines · Jeroen Van den Keybus
Ok,
dev->irqgives number 22 and interrupt is working.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The result is 10, but the result of lspci -v is:
As far as I know, the IRQ value field in the PCI config area is rather a scratch pad memory, and intended to be set correctly by the BIOS after PCI device enumeration. When interrupts are changed from the BIOS defaults during e.g. ACPI config, no one seems to care about this value anymore. As pointed out earlier, use
dev->irq, which is always correct.Quoted 1 line
Is there not something like a signal I can set in the interrupt routine of the driver. The user space application have to wait its execution until the signal is set?
Yes, you could use the following code:
#include <
rtdm/rtdm_driver.h>static
rtdm_event_tevt;static int
realtime_intr(rtdm_irq_t *irq_context){ acknowledge_irq_on_fpga_card(); rtdm_event_signal(&evt); }static int
realtime_read(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, void *buf, size_t nbyte){ // ... err = rtdm_event_wait(&evt); get_data_from_fpga_card(); // ... }static int
realtime_open(){ // ... evt = rtdm_evt_init(&evt); enable_irq_from_fpga_card(); // ... }
Quoted 6 lines
Quoted 3 lines
This is assuming use of the RTDM. You can do the
rtdm_event_waitfrom a user task equally, I would think.The RTDM code is compiled as a kernel module, so I can't use the
rtdm_event_waitfunction in the driver. That part should be in the user
Why do you think you cannot use that service? You can.
Quoted 2 lines
space application which is a real-time task. The API documentation says that the
rtdm_event_waitfunction can be called from an user-space task(RT). How
The documentation _means_ (but doesn't state it clearly enough, I know) that you can call this service in the _context_ of a user space RT task that called into your driver.
Quoted 2 lines
do I have to use it in an user-space task(RT) if
rtdm_event_waitis not defined inrtdm.h?
The applications invokes some driver services, e.g. ioctl or read, and your driver can then block the task by calling rtdm_event_wait in the kernel on behalf of the task, that's the idea.
Quoted 10 lines
For the moment I have the kernel module(driver that communicates with the FPGA card), 1 user space applications(real-time tasks). For example the FPGA implements a multiplier. The user space task sends 2 values to the driver, after that it should wait (
rtdm_event_waitif it is possible). When the multiplier on the FPGA is done, it generates an interrupt. The RTDM driver receives this interrupt and sends a signal to the user space task that it can stop waiting and read the result of the multiplying.I hope that this makes it easier to understand my problem.
Yep, and I hope the explanations above helped to clarify the situation. If not, just tell us what remains unclear.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux