Skip to content

Commit 4863b57

Browse files
committed
Merge tag 'mlx5-fixes-2023-07-05' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2023-07-05 This series provides bug fixes to mlx5 driver. * tag 'mlx5-fixes-2023-07-05' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5e: RX, Fix page_pool page fragment tracking for XDP net/mlx5: Query hca_cap_2 only when supported net/mlx5e: TC, CT: Offload ct clear only once net/mlx5e: Check for NOT_READY flag state after locking net/mlx5: Register a unique thermal zone per device net/mlx5e: RX, Fix flush and close release flow of regular rq for legacy rq net/mlx5e: fix memory leak in mlx5e_ptp_open net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create net/mlx5e: fix double free in mlx5e_destroy_flow_table ==================== Link: https://lore.kernel.org/r/20230705175757.284614-1-saeed@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 0323bce + 7abd955 commit 4863b57

10 files changed

Lines changed: 61 additions & 42 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_flow_steering *fs)
594594

595595
err = fs_any_create_table(fs);
596596
if (err)
597-
return err;
597+
goto err_free_any;
598598

599599
err = fs_any_enable(fs);
600600
if (err)
@@ -606,8 +606,8 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_flow_steering *fs)
606606

607607
err_destroy_table:
608608
fs_any_destroy_table(fs_any);
609-
610-
kfree(fs_any);
609+
err_free_any:
611610
mlx5e_fs_set_any(fs, NULL);
611+
kfree(fs_any);
612612
return err;
613613
}

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
729729

730730
c = kvzalloc_node(sizeof(*c), GFP_KERNEL, dev_to_node(mlx5_core_dma_dev(mdev)));
731731
cparams = kvzalloc(sizeof(*cparams), GFP_KERNEL);
732-
if (!c || !cparams)
733-
return -ENOMEM;
732+
if (!c || !cparams) {
733+
err = -ENOMEM;
734+
goto err_free;
735+
}
734736

735737
c->priv = priv;
736738
c->mdev = priv->mdev;

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv,
15451545

15461546
attr->ct_attr.ct_action |= act->ct.action; /* So we can have clear + ct */
15471547
attr->ct_attr.zone = act->ct.zone;
1548-
attr->ct_attr.nf_ft = act->ct.flow_table;
1548+
if (!(act->ct.action & TCA_CT_ACT_CLEAR))
1549+
attr->ct_attr.nf_ft = act->ct.flow_table;
15491550
attr->ct_attr.act_miss_cookie = act->miss_cookie;
15501551

15511552
return 0;
@@ -1990,6 +1991,9 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, struct mlx5_flow_attr *att
19901991
if (!priv)
19911992
return -EOPNOTSUPP;
19921993

1994+
if (attr->ct_attr.offloaded)
1995+
return 0;
1996+
19931997
if (attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR) {
19941998
err = mlx5_tc_ct_entry_set_registers(priv, &attr->parse_attr->mod_hdr_acts,
19951999
0, 0, 0, 0);
@@ -1999,11 +2003,15 @@ mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *priv, struct mlx5_flow_attr *att
19992003
attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
20002004
}
20012005

2002-
if (!attr->ct_attr.nf_ft) /* means only ct clear action, and not ct_clear,ct() */
2006+
if (!attr->ct_attr.nf_ft) { /* means only ct clear action, and not ct_clear,ct() */
2007+
attr->ct_attr.offloaded = true;
20032008
return 0;
2009+
}
20042010

20052011
mutex_lock(&priv->control_lock);
20062012
err = __mlx5_tc_ct_flow_offload(priv, attr);
2013+
if (!err)
2014+
attr->ct_attr.offloaded = true;
20072015
mutex_unlock(&priv->control_lock);
20082016

