Revert "RDMA/hns: Add mapped page count checking for MTR"
This reverts commit 725d573b2c
.
This commit is contained in:
parent
f44fe6d5a6
commit
464ef7132b
2 changed files with 25 additions and 40 deletions
|
@ -981,8 +981,9 @@ static struct roce_hem_item *hem_list_alloc_item(struct hns_roce_dev *hr_dev,
|
|||
return NULL;
|
||||
|
||||
if (exist_bt) {
|
||||
hem->addr = dma_alloc_coherent(hr_dev->dev, count * BA_BYTE_LEN,
|
||||
&hem->dma_addr, GFP_KERNEL);
|
||||
hem->addr = dma_alloc_coherent(hr_dev->dev,
|
||||
count * BA_BYTE_LEN,
|
||||
&hem->dma_addr, GFP_KERNEL);
|
||||
if (!hem->addr) {
|
||||
kfree(hem);
|
||||
return NULL;
|
||||
|
@ -1241,10 +1242,6 @@ static int hem_list_alloc_root_bt(struct hns_roce_dev *hr_dev,
|
|||
if (ba_num < 1)
|
||||
return -ENOMEM;
|
||||
|
||||
if (ba_num > unit)
|
||||
return -ENOBUFS;
|
||||
|
||||
ba_num = min_t(int, ba_num, unit);
|
||||
INIT_LIST_HEAD(&temp_root);
|
||||
offset = r->offset;
|
||||
/* indicate to last region */
|
||||
|
|
|
@ -633,26 +633,30 @@ int hns_roce_dealloc_mw(struct ib_mw *ibmw)
|
|||
}
|
||||
|
||||
static int mtr_map_region(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
struct hns_roce_buf_region *region, dma_addr_t *pages,
|
||||
int max_count)
|
||||
dma_addr_t *pages, struct hns_roce_buf_region *region)
|
||||
{
|
||||
int count, npage;
|
||||
int offset, end;
|
||||
__le64 *mtts;
|
||||
int offset;
|
||||
int count;
|
||||
int npage;
|
||||
u64 addr;
|
||||
int end;
|
||||
int i;
|
||||
|
||||
/* if hopnum is 0, buffer cannot store BAs, so skip write mtt */
|
||||
if (!region->hopnum)
|
||||
return 0;
|
||||
|
||||
offset = region->offset;
|
||||
end = offset + region->count;
|
||||
npage = 0;
|
||||
while (offset < end && npage < max_count) {
|
||||
count = 0;
|
||||
while (offset < end) {
|
||||
mtts = hns_roce_hem_list_find_mtt(hr_dev, &mtr->hem_list,
|
||||
offset, &count, NULL);
|
||||
if (!mtts)
|
||||
return -ENOBUFS;
|
||||
|
||||
for (i = 0; i < count && npage < max_count; i++) {
|
||||
for (i = 0; i < count; i++) {
|
||||
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1)
|
||||
addr = to_hr_hw_page_addr(pages[npage]);
|
||||
else
|
||||
|
@ -664,7 +668,7 @@ static int mtr_map_region(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
|||
offset += count;
|
||||
}
|
||||
|
||||
return npage;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool mtr_has_mtt(struct hns_roce_buf_attr *attr)
|
||||
|
@ -831,8 +835,8 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
|||
{
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
struct hns_roce_buf_region *r;
|
||||
unsigned int i, mapped_cnt;
|
||||
int ret;
|
||||
unsigned int i;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* Only use the first page address as root ba when hopnum is 0, this
|
||||
|
@ -843,42 +847,26 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0, mapped_cnt = 0; i < mtr->hem_cfg.region_count &&
|
||||
mapped_cnt < page_cnt; i++) {
|
||||
for (i = 0; i < mtr->hem_cfg.region_count; i++) {
|
||||
r = &mtr->hem_cfg.region[i];
|
||||
/* if hopnum is 0, no need to map pages in this region */
|
||||
if (!r->hopnum) {
|
||||
mapped_cnt += r->count;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r->offset + r->count > page_cnt) {
|
||||
ret = -EINVAL;
|
||||
err = -EINVAL;
|
||||
ibdev_err(ibdev,
|
||||
"failed to check mtr%u end %u + %u, max %u.\n",
|
||||
i, r->offset, r->count, page_cnt);
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
ret = mtr_map_region(hr_dev, mtr, r, &pages[r->offset],
|
||||
page_cnt - mapped_cnt);
|
||||
if (ret < 0) {
|
||||
err = mtr_map_region(hr_dev, mtr, &pages[r->offset], r);
|
||||
if (err) {
|
||||
ibdev_err(ibdev,
|
||||
"failed to map mtr%u offset %u, ret = %d.\n",
|
||||
i, r->offset, ret);
|
||||
return ret;
|
||||
i, r->offset, err);
|
||||
return err;
|
||||
}
|
||||
mapped_cnt += ret;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (mapped_cnt < page_cnt) {
|
||||
ret = -ENOBUFS;
|
||||
ibdev_err(ibdev, "failed to map mtr pages count: %u < %u.\n",
|
||||
mapped_cnt, page_cnt);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
|
||||
|
|
Loading…
Add table
Reference in a new issue