Commit bfe86035 authored by Lang Cheng's avatar Lang Cheng Committed by Doug Ledford

RDMA/hns: Fix cast from or to restricted __le32 for driver

Sparse is whining about the u32 and __le32 mixed usage in the driver.
The roce_set_field() is used to __le32 data of hardware only.
If a variable is not delivered to the hardware, the __le32 type and
related operations are not required.
Signed-off-by: default avatarLang Cheng <chenglang@huawei.com>
Link: https://lore.kernel.org/r/1566393276-42555-6-git-send-email-oulijun@huawei.comSigned-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 90c559b1
...@@ -657,7 +657,7 @@ struct hns_roce_qp { ...@@ -657,7 +657,7 @@ struct hns_roce_qp {
u8 rdb_en; u8 rdb_en;
u8 sdb_en; u8 sdb_en;
u32 doorbell_qpn; u32 doorbell_qpn;
__le32 sq_signal_bits; u32 sq_signal_bits;
u32 sq_next_wqe; u32 sq_next_wqe;
struct hns_roce_wq sq; struct hns_roce_wq sq;
...@@ -712,7 +712,7 @@ enum { ...@@ -712,7 +712,7 @@ enum {
}; };
struct hns_roce_ceqe { struct hns_roce_ceqe {
u32 comp; __le32 comp;
}; };
struct hns_roce_aeqe { struct hns_roce_aeqe {
......
...@@ -368,9 +368,9 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev, ...@@ -368,9 +368,9 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
unsigned long flags; unsigned long flags;
struct hns_roce_hem_iter iter; struct hns_roce_hem_iter iter;
void __iomem *bt_cmd; void __iomem *bt_cmd;
u32 bt_cmd_h_val = 0; __le32 bt_cmd_val[2];
u32 bt_cmd_val[2]; __le32 bt_cmd_h = 0;
u32 bt_cmd_l = 0; __le32 bt_cmd_l = 0;
u64 bt_ba = 0; u64 bt_ba = 0;
int ret = 0; int ret = 0;
...@@ -380,30 +380,20 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev, ...@@ -380,30 +380,20 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
switch (table->type) { switch (table->type) {
case HEM_TYPE_QPC: case HEM_TYPE_QPC:
roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_QPC);
break;
case HEM_TYPE_MTPT: case HEM_TYPE_MTPT:
roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S,
HEM_TYPE_MTPT);
break;
case HEM_TYPE_CQC: case HEM_TYPE_CQC:
roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_CQC);
break;
case HEM_TYPE_SRQC: case HEM_TYPE_SRQC:
roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M, roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, table->type);
HEM_TYPE_SRQC);
break; break;
default: default:
return ret; return ret;
} }
roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj); ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj);
roce_set_bit(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0); roce_set_bit(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0);
roce_set_bit(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_HW_SYNS_S, 1); roce_set_bit(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_HW_SYNS_S, 1);
/* Currently iter only a chunk */ /* Currently iter only a chunk */
for (hns_roce_hem_first(table->hem[i], &iter); for (hns_roce_hem_first(table->hem[i], &iter);
...@@ -429,13 +419,13 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev, ...@@ -429,13 +419,13 @@ static int hns_roce_set_hem(struct hns_roce_dev *hr_dev,
return -EBUSY; return -EBUSY;
} }
bt_cmd_l = (u32)bt_ba; bt_cmd_l = cpu_to_le32(bt_ba);
roce_set_field(bt_cmd_h_val, ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M, roce_set_field(bt_cmd_h, ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S, ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S,
bt_ba >> BT_BA_SHIFT); bt_ba >> BT_BA_SHIFT);
bt_cmd_val[0] = bt_cmd_l; bt_cmd_val[0] = bt_cmd_l;
bt_cmd_val[1] = bt_cmd_h_val; bt_cmd_val[1] = bt_cmd_h;
hns_roce_write64_k(bt_cmd_val, hns_roce_write64_k(bt_cmd_val,
hr_dev->reg_base + ROCEE_BT_CMD_L_REG); hr_dev->reg_base + ROCEE_BT_CMD_L_REG);
spin_unlock_irqrestore(lock, flags); spin_unlock_irqrestore(lock, flags);
......
...@@ -73,7 +73,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp, ...@@ -73,7 +73,7 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
int ps_opcode = 0, i = 0; int ps_opcode = 0, i = 0;
unsigned long flags = 0; unsigned long flags = 0;
void *wqe = NULL; void *wqe = NULL;
u32 doorbell[2]; __le32 doorbell[2];
int nreq = 0; int nreq = 0;
u32 ind = 0; u32 ind = 0;
int ret = 0; int ret = 0;
...@@ -332,10 +332,10 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp, ...@@ -332,10 +332,10 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp,
SQ_DOORBELL_U32_8_QPN_S, qp->doorbell_qpn); SQ_DOORBELL_U32_8_QPN_S, qp->doorbell_qpn);
roce_set_bit(sq_db.u32_8, SQ_DOORBELL_HW_SYNC_S, 1); roce_set_bit(sq_db.u32_8, SQ_DOORBELL_HW_SYNC_S, 1);
doorbell[0] = le32_to_cpu(sq_db.u32_4); doorbell[0] = sq_db.u32_4;
doorbell[1] = le32_to_cpu(sq_db.u32_8); doorbell[1] = sq_db.u32_8;
hns_roce_write64_k((__le32 *)doorbell, qp->sq.db_reg_l); hns_roce_write64_k(doorbell, qp->sq.db_reg_l);
qp->sq_next_wqe = ind; qp->sq_next_wqe = ind;
} }
...@@ -360,7 +360,7 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp, ...@@ -360,7 +360,7 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device); struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
struct device *dev = &hr_dev->pdev->dev; struct device *dev = &hr_dev->pdev->dev;
struct hns_roce_rq_db rq_db; struct hns_roce_rq_db rq_db;
uint32_t doorbell[2] = {0}; __le32 doorbell[2] = {0};
spin_lock_irqsave(&hr_qp->rq.lock, flags); spin_lock_irqsave(&hr_qp->rq.lock, flags);
ind = hr_qp->rq.head & (hr_qp->rq.wqe_cnt - 1); ind = hr_qp->rq.head & (hr_qp->rq.wqe_cnt - 1);
...@@ -434,11 +434,10 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp, ...@@ -434,11 +434,10 @@ static int hns_roce_v1_post_recv(struct ib_qp *ibqp,
roce_set_bit(rq_db.u32_8, RQ_DOORBELL_U32_8_HW_SYNC_S, roce_set_bit(rq_db.u32_8, RQ_DOORBELL_U32_8_HW_SYNC_S,
1); 1);
doorbell[0] = le32_to_cpu(rq_db.u32_4); doorbell[0] = rq_db.u32_4;
doorbell[1] = le32_to_cpu(rq_db.u32_8); doorbell[1] = rq_db.u32_8;
hns_roce_write64_k((__le32 *)doorbell, hns_roce_write64_k(doorbell, hr_qp->rq.db_reg_l);
hr_qp->rq.db_reg_l);
} }
} }
spin_unlock_irqrestore(&hr_qp->rq.lock, flags); spin_unlock_irqrestore(&hr_qp->rq.lock, flags);
...@@ -712,7 +711,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) ...@@ -712,7 +711,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev)
struct ib_cq *cq; struct ib_cq *cq;
struct ib_pd *pd; struct ib_pd *pd;
union ib_gid dgid; union ib_gid dgid;
u64 subnet_prefix; __be64 subnet_prefix;
int attr_mask = 0; int attr_mask = 0;
int ret; int ret;
int i, j; int i, j;
...@@ -2162,7 +2161,7 @@ static int hns_roce_v1_req_notify_cq(struct ib_cq *ibcq, ...@@ -2162,7 +2161,7 @@ static int hns_roce_v1_req_notify_cq(struct ib_cq *ibcq,
{ {
struct hns_roce_cq *hr_cq = to_hr_cq(ibcq); struct hns_roce_cq *hr_cq = to_hr_cq(ibcq);
u32 notification_flag; u32 notification_flag;
__le32 doorbell[2]; __le32 doorbell[2] = {};
notification_flag = (flags & IB_CQ_SOLICITED_MASK) == notification_flag = (flags & IB_CQ_SOLICITED_MASK) ==
IB_CQ_SOLICITED ? CQ_DB_REQ_NOT : CQ_DB_REQ_NOT_SOL; IB_CQ_SOLICITED ? CQ_DB_REQ_NOT : CQ_DB_REQ_NOT_SOL;
...@@ -2437,18 +2436,12 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev, ...@@ -2437,18 +2436,12 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev,
switch (table->type) { switch (table->type) {
case HEM_TYPE_QPC: case HEM_TYPE_QPC:
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_QPC);
bt_ba = priv->bt_table.qpc_buf.map >> 12; bt_ba = priv->bt_table.qpc_buf.map >> 12;
break; break;
case HEM_TYPE_MTPT: case HEM_TYPE_MTPT:
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_MTPT);
bt_ba = priv->bt_table.mtpt_buf.map >> 12; bt_ba = priv->bt_table.mtpt_buf.map >> 12;
break; break;
case HEM_TYPE_CQC: case HEM_TYPE_CQC:
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, HEM_TYPE_CQC);
bt_ba = priv->bt_table.cqc_buf.map >> 12; bt_ba = priv->bt_table.cqc_buf.map >> 12;
break; break;
case HEM_TYPE_SRQC: case HEM_TYPE_SRQC:
...@@ -2457,6 +2450,8 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev, ...@@ -2457,6 +2450,8 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev,
default: default:
return 0; return 0;
} }
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_MDF_S, table->type);
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M, roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj); ROCEE_BT_CMD_H_ROCEE_BT_CMD_IN_MDF_S, obj);
roce_set_bit(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0); roce_set_bit(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_S, 0);
...@@ -2481,7 +2476,7 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev, ...@@ -2481,7 +2476,7 @@ static int hns_roce_v1_clear_hem(struct hns_roce_dev *hr_dev,
end -= HW_SYNC_SLEEP_TIME_INTERVAL; end -= HW_SYNC_SLEEP_TIME_INTERVAL;
} }
bt_cmd_val[0] = (__le32)bt_ba; bt_cmd_val[0] = cpu_to_le32(bt_ba);
roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M, roce_set_field(bt_cmd_val[1], ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_M,
ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S, bt_ba >> 32); ROCEE_BT_CMD_H_ROCEE_BT_CMD_BA_H_S, bt_ba >> 32);
hns_roce_write64_k(bt_cmd_val, hr_dev->reg_base + ROCEE_BT_CMD_L_REG); hns_roce_write64_k(bt_cmd_val, hr_dev->reg_base + ROCEE_BT_CMD_L_REG);
...@@ -2624,7 +2619,7 @@ static int hns_roce_v1_m_sqp(struct ib_qp *ibqp, const struct ib_qp_attr *attr, ...@@ -2624,7 +2619,7 @@ static int hns_roce_v1_m_sqp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
QP1C_BYTES_16_PORT_NUM_S, hr_qp->phy_port); QP1C_BYTES_16_PORT_NUM_S, hr_qp->phy_port);
roce_set_bit(context->qp1c_bytes_16, roce_set_bit(context->qp1c_bytes_16,
QP1C_BYTES_16_SIGNALING_TYPE_S, QP1C_BYTES_16_SIGNALING_TYPE_S,
le32_to_cpu(hr_qp->sq_signal_bits)); hr_qp->sq_signal_bits);
roce_set_bit(context->qp1c_bytes_16, QP1C_BYTES_16_RQ_BA_FLG_S, roce_set_bit(context->qp1c_bytes_16, QP1C_BYTES_16_RQ_BA_FLG_S,
1); 1);
roce_set_bit(context->qp1c_bytes_16, QP1C_BYTES_16_SQ_BA_FLG_S, roce_set_bit(context->qp1c_bytes_16, QP1C_BYTES_16_SQ_BA_FLG_S,
...@@ -2930,7 +2925,7 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr, ...@@ -2930,7 +2925,7 @@ static int hns_roce_v1_m_qp(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
1); 1);
roce_set_bit(context->qpc_bytes_32, roce_set_bit(context->qpc_bytes_32,
QP_CONTEXT_QPC_BYTE_32_SIGNALING_TYPE_S, QP_CONTEXT_QPC_BYTE_32_SIGNALING_TYPE_S,
le32_to_cpu(hr_qp->sq_signal_bits)); hr_qp->sq_signal_bits);
port = (attr_mask & IB_QP_PORT) ? (attr->port_num - 1) : port = (attr_mask & IB_QP_PORT) ? (attr->port_num - 1) :
hr_qp->port; hr_qp->port;
...@@ -3575,7 +3570,7 @@ static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, ...@@ -3575,7 +3570,7 @@ static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
qp_attr->retry_cnt = roce_get_field(context->qpc_bytes_148, qp_attr->retry_cnt = roce_get_field(context->qpc_bytes_148,
QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_M, QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_M,
QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_S); QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_S);
qp_attr->rnr_retry = (u8)context->rnr_retry; qp_attr->rnr_retry = (u8)le32_to_cpu(context->rnr_retry);
done: done:
qp_attr->cur_qp_state = qp_attr->qp_state; qp_attr->cur_qp_state = qp_attr->qp_state;
......
This diff is collapsed.
...@@ -1426,7 +1426,7 @@ static int hns_roce_set_page(struct ib_mr *ibmr, u64 addr) ...@@ -1426,7 +1426,7 @@ static int hns_roce_set_page(struct ib_mr *ibmr, u64 addr)
{ {
struct hns_roce_mr *mr = to_hr_mr(ibmr); struct hns_roce_mr *mr = to_hr_mr(ibmr);
mr->pbl_buf[mr->npages++] = cpu_to_le64(addr); mr->pbl_buf[mr->npages++] = addr;
return 0; return 0;
} }
...@@ -1597,10 +1597,9 @@ static int hns_roce_write_mtr(struct hns_roce_dev *hr_dev, ...@@ -1597,10 +1597,9 @@ static int hns_roce_write_mtr(struct hns_roce_dev *hr_dev,
/* Save page addr, low 12 bits : 0 */ /* Save page addr, low 12 bits : 0 */
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) if (hr_dev->hw_rev == HNS_ROCE_HW_VER1)
mtts[i] = cpu_to_le64(bufs[npage] >> mtts[i] = bufs[npage] >> PAGE_ADDR_SHIFT;
PAGE_ADDR_SHIFT);
else else
mtts[i] = cpu_to_le64(bufs[npage]); mtts[i] = bufs[npage];
npage++; npage++;
} }
......
...@@ -641,7 +641,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, ...@@ -641,7 +641,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
struct ib_udata *udata, unsigned long sqpn, struct ib_udata *udata, unsigned long sqpn,
struct hns_roce_qp *hr_qp) struct hns_roce_qp *hr_qp)
{ {
dma_addr_t *buf_list[ARRAY_SIZE(hr_qp->regions)] = { 0 }; dma_addr_t *buf_list[ARRAY_SIZE(hr_qp->regions)] = { NULL };
struct device *dev = hr_dev->dev; struct device *dev = hr_dev->dev;
struct hns_roce_ib_create_qp ucmd; struct hns_roce_ib_create_qp ucmd;
struct hns_roce_ib_create_qp_resp resp = {}; struct hns_roce_ib_create_qp_resp resp = {};
...@@ -663,9 +663,9 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, ...@@ -663,9 +663,9 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
hr_qp->ibqp.qp_type = init_attr->qp_type; hr_qp->ibqp.qp_type = init_attr->qp_type;
if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_ALL_WR); hr_qp->sq_signal_bits = IB_SIGNAL_ALL_WR;
else else
hr_qp->sq_signal_bits = cpu_to_le32(IB_SIGNAL_REQ_WR); hr_qp->sq_signal_bits = IB_SIGNAL_REQ_WR;
ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, udata, ret = hns_roce_set_rq_size(hr_dev, &init_attr->cap, udata,
hns_roce_qp_has_rq(init_attr), hr_qp); hns_roce_qp_has_rq(init_attr), hr_qp);
...@@ -910,7 +910,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, ...@@ -910,7 +910,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
if (sqpn) if (sqpn)
hr_qp->doorbell_qpn = 1; hr_qp->doorbell_qpn = 1;
else else
hr_qp->doorbell_qpn = cpu_to_le64(hr_qp->qpn); hr_qp->doorbell_qpn = (u32)hr_qp->qpn;
if (udata) { if (udata) {
ret = ib_copy_to_udata(udata, &resp, ret = ib_copy_to_udata(udata, &resp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment