qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 1/3] msi: Allow pre-existing MSI capabilities


From: Michael S. Tsirkin
Subject: [Qemu-devel] Re: [PATCH 1/3] msi: Allow pre-existing MSI capabilities
Date: Tue, 2 Nov 2010 14:02:02 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Nov 01, 2010 at 11:37:32PM -0600, Alex Williamson wrote:
> For use with device assignment, allow calling msi_init() on devices
> with MSI capability already configured.
> 
> Signed-off-by: Alex Williamson <address@hidden>

Looks like the same find/add trick is repeated all over:
you put it in msix and now in msi. How about
we teach pci_add_capability about this functionality?
Then if offset is != 0 and capability is found, we can assert.

> ---
>  
>  hw/msi.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/msi.c b/hw/msi.c
> index f03f519..0ad4e38 100644
> --- a/hw/msi.c
> +++ b/hw/msi.c
> @@ -135,10 +135,16 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
>          flags |= PCI_MSI_FLAGS_MASKBIT;
>      }
>  
> +    config_offset = pci_find_capability(dev, PCI_CAP_ID_MSI);
> +
>      cap_size = msi_cap_sizeof(flags);
> -    config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, 
> cap_size);
> -    if (config_offset < 0) {
> -        return config_offset;
> +
> +    if (!config_offset) {
> +        config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI,
> +                                           offset, cap_size);
> +        if (config_offset < 0) {
> +            return config_offset;
> +        }
>      }
>  
>      dev->msi_cap = config_offset;



reply via email to

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