From: Leon Romanovsky <leon@kernel.org>
To: Junxian Huang <huangjunxian6@hisilicon.com>
Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linuxarm@huawei.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH for-rc 1/9] RDMA/hns: Check atomic wr length
Date: Sun, 7 Jul 2024 11:24:33 +0300 [thread overview]
Message-ID: <20240707082433.GD6695@unreal> (raw)
In-Reply-To: <20240705085937.1644229-2-huangjunxian6@hisilicon.com>
On Fri, Jul 05, 2024 at 04:59:29PM +0800, Junxian Huang wrote:
> 8 bytes is the only supported length of atomic. Return an error if
> it is not.
>
> Fixes: 384f88185112 ("RDMA/hns: Add atomic support")
> Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
> ---
> drivers/infiniband/hw/hns/hns_roce_device.h | 2 ++
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 19 +++++++++++++++----
> 2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
> index ff0b3f68ee3a..05005079258c 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_device.h
> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h
> @@ -91,6 +91,8 @@
> /* Configure to HW for PAGE_SIZE larger than 4KB */
> #define PG_SHIFT_OFFSET (PAGE_SHIFT - 12)
>
> +#define ATOMIC_WR_LEN 8
> +
> #define HNS_ROCE_IDX_QUE_ENTRY_SZ 4
> #define SRQ_DB_REG 0x230
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 4287818a737f..a5d746a5cc68 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -164,15 +164,23 @@ static void set_frmr_seg(struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
> hr_reg_clear(fseg, FRMR_BLK_MODE);
> }
>
> -static void set_atomic_seg(const struct ib_send_wr *wr,
> - struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
> - unsigned int valid_num_sge)
> +static int set_atomic_seg(struct hns_roce_dev *hr_dev,
> + const struct ib_send_wr *wr,
> + struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
> + unsigned int valid_num_sge, u32 msg_len)
> {
> struct hns_roce_v2_wqe_data_seg *dseg =
> (void *)rc_sq_wqe + sizeof(struct hns_roce_v2_rc_send_wqe);
> struct hns_roce_wqe_atomic_seg *aseg =
> (void *)dseg + sizeof(struct hns_roce_v2_wqe_data_seg);
>
> + if (msg_len != ATOMIC_WR_LEN) {
> + ibdev_err_ratelimited(&hr_dev->ib_dev,
> + "invalid atomic wr len, len = %u.\n",
> + msg_len);
> + return -EINVAL;
1. Please don't add prints in data-path.
2. You most likely need to add this check before calling to set_atomic_seg().
3. You shouldn't continue to process the WQE if the length is invalid.
Need to return from set_rc_wqe() and not continue.
4. I wonder if it is right place to put this limitation and can't be
enforced much earlier.
Thanks
next prev parent reply other threads:[~2024-07-07 8:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 8:59 [PATCH for-rc 0/9] RDMA/hns: Bugfixes Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 1/9] RDMA/hns: Check atomic wr length Junxian Huang
2024-07-07 8:24 ` Leon Romanovsky [this message]
2024-07-08 2:27 ` Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 2/9] RDMA/hns: Fix a long wait for cmdq event during reset Junxian Huang
2024-07-07 8:30 ` Leon Romanovsky
2024-07-08 2:29 ` Junxian Huang
2024-07-08 5:38 ` Leon Romanovsky
2024-07-08 6:50 ` Junxian Huang
2024-07-08 7:33 ` Leon Romanovsky
2024-07-08 7:46 ` Junxian Huang
2024-07-08 8:27 ` Leon Romanovsky
2024-07-08 8:45 ` Junxian Huang
2024-07-08 8:59 ` Leon Romanovsky
2024-07-08 9:30 ` Junxian Huang
2024-07-08 11:16 ` Leon Romanovsky
2024-07-09 6:21 ` Junxian Huang
2024-07-09 7:22 ` Leon Romanovsky
2024-07-09 7:49 ` Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 3/9] RDMA/hns: Fix soft lockup under heavy CEQE load Junxian Huang
2024-07-05 10:47 ` Zhu Yanjun
2024-07-08 2:30 ` Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 4/9] RDMA/hns: Fix unmatch exception handling when init eq table fails Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 5/9] RDMA/hns: Fix missing pagesize and alignment check in FRMR Junxian Huang
2024-07-07 9:16 ` Zhu Yanjun
2024-07-08 2:44 ` Junxian Huang
2024-07-08 5:41 ` Leon Romanovsky
2024-07-08 7:57 ` Zhu Yanjun
2024-07-08 8:33 ` Leon Romanovsky
2024-07-05 8:59 ` [PATCH for-rc 6/9] RDMA/hns: Fix shift-out-bounds when max_inline_data is 0 Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 7/9] RDMA/hns: Fix undifined behavior caused by invalid max_sge Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 8/9] RDMA/hns: Fix insufficient extend DB for VFs Junxian Huang
2024-07-05 8:59 ` [PATCH for-rc 9/9] RDMA/hns: Fix mbx timing out before CMD execution is completed Junxian Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240707082433.GD6695@unreal \
--to=leon@kernel.org \
--cc=huangjunxian6@hisilicon.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox