On 2020/11/24 0:17, Jason Gunthorpe wrote: > On Mon, Nov 23, 2020 at 09:06:48PM +0800, Weihang Li wrote: >> +static int alloc_qpn_with_bankid(struct hns_roce_bank *bank, u8 bankid, >> + unsigned long *qpn) >> +{ >> + int id; >> + >> + id = ida_alloc_range(&bank->ida, bank->min, bank->max, GFP_KERNEL); >> + if (id < 0) { >> + id = ida_alloc_range(&bank->ida, bank->rsv_bot, bank->min, >> + GFP_KERNEL); > > Shouldn't this one be bank->max not min? That is the usual way to write a > cyclic allocator over this kind of API. See the logic in __xa_alloc_cyclic() > > Jason > Thanks for your advice, it's clearer to use bank->max here. We will refer to how __xa_alloc_cyclic() is implemented. Weihang