20092017
return err;
@@ -2021,7 +2029,7 @@ void
20212029
mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv,
20222030
struct mlx5_flow_attr *attr)
20232031
{
2024-
if (!attr->ct_attr.ft) /* no ct action, return */
2032+
if (!attr->ct_attr.offloaded) /* no ct action, return */
20252033
return;
20262034
if (!attr->ct_attr.nf_ft) /* means only ct clear action, and not ct_clear,ct() */
20272035
return;

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct mlx5_ct_attr {
2929
u32 ct_labels_id;
3030
u32 act_miss_mapping;
3131
u64 act_miss_cookie;
32+
bool offloaded;
3233
struct mlx5_ct_ft *ft;
3334
};
3435

drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ static void mlx5e_free_xdpsq_desc(struct mlx5e_xdpsq *sq,
662662
/* No need to check ((page->pp_magic & ~0x3UL) == PP_SIGNATURE)
663663
* as we know this is a page_pool page.
664664
*/
665-
page_pool_put_defragged_page(page->pp,
666-
page, -1, true);
665+
page_pool_recycle_direct(page->pp, page);
667666
} while (++n < num);
668667

669668
break;

drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ static int accel_fs_tcp_create_groups(struct mlx5e_flow_table *ft,
190190
in = kvzalloc(inlen, GFP_KERNEL);
191191
if (!in || !ft->g) {
192192
kfree(ft->g);
193+
ft->g = NULL;
193194
kvfree(in);
194195
return -ENOMEM;
195196
}

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,18 @@ static void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix)
390390
{
391391
struct mlx5e_wqe_frag_info *wi = get_frag(rq, ix);
392392

393-
if (rq->xsk_pool)
393+
if (rq->xsk_pool) {
394394
mlx5e_xsk_free_rx_wqe(wi);
395-
else
395+
} else {
396396
mlx5e_free_rx_wqe(rq, wi);
397+
398+
/* Avoid a second release of the wqe pages: dealloc is called
399+
* for the same missing wqes on regular RQ flush and on regular
400+
* RQ close. This happens when XSK RQs come into play.
401+
*/
402+
for (int i = 0; i < rq->wqe.info.num_frags; i++, wi++)
403+
wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
404+
}
397405
}
398406

399407
static void mlx5e_xsk_free_rx_wqes(struct mlx5e_rq *rq, u16 ix, int wqe_bulk)
@@ -1743,11 +1751,11 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi
17431751

17441752
prog = rcu_dereference(rq->xdp_prog);
17451753
if (prog && mlx5e_xdp_handle(rq, prog, &mxbuf)) {
1746-
if (test_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
1754+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
17471755
struct mlx5e_wqe_frag_info *pwi;
17481756

17491757
for (pwi = head_wi; pwi < wi; pwi++)
1750-
pwi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
1758+
pwi->frag_page->frags++;
17511759
}
17521760
return NULL; /* page/packet was consumed by XDP */
17531761
}
@@ -1817,12 +1825,8 @@ static void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
18171825
rq, wi, cqe, cqe_bcnt);
18181826
if (!skb) {
18191827
/* probably for XDP */
1820-
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
1821-
/* do not return page to cache,
1822-
* it will be returned on XDP_TX completion.
1823-
*/
1824-
wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
1825-
}
1828+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
1829+
wi->frag_page->frags++;
18261830
goto wq_cyc_pop;
18271831
}
18281832

@@ -1868,12 +1872,8 @@ static void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
18681872
rq, wi, cqe, cqe_bcnt);
18691873
if (!skb) {
18701874
/* probably for XDP */
1871-
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
1872-
/* do not return page to cache,
1873-
* it will be returned on XDP_TX completion.
1874-
*/
1875-
wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
1876-
}
1875+
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
1876+
wi->frag_page->frags++;
18771877
goto wq_cyc_pop;
18781878
}
18791879

