Skip to content

Commit

Permalink
IB/core: Refactor idr to be per uverbs_file
Browse files Browse the repository at this point in the history
The current code creates an idr per type. Since types are currently
common for all drivers and known in advance, this was good enough.
However, the proposed ioctl based infrastructure allows each driver
to declare only some of the common types and declare its own specific
types.

Thus, we decided to implement idr to be per uverbs_file.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Matan Barak authored and Doug Ledford committed Apr 5, 2017
1 parent 97da385 commit 771addf
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 127 deletions.
19 changes: 5 additions & 14 deletions drivers/infiniband/core/uverbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ struct ib_uverbs_file {
struct ib_uverbs_event_file *async_file;
struct list_head list;
int is_closed;

struct idr idr;
/* spinlock protects write access to idr */
spinlock_t idr_lock;
};

struct ib_uverbs_event {
Expand Down Expand Up @@ -176,20 +180,7 @@ struct ib_ucq_object {
u32 async_events_reported;
};

extern spinlock_t ib_uverbs_idr_lock;
extern struct idr ib_uverbs_pd_idr;
extern struct idr ib_uverbs_mr_idr;
extern struct idr ib_uverbs_mw_idr;
extern struct idr ib_uverbs_ah_idr;
extern struct idr ib_uverbs_cq_idr;
extern struct idr ib_uverbs_qp_idr;
extern struct idr ib_uverbs_srq_idr;
extern struct idr ib_uverbs_xrcd_idr;
extern struct idr ib_uverbs_rule_idr;
extern struct idr ib_uverbs_wq_idr;
extern struct idr ib_uverbs_rwq_ind_tbl_idr;

void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
void idr_remove_uobj(struct ib_uobject *uobj);

struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
struct ib_device *ib_dev,
Expand Down
Loading

0 comments on commit 771addf

Please sign in to comment.