kernel: Update kernel 4.14 to version 4.14.187
[openwrt/staging/adrian.git] / target / linux / layerscape / patches-4.14 / 816-pcie-support-layerscape.patch
index 88f38df746386bd61cab2480aa04a1af588e5ee1..1875c8931d924bf2a1c1ed40aad3b53d93356241 100644 (file)
@@ -286,15 +286,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  enum pci_barno {
        BAR_0,
        BAR_1,
-@@ -92,6 +103,7 @@ struct pci_endpoint_test {
-       void __iomem    *bar[6];
-       struct completion irq_raised;
-       int             last_irq;
-+      int             num_irqs;
-       /* mutex to protect the ioctls */
-       struct mutex    mutex;
-       struct miscdevice miscdev;
-@@ -102,7 +114,7 @@ struct pci_endpoint_test {
+@@ -103,7 +114,7 @@ struct pci_endpoint_test {
  struct pci_endpoint_test_data {
        enum pci_barno test_reg_bar;
        size_t alignment;
@@ -303,7 +295,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  };
  
  static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
-@@ -146,6 +158,100 @@ static irqreturn_t pci_endpoint_test_irq
+@@ -147,6 +158,100 @@ static irqreturn_t pci_endpoint_test_irq
        return IRQ_HANDLED;
  }
  
@@ -404,7 +396,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
                                  enum pci_barno barno)
  {
-@@ -178,6 +284,9 @@ static bool pci_endpoint_test_legacy_irq
+@@ -179,6 +284,9 @@ static bool pci_endpoint_test_legacy_irq
  {
        u32 val;
  
@@ -414,7 +406,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND,
                                 COMMAND_RAISE_LEGACY_IRQ);
        val = wait_for_completion_timeout(&test->irq_raised,
-@@ -189,20 +298,24 @@ static bool pci_endpoint_test_legacy_irq
+@@ -190,20 +298,24 @@ static bool pci_endpoint_test_legacy_irq
  }
  
  static bool pci_endpoint_test_msi_irq(struct pci_endpoint_test *test,
@@ -443,9 +435,9 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                return true;
  
        return false;
-@@ -226,10 +339,18 @@ static bool pci_endpoint_test_copy(struc
-       u32 src_crc32;
-       u32 dst_crc32;
+@@ -230,10 +342,18 @@ static bool pci_endpoint_test_copy(struc
+       if (size > SIZE_MAX - alignment)
+               goto err;
  
 +      if (size > SIZE_MAX - alignment)
 +              goto err;
@@ -463,7 +455,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                ret = false;
                goto err;
        }
-@@ -255,7 +376,7 @@ static bool pci_endpoint_test_copy(struc
+@@ -259,7 +379,7 @@ static bool pci_endpoint_test_copy(struc
        orig_dst_addr = dma_alloc_coherent(dev, size + alignment,
                                           &orig_dst_phys_addr, GFP_KERNEL);
        if (!orig_dst_addr) {
@@ -472,7 +464,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                ret = false;
                goto err_orig_src_addr;
        }
-@@ -277,8 +398,10 @@ static bool pci_endpoint_test_copy(struc
+@@ -281,8 +401,10 @@ static bool pci_endpoint_test_copy(struc
        pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE,
                                 size);
  
@@ -484,9 +476,9 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  
        wait_for_completion(&test->irq_raised);
  
-@@ -311,10 +434,18 @@ static bool pci_endpoint_test_write(stru
-       size_t alignment = test->alignment;
-       u32 crc32;
+@@ -318,10 +440,18 @@ static bool pci_endpoint_test_write(stru
+       if (size > SIZE_MAX - alignment)
+               goto err;
  
 +      if (size > SIZE_MAX - alignment)
 +              goto err;
@@ -504,7 +496,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                ret = false;
                goto err;
        }
-@@ -341,8 +472,10 @@ static bool pci_endpoint_test_write(stru
+@@ -348,8 +478,10 @@ static bool pci_endpoint_test_write(stru
  
        pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size);
  
@@ -516,9 +508,9 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  
        wait_for_completion(&test->irq_raised);
  
-@@ -369,10 +502,18 @@ static bool pci_endpoint_test_read(struc
-       size_t alignment = test->alignment;
-       u32 crc32;
+@@ -379,10 +511,18 @@ static bool pci_endpoint_test_read(struc
+       if (size > SIZE_MAX - alignment)
+               goto err;
  
 +      if (size > SIZE_MAX - alignment)
 +              goto err;
@@ -536,7 +528,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                ret = false;
                goto err;
        }
-@@ -393,8 +534,10 @@ static bool pci_endpoint_test_read(struc
+@@ -403,8 +543,10 @@ static bool pci_endpoint_test_read(struc
  
        pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size);
  
@@ -548,7 +540,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  
        wait_for_completion(&test->irq_raised);
  
-@@ -407,6 +550,38 @@ err:
+@@ -417,6 +559,38 @@ err:
        return ret;
  }
  
@@ -587,7 +579,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
                                    unsigned long arg)
  {
-@@ -426,7 +601,8 @@ static long pci_endpoint_test_ioctl(stru
+@@ -436,7 +610,8 @@ static long pci_endpoint_test_ioctl(stru
                ret = pci_endpoint_test_legacy_irq(test);
                break;
        case PCITEST_MSI:
@@ -597,7 +589,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                break;
        case PCITEST_WRITE:
                ret = pci_endpoint_test_write(test, arg);
-@@ -437,6 +613,12 @@ static long pci_endpoint_test_ioctl(stru
+@@ -447,6 +622,12 @@ static long pci_endpoint_test_ioctl(stru
        case PCITEST_COPY:
                ret = pci_endpoint_test_copy(test, arg);
                break;
@@ -610,7 +602,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        }
  
  ret:
-@@ -452,9 +634,7 @@ static const struct file_operations pci_
+@@ -462,9 +643,7 @@ static const struct file_operations pci_
  static int pci_endpoint_test_probe(struct pci_dev *pdev,
                                   const struct pci_device_id *ent)
  {
@@ -618,9 +610,9 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        int err;
 -      int irq = 0;
        int id;
-       char name[20];
+       char name[24];
        enum pci_barno bar;
-@@ -476,12 +656,15 @@ static int pci_endpoint_test_probe(struc
+@@ -486,12 +665,15 @@ static int pci_endpoint_test_probe(struc
        test->alignment = 0;
        test->pdev = pdev;
  
@@ -637,7 +629,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        }
  
        init_completion(&test->irq_raised);
-@@ -501,35 +684,21 @@ static int pci_endpoint_test_probe(struc
+@@ -511,36 +693,21 @@ static int pci_endpoint_test_probe(struc
  
        pci_set_master(pdev);
  
@@ -645,6 +637,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
 -              irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI);
 -              if (irq < 0)
 -                      dev_err(dev, "failed to get MSI interrupts\n");
+-              test->num_irqs = irq;
 -      }
 +      if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
 +              goto err_disable_irq;
@@ -684,7 +677,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        }
  
        test->base = test->bar[test_reg_bar];
-@@ -545,24 +714,31 @@ static int pci_endpoint_test_probe(struc
+@@ -556,24 +723,31 @@ static int pci_endpoint_test_probe(struc
        id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL);
        if (id < 0) {
                err = id;
@@ -720,20 +713,23 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  err_ida_remove:
        ida_simple_remove(&pci_endpoint_test_ida, id);
  
-@@ -571,9 +747,10 @@ err_iounmap:
-               if (test->bar[bar])
+@@ -583,11 +757,13 @@ err_iounmap:
                        pci_iounmap(pdev, test->bar[bar]);
        }
+-      for (i = 0; i < irq; i++)
+-              devm_free_irq(dev, pdev->irq + i, test);
 +      pci_endpoint_test_release_irq(test);
  
--err_disable_msi:
--      pci_disable_msi(pdev);
+ err_disable_msi:
+       pci_disable_msi(pdev);
++
 +err_disable_irq:
 +      pci_endpoint_test_free_irq_vectors(test);
        pci_release_regions(pdev);
  
  err_disable_pdev:
-@@ -595,12 +772,16 @@ static void pci_endpoint_test_remove(str
+@@ -610,14 +786,15 @@ static void pci_endpoint_test_remove(str
                return;
  
        misc_deregister(&test->miscdev);
@@ -743,15 +739,16 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
                if (test->bar[bar])
                        pci_iounmap(pdev, test->bar[bar]);
        }
+-      for (i = 0; i < test->num_irqs; i++)
+-              devm_free_irq(&pdev->dev, pdev->irq + i, test);
 -      pci_disable_msi(pdev);
 +
 +      pci_endpoint_test_release_irq(test);
 +      pci_endpoint_test_free_irq_vectors(test);
-+
        pci_release_regions(pdev);
        pci_disable_device(pdev);
  }
-@@ -608,6 +789,7 @@ static void pci_endpoint_test_remove(str
+@@ -625,6 +802,7 @@ static void pci_endpoint_test_remove(str
  static const struct pci_device_id pci_endpoint_test_tbl[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) },
        { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) },
@@ -5607,7 +5604,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
         * them, we have to fall back to INTx or other interrupts, e.g., a
 --- a/drivers/pci/quirks.c
 +++ b/drivers/pci/quirks.c
-@@ -3394,6 +3394,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_A
+@@ -3395,6 +3395,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_A
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0033, quirk_no_bus_reset);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset);
  
@@ -5621,18 +5618,6 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  static void quirk_no_pm_reset(struct pci_dev *dev)
  {
        /*
-@@ -4878,3 +4885,11 @@ static void quirk_no_ats(struct pci_dev
- DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x98e4, quirk_no_ats);
- DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6900, quirk_no_ats);
- #endif /* CONFIG_PCI_ATS */
-+
-+/* Freescale PCIe doesn't support MSI in RC mode */
-+static void quirk_fsl_no_msi(struct pci_dev *pdev)
-+{
-+      if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT)
-+              pdev->no_msi = 1;
-+}
-+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, quirk_fsl_no_msi);
 --- a/include/linux/pci-ep-cfs.h
 +++ b/include/linux/pci-ep-cfs.h
 @@ -1,12 +1,9 @@
@@ -5718,7 +5703,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        int     (*start)(struct pci_epc *epc);
        void    (*stop)(struct pci_epc *epc);
        struct module *owner;
-@@ -91,8 +97,17 @@ struct pci_epc {
+@@ -94,8 +100,17 @@ struct pci_epc {
        struct config_group             *group;
        /* spinlock to protect against concurrent access of EP controller */
        spinlock_t                      lock;
@@ -5736,7 +5721,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  #define to_pci_epc(device) container_of((device), struct pci_epc, dev)
  
  #define pci_epc_create(dev, ops)    \
-@@ -124,17 +139,23 @@ void pci_epc_destroy(struct pci_epc *epc
+@@ -127,17 +142,23 @@ void pci_epc_destroy(struct pci_epc *epc
  int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf);
  void pci_epc_linkup(struct pci_epc *epc);
  void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf);
@@ -5844,7 +5829,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  #endif /* __UAPI_LINUX_PCITEST_H */
 --- a/tools/pci/pcitest.c
 +++ b/tools/pci/pcitest.c
-@@ -31,12 +31,17 @@
+@@ -30,12 +30,17 @@
  #define BILLION 1E9
  
  static char *result[] = { "NOT OKAY", "OKAY" };
@@ -5862,7 +5847,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        bool            read;
        bool            write;
        bool            copy;
-@@ -65,6 +70,24 @@ static int run_test(struct pci_test *tes
+@@ -62,6 +67,24 @@ static int run_test(struct pci_test *tes
                        fprintf(stdout, "%s\n", result[ret]);
        }
  
@@ -5887,7 +5872,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        if (test->legacyirq) {
                ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0);
                fprintf(stdout, "LEGACY IRQ:\t");
-@@ -83,6 +106,15 @@ static int run_test(struct pci_test *tes
+@@ -80,6 +103,15 @@ static int run_test(struct pci_test *tes
                        fprintf(stdout, "%s\n", result[ret]);
        }
  
@@ -5903,7 +5888,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        if (test->write) {
                ret = ioctl(fd, PCITEST_WRITE, test->size);
                fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
-@@ -133,7 +165,7 @@ int main(int argc, char **argv)
+@@ -130,7 +162,7 @@ int main(int argc, char **argv)
        /* set default endpoint device */
        test->device = "/dev/pci-endpoint-test.0";
  
@@ -5912,7 +5897,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        switch (c) {
        case 'D':
                test->device = optarg;
-@@ -151,6 +183,20 @@ int main(int argc, char **argv)
+@@ -148,6 +180,20 @@ int main(int argc, char **argv)
                if (test->msinum < 1 || test->msinum > 32)
                        goto usage;
                continue;
@@ -5933,7 +5918,7 @@ Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
        case 'r':
                test->read = true;
                continue;
-@@ -173,6 +219,9 @@ usage:
+@@ -170,6 +216,9 @@ usage:
                        "\t-D <dev>             PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n"
                        "\t-b <bar num>         BAR test (bar number between 0..5)\n"
                        "\t-m <msi num>         MSI test (msi number between 1..32)\n"