usb: typec: ucsi: Mark dGPUs as DEVICE scope
[platform/kernel/linux-starfive.git] / net / core / dev.c
index 3be2560..a2e3c64 100644 (file)
@@ -2549,6 +2549,8 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
        struct xps_map *map, *new_map;
        unsigned int nr_ids;
 
+       WARN_ON_ONCE(index >= dev->num_tx_queues);
+
        if (dev->num_tc) {
                /* Do not allow XPS on subordinate device directly */
                num_tc = dev->num_tc;
@@ -3146,8 +3148,10 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
 {
        if (in_hardirq() || irqs_disabled())
                __dev_kfree_skb_irq(skb, reason);
+       else if (unlikely(reason == SKB_REASON_DROPPED))
+               kfree_skb(skb);
        else
-               dev_kfree_skb(skb);
+               consume_skb(skb);
 }
 EXPORT_SYMBOL(__dev_kfree_skb_any);
 
@@ -3209,6 +3213,7 @@ static u16 skb_tx_hash(const struct net_device *dev,
        }
 
        if (skb_rx_queue_recorded(skb)) {
+               DEBUG_NET_WARN_ON_ONCE(qcount == 0);
                hash = skb_get_rx_queue(skb);
                if (hash >= qoffset)
                        hash -= qoffset;
@@ -3347,7 +3352,7 @@ __be16 skb_network_protocol(struct sk_buff *skb, int *depth)
                type = eth->h_proto;
        }
 
-       return __vlan_get_protocol(skb, type, depth);
+       return vlan_get_protocol_and_depth(skb, type, depth);
 }
 
 /* openvswitch calls this on rx path, so we need a different check.
@@ -4478,8 +4483,10 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
                u32 next_cpu;
                u32 ident;
 
-               /* First check into global flow table if there is a match */
-               ident = sock_flow_table->ents[hash & sock_flow_table->mask];
+               /* First check into global flow table if there is a match.
+                * This READ_ONCE() pairs with WRITE_ONCE() from rps_record_sock_flow().
+                */
+               ident = READ_ONCE(sock_flow_table->ents[hash & sock_flow_table->mask]);
                if ((ident ^ hash) & ~rps_cpu_mask)
                        goto try_rps;
 
@@ -10379,24 +10386,16 @@ void netdev_run_todo(void)
 void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
                             const struct net_device_stats *netdev_stats)
 {
-#if BITS_PER_LONG == 64
-       BUILD_BUG_ON(sizeof(*stats64) < sizeof(*netdev_stats));
-       memcpy(stats64, netdev_stats, sizeof(*netdev_stats));
-       /* zero out counters that only exist in rtnl_link_stats64 */
-       memset((char *)stats64 + sizeof(*netdev_stats), 0,
-              sizeof(*stats64) - sizeof(*netdev_stats));
-#else
-       size_t i, n = sizeof(*netdev_stats) / sizeof(unsigned long);
-       const unsigned long *src = (const unsigned long *)netdev_stats;
+       size_t i, n = sizeof(*netdev_stats) / sizeof(atomic_long_t);
+       const atomic_long_t *src = (atomic_long_t *)netdev_stats;
        u64 *dst = (u64 *)stats64;
 
        BUILD_BUG_ON(n > sizeof(*stats64) / sizeof(u64));
        for (i = 0; i < n; i++)
-               dst[i] = src[i];
+               dst[i] = (unsigned long)atomic_long_read(&src[i]);
        /* zero out counters that only exist in rtnl_link_stats64 */
        memset((char *)stats64 + n * sizeof(u64), 0,
               sizeof(*stats64) - n * sizeof(u64));
-#endif
 }
 EXPORT_SYMBOL(netdev_stats_to_stats64);
 
@@ -10519,7 +10518,7 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
                return NULL;
        netdev_init_one_queue(dev, queue, NULL);
        RCU_INIT_POINTER(queue->qdisc, &noop_qdisc);
-       queue->qdisc_sleeping = &noop_qdisc;
+       RCU_INIT_POINTER(queue->qdisc_sleeping, &noop_qdisc);
        rcu_assign_pointer(dev->ingress_queue, queue);
 #endif
        return queue;