msix: drop unused msix_bar_size, require valid bar_size

No user in sight for msix_bar_size.
bar_size for all users is aligned, let's simply
require this instead of trying to fix up invalid input.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Jan Kiszka 2012-06-04 16:56:01 +02:00 committed by Michael S. Tsirkin
parent 80aa796bf3
commit 393a98924e
3 changed files with 3 additions and 21 deletions

View File

@ -55,24 +55,17 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
{ {
int config_offset; int config_offset;
uint8_t *config; uint8_t *config;
uint32_t new_size;
if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1) if (nentries < 1 || nentries > PCI_MSIX_FLAGS_QSIZE + 1)
return -EINVAL; return -EINVAL;
if (bar_size > 0x80000000) if (bar_size > 0x80000000)
return -ENOSPC; return -ENOSPC;
/* Add space for MSI-X structures */ /* Require aligned offset for MSI-X structures */
if (!bar_size) { if (bar_size & ~(MSIX_PAGE_SIZE - 1)) {
new_size = MSIX_PAGE_SIZE; return -EINVAL;
} else if (bar_size < MSIX_PAGE_SIZE) {
bar_size = MSIX_PAGE_SIZE;
new_size = MSIX_PAGE_SIZE * 2;
} else {
new_size = bar_size * 2;
} }
pdev->msix_bar_size = new_size;
config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX, config_offset = pci_add_capability(pdev, PCI_CAP_ID_MSIX,
0, MSIX_CAP_LENGTH); 0, MSIX_CAP_LENGTH);
if (config_offset < 0) if (config_offset < 0)
@ -382,13 +375,6 @@ int msix_enabled(PCIDevice *dev)
MSIX_ENABLE_MASK); MSIX_ENABLE_MASK);
} }
/* Size of bar where MSI-X table resides, or 0 if MSI-X not supported. */
uint32_t msix_bar_size(PCIDevice *dev)
{
return (dev->cap_present & QEMU_PCI_CAP_MSIX) ?
dev->msix_bar_size : 0;
}
/* Send an MSI-X message */ /* Send an MSI-X message */
void msix_notify(PCIDevice *dev, unsigned vector) void msix_notify(PCIDevice *dev, unsigned vector)
{ {

View File

@ -21,8 +21,6 @@ void msix_load(PCIDevice *dev, QEMUFile *f);
int msix_enabled(PCIDevice *dev); int msix_enabled(PCIDevice *dev);
int msix_present(PCIDevice *dev); int msix_present(PCIDevice *dev);
uint32_t msix_bar_size(PCIDevice *dev);
int msix_vector_use(PCIDevice *dev, unsigned vector); int msix_vector_use(PCIDevice *dev, unsigned vector);
void msix_vector_unuse(PCIDevice *dev, unsigned vector); void msix_vector_unuse(PCIDevice *dev, unsigned vector);
void msix_unuse_all_vectors(PCIDevice *dev); void msix_unuse_all_vectors(PCIDevice *dev);

View File

@ -226,8 +226,6 @@ struct PCIDevice {
MemoryRegion msix_mmio; MemoryRegion msix_mmio;
/* Reference-count for entries actually in use by driver. */ /* Reference-count for entries actually in use by driver. */
unsigned *msix_entry_used; unsigned *msix_entry_used;
/* Region including the MSI-X table */
uint32_t msix_bar_size;
/* MSIX function mask set or MSIX disabled */ /* MSIX function mask set or MSIX disabled */
bool msix_function_masked; bool msix_function_masked;
/* Version id needed for VMState */ /* Version id needed for VMState */