Commit 7a268a93 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Jason Gunthorpe

cxgb4: Convert mmidr to XArray

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 2f431291
...@@ -374,9 +374,8 @@ static const struct file_operations qp_debugfs_fops = { ...@@ -374,9 +374,8 @@ static const struct file_operations qp_debugfs_fops = {
.llseek = default_llseek, .llseek = default_llseek,
}; };
static int dump_stag(int id, void *p, void *data) static int dump_stag(unsigned long id, struct c4iw_debugfs_data *stagd)
{ {
struct c4iw_debugfs_data *stagd = data;
int space; int space;
int cc; int cc;
struct fw_ri_tpte tpte; struct fw_ri_tpte tpte;
...@@ -425,6 +424,8 @@ static int stag_release(struct inode *inode, struct file *file) ...@@ -425,6 +424,8 @@ static int stag_release(struct inode *inode, struct file *file)
static int stag_open(struct inode *inode, struct file *file) static int stag_open(struct inode *inode, struct file *file)
{ {
struct c4iw_debugfs_data *stagd; struct c4iw_debugfs_data *stagd;
void *p;
unsigned long index;
int ret = 0; int ret = 0;
int count = 1; int count = 1;
...@@ -436,9 +437,8 @@ static int stag_open(struct inode *inode, struct file *file) ...@@ -436,9 +437,8 @@ static int stag_open(struct inode *inode, struct file *file)
stagd->devp = inode->i_private; stagd->devp = inode->i_private;
stagd->pos = 0; stagd->pos = 0;
spin_lock_irq(&stagd->devp->lock); xa_for_each(&stagd->devp->mrs, index, p)
idr_for_each(&stagd->devp->mmidr, count_idrs, &count); count++;
spin_unlock_irq(&stagd->devp->lock);
stagd->bufsize = count * 256; stagd->bufsize = count * 256;
stagd->buf = vmalloc(stagd->bufsize); stagd->buf = vmalloc(stagd->bufsize);
...@@ -447,9 +447,10 @@ static int stag_open(struct inode *inode, struct file *file) ...@@ -447,9 +447,10 @@ static int stag_open(struct inode *inode, struct file *file)
goto err1; goto err1;
} }
spin_lock_irq(&stagd->devp->lock); xa_lock_irq(&stagd->devp->mrs);
idr_for_each(&stagd->devp->mmidr, dump_stag, stagd); xa_for_each(&stagd->devp->mrs, index, p)
spin_unlock_irq(&stagd->devp->lock); dump_stag(index, stagd);
xa_unlock_irq(&stagd->devp->mrs);
stagd->buf[stagd->pos++] = 0; stagd->buf[stagd->pos++] = 0;
file->private_data = stagd; file->private_data = stagd;
...@@ -934,8 +935,7 @@ void c4iw_dealloc(struct uld_ctx *ctx) ...@@ -934,8 +935,7 @@ void c4iw_dealloc(struct uld_ctx *ctx)
c4iw_rdev_close(&ctx->dev->rdev); c4iw_rdev_close(&ctx->dev->rdev);
WARN_ON(!xa_empty(&ctx->dev->cqs)); WARN_ON(!xa_empty(&ctx->dev->cqs));
WARN_ON(!xa_empty(&ctx->dev->qps)); WARN_ON(!xa_empty(&ctx->dev->qps));
WARN_ON_ONCE(!idr_is_empty(&ctx->dev->mmidr)); WARN_ON(!xa_empty(&ctx->dev->mrs));
idr_destroy(&ctx->dev->mmidr);
wait_event(ctx->dev->wait, idr_is_empty(&ctx->dev->hwtid_idr)); wait_event(ctx->dev->wait, idr_is_empty(&ctx->dev->hwtid_idr));
idr_destroy(&ctx->dev->hwtid_idr); idr_destroy(&ctx->dev->hwtid_idr);
idr_destroy(&ctx->dev->stid_idr); idr_destroy(&ctx->dev->stid_idr);
...@@ -1045,7 +1045,7 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop) ...@@ -1045,7 +1045,7 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
xa_init_flags(&devp->cqs, XA_FLAGS_LOCK_IRQ); xa_init_flags(&devp->cqs, XA_FLAGS_LOCK_IRQ);
xa_init_flags(&devp->qps, XA_FLAGS_LOCK_IRQ); xa_init_flags(&devp->qps, XA_FLAGS_LOCK_IRQ);
idr_init(&devp->mmidr); xa_init_flags(&devp->mrs, XA_FLAGS_LOCK_IRQ);
idr_init(&devp->hwtid_idr); idr_init(&devp->hwtid_idr);
idr_init(&devp->stid_idr); idr_init(&devp->stid_idr);
idr_init(&devp->atid_idr); idr_init(&devp->atid_idr);
......
...@@ -317,7 +317,7 @@ struct c4iw_dev { ...@@ -317,7 +317,7 @@ struct c4iw_dev {
u32 device_cap_flags; u32 device_cap_flags;
struct xarray cqs; struct xarray cqs;
struct xarray qps; struct xarray qps;
struct idr mmidr; struct xarray mrs;
spinlock_t lock; spinlock_t lock;
struct mutex db_mutex; struct mutex db_mutex;
struct dentry *debugfs_root; struct dentry *debugfs_root;
...@@ -357,10 +357,6 @@ static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qpid) ...@@ -357,10 +357,6 @@ static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qpid)
return xa_load(&rhp->qps, qpid); return xa_load(&rhp->qps, qpid);
} }
static inline struct c4iw_mr *get_mhp(struct c4iw_dev *rhp, u32 mmid)
{
return idr_find(&rhp->mmidr, mmid);
}
static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr, static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr,
void *handle, u32 id, int lock) void *handle, u32 id, int lock)
......
...@@ -395,7 +395,7 @@ static int finish_mem_reg(struct c4iw_mr *mhp, u32 stag) ...@@ -395,7 +395,7 @@ static int finish_mem_reg(struct c4iw_mr *mhp, u32 stag)
mhp->ibmr.iova = mhp->attr.va_fbo; mhp->ibmr.iova = mhp->attr.va_fbo;
mhp->ibmr.page_size = 1U << (mhp->attr.page_size + 12); mhp->ibmr.page_size = 1U << (mhp->attr.page_size + 12);
pr_debug("mmid 0x%x mhp %p\n", mmid, mhp); pr_debug("mmid 0x%x mhp %p\n", mmid, mhp);
return insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid); return xa_insert_irq(&mhp->rhp->mrs, mmid, mhp, GFP_KERNEL);
} }
static int register_mem(struct c4iw_dev *rhp, struct c4iw_pd *php, static int register_mem(struct c4iw_dev *rhp, struct c4iw_pd *php,
...@@ -645,7 +645,7 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type, ...@@ -645,7 +645,7 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
mhp->attr.stag = stag; mhp->attr.stag = stag;
mmid = (stag) >> 8; mmid = (stag) >> 8;
mhp->ibmw.rkey = stag; mhp->ibmw.rkey = stag;
if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) { if (xa_insert_irq(&rhp->mrs, mmid, mhp, GFP_KERNEL)) {
ret = -ENOMEM; ret = -ENOMEM;
goto dealloc_win; goto dealloc_win;
} }
...@@ -673,7 +673,7 @@ int c4iw_dealloc_mw(struct ib_mw *mw) ...@@ -673,7 +673,7 @@ int c4iw_dealloc_mw(struct ib_mw *mw)
mhp = to_c4iw_mw(mw); mhp = to_c4iw_mw(mw);
rhp = mhp->rhp; rhp = mhp->rhp;
mmid = (mw->rkey) >> 8; mmid = (mw->rkey) >> 8;
remove_handle(rhp, &rhp->mmidr, mmid); xa_erase_irq(&rhp->mrs, mmid);
deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb, deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb,
mhp->wr_waitp); mhp->wr_waitp);
kfree_skb(mhp->dereg_skb); kfree_skb(mhp->dereg_skb);
...@@ -740,7 +740,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, ...@@ -740,7 +740,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd,
mhp->attr.state = 0; mhp->attr.state = 0;
mmid = (stag) >> 8; mmid = (stag) >> 8;
mhp->ibmr.rkey = mhp->ibmr.lkey = stag; mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) { if (xa_insert_irq(&rhp->mrs, mmid, mhp, GFP_KERNEL)) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_dereg; goto err_dereg;
} }
...@@ -797,7 +797,7 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr) ...@@ -797,7 +797,7 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr)
mhp = to_c4iw_mr(ib_mr); mhp = to_c4iw_mr(ib_mr);
rhp = mhp->rhp; rhp = mhp->rhp;
mmid = mhp->attr.stag >> 8; mmid = mhp->attr.stag >> 8;
remove_handle(rhp, &rhp->mmidr, mmid); xa_erase_irq(&rhp->mrs, mmid);
if (mhp->mpl) if (mhp->mpl)
dma_free_coherent(&mhp->rhp->rdev.lldi.pdev->dev, dma_free_coherent(&mhp->rhp->rdev.lldi.pdev->dev,
mhp->max_mpl_len, mhp->mpl, mhp->mpl_addr); mhp->max_mpl_len, mhp->mpl, mhp->mpl_addr);
...@@ -821,9 +821,9 @@ void c4iw_invalidate_mr(struct c4iw_dev *rhp, u32 rkey) ...@@ -821,9 +821,9 @@ void c4iw_invalidate_mr(struct c4iw_dev *rhp, u32 rkey)
struct c4iw_mr *mhp; struct c4iw_mr *mhp;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&rhp->lock, flags); xa_lock_irqsave(&rhp->mrs, flags);
mhp = get_mhp(rhp, rkey >> 8); mhp = xa_load(&rhp->mrs, rkey >> 8);
if (mhp) if (mhp)
mhp->attr.state = 0; mhp->attr.state = 0;
spin_unlock_irqrestore(&rhp->lock, flags); xa_unlock_irqrestore(&rhp->mrs, flags);
} }
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