All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cheng Xu <chengyou@linux.alibaba.com>
To: Wenpeng Liang <liangwenpeng@huawei.com>,
	jgg@ziepe.ca, dledford@redhat.com
Cc: leon@kernel.org, linux-rdma@vger.kernel.org,
	KaiShen@linux.alibaba.com, tonylu@linux.alibaba.com,
	BMT@zurich.ibm.com
Subject: Re: [PATCH for-next v4 05/12] RDMA/erdma: Add cmdq implementation
Date: Sat, 19 Mar 2022 16:38:41 +0800	[thread overview]
Message-ID: <32e91657-4ca5-3012-cede-ac83e7b13d22@linux.alibaba.com> (raw)
In-Reply-To: <e1036da4-4175-3044-1e7f-e7b3710f9e61@huawei.com>



On 3/18/22 7:13 PM, Wenpeng Liang wrote:
> On 2022/3/14 14:47, Cheng Xu wrote:
> <...>
>> +static int erdma_cmdq_eq_init(struct erdma_dev *dev)
>> +{
>> +	struct erdma_cmdq *cmdq = &dev->cmdq;
>> +	struct erdma_eq *eq = &cmdq->eq;
>> +	u32 buf_size;
>> +
>> +	eq->depth = cmdq->max_outstandings;
>> +	buf_size = eq->depth << EQE_SHIFT;
>> +
>> +	eq->qbuf = dma_alloc_coherent(&dev->pdev->dev,
>> +				      WARPPED_BUFSIZE(buf_size),
>> +				      &eq->qbuf_dma_addr,
>> +				      GFP_KERNEL | __GFP_ZERO);
>> +	if (!eq->qbuf)
>> +		return -ENOMEM;
>> +
>> +	spin_lock_init(&eq->lock);
>> +	atomic64_set(&eq->event_num, 0);
> 
> This patchset sets and increases the reference count of event_num, but does not
> call other interfaces such as atomic_dec_and_test to judge event_num. This
> variable seems to be redundant in this patchset. Will subsequent patches
> extend the function of event_num?
> 
> Similar to notify_num, armed_num.
> 

Yes, We plan to expose these counters to ib_device_ops.get_hw_stats 
interface in later patches.

Thanks

> <...>
>> +
>> +static void erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq,
>> +					     __be32 *cqe)
>> +{
>> +	struct erdma_comp_wait *comp_wait;
>> +	u16 sqe_idx, ctx_id;
>> +	u64 *sqe;
>> +	int i;
>> +	u32 hdr0 = __be32_to_cpu(*cqe);
>> +
>> +	sqe_idx = __be32_to_cpu(*(cqe + 1));
>> +	sqe = (u64 *)get_cmdq_sqe(cmdq, sqe_idx);
> 
> The pointer type returned by get_cmdq_sqe is "void *",
> which does not need to be cast.
> 

Will fix.

> <...>
>> +
>> +static void erdma_polling_cmd_completions(struct erdma_cmdq *cmdq)
>> +{
>> +	u32 hdr;
>> +	__be32 *cqe;
>> +	unsigned long flags;
>> +	u16 comp_num = 0;
>> +	u8 owner, expect_owner;
>> +	u16 cqe_idx;
>> +
>> +	spin_lock_irqsave(&cmdq->cq.lock, flags);
>> +
>> +	expect_owner = cmdq->cq.owner;
>> +	cqe_idx = cmdq->cq.ci & (cmdq->cq.depth - 1);
>> +
>> +	while (1) {
>> +		cqe = (__be32 *)get_cmdq_cqe(cmdq, cqe_idx);
>> +		hdr = __be32_to_cpu(READ_ONCE(*cqe));
>> +
>> +		owner = FIELD_GET(ERDMA_CQE_HDR_OWNER_MASK, hdr);
>> +		if (owner != expect_owner)
>> +			break;
>> +
>> +		dma_rmb();
>> +		erdma_poll_single_cmd_completion(cmdq, cqe);
>> +		comp_num++;
>> +		if (cqe_idx == cmdq->cq.depth - 1) {
>> +			cqe_idx = 0;
>> +			expect_owner = !expect_owner;
>> +		} else {
>> +			cqe_idx++;
>> +		}
>> +	}
>> +
>> +	if (comp_num) {
>> +		cmdq->cq.ci += comp_num;
>> +		cmdq->cq.owner = expect_owner;
>> +
>> +		if (cmdq->use_event)
>> +			arm_cmdq_cq(cmdq);
>> +	}
>> +
>> +	spin_unlock_irqrestore(&cmdq->cq.lock, flags);
>> +}
> 
> The logic for judging whether cqe is valid is too complicated,
> you can refer to the function get_sw_cqe_v2() of hns roce,
> I hope it will help you.
> 

I will check this.

Thanks,
Cheng Xu

> Thanks,
> Wenpeng

  reply	other threads:[~2022-03-19  8:38 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14  6:47 [PATCH for-next v4 00/12] Elastic RDMA Adapter (ERDMA) driver Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 01/12] RDMA: Add ERDMA to rdma_driver_id definition Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 02/12] RDMA/core: Allow calling query_port when netdev isn't attached in iWarp Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 03/12] RDMA/erdma: Add the hardware related definitions Cheng Xu
2022-03-18 10:27   ` Wenpeng Liang
2022-03-19  7:53     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 04/12] RDMA/erdma: Add main include file Cheng Xu
2022-03-18 10:35   ` Wenpeng Liang
2022-03-19  8:11     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 05/12] RDMA/erdma: Add cmdq implementation Cheng Xu
2022-03-18 11:13   ` Wenpeng Liang
2022-03-19  8:38     ` Cheng Xu [this message]
2022-03-18 11:16   ` Wenpeng Liang
2022-03-18 18:17     ` Jason Gunthorpe
2022-03-19  1:26       ` Wenpeng Liang
2022-03-18 12:57   ` Wenpeng Liang
2022-03-19  9:18     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 06/12] RDMA/erdma: Add event queue implementation Cheng Xu
2022-03-18 11:43   ` Wenpeng Liang
2022-03-18 18:18     ` Jason Gunthorpe
2022-03-19  9:43       ` Cheng Xu
2022-03-21 22:23         ` Jason Gunthorpe
2022-03-22  3:06           ` Cheng Xu
2022-03-19  8:54     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 07/12] RDMA/erdma: Add verbs header file Cheng Xu
2022-03-18 11:46   ` Wenpeng Liang
2022-03-19  8:55     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 08/12] RDMA/erdma: Add verbs implementation Cheng Xu
2022-03-18 12:24   ` Wenpeng Liang
2022-03-19  9:06     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 09/12] RDMA/erdma: Add connection management (CM) support Cheng Xu
2022-03-18 12:38   ` Wenpeng Liang
2022-03-19  9:10     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 10/12] RDMA/erdma: Add the erdma module Cheng Xu
2022-03-18 12:46   ` Wenpeng Liang
2022-03-19  9:13     ` Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 11/12] RDMA/erdma: Add the ABI definitions Cheng Xu
2022-03-14  6:47 ` [PATCH for-next v4 12/12] RDMA/erdma: Add driver to kernel build environment Cheng Xu
2022-03-17  3:14   ` kernel test robot

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=32e91657-4ca5-3012-cede-ac83e7b13d22@linux.alibaba.com \
    --to=chengyou@linux.alibaba.com \
    --cc=BMT@zurich.ibm.com \
    --cc=KaiShen@linux.alibaba.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=liangwenpeng@huawei.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=tonylu@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.