From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753246AbcFTHzn (ORCPT ); Mon, 20 Jun 2016 03:55:43 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:36230 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752882AbcFTHzf (ORCPT ); Mon, 20 Jun 2016 03:55:35 -0400 Subject: Re: [PATCH v10 08/22] IB/hns: Add icm support To: References: <1466087730-54856-1-git-send-email-oulijun@huawei.com> <1466087730-54856-9-git-send-email-oulijun@huawei.com> <20160617095834.GA5408@leon.nu> <57677314.70909@huawei.com> <20160620060614.GC1172@leon.nu> CC: Lijun Ou , , , , , , , , , , , , , , , , , , From: "Wei Hu (Xavier)" Message-ID: <5767A004.4060808@huawei.com> Date: Mon, 20 Jun 2016 15:49:24 +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: <20160620060614.GC1172@leon.nu> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.57.115.113] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5767A043.0019,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: ea57502699af9d4f7a9423ac68b48cdf Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/6/20 14:06, Leon Romanovsky wrote: > On Mon, Jun 20, 2016 at 12:37:40PM +0800, Wei Hu (Xavier) wrote: >> >> On 2016/6/17 17:58, Leon Romanovsky wrote: >>> On Thu, Jun 16, 2016 at 10:35:16PM +0800, Lijun Ou wrote: >>>> This patch mainly added icm support for RoCE. It initializes icm >>>> which managers the relative memory blocks for RoCE. The data >>>> structures of RoCE will be located in it. For example, CQ table, >>>> QP table and MTPT table so on. >>>> >>>> Signed-off-by: Wei Hu >>>> Signed-off-by: Nenglong Zhao >>>> Signed-off-by: Lijun Ou >>>> --- >>> <...> >>> >>>> + >>>> +static int hns_roce_alloc_icm_pages(struct scatterlist *mem, int order, >>>> + gfp_t gfp_mask) >>>> +{ >>>> + struct page *page; >>>> + >>>> + page = alloc_pages(gfp_mask, order); >>>> + if (!page) >>>> + return -ENOMEM; >>>> + >>>> + sg_set_page(mem, page, PAGE_SIZE << order, 0); >>>> + >>>> + return 0; >>>> +} >>>> + >>>> +static int hns_roce_alloc_icm_coherent(struct device *dev, >>>> + struct scatterlist *mem, int order, >>>> + gfp_t gfp_mask) >>>> +{ >>>> + void *buf = dma_alloc_coherent(dev, PAGE_SIZE << order, >>>> + &sg_dma_address(mem), gfp_mask); >>>> + if (!buf) >>>> + return -ENOMEM; >>>> + >>>> + sg_set_buf(mem, buf, PAGE_SIZE << order); >>>> + WARN_ON(mem->offset); >>>> + sg_dma_len(mem) = PAGE_SIZE << order; >>>> + return 0; >>>> +} >>>> + >>> <...> >>> >>>> + >>>> +static void hns_roce_free_icm_pages(struct hns_roce_dev *hr_dev, >>>> + struct hns_roce_icm_chunk *chunk) >>>> +{ >>>> + int i; >>>> + >>>> + if (chunk->nsg > 0) >>>> + dma_unmap_sg(&hr_dev->pdev->dev, chunk->mem, chunk->npages, >>>> + DMA_BIDIRECTIONAL); >>>> + >>>> + for (i = 0; i < chunk->npages; ++i) >>>> + __free_pages(sg_page(&chunk->mem[i]), >>>> + get_order(chunk->mem[i].length)); >>> You used alloc_pages for this allocation, so why are you using >>> __free_pages instead of free_pages? >> Hi, Leon >> The function prototype of these functions as below: >> static inline struct page * alloc_pages(gfp_t gfp_mask, unsigned int >> order); >> void free_pages(unsigned long addr, unsigned int order); >> void __free_pages(struct page *page, unsigned int order); >> >> The type of the first parameter of free_pages is same with the type of >> return value of alloc_pages. >> Maybe it is better to call __free_pages to release memory that allocated >> by calling alloc_pages. > OK, I see. > > Another question which you didn't answer [1]. > > "I wonder if you have the same needs for ICM as it is in mlx4 device. > Do you have firmware?" > > [1] http://marc.info/?l=linux-rdma&m=146545553104913&w=2 Hi, Leon Now we haven't firmware. But hardware still need memory for QPC\CQC\MTPT\mtt etc. Thanks Wei Hu >> Regards >> Wei Hu >>