[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SN1PR0301MB1550CE6B922CE64AA4F862759B610@SN1PR0301MB1550.namprd03.prod.outlook.com>
Date: Tue, 25 Aug 2015 07:19:17 +0000
From: Zhao Qiang <qiang.zhao@...escale.com>
To: Laura Abbott <labbott@...hat.com>,
Scott Wood <scottwood@...escale.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"lauraa@...eaurora.org" <lauraa@...eaurora.org>,
Xiaobo Xie <X.Xie@...escale.com>,
"benh@...nel.crashing.org" <benh@...nel.crashing.org>,
Li Leo <LeoLi@...escale.com>,
"paulus@...ba.org" <paulus@...ba.org>
Subject: RE: [PATCH v6 3/3] qe_common: add qe_muram_ functions to manage muram
On 08/25/2015 12:15 PM, Laura Abbott wrote
> -----Original Message-----
> From: Laura Abbott [mailto:labbott@...hat.com]
> Sent: Tuesday, August 25, 2015 12:15 PM
> To: Zhao Qiang-B45475; Wood Scott-B07421
> Cc: linux-kernel@...r.kernel.org; linuxppc-dev@...ts.ozlabs.org;
> lauraa@...eaurora.org; Xie Xiaobo-R63061; benh@...nel.crashing.org; Li
> Yang-Leo-R58472; paulus@...ba.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@...hat.com]
> >> Sent: Tuesday, August 25, 2015 7:32 AM
> >> To: Zhao Qiang-B45475; Wood Scott-B07421
> >> Cc: linux-kernel@...r.kernel.org; linuxppc-dev@...ts.ozlabs.org;
> >> lauraa@...eaurora.org; Xie Xiaobo-R63061; benh@...nel.crashing.org;
> >> Li Yang-Leo-R58472; paulus@...ba.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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists