Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9844b71b authored by Joachim Fenkes's avatar Joachim Fenkes Committed by Roland Dreier
Browse files

IB/ehca: Lock renaming, static initializers



- Rename all spinlock flags to "flags", matching the vast majority of kernel
  code.
- Move hcall_lock into the only file it's used in.
- Replaced spin_lock_init() and friends with static initializers for
  global variables.

Signed-off-by: default avatarJoachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 15f001ec
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -295,7 +295,6 @@ void ehca_cleanup_mrmw_cache(void);


extern spinlock_t ehca_qp_idr_lock;
extern spinlock_t ehca_qp_idr_lock;
extern spinlock_t ehca_cq_idr_lock;
extern spinlock_t ehca_cq_idr_lock;
extern spinlock_t hcall_lock;
extern struct idr ehca_qp_idr;
extern struct idr ehca_qp_idr;
extern struct idr ehca_cq_idr;
extern struct idr ehca_cq_idr;


+6 −6
Original line number Original line Diff line number Diff line
@@ -56,11 +56,11 @@ int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp)
{
{
	unsigned int qp_num = qp->real_qp_num;
	unsigned int qp_num = qp->real_qp_num;
	unsigned int key = qp_num & (QP_HASHTAB_LEN-1);
	unsigned int key = qp_num & (QP_HASHTAB_LEN-1);
	unsigned long spl_flags;
	unsigned long flags;


	spin_lock_irqsave(&cq->spinlock, spl_flags);
	spin_lock_irqsave(&cq->spinlock, flags);
	hlist_add_head(&qp->list_entries, &cq->qp_hashtab[key]);
	hlist_add_head(&qp->list_entries, &cq->qp_hashtab[key]);
	spin_unlock_irqrestore(&cq->spinlock, spl_flags);
	spin_unlock_irqrestore(&cq->spinlock, flags);


	ehca_dbg(cq->ib_cq.device, "cq_num=%x real_qp_num=%x",
	ehca_dbg(cq->ib_cq.device, "cq_num=%x real_qp_num=%x",
		 cq->cq_number, qp_num);
		 cq->cq_number, qp_num);
@@ -74,9 +74,9 @@ int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int real_qp_num)
	unsigned int key = real_qp_num & (QP_HASHTAB_LEN-1);
	unsigned int key = real_qp_num & (QP_HASHTAB_LEN-1);
	struct hlist_node *iter;
	struct hlist_node *iter;
	struct ehca_qp *qp;
	struct ehca_qp *qp;
	unsigned long spl_flags;
	unsigned long flags;


	spin_lock_irqsave(&cq->spinlock, spl_flags);
	spin_lock_irqsave(&cq->spinlock, flags);
	hlist_for_each(iter, &cq->qp_hashtab[key]) {
	hlist_for_each(iter, &cq->qp_hashtab[key]) {
		qp = hlist_entry(iter, struct ehca_qp, list_entries);
		qp = hlist_entry(iter, struct ehca_qp, list_entries);
		if (qp->real_qp_num == real_qp_num) {
		if (qp->real_qp_num == real_qp_num) {
@@ -88,7 +88,7 @@ int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int real_qp_num)
			break;
			break;
		}
		}
	}
	}
	spin_unlock_irqrestore(&cq->spinlock, spl_flags);
	spin_unlock_irqrestore(&cq->spinlock, flags);
	if (ret)
	if (ret)
		ehca_err(cq->ib_cq.device,
		ehca_err(cq->ib_cq.device,
			 "qp not found cq_num=%x real_qp_num=%x",
			 "qp not found cq_num=%x real_qp_num=%x",
+4 −14
Original line number Original line Diff line number Diff line
@@ -96,15 +96,13 @@ MODULE_PARM_DESC(static_rate,
MODULE_PARM_DESC(scaling_code,
MODULE_PARM_DESC(scaling_code,
		 "set scaling code (0: disabled/default, 1: enabled)");
		 "set scaling code (0: disabled/default, 1: enabled)");


spinlock_t ehca_qp_idr_lock;
DEFINE_SPINLOCK(ehca_qp_idr_lock);
spinlock_t ehca_cq_idr_lock;
DEFINE_SPINLOCK(ehca_cq_idr_lock);
spinlock_t hcall_lock;
DEFINE_IDR(ehca_qp_idr);
DEFINE_IDR(ehca_qp_idr);
DEFINE_IDR(ehca_cq_idr);
DEFINE_IDR(ehca_cq_idr);



static LIST_HEAD(shca_list); /* list of all registered ehcas */
static struct list_head shca_list; /* list of all registered ehcas */
static DEFINE_SPINLOCK(shca_list_lock);
static spinlock_t shca_list_lock;


static struct timer_list poll_eqs_timer;
static struct timer_list poll_eqs_timer;


@@ -864,14 +862,6 @@ int __init ehca_module_init(void)


	printk(KERN_INFO "eHCA Infiniband Device Driver "
	printk(KERN_INFO "eHCA Infiniband Device Driver "
	       "(Rel.: SVNEHCA_0023)\n");
	       "(Rel.: SVNEHCA_0023)\n");
	idr_init(&ehca_qp_idr);
	idr_init(&ehca_cq_idr);
	spin_lock_init(&ehca_qp_idr_lock);
	spin_lock_init(&ehca_cq_idr_lock);
	spin_lock_init(&hcall_lock);

	INIT_LIST_HEAD(&shca_list);
	spin_lock_init(&shca_list_lock);


	if ((ret = ehca_create_comp_pool())) {
	if ((ret = ehca_create_comp_pool())) {
		ehca_gen_err("Cannot create comp pool.");
		ehca_gen_err("Cannot create comp pool.");
+3 −3
Original line number Original line Diff line number Diff line
@@ -933,7 +933,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
	u64 h_ret;
	u64 h_ret;
	int bad_wqe_cnt = 0;
	int bad_wqe_cnt = 0;
	int squeue_locked = 0;
	int squeue_locked = 0;
	unsigned long spl_flags = 0;
	unsigned long flags = 0;


	/* do query_qp to obtain current attr values */
	/* do query_qp to obtain current attr values */
	mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL);
	mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL);
@@ -1074,7 +1074,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
		if (!ibqp->uobject) {
		if (!ibqp->uobject) {
			struct ehca_wqe *wqe;
			struct ehca_wqe *wqe;
			/* lock send queue */
			/* lock send queue */
			spin_lock_irqsave(&my_qp->spinlock_s, spl_flags);
			spin_lock_irqsave(&my_qp->spinlock_s, flags);
			squeue_locked = 1;
			squeue_locked = 1;
			/* mark next free wqe */
			/* mark next free wqe */
			wqe = (struct ehca_wqe*)
			wqe = (struct ehca_wqe*)
@@ -1360,7 +1360,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,


modify_qp_exit2:
modify_qp_exit2:
	if (squeue_locked) { /* this means: sqe -> rts */
	if (squeue_locked) { /* this means: sqe -> rts */
		spin_unlock_irqrestore(&my_qp->spinlock_s, spl_flags);
		spin_unlock_irqrestore(&my_qp->spinlock_s, flags);
		my_qp->sqerr_purgeflag = 1;
		my_qp->sqerr_purgeflag = 1;
	}
	}


+12 −12
Original line number Original line Diff line number Diff line
@@ -363,10 +363,10 @@ int ehca_post_send(struct ib_qp *qp,
	struct ehca_wqe *wqe_p;
	struct ehca_wqe *wqe_p;
	int wqe_cnt = 0;
	int wqe_cnt = 0;
	int ret = 0;
	int ret = 0;
	unsigned long spl_flags;
	unsigned long flags;


	/* LOCK the QUEUE */
	/* LOCK the QUEUE */
	spin_lock_irqsave(&my_qp->spinlock_s, spl_flags);
	spin_lock_irqsave(&my_qp->spinlock_s, flags);


	/* loop processes list of send reqs */
	/* loop processes list of send reqs */
	for (cur_send_wr = send_wr; cur_send_wr != NULL;
	for (cur_send_wr = send_wr; cur_send_wr != NULL;
@@ -408,7 +408,7 @@ int ehca_post_send(struct ib_qp *qp,


post_send_exit0:
post_send_exit0:
	/* UNLOCK the QUEUE */
	/* UNLOCK the QUEUE */
	spin_unlock_irqrestore(&my_qp->spinlock_s, spl_flags);
	spin_unlock_irqrestore(&my_qp->spinlock_s, flags);
	iosync(); /* serialize GAL register access */
	iosync(); /* serialize GAL register access */
	hipz_update_sqa(my_qp, wqe_cnt);
	hipz_update_sqa(my_qp, wqe_cnt);
	return ret;
	return ret;
@@ -423,7 +423,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
	struct ehca_wqe *wqe_p;
	struct ehca_wqe *wqe_p;
	int wqe_cnt = 0;
	int wqe_cnt = 0;
	int ret = 0;
	int ret = 0;
	unsigned long spl_flags;
	unsigned long flags;


	if (unlikely(!HAS_RQ(my_qp))) {
	if (unlikely(!HAS_RQ(my_qp))) {
		ehca_err(dev, "QP has no RQ  ehca_qp=%p qp_num=%x ext_type=%d",
		ehca_err(dev, "QP has no RQ  ehca_qp=%p qp_num=%x ext_type=%d",
@@ -432,7 +432,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
	}
	}


	/* LOCK the QUEUE */
	/* LOCK the QUEUE */
	spin_lock_irqsave(&my_qp->spinlock_r, spl_flags);
	spin_lock_irqsave(&my_qp->spinlock_r, flags);


	/* loop processes list of send reqs */
	/* loop processes list of send reqs */
	for (cur_recv_wr = recv_wr; cur_recv_wr != NULL;
	for (cur_recv_wr = recv_wr; cur_recv_wr != NULL;
@@ -473,7 +473,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
	} /* eof for cur_recv_wr */
	} /* eof for cur_recv_wr */


post_recv_exit0:
post_recv_exit0:
	spin_unlock_irqrestore(&my_qp->spinlock_r, spl_flags);
	spin_unlock_irqrestore(&my_qp->spinlock_r, flags);
	iosync(); /* serialize GAL register access */
	iosync(); /* serialize GAL register access */
	hipz_update_rqa(my_qp, wqe_cnt);
	hipz_update_rqa(my_qp, wqe_cnt);
	return ret;
	return ret;
@@ -536,7 +536,7 @@ static inline int ehca_poll_cq_one(struct ib_cq *cq, struct ib_wc *wc)
	if (unlikely(cqe->status & WC_STATUS_PURGE_BIT)) {
	if (unlikely(cqe->status & WC_STATUS_PURGE_BIT)) {
		struct ehca_qp *qp=ehca_cq_get_qp(my_cq, cqe->local_qp_number);
		struct ehca_qp *qp=ehca_cq_get_qp(my_cq, cqe->local_qp_number);
		int purgeflag;
		int purgeflag;
		unsigned long spl_flags;
		unsigned long flags;
		if (!qp) {
		if (!qp) {
			ehca_err(cq->device, "cq_num=%x qp_num=%x "
			ehca_err(cq->device, "cq_num=%x qp_num=%x "
				 "could not find qp -> ignore cqe",
				 "could not find qp -> ignore cqe",
@@ -546,9 +546,9 @@ static inline int ehca_poll_cq_one(struct ib_cq *cq, struct ib_wc *wc)
			/* ignore this purged cqe */
			/* ignore this purged cqe */
			goto poll_cq_one_read_cqe;
			goto poll_cq_one_read_cqe;
		}
		}
		spin_lock_irqsave(&qp->spinlock_s, spl_flags);
		spin_lock_irqsave(&qp->spinlock_s, flags);
		purgeflag = qp->sqerr_purgeflag;
		purgeflag = qp->sqerr_purgeflag;
		spin_unlock_irqrestore(&qp->spinlock_s, spl_flags);
		spin_unlock_irqrestore(&qp->spinlock_s, flags);


		if (purgeflag) {
		if (purgeflag) {
			ehca_dbg(cq->device, "Got CQE with purged bit qp_num=%x "
			ehca_dbg(cq->device, "Got CQE with purged bit qp_num=%x "
@@ -633,7 +633,7 @@ int ehca_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
	int nr;
	int nr;
	struct ib_wc *current_wc = wc;
	struct ib_wc *current_wc = wc;
	int ret = 0;
	int ret = 0;
	unsigned long spl_flags;
	unsigned long flags;


	if (num_entries < 1) {
	if (num_entries < 1) {
		ehca_err(cq->device, "Invalid num_entries=%d ehca_cq=%p "
		ehca_err(cq->device, "Invalid num_entries=%d ehca_cq=%p "
@@ -642,14 +642,14 @@ int ehca_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc)
		goto poll_cq_exit0;
		goto poll_cq_exit0;
	}
	}


	spin_lock_irqsave(&my_cq->spinlock, spl_flags);
	spin_lock_irqsave(&my_cq->spinlock, flags);
	for (nr = 0; nr < num_entries; nr++) {
	for (nr = 0; nr < num_entries; nr++) {
		ret = ehca_poll_cq_one(cq, current_wc);
		ret = ehca_poll_cq_one(cq, current_wc);
		if (ret)
		if (ret)
			break;
			break;
		current_wc++;
		current_wc++;
	} /* eof for nr */
	} /* eof for nr */
	spin_unlock_irqrestore(&my_cq->spinlock, spl_flags);
	spin_unlock_irqrestore(&my_cq->spinlock, flags);
	if (ret == -EAGAIN  || !ret)
	if (ret == -EAGAIN  || !ret)
		ret = nr;
		ret = nr;


Loading