From patchwork Sat Mar 18 00:54:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9631815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 038CA60249 for ; Sat, 18 Mar 2017 00:55:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB04B2841F for ; Sat, 18 Mar 2017 00:55:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFA31284EE; Sat, 18 Mar 2017 00:55:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADA312841F for ; Sat, 18 Mar 2017 00:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oI20O1NK++wA9X/vunmvbt08gDr5MkLV/McmTCwwD9U=; b=BgaRqVQMRIaj08xnz1uqJviRyN vkiQ1YvqFUf2Tus4BagaI09WCG262a1FNLgpgdC2/mrOt8UKE2Tke1YQMjXlJ1ri42Ebz/MczVHhr ivCtm/phY3r3OWyKbd6HmdjrtVM7G4CbGu6gXRs19NZREvcJuUyX2rL03dEEJc5y0TGIO3/z/8/oh lsDzOe1OIW2fJ5Pxp2W0BqJXFiukHGo1mIbqh2boWTOjZHWtABZ47lAKMtbQD3b4KuwZH3jVcjwSe eIjUiv6iX299qtjGehQq44bqpTEqtcebAqrBS7Ffccvc0rKWDy3hFRdKTo9JzYkAJf8baqrMJqbPV KouFshdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cp2ex-00040y-4M; Sat, 18 Mar 2017 00:55:55 +0000 Received: from mail-qt0-f176.google.com ([209.85.216.176]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cp2eV-0003AD-BC for linux-arm-kernel@lists.infradead.org; Sat, 18 Mar 2017 00:55:29 +0000 Received: by mail-qt0-f176.google.com with SMTP id r45so75158553qte.3 for ; Fri, 17 Mar 2017 17:55:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wAp6SxuYvzBTae5wjey2zlwzqRptBvnOeXjHMGgFRI8=; b=CbOIMdlbR3LpwbUKhA3JXr8u+qDydK2JnWooet/vEJALADEJSCKrIYpc2Sf4XwwE34 ffflFwWYmwaWYrY4uGjUT9BXpQ1m4D/eQ0e21ucRAdAw4KloYm0mSY3Ymoa49mspexr6 fTjwRBu3kir/KrXi5AJtARGTjw7qMxUCVsnyrWz77XpqvHE7CcaYLhRzunY+xBJPF6XW +M40wCiYzdUvbTMPCAxRut/QwntqvHLeo3k1yeCR6M2JXTUVZKNZ4QBwnh3wJ4TQj4HD Jb5Pa/Pg+Hk7xLMavuL+viAAxU0beADBcUV0n8cQUb6WSfslLZBPFiQ5cVNGaXXCwwnD ow3Q== X-Gm-Message-State: AFeK/H3T4CYPMPHCMcp11AVe64wkEsqHdAlXSwBTayeRoexVEc+MBlv6PfkERhyufX6xTNN8 X-Received: by 10.200.47.161 with SMTP id l30mr16798571qta.248.1489798506179; Fri, 17 Mar 2017 17:55:06 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc:1722:8a6b:a66c:79eb]) by smtp.gmail.com with ESMTPSA id e55sm7118568qte.52.2017.03.17.17.55.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2017 17:55:04 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , Riley Andrews , arve@android.com Subject: [RFC PATCHv2 02/21] cma: Introduce cma_for_each_area Date: Fri, 17 Mar 2017 17:54:34 -0700 Message-Id: <1489798493-16600-3-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489798493-16600-1-git-send-email-labbott@redhat.com> References: <1489798493-16600-1-git-send-email-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170317_175527_576315_3D86D327 X-CRM114-Status: GOOD ( 10.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, romlem@google.com, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, Mark Brown , Laurent Pinchart , Benjamin Gaignard , Daniel Vetter , Laura Abbott , Brian Starkey , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Frameworks (e.g. Ion) may want to iterate over each possible CMA area to allow for enumeration. Introduce a function to allow a callback. Signed-off-by: Laura Abbott Reviewed-by: Benjamin Gaignard --- 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; +}