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

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



Introduce a 'flags' field to create 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 5dabcd04
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
		ret = -ENODEV;
		goto out;
	}
	ah = rdma_create_ah(mad_agent->qp->pd, &av->ah_attr);
	ah = rdma_create_ah(mad_agent->qp->pd, &av->ah_attr, 0);
	if (IS_ERR(ah)) {
		ret = PTR_ERR(ah);
		goto out;
+2 −1
Original line number Diff line number Diff line
@@ -2276,7 +2276,8 @@ static void update_sm_ah(struct work_struct *work)
					 cpu_to_be64(IB_SA_WELL_KNOWN_GUID));
	}

	new_ah->ah = rdma_create_ah(port->agent->qp->pd, &ah_attr);
	new_ah->ah = rdma_create_ah(port->agent->qp->pd, &ah_attr,
				    RDMA_CREATE_AH_SLEEPABLE);
	if (IS_ERR(new_ah->ah)) {
		pr_warn("Couldn't create new SM AH\n");
		kfree(new_ah);
+10 −5
Original line number Diff line number Diff line
@@ -487,14 +487,17 @@ rdma_update_sgid_attr(struct rdma_ah_attr *ah_attr,

static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
				     struct rdma_ah_attr *ah_attr,
				     u32 flags,
				     struct ib_udata *udata)
{
	struct ib_ah *ah;

	might_sleep_if(flags & RDMA_CREATE_AH_SLEEPABLE);

	if (!pd->device->ops.create_ah)
		return ERR_PTR(-EOPNOTSUPP);

	ah = pd->device->ops.create_ah(pd, ah_attr, udata);
	ah = pd->device->ops.create_ah(pd, ah_attr, flags, udata);

	if (!IS_ERR(ah)) {
		ah->device  = pd->device;
@@ -514,12 +517,14 @@ static struct ib_ah *_rdma_create_ah(struct ib_pd *pd,
 * given address vector.
 * @pd: The protection domain associated with the address handle.
 * @ah_attr: The attributes of the address vector.
 * @flags: Create address handle flags (see enum rdma_create_ah_flags).
 *
 * It returns 0 on success and returns appropriate error code on error.
 * The address handle is used to reference a local or global destination
 * in all UD QP post sends.
 */
struct ib_ah *rdma_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr)
struct ib_ah *rdma_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
			     u32 flags)
{
	const struct ib_gid_attr *old_sgid_attr;
	struct ib_ah *ah;
@@ -529,7 +534,7 @@ struct ib_ah *rdma_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr)
	if (ret)
		return ERR_PTR(ret);

	ah = _rdma_create_ah(pd, ah_attr, NULL);
	ah = _rdma_create_ah(pd, ah_attr, flags, NULL);

	rdma_unfill_sgid_attr(ah_attr, old_sgid_attr);
	return ah;
@@ -569,7 +574,7 @@ struct ib_ah *rdma_create_user_ah(struct ib_pd *pd,
		}
	}

	ah = _rdma_create_ah(pd, ah_attr, udata);
	ah = _rdma_create_ah(pd, ah_attr, RDMA_CREATE_AH_SLEEPABLE, udata);

out:
	rdma_unfill_sgid_attr(ah_attr, old_sgid_attr);
@@ -881,7 +886,7 @@ struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc,
	if (ret)
		return ERR_PTR(ret);

	ah = rdma_create_ah(pd, &ah_attr);
	ah = rdma_create_ah(pd, &ah_attr, RDMA_CREATE_AH_SLEEPABLE);

	rdma_destroy_ah_attr(&ah_attr);
	return ah;
+1 −0
Original line number Diff line number Diff line
@@ -664,6 +664,7 @@ int bnxt_re_destroy_ah(struct ib_ah *ib_ah)

struct ib_ah *bnxt_re_create_ah(struct ib_pd *ib_pd,
				struct rdma_ah_attr *ah_attr,
				u32 flags,
				struct ib_udata *udata)
{
	struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
+1 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev,
int bnxt_re_dealloc_pd(struct ib_pd *pd);
struct ib_ah *bnxt_re_create_ah(struct ib_pd *pd,
				struct rdma_ah_attr *ah_attr,
				u32 flags,
				struct ib_udata *udata);
int bnxt_re_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
Loading