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: 9631869 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 4514860249 for ; Sat, 18 Mar 2017 01:04:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37E3328518 for ; Sat, 18 Mar 2017 01:04:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B23928532; Sat, 18 Mar 2017 01:04:59 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA3D328518 for ; Sat, 18 Mar 2017 01:04:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751143AbdCRBE5 (ORCPT ); Fri, 17 Mar 2017 21:04:57 -0400 Received: from mail-qt0-f180.google.com ([209.85.216.180]:34877 "EHLO mail-qt0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbdCRBEz (ORCPT ); Fri, 17 Mar 2017 21:04:55 -0400 Received: by mail-qt0-f180.google.com with SMTP id x35so75178423qtc.2 for ; Fri, 17 Mar 2017 18:03:08 -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=Of3mIZTAxMKD9TV6V51N6Ue3GyT7v/rKQTXbijVKwlA+nOzzR7lgmVALdfGlzCSni4 nZsEdVQhs8jxo3t/80wKxVpyvMtwyuYU3flVcWNqShvTUU2kR5vSkSQFEa8hD8S2NNFj J1+mtssxn6ywRQGG9l1FX29asy5osR2NPt/RPRnuKtf4bTNJnH3XV+klDx1JOsI6fTbu kaaBLKrKKAKyHCuBUj1OO5BWwvyvODse0CkHSZj5burGXQhCbLZM+H02JwUmtPZOX53s TU0sNPDpdNshr+Kibrclaxv3HC2WyqVrZxV9QVs7a1xs+gnB1nTB8suacO5kLUGTwfDn dXIQ== X-Gm-Message-State: AFeK/H1B42hEnrDy4y5dJE6meikOJZyRdcffM1+QU2g0FtYl+ymASRYZD0cQTXSBXMGZOCrB 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 Cc: Laura Abbott , romlem@google.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, 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 , Benjamin Gaignard , linux-mm@kvack.org, Laurent Pinchart 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> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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; +}