From e80e7edc55ba711f3fe23975061b3f1c336ceb95 Mon Sep 17 00:00:00 2001 From: "Guilherme G. Piccoli" Date: Wed, 21 Oct 2015 12:17:35 -0200 Subject: PCI/MSI: Initialize MSI capability for all architectures 1851617cd2da ("PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI") moved dev->msi_cap and dev->msix_cap initialization from the pci_init_capabilities() path (used on all architectures) to the pci_setup_device() path (not used on Open Firmware architectures). This broke MSI or MSI-X on Open Firmware machines. 4d9aac397a5d ("powerpc/PCI: Disable MSI/MSI-X interrupts at PCI probe time in OF case") fixed it for PowerPC but not for SPARC. Set up MSI and MSI-X (initialize msi_cap and msix_cap and disable MSI and MSI-X) in pci_init_capabilities() so all architectures do it the same way. This reverts 4d9aac397a5d since this patch fixes the problem generically for both PowerPC and SPARC. [bhelgaas: changelog, make pci_msi_setup_pci_dev() static] Fixes: 1851617cd2da ("PCI/MSI: Disable MSI at enumeration even if kernel doesn't support MSI") Signed-off-by: Guilherme G. Piccoli Signed-off-by: Bjorn Helgaas --- drivers/pci/probe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/pci/probe.c') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index edb1984201e9..cd94737af8fd 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1145,7 +1145,7 @@ int pci_cfg_space_size(struct pci_dev *dev) #define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) -void pci_msi_setup_pci_dev(struct pci_dev *dev) +static void pci_msi_setup_pci_dev(struct pci_dev *dev) { /* * Disable the MSI hardware to avoid screaming interrupts @@ -1212,8 +1212,6 @@ int pci_setup_device(struct pci_dev *dev) /* "Unknown power state" */ dev->current_state = PCI_UNKNOWN; - pci_msi_setup_pci_dev(dev); - /* Early fixups, before probing the BARs */ pci_fixup_device(pci_fixup_early, dev); /* device class may be changed after fixup */ @@ -1606,6 +1604,9 @@ static void pci_init_capabilities(struct pci_dev *dev) /* MSI/MSI-X list */ pci_msi_init_pci_dev(dev); + /* Setup MSI caps & disable MSI/MSI-X interrupts */ + pci_msi_setup_pci_dev(dev); + /* Buffers for saving PCIe and PCI-X capabilities */ pci_allocate_cap_save_buffers(dev); -- cgit v1.2.3 From 128fc68ca1c3c73ed35ef9c7c50b8972de40322f Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 30 Nov 2015 19:35:53 -0600 Subject: PCI/MSI: Remove empty pci_msi_init_pci_dev() 4a7cc8316705 ("genirq/MSI: Move msi_list from struct pci_dev to struct device") removed the contents of pci_msi_init_pci_dev(). All implementation of it are now empty, so remove it completely. Signed-off-by: Bjorn Helgaas --- drivers/pci/msi.c | 4 ---- drivers/pci/pci.h | 2 -- drivers/pci/probe.c | 3 --- 3 files changed, 9 deletions(-) (limited to 'drivers/pci/probe.c') diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 53e463244bb7..b64d26719906 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1024,10 +1024,6 @@ int pci_msi_enabled(void) } EXPORT_SYMBOL(pci_msi_enabled); -void pci_msi_init_pci_dev(struct pci_dev *dev) -{ -} - /** * pci_enable_msi_range - configure device's MSI capability structure * @dev: device to configure diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fd2f03fa53f3..44d9859057b4 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -144,10 +144,8 @@ extern unsigned int pci_pm_d3_delay; #ifdef CONFIG_PCI_MSI void pci_no_msi(void); -void pci_msi_init_pci_dev(struct pci_dev *dev); #else static inline void pci_no_msi(void) { } -static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } #endif static inline void pci_msi_set_enable(struct pci_dev *dev, int enable) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cd94737af8fd..88f0fedbe891 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1601,9 +1601,6 @@ static void pci_init_capabilities(struct pci_dev *dev) /* Enhanced Allocation */ pci_ea_init(dev); - /* MSI/MSI-X list */ - pci_msi_init_pci_dev(dev); - /* Setup MSI caps & disable MSI/MSI-X interrupts */ pci_msi_setup_pci_dev(dev); -- cgit v1.2.3 From 8e5a395a040a7c72ec283f844eca679b924f5f01 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 7 Dec 2015 18:21:10 -0600 Subject: PCI: Simplify config space size computation Restructure the logic so we return the config space size as soon as we know it. This reduces indentation, removes negations, and removes gotos. No functional change. Signed-off-by: Bjorn Helgaas --- drivers/pci/probe.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'drivers/pci/probe.c') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index edb1984201e9..0d86c82b8880 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1107,14 +1107,11 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev) int pos = PCI_CFG_SPACE_SIZE; if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL) - goto fail; + return PCI_CFG_SPACE_SIZE; if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev)) - goto fail; + return PCI_CFG_SPACE_SIZE; return PCI_CFG_SPACE_EXP_SIZE; - - fail: - return PCI_CFG_SPACE_SIZE; } int pci_cfg_space_size(struct pci_dev *dev) @@ -1127,19 +1124,17 @@ int pci_cfg_space_size(struct pci_dev *dev) if (class == PCI_CLASS_BRIDGE_HOST) return pci_cfg_space_size_ext(dev); - if (!pci_is_pcie(dev)) { - pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); - if (!pos) - goto fail; + if (pci_is_pcie(dev)) + return pci_cfg_space_size_ext(dev); - pci_read_config_dword(dev, pos + PCI_X_STATUS, &status); - if (!(status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ))) - goto fail; - } + pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); + if (!pos) + return PCI_CFG_SPACE_SIZE; - return pci_cfg_space_size_ext(dev); + pci_read_config_dword(dev, pos + PCI_X_STATUS, &status); + if (status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ)) + return pci_cfg_space_size_ext(dev); - fail: return PCI_CFG_SPACE_SIZE; } -- cgit v1.2.3