From patchwork Mon Apr 3 18:57:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9660271 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 AFD2E6032D for ; Mon, 3 Apr 2017 18:58:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A47EB284C2 for ; Mon, 3 Apr 2017 18:58:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 995EC284F5; Mon, 3 Apr 2017 18:58:19 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 58127284C2 for ; Mon, 3 Apr 2017 18:58:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 937886E3D1; Mon, 3 Apr 2017 18:58:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-f173.google.com (mail-qk0-f173.google.com [209.85.220.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6210B6E3CF for ; Mon, 3 Apr 2017 18:58:17 +0000 (UTC) Received: by mail-qk0-f173.google.com with SMTP id g195so50918409qke.2 for ; Mon, 03 Apr 2017 11:58:17 -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=u4DoFJJI4AfDMMvX7FVu5xXVhMrTyMwU15pfIegY2wY=; b=LGGaNGjcg/woqAukU6XFlAPw1VI824xvkh8jc7ecS3pqbKOj7ZxnVwn9uu0JH4pkOd DcPFmvyGWxt9ThJW5n/OJLIHBqp2QT417Ialby/juRpmbX4HH8JnxeIRX4Hd5/4Z1E/Y +i0GF0kXZRQwcHFWVHaHOFr+9/8KDPTztKu45hzNpjqFfEzFrveHRf6zkavb2V/wc1yO NIuBrOrBIuprvDjFuC3mOZTgOKsVTZNSx6XF3DJvBPt7kxJH6MX4zOVmpjwQdemU+1R7 HrIQK0BN8uQ257W+bMhGYUU+ub3rpmXtiO3eoAZy5ruH3BVmDOrrhOfu+Of7/m4wZ9s6 +cNQ== X-Gm-Message-State: AFeK/H1mbnJBqyA8tUCdygwsUMGneuv2yCTKmVtVzJT+o9+GZupb0PZa58YBi9hozZSgWRMO X-Received: by 10.55.79.140 with SMTP id d134mr16121017qkb.120.1491245896576; Mon, 03 Apr 2017 11:58:16 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc:1722:8a6b:a66c:79eb]) by smtp.gmail.com with ESMTPSA id e5sm10173689qtc.6.2017.04.03.11.58.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 11:58:15 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , Riley Andrews , arve@android.com Subject: [PATCHv3 02/22] cma: Introduce cma_for_each_area Date: Mon, 3 Apr 2017 11:57:44 -0700 Message-Id: <1491245884-15852-3-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491245884-15852-1-git-send-email-labbott@redhat.com> References: <1491245884-15852-1-git-send-email-labbott@redhat.com> 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 , Daniel Vetter , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 43c1b2c..978b4a1 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -504,3 +504,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; +}