Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1387166

Re: [PATCH v5 09/21] IB/hns: Add hca support

From oulijun <oulijun@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v5 09/21] IB/hns: Add hca support
Date 2016-04-26 08:40 +0200
Message-ID <rs4P7-2R0-5@gated-at.bofh.it> (permalink)
References <rr2Pn-1qw-3@gated-at.bofh.it> <rr2Pn-1qw-9@gated-at.bofh.it> <rrn7s-VO-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2016/4/24 15:54, Leon Romanovsky wrote:
> On Sat, Apr 23, 2016 at 06:26:47PM +0800, Lijun Ou wrote:
>> This patch mainly setup hca for RoCE. it will do a series of
>> initial works as follows:
>>       1. init uar table, allocate uar resource
>>       2. init pd table
>>       3. init cq table
>>       4. init mr table
>>       5. init qp table
>>
>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>> Signed-off-by: Wei Hu(Xavier) <xavier.huwei@huawei.com>
>> ---
>>  drivers/infiniband/hw/hns/hns_roce_alloc.c  | 104 ++++++++++++++++
>>  drivers/infiniband/hw/hns/hns_roce_cq.c     |  25 ++++
>>  drivers/infiniband/hw/hns/hns_roce_device.h |  69 ++++++++++
>>  drivers/infiniband/hw/hns/hns_roce_eq.c     |   1 -
>>  drivers/infiniband/hw/hns/hns_roce_icm.c    |  88 +++++++++++++
>>  drivers/infiniband/hw/hns/hns_roce_icm.h    |   9 ++
>>  drivers/infiniband/hw/hns/hns_roce_main.c   |  79 ++++++++++++
>>  drivers/infiniband/hw/hns/hns_roce_mr.c     | 187 ++++++++++++++++++++++++++++
>>  drivers/infiniband/hw/hns/hns_roce_pd.c     |  65 ++++++++++
>>  drivers/infiniband/hw/hns/hns_roce_qp.c     |  30 +++++
>>  10 files changed, 656 insertions(+), 1 deletion(-)
>>  create mode 100644 drivers/infiniband/hw/hns/hns_roce_alloc.c
>>  create mode 100644 drivers/infiniband/hw/hns/hns_roce_mr.c
>>  create mode 100644 drivers/infiniband/hw/hns/hns_roce_pd.c
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_alloc.c b/drivers/infiniband/hw/hns/hns_roce_alloc.c
>> new file mode 100644
>> index 0000000..0c76f1b
>> --- /dev/null
>> +++ b/drivers/infiniband/hw/hns/hns_roce_alloc.c
>> @@ -0,0 +1,104 @@
>> +/*
>> + * Copyright (c) 2016 Hisilicon Limited.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + */
>> +
>> +#include <linux/bitmap.h>
>> +#include <linux/dma-mapping.h>
>> +#include <linux/errno.h>
>> +#include <linux/mm.h>
>> +#include <linux/slab.h>
>> +#include <linux/vmalloc.h>
>> +#include "hns_roce_device.h"
>> +
>> +int hns_roce_bitmap_alloc(struct hns_roce_bitmap *bitmap, u32 *obj)
>> +{
>> +	int ret = 0;
>> +
>> +	spin_lock(&bitmap->lock);
>> +	*obj = find_next_zero_bit(bitmap->table, bitmap->max, bitmap->last);
>> +	if (*obj >= bitmap->max) {
>> +		bitmap->top = (bitmap->top + bitmap->max + bitmap->reserved_top)
>> +			       & bitmap->mask;
>> +		*obj = find_first_zero_bit(bitmap->table, bitmap->max);
> 
> find_first_zero_bit function returns "unsigned long" which may or may
> not be equal to u32 on some architectures.
> 
Hi Leon,
    I appreciate your keen eye. this code is meant for ARM64bit therefore should run corretly for 64-bit AARCH64.
I will consider changing it as part of good partice and better portability "
I will give a primary plan to modified it.
for example:
    *obj = (u32)find_next_zero_bit(bitmap->table, bitmap->max, bitmap->last);
Beause the max size of bitmap->table is u32 in current version.

int hns_roce_bitmap_init(struct hns_roce_bitmap *bitmap, u32 num, u32 mask,
			 u32 reserved_bot, u32 reserved_top)
{
	u32 i;

	if (num != roundup_pow_of_two(num))
		return -EINVAL;

	bitmap->last = 0;
	bitmap->top = 0;
	bitmap->max = num - reserved_top;
	bitmap->mask = mask;
	bitmap->reserved_top = reserved_top;
	spin_lock_init(&bitmap->lock);
	bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long),
				GFP_KERNEL);

Is this plan ok?

Thanks
Lijun Ou

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 09/21] IB/hns: Add hca support Lijun Ou <oulijun@huawei.com> - 2016-04-23 12:20 +0200
  Re: [PATCH v5 09/21] IB/hns: Add hca support Leon Romanovsky <leon@kernel.org> - 2016-04-24 10:00 +0200
    Re: [PATCH v5 09/21] IB/hns: Add hca support oulijun <oulijun@huawei.com> - 2016-04-26 08:40 +0200
      Re: [PATCH v5 09/21] IB/hns: Add hca support Leon Romanovsky <leon@kernel.org> - 2016-04-26 16:20 +0200
        Re: [PATCH v5 09/21] IB/hns: Add hca support Jiri Pirko <jiri@resnulli.us> - 2016-04-26 16:30 +0200
          Re: [PATCH v5 09/21] IB/hns: Add hca support oulijun <oulijun@huawei.com> - 2016-04-27 05:40 +0200
        Re: [PATCH v5 09/21] IB/hns: Add hca support oulijun <oulijun@huawei.com> - 2016-04-27 05:40 +0200

csiph-web