mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 14:41:39 +00:00
857f864014
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJZEHmsAAoJEFmIoMA60/r88SgQAJbFddueb0+DfJ+USDud4b/Z akfS+G1UAm+TgtMyh1wM49dHzFssp36uWJxtWI+bPqBzuy94PMCbz7JVUV28gX9G tFhFuc5YH94I/3y85rbZnolb6uZN9MhLjzTFqDC9ilW6HFqmwK4t4wlHSCjQN1St svLYvs2G6n6/VK3Fre7/wOvdZ1erG4Qod+kn5Tx3K5TQydmRlaSBfK+DRANuDBkM KzGO7Bkc/Cx8hb9pHmaey/wxmNrrgmVjTtWrEnb2tEq833zP4h6GhUIJEKodMSi5 gXPNZgKlu3n5L592M0UCh4EoHejzkv9wrcsoDm+djmsc5Zg2Howq4kAdHP8k4hUG 0gt8n0ni9vhJN56jikrGi7cAdHCKSNnx2Ue/qTCbX0ncB3XUMuJxJwCsgW/6wa9f oU7tRtTS03UltnKoFAcyYclS4TaSY4SA4ySaK6Hi+cRkdVFDdyHQYbHHNSU7MsA+ IS2tXvGoIdSYyrZMHSRcl2rRTfYQUkmPEvBF3LvqZr32M4mJMmUNAPLZaly373ZE iwq0ZJlrLeM0cqdFIG3S60RtJyQk/HBN1NMqrYHArWOxvWIgNd5F8NCsTTxY3wU3 IxgBIuUFcbVwVkqEHGs8K5AvB3oghqdnA3eGOV79799eMtLn3LOvyIlpHMSw9WUq ags00JtMLitfNPBH3eSl =eE4D -----END PGP SIGNATURE----- Merge tag 'pci-v4.12-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci Pull PCI updates from Bjorn Helgaas: - add framework for supporting PCIe devices in Endpoint mode (Kishon Vijay Abraham I) - use non-postable PCI config space mappings when possible (Lorenzo Pieralisi) - clean up and unify mmap of PCI BARs (David Woodhouse) - export and unify Function Level Reset support (Christoph Hellwig) - avoid FLR for Intel 82579 NICs (Sasha Neftin) - add pci_request_irq() and pci_free_irq() helpers (Christoph Hellwig) - short-circuit config access failures for disconnected devices (Keith Busch) - remove D3 sleep delay when possible (Adrian Hunter) - freeze PME scan before suspending devices (Lukas Wunner) - stop disabling MSI/MSI-X in pci_device_shutdown() (Prarit Bhargava) - disable boot interrupt quirk for ASUS M2N-LR (Stefan Assmann) - add arch-specific alignment control to improve device passthrough by avoiding multiple BARs in a page (Yongji Xie) - add sysfs sriov_drivers_autoprobe to control VF driver binding (Bodong Wang) - allow slots below PCI-to-PCIe "reverse bridges" (Bjorn Helgaas) - fix crashes when unbinding host controllers that don't support removal (Brian Norris) - add driver for MicroSemi Switchtec management interface (Logan Gunthorpe) - add driver for Faraday Technology FTPCI100 host bridge (Linus Walleij) - add i.MX7D support (Andrey Smirnov) - use generic MSI support for Aardvark (Thomas Petazzoni) - make Rockchip driver modular (Brian Norris) - advertise 128-byte Read Completion Boundary support for Rockchip (Shawn Lin) - advertise PCI_EXP_LNKSTA_SLC for Rockchip root port (Shawn Lin) - convert atomic_t to refcount_t in HV driver (Elena Reshetova) - add CPU IRQ affinity in HV driver (K. Y. Srinivasan) - fix PCI bus removal in HV driver (Long Li) - add support for ThunderX2 DMA alias topology (Jayachandran C) - add ThunderX pass2.x 2nd node MCFG quirk (Tomasz Nowicki) - add ITE 8893 bridge DMA alias quirk (Jarod Wilson) - restrict Cavium ACS quirk only to CN81xx/CN83xx/CN88xx devices (Manish Jaggi) * tag 'pci-v4.12-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (146 commits) PCI: Don't allow unbinding host controllers that aren't prepared ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP MAINTAINERS: Add PCI Endpoint maintainer Documentation: PCI: Add userguide for PCI endpoint test function tools: PCI: Add sample test script to invoke pcitest tools: PCI: Add a userspace tool to test PCI endpoint Documentation: misc-devices: Add Documentation for pci-endpoint-test driver misc: Add host side PCI driver for PCI test function device PCI: Add device IDs for DRA74x and DRA72x dt-bindings: PCI: dra7xx: Add DT bindings to enable unaligned access PCI: dwc: dra7xx: Workaround for errata id i870 dt-bindings: PCI: dra7xx: Add DT bindings for PCI dra7xx EP mode PCI: dwc: dra7xx: Add EP mode support PCI: dwc: dra7xx: Facilitate wrapper and MSI interrupts to be enabled independently dt-bindings: PCI: Add DT bindings for PCI designware EP mode PCI: dwc: designware: Add EP mode support Documentation: PCI: Add binding documentation for pci-test endpoint function ixgbe: Use pcie_flr() instead of duplicating it IB/hfi1: Use pcie_flr() instead of duplicating it PCI: imx6: Fix spelling mistake: "contol" -> "control" ...
121 lines
3.8 KiB
C
121 lines
3.8 KiB
C
/*
|
|
* PCI IRQ handling code
|
|
*
|
|
* Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com>
|
|
* Copyright (C) 2017 Christoph Hellwig.
|
|
*/
|
|
|
|
#include <linux/acpi.h>
|
|
#include <linux/device.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/export.h>
|
|
#include <linux/pci.h>
|
|
|
|
static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason)
|
|
{
|
|
struct pci_dev *parent = to_pci_dev(pdev->dev.parent);
|
|
|
|
dev_err(&pdev->dev,
|
|
"Potentially misrouted IRQ (Bridge %s %04x:%04x)\n",
|
|
dev_name(&parent->dev), parent->vendor, parent->device);
|
|
dev_err(&pdev->dev, "%s\n", reason);
|
|
dev_err(&pdev->dev, "Please report to linux-kernel@vger.kernel.org\n");
|
|
WARN_ON(1);
|
|
}
|
|
|
|
/**
|
|
* pci_lost_interrupt - reports a lost PCI interrupt
|
|
* @pdev: device whose interrupt is lost
|
|
*
|
|
* The primary function of this routine is to report a lost interrupt
|
|
* in a standard way which users can recognise (instead of blaming the
|
|
* driver).
|
|
*
|
|
* Returns:
|
|
* a suggestion for fixing it (although the driver is not required to
|
|
* act on this).
|
|
*/
|
|
enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *pdev)
|
|
{
|
|
if (pdev->msi_enabled || pdev->msix_enabled) {
|
|
enum pci_lost_interrupt_reason ret;
|
|
|
|
if (pdev->msix_enabled) {
|
|
pci_note_irq_problem(pdev, "MSIX routing failure");
|
|
ret = PCI_LOST_IRQ_DISABLE_MSIX;
|
|
} else {
|
|
pci_note_irq_problem(pdev, "MSI routing failure");
|
|
ret = PCI_LOST_IRQ_DISABLE_MSI;
|
|
}
|
|
return ret;
|
|
}
|
|
#ifdef CONFIG_ACPI
|
|
if (!(acpi_disabled || acpi_noirq)) {
|
|
pci_note_irq_problem(pdev, "Potential ACPI misrouting please reboot with acpi=noirq");
|
|
/* currently no way to fix acpi on the fly */
|
|
return PCI_LOST_IRQ_DISABLE_ACPI;
|
|
}
|
|
#endif
|
|
pci_note_irq_problem(pdev, "unknown cause (not MSI or ACPI)");
|
|
return PCI_LOST_IRQ_NO_INFORMATION;
|
|
}
|
|
EXPORT_SYMBOL(pci_lost_interrupt);
|
|
|
|
/**
|
|
* pci_request_irq - allocate an interrupt line for a PCI device
|
|
* @dev: PCI device to operate on
|
|
* @nr: device-relative interrupt vector index (0-based).
|
|
* @handler: Function to be called when the IRQ occurs.
|
|
* Primary handler for threaded interrupts.
|
|
* If NULL and thread_fn != NULL the default primary handler is
|
|
* installed.
|
|
* @thread_fn: Function called from the IRQ handler thread
|
|
* If NULL, no IRQ thread is created
|
|
* @dev_id: Cookie passed back to the handler function
|
|
* @fmt: Printf-like format string naming the handler
|
|
*
|
|
* This call allocates interrupt resources and enables the interrupt line and
|
|
* IRQ handling. From the point this call is made @handler and @thread_fn may
|
|
* be invoked. All interrupts requested using this function might be shared.
|
|
*
|
|
* @dev_id must not be NULL and must be globally unique.
|
|
*/
|
|
int pci_request_irq(struct pci_dev *dev, unsigned int nr, irq_handler_t handler,
|
|
irq_handler_t thread_fn, void *dev_id, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
int ret;
|
|
char *devname;
|
|
|
|
va_start(ap, fmt);
|
|
devname = kvasprintf(GFP_KERNEL, fmt, ap);
|
|
va_end(ap);
|
|
|
|
ret = request_threaded_irq(pci_irq_vector(dev, nr), handler, thread_fn,
|
|
IRQF_SHARED, devname, dev_id);
|
|
if (ret)
|
|
kfree(devname);
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(pci_request_irq);
|
|
|
|
/**
|
|
* pci_free_irq - free an interrupt allocated with pci_request_irq
|
|
* @dev: PCI device to operate on
|
|
* @nr: device-relative interrupt vector index (0-based).
|
|
* @dev_id: Device identity to free
|
|
*
|
|
* Remove an interrupt handler. The handler is removed and if the interrupt
|
|
* line is no longer in use by any driver it is disabled. The caller must
|
|
* ensure the interrupt is disabled on the device before calling this function.
|
|
* The function does not return until any executing interrupts for this IRQ
|
|
* have completed.
|
|
*
|
|
* This function must not be called from interrupt context.
|
|
*/
|
|
void pci_free_irq(struct pci_dev *dev, unsigned int nr, void *dev_id)
|
|
{
|
|
kfree(free_irq(pci_irq_vector(dev, nr), dev_id));
|
|
}
|
|
EXPORT_SYMBOL(pci_free_irq);
|