Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755417AbbHYHe4 (ORCPT ); Tue, 25 Aug 2015 03:34:56 -0400 Received: from mail-bl2on0126.outbound.protection.outlook.com ([65.55.169.126]:5984 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752358AbbHYHez convert rfc822-to-8bit (ORCPT ); Tue, 25 Aug 2015 03:34:55 -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/oy40LAO0yp4bzaWAgAA3LDCAABe8AIAAMajw Date: Tue, 25 Aug 2015 07:19:17 +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> <55DBEBBE.30702@redhat.com> In-Reply-To: <55DBEBBE.30702@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;BLUPR03MB1475;5:Pffe8Im1pw/Km2GXVX93PmWPpq4oXs4WFB55jwyYkYexC7kLMdhyBCS5nQ3g2v9koeolJjRjusutZntdAs8C+xU+pYnZ+9nWdr0Eo5b4sxnfZucH8hHvcXSjFM7O7XiXmBTM7HER9HdPL+6NjGpn+Q==;24:FLcC/NGWVNV4WzAAIXD/NbGzfiPjN10tu4vMVr3FPenAlBSIII0qwpz6+ertRq/u6DteDb2qWqXVn6/1NRkT8Mp7DtDGwM3TdsBGUrFDWgU=;20:oTLBFCzkcs2yXtrZlelo6/Jktgpqr2C6Ih4x6LiPY7TzoKhywGJMKW5fTCp9h6KSnAMPe3h4QNl+oZXtcfuT0A== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1475; 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:BLUPR03MB1475;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1475; x-forefront-prvs: 06793E740F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(377454003)(479174004)(13464003)(199003)(164054003)(24454002)(93886004)(99286002)(74316001)(4001540100001)(81156007)(62966003)(106116001)(46102003)(77156002)(189998001)(5007970100001)(97736004)(4001450100002)(2656002)(86362001)(5001860100001)(122556002)(5002640100001)(19580405001)(5001770100001)(101416001)(10400500002)(5003600100002)(76576001)(68736005)(87936001)(40100003)(76176999)(66066001)(19580395003)(77096005)(5001830100001)(102836002)(54356999)(33656002)(106356001)(5001960100002)(64706001)(2950100001)(2900100001)(50986999)(5004730100002)(92566002)(105586002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1475;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 07:19:18.0060 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1475 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3135 Lines: 84 On 08/25/2015 12:15 PM, Laura Abbott wrote > -----Original Message----- > From: Laura Abbott [mailto:labbott@redhat.com] > Sent: Tuesday, August 25, 2015 12:15 PM > 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 08:03 PM, Zhao Qiang wrote: > > > >> -----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. > > > > Yes, that's a bad limitation of gen_pool. Maybe one day that will get > fixed. > In a previous out of tree driver, I worked around this by offsetting the > gen_pool_add by a constant so any return value was non-zero and out of > memory was zero and then subtracting the constant off of the return value. > Not sure if that's better or worse than just fixing gen_alloc. > The workaround works for non alignment allocation, but for alignment allocation, It need to align bytes to addr 0, offsetting the gen_pool_add maybe make wrong alignment . > > Thanks, > Laura -- 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/