qib: Convert qib_unit_table to XArray
Also remove qib_devs_list. Signed-off-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
03b92789e5
commit
059d48fbf6
@ -52,6 +52,7 @@
|
|||||||
#include <linux/kref.h>
|
#include <linux/kref.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/kthread.h>
|
#include <linux/kthread.h>
|
||||||
|
#include <linux/xarray.h>
|
||||||
#include <rdma/ib_hdrs.h>
|
#include <rdma/ib_hdrs.h>
|
||||||
#include <rdma/rdma_vt.h>
|
#include <rdma/rdma_vt.h>
|
||||||
|
|
||||||
@ -1105,8 +1106,7 @@ struct qib_filedata {
|
|||||||
int rec_cpu_num; /* for cpu affinity; -1 if none */
|
int rec_cpu_num; /* for cpu affinity; -1 if none */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct list_head qib_dev_list;
|
extern struct xarray qib_dev_table;
|
||||||
extern spinlock_t qib_devs_lock;
|
|
||||||
extern struct qib_devdata *qib_lookup(int unit);
|
extern struct qib_devdata *qib_lookup(int unit);
|
||||||
extern u32 qib_cpulist_count;
|
extern u32 qib_cpulist_count;
|
||||||
extern unsigned long *qib_cpulist;
|
extern unsigned long *qib_cpulist;
|
||||||
|
@ -49,8 +49,6 @@
|
|||||||
*/
|
*/
|
||||||
const char ib_qib_version[] = QIB_DRIVER_VERSION "\n";
|
const char ib_qib_version[] = QIB_DRIVER_VERSION "\n";
|
||||||
|
|
||||||
DEFINE_SPINLOCK(qib_devs_lock);
|
|
||||||
LIST_HEAD(qib_dev_list);
|
|
||||||
DEFINE_MUTEX(qib_mutex); /* general driver use */
|
DEFINE_MUTEX(qib_mutex); /* general driver use */
|
||||||
|
|
||||||
unsigned qib_ibmtu;
|
unsigned qib_ibmtu;
|
||||||
@ -96,11 +94,11 @@ int qib_count_active_units(void)
|
|||||||
{
|
{
|
||||||
struct qib_devdata *dd;
|
struct qib_devdata *dd;
|
||||||
struct qib_pportdata *ppd;
|
struct qib_pportdata *ppd;
|
||||||
unsigned long flags;
|
unsigned long index, flags;
|
||||||
int pidx, nunits_active = 0;
|
int pidx, nunits_active = 0;
|
||||||
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
xa_lock_irqsave(&qib_dev_table, flags);
|
||||||
list_for_each_entry(dd, &qib_dev_list, list) {
|
xa_for_each(&qib_dev_table, index, dd) {
|
||||||
if (!(dd->flags & QIB_PRESENT) || !dd->kregbase)
|
if (!(dd->flags & QIB_PRESENT) || !dd->kregbase)
|
||||||
continue;
|
continue;
|
||||||
for (pidx = 0; pidx < dd->num_pports; ++pidx) {
|
for (pidx = 0; pidx < dd->num_pports; ++pidx) {
|
||||||
@ -112,7 +110,7 @@ int qib_count_active_units(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
xa_unlock_irqrestore(&qib_dev_table, flags);
|
||||||
return nunits_active;
|
return nunits_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,13 +123,12 @@ int qib_count_units(int *npresentp, int *nupp)
|
|||||||
{
|
{
|
||||||
int nunits = 0, npresent = 0, nup = 0;
|
int nunits = 0, npresent = 0, nup = 0;
|
||||||
struct qib_devdata *dd;
|
struct qib_devdata *dd;
|
||||||
unsigned long flags;
|
unsigned long index, flags;
|
||||||
int pidx;
|
int pidx;
|
||||||
struct qib_pportdata *ppd;
|
struct qib_pportdata *ppd;
|
||||||
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
xa_lock_irqsave(&qib_dev_table, flags);
|
||||||
|
xa_for_each(&qib_dev_table, index, dd) {
|
||||||
list_for_each_entry(dd, &qib_dev_list, list) {
|
|
||||||
nunits++;
|
nunits++;
|
||||||
if ((dd->flags & QIB_PRESENT) && dd->kregbase)
|
if ((dd->flags & QIB_PRESENT) && dd->kregbase)
|
||||||
npresent++;
|
npresent++;
|
||||||
@ -142,8 +139,7 @@ int qib_count_units(int *npresentp, int *nupp)
|
|||||||
nup++;
|
nup++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
xa_unlock_irqrestore(&qib_dev_table, flags);
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
|
||||||
|
|
||||||
if (npresentp)
|
if (npresentp)
|
||||||
*npresentp = npresent;
|
*npresentp = npresent;
|
||||||
|
@ -508,8 +508,8 @@ bail:
|
|||||||
*/
|
*/
|
||||||
static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
|
static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
{
|
{
|
||||||
struct qib_devdata *dd, *tmp;
|
struct qib_devdata *dd;
|
||||||
unsigned long flags;
|
unsigned long index;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
static const struct tree_descr files[] = {
|
static const struct tree_descr files[] = {
|
||||||
@ -524,18 +524,12 @@ static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
xa_for_each(&qib_dev_table, index, dd) {
|
||||||
|
|
||||||
list_for_each_entry_safe(dd, tmp, &qib_dev_list, list) {
|
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
|
||||||
ret = add_cntr_files(sb, dd);
|
ret = add_cntr_files(sb, dd);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto bail;
|
goto bail;
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -6140,7 +6140,7 @@ static void set_no_qsfp_atten(struct qib_devdata *dd, int change)
|
|||||||
static int setup_txselect(const char *str, const struct kernel_param *kp)
|
static int setup_txselect(const char *str, const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
struct qib_devdata *dd;
|
struct qib_devdata *dd;
|
||||||
unsigned long val;
|
unsigned long index, val;
|
||||||
char *n;
|
char *n;
|
||||||
|
|
||||||
if (strlen(str) >= ARRAY_SIZE(txselect_list)) {
|
if (strlen(str) >= ARRAY_SIZE(txselect_list)) {
|
||||||
@ -6156,7 +6156,7 @@ static int setup_txselect(const char *str, const struct kernel_param *kp)
|
|||||||
}
|
}
|
||||||
strncpy(txselect_list, str, ARRAY_SIZE(txselect_list) - 1);
|
strncpy(txselect_list, str, ARRAY_SIZE(txselect_list) - 1);
|
||||||
|
|
||||||
list_for_each_entry(dd, &qib_dev_list, list)
|
xa_for_each(&qib_dev_table, index, dd)
|
||||||
if (dd->deviceid == PCI_DEVICE_ID_QLOGIC_IB_7322)
|
if (dd->deviceid == PCI_DEVICE_ID_QLOGIC_IB_7322)
|
||||||
set_no_qsfp_atten(dd, 1);
|
set_no_qsfp_atten(dd, 1);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/idr.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
#ifdef CONFIG_INFINIBAND_QIB_DCA
|
#ifdef CONFIG_INFINIBAND_QIB_DCA
|
||||||
@ -95,7 +94,7 @@ MODULE_PARM_DESC(cc_table_size, "Congestion control table entries 0 (CCA disable
|
|||||||
|
|
||||||
static void verify_interrupt(struct timer_list *);
|
static void verify_interrupt(struct timer_list *);
|
||||||
|
|
||||||
static struct idr qib_unit_table;
|
DEFINE_XARRAY_FLAGS(qib_dev_table, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ);
|
||||||
u32 qib_cpulist_count;
|
u32 qib_cpulist_count;
|
||||||
unsigned long *qib_cpulist;
|
unsigned long *qib_cpulist;
|
||||||
|
|
||||||
@ -785,21 +784,9 @@ void __attribute__((weak)) qib_disable_wc(struct qib_devdata *dd)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct qib_devdata *__qib_lookup(int unit)
|
|
||||||
{
|
|
||||||
return idr_find(&qib_unit_table, unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct qib_devdata *qib_lookup(int unit)
|
struct qib_devdata *qib_lookup(int unit)
|
||||||
{
|
{
|
||||||
struct qib_devdata *dd;
|
return xa_load(&qib_dev_table, unit);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
|
||||||
dd = __qib_lookup(unit);
|
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
|
||||||
|
|
||||||
return dd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1046,10 +1033,9 @@ void qib_free_devdata(struct qib_devdata *dd)
|
|||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
xa_lock_irqsave(&qib_dev_table, flags);
|
||||||
idr_remove(&qib_unit_table, dd->unit);
|
__xa_erase(&qib_dev_table, dd->unit);
|
||||||
list_del(&dd->list);
|
xa_unlock_irqrestore(&qib_dev_table, flags);
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
qib_dbg_ibdev_exit(&dd->verbs_dev);
|
qib_dbg_ibdev_exit(&dd->verbs_dev);
|
||||||
@ -1070,15 +1056,15 @@ u64 qib_int_counter(struct qib_devdata *dd)
|
|||||||
|
|
||||||
u64 qib_sps_ints(void)
|
u64 qib_sps_ints(void)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long index, flags;
|
||||||
struct qib_devdata *dd;
|
struct qib_devdata *dd;
|
||||||
u64 sps_ints = 0;
|
u64 sps_ints = 0;
|
||||||
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
xa_lock_irqsave(&qib_dev_table, flags);
|
||||||
list_for_each_entry(dd, &qib_dev_list, list) {
|
xa_for_each(&qib_dev_table, index, dd) {
|
||||||
sps_ints += qib_int_counter(dd);
|
sps_ints += qib_int_counter(dd);
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
xa_unlock_irqrestore(&qib_dev_table, flags);
|
||||||
return sps_ints;
|
return sps_ints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1087,12 +1073,9 @@ u64 qib_sps_ints(void)
|
|||||||
* allocator, because the verbs cleanup process both does cleanup and
|
* allocator, because the verbs cleanup process both does cleanup and
|
||||||
* free of the data structure.
|
* free of the data structure.
|
||||||
* "extra" is for chip-specific data.
|
* "extra" is for chip-specific data.
|
||||||
*
|
|
||||||
* Use the idr mechanism to get a unit number for this unit.
|
|
||||||
*/
|
*/
|
||||||
struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
|
struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
|
||||||
struct qib_devdata *dd;
|
struct qib_devdata *dd;
|
||||||
int ret, nports;
|
int ret, nports;
|
||||||
|
|
||||||
@ -1103,20 +1086,8 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
|
|||||||
if (!dd)
|
if (!dd)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
INIT_LIST_HEAD(&dd->list);
|
ret = xa_alloc_irq(&qib_dev_table, &dd->unit, dd, xa_limit_32b,
|
||||||
|
GFP_KERNEL);
|
||||||
idr_preload(GFP_KERNEL);
|
|
||||||
spin_lock_irqsave(&qib_devs_lock, flags);
|
|
||||||
|
|
||||||
ret = idr_alloc(&qib_unit_table, dd, 0, 0, GFP_NOWAIT);
|
|
||||||
if (ret >= 0) {
|
|
||||||
dd->unit = ret;
|
|
||||||
list_add(&dd->list, &qib_dev_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&qib_devs_lock, flags);
|
|
||||||
idr_preload_end();
|
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
qib_early_err(&pdev->dev,
|
qib_early_err(&pdev->dev,
|
||||||
"Could not allocate unit ID: error %d\n", -ret);
|
"Could not allocate unit ID: error %d\n", -ret);
|
||||||
@ -1255,8 +1226,6 @@ static int __init qib_ib_init(void)
|
|||||||
* These must be called before the driver is registered with
|
* These must be called before the driver is registered with
|
||||||
* the PCI subsystem.
|
* the PCI subsystem.
|
||||||
*/
|
*/
|
||||||
idr_init(&qib_unit_table);
|
|
||||||
|
|
||||||
#ifdef CONFIG_INFINIBAND_QIB_DCA
|
#ifdef CONFIG_INFINIBAND_QIB_DCA
|
||||||
dca_register_notify(&dca_notifier);
|
dca_register_notify(&dca_notifier);
|
||||||
#endif
|
#endif
|
||||||
@ -1281,7 +1250,6 @@ bail_dev:
|
|||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
qib_dbg_exit();
|
qib_dbg_exit();
|
||||||
#endif
|
#endif
|
||||||
idr_destroy(&qib_unit_table);
|
|
||||||
qib_dev_cleanup();
|
qib_dev_cleanup();
|
||||||
bail:
|
bail:
|
||||||
return ret;
|
return ret;
|
||||||
@ -1313,7 +1281,7 @@ static void __exit qib_ib_cleanup(void)
|
|||||||
qib_cpulist_count = 0;
|
qib_cpulist_count = 0;
|
||||||
kfree(qib_cpulist);
|
kfree(qib_cpulist);
|
||||||
|
|
||||||
idr_destroy(&qib_unit_table);
|
WARN_ON(!xa_empty(&qib_dev_table));
|
||||||
qib_dev_cleanup();
|
qib_dev_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user