@@ -2052,12 +2052,12 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w
20522052
if (prog) {
20532053
if (mlx5e_xdp_handle(rq, prog, &mxbuf)) {
20542054
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) {
2055-
int i;
2055+
struct mlx5e_frag_page *pfp;
2056+
2057+
for (pfp = head_page; pfp < frag_page; pfp++)
2058+
pfp->frags++;
20562059

2057-
for (i = 0; i < sinfo->nr_frags; i++)
2058-
/* non-atomic */
2059-
__set_bit(page_idx + i, wi->skip_release_bitmap);
2060-
return NULL;
2060+
wi->linear_page.frags++;
20612061
}
20622062
mlx5e_page_release_fragmented(rq, &wi->linear_page);
20632063
return NULL; /* page/packet was consumed by XDP */
@@ -2155,7 +2155,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
21552155
cqe_bcnt, &mxbuf);
21562156
if (mlx5e_xdp_handle(rq, prog, &mxbuf)) {
21572157
if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags))
2158-
__set_bit(page_idx, wi->skip_release_bitmap); /* non-atomic */
2158+
frag_page->frags++;
21592159
return NULL; /* page/packet was consumed by XDP */
21602160
}
21612161

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,8 @@ static void remove_unready_flow(struct mlx5e_tc_flow *flow)
16391639
uplink_priv = &rpriv->uplink_priv;
16401640

16411641
mutex_lock(&uplink_priv->unready_flows_lock);
1642-
unready_flow_del(flow);
1642+
if (flow_flag_test(flow, NOT_READY))
1643+
unready_flow_del(flow);
16431644
mutex_unlock(&uplink_priv->unready_flows_lock);
16441645
}
16451646

@@ -1932,8 +1933,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
19321933
esw_attr = attr->esw_attr;
19331934
mlx5e_put_flow_tunnel_id(flow);
19341935

1935-
if (flow_flag_test(flow, NOT_READY))
1936-
remove_unready_flow(flow);
1936+
remove_unready_flow(flow);
19371937

19381938
if (mlx5e_is_offloaded_flow(flow)) {
19391939
if (flow_flag_test(flow, SLOW))

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,9 @@ static int mlx5_esw_vport_caps_get(struct mlx5_eswitch *esw, struct mlx5_vport *
807807
hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
808808
vport->info.roce_enabled = MLX5_GET(cmd_hca_cap, hca_caps, roce);
809809

810+
if (!MLX5_CAP_GEN_MAX(esw->dev, hca_cap_2))
811+
goto out_free;
812+
810813
memset(query_ctx, 0, query_out_sz);
811814
err = mlx5_vport_get_other_func_cap(esw->dev, vport->vport, query_ctx,
812815
MLX5_CAP_GENERAL_2);

drivers/net/ethernet/mellanox/mlx5/core/thermal.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ static struct thermal_zone_device_ops mlx5_thermal_ops = {
6868

6969
int mlx5_thermal_init(struct mlx5_core_dev *mdev)
7070
{
71+
char data[THERMAL_NAME_LENGTH];
7172
struct mlx5_thermal *thermal;
72-
struct thermal_zone_device *tzd;
73-
const char *data = "mlx5";
73+
int err;
7474

75-
tzd = thermal_zone_get_zone_by_name(data);
76-
if (!IS_ERR(tzd))
75+
if (!mlx5_core_is_pf(mdev) && !mlx5_core_is_ecpf(mdev))
7776
return 0;
7877

78+
err = snprintf(data, sizeof(data), "mlx5_%s", dev_name(mdev->device));
79+
if (err < 0 || err >= sizeof(data)) {
80+
mlx5_core_err(mdev, "Failed to setup thermal zone name, %d\n", err);
81+
return -EINVAL;
82+
}
83+
7984
thermal = kzalloc(sizeof(*thermal), GFP_KERNEL);
8085
if (!thermal)
8186
return -ENOMEM;
@@ -89,10 +94,10 @@ int mlx5_thermal_init(struct mlx5_core_dev *mdev)
8994
&mlx5_thermal_ops,
9095
NULL, 0, MLX5_THERMAL_POLL_INT_MSEC);
9196
if (IS_ERR(thermal->tzdev)) {
92-
dev_err(mdev->device, "Failed to register thermal zone device (%s) %ld\n",
93-
data, PTR_ERR(thermal->tzdev));
97+
err = PTR_ERR(thermal->tzdev);
98+
mlx5_core_err(mdev, "Failed to register thermal zone device (%s) %d\n", data, err);
9499
kfree(thermal);
95-
return -EINVAL;
100+
return err;
96101
}
97102

98103
mdev->thermal = thermal;

0 commit comments

Comments
 (0)