diff options
author | Wei Hu(Xavier) <xavier.huwei@huawei.com> | 2018-05-23 06:16:27 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-05-24 17:41:52 -0400 |
commit | 5b6eb54f586ba0a6385f1523bce4c96cbdb79afd (patch) | |
tree | e13b4f4ce5ff76047168fbe5df167009273975dc | |
parent | c62091bcd9843eedde93f1898ca05765a6875c18 (diff) |
RDMA/hns: Modify uar allocation algorithm to avoid bitmap exhaust
This patch modified uar allocation algorithm in hns_roce_uar_alloc
function to avoid bitmap exhaust.
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r-- | drivers/infiniband/hw/hns/hns_roce_device.h | 1 | ||||
-rw-r--r-- | drivers/infiniband/hw/hns/hns_roce_pd.c | 10 |
2 files changed, 7 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index 53c2f1b8d068..412297d4b86c 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h | |||
@@ -214,6 +214,7 @@ enum { | |||
214 | struct hns_roce_uar { | 214 | struct hns_roce_uar { |
215 | u64 pfn; | 215 | u64 pfn; |
216 | unsigned long index; | 216 | unsigned long index; |
217 | unsigned long logic_idx; | ||
217 | }; | 218 | }; |
218 | 219 | ||
219 | struct hns_roce_ucontext { | 220 | struct hns_roce_ucontext { |
diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c index 4b41e041799c..b9f2c871ff9a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_pd.c +++ b/drivers/infiniband/hw/hns/hns_roce_pd.c | |||
@@ -107,13 +107,15 @@ int hns_roce_uar_alloc(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar) | |||
107 | int ret = 0; | 107 | int ret = 0; |
108 | 108 | ||
109 | /* Using bitmap to manager UAR index */ | 109 | /* Using bitmap to manager UAR index */ |
110 | ret = hns_roce_bitmap_alloc(&hr_dev->uar_table.bitmap, &uar->index); | 110 | ret = hns_roce_bitmap_alloc(&hr_dev->uar_table.bitmap, &uar->logic_idx); |
111 | if (ret == -1) | 111 | if (ret == -1) |
112 | return -ENOMEM; | 112 | return -ENOMEM; |
113 | 113 | ||
114 | if (uar->index > 0) | 114 | if (uar->logic_idx > 0 && hr_dev->caps.phy_num_uars > 1) |
115 | uar->index = (uar->index - 1) % | 115 | uar->index = (uar->logic_idx - 1) % |
116 | (hr_dev->caps.phy_num_uars - 1) + 1; | 116 | (hr_dev->caps.phy_num_uars - 1) + 1; |
117 | else | ||
118 | uar->index = 0; | ||
117 | 119 | ||
118 | if (!dev_is_pci(hr_dev->dev)) { | 120 | if (!dev_is_pci(hr_dev->dev)) { |
119 | res = platform_get_resource(hr_dev->pdev, IORESOURCE_MEM, 0); | 121 | res = platform_get_resource(hr_dev->pdev, IORESOURCE_MEM, 0); |
@@ -132,7 +134,7 @@ int hns_roce_uar_alloc(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar) | |||
132 | 134 | ||
133 | void hns_roce_uar_free(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar) | 135 | void hns_roce_uar_free(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar) |
134 | { | 136 | { |
135 | hns_roce_bitmap_free(&hr_dev->uar_table.bitmap, uar->index, | 137 | hns_roce_bitmap_free(&hr_dev->uar_table.bitmap, uar->logic_idx, |
136 | BITMAP_NO_RR); | 138 | BITMAP_NO_RR); |
137 | } | 139 | } |
138 | 140 | ||