Thread (1 message) 1 message, 1 author, 2014-07-13

Re: [PATCH 2/4] cxgb4/iw_cxgb4: use firmware ord/ird resource limits

From: Yann Droneaud <hidden>
Date: 2014-07-13 11:59:24
Also in: linux-rdma

Hi,

Le vendredi 11 juillet 2014 à 20:44 +0530, Hariprasad Shenai a écrit :
quoted hunk
diff --git a/drivers/infiniband/hw/cxgb4/qp.c
b/drivers/infiniband/hw/cxgb4/qp.c
index 6f74e0e..c911e96 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -58,6 +58,30 @@ static int max_fr_immd = T4_MAX_FR_IMMD;
 module_param(max_fr_immd, int, 0644);
 MODULE_PARM_DESC(max_fr_immd, "fastreg threshold for using DSGL
instead of immedate");
 
+static int alloc_ird(struct c4iw_dev *dev, u32 ird)
+{
+       int ret;
+
+       spin_lock_irq(&dev->lock);
+       if (ird <= dev->avail_ird) {
+               dev->avail_ird -= ird;
+               ret = 0;
+       } else {
+               ret = -ENOMEM;
+               pr_info("%s: device IRD resources exhausted\n",
+                       pci_name(dev->rdev.lldi.pdev));
+       }
+       spin_unlock_irq(&dev->lock);
+       return ret;
+}
+
I would have written this function has:

static int alloc_ird(struct c4iw_dev *dev, u32 ird)
{
	int ret = 0

	spin_lock_irq(&dev->lock);
	if (ird <= dev->avail_ird)
		dev->avail_ird -= ird;
	else
		ret = -ENOMEM;
	spin_unlock_irq(&dev->lock);

	if (ret)
		dev_warn(dev->rdev.lldi.pdev,
			 "device IRD resources exhausted\n");

	return ret;
}

Regards.

-- 
Yann Droneaud
OPTEYA


--
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help