Re: [EXTERNAL] Re: bus_alloc_resource_any failing to allocate irq for vmbus in amd64

From: Souradeep Chakrabarti <schakrabarti_at_microsoft.com>
Date: Fri, 10 Jun 2022 15:13:46 UTC
I have tried without RF_SHAREABLE as well, but it is failing allocate irq.
Also I have tried with sc->vmbus_dev, parent(sc->vmbus_dev) acpi_container,
grandparent(sc->vmbus_dev) acpi as dev. But it is failing.

Thanks & Regards,
 Souradeep



From: Hans Petter Selasky <hps@selasky.org>
Sent: Friday, June 10, 2022 7:06 PM
To: Souradeep Chakrabarti <schakrabarti@microsoft.com>; freebsd-arm@FreeBSD.org <freebsd-arm@FreeBSD.org>; Andrew Turner <andrew@freebsd.org>; Li-Wen Hsu <lwhsu@freebsd.org>; Warner Losh <imp@bsdimp.com>
Cc: Wei Hu <weh@microsoft.com>
Subject: [EXTERNAL] Re: bus_alloc_resource_any failing to allocate irq for vmbus in amd64 
 
On 6/10/22 15:16, Souradeep Chakrabarti wrote:
> +Warner Losh
> 
> 
> Thanks & Regards,
>   Souradeep
> 
> 
> 
> From: Souradeep Chakrabarti <schakrabarti@microsoft.com>
> Sent: Friday, June 10, 2022 6:44 PM
> To: freebsd-arm@FreeBSD.org <freebsd-arm@FreeBSD.org>; Andrew Turner <andrew@freebsd.org>; Li-Wen Hsu <lwhsu@freebsd.org>
> Cc: Wei Hu <weh@microsoft.com>
> Subject: bus_alloc_resource_any failing to allocate irq for vmbus in amd64
>   
> Hi,
> I am trying to use bus_alloc_resource_any() to allocate a irq line for vmbus but it is failing.
> 
> this is the patch :
> 
> +  sc->sc_vmbus_irid = 1;
> +  device_t parent = device_get_parent(device_get_parent(sc->vmbus_dev));
> +  sc->sc_vmbus_ires = bus_alloc_resource_any(parent,
> +                                                   SYS_RES_IRQ, &(sc->sc_vmbus_irid), RF_ACTIVE|RF_SHAREABLE);
> +   if (sc->sc_vmbus_ires == NULL) {
> +           device_printf(sc->vmbus_dev, "could not allocate IRQ\n");
> +           return (ENXIO);
> +   }
> +   error = bus_setup_intr(sc->vmbus_dev, sc->sc_vmbus_ires, INTR_TYPE_NET | INTR_MPSAFE,
> +                                   NULL, vmbus_handle_intr_new, sc, &(sc->sc_vmbus_ihand));
> +   if (error) {
> +           device_printf(sc->vmbus_dev, "failed to setup IRQ\n");
> +           if (bus_release_resource(sc->vmbus_dev, SYS_RES_IRQ, sc->sc_vmbus_irid, sc->sc_vmbus_ires))
> +                   device_printf(sc->vmbus_dev, "could not release IRQ\n");
> +           sc->sc_vmbus_ires = NULL;
> +           return (error);
> +   }
> 
> What am I missing here? Any help would be greatly appreciated.
> 
> Thanks & Regards,
> Souradeep

Maybe the IRQ is not sharable:

RF_SHAREABLE

--HPS