Commit 2553ba21 authored by Gal Pressman's avatar Gal Pressman Committed by Jason Gunthorpe
Browse files

RDMA: Mark if destroy address handle is in a sleepable context



Introduce a 'flags' field to destroy address handle callback and add a
flag that marks whether the callback is executed in an atomic context or
not.

This will allow drivers to wait for completion instead of polling for it
when it is allowed.

Signed-off-by: default avatarGal Pressman <galpress@amazon.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent b090c4e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -137,13 +137,13 @@ void agent_send_response(const struct ib_mad_hdr *mad_hdr, const struct ib_grh *
err2:
	ib_free_send_mad(send_buf);
err1:
	rdma_destroy_ah(ah);
	rdma_destroy_ah(ah, RDMA_DESTROY_AH_SLEEPABLE);
}

static void agent_send_handler(struct ib_mad_agent *mad_agent,
			       struct ib_mad_send_wc *mad_send_wc)
{
	rdma_destroy_ah(mad_send_wc->send_buf->ah);
	rdma_destroy_ah(mad_send_wc->send_buf->ah, RDMA_DESTROY_AH_SLEEPABLE);
	ib_free_send_mad(mad_send_wc->send_buf);
}

+2 −2
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
			       GFP_ATOMIC,
			       IB_MGMT_BASE_VERSION);
	if (IS_ERR(m)) {
		rdma_destroy_ah(ah);
		rdma_destroy_ah(ah, 0);
		ret = PTR_ERR(m);
		goto out;
	}
@@ -400,7 +400,7 @@ static int cm_create_response_msg_ah(struct cm_port *port,
static void cm_free_msg(struct ib_mad_send_buf *msg)
{
	if (msg->ah)
		rdma_destroy_ah(msg->ah);
		rdma_destroy_ah(msg->ah, 0);
	if (msg->context[0])
		cm_deref_id(msg->context[0]);
	ib_free_send_mad(msg);
+6 −5
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ static void destroy_rmpp_recv(struct mad_rmpp_recv *rmpp_recv)
{
	deref_rmpp_recv(rmpp_recv);
	wait_for_completion(&rmpp_recv->comp);
	rdma_destroy_ah(rmpp_recv->ah);
	rdma_destroy_ah(rmpp_recv->ah, RDMA_DESTROY_AH_SLEEPABLE);
	kfree(rmpp_recv);
}

@@ -171,7 +171,7 @@ static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
				 hdr_len, 0, GFP_KERNEL,
				 IB_MGMT_BASE_VERSION);
	if (IS_ERR(msg))
		rdma_destroy_ah(ah);
		rdma_destroy_ah(ah, RDMA_DESTROY_AH_SLEEPABLE);
	else {
		msg->ah = ah;
		msg->context[0] = ah;
@@ -201,7 +201,7 @@ static void ack_ds_ack(struct ib_mad_agent_private *agent,

	ret = ib_post_send_mad(msg, NULL);
	if (ret) {
		rdma_destroy_ah(msg->ah);
		rdma_destroy_ah(msg->ah, RDMA_DESTROY_AH_SLEEPABLE);
		ib_free_send_mad(msg);
	}
}
@@ -209,7 +209,8 @@ static void ack_ds_ack(struct ib_mad_agent_private *agent,
void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
{
	if (mad_send_wc->send_buf->context[0] == mad_send_wc->send_buf->ah)
		rdma_destroy_ah(mad_send_wc->send_buf->ah);
		rdma_destroy_ah(mad_send_wc->send_buf->ah,
				RDMA_DESTROY_AH_SLEEPABLE);
	ib_free_send_mad(mad_send_wc->send_buf);
}

@@ -237,7 +238,7 @@ static void nack_recv(struct ib_mad_agent_private *agent,

	ret = ib_post_send_mad(msg, NULL);
	if (ret) {
		rdma_destroy_ah(msg->ah);
		rdma_destroy_ah(msg->ah, RDMA_DESTROY_AH_SLEEPABLE);
		ib_free_send_mad(msg);
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -1147,7 +1147,7 @@ static void free_sm_ah(struct kref *kref)
{
	struct ib_sa_sm_ah *sm_ah = container_of(kref, struct ib_sa_sm_ah, ref);

	rdma_destroy_ah(sm_ah->ah);
	rdma_destroy_ah(sm_ah->ah, 0);
	kfree(sm_ah);
}

+2 −2
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ static void send_handler(struct ib_mad_agent *agent,
	struct ib_umad_packet *packet = send_wc->send_buf->context[0];

	dequeue_send(file, packet);
	rdma_destroy_ah(packet->msg->ah);
	rdma_destroy_ah(packet->msg->ah, RDMA_DESTROY_AH_SLEEPABLE);
	ib_free_send_mad(packet->msg);

	if (send_wc->status == IB_WC_RESP_TIMEOUT_ERR) {
@@ -621,7 +621,7 @@ err_send:
err_msg:
	ib_free_send_mad(packet->msg);
err_ah:
	rdma_destroy_ah(ah);
	rdma_destroy_ah(ah, RDMA_DESTROY_AH_SLEEPABLE);
err_up:
	mutex_unlock(&file->mutex);
err:
Loading