Skip to content

Commit 68a4abb

Browse files
committed
Merge tag 'linux-can-fixes-for-6.16-20250617' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== pull-request: can 2025-06-17 The patch is by Brett Werling, and fixes the power regulator retrieval during probe of the tcan4x5x glue code for the m_can driver. * tag 'linux-can-fixes-for-6.16-20250617' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can: can: tcan4x5x: fix power regulator retrieval during probe openvswitch: Allocate struct ovs_pcpu_storage dynamically ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6f793a1 + db22720 commit 68a4abb

File tree

4 files changed

+52
-25
lines changed

4 files changed

+52
-25
lines changed

drivers/net/can/m_can/tcan4x5x-core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,11 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
411411
priv = cdev_to_priv(mcan_class);
412412

413413
priv->power = devm_regulator_get_optional(&spi->dev, "vsup");
414-
if (PTR_ERR(priv->power) == -EPROBE_DEFER) {
415-
ret = -EPROBE_DEFER;
416-
goto out_m_can_class_free_dev;
417-
} else {
414+
if (IS_ERR(priv->power)) {
415+
if (PTR_ERR(priv->power) == -EPROBE_DEFER) {
416+
ret = -EPROBE_DEFER;
417+
goto out_m_can_class_free_dev;
418+
}
418419
priv->power = NULL;
419420
}
420421

net/openvswitch/actions.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,14 @@
3939
#include "flow_netlink.h"
4040
#include "openvswitch_trace.h"
4141

42-
DEFINE_PER_CPU(struct ovs_pcpu_storage, ovs_pcpu_storage) = {
43-
.bh_lock = INIT_LOCAL_LOCK(bh_lock),
44-
};
42+
struct ovs_pcpu_storage __percpu *ovs_pcpu_storage;
4543

4644
/* Make a clone of the 'key', using the pre-allocated percpu 'flow_keys'
4745
* space. Return NULL if out of key spaces.
4846
*/
4947
static struct sw_flow_key *clone_key(const struct sw_flow_key *key_)
5048
{
51-
struct ovs_pcpu_storage *ovs_pcpu = this_cpu_ptr(&ovs_pcpu_storage);
49+
struct ovs_pcpu_storage *ovs_pcpu = this_cpu_ptr(ovs_pcpu_storage);
5250
struct action_flow_keys *keys = &ovs_pcpu->flow_keys;
5351
int level = ovs_pcpu->exec_level;
5452
struct sw_flow_key *key = NULL;
@@ -94,7 +92,7 @@ static struct deferred_action *add_deferred_actions(struct sk_buff *skb,
9492
const struct nlattr *actions,
9593
const int actions_len)
9694
{
97-
struct action_fifo *fifo = this_cpu_ptr(&ovs_pcpu_storage.action_fifos);
95+
struct action_fifo *fifo = this_cpu_ptr(&ovs_pcpu_storage->action_fifos);
9896
struct deferred_action *da;
9997

10098
da = action_fifo_put(fifo);
@@ -755,7 +753,7 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key,
755753
static int ovs_vport_output(struct net *net, struct sock *sk,
756754
struct sk_buff *skb)
757755
{
758-
struct ovs_frag_data *data = this_cpu_ptr(&ovs_pcpu_storage.frag_data);
756+
struct ovs_frag_data *data = this_cpu_ptr(&ovs_pcpu_storage->frag_data);
759757
struct vport *vport = data->vport;
760758

761759
if (skb_cow_head(skb, data->l2_len) < 0) {
@@ -807,7 +805,7 @@ static void prepare_frag(struct vport *vport, struct sk_buff *skb,
807805
unsigned int hlen = skb_network_offset(skb);
808806
struct ovs_frag_data *data;
809807

810-
data = this_cpu_ptr(&ovs_pcpu_storage.frag_data);
808+
data = this_cpu_ptr(&ovs_pcpu_storage->frag_data);
811809
data->dst = skb->_skb_refdst;
812810
data->vport = vport;
813811
data->cb = *OVS_CB(skb);
@@ -1566,16 +1564,15 @@ static int clone_execute(struct datapath *dp, struct sk_buff *skb,
15661564
clone = clone_flow_key ? clone_key(key) : key;
15671565
if (clone) {
15681566
int err = 0;
1569-
15701567
if (actions) { /* Sample action */
15711568
if (clone_flow_key)
1572-
__this_cpu_inc(ovs_pcpu_storage.exec_level);
1569+
__this_cpu_inc(ovs_pcpu_storage->exec_level);
15731570

15741571
err = do_execute_actions(dp, skb, clone,
15751572
actions, len);
15761573

15771574
if (clone_flow_key)
1578-
__this_cpu_dec(ovs_pcpu_storage.exec_level);
1575+
__this_cpu_dec(ovs_pcpu_storage->exec_level);
15791576
} else { /* Recirc action */
15801577
clone->recirc_id = recirc_id;
15811578
ovs_dp_process_packet(skb, clone);
@@ -1611,7 +1608,7 @@ static int clone_execute(struct datapath *dp, struct sk_buff *skb,
16111608

16121609
static void process_deferred_actions(struct datapath *dp)
16131610
{
1614-
struct action_fifo *fifo = this_cpu_ptr(&ovs_pcpu_storage.action_fifos);
1611+
struct action_fifo *fifo = this_cpu_ptr(&ovs_pcpu_storage->action_fifos);
16151612

16161613
/* Do not touch the FIFO in case there is no deferred actions. */
16171614
if (action_fifo_is_empty(fifo))
@@ -1642,7 +1639,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
16421639
{
16431640
int err, level;
16441641

1645-
level = __this_cpu_inc_return(ovs_pcpu_storage.exec_level);
1642+
level = __this_cpu_inc_return(ovs_pcpu_storage->exec_level);
16461643
if (unlikely(level > OVS_RECURSION_LIMIT)) {
16471644
net_crit_ratelimited("ovs: recursion limit reached on datapath %s, probable configuration error\n",
16481645
ovs_dp_name(dp));
@@ -1659,6 +1656,6 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
16591656
process_deferred_actions(dp);
16601657

16611658
out:
1662-
__this_cpu_dec(ovs_pcpu_storage.exec_level);
1659+
__this_cpu_dec(ovs_pcpu_storage->exec_level);
16631660
return err;
16641661
}

net/openvswitch/datapath.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void ovs_dp_detach_port(struct vport *p)
244244
/* Must be called with rcu_read_lock. */
245245
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
246246
{
247-
struct ovs_pcpu_storage *ovs_pcpu = this_cpu_ptr(&ovs_pcpu_storage);
247+
struct ovs_pcpu_storage *ovs_pcpu = this_cpu_ptr(ovs_pcpu_storage);
248248
const struct vport *p = OVS_CB(skb)->input_vport;
249249
struct datapath *dp = p->dp;
250250
struct sw_flow *flow;
@@ -299,7 +299,7 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
299299
* avoided.
300300
*/
301301
if (IS_ENABLED(CONFIG_PREEMPT_RT) && ovs_pcpu->owner != current) {
302-
local_lock_nested_bh(&ovs_pcpu_storage.bh_lock);
302+
local_lock_nested_bh(&ovs_pcpu_storage->bh_lock);
303303
ovs_pcpu->owner = current;
304304
ovs_pcpu_locked = true;
305305
}
@@ -310,7 +310,7 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
310310
ovs_dp_name(dp), error);
311311
if (ovs_pcpu_locked) {
312312
ovs_pcpu->owner = NULL;
313-
local_unlock_nested_bh(&ovs_pcpu_storage.bh_lock);
313+
local_unlock_nested_bh(&ovs_pcpu_storage->bh_lock);
314314
}
315315

316316
stats_counter = &stats->n_hit;
@@ -689,13 +689,13 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
689689
sf_acts = rcu_dereference(flow->sf_acts);
690690

691691
local_bh_disable();
692-
local_lock_nested_bh(&ovs_pcpu_storage.bh_lock);
692+
local_lock_nested_bh(&ovs_pcpu_storage->bh_lock);
693693
if (IS_ENABLED(CONFIG_PREEMPT_RT))
694-
this_cpu_write(ovs_pcpu_storage.owner, current);
694+
this_cpu_write(ovs_pcpu_storage->owner, current);
695695
err = ovs_execute_actions(dp, packet, sf_acts, &flow->key);
696696
if (IS_ENABLED(CONFIG_PREEMPT_RT))
697-
this_cpu_write(ovs_pcpu_storage.owner, NULL);
698-
local_unlock_nested_bh(&ovs_pcpu_storage.bh_lock);
697+
this_cpu_write(ovs_pcpu_storage->owner, NULL);
698+
local_unlock_nested_bh(&ovs_pcpu_storage->bh_lock);
699699
local_bh_enable();
700700
rcu_read_unlock();
701701

@@ -2744,6 +2744,28 @@ static struct drop_reason_list drop_reason_list_ovs = {
27442744
.n_reasons = ARRAY_SIZE(ovs_drop_reasons),
27452745
};
27462746

2747+
static int __init ovs_alloc_percpu_storage(void)
2748+
{
2749+
unsigned int cpu;
2750+
2751+
ovs_pcpu_storage = alloc_percpu(*ovs_pcpu_storage);
2752+
if (!ovs_pcpu_storage)
2753+
return -ENOMEM;
2754+
2755+
for_each_possible_cpu(cpu) {
2756+
struct ovs_pcpu_storage *ovs_pcpu;
2757+
2758+
ovs_pcpu = per_cpu_ptr(ovs_pcpu_storage, cpu);
2759+
local_lock_init(&ovs_pcpu->bh_lock);
2760+
}
2761+
return 0;
2762+
}
2763+
2764+
static void ovs_free_percpu_storage(void)
2765+
{
2766+
free_percpu(ovs_pcpu_storage);
2767+
}
2768+
27472769
static int __init dp_init(void)
27482770
{
27492771
int err;
@@ -2753,6 +2775,10 @@ static int __init dp_init(void)
27532775

27542776
pr_info("Open vSwitch switching datapath\n");
27552777

2778+
err = ovs_alloc_percpu_storage();
2779+
if (err)
2780+
goto error;
2781+
27562782
err = ovs_internal_dev_rtnl_link_register();
27572783
if (err)
27582784
goto error;
@@ -2799,6 +2825,7 @@ static int __init dp_init(void)
27992825
error_unreg_rtnl_link:
28002826
ovs_internal_dev_rtnl_link_unregister();
28012827
error:
2828+
ovs_free_percpu_storage();
28022829
return err;
28032830
}
28042831

@@ -2813,6 +2840,7 @@ static void dp_cleanup(void)
28132840
ovs_vport_exit();
28142841
ovs_flow_exit();
28152842
ovs_internal_dev_rtnl_link_unregister();
2843+
ovs_free_percpu_storage();
28162844
}
28172845

28182846
module_init(dp_init);

net/openvswitch/datapath.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ struct ovs_pcpu_storage {
220220
struct task_struct *owner;
221221
local_lock_t bh_lock;
222222
};
223-
DECLARE_PER_CPU(struct ovs_pcpu_storage, ovs_pcpu_storage);
223+
224+
extern struct ovs_pcpu_storage __percpu *ovs_pcpu_storage;
224225

225226
/**
226227
* enum ovs_pkt_hash_types - hash info to include with a packet

0 commit comments

Comments
 (0)