From patchwork Tue Apr 18 18:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9685979 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 ACFF1601C2 for ; Tue, 18 Apr 2017 18:27:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2BC61FF12 for ; Tue, 18 Apr 2017 18:27:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97AA8200DF; Tue, 18 Apr 2017 18:27:30 +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 64B461FF12 for ; Tue, 18 Apr 2017 18:27:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A40506E227; Tue, 18 Apr 2017 18:27:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id A240E6E227 for ; Tue, 18 Apr 2017 18:27:27 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id d131so1118661qkc.3 for ; Tue, 18 Apr 2017 11:27:27 -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=IjGavS1/0rONQIf7OnekZinRM916vkWqJBL41MxG7WIn728X7MgjqfJaLPeAHs7TVD hwX11ScGi1LrpFYG+zMGT3M48Ry3CFJ4E6D5eZJU7Y/nuE1rgTqbJzjIMVPZDQPcUpn0 5HU7L5XBvgnhs0s5atH68zdB+0kBY4Z6Z0t3GTL4pVU8ngoBuy1WyXINNaEPlT0G2Soo PJXGiu6MUs96HFYfMDfEc+QtXp4EhZuJsEeUg/HoHTKd9dLC0yRUFvcUkyClcgn5icM/ cnC5dIlRDGP+xkphtltDdyytVOR4EY0OUzRtuYNXF6CyT8AHjZ81Y0ZewyS7XRaQ5mWc 3Bnw== X-Gm-Message-State: AN3rC/4AWK7dlMmZ7n5nT1zRqZ3o8MM5kwR9JoseqpmhZzmRyIK2cg5m GGH31feljA0WVTJb X-Received: by 10.55.75.68 with SMTP id y65mr13636849qka.2.1492540046833; Tue, 18 Apr 2017 11:27:26 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc::159c]) by smtp.gmail.com with ESMTPSA id q66sm10142381qkd.69.2017.04.18.11.27.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 11:27:25 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , Riley Andrews , arve@android.com, Greg Kroah-Hartman Subject: [PATCHv4 02/12] cma: Introduce cma_for_each_area Date: Tue, 18 Apr 2017 11:27:04 -0700 Message-Id: <1492540034-5466-3-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492540034-5466-1-git-send-email-labbott@redhat.com> References: <1492540034-5466-1-git-send-email-labbott@redhat.com> Cc: devel@driverdev.osuosl.org, romlem@google.com, 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; +}