]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge branch 'pci/misc'
authorBjorn Helgaas <bhelgaas@google.com>
Sat, 20 Oct 2018 16:45:30 +0000 (11:45 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Sat, 20 Oct 2018 16:45:30 +0000 (11:45 -0500)
  - Remove unused Netronome NFP32xx Device IDs (Jakub Kicinski)

  - Use bitmap_zalloc() for dma_alias_mask (Andy Shevchenko)

  - Add switch fall-through annotations (Gustavo A. R. Silva)

  - Remove unused Switchtec quirk variable (Joshua Abraham)

  - Fix pci.c kernel-doc warning (Randy Dunlap)

  - Remove trivial PCI wrappers for DMA APIs (Christoph Hellwig)

  - Add Intel GPU device IDs to spurious interrupt quirk (Bin Meng)

  - Run Switchtec DMA aliasing quirk only on NTB endpoints to avoid useless
    dmesg errors (Logan Gunthorpe)

  - Update Switchtec NTB documentation (Wesley Yung)

  - Remove redundant "default n" from Kconfig (Bartlomiej Zolnierkiewicz)

* pci/misc:
  PCI: pcie: Remove redundant 'default n' from Kconfig
  NTB: switchtec_ntb: Update switchtec documentation with prerequisites for NTB
  PCI: Fix Switchtec DMA aliasing quirk dmesg noise
  PCI: Add macro for Switchtec quirk declarations
  PCI: Add Device IDs for Intel GPU "spurious interrupt" quirk
  PCI: Remove pci_set_dma_max_seg_size()
  PCI: Remove pci_set_dma_seg_boundary()
  PCI: Remove pci_unmap_addr() wrappers for DMA API
  PCI / ACPI: Mark expected switch fall-through
  PCI: Remove set but unused variable
  PCI: Fix pci.c kernel-doc parameter warning
  PCI: Allocate dma_alias_mask with bitmap_zalloc()
  PCI: Remove unused NFP32xx IDs

1  2 
drivers/pci/pci-acpi.c
drivers/pci/pci.c
drivers/pci/probe.c
drivers/scsi/aacraid/linit.c
include/linux/pci.h

diff --combined drivers/pci/pci-acpi.c
index 79c8e955a0ab023fb99931fd67764de9bbed5204,deb96d1a47284771a59053a688ce77e0acff4884..2a4aa64685794434f9ffdc5c38613035e63038f3
@@@ -519,46 -519,6 +519,46 @@@ static pci_power_t acpi_pci_choose_stat
        return PCI_POWER_ERROR;
  }
  
 +static struct acpi_device *acpi_pci_find_companion(struct device *dev);
 +
 +static bool acpi_pci_bridge_d3(struct pci_dev *dev)
 +{
 +      const struct fwnode_handle *fwnode;
 +      struct acpi_device *adev;
 +      struct pci_dev *root;
 +      u8 val;
 +
 +      if (!dev->is_hotplug_bridge)
 +              return false;
 +
 +      /*
 +       * Look for a special _DSD property for the root port and if it
 +       * is set we know the hierarchy behind it supports D3 just fine.
 +       */
 +      root = pci_find_pcie_root_port(dev);
 +      if (!root)
 +              return false;
 +
 +      adev = ACPI_COMPANION(&root->dev);
 +      if (root == dev) {
 +              /*
 +               * It is possible that the ACPI companion is not yet bound
 +               * for the root port so look it up manually here.
 +               */
 +              if (!adev && !pci_dev_is_added(root))
 +                      adev = acpi_pci_find_companion(&root->dev);
 +      }
 +
 +      if (!adev)
 +              return false;
 +
 +      fwnode = acpi_fwnode_handle(adev);
 +      if (fwnode_property_read_u8(fwnode, "HotPlugSupportInD3", &val))
 +              return false;
 +
 +      return val == 1;
 +}
 +
  static bool acpi_pci_power_manageable(struct pci_dev *dev)
  {
        struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
@@@ -588,6 -548,7 +588,7 @@@ static int acpi_pci_set_power_state(str
                        error = -EBUSY;
                        break;
                }
+               /* Fall through */
        case PCI_D0:
        case PCI_D1:
        case PCI_D2:
@@@ -675,7 -636,6 +676,7 @@@ static bool acpi_pci_need_resume(struc
  }
  
  static const struct pci_platform_pm_ops acpi_pci_platform_pm = {
 +      .bridge_d3 = acpi_pci_bridge_d3,
        .is_manageable = acpi_pci_power_manageable,
        .set_state = acpi_pci_set_power_state,
        .get_state = acpi_pci_get_power_state,
@@@ -792,15 -752,10 +793,15 @@@ static void pci_acpi_setup(struct devic
  {
        struct pci_dev *pci_dev = to_pci_dev(dev);
        struct acpi_device *adev = ACPI_COMPANION(dev);
 +      int node;
  
        if (!adev)
                return;
  
 +      node = acpi_get_node(adev->handle);
 +      if (node != NUMA_NO_NODE)
 +              set_dev_node(dev, node);
 +
        pci_acpi_optimize_delay(pci_dev, adev->handle);
  
        pci_acpi_add_pm_notifier(adev, pci_dev);
                return;
  
        device_set_wakeup_capable(dev, true);
 +      /*
 +       * For bridges that can do D3 we enable wake automatically (as
 +       * we do for the power management itself in that case). The
 +       * reason is that the bridge may have additional methods such as
 +       * _DSW that need to be called.
 +       */
 +      if (pci_dev->bridge_d3)
 +              device_wakeup_enable(dev);
 +
        acpi_pci_wakeup(pci_dev, false);
  }
  
  static void pci_acpi_cleanup(struct device *dev)
  {
        struct acpi_device *adev = ACPI_COMPANION(dev);
 +      struct pci_dev *pci_dev = to_pci_dev(dev);
  
        if (!adev)
                return;
  
        pci_acpi_remove_pm_notifier(adev);
 -      if (adev->wakeup.flags.valid)
 +      if (adev->wakeup.flags.valid) {
 +              if (pci_dev->bridge_d3)
 +                      device_wakeup_disable(dev);
 +
                device_set_wakeup_capable(dev, false);
 +      }
  }
  
  static bool pci_acpi_bus_match(struct device *dev)
diff --combined drivers/pci/pci.c
index b309ce8555775731117d9a2a1e25be257abb2d88,455783d3acdfc6a6795ad19541df849b9ebeebd9..535c9f974de293f0b6d71fb447d549fdd370cbf7
@@@ -35,8 -35,6 +35,8 @@@
  #include <linux/aer.h>
  #include "pci.h"
  
 +DEFINE_MUTEX(pci_slot_mutex);
 +
  const char *pci_power_names[] = {
        "error", "D0", "D1", "D2", "D3hot", "D3cold", "unknown",
  };
@@@ -198,7 -196,7 +198,7 @@@ EXPORT_SYMBOL_GPL(pci_ioremap_wc_bar)
  /**
   * pci_dev_str_match_path - test if a path string matches a device
   * @dev:    the PCI device to test
-  * @p:      string to match the device against
+  * @path:   string to match the device against
   * @endptr: pointer to the string after the match
   *
   * Test if a string (typically from a kernel parameter) formatted as a
@@@ -793,11 -791,6 +793,11 @@@ static inline bool platform_pci_need_re
        return pci_platform_pm ? pci_platform_pm->need_resume(dev) : false;
  }
  
 +static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
 +{
 +      return pci_platform_pm ? pci_platform_pm->bridge_d3(dev) : false;
 +}
 +
  /**
   * pci_raw_set_power_state - Use PCI PM registers to set the power state of
   *                           given PCI device
@@@ -1006,7 -999,7 +1006,7 @@@ static void __pci_start_power_transitio
                 * because have already delayed for the bridge.
                 */
                if (dev->runtime_d3cold) {
 -                      if (dev->d3cold_delay)
 +                      if (dev->d3cold_delay && !dev->imm_ready)
                                msleep(dev->d3cold_delay);
                        /*
                         * When powering on a bridge from D3cold, the
@@@ -1291,7 -1284,6 +1291,7 @@@ int pci_save_state(struct pci_dev *dev
        if (i != 0)
                return i;
  
 +      pci_save_dpc_state(dev);
        return pci_save_vc_state(dev);
  }
  EXPORT_SYMBOL(pci_save_state);
@@@ -1386,7 -1378,6 +1386,7 @@@ void pci_restore_state(struct pci_dev *
        pci_restore_ats_state(dev);
        pci_restore_vc_state(dev);
        pci_restore_rebar_state(dev);
 +      pci_restore_dpc_state(dev);
  
        pci_cleanup_aer_error_status_regs(dev);
  
@@@ -2142,13 -2133,10 +2142,13 @@@ static int __pci_enable_wake(struct pci
        int ret = 0;
  
        /*
 -       * Bridges can only signal wakeup on behalf of subordinate devices,
 -       * but that is set up elsewhere, so skip them.
 +       * Bridges that are not power-manageable directly only signal
 +       * wakeup on behalf of subordinate devices which is set up
 +       * elsewhere, so skip them. However, bridges that are
 +       * power-manageable may signal wakeup for themselves (for example,
 +       * on a hotplug event) and they need to be covered here.
         */
 -      if (pci_has_subordinate(dev))
 +      if (!pci_power_manageable(dev))
                return 0;
  
        /* Don't do the same thing twice in a row for one device. */
@@@ -2523,10 -2511,6 +2523,10 @@@ bool pci_bridge_d3_possible(struct pci_
                if (bridge->is_thunderbolt)
                        return true;
  
 +              /* Platform might know better if the bridge supports D3 */
 +              if (platform_pci_bridge_d3(bridge))
 +                      return true;
 +
                /*
                 * Hotplug ports handled natively by the OS were not validated
                 * by vendors for runtime D3 at least until 2018 because there
@@@ -2660,7 -2644,6 +2660,7 @@@ EXPORT_SYMBOL_GPL(pci_d3cold_disable)
  void pci_pm_init(struct pci_dev *dev)
  {
        int pm;
 +      u16 status;
        u16 pmc;
  
        pm_runtime_forbid(&dev->dev);
                /* Disable the PME# generation functionality */
                pci_pme_active(dev, false);
        }
 +
 +      pci_read_config_word(dev, PCI_STATUS, &status);
 +      if (status & PCI_STATUS_IMM_READY)
 +              dev->imm_ready = 1;
  }
  
  static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)
@@@ -4397,9 -4376,6 +4397,9 @@@ int pcie_flr(struct pci_dev *dev
  
        pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
  
 +      if (dev->imm_ready)
 +              return 0;
 +
        /*
         * Per PCIe r4.0, sec 6.6.2, a device must complete an FLR within
         * 100ms, but may silently discard requests while the FLR is in
@@@ -4441,9 -4417,6 +4441,9 @@@ static int pci_af_flr(struct pci_dev *d
  
        pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
  
 +      if (dev->imm_ready)
 +              return 0;
 +
        /*
         * Per Advanced Capabilities for Conventional PCI ECN, 13 April 2006,
         * updated 27 July 2006; a device must complete an FLR within
@@@ -4512,42 -4485,21 +4512,42 @@@ bool pcie_wait_for_link(struct pci_dev 
        bool ret;
        u16 lnk_status;
  
 +      /*
 +       * Some controllers might not implement link active reporting. In this
 +       * case, we wait for 1000 + 100 ms.
 +       */
 +      if (!pdev->link_active_reporting) {
 +              msleep(1100);
 +              return true;
 +      }
 +
 +      /*
 +       * PCIe r4.0 sec 6.6.1, a component must enter LTSSM Detect within 20ms,
 +       * after which we should expect an link active if the reset was
 +       * successful. If so, software must wait a minimum 100ms before sending
 +       * configuration requests to devices downstream this port.
 +       *
 +       * If the link fails to activate, either the device was physically
 +       * removed or the link is permanently failed.
 +       */
 +      if (active)
 +              msleep(20);
        for (;;) {
                pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
                ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA);
                if (ret == active)
 -                      return true;
 +                      break;
                if (timeout <= 0)
                        break;
                msleep(10);
                timeout -= 10;
        }
 -
 -      pci_info(pdev, "Data Link Layer Link Active not %s in 1000 msec\n",
 -               active ? "set" : "cleared");
 -
 -      return false;
 +      if (active && ret)
 +              msleep(100);
 +      else if (ret != active)
 +              pci_info(pdev, "Data Link Layer Link Active not %s in 1000 msec\n",
 +                      active ? "set" : "cleared");
 +      return ret == active;
  }
  
  void pci_reset_secondary_bus(struct pci_dev *dev)
@@@ -4619,13 -4571,13 +4619,13 @@@ static int pci_reset_hotplug_slot(struc
  {
        int rc = -ENOTTY;
  
 -      if (!hotplug || !try_module_get(hotplug->ops->owner))
 +      if (!hotplug || !try_module_get(hotplug->owner))
                return rc;
  
        if (hotplug->ops->reset_slot)
                rc = hotplug->ops->reset_slot(hotplug, probe);
  
 -      module_put(hotplug->ops->owner);
 +      module_put(hotplug->owner);
  
        return rc;
  }
@@@ -5201,41 -5153,6 +5201,41 @@@ static int pci_bus_reset(struct pci_bu
        return ret;
  }
  
 +/**
 + * pci_bus_error_reset - reset the bridge's subordinate bus
 + * @bridge: The parent device that connects to the bus to reset
 + *
 + * This function will first try to reset the slots on this bus if the method is
 + * available. If slot reset fails or is not available, this will fall back to a
 + * secondary bus reset.
 + */
 +int pci_bus_error_reset(struct pci_dev *bridge)
 +{
 +      struct pci_bus *bus = bridge->subordinate;
 +      struct pci_slot *slot;
 +
 +      if (!bus)
 +              return -ENOTTY;
 +
 +      mutex_lock(&pci_slot_mutex);
 +      if (list_empty(&bus->slots))
 +              goto bus_reset;
 +
 +      list_for_each_entry(slot, &bus->slots, list)
 +              if (pci_probe_reset_slot(slot))
 +                      goto bus_reset;
 +
 +      list_for_each_entry(slot, &bus->slots, list)
 +              if (pci_slot_reset(slot, 0))
 +                      goto bus_reset;
 +
 +      mutex_unlock(&pci_slot_mutex);
 +      return 0;
 +bus_reset:
 +      mutex_unlock(&pci_slot_mutex);
 +      return pci_bus_reset(bridge->subordinate, 0);
 +}
 +
  /**
   * pci_probe_reset_bus - probe whether a PCI bus can be reset
   * @bus: PCI bus to probe
@@@ -5773,8 -5690,7 +5773,7 @@@ int pci_set_vga_state(struct pci_dev *d
  void pci_add_dma_alias(struct pci_dev *dev, u8 devfn)
  {
        if (!dev->dma_alias_mask)
-               dev->dma_alias_mask = kcalloc(BITS_TO_LONGS(U8_MAX),
-                                             sizeof(long), GFP_KERNEL);
+               dev->dma_alias_mask = bitmap_zalloc(U8_MAX, GFP_KERNEL);
        if (!dev->dma_alias_mask) {
                pci_warn(dev, "Unable to allocate DMA alias mask\n");
                return;
diff --combined drivers/pci/probe.c
index bb2999d1b199a0b46a59374a1d68e521e4edf4bb,75d8965493604ddda271d1f96c062f5cfe489ba6..966641d517ba701a82aa9d316f6a0f499bfcebc2
@@@ -713,7 -713,6 +713,7 @@@ static void pci_set_bus_speed(struct pc
  
                pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap);
                bus->max_bus_speed = pcie_link_speed[linkcap & PCI_EXP_LNKCAP_SLS];
 +              bridge->link_active_reporting = !!(linkcap & PCI_EXP_LNKCAP_DLLLARC);
  
                pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta);
                pcie_update_link_speed(bus, linksta);
@@@ -2144,7 -2143,7 +2144,7 @@@ static void pci_release_dev(struct devi
        pcibios_release_device(pci_dev);
        pci_bus_put(pci_dev->bus);
        kfree(pci_dev->driver_override);
-       kfree(pci_dev->dma_alias_mask);
+       bitmap_free(pci_dev->dma_alias_mask);
        kfree(pci_dev);
  }
  
@@@ -2398,8 -2397,8 +2398,8 @@@ void pci_device_add(struct pci_dev *dev
        dev->dev.dma_parms = &dev->dma_parms;
        dev->dev.coherent_dma_mask = 0xffffffffull;
  
-       pci_set_dma_max_seg_size(dev, 65536);
-       pci_set_dma_seg_boundary(dev, 0xffffffff);
+       dma_set_max_seg_size(&dev->dev, 65536);
+       dma_set_seg_boundary(&dev->dev, 0xffffffff);
  
        /* Fix up broken headers */
        pci_fixup_device(pci_fixup_header, dev);
index 1bcdd50786f1db22dca330015c5ed2569e3f42fe,53eb2e9569b91595b623b2402ad99f9ba58e70da..2d4e4ddc5acecfe4608a43a4609c2a69405539de
@@@ -1747,7 -1747,7 +1747,7 @@@ static int aac_probe_one(struct pci_de
                shost->max_sectors = (shost->sg_tablesize * 8) + 112;
        }
  
-       error = pci_set_dma_max_seg_size(pdev,
+       error = dma_set_max_seg_size(&pdev->dev,
                (aac->adapter_info.options & AAC_OPT_NEW_COMM) ?
                        (shost->max_sectors << 9) : 65536);
        if (error)
@@@ -2055,6 -2055,8 +2055,6 @@@ static void aac_pci_resume(struct pci_d
        struct scsi_device *sdev = NULL;
        struct aac_dev *aac = (struct aac_dev *)shost_priv(shost);
  
 -      pci_cleanup_aer_uncorrect_error_status(pdev);
 -
        if (aac_adapter_ioremap(aac, aac->base_size)) {
  
                dev_err(&pdev->dev, "aacraid: ioremap failed\n");
diff --combined include/linux/pci.h
index 45f60110e2e1d795b5552272d6fa003244d8ae6b,e938e80e59c1675c0cdb77765e4628b5f74b88fe..7c4802de1e3a59178aeb7b88d37827e45260f4c6
@@@ -325,7 -325,6 +325,7 @@@ struct pci_dev 
        pci_power_t     current_state;  /* Current operating state. In ACPI,
                                           this is D0-D3, D0 being fully
                                           functional, and D3 being off. */
 +      unsigned int    imm_ready:1;    /* Supports Immediate Readiness */
        u8              pm_cap;         /* PM capability offset */
        unsigned int    pme_support:5;  /* Bitmask of states from which PME#
                                           can be generated */
        unsigned int    has_secondary_link:1;
        unsigned int    non_compliant_bars:1;   /* Broken BARs; ignore them */
        unsigned int    is_probed:1;            /* Device probing in progress */
 +      unsigned int    link_active_reporting:1;/* Device capable of reporting link active */
        pci_dev_flags_t dev_flags;
        atomic_t        enable_cnt;     /* pci_enable_device has been called */
  
@@@ -1344,7 -1342,6 +1344,6 @@@ int pci_set_vga_state(struct pci_dev *p
  
  /* kmem_cache style wrapper around pci_alloc_consistent() */
  
- #include <linux/pci-dma.h>
  #include <linux/dmapool.h>
  
  #define       pci_pool dma_pool