diff options
| author | Mark Zhang <[email protected]> | 2019-08-07 10:18:19 +0000 |
|---|---|---|
| committer | Doug Ledford <[email protected]> | 2019-08-07 20:09:23 +0000 |
| commit | d97de8887a12c598abc4d2e4e57a54c1f030e112 (patch) | |
| tree | 72ab0466600d3e6b076b9e2366f55f903dbf8f62 | |
| parent | IB/mlx5: Fix implicit MR release flow (diff) | |
| download | kernel-d97de8887a12c598abc4d2e4e57a54c1f030e112.tar.gz kernel-d97de8887a12c598abc4d2e4e57a54c1f030e112.zip | |
RDMA/counter: Prevent QP counter binding if counters unsupported
In case of rdma_counter_init() fails, counter allocation and QP bind
should not be allowed.
Fixes: 413d3347503b ("RDMA/counter: Add set/clear per-port auto mode support")
Fixes: 1bd8e0a9d0fd ("RDMA/counter: Allow manual mode configuration support")
Signed-off-by: Mark Zhang <[email protected]>
Reviewed-by: Parav Pandit <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Doug Ledford <[email protected]>
| -rw-r--r-- | drivers/infiniband/core/counters.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c index 45d5164e9574..b79890739a2c 100644 --- a/drivers/infiniband/core/counters.c +++ b/drivers/infiniband/core/counters.c @@ -38,6 +38,9 @@ int rdma_counter_set_auto_mode(struct ib_device *dev, u8 port, int ret; port_counter = &dev->port_data[port].port_counter; + if (!port_counter->hstats) + return -EOPNOTSUPP; + mutex_lock(&port_counter->lock); if (on) { ret = __counter_set_mode(&port_counter->mode, @@ -509,6 +512,9 @@ int rdma_counter_bind_qpn_alloc(struct ib_device *dev, u8 port, if (!rdma_is_port_valid(dev, port)) return -EINVAL; + if (!dev->port_data[port].port_counter.hstats) + return -EOPNOTSUPP; + qp = rdma_counter_get_qp(dev, qp_num); if (!qp) return -ENOENT; |
