Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754244AbbHYDDU (ORCPT ); Mon, 24 Aug 2015 23:03:20 -0400 Received: from mail-bn1bn0109.outbound.protection.outlook.com ([157.56.110.109]:4884 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751687AbbHYDDS convert rfc822-to-8bit (ORCPT ); Mon, 24 Aug 2015 23:03:18 -0400 From: Zhao Qiang To: Laura Abbott , Scott Wood CC: "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "lauraa@codeaurora.org" , Xiaobo Xie , "benh@kernel.crashing.org" , Li Leo , "paulus@samba.org" Subject: RE: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram Thread-Topic: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram Thread-Index: AQHQ3lE08qg+K0DuDEa/oy40LAO0yp4bzaWAgAA3LDA= Date: Tue, 25 Aug 2015 03:03:09 +0000 Message-ID: References: <1440408703-6113-1-git-send-email-qiang.zhao@freescale.com> <1440408703-6113-3-git-send-email-qiang.zhao@freescale.com> <55DBA98D.1070202@redhat.com> In-Reply-To: <55DBA98D.1070202@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=qiang.zhao@freescale.com; x-originating-ip: [192.158.241.86] x-microsoft-exchange-diagnostics: 1;BN3PR03MB1478;5:/IpEATRGMZdQchtpFdJ4Otd3mzTfZAkfwMUbTyYwoj8EjkkWa1XsLmBV2ASFEx2x5hyKBsT1Rac4gdNvwokvQl7r/H+ymvRgExtUfDdVELyJrbjJdsPbQFTCZUn6Ei774YiLMwsm2jI/DlXwErCi2A==;24:sXwizwvru9Auw6MPmabFAdWStpnkoAQ6h2wI6oKbCImTXKDoHD+o7oBpcB2019H4BzIR5cN01GwHF4u2FOb/DzhvKCPLSnHsnu5BQwtsmFI=;20:Of9v7xfL028BEfOS98ZBfAYjYDRQ7zuYGn3264gmmwbepbbUM6Suu5L/nzVDbUnh6O725mnnjyTA2NBStR2USA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1478; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:BN3PR03MB1478;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1478; x-forefront-prvs: 06793E740F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(377454003)(24454002)(164054003)(13464003)(479174004)(199003)(102836002)(76576001)(86362001)(68736005)(81156007)(92566002)(33656002)(62966003)(106356001)(40100003)(77096005)(106116001)(122556002)(19580395003)(77156002)(19580405001)(105586002)(87936001)(5001960100002)(5001860100001)(46102003)(5001770100001)(4001450100002)(2950100001)(5001920100001)(189998001)(5007970100001)(97736004)(2900100001)(64706001)(4001540100001)(50986999)(54356999)(66066001)(5003600100002)(5001830100001)(99286002)(2656002)(5002640100001)(74316001)(76176999)(101416001)(5004730100002)(10400500002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1478;H:SN1PR0301MB1550.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2015 03:03:09.9138 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1478 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2614 Lines: 79 > -----Original Message----- > From: Laura Abbott [mailto:labbott@redhat.com] > Sent: Tuesday, August 25, 2015 7:32 AM > To: Zhao Qiang-B45475; Wood Scott-B07421 > Cc: linux-kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > lauraa@codeaurora.org; Xie Xiaobo-R63061; benh@kernel.crashing.org; Li > Yang-Leo-R58472; paulus@samba.org > Subject: Re: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage > muram > > On 08/24/2015 02:31 AM, Zhao Qiang wrote: > > > > +out: > > + of_node_put(np); > > + return ret; > > +} > > + > > +/** > > + * qe_muram_alloc - allocate the requested size worth of multi-user > > +ram > > + * @size: number of bytes to allocate > > + * @align: requested alignment, in bytes > > + * > > + * This function returns an offset into the muram area. > > + * Use qe_dpram_addr() to get the virtual address of the area. > > + * Use qe_muram_free() to free the allocation. > > + */ > > +unsigned long qe_muram_alloc(unsigned long size, unsigned long align) > > +{ > > + unsigned long start; > > + unsigned long flags; > > + struct muram_block *entry; > > + > > + spin_lock_irqsave(&qe_muram_lock, flags); > > + muram_pool_data.align = align; > > + start = gen_pool_alloc(muram_pool, size); > > The advantage of creating gen_pool_alloc_data was so that you could pass > in the align automatically without having to modify the structure. > Is there a reason you aren't using that? > > > + memset(qe_muram_addr(start), 0, size); > > There doesn't seem to be a check for allocation failure from the > gen_alloc. gen_pool_alloc will return 0 if there is error, but if the address returned is just 0x0, it can't distinguish it is address or error. > > > + entry = kmalloc(sizeof(*entry), GFP_KERNEL); > > + if (!entry) > > + goto out; > > + entry->start = start; > > + entry->size = size; > > + list_add(&entry->head, &muram_block_list); > > What's the point of keeping the block list anyway? It's used only in this > file and it only seems to duplicate what gen_alloc is doing internally. > Is there some lookup functionality you still need? Could you use a > gen_alloc API to do so? I need to record the size when allocation, so when free the block, I can get The right size for the block, and pass the right size to gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size). > > > Thanks, > Laura Thanks Zhao -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/