Merge branch 'pci/misc'
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 21 Oct 2020 14:58:36 +0000 (09:58 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 21 Oct 2020 14:58:36 +0000 (09:58 -0500)
- Remove unnecessary #includes (Gustavo Pimentel)

- Fix intel_mid_pci.c build error when !CONFIG_ACPI (Randy Dunlap)

- Use scnprintf(), not snprintf(), in sysfs "show" functions (Krzysztof
  Wilczyński)

- Simplify pci-pf-stub by using module_pci_driver() (Liu Shixin)

- Print IRQ used by Link Bandwidth Notification (Dongdong Liu)

- Update sysfs mmap-related #ifdef comments (Clint Sbisa)

- Simplify pci_dev_reset_slot_function() (Lukas Wunner)

- Use "NULL" instead of "0" to fix sparse warnings (Gustavo Pimentel)

- Simplify bool comparisons (Krzysztof Wilczyński)

- Drop double zeroing for P2PDMA sg_init_table() (Julia Lawall)

* pci/misc:
  PCI: v3-semi: Remove unneeded break
  PCI/P2PDMA: Drop double zeroing for sg_init_table()
  PCI: Simplify bool comparisons
  PCI: endpoint: Use "NULL" instead of "0" as a NULL pointer
  PCI: Simplify pci_dev_reset_slot_function()
  PCI: Update mmap-related #ifdef comments
  PCI/LINK: Print IRQ number used by port
  PCI/IOV: Simplify pci-pf-stub with module_pci_driver()
  PCI: Use scnprintf(), not snprintf(), in sysfs "show" functions
  x86/PCI: Fix intel_mid_pci.c build error when ACPI is not enabled
  PCI: Remove unnecessary header includes

1  2 
arch/x86/pci/intel_mid_pci.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.c

@@@ -33,6 -33,7 +33,7 @@@
  #include <asm/hw_irq.h>
  #include <asm/io_apic.h>
  #include <asm/intel-mid.h>
+ #include <asm/acpi.h>
  
  #define PCIE_CAP_OFFSET       0x100
  
@@@ -322,7 -323,7 +323,7 @@@ static void pci_d3delay_fixup(struct pc
         */
        if (type1_access_ok(dev->bus->number, dev->devfn, PCI_DEVICE_ID))
                return;
 -      dev->d3_delay = 0;
 +      dev->d3hot_delay = 0;
  }
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_d3delay_fixup);
  
diff --combined drivers/pci/pci-sysfs.c
@@@ -574,7 -574,7 +574,7 @@@ static ssize_t driver_override_show(str
        ssize_t len;
  
        device_lock(dev);
-       len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override);
+       len = scnprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override);
        device_unlock(dev);
        return len;
  }
@@@ -708,7 -708,6 +708,7 @@@ static ssize_t pci_read_config(struct f
                data[off - init_off + 3] = (val >> 24) & 0xff;
                off += 4;
                size -= 4;
 +              cond_resched();
        }
  
        if (size >= 2) {
@@@ -1197,10 -1196,10 +1197,10 @@@ static int pci_create_resource_files(st
        }
        return 0;
  }
- #else /* !HAVE_PCI_MMAP */
+ #else /* !(defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)) */
  int __weak pci_create_resource_files(struct pci_dev *dev) { return 0; }
  void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
- #endif /* HAVE_PCI_MMAP */
+ #endif
  
  /**
   * pci_write_rom - used to enable access to the PCI ROM display
diff --combined drivers/pci/pci.c
@@@ -15,7 -15,6 +15,6 @@@
  #include <linux/init.h>
  #include <linux/msi.h>
  #include <linux/of.h>
- #include <linux/of_pci.h>
  #include <linux/pci.h>
  #include <linux/pm.h>
  #include <linux/slab.h>
@@@ -30,8 -29,6 +29,6 @@@
  #include <linux/pm_runtime.h>
  #include <linux/pci_hotplug.h>
  #include <linux/vmalloc.h>
- #include <linux/pci-ats.h>
- #include <asm/setup.h>
  #include <asm/dma.h>
  #include <linux/aer.h>
  #include "pci.h"
@@@ -49,7 -46,7 +46,7 @@@ EXPORT_SYMBOL(isa_dma_bridge_buggy)
  int pci_pci_problems;
  EXPORT_SYMBOL(pci_pci_problems);
  
 -unsigned int pci_pm_d3_delay;
 +unsigned int pci_pm_d3hot_delay;
  
  static void pci_pme_list_scan(struct work_struct *work);
  
@@@ -66,10 -63,10 +63,10 @@@ struct pci_pme_device 
  
  static void pci_dev_d3_sleep(struct pci_dev *dev)
  {
 -      unsigned int delay = dev->d3_delay;
 +      unsigned int delay = dev->d3hot_delay;
  
 -      if (delay < pci_pm_d3_delay)
 -              delay = pci_pm_d3_delay;
 +      if (delay < pci_pm_d3hot_delay)
 +              delay = pci_pm_d3hot_delay;
  
        if (delay)
                msleep(delay);
@@@ -101,19 -98,7 +98,19 @@@ unsigned long pci_hotplug_mmio_pref_siz
  #define DEFAULT_HOTPLUG_BUS_SIZE      1
  unsigned long pci_hotplug_bus_size = DEFAULT_HOTPLUG_BUS_SIZE;
  
 +
 +/* PCIe MPS/MRRS strategy; can be overridden by kernel command-line param */
 +#ifdef CONFIG_PCIE_BUS_TUNE_OFF
 +enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_TUNE_OFF;
 +#elif defined CONFIG_PCIE_BUS_SAFE
 +enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_SAFE;
 +#elif defined CONFIG_PCIE_BUS_PERFORMANCE
 +enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_PERFORMANCE;
 +#elif defined CONFIG_PCIE_BUS_PEER2PEER
 +enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_PEER2PEER;
 +#else
  enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT;
 +#endif
  
  /*
   * The default CLS is used if arch didn't set CLS explicitly and not
@@@ -888,10 -873,6 +885,10 @@@ static void pci_std_enable_acs(struct p
        /* Upstream Forwarding */
        ctrl |= (cap & PCI_ACS_UF);
  
 +      /* Enable Translation Blocking for external devices */
 +      if (dev->external_facing || dev->untrusted)
 +              ctrl |= (cap & PCI_ACS_TB);
 +
        pci_write_config_word(dev, pos + PCI_ACS_CTRL, ctrl);
  }
  
@@@ -1081,7 -1062,7 +1078,7 @@@ static int pci_raw_set_power_state(stru
        if (state == PCI_D3hot || dev->current_state == PCI_D3hot)
                pci_dev_d3_sleep(dev);
        else if (state == PCI_D2 || dev->current_state == PCI_D2)
 -              msleep(PCI_PM_D2_DELAY);
 +              udelay(PCI_PM_D2_DELAY);
  
        pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
        dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
@@@ -3029,7 -3010,7 +3026,7 @@@ void pci_pm_init(struct pci_dev *dev
        }
  
        dev->pm_cap = pm;
 -      dev->d3_delay = PCI_PM_D3_WAIT;
 +      dev->d3hot_delay = PCI_PM_D3HOT_WAIT;
        dev->d3cold_delay = PCI_PM_D3COLD_WAIT;
        dev->bridge_d3 = pci_bridge_d3_possible(dev);
        dev->d3cold_allowed = true;
                         (pmc & PCI_PM_CAP_PME_D0) ? " D0" : "",
                         (pmc & PCI_PM_CAP_PME_D1) ? " D1" : "",
                         (pmc & PCI_PM_CAP_PME_D2) ? " D2" : "",
 -                       (pmc & PCI_PM_CAP_PME_D3) ? " D3hot" : "",
 +                       (pmc & PCI_PM_CAP_PME_D3hot) ? " D3hot" : "",
                         (pmc & PCI_PM_CAP_PME_D3cold) ? " D3cold" : "");
                dev->pme_support = pmc >> PCI_PM_CAP_PME_SHIFT;
                dev->pme_poll = true;
@@@ -4637,7 -4618,7 +4634,7 @@@ static int pci_af_flr(struct pci_dev *d
   *
   * NOTE: This causes the caller to sleep for twice the device power transition
   * cooldown period, which for the D0->D3hot and D3hot->D0 transitions is 10 ms
 - * by default (i.e. unless the @dev's d3_delay field has a different value).
 + * by default (i.e. unless the @dev's d3hot_delay field has a different value).
   * Moreover, only devices in D0 can be reset by this function.
   */
  static int pci_pm_reset(struct pci_dev *dev, int probe)
@@@ -4717,7 -4698,9 +4714,7 @@@ static bool pcie_wait_for_link_delay(st
        }
        if (active && ret)
                msleep(delay);
 -      else if (ret != active)
 -              pci_info(pdev, "Data Link Layer Link Active not %s in 1000 msec\n",
 -                      active ? "set" : "cleared");
 +
        return ret == active;
  }
  
@@@ -4842,7 -4825,6 +4839,7 @@@ void pci_bridge_wait_for_secondary_bus(
                        delay);
                if (!pcie_wait_for_link_delay(dev, true, delay)) {
                        /* Did not train, no need to wait any further */
 +                      pci_info(dev, "Data Link Layer Link Active not set in 1000 msec\n");
                        return;
                }
        }
@@@ -4935,16 -4917,10 +4932,10 @@@ static int pci_reset_hotplug_slot(struc
  
  static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe)
  {
-       struct pci_dev *pdev;
-       if (dev->subordinate || !dev->slot ||
+       if (dev->multifunction || dev->subordinate || !dev->slot ||
            dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
                return -ENOTTY;
  
-       list_for_each_entry(pdev, &dev->bus->devices, bus_list)
-               if (pdev != dev && pdev->slot == dev->slot)
-                       return -ENOTTY;
        return pci_reset_hotplug_slot(dev->slot->hotplug, probe);
  }
  
@@@ -6020,7 -5996,7 +6011,7 @@@ int pci_set_vga_state(struct pci_dev *d
  
        if (flags & PCI_VGA_STATE_CHANGE_DECODES) {
                pci_read_config_word(dev, PCI_COMMAND, &cmd);
-               if (decode == true)
+               if (decode)
                        cmd |= command_bits;
                else
                        cmd &= ~command_bits;
                if (bridge) {
                        pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
                                             &cmd);
-                       if (decode == true)
+                       if (decode)
                                cmd |= PCI_BRIDGE_CTL_VGA;
                        else
                                cmd &= ~PCI_BRIDGE_CTL_VGA;
@@@ -6365,7 -6341,7 +6356,7 @@@ static ssize_t resource_alignment_show(
  
        spin_lock(&resource_alignment_lock);
        if (resource_alignment_param)
-               count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
+               count = scnprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
        spin_unlock(&resource_alignment_lock);
  
        /*