From: Juan Zhou zhoujuan51@h-partners.com
Juan Zhou (2): RDMA/hns: Fix missing parameter check in set_write_notify_param() RDMA/hns: Fix memory leak in POE debugfs
Junxian Huang (2): RDMA/hns: Add cap_flag check for check_vf_support() RDMA/hns: Fix incorrect bond clear during slave increase event
drivers/infiniband/hw/hns/hns_roce_bond.c | 22 ++++++++++++++------ drivers/infiniband/hw/hns/hns_roce_cq.c | 3 +++ drivers/infiniband/hw/hns/hns_roce_debugfs.c | 6 +----- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- 4 files changed, 22 insertions(+), 12 deletions(-)
From: Juan Zhou zhoujuan51@h-partners.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8NZ4Y
--------------------------------------------------------------------------
Add parameter check in set_write_notify_param().
Fixes: 21cacb516f20 ("RDMA/hns: Support write with notify") Signed-off-by: Juan Zhou zhoujuan51@h-partners.com Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_cq.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c index 2363e338765c..48c25b30a395 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cq.c +++ b/drivers/infiniband/hw/hns/hns_roce_cq.c @@ -392,6 +392,9 @@ static int set_write_notify_param(struct hns_roce_dev *hr_dev, notify_attr[attr].mem_type)) return -EOPNOTSUPP;
+ if (!hr_dev->notify_tbl || ucmd->notify_idx >= hr_dev->notify_num) + return -EINVAL; + hr_cq->flags |= HNS_ROCE_CQ_FLAG_NOTIFY_EN; hr_cq->write_notify.notify_addr = hr_dev->notify_tbl[ucmd->notify_idx].base_addr;
From: Juan Zhou zhoujuan51@h-partners.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8OLBT
--------------------------------------------------------------------------
In the init_poe_ch_debugfs() function, the variable dbgfs can be directly read without applying for additional memory. Otherwise, memory leakage may occur.
Fixes: b6643496e2b4 ("RDMA/hns: Refactor hns RoCE debugfs") Signed-off-by: Juan Zhou zhoujuan51@h-partners.com Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_debugfs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_debugfs.c b/drivers/infiniband/hw/hns/hns_roce_debugfs.c index d42bea711507..9d3075ee0d22 100644 --- a/drivers/infiniband/hw/hns/hns_roce_debugfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_debugfs.c @@ -557,14 +557,10 @@ static void init_poe_ch_debugfs(struct hns_roce_dev *hr_dev, uint8_t index, struct dentry *parent) { #define POE_CH_NAME_LEN 10 + struct hns_poe_ch_debugfs *dbgfs = &hr_dev->dbgfs.poe_root.poe_ch[index]; struct hns_roce_poe_ch *poe_ch = &hr_dev->poe_ctx.poe_ch[index]; - struct hns_poe_ch_debugfs *dbgfs; char name[POE_CH_NAME_LEN];
- dbgfs = kvzalloc(sizeof(*dbgfs), GFP_KERNEL); - if (!dbgfs) - return; - snprintf(name, sizeof(name), "poe_%u", index); dbgfs->root = debugfs_create_dir(name, parent);
From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: cleanup bugzilla: https://gitee.com/openeuler/kernel/issues/I8O0QJ
--------------------------------------------------------------------------
check_vf_support() aims to prevent the init of roce vf whose corresponding pf is in a bond group. For devices that doesn't support bonding, there is no need to execute this checking.
Fixes: a1598d8616e7 ("RDMA/hns: fix the error of RoCE VF based on RoCE Bonding PF") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com Signed-off-by: Juan Zhou zhoujuan51@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 978d26ba153e..2b474c22cafa 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -7650,7 +7650,8 @@ static int __hns_roce_hw_v2_init_instance(struct hnae3_handle *handle)
hns_roce_hw_v2_get_cfg(hr_dev, handle);
- if (hr_dev->is_vf && !check_vf_support(hr_dev->pci_dev)) { + if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_BOND && + hr_dev->is_vf && !check_vf_support(hr_dev->pci_dev)) { ret = -EOPNOTSUPP; goto error_failed_roce_init; }
From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8N6RR
----------------------------------------------------------------------
During slave increase event (a new slave being added to a existing bond), the existing slaves do not have a corresponding hr_dev handle (except for the main_hr_dev one). These slaves are mistakenly treated as non-hns devices and will lead to bond clear currently.
The correct way to confirm if a slave is a hns device is to compare the netdev handle saved in the bond group.
Fixes: 6ba084e0f031 ("RDMA/hns: add constraints for bonding-unsupported situations") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com Signed-off-by: Juan Zhou zhoujuan51@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_bond.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_bond.c b/drivers/infiniband/hw/hns/hns_roce_bond.c index 2923acb810bd..238914c58869 100644 --- a/drivers/infiniband/hw/hns/hns_roce_bond.c +++ b/drivers/infiniband/hw/hns/hns_roce_bond.c @@ -790,9 +790,20 @@ static struct hns_roce_bond_group *hns_roce_alloc_bond_grp(struct hns_roce_dev * return bond_grp; }
-static bool is_dev_bond_supported(struct hns_roce_dev *hr_dev, int bus_num) +static bool is_dev_bond_supported(struct hns_roce_bond_group *bond_grp, + struct net_device *net_dev, int bus_num) { - if (!hr_dev || !(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_BOND)) + struct hns_roce_dev *hr_dev = hns_roce_get_hrdev_by_netdev(net_dev); + + if (!hr_dev) { + if (bond_grp && + get_netdev_bond_slave_id(net_dev, bond_grp) >= 0) + return true; + else + return false; + } + + if (!(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_BOND)) return false;
if (hr_dev->is_vf || pci_num_vf(hr_dev->pci_dev) > 0) @@ -820,10 +831,10 @@ static bool check_unlinking_bond_support(struct hns_roce_bond_group *bond_grp) }
static bool check_linking_bond_support(struct netdev_lag_upper_info *bond_info, + struct hns_roce_bond_group *bond_grp, struct net_device *upper_dev, int bus_num) { - struct hns_roce_dev *hr_dev; struct net_device *net_dev; u8 slave_num = 0;
@@ -832,8 +843,7 @@ static bool check_linking_bond_support(struct netdev_lag_upper_info *bond_info,
rcu_read_lock(); for_each_netdev_in_bond_rcu(upper_dev, net_dev) { - hr_dev = hns_roce_get_hrdev_by_netdev(net_dev); - if (is_dev_bond_supported(hr_dev, bus_num)) { + if (is_dev_bond_supported(bond_grp, net_dev, bus_num)) { slave_num++; } else { rcu_read_unlock(); @@ -865,7 +875,7 @@ static enum bond_support_type return BOND_NOT_SUPPORT;
if (info->linking) - support = check_linking_bond_support(info->upper_info, + support = check_linking_bond_support(info->upper_info, bond_grp, *upper_dev, bus_num); else support = check_unlinking_bond_support(bond_grp);