@@ -46,7 +46,7 @@ static int vpci_msi_control_read(struct pci_dev *pdev, unsigned int reg,
{
struct vpci_msi *msi = data;
- if ( msi->enabled )
+ if ( msi->pirq != -1 )
val->word |= PCI_MSI_FLAGS_ENABLE;
if ( msi->masking )
val->word |= PCI_MSI_FLAGS_MASKBIT;
@@ -74,7 +74,7 @@ static int vpci_msi_control_write(struct pci_dev *pdev, unsigned int reg,
msi->guest_vectors = vectors;
- if ( !((val.word ^ msi->enabled) & PCI_MSI_FLAGS_ENABLE) )
+ if ( !!(val.word & PCI_MSI_FLAGS_ENABLE) == (msi->pirq != -1) )
return 0;
if ( val.word & PCI_MSI_FLAGS_ENABLE )
@@ -87,7 +87,7 @@ static int vpci_msi_control_write(struct pci_dev *pdev, unsigned int reg,
.entry_nr = vectors,
};
- ASSERT(!msi->enabled);
+ ASSERT(msi->pirq == -1);
/* Get a PIRQ. */
rc = allocate_and_map_msi_pirq(pdev->domain, &index, &msi->pirq,
@@ -149,11 +149,10 @@ static int vpci_msi_control_write(struct pci_dev *pdev, unsigned int reg,
__msi_set_enable(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn),
PCI_FUNC(pdev->devfn), reg - PCI_MSI_FLAGS, 1);
- msi->enabled = true;
}
else
{
- ASSERT(msi->enabled);
+ ASSERT(msi->pirq != -1);
__msi_set_enable(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn),
PCI_FUNC(pdev->devfn), reg - PCI_MSI_FLAGS, 0);
@@ -178,7 +177,6 @@ static int vpci_msi_control_write(struct pci_dev *pdev, unsigned int reg,
msi->pirq = -1;
msi->vectors = 0;
- msi->enabled = false;
}
return 0;
@@ -426,7 +424,7 @@ static void vpci_dump_msi(unsigned char key)
printk("Device %04x:%02x:%02x.%u\n", seg, bus, slot, func);
printk("Enabled: %u Supports masking: %u 64-bit addresses: %u\n",
- msi->enabled, msi->masking, msi->address64);
+ msi->pirq != -1, msi->masking, msi->address64);
printk("Max vectors: %u guest vectors: %u enabled vectors: %u\n",
msi->max_vectors, msi->guest_vectors, msi->vectors);
@@ -100,12 +100,10 @@ struct vpci {
/* Address and data fields. */
uint64_t address;
uint16_t data;
- /* PIRQ */
+ /* PIRQ (if this field is different than -1, MSIs are enabled) */
int pirq;
/* Mask bitfield. */
uint32_t mask;
- /* MSI enabled? */
- bool enabled;
/* Supports per-vector masking? */
bool masking;
/* 64-bit address capable? */