^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * pci_irq.c - ACPI PCI Interrupt Routing ($Revision: 11 $)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Bjorn Helgaas <bjorn.helgaas@hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/dmi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define PREFIX "ACPI: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define _COMPONENT ACPI_PCI_COMPONENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ACPI_MODULE_NAME("pci_irq");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct acpi_prt_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct acpi_pci_id id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u8 pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) acpi_handle link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u32 index; /* GSI, or link _CRS index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static inline char pin_name(int pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) return 'A' + pin - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) PCI IRQ Routing Table (PRT) Support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) -------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* http://bugzilla.kernel.org/show_bug.cgi?id=4773 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static const struct dmi_system_id medion_md9580[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) .ident = "Medion MD9580-F laptop",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) .matches = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) DMI_MATCH(DMI_PRODUCT_NAME, "A555"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* http://bugzilla.kernel.org/show_bug.cgi?id=5044 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static const struct dmi_system_id dell_optiplex[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) .ident = "Dell Optiplex GX1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .matches = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX1 600S+"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* http://bugzilla.kernel.org/show_bug.cgi?id=10138 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static const struct dmi_system_id hp_t5710[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .ident = "HP t5710",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .matches = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) DMI_MATCH(DMI_PRODUCT_NAME, "hp t5000 series"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) DMI_MATCH(DMI_BOARD_NAME, "098Ch"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct prt_quirk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) const struct dmi_system_id *system;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) unsigned int segment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned int bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned int device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) unsigned char pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) const char *source; /* according to BIOS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) const char *actual_source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define PCI_INTX_PIN(c) (c - 'A' + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * These systems have incorrect _PRT entries. The BIOS claims the PCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * interrupt at the listed segment/bus/device/pin is connected to the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * link device, but it is actually connected to the second.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static const struct prt_quirk prt_quirks[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) { medion_md9580, 0, 0, 9, PCI_INTX_PIN('A'),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) "\\_SB_.PCI0.ISA_.LNKA",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) "\\_SB_.PCI0.ISA_.LNKB"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) { dell_optiplex, 0, 0, 0xd, PCI_INTX_PIN('A'),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) "\\_SB_.LNKB",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) "\\_SB_.LNKA"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) { hp_t5710, 0, 0, 1, PCI_INTX_PIN('A'),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) "\\_SB_.PCI0.LNK1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) "\\_SB_.PCI0.LNK3"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static void do_prt_fixups(struct acpi_prt_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct acpi_pci_routing_table *prt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) const struct prt_quirk *quirk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) for (i = 0; i < ARRAY_SIZE(prt_quirks); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) quirk = &prt_quirks[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* All current quirks involve link devices, not GSIs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (dmi_check_system(quirk->system) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) entry->id.segment == quirk->segment &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) entry->id.bus == quirk->bus &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) entry->id.device == quirk->device &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) entry->pin == quirk->pin &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) !strcmp(prt->source, quirk->source) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) strlen(prt->source) >= strlen(quirk->actual_source)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) printk(KERN_WARNING PREFIX "firmware reports "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) "%04x:%02x:%02x PCI INT %c connected to %s; "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) "changing to %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) entry->id.segment, entry->id.bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) entry->id.device, pin_name(entry->pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) prt->source, quirk->actual_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) strcpy(prt->source, quirk->actual_source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static int acpi_pci_irq_check_entry(acpi_handle handle, struct pci_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int pin, struct acpi_pci_routing_table *prt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct acpi_prt_entry **entry_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int segment = pci_domain_nr(dev->bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int bus = dev->bus->number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int device = pci_ari_enabled(dev->bus) ? 0 : PCI_SLOT(dev->devfn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct acpi_prt_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (((prt->address >> 16) & 0xffff) != device ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) prt->pin + 1 != pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (!entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * Note that the _PRT uses 0=INTA, 1=INTB, etc, while PCI uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * it here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) entry->id.segment = segment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) entry->id.bus = bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) entry->id.device = (prt->address >> 16) & 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) entry->pin = prt->pin + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) do_prt_fixups(entry, prt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) entry->index = prt->source_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * Type 1: Dynamic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * The 'source' field specifies the PCI interrupt link device used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * configure the IRQ assigned to this slot|dev|pin. The 'source_index'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * indicates which resource descriptor in the resource template (of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * the link device) this interrupt is allocated from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * NOTE: Don't query the Link Device for IRQ information at this time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * because Link Device enumeration may not have occurred yet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * (e.g. exists somewhere 'below' this _PRT entry in the ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * namespace).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (prt->source[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) acpi_get_handle(handle, prt->source, &entry->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * Type 2: Static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * --------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * The 'source' field is NULL, and the 'source_index' field specifies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * the IRQ value, which is hardwired to specific interrupt inputs on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * the interrupt controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) " %04x:%02x:%02x[%c] -> %s[%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) entry->id.segment, entry->id.bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) entry->id.device, pin_name(entry->pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) prt->source, entry->index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) *entry_ptr = entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int pin, struct acpi_prt_entry **entry_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct acpi_pci_routing_table *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) acpi_handle handle = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (dev->bus->bridge)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) handle = ACPI_HANDLE(dev->bus->bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (!handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) status = acpi_get_irq_routing_table(handle, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) kfree(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) entry = buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) while (entry && (entry->length > 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (!acpi_pci_irq_check_entry(handle, dev, pin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) entry, entry_ptr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) entry = (struct acpi_pci_routing_table *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ((unsigned long)entry + entry->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) kfree(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /* --------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) PCI Interrupt Routing Support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) -------------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #ifdef CONFIG_X86_IO_APIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) extern int noioapicquirk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) extern int noioapicreroute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static int bridge_has_boot_interrupt_variant(struct pci_bus *bus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct pci_bus *bus_it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) for (bus_it = bus ; bus_it ; bus_it = bus_it->parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (!bus_it->self)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) if (bus_it->self->irq_reroute_variant)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return bus_it->self->irq_reroute_variant;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * Some chipsets (e.g. Intel 6700PXH) generate a legacy INTx when the IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * entry in the chipset's IO-APIC is masked (as, e.g. the RT kernel does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * during interrupt handling). When this INTx generation cannot be disabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * we reroute these interrupts to their legacy equivalent to get rid of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * spurious interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static int acpi_reroute_boot_interrupt(struct pci_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) struct acpi_prt_entry *entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (noioapicquirk || noioapicreroute) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) switch (bridge_has_boot_interrupt_variant(dev->bus)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /* no rerouting necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) case INTEL_IRQ_REROUTE_VARIANT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * Remap according to INTx routing table in 6700PXH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * specs, intel order number 302628-002, section
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * 2.15.2. Other chipsets (80332, ...) have the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * mapping and are handled here as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) dev_info(&dev->dev, "PCI IRQ %d -> rerouted to legacy "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) "IRQ %d\n", entry->index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) (entry->index % 4) + 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) entry->index = (entry->index % 4) + 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) dev_warn(&dev->dev, "Cannot reroute IRQ %d to legacy "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) "IRQ: unknown mapping\n", entry->index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #endif /* CONFIG_X86_IO_APIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) struct acpi_prt_entry *entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) struct pci_dev *bridge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) u8 bridge_pin, orig_pin = pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ret = acpi_pci_irq_find_prt_entry(dev, pin, &entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (!ret && entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #ifdef CONFIG_X86_IO_APIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) acpi_reroute_boot_interrupt(dev, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #endif /* CONFIG_X86_IO_APIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s[%c] _PRT entry\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) pci_name(dev), pin_name(pin)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) return entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * Attempt to derive an IRQ for this device from a parent bridge's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) bridge = dev->bus->self;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) while (bridge) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) pin = pci_swizzle_interrupt_pin(dev, pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /* PC card has the same IRQ as its cardbridge */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) bridge_pin = bridge->pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (!bridge_pin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) "No interrupt pin configured for device %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) pci_name(bridge)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) pin = bridge_pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) ret = acpi_pci_irq_find_prt_entry(bridge, pin, &entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (!ret && entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) "Derived GSI for %s INT %c from %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) pci_name(dev), pin_name(orig_pin),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) pci_name(bridge)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) return entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) dev = bridge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) bridge = dev->bus->self;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) pin_name(orig_pin));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) #if IS_ENABLED(CONFIG_ISA) || IS_ENABLED(CONFIG_EISA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) static int acpi_isa_register_gsi(struct pci_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) u32 dev_gsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /* Interrupt Line values above 0xF are forbidden */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) if (dev->irq > 0 && (dev->irq <= 0xF) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) acpi_isa_irq_available(dev->irq) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) (acpi_isa_irq_to_gsi(dev->irq, &dev_gsi) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) dev_warn(&dev->dev, "PCI INT %c: no GSI - using ISA IRQ %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) pin_name(dev->pin), dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) acpi_register_gsi(&dev->dev, dev_gsi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) ACPI_LEVEL_SENSITIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) ACPI_ACTIVE_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) static inline int acpi_isa_register_gsi(struct pci_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) static inline bool acpi_pci_irq_valid(struct pci_dev *dev, u8 pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) #ifdef CONFIG_X86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) * On x86 irq line 0xff means "unknown" or "no connection"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * (PCI 3.0, Section 6.2.4, footnote on page 223).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (dev->irq == 0xff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) dev->irq = IRQ_NOTCONNECTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) dev_warn(&dev->dev, "PCI INT %c: not connected\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) pin_name(pin));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) int acpi_pci_irq_enable(struct pci_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) struct acpi_prt_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) int gsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) u8 pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) int triggering = ACPI_LEVEL_SENSITIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * On ARM systems with the GIC interrupt model, level interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * are always polarity high by specification; PCI legacy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) * IRQs lines are inverted before reaching the interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * controller and must therefore be considered active high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * as default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) int polarity = acpi_irq_model == ACPI_IRQ_MODEL_GIC ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) ACPI_ACTIVE_HIGH : ACPI_ACTIVE_LOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) char *link = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) char link_desc[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) pin = dev->pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if (!pin) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) ACPI_DEBUG_PRINT((ACPI_DB_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) "No interrupt pin configured for device %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) pci_name(dev)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) if (dev->irq_managed && dev->irq > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) entry = acpi_pci_irq_lookup(dev, pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if (!entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * IDE legacy mode controller IRQs are magic. Why do compat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * extensions always make such a nasty mess.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) (dev->class & 0x05) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) if (entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (entry->link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) gsi = acpi_pci_link_allocate_irq(entry->link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) entry->index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) &triggering, &polarity,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) &link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) gsi = entry->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) gsi = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) if (gsi < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) * No IRQ known to the ACPI subsystem - maybe the BIOS /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * driver reported one, then use it. Exit in any case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) if (!acpi_pci_irq_valid(dev, pin)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (acpi_isa_register_gsi(dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) pin_name(pin));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) rc = acpi_register_gsi(&dev->dev, gsi, triggering, polarity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) if (rc < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) pin_name(pin));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) dev->irq = rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) dev->irq_managed = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) link_desc[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) dev_dbg(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) pin_name(pin), link_desc, gsi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) void acpi_pci_irq_disable(struct pci_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) struct acpi_prt_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) int gsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) u8 pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) pin = dev->pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) if (!pin || !dev->irq_managed || dev->irq <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /* Keep IOAPIC pin configuration when suspending */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) if (dev->dev.power.is_prepared)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) if (dev->dev.power.runtime_status == RPM_SUSPENDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) entry = acpi_pci_irq_lookup(dev, pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) if (!entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if (entry->link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) gsi = acpi_pci_link_free_irq(entry->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) gsi = entry->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * TBD: It might be worth clearing dev->irq by magic constant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * (e.g. PCI_UNDEFINED_IRQ).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (gsi >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) acpi_unregister_gsi(gsi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) dev->irq_managed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) }