Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754685AbdC2Isy (ORCPT ); Wed, 29 Mar 2017 04:48:54 -0400 Received: from mail-qt0-f181.google.com ([209.85.216.181]:36418 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752459AbdC2Isw (ORCPT ); Wed, 29 Mar 2017 04:48:52 -0400 MIME-Version: 1.0 In-Reply-To: <1489798493-16600-3-git-send-email-labbott@redhat.com> References: <1489798493-16600-1-git-send-email-labbott@redhat.com> <1489798493-16600-3-git-send-email-labbott@redhat.com> From: Benjamin Gaignard Date: Wed, 29 Mar 2017 10:48:36 +0200 Message-ID: Subject: Re: [RFC PATCHv2 02/21] cma: Introduce cma_for_each_area To: Laura Abbott Cc: Sumit Semwal , Riley Andrews , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Rom Lemarchand , devel@driverdev.osuosl.org, Linux Kernel Mailing List , "linaro-mm-sig@lists.linaro.org" , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, "linux-media@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Brian Starkey , Daniel Vetter , Mark Brown , Linux MM , Laurent Pinchart Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v2T8nD7D018225 Content-Length: 1750 Lines: 63 2017-03-18 1:54 GMT+01:00 Laura Abbott : > > Frameworks (e.g. Ion) may want to iterate over each possible CMA area to > allow for enumeration. Introduce a function to allow a callback. even outside ION rework that could be useful Reviewed-by: Benjamin Gaignard > > Signed-off-by: Laura Abbott > --- > include/linux/cma.h | 2 ++ > mm/cma.c | 14 ++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/include/linux/cma.h b/include/linux/cma.h > index d41d1f8..3e8fbf5 100644 > --- a/include/linux/cma.h > +++ b/include/linux/cma.h > @@ -34,4 +34,6 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, > extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, > gfp_t gfp_mask); > extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count); > + > +extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data); > #endif > diff --git a/mm/cma.c b/mm/cma.c > index 0d187b1..9a040e1 100644 > --- a/mm/cma.c > +++ b/mm/cma.c > @@ -498,3 +498,17 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count) > > return true; > } > + > +int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data) > +{ > + int i; > + > + for (i = 0; i < cma_area_count; i++) { > + int ret = it(&cma_areas[i], data); > + > + if (ret) > + return ret; > + } > + > + return 0; > +} > -- > 2.7.4 > -- Benjamin Gaignard Graphic Study Group Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog