mirror of
https://github.com/torvalds/linux.git
synced 2024-12-31 23:31:29 +00:00
net/rds: Avoid calling ib_query_device
Instead, use the cached copy of the attributes present on the device. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
4a061b287b
commit
0353261c12
34
net/rds/ib.c
34
net/rds/ib.c
@ -122,44 +122,34 @@ void rds_ib_dev_put(struct rds_ib_device *rds_ibdev)
|
|||||||
static void rds_ib_add_one(struct ib_device *device)
|
static void rds_ib_add_one(struct ib_device *device)
|
||||||
{
|
{
|
||||||
struct rds_ib_device *rds_ibdev;
|
struct rds_ib_device *rds_ibdev;
|
||||||
struct ib_device_attr *dev_attr;
|
|
||||||
|
|
||||||
/* Only handle IB (no iWARP) devices */
|
/* Only handle IB (no iWARP) devices */
|
||||||
if (device->node_type != RDMA_NODE_IB_CA)
|
if (device->node_type != RDMA_NODE_IB_CA)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL);
|
|
||||||
if (!dev_attr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ib_query_device(device, dev_attr)) {
|
|
||||||
rdsdebug("Query device failed for %s\n", device->name);
|
|
||||||
goto free_attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
rds_ibdev = kzalloc_node(sizeof(struct rds_ib_device), GFP_KERNEL,
|
rds_ibdev = kzalloc_node(sizeof(struct rds_ib_device), GFP_KERNEL,
|
||||||
ibdev_to_node(device));
|
ibdev_to_node(device));
|
||||||
if (!rds_ibdev)
|
if (!rds_ibdev)
|
||||||
goto free_attr;
|
return;
|
||||||
|
|
||||||
spin_lock_init(&rds_ibdev->spinlock);
|
spin_lock_init(&rds_ibdev->spinlock);
|
||||||
atomic_set(&rds_ibdev->refcount, 1);
|
atomic_set(&rds_ibdev->refcount, 1);
|
||||||
INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free);
|
INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free);
|
||||||
|
|
||||||
rds_ibdev->max_wrs = dev_attr->max_qp_wr;
|
rds_ibdev->max_wrs = device->attrs.max_qp_wr;
|
||||||
rds_ibdev->max_sge = min(dev_attr->max_sge, RDS_IB_MAX_SGE);
|
rds_ibdev->max_sge = min(device->attrs.max_sge, RDS_IB_MAX_SGE);
|
||||||
|
|
||||||
rds_ibdev->fmr_max_remaps = dev_attr->max_map_per_fmr?: 32;
|
rds_ibdev->fmr_max_remaps = device->attrs.max_map_per_fmr?: 32;
|
||||||
rds_ibdev->max_1m_fmrs = dev_attr->max_mr ?
|
rds_ibdev->max_1m_fmrs = device->attrs.max_mr ?
|
||||||
min_t(unsigned int, (dev_attr->max_mr / 2),
|
min_t(unsigned int, (device->attrs.max_mr / 2),
|
||||||
rds_ib_fmr_1m_pool_size) : rds_ib_fmr_1m_pool_size;
|
rds_ib_fmr_1m_pool_size) : rds_ib_fmr_1m_pool_size;
|
||||||
|
|
||||||
rds_ibdev->max_8k_fmrs = dev_attr->max_mr ?
|
rds_ibdev->max_8k_fmrs = device->attrs.max_mr ?
|
||||||
min_t(unsigned int, ((dev_attr->max_mr / 2) * RDS_MR_8K_SCALE),
|
min_t(unsigned int, ((device->attrs.max_mr / 2) * RDS_MR_8K_SCALE),
|
||||||
rds_ib_fmr_8k_pool_size) : rds_ib_fmr_8k_pool_size;
|
rds_ib_fmr_8k_pool_size) : rds_ib_fmr_8k_pool_size;
|
||||||
|
|
||||||
rds_ibdev->max_initiator_depth = dev_attr->max_qp_init_rd_atom;
|
rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
|
||||||
rds_ibdev->max_responder_resources = dev_attr->max_qp_rd_atom;
|
rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
|
||||||
|
|
||||||
rds_ibdev->dev = device;
|
rds_ibdev->dev = device;
|
||||||
rds_ibdev->pd = ib_alloc_pd(device);
|
rds_ibdev->pd = ib_alloc_pd(device);
|
||||||
@ -183,7 +173,7 @@ static void rds_ib_add_one(struct ib_device *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rdsdebug("RDS/IB: max_mr = %d, max_wrs = %d, max_sge = %d, fmr_max_remaps = %d, max_1m_fmrs = %d, max_8k_fmrs = %d\n",
|
rdsdebug("RDS/IB: max_mr = %d, max_wrs = %d, max_sge = %d, fmr_max_remaps = %d, max_1m_fmrs = %d, max_8k_fmrs = %d\n",
|
||||||
dev_attr->max_fmr, rds_ibdev->max_wrs, rds_ibdev->max_sge,
|
device->attrs.max_fmr, rds_ibdev->max_wrs, rds_ibdev->max_sge,
|
||||||
rds_ibdev->fmr_max_remaps, rds_ibdev->max_1m_fmrs,
|
rds_ibdev->fmr_max_remaps, rds_ibdev->max_1m_fmrs,
|
||||||
rds_ibdev->max_8k_fmrs);
|
rds_ibdev->max_8k_fmrs);
|
||||||
|
|
||||||
@ -202,8 +192,6 @@ static void rds_ib_add_one(struct ib_device *device)
|
|||||||
|
|
||||||
put_dev:
|
put_dev:
|
||||||
rds_ib_dev_put(rds_ibdev);
|
rds_ib_dev_put(rds_ibdev);
|
||||||
free_attr:
|
|
||||||
kfree(dev_attr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
23
net/rds/iw.c
23
net/rds/iw.c
@ -60,30 +60,20 @@ LIST_HEAD(iw_nodev_conns);
|
|||||||
static void rds_iw_add_one(struct ib_device *device)
|
static void rds_iw_add_one(struct ib_device *device)
|
||||||
{
|
{
|
||||||
struct rds_iw_device *rds_iwdev;
|
struct rds_iw_device *rds_iwdev;
|
||||||
struct ib_device_attr *dev_attr;
|
|
||||||
|
|
||||||
/* Only handle iwarp devices */
|
/* Only handle iwarp devices */
|
||||||
if (device->node_type != RDMA_NODE_RNIC)
|
if (device->node_type != RDMA_NODE_RNIC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL);
|
|
||||||
if (!dev_attr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ib_query_device(device, dev_attr)) {
|
|
||||||
rdsdebug("Query device failed for %s\n", device->name);
|
|
||||||
goto free_attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
rds_iwdev = kmalloc(sizeof *rds_iwdev, GFP_KERNEL);
|
rds_iwdev = kmalloc(sizeof *rds_iwdev, GFP_KERNEL);
|
||||||
if (!rds_iwdev)
|
if (!rds_iwdev)
|
||||||
goto free_attr;
|
return;
|
||||||
|
|
||||||
spin_lock_init(&rds_iwdev->spinlock);
|
spin_lock_init(&rds_iwdev->spinlock);
|
||||||
|
|
||||||
rds_iwdev->dma_local_lkey = !!(dev_attr->device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY);
|
rds_iwdev->dma_local_lkey = !!(device->attrs.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY);
|
||||||
rds_iwdev->max_wrs = dev_attr->max_qp_wr;
|
rds_iwdev->max_wrs = device->attrs.max_qp_wr;
|
||||||
rds_iwdev->max_sge = min(dev_attr->max_sge, RDS_IW_MAX_SGE);
|
rds_iwdev->max_sge = min(device->attrs.max_sge, RDS_IW_MAX_SGE);
|
||||||
|
|
||||||
rds_iwdev->dev = device;
|
rds_iwdev->dev = device;
|
||||||
rds_iwdev->pd = ib_alloc_pd(device);
|
rds_iwdev->pd = ib_alloc_pd(device);
|
||||||
@ -111,8 +101,7 @@ static void rds_iw_add_one(struct ib_device *device)
|
|||||||
list_add_tail(&rds_iwdev->list, &rds_iw_devices);
|
list_add_tail(&rds_iwdev->list, &rds_iw_devices);
|
||||||
|
|
||||||
ib_set_client_data(device, &rds_iw_client, rds_iwdev);
|
ib_set_client_data(device, &rds_iw_client, rds_iwdev);
|
||||||
|
return;
|
||||||
goto free_attr;
|
|
||||||
|
|
||||||
err_mr:
|
err_mr:
|
||||||
if (rds_iwdev->mr)
|
if (rds_iwdev->mr)
|
||||||
@ -121,8 +110,6 @@ err_pd:
|
|||||||
ib_dealloc_pd(rds_iwdev->pd);
|
ib_dealloc_pd(rds_iwdev->pd);
|
||||||
free_dev:
|
free_dev:
|
||||||
kfree(rds_iwdev);
|
kfree(rds_iwdev);
|
||||||
free_attr:
|
|
||||||
kfree(dev_attr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rds_iw_remove_one(struct ib_device *device, void *client_data)
|
static void rds_iw_remove_one(struct ib_device *device, void *client_data)
|
||||||
|
Loading…
Reference in New Issue
Block a user