Skip to content

Commit 82d07a4

Browse files
Weihang Lijgunthorpe
authored andcommitted
RDMA/hns: Change all page_shift to unsigned
page_shift is used to calculate the page size, it's always non-negative, and should be in type of unsigned. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent e9f2cd2 commit 82d07a4

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

drivers/infiniband/hw/hns/hns_roce_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
254254

255255
int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
256256
int buf_cnt, int start, struct ib_umem *umem,
257-
int page_shift)
257+
unsigned int page_shift)
258258
{
259259
struct ib_block_iter biter;
260260
int total = 0;

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ struct hns_roce_buf_attr {
342342
int hopnum; /* multi-hop addressing hop num */
343343
} region[HNS_ROCE_MAX_BT_REGION];
344344
int region_count; /* valid region count */
345-
int page_shift; /* buffer page shift */
345+
unsigned int page_shift; /* buffer page shift */
346346
bool fixed_page; /* decide page shift is fixed-size or maximum size */
347347
int user_access; /* umem access flag */
348348
bool mtt_only; /* only alloc buffer-required MTT memory */
@@ -351,14 +351,14 @@ struct hns_roce_buf_attr {
351351
/* memory translate region */
352352
struct hns_roce_mtr {
353353
struct hns_roce_hem_list hem_list; /* multi-hop addressing resource */
354-
struct ib_umem *umem; /* user space buffer */
355-
struct hns_roce_buf *kmem; /* kernel space buffer */
354+
struct ib_umem *umem; /* user space buffer */
355+
struct hns_roce_buf *kmem; /* kernel space buffer */
356356
struct {
357-
dma_addr_t root_ba; /* root BA table's address */
358-
bool is_direct; /* addressing without BA table */
359-
int ba_pg_shift; /* BA table page shift */
360-
int buf_pg_shift; /* buffer page shift */
361-
int buf_pg_count; /* buffer page count */
357+
dma_addr_t root_ba; /* root BA table's address */
358+
bool is_direct; /* addressing without BA table */
359+
unsigned int ba_pg_shift; /* BA table page shift */
360+
unsigned int buf_pg_shift; /* buffer page shift */
361+
int buf_pg_count; /* buffer page count */
362362
} hem_cfg; /* config for hardware addressing */
363363
};
364364

@@ -423,7 +423,7 @@ struct hns_roce_buf {
423423
struct hns_roce_buf_list *page_list;
424424
u32 npages;
425425
u32 size;
426-
int page_shift;
426+
unsigned int page_shift;
427427
};
428428

429429
struct hns_roce_db_pgdir {
@@ -1139,8 +1139,9 @@ void hns_roce_cmd_use_polling(struct hns_roce_dev *hr_dev);
11391139
int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
11401140
int offset, u64 *mtt_buf, int mtt_max, u64 *base_addr);
11411141
int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
1142-
struct hns_roce_buf_attr *buf_attr, int page_shift,
1143-
struct ib_udata *udata, unsigned long user_addr);
1142+
struct hns_roce_buf_attr *buf_attr,
1143+
unsigned int page_shift, struct ib_udata *udata,
1144+
unsigned long user_addr);
11441145
void hns_roce_mtr_destroy(struct hns_roce_dev *hr_dev,
11451146
struct hns_roce_mtr *mtr);
11461147
int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
@@ -1210,7 +1211,7 @@ int hns_roce_get_kmem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
12101211
int buf_cnt, int start, struct hns_roce_buf *buf);
12111212
int hns_roce_get_umem_bufs(struct hns_roce_dev *hr_dev, dma_addr_t *bufs,
12121213
int buf_cnt, int start, struct ib_umem *umem,
1213-
int page_shift);
1214+
unsigned int page_shift);
12141215

12151216
int hns_roce_create_srq(struct ib_srq *srq,
12161217
struct ib_srq_init_attr *srq_init_attr,

drivers/infiniband/hw/hns/hns_roce_hem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ static int hem_list_alloc_root_bt(struct hns_roce_dev *hr_dev,
14001400
int hns_roce_hem_list_request(struct hns_roce_dev *hr_dev,
14011401
struct hns_roce_hem_list *hem_list,
14021402
const struct hns_roce_buf_region *regions,
1403-
int region_cnt, int bt_pg_shift)
1403+
int region_cnt, unsigned int bt_pg_shift)
14041404
{
14051405
const struct hns_roce_buf_region *r;
14061406
int ofs, end;

drivers/infiniband/hw/hns/hns_roce_hem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int hns_roce_hem_list_calc_root_ba(const struct hns_roce_buf_region *regions,
133133
int hns_roce_hem_list_request(struct hns_roce_dev *hr_dev,
134134
struct hns_roce_hem_list *hem_list,
135135
const struct hns_roce_buf_region *regions,
136-
int region_cnt, int bt_pg_shift);
136+
int region_cnt, unsigned int bt_pg_shift);
137137
void hns_roce_hem_list_release(struct hns_roce_dev *hr_dev,
138138
struct hns_roce_hem_list *hem_list);
139139
void *hns_roce_hem_list_find_mtt(struct hns_roce_dev *hr_dev,

drivers/infiniband/hw/hns/hns_roce_mr.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,8 @@ static inline size_t mtr_bufs_size(struct hns_roce_buf_attr *attr)
706706
return size;
707707
}
708708

709-
static inline int mtr_umem_page_count(struct ib_umem *umem, int page_shift)
709+
static inline int mtr_umem_page_count(struct ib_umem *umem,
710+
unsigned int page_shift)
710711
{
711712
int count = ib_umem_page_count(umem);
712713

@@ -719,7 +720,7 @@ static inline int mtr_umem_page_count(struct ib_umem *umem, int page_shift)
719720
}
720721

721722
static inline size_t mtr_kmem_direct_size(bool is_direct, size_t alloc_size,
722-
int page_shift)
723+
unsigned int page_shift)
723724
{
724725
if (is_direct)
725726
return ALIGN(alloc_size, 1 << page_shift);
@@ -732,7 +733,7 @@ static inline size_t mtr_kmem_direct_size(bool is_direct, size_t alloc_size,
732733
* Returns 0 on success, or the error page num.
733734
*/
734735
static inline int mtr_check_direct_pages(dma_addr_t *pages, int page_count,
735-
int page_shift)
736+
unsigned int page_shift)
736737
{
737738
size_t page_size = 1 << page_shift;
738739
int i;
@@ -765,8 +766,8 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
765766
struct ib_udata *udata, unsigned long user_addr)
766767
{
767768
struct ib_device *ibdev = &hr_dev->ib_dev;
768-
int max_pg_shift = buf_attr->page_shift;
769-
int best_pg_shift = 0;
769+
unsigned int max_pg_shift = buf_attr->page_shift;
770+
unsigned int best_pg_shift = 0;
770771
int all_pg_count = 0;
771772
size_t direct_size;
772773
size_t total_size;
@@ -836,7 +837,7 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
836837
}
837838

838839
static int mtr_get_pages(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
839-
dma_addr_t *pages, int count, int page_shift)
840+
dma_addr_t *pages, int count, unsigned int page_shift)
840841
{
841842
struct ib_device *ibdev = &hr_dev->ib_dev;
842843
int npage;
@@ -946,7 +947,7 @@ int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
946947
/* convert buffer size to page index and page count */
947948
static int mtr_init_region(struct hns_roce_buf_attr *attr, int page_cnt,
948949
struct hns_roce_buf_region *regions, int region_cnt,
949-
int page_shift)
950+
unsigned int page_shift)
950951
{
951952
unsigned int page_size = 1 << page_shift;
952953
int max_region = attr->region_count;
@@ -977,8 +978,9 @@ static int mtr_init_region(struct hns_roce_buf_attr *attr, int page_cnt,
977978
* @buf_alloced: mtr has private buffer, true means need to alloc
978979
*/
979980
int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
980-
struct hns_roce_buf_attr *buf_attr, int page_shift,
981-
struct ib_udata *udata, unsigned long user_addr)
981+
struct hns_roce_buf_attr *buf_attr,
982+
unsigned int page_shift, struct ib_udata *udata,
983+
unsigned long user_addr)
982984
{
983985
struct hns_roce_buf_region regions[HNS_ROCE_MAX_BT_REGION] = {};
984986
struct ib_device *ibdev = &hr_dev->ib_dev;

0 commit comments

Comments
 (0)