Skip to content

Commit 6e0567b

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "Last fixes before holidays. Nothing very exciting: - Work around a HW bug in HNS HIP08 - Recent memory leak regression in qib - Incorrect use of kfree() for vmalloc memory in hns" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/hns: Replace kfree() with kvfree() IB/qib: Fix memory leak in qib_user_sdma_queue_pkts() RDMA/hns: Fix RNR retransmission issue for HIP08
2 parents 86085fe + 12d3bbd commit 6e0567b

4 files changed

Lines changed: 67 additions & 9 deletions

File tree

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,11 +1594,17 @@ static int hns_roce_config_global_param(struct hns_roce_dev *hr_dev)
15941594
{
15951595
struct hns_roce_cmq_desc desc;
15961596
struct hns_roce_cmq_req *req = (struct hns_roce_cmq_req *)desc.data;
1597+
u32 clock_cycles_of_1us;
15971598

15981599
hns_roce_cmq_setup_basic_desc(&desc, HNS_ROCE_OPC_CFG_GLOBAL_PARAM,
15991600
false);
16001601

1601-
hr_reg_write(req, CFG_GLOBAL_PARAM_1US_CYCLES, 0x3e8);
1602+
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08)
1603+
clock_cycles_of_1us = HNS_ROCE_1NS_CFG;
1604+
else
1605+
clock_cycles_of_1us = HNS_ROCE_1US_CFG;
1606+
1607+
hr_reg_write(req, CFG_GLOBAL_PARAM_1US_CYCLES, clock_cycles_of_1us);
16021608
hr_reg_write(req, CFG_GLOBAL_PARAM_UDP_PORT, ROCE_V2_UDP_DPORT);
16031609

16041610
return hns_roce_cmq_send(hr_dev, &desc, 1);
@@ -4802,6 +4808,30 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp,
48024808
return ret;
48034809
}
48044810

4811+
static bool check_qp_timeout_cfg_range(struct hns_roce_dev *hr_dev, u8 *timeout)
4812+
{
4813+
#define QP_ACK_TIMEOUT_MAX_HIP08 20
4814+
#define QP_ACK_TIMEOUT_OFFSET 10
4815+
#define QP_ACK_TIMEOUT_MAX 31
4816+
4817+
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
4818+
if (*timeout > QP_ACK_TIMEOUT_MAX_HIP08) {
4819+
ibdev_warn(&hr_dev->ib_dev,
4820+
"Local ACK timeout shall be 0 to 20.\n");
4821+
return false;
4822+
}
4823+
*timeout += QP_ACK_TIMEOUT_OFFSET;
4824+
} else if (hr_dev->pci_dev->revision > PCI_REVISION_ID_HIP08) {
4825+
if (*timeout > QP_ACK_TIMEOUT_MAX) {
4826+
ibdev_warn(&hr_dev->ib_dev,
4827+
"Local ACK timeout shall be 0 to 31.\n");
4828+
return false;
4829+
}
4830+
}
4831+
4832+
return true;
4833+
}
4834+
48054835
static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
48064836
const struct ib_qp_attr *attr,
48074837
int attr_mask,
@@ -4811,6 +4841,7 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
48114841
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
48124842
struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
48134843
int ret = 0;
4844+
u8 timeout;
48144845

48154846
if (attr_mask & IB_QP_AV) {
48164847
ret = hns_roce_v2_set_path(ibqp, attr, attr_mask, context,
@@ -4820,12 +4851,10 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
48204851
}
48214852

48224853
if (attr_mask & IB_QP_TIMEOUT) {
4823-
if (attr->timeout < 31) {
4824-
hr_reg_write(context, QPC_AT, attr->timeout);
4854+
timeout = attr->timeout;
4855+
if (check_qp_timeout_cfg_range(hr_dev, &timeout)) {
4856+
hr_reg_write(context, QPC_AT, timeout);
48254857
hr_reg_clear(qpc_mask, QPC_AT);
4826-
} else {
4827-
ibdev_warn(&hr_dev->ib_dev,
4828-
"Local ACK timeout shall be 0 to 30.\n");
48294858
}
48304859
}
48314860

@@ -4882,7 +4911,9 @@ static int hns_roce_v2_set_opt_fields(struct ib_qp *ibqp,
48824911
set_access_flags(hr_qp, context, qpc_mask, attr, attr_mask);
48834912

48844913
if (attr_mask & IB_QP_MIN_RNR_TIMER) {
4885-
hr_reg_write(context, QPC_MIN_RNR_TIME, attr->min_rnr_timer);
4914+
hr_reg_write(context, QPC_MIN_RNR_TIME,
4915+
hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08 ?
4916+
HNS_ROCE_RNR_TIMER_10NS : attr->min_rnr_timer);
48864917
hr_reg_clear(qpc_mask, QPC_MIN_RNR_TIME);
48874918
}
48884919

@@ -5499,6 +5530,16 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
54995530

55005531
hr_reg_write(cq_context, CQC_CQ_MAX_CNT, cq_count);
55015532
hr_reg_clear(cqc_mask, CQC_CQ_MAX_CNT);
5533+
5534+
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
5535+
if (cq_period * HNS_ROCE_CLOCK_ADJUST > USHRT_MAX) {
5536+
dev_info(hr_dev->dev,
5537+
"cq_period(%u) reached the upper limit, adjusted to 65.\n",
5538+
cq_period);
5539+
cq_period = HNS_ROCE_MAX_CQ_PERIOD;
5540+
}
5541+
cq_period *= HNS_ROCE_CLOCK_ADJUST;
5542+
}
55025543
hr_reg_write(cq_context, CQC_CQ_PERIOD, cq_period);
55035544
hr_reg_clear(cqc_mask, CQC_CQ_PERIOD);
55045545

@@ -5894,6 +5935,15 @@ static int config_eqc(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq,
58945935
hr_reg_write(eqc, EQC_EQ_PROD_INDX, HNS_ROCE_EQ_INIT_PROD_IDX);
58955936
hr_reg_write(eqc, EQC_EQ_MAX_CNT, eq->eq_max_cnt);
58965937

5938+
if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) {
5939+
if (eq->eq_period * HNS_ROCE_CLOCK_ADJUST > USHRT_MAX) {
5940+
dev_info(hr_dev->dev, "eq_period(%u) reached the upper limit, adjusted to 65.\n",
5941+
eq->eq_period);
5942+
eq->eq_period = HNS_ROCE_MAX_EQ_PERIOD;
5943+
}
5944+
eq->eq_period *= HNS_ROCE_CLOCK_ADJUST;
5945+
}
5946+
58975947
hr_reg_write(eqc, EQC_EQ_PERIOD, eq->eq_period);
58985948
hr_reg_write(eqc, EQC_EQE_REPORT_TIMER, HNS_ROCE_EQ_INIT_REPORT_TIMER);
58995949
hr_reg_write(eqc, EQC_EQE_BA_L, bt_ba >> 3);

drivers/infiniband/hw/hns/hns_roce_hw_v2.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,14 @@ struct hns_roce_dip {
14441444
struct list_head node; /* all dips are on a list */
14451445
};
14461446

1447+
/* only for RNR timeout issue of HIP08 */
1448+
#define HNS_ROCE_CLOCK_ADJUST 1000
1449+
#define HNS_ROCE_MAX_CQ_PERIOD 65
1450+
#define HNS_ROCE_MAX_EQ_PERIOD 65
1451+
#define HNS_ROCE_RNR_TIMER_10NS 1
1452+
#define HNS_ROCE_1US_CFG 999
1453+
#define HNS_ROCE_1NS_CFG 0
1454+
14471455
#define HNS_ROCE_AEQ_DEFAULT_BURST_NUM 0x0
14481456
#define HNS_ROCE_AEQ_DEFAULT_INTERVAL 0x0
14491457
#define HNS_ROCE_CEQ_DEFAULT_BURST_NUM 0x0

drivers/infiniband/hw/hns/hns_roce_srq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int alloc_srq_wrid(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
259259

260260
static void free_srq_wrid(struct hns_roce_srq *srq)
261261
{
262-
kfree(srq->wrid);
262+
kvfree(srq->wrid);
263263
srq->wrid = NULL;
264264
}
265265

drivers/infiniband/hw/qib/qib_user_sdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd,
941941
&addrlimit) ||
942942
addrlimit > type_max(typeof(pkt->addrlimit))) {
943943
ret = -EINVAL;
944-
goto free_pbc;
944+
goto free_pkt;
945945
}
946946
pkt->addrlimit = addrlimit;
947947

0 commit comments

Comments
 (0)