Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbcD0Dey (ORCPT ); Tue, 26 Apr 2016 23:34:54 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:42901 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751920AbcD0Dew (ORCPT ); Tue, 26 Apr 2016 23:34:52 -0400 Subject: Re: [PATCH v5 09/21] IB/hns: Add hca support To: Jiri Pirko , Leon Romanovsky References: <1461407219-72027-1-git-send-email-oulijun@huawei.com> <1461407219-72027-10-git-send-email-oulijun@huawei.com> <20160424075424.GE7974@leon.nu> <571F0C04.2010005@huawei.com> <20160426141821.GJ7974@leon.nu> <20160426142517.GA1937@nanopsycho.orion> CC: , , , , , , , , , , , , , , , , , , From: oulijun Message-ID: <57203347.4000107@huawei.com> Date: Wed, 27 Apr 2016 11:34:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160426142517.GA1937@nanopsycho.orion> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.61.25.147] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.57203356.00B3,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ffc15f9ac66c7cd7b4d76bb86c2f673e Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2292 Lines: 75 On 2016/4/26 22:25, Jiri Pirko wrote: > Tue, Apr 26, 2016 at 04:18:21PM CEST, leon@kernel.org wrote: >> On Tue, Apr 26, 2016 at 02:34:44PM +0800, oulijun wrote: >>> On 2016/4/24 15:54, Leon Romanovsky wrote: > > > >>>>> +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. > > The driver should run correctly on any arch. > Hi Jiri Pirko, Our driver run in ARM64 platform by depending on Kconfig. It will be configure in Kconfig file. Thanks Lijun Ou > >>> 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? >> >> No, >> You are submitting new driver, please do it properly (without casting) >>from the beginning. >> >>> >>> Thanks >>> Lijun Ou >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > . >