Commit a2f40971 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Jason Gunthorpe

cxgb3: Convert cqidr to XArray

It would make sense to convert this to an allocating XArray and remove the
kfifo that is currently used to allocate the CQID, but that work is better
done by someone who has the hardware to test with.
Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
Acked-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 8c2ffd91
...@@ -105,7 +105,7 @@ static void iwch_db_drop_task(struct work_struct *work) ...@@ -105,7 +105,7 @@ static void iwch_db_drop_task(struct work_struct *work)
static void rnic_init(struct iwch_dev *rnicp) static void rnic_init(struct iwch_dev *rnicp)
{ {
pr_debug("%s iwch_dev %p\n", __func__, rnicp); pr_debug("%s iwch_dev %p\n", __func__, rnicp);
idr_init(&rnicp->cqidr); xa_init_flags(&rnicp->cqs, XA_FLAGS_LOCK_IRQ);
idr_init(&rnicp->qpidr); idr_init(&rnicp->qpidr);
idr_init(&rnicp->mmidr); idr_init(&rnicp->mmidr);
spin_lock_init(&rnicp->lock); spin_lock_init(&rnicp->lock);
...@@ -190,7 +190,7 @@ static void close_rnic_dev(struct t3cdev *tdev) ...@@ -190,7 +190,7 @@ static void close_rnic_dev(struct t3cdev *tdev)
list_del(&dev->entry); list_del(&dev->entry);
iwch_unregister_device(dev); iwch_unregister_device(dev);
cxio_rdev_close(&dev->rdev); cxio_rdev_close(&dev->rdev);
idr_destroy(&dev->cqidr); WARN_ON(!xa_empty(&dev->cqs));
idr_destroy(&dev->qpidr); idr_destroy(&dev->qpidr);
idr_destroy(&dev->mmidr); idr_destroy(&dev->mmidr);
ib_dealloc_device(&dev->ibdev); ib_dealloc_device(&dev->ibdev);
......
...@@ -106,7 +106,7 @@ struct iwch_dev { ...@@ -106,7 +106,7 @@ struct iwch_dev {
struct cxio_rdev rdev; struct cxio_rdev rdev;
u32 device_cap_flags; u32 device_cap_flags;
struct iwch_rnic_attributes attr; struct iwch_rnic_attributes attr;
struct idr cqidr; struct xarray cqs;
struct idr qpidr; struct idr qpidr;
struct idr mmidr; struct idr mmidr;
spinlock_t lock; spinlock_t lock;
...@@ -136,7 +136,7 @@ static inline int t3a_device(const struct iwch_dev *rhp) ...@@ -136,7 +136,7 @@ static inline int t3a_device(const struct iwch_dev *rhp)
static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid) static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid)
{ {
return idr_find(&rhp->cqidr, cqid); return xa_load(&rhp->cqs, cqid);
} }
static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid) static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid)
......
...@@ -95,7 +95,7 @@ static int iwch_destroy_cq(struct ib_cq *ib_cq) ...@@ -95,7 +95,7 @@ static int iwch_destroy_cq(struct ib_cq *ib_cq)
pr_debug("%s ib_cq %p\n", __func__, ib_cq); pr_debug("%s ib_cq %p\n", __func__, ib_cq);
chp = to_iwch_cq(ib_cq); chp = to_iwch_cq(ib_cq);
remove_handle(chp->rhp, &chp->rhp->cqidr, chp->cq.cqid); xa_erase_irq(&chp->rhp->cqs, chp->cq.cqid);
atomic_dec(&chp->refcnt); atomic_dec(&chp->refcnt);
wait_event(chp->wait, !atomic_read(&chp->refcnt)); wait_event(chp->wait, !atomic_read(&chp->refcnt));
...@@ -164,7 +164,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, ...@@ -164,7 +164,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev,
spin_lock_init(&chp->comp_handler_lock); spin_lock_init(&chp->comp_handler_lock);
atomic_set(&chp->refcnt, 1); atomic_set(&chp->refcnt, 1);
init_waitqueue_head(&chp->wait); init_waitqueue_head(&chp->wait);
if (insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid)) { if (xa_store_irq(&rhp->cqs, chp->cq.cqid, chp, GFP_KERNEL)) {
cxio_destroy_cq(&chp->rhp->rdev, &chp->cq); cxio_destroy_cq(&chp->rhp->rdev, &chp->cq);
kfree(chp); kfree(chp);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment