dpaa_eth: use only online CPU portals
authorMadalin Bucur <madalin.bucur@nxp.com>
Mon, 27 May 2019 12:24:05 +0000 (15:24 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 May 2019 18:19:55 +0000 (11:19 -0700)
Make sure only the portals for the online CPUs are used.
Without this change, there are issues when someone boots with
maxcpus=n, with n < actual number of cores available as frames
either received or corresponding to the transmit confirmation
path would be offered for dequeue to the offline CPU portals,
getting lost.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c

index d3f2408dc9e8003d8e823b3402b771c87b02fa22..f38c3fa7d70578cf15da9b56edcafda460beb340 100644 (file)
@@ -780,7 +780,7 @@ static void dpaa_eth_add_channel(u16 channel)
        struct qman_portal *portal;
        int cpu;
 
-       for_each_cpu(cpu, cpus) {
+       for_each_cpu_and(cpu, cpus, cpu_online_mask) {
                portal = qman_get_affine_portal(cpu);
                qman_p_static_dequeue_add(portal, pool);
        }
@@ -896,7 +896,7 @@ static void dpaa_fq_setup(struct dpaa_priv *priv,
        u16 channels[NR_CPUS];
        struct dpaa_fq *fq;
 
-       for_each_cpu(cpu, affine_cpus)
+       for_each_cpu_and(cpu, affine_cpus, cpu_online_mask)
                channels[num_portals++] = qman_affine_channel(cpu);
 
        if (num_portals == 0)
@@ -2174,7 +2174,6 @@ static int dpaa_eth_poll(struct napi_struct *napi, int budget)
        if (cleaned < budget) {
                napi_complete_done(napi, cleaned);
                qman_p_irqsource_add(np->p, QM_PIRQ_DQRI);
-
        } else if (np->down) {
                qman_p_irqsource_add(np->p, QM_PIRQ_DQRI);
        }
@@ -2448,7 +2447,7 @@ static void dpaa_eth_napi_enable(struct dpaa_priv *priv)
        struct dpaa_percpu_priv *percpu_priv;
        int i;
 
-       for_each_possible_cpu(i) {
+       for_each_online_cpu(i) {
                percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
 
                percpu_priv->np.down = 0;
@@ -2461,7 +2460,7 @@ static void dpaa_eth_napi_disable(struct dpaa_priv *priv)
        struct dpaa_percpu_priv *percpu_priv;
        int i;
 
-       for_each_possible_cpu(i) {
+       for_each_online_cpu(i) {
                percpu_priv = per_cpu_ptr(priv->percpu_priv, i);
 
                percpu_priv->np.down = 1;
index bdee441bc3b7b93710dac119a96374f698cbded2..7ce2e99b594d6299fbf15cf89d4707d6fba4082a 100644 (file)
@@ -569,7 +569,7 @@ static int dpaa_set_coalesce(struct net_device *dev,
        qman_dqrr_get_ithresh(portal, &prev_thresh);
 
        /* set new values */
-       for_each_cpu(cpu, cpus) {
+       for_each_cpu_and(cpu, cpus, cpu_online_mask) {
                portal = qman_get_affine_portal(cpu);
                res = qman_portal_set_iperiod(portal, period);
                if (res)
@@ -586,7 +586,7 @@ static int dpaa_set_coalesce(struct net_device *dev,
 
 revert_values:
        /* restore previous values */
-       for_each_cpu(cpu, cpus) {
+       for_each_cpu_and(cpu, cpus, cpu_online_mask) {
                if (!needs_revert[cpu])
                        continue;
                portal = qman_get_affine_portal(cpu);