Commit a8676066 authored by Romain Bezut's avatar Romain Bezut Committed by Bjorn Helgaas

PCI/MSI: Export all remapped MSIs to sysfs attributes

irqbalance uses sysfs attributes to populate its internal database, which
is then used to bind the IRQ to the appropriate NUMA node.

On a device accepting multiple MSIs and with interrupt remapping enabled,
only the first IRQ entry is exported in the "msi_irqs" directory.  This
results in irqbalance having no clue of the NUMA affinity for the extra
IRQs, so it can't bind them to the correct node.

Export all MSI interrupts as sysfs attributes when relevant.

[bhelgaas: changelog]
Signed-off-by: default avatarRomain Bezut <rbezut@gmail.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 10b4ad1a
...@@ -475,10 +475,11 @@ static int populate_msi_sysfs(struct pci_dev *pdev) ...@@ -475,10 +475,11 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
int ret = -ENOMEM; int ret = -ENOMEM;
int num_msi = 0; int num_msi = 0;
int count = 0; int count = 0;
int i;
/* Determine how many msi entries we have */ /* Determine how many msi entries we have */
for_each_pci_msi_entry(entry, pdev) for_each_pci_msi_entry(entry, pdev)
++num_msi; num_msi += entry->nvec_used;
if (!num_msi) if (!num_msi)
return 0; return 0;
...@@ -487,6 +488,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev) ...@@ -487,6 +488,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
if (!msi_attrs) if (!msi_attrs)
return -ENOMEM; return -ENOMEM;
for_each_pci_msi_entry(entry, pdev) { for_each_pci_msi_entry(entry, pdev) {
for (i = 0; i < entry->nvec_used; i++) {
msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
if (!msi_dev_attr) if (!msi_dev_attr)
goto error_attrs; goto error_attrs;
...@@ -494,13 +496,14 @@ static int populate_msi_sysfs(struct pci_dev *pdev) ...@@ -494,13 +496,14 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
sysfs_attr_init(&msi_dev_attr->attr); sysfs_attr_init(&msi_dev_attr->attr);
msi_dev_attr->attr.name = kasprintf(GFP_KERNEL, "%d", msi_dev_attr->attr.name = kasprintf(GFP_KERNEL, "%d",
entry->irq); entry->irq + i);
if (!msi_dev_attr->attr.name) if (!msi_dev_attr->attr.name)
goto error_attrs; goto error_attrs;
msi_dev_attr->attr.mode = S_IRUGO; msi_dev_attr->attr.mode = S_IRUGO;
msi_dev_attr->show = msi_mode_show; msi_dev_attr->show = msi_mode_show;
++count; ++count;
} }
}
msi_irq_group = kzalloc(sizeof(*msi_irq_group), GFP_KERNEL); msi_irq_group = kzalloc(sizeof(*msi_irq_group), GFP_KERNEL);
if (!msi_irq_group) if (!msi_irq_group)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment