RE: [EXTERNAL] Re: allocating IRQ mentioned in _CRS of ACPI

From: Souradeep Chakrabarti <schakrabarti_at_microsoft.com>
Date: Wed, 19 Oct 2022 17:51:26 UTC
Hi Warner,


1) PCI mmio resource in HID "ACPI0004", which is needed by the FreeBSD guest for SRIOV devices.



   Device (\_SB.VMOD)    <-- This is currently owned by acpi_syscontainer module on FreeBSD

    {

        Name (_HID, "ACPI0004" /* Module Device */)  // _HID: Hardware ID

        Name (_UID, Zero)  // _UID: Unique ID

        Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings

        {

            ...

        }

        CreateDWordField (_CRS, \_SB.VMOD._Y00._MIN, MIN6)  // _MIN: Minimum Base Address

        CreateDWordField (_CRS, \_SB.VMOD._Y00._MAX, MAX6)  // _MAX: Maximum Base Address

        CreateDWordField (_CRS, \_SB.VMOD._Y00._LEN, LEN6)  // _LEN: Length

        CreateQWordField (_CRS, \_SB.VMOD._Y01._MIN, MIN7)  // _MIN: Minimum Base Address

        CreateQWordField (_CRS, \_SB.VMOD._Y01._MAX, MAX7)  // _MAX: Maximum Base Address

        CreateQWordField (_CRS, \_SB.VMOD._Y01._LEN, LEN7)  // _LEN: Length

        Method (_INI, 0, NotSerialized)  // _INI: Initialize

        {

            MIN6 = MG2B /* \MG2B */

            LEN6 = MG2L /* \MG2L */

            Local0 = MG2L /* \MG2L */

            MAX6 = (MIN6 + Local0--)

            Local1 = (HMIB << 0x14)

            Local2 = (HMIL << 0x14)

            MIN7 = Local1

            LEN7 = Local2

            Local0 = Local2

            MAX7 = (MIN7 + Local0--)

        }

    }



2) Vmbus IRQ resource in HID "VMBus", which is needed to get Hyper-V vmbus interrupt to work on guests.

Device (\_SB.VMOD.VMBS)   <--- currently owned by vmbus_res module on FreeBSD

    {

        ...

        Name (_HID, "VMBus")  // _HID: Hardware ID

        Name (_UID, Zero)  // _UID: Unique ID

        ...

        Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings

        {

            Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )

            {

                0x00000012,

            }

        })

    }


[Diagram  Description automatically generated]

Today I was able to get both IRQ and MMIO allocation successful using below snippet in vmbus:


+       device_t dev =  devclass_get_device(devclass_find("vmbus_res"), 0);

+       sc->ires = bus_alloc_resource_any(dev,

            SYS_RES_IRQ, &sc->vector, RF_ACTIVE | RF_SHAREABLE);


Thanks & Regards,
 Souradeep

From: Warner Losh <imp@bsdimp.com>
Sent: Wednesday, October 19, 2022 11:09 PM
To: Souradeep Chakrabarti <schakrabarti@microsoft.com>
Cc: freebsd-hackers@freebsd.org; Wei Hu <weh@microsoft.com>
Subject: [EXTERNAL] Re: allocating IRQ mentioned in _CRS of ACPI

Sorry for the late reply... I've been busy with some things for work...

I think you'll need to get the parent of vmbus to allow a pass through allocation. What bus is that
currently?

Warner

On Tue, Oct 18, 2022 at 12:33 PM Souradeep Chakrabarti <schakrabarti@microsoft.com<mailto:schakrabarti@microsoft.com>> wrote:
Hi,
It will be a great help, if someone can help here with some idea.
As it is blocking the FreeBSD on Hyper-V ARM64.

Thanks & Regards,
Souradeep

> -----Original Message-----
> From: Souradeep Chakrabarti
> Sent: Friday, October 14, 2022 1:24 PM
> To: 'Warner Losh' <imp@bsdimp.com<mailto:imp@bsdimp.com>>
> Cc: freebsd-hackers@freebsd.org<mailto:freebsd-hackers@freebsd.org>; Wei Hu <weh@microsoft.com<mailto:weh@microsoft.com>>
> Subject: RE: allocating IRQ mentioned in _CRS of ACPI
>
> Last mail was having incorrect FreeBSD hacker alias. Replacing that with correct
> one here.
>
>
> > -----Original Message-----
> > From: Souradeep Chakrabarti
> > Sent: Friday, October 14, 2022 1:19 PM
> > To: Warner Losh <imp@bsdimp.com<mailto:imp@bsdimp.com>>
> > Cc: hacker@freebsd.org<mailto:hacker@freebsd.org>; Wei Hu <weh@microsoft.com<mailto:weh@microsoft.com>>
> > Subject: allocating IRQ mentioned in _CRS of ACPI
> >
> > Hi,
> > I would like to allocate IRQ to a device, mentioned in the _CRS of
> > that device in ACPI table.
> > I have tried with bus_alloc_resource_any(), but it is failing as the
> > parent of that device is not owning the IRQ.
> >
> > Current ACPI topo for the device :
> > ACPI0->SB.VMOD(HID ACPI0004, has SYS_RES_MEM for MMIO in _CRS)-
> > >VMBUS( it has SYS_RES_IRQ in it's _CRS).
> >
> > How can I get here both SYS_RES_IRQ and SYS_RES_MEM allocated to VMBUS?
> >
> > Thanks & Regards,
> > Souradeep