Merge tag 'pci-v4.12-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 May 2017 17:51:18 +0000 (10:51 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 May 2017 17:51:18 +0000 (10:51 -0700)
Pull PCI fixes from Bjorn Helgaas:

 - fix PCI_ENDPOINT build error (merged for v4.12)

 - fix Switchtec driver (merged for v4.12)

 - fix imx6 config read timeouts, fallout from changing to non-postable
   reads

 - add PM "needs_resume" flag for i915 suspend issue

* tag 'pci-v4.12-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
  PCI/PM: Add needs_resume flag to avoid suspend complete optimization
  PCI: imx6: Fix config read timeout handling
  switchtec: Fix minor bug with partition ID register
  switchtec: Use new cdev_device_add() helper function
  PCI: endpoint: Make PCI_ENDPOINT depend on HAS_DMA

drivers/pci/dwc/pci-imx6.c
drivers/pci/endpoint/Kconfig
drivers/pci/pci.c
drivers/pci/switch/switchtec.c
include/linux/pci.h

index a98cba5..19a289b 100644 (file)
@@ -252,7 +252,34 @@ static void imx6_pcie_reset_phy(struct imx6_pcie *imx6_pcie)
 static int imx6q_pcie_abort_handler(unsigned long addr,
                unsigned int fsr, struct pt_regs *regs)
 {
-       return 0;
+       unsigned long pc = instruction_pointer(regs);
+       unsigned long instr = *(unsigned long *)pc;
+       int reg = (instr >> 12) & 15;
+
+       /*
+        * If the instruction being executed was a read,
+        * make it look like it read all-ones.
+        */
+       if ((instr & 0x0c100000) == 0x04100000) {
+               unsigned long val;
+
+               if (instr & 0x00400000)
+                       val = 255;
+               else
+                       val = -1;
+
+               regs->uregs[reg] = val;
+               regs->ARM_pc += 4;
+               return 0;
+       }
+
+       if ((instr & 0x0e100090) == 0x00100090) {
+               regs->uregs[reg] = -1;
+               regs->ARM_pc += 4;
+               return 0;
+       }
+
+       return 1;
 }
 
 static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)
@@ -819,8 +846,8 @@ static int __init imx6_pcie_init(void)
         * we can install the handler here without risking it
         * accessing some uninitialized driver state.
         */
-       hook_fault_code(16 + 6, imx6q_pcie_abort_handler, SIGBUS, 0,
-                       "imprecise external abort");
+       hook_fault_code(8, imx6q_pcie_abort_handler, SIGBUS, 0,
+                       "external abort on non-linefetch");
 
        return platform_driver_register(&imx6_pcie_driver);
 }
index c23f146..c09623c 100644 (file)
@@ -6,6 +6,7 @@ menu "PCI Endpoint"
 
 config PCI_ENDPOINT
        bool "PCI Endpoint Support"
+       depends on HAS_DMA
        help
           Enable this configuration option to support configurable PCI
           endpoint. This should be enabled if the platform has a PCI
index b01bd5b..563901c 100644 (file)
@@ -2144,7 +2144,8 @@ bool pci_dev_keep_suspended(struct pci_dev *pci_dev)
 
        if (!pm_runtime_suspended(dev)
            || pci_target_state(pci_dev) != pci_dev->current_state
-           || platform_pci_need_resume(pci_dev))
+           || platform_pci_need_resume(pci_dev)
+           || (pci_dev->dev_flags & PCI_DEV_FLAGS_NEEDS_RESUME))
                return false;
 
        /*
index cc6e085..f6a6340 100644 (file)
@@ -1291,7 +1291,6 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
        cdev = &stdev->cdev;
        cdev_init(cdev, &switchtec_fops);
        cdev->owner = THIS_MODULE;
-       cdev->kobj.parent = &dev->kobj;
 
        return stdev;
 
@@ -1442,12 +1441,15 @@ static int switchtec_init_pci(struct switchtec_dev *stdev,
        stdev->mmio_sys_info = stdev->mmio + SWITCHTEC_GAS_SYS_INFO_OFFSET;
        stdev->mmio_flash_info = stdev->mmio + SWITCHTEC_GAS_FLASH_INFO_OFFSET;
        stdev->mmio_ntb = stdev->mmio + SWITCHTEC_GAS_NTB_OFFSET;
-       stdev->partition = ioread8(&stdev->mmio_ntb->partition_id);
+       stdev->partition = ioread8(&stdev->mmio_sys_info->partition_id);
        stdev->partition_count = ioread8(&stdev->mmio_ntb->partition_count);
        stdev->mmio_part_cfg_all = stdev->mmio + SWITCHTEC_GAS_PART_CFG_OFFSET;
        stdev->mmio_part_cfg = &stdev->mmio_part_cfg_all[stdev->partition];
        stdev->mmio_pff_csr = stdev->mmio + SWITCHTEC_GAS_PFF_CSR_OFFSET;
 
+       if (stdev->partition_count < 1)
+               stdev->partition_count = 1;
+
        init_pff(stdev);
 
        pci_set_drvdata(pdev, stdev);
@@ -1479,11 +1481,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
                  SWITCHTEC_EVENT_EN_IRQ,
                  &stdev->mmio_part_cfg->mrpc_comp_hdr);
 
-       rc = cdev_add(&stdev->cdev, stdev->dev.devt, 1);
-       if (rc)
-               goto err_put;
-
-       rc = device_add(&stdev->dev);
+       rc = cdev_device_add(&stdev->cdev, &stdev->dev);
        if (rc)
                goto err_devadd;
 
@@ -1492,7 +1490,6 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
        return 0;
 
 err_devadd:
-       cdev_del(&stdev->cdev);
        stdev_kill(stdev);
 err_put:
        ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
@@ -1506,8 +1503,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
 
        pci_set_drvdata(pdev, NULL);
 
-       device_del(&stdev->dev);
-       cdev_del(&stdev->cdev);
+       cdev_device_del(&stdev->cdev, &stdev->dev);
        ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
        dev_info(&stdev->dev, "unregistered.\n");
 
index fc2e832..8039f9f 100644 (file)
@@ -183,6 +183,11 @@ enum pci_dev_flags {
        PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT = (__force pci_dev_flags_t) (1 << 9),
        /* Do not use FLR even if device advertises PCI_AF_CAP */
        PCI_DEV_FLAGS_NO_FLR_RESET = (__force pci_dev_flags_t) (1 << 10),
+       /*
+        * Resume before calling the driver's system suspend hooks, disabling
+        * the direct_complete optimization.
+        */
+       PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11),
 };
 
 enum pci_irq_reroute_variant {