aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/msi.c
diff options
context:
space:
mode:
authorHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>2009-08-05 22:34:34 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-09-09 16:29:33 -0400
commit5a05a9d819a328b3aae750237909aa2097adbeec (patch)
tree018b4d173c43e1f88c970de20612ce3d20481ae1 /drivers/pci/msi.c
parent583871d436bea48cc2204cee0ec8eb7025e03db6 (diff)
PCI MSI: MSI-X cleanup, msix_map_region()
Cleanup based on the prototype from Matthew Milcox. Reviewed-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r--drivers/pci/msi.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 7085d665db01..b0cc82123cc7 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -432,6 +432,21 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
432 return 0; 432 return 0;
433} 433}
434 434
435static void __iomem *msix_map_region(struct pci_dev *dev, unsigned pos,
436 unsigned nr_entries)
437{
438 unsigned long phys_addr;
439 u32 table_offset;
440 u8 bir;
441
442 pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset);
443 bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
444 table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
445 phys_addr = pci_resource_start(dev, bir) + table_offset;
446
447 return ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
448}
449
435/** 450/**
436 * msix_capability_init - configure device's MSI-X capability 451 * msix_capability_init - configure device's MSI-X capability
437 * @dev: pointer to the pci_dev data structure of MSI-X device function 452 * @dev: pointer to the pci_dev data structure of MSI-X device function
@@ -446,11 +461,8 @@ static int msix_capability_init(struct pci_dev *dev,
446 struct msix_entry *entries, int nvec) 461 struct msix_entry *entries, int nvec)
447{ 462{
448 struct msi_desc *entry; 463 struct msi_desc *entry;
449 int pos, i, j, nr_entries, ret; 464 int pos, i, j, ret;
450 unsigned long phys_addr; 465 u16 control;
451 u32 table_offset;
452 u16 control;
453 u8 bir;
454 void __iomem *base; 466 void __iomem *base;
455 467
456 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); 468 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
@@ -461,14 +473,8 @@ static int msix_capability_init(struct pci_dev *dev,
461 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); 473 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
462 474
463 /* Request & Map MSI-X table region */ 475 /* Request & Map MSI-X table region */
464 nr_entries = multi_msix_capable(control); 476 base = msix_map_region(dev, pos, multi_msix_capable(control));
465 477 if (!base)
466 pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset);
467 bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
468 table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
469 phys_addr = pci_resource_start (dev, bir) + table_offset;
470 base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
471 if (base == NULL)
472 return -ENOMEM; 478 return -ENOMEM;
473 479
474 for (i = 0; i < nvec; i++) { 480 for (i = 0; i < nvec; i++) {