All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] RTDM interrupt questions
@ 2007-10-31 14:23 Steven Kauffmann
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Kauffmann @ 2007-10-31 14:23 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]

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);

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 function rtdm_irq_request, than the interrupt handler is working.
When I use the interrupt line number received from the read_config_byte
function nothing happens.
In linux device drivers they write that the value of PCI_INTERRUPT_LINE is
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?

thanks in advance

Steven

[-- Attachment #2: Type: text/html, Size: 1466 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-help] RTDM interrupt questions
@ 2007-10-31 15:42 Wolfgang Grandegger
       [not found] ` <ff1d78710711050043h7ebe3bc1l88c180d36c800d3@domain.hid>
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Grandegger @ 2007-10-31 15:42 UTC (permalink / raw)
  To: Steven Kauffmann, xenomai



> 
> 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").

> 
> 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 function rtdm_irq_request, than the interrupt handler is working.
> When I use the interrupt line number received from the read_config_byte
> function nothing happens.
> In linux device drivers they write that the value of PCI_INTERRUPT_LINE is
> 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.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-help] RTDM interrupt questions
       [not found] ` <ff1d78710711050043h7ebe3bc1l88c180d36c800d3@domain.hid>
@ 2007-11-05  8:46   ` Steven Kauffmann
  2007-11-05  9:36     ` Wolfgang Grandegger
       [not found]     ` <fd6a47a90711050117h1d2afbd1p56add10625a8da6f@domain.hid>
  0 siblings, 2 replies; 6+ messages in thread
From: Steven Kauffmann @ 2007-11-05  8:46 UTC (permalink / raw)
  To: Wolfgang Grandegger, xenomai

[-- Attachment #1: Type: text/plain, Size: 2512 bytes --]

On Oct 31, 2007 4:42 PM, Wolfgang Grandegger <wg@domain.hid> wrote:

>
>
> >
> > 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->irq gives number 22 and interrupt is working.


> >
> > 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 function rtdm_irq_request, than the interrupt handler is working.
>
> > When I use the interrupt line number received from the read_config_byte
> > function nothing happens.
> > In linux device drivers they write that the value of PCI_INTERRUPT_LINE
> is
> > 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


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

[-- Attachment #2: Type: text/html, Size: 3380 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-help] RTDM interrupt questions
  2007-11-05  8:46   ` Steven Kauffmann
@ 2007-11-05  9:36     ` Wolfgang Grandegger
       [not found]     ` <fd6a47a90711050117h1d2afbd1p56add10625a8da6f@domain.hid>
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Grandegger @ 2007-11-05  9:36 UTC (permalink / raw)
  To: Steven Kauffmann; +Cc: xenomai

Steven Kauffmann wrote:
> On Oct 31, 2007 4:42 PM, Wolfgang Grandegger <wg@domain.hid
> <mailto:wg@domain.hid>> wrote:
> 
> 
> 
>     >
>     > 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->irq gives number 22 and interrupt is working.
> 
> 
>     >
>     > 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 function rtdm_irq_request, than the interrupt handler is
>     working.
>     > When I use the interrupt line number received from the
>     read_config_byte
>     > function nothing happens.
>     > In linux device drivers they write that the value of
>     PCI_INTERRUPT_LINE is
>     > 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
> 
> 
> The last number should be 01.0 instead of 08.0 I think or am I wrong?

You are right, of course.

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

The interrupt line written to the device is 10 and therefore wrong.
Don't know why, but you do not need it anyhow.

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

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-help] RTDM interrupt questions
       [not found]     ` <fd6a47a90711050117h1d2afbd1p56add10625a8da6f@domain.hid>
@ 2007-11-05 15:57       ` Steven Kauffmann
  2007-11-05 16:34         ` Jan Kiszka
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Kauffmann @ 2007-11-05 15:57 UTC (permalink / raw)
  To: Jeroen Van den Keybus, xenomai

[-- Attachment #1: Type: text/plain, Size: 2448 bytes --]

On Nov 5, 2007 10:17 AM, Jeroen Van den Keybus <
jeroen.vandenkeybus@domain.hid> wrote:

>  Ok, dev->irq gives number 22 and interrupt is working.
> >
> >
> >
> > >
> > > >
> > > > 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.
>
>
> >
> >
> 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_t evt;
>
> 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();
>     // ...
> }
>
> This is assuming use of the RTDM. You can do the rtdm_event_wait from 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

[-- Attachment #2: Type: text/html, Size: 4079 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-help] RTDM interrupt questions
  2007-11-05 15:57       ` Steven Kauffmann
@ 2007-11-05 16:34         ` Jan Kiszka
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2007-11-05 16:34 UTC (permalink / raw)
  To: Steven Kauffmann; +Cc: xenomai

Steven Kauffmann wrote:
> On Nov 5, 2007 10:17 AM, Jeroen Van den Keybus <
> jeroen.vandenkeybus@domain.hid> wrote:
> 
>>  Ok, dev->irq gives number 22 and interrupt is working.
>>>
>>>
>>>>> 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.
>>
>>
>>>
>> 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_t evt;
>>
>> 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();
>>     // ...
>> }
>>
>> This is assuming use of the RTDM. You can do the rtdm_event_wait from 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

Why do you think you cannot use that service? You can.

> 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

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.

> do I have to use it in an user-space task(RT) if rtdm_event_wait is not
> defined in rtdm.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.

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

Yep, and I hope the explanations above helped to clarify the situation.
If not, just tell us what remains unclear.

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-11-05 16:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-31 15:42 [Xenomai-help] RTDM interrupt questions Wolfgang Grandegger
     [not found] ` <ff1d78710711050043h7ebe3bc1l88c180d36c800d3@domain.hid>
2007-11-05  8:46   ` Steven Kauffmann
2007-11-05  9:36     ` Wolfgang Grandegger
     [not found]     ` <fd6a47a90711050117h1d2afbd1p56add10625a8da6f@domain.hid>
2007-11-05 15:57       ` Steven Kauffmann
2007-11-05 16:34         ` Jan Kiszka
  -- strict thread matches above, loose matches on Subject: below --
2007-10-31 14:23 Steven Kauffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.