All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
To: Steve Wise
	<swise-7bPotxP6k4+P2YhJcF5u+p6NamaJ0bNTAL8bYrjMMd8@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
Subject: Re: [PATCH v4 1/4] IB: new common API for draining queues
Date: Wed, 17 Feb 2016 15:35:44 -0800	[thread overview]
Message-ID: <56C503D0.7060402@sandisk.com> (raw)
In-Reply-To: <5b4799151723516ec440191b3f0ae98a46b356f0.1455741336.git.swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>

On 02/17/2016 08:15 AM, Steve Wise wrote:
> +static void __ib_drain_sq(struct ib_qp *qp)
> +{
> +	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
> +	struct ib_drain_cqe sdrain;
> +	struct ib_send_wr swr = {}, *bad_swr;
> +	int ret;
> +
> +	if (qp->send_cq->poll_ctx == IB_POLL_DIRECT) {
> +		WARN_ONCE(qp->send_cq->poll_ctx == IB_POLL_DIRECT,
> +			  "IB_POLL_DIRECT poll_ctx not supported for drain\n");
> +		return;
> +	}
> +
> +	swr.wr_cqe = &sdrain.cqe;
> +	sdrain.cqe.done = ib_drain_qp_done;
> +	init_completion(&sdrain.done);
> +
> +	ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
> +	if (ret) {
> +		WARN_ONCE(ret, "failed to drain send queue: %d\n", ret);
> +		return;
> +	}
> +
> +	ret = ib_post_send(qp, &swr, &bad_swr);
> +	if (ret) {
> +		WARN_ONCE(ret, "failed to drain send queue: %d\n", ret);
> +		return;
> +	}
> +
> +	wait_for_completion(&sdrain.done);
> +}
> +
> +/*
> + * Post a WR and block until its completion is reaped for the RQ.
> + */
> +static void __ib_drain_rq(struct ib_qp *qp)
> +{
> +	struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
> +	struct ib_drain_cqe rdrain;
> +	struct ib_recv_wr rwr = {}, *bad_rwr;
> +	int ret;
> +
> +	if (qp->recv_cq->poll_ctx == IB_POLL_DIRECT) {
> +		WARN_ONCE(qp->recv_cq->poll_ctx == IB_POLL_DIRECT,
> +			  "IB_POLL_DIRECT poll_ctx not supported for drain\n");
> +		return;
> +	}
> +
> +	rwr.wr_cqe = &rdrain.cqe;
> +	rdrain.cqe.done = ib_drain_qp_done;
> +	init_completion(&rdrain.done);
> +
> +	ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
> +	if (ret) {
> +		WARN_ONCE(ret, "failed to drain recv queue: %d\n", ret);
> +		return;
> +	}
> +
> +	ret = ib_post_recv(qp, &rwr, &bad_rwr);
> +	if (ret) {
> +		WARN_ONCE(ret, "failed to drain recv queue: %d\n", ret);
> +		return;
> +	}
> +
> +	wait_for_completion(&rdrain.done);
> +}

Hello Steve,

I only have one comment about this patch: are you aware that the six 
invocations of WARN_ONCE() can be made less verbose by rewriting if (c) 
{ WARN_ONCE(c, m); ... } as if (WARN_ONCE(c, m)) { ... } ?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-02-17 23:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 20:35 [PATCH v4 0/4] new ib_drain_qp() API Steve Wise
     [not found] ` <cover.1455741336.git.swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2016-02-17 16:15   ` [PATCH v4 1/4] IB: new common API for draining queues Steve Wise
     [not found]     ` <5b4799151723516ec440191b3f0ae98a46b356f0.1455741336.git.swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2016-02-17 23:35       ` Bart Van Assche [this message]
     [not found]         ` <56C503D0.7060402-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-02-17 23:39           ` Steve Wise
2016-02-21 15:01       ` Sagi Grimberg
     [not found]         ` <56C9D14B.9010307-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-02-22  5:39           ` Devesh Sharma
2016-02-17 16:15   ` [PATCH v4 2/4] iw_cxgb4: add queue drain functions Steve Wise
     [not found]     ` <162a5429342dfd5e16881f4360c0ef858fd39cbd.1455741336.git.swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2016-02-21 15:01       ` Sagi Grimberg
2016-03-09 12:53       ` Leon Romanovsky
     [not found]         ` <20160309125349.GA1977-2ukJVAZIZ/Y@public.gmane.org>
2016-03-09 15:23           ` Steve Wise
2016-03-09 15:28             ` Sagi Grimberg
     [not found]               ` <56E0412F.4000602-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-03-10  5:05                 ` Leon Romanovsky
     [not found]                   ` <20160310050558.GD1977-2ukJVAZIZ/Y@public.gmane.org>
2016-03-24 10:46                     ` Leon Romanovsky
     [not found]                       ` <20160324104659.GC11949-2ukJVAZIZ/Y@public.gmane.org>
2016-03-24 14:36                         ` Faisal Latif
2016-02-17 16:15   ` [PATCH v4 3/4] IB/srp: Use ib_drain_rq() Steve Wise
     [not found]     ` <8a0a024ce256ac8c9be5e46a05f158d6e74a3cb9.1455741336.git.swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2016-02-21 15:02       ` Sagi Grimberg
2016-02-17 16:17   ` [PATCH v4 4/4] IB/iser: Use ib_drain_sq() Steve Wise
     [not found]     ` <269ab4c6de9c30bb6beba249302d5f1d1db9b924.1455741337.git.swise-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2016-02-21 15:02       ` Sagi Grimberg
2016-03-03 10:10       ` Sagi Grimberg
     [not found]         ` <56D80D8F.7070700-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-03-03 15:17           ` Steve Wise
2016-02-17 21:09   ` [PATCH v4 0/4] new ib_drain_qp() API Doug Ledford

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=56C503D0.7060402@sandisk.com \
    --to=bart.vanassche-xdaiopvojttbdgjk7y7tuq@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=swise-7bPotxP6k4+P2YhJcF5u+p6NamaJ0bNTAL8bYrjMMd8@public.gmane.org \
    /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.