Date: Wed, 29 Sep 2010 13:53:39 -0400 From: Deepa Srinivasan <dsriniv@ncsu.edu> To: John Baldwin <jhb@freebsd.org> Cc: freebsd-drivers@freebsd.org Subject: Re: Requesting an IRQ Message-ID: <AANLkTinznvAZKqjrKNzFKZW-6pvywAj5Xyudq_Qs7Z0J@mail.gmail.com> In-Reply-To: <201009291341.13483.jhb@freebsd.org> References: <AANLkTikS%2BtwoJTCm82wgo357Z8%2Bz8Kcp1vji0cmB=KiP@mail.gmail.com> <201009291341.13483.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks for your prompt response. I made an error in my earlier post - I'm using FreeBSD 8.1 not 5.0. I'll look into the PCI bus driver code. I've also been looking at the Xenbus code since it does something similar to what I need. - Deepa On Wed, Sep 29, 2010 at 1:41 PM, John Baldwin <jhb@freebsd.org> wrote: > On Wednesday, September 29, 2010 12:07:27 pm Deepa Srinivasan wrote: > > I'm writing a "pseudo" device driver for FreeBSD 5.0 - i.e. there is no > > physical device backing it. But I need to be able to send an interrupt to > it > > from an underlying hypervisor (KVM). FreeBSD runs as a guest OS. I have > done > > the same in Linux - wrote a kernel module and used the "request_irq" > > function to allocate an unused interrupt number. When the underlying KVM > > injects an interrupt into the guest OS, the registered interrupt handler > > gets called as expected. > > > > However, in FreeBSD, I cannot find an equivalent function to > "request_irq". > > Going with the available documentation and sample code, I tried modifying > a > > PCI driver (this may be overkill for what I'm doing, but still...) and > used > > the bus_alloc_resource() and bus_setup_intr() functions. In my OS > > configuration, this results in the "irq9" being allocated to my driver. > But > > the same IRQ is also allocated to "acpi0". Now, when I inject an > interrupt > > from the hypervisor, it immediately causes an "interrupt storm" and I see > > this message continuously printed: "interrupt storm detected on irq9; > > throttling interrupt source". This happens even without my driver being > > loaded. In the KVM hypervisor code, I set the interrupt to "1" and > > immediately to "0" and I know for sure that this code path is being > > executed. > > > > My question is: > > - Is it possible to write a pseudo device driver and use something like > the > > "request_irq" in Linux to just be able to invoke a callback function in > the > > driver? > > - Is it possible to specify the interrupt number that needs to be > allocated > > to my device driver so I can ensure that it is not shared with anything > > else? > > You can do 2), but you will need to do it by overriding what the bus thinks > the IRQ is. Part of the problem is that you need a way to hook up your > fake > IRQ to the MD interrupt code. This may be hackish to do in 5.0 was the x86 > code does not have the interrupt source abstraction that later versions use > to > implement support for PCI MSI. In newer versions you would basically > provide > some sort of interrupt provider similar to MSI and then use a modified PCI > bus > driver to allocate an interrupt from your provider and return it via > bus_alloc_resource(). > > -- > John Baldwin >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinznvAZKqjrKNzFKZW-6pvywAj5Xyudq_Qs7Z0J>