qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] pci: Add pci_device_get_host_irq


From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH 1/2] pci: Add pci_device_get_host_irq
Date: Mon, 21 May 2012 17:36:25 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

On 05/21/2012 04:13 PM, Jan Kiszka wrote:
> Add a PCI IRQ path discovery function that walks from a given device to
> the host bridge, returning the IRQ number that is reported to the
> attached interrupt controller. For this purpose, another PCI bridge
> callback function is introduced: map_host_irq. It is so far only
> implemented by the PIIX3, other host bridges can be added later on as
> required.
>
> Will be used for KVM PCI device assignment.

This is similar to the memory API, which converts a memory region
hierarchy to a flat list and fires notifiers whenever it changes.

> +int pci_device_get_host_irq(PCIDevice *pci_dev, int irq_num)
> +{
> +    PCIBus *bus;
> +
> +    for (;;) {
> +        bus = pci_dev->bus;
> +        irq_num = bus->map_irq(pci_dev, irq_num);
> +        if (bus->map_host_irq) {
> +            break;
> +        }
> +        pci_dev = bus->parent_dev;
> +        assert(pci_dev);
> +    }
> +    return bus->map_host_irq(bus->irq_opaque, irq_num);
> +}
> +

My personal preference is to avoid infinite loops with breaks, I'd write
this as a do/while (without the assert).  Or maybe supply all buses with
a default map_host_irq that recurses back into
pci_device_get_host_irq().  But this is not an objection to the patch.

-- 
error compiling committee.c: too many arguments to function




reply via email to

[Prev in Thread] Current Thread [Next in Thread]