summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
diff options
context:
space:
mode:
authorSelvin Xavier <selvin.xavier@broadcom.com>2016-02-05 20:06:37 +0530
committerDoug Ledford <dledford@redhat.com>2016-02-05 15:14:27 -0500
commitfd98d89698855f6cf5650c014e5d3fca38783c8b (patch)
tree5726300e584bfa0b6bc8b003cda389cbc7ed8165 /drivers/infiniband/hw/ocrdma/ocrdma_stats.c
parent9f780dab7fb5618ee8bacbf6f91832374231c30c (diff)
downloadlinux-fd98d89698855f6cf5650c014e5d3fca38783c8b.tar.gz
linux-fd98d89698855f6cf5650c014e5d3fca38783c8b.tar.bz2
linux-fd98d89698855f6cf5650c014e5d3fca38783c8b.zip
RDMA/ocrdma: Initialize stats resources in the driver before ib device registration.
In the latest kernel, process_mad hook of the driver can be invoked as soon as device is registered. In this hook, ocrdma driver is issuing a command to get the stats counters from the HW. This is triggering system crash since the statistics command resources are not allocated by the driver. Changing the sequence of initialization to avoid this crash. Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/ocrdma/ocrdma_stats.c')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_stats.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 86c303a620c1..fc02e86849ce 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -64,10 +64,11 @@ static int ocrdma_add_stat(char *start, char *pcur,
return cpy_len;
}
-static bool ocrdma_alloc_stats_mem(struct ocrdma_dev *dev)
+bool ocrdma_alloc_stats_resources(struct ocrdma_dev *dev)
{
struct stats_mem *mem = &dev->stats_mem;
+ mutex_init(&dev->stats_lock);
/* Alloc mbox command mem*/
mem->size = max_t(u32, sizeof(struct ocrdma_rdma_stats_req),
sizeof(struct ocrdma_rdma_stats_resp));
@@ -91,13 +92,14 @@ static bool ocrdma_alloc_stats_mem(struct ocrdma_dev *dev)
return true;
}
-static void ocrdma_release_stats_mem(struct ocrdma_dev *dev)
+void ocrdma_release_stats_resources(struct ocrdma_dev *dev)
{
struct stats_mem *mem = &dev->stats_mem;
if (mem->va)
dma_free_coherent(&dev->nic_info.pdev->dev, mem->size,
mem->va, mem->pa);
+ mem->va = NULL;
kfree(mem->debugfs_mem);
}
@@ -838,15 +840,9 @@ void ocrdma_add_port_stats(struct ocrdma_dev *dev)
&dev->reset_stats, &ocrdma_dbg_ops))
goto err;
- /* Now create dma_mem for stats mbx command */
- if (!ocrdma_alloc_stats_mem(dev))
- goto err;
-
- mutex_init(&dev->stats_lock);
return;
err:
- ocrdma_release_stats_mem(dev);
debugfs_remove_recursive(dev->dir);
dev->dir = NULL;
}
@@ -856,8 +852,6 @@ void ocrdma_rem_port_stats(struct ocrdma_dev *dev)
if (!dev->dir)
return;
debugfs_remove(dev->dir);
- mutex_destroy(&dev->stats_lock);
- ocrdma_release_stats_mem(dev);
}
void ocrdma_init_debugfs(void)