diff options
Diffstat (limited to 'drivers/infiniband/core/counters.c')
-rw-r--r-- | drivers/infiniband/core/counters.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c index 01faef7bc061..45d5164e9574 100644 --- a/drivers/infiniband/core/counters.c +++ b/drivers/infiniband/core/counters.c | |||
@@ -393,6 +393,9 @@ u64 rdma_counter_get_hwstat_value(struct ib_device *dev, u8 port, u32 index) | |||
393 | u64 sum; | 393 | u64 sum; |
394 | 394 | ||
395 | port_counter = &dev->port_data[port].port_counter; | 395 | port_counter = &dev->port_data[port].port_counter; |
396 | if (!port_counter->hstats) | ||
397 | return 0; | ||
398 | |||
396 | sum = get_running_counters_hwstat_sum(dev, port, index); | 399 | sum = get_running_counters_hwstat_sum(dev, port, index); |
397 | sum += port_counter->hstats->value[index]; | 400 | sum += port_counter->hstats->value[index]; |
398 | 401 | ||
@@ -594,7 +597,7 @@ void rdma_counter_init(struct ib_device *dev) | |||
594 | struct rdma_port_counter *port_counter; | 597 | struct rdma_port_counter *port_counter; |
595 | u32 port; | 598 | u32 port; |
596 | 599 | ||
597 | if (!dev->ops.alloc_hw_stats || !dev->port_data) | 600 | if (!dev->port_data) |
598 | return; | 601 | return; |
599 | 602 | ||
600 | rdma_for_each_port(dev, port) { | 603 | rdma_for_each_port(dev, port) { |
@@ -602,6 +605,9 @@ void rdma_counter_init(struct ib_device *dev) | |||
602 | port_counter->mode.mode = RDMA_COUNTER_MODE_NONE; | 605 | port_counter->mode.mode = RDMA_COUNTER_MODE_NONE; |
603 | mutex_init(&port_counter->lock); | 606 | mutex_init(&port_counter->lock); |
604 | 607 | ||
608 | if (!dev->ops.alloc_hw_stats) | ||
609 | continue; | ||
610 | |||
605 | port_counter->hstats = dev->ops.alloc_hw_stats(dev, port); | 611 | port_counter->hstats = dev->ops.alloc_hw_stats(dev, port); |
606 | if (!port_counter->hstats) | 612 | if (!port_counter->hstats) |
607 | goto fail; | 613 | goto fail; |
@@ -624,9 +630,6 @@ void rdma_counter_release(struct ib_device *dev) | |||
624 | struct rdma_port_counter *port_counter; | 630 | struct rdma_port_counter *port_counter; |
625 | u32 port; | 631 | u32 port; |
626 | 632 | ||
627 | if (!dev->ops.alloc_hw_stats) | ||
628 | return; | ||
629 | |||
630 | rdma_for_each_port(dev, port) { | 633 | rdma_for_each_port(dev, port) { |
631 | port_counter = &dev->port_data[port].port_counter; | 634 | port_counter = &dev->port_data[port].port_counter; |
632 | kfree(port_counter->hstats); | 635 | kfree(port_counter->hstats); |