]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
soc: fsl: qbman: Check if CPU is offline when initializing portals
authorRoy Pledge <roy.pledge@nxp.com>
Fri, 28 Sep 2018 08:43:20 +0000 (11:43 +0300)
committerLi Yang <leoyang.li@nxp.com>
Fri, 5 Oct 2018 19:01:46 +0000 (14:01 -0500)
If the CPU to affine the portal interrupt is offline at boot time
affine the portal interrupt to another online CPU. If the CPU is later
brought online the hotplug handler will correctly adjust the affinity.
Moved common code in a function.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
drivers/soc/fsl/qbman/bman.c
drivers/soc/fsl/qbman/dpaa_sys.h
drivers/soc/fsl/qbman/qman.c

index f9485cedc648f70380944f904f1ee15563c697f7..f84ab596bde8c3b43920a6c1c3d54620f4d6132b 100644 (file)
@@ -562,11 +562,9 @@ static int bman_create_portal(struct bman_portal *portal,
                dev_err(c->dev, "request_irq() failed\n");
                goto fail_irq;
        }
-       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
-           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
-               dev_err(c->dev, "irq_set_affinity() failed\n");
+
+       if (dpaa_set_portal_irq_affinity(c->dev, c->irq, c->cpu))
                goto fail_affinity;
-       }
 
        /* Need RCR to be empty before continuing */
        ret = bm_rcr_get_fill(p);
index 9f379000da85aa1dc23bbc48ed7775ce0939c14b..ae8afa552b1ef47e629de1eae4f324dc8b0af181 100644 (file)
@@ -111,4 +111,24 @@ int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
 #define QBMAN_MEMREMAP_ATTR    MEMREMAP_WC
 #endif
 
+static inline int dpaa_set_portal_irq_affinity(struct device *dev,
+                                              int irq, int cpu)
+{
+       int ret = 0;
+
+       if (!irq_can_set_affinity(irq)) {
+               dev_err(dev, "unable to set IRQ affinity\n");
+               return -EINVAL;
+       }
+
+       if (cpu == -1 || !cpu_online(cpu))
+               cpu = cpumask_any(cpu_online_mask);
+
+       ret = irq_set_affinity(irq, cpumask_of(cpu));
+       if (ret)
+               dev_err(dev, "irq_set_affinity() on CPU %d failed\n", cpu);
+
+       return ret;
+}
+
 #endif /* __DPAA_SYS_H */
index 8cc0151830433230e8f629c2660eec90871b7e8c..1897144b928163750e990f428bfb4447a17494ee 100644 (file)
@@ -1210,11 +1210,9 @@ static int qman_create_portal(struct qman_portal *portal,
                dev_err(c->dev, "request_irq() failed\n");
                goto fail_irq;
        }
-       if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
-           irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
-               dev_err(c->dev, "irq_set_affinity() failed\n");
+
+       if (dpaa_set_portal_irq_affinity(c->dev, c->irq, c->cpu))
                goto fail_affinity;
-       }
 
        /* Need EQCR to be empty before continuing */
        isdr &= ~QM_PIRQ_EQCI;