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: 9686051 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 414A2601C2 for ; Tue, 18 Apr 2017 18:33:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35ECC28375 for ; Tue, 18 Apr 2017 18:33:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 296182839C; Tue, 18 Apr 2017 18:33:51 +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 DAB6728375 for ; Tue, 18 Apr 2017 18:33:50 +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=FQrwJLa4KAgHgClICOTgCvNYrXDqCc5DzhI2T+ppIU0=; b=IgS+3W+2J1uggkyRzqFK7DqO3C Logf6968feSjVileQgSyYqTmYfwdab+vzSC5NcdnZPQN+Icp+VQqgcbJHZcm5I6Ju1gf2kXX2MsGj YRE6AnXkIj/alq7y+1YqolkB+2FsUlxNNoNEWtc8ugpwXDTENdbkhNoAsqNRo0W/Wtsd3XE1uNNEv hpiFLf0fH+PPKekSfYLJov5nX44vi3BEHXujZT9sXE9QzfxLNtqFaDfSNpucnolEuIvBVPWpIR9j8 lMNKh8qc9UuRRumK9j4Ojq0GIeHk8VZOMHHOYOXDWj29l5Y8NrIlgrYefuxDnaqdH3b1/4I3h12zt Ju68tKpQ==; 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 1d0Xwk-0002C3-HV; Tue, 18 Apr 2017 18:33:50 +0000 Received: from mail-qk0-f177.google.com ([209.85.220.177]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d0Xwa-0001w8-1l for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2017 18:33:42 +0000 Received: by mail-qk0-f177.google.com with SMTP id d131so1264366qkc.3 for ; Tue, 18 Apr 2017 11:33:19 -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=Tr4rv3sRhT7XM0UjJ+M9pZxaJBBeq/9h860tPcdrk20+ijCLOcgk6BscrcIkYOP1+z JzbokwCmlFYjPiCWB7zXvEnGUTX9TvzNLGN6NLNQZg7ZypcF5Q5WNWxluJOeEz3D3NrO Rv2Lz13o/OX2TEbfylE//7xFsDremy549WchEUioOm+v7Yb3yAFgORgrcnF+yV1cINll aqIkfzX4fsOpcgYDpqxTBY4FrYt37gDKLF/ghDl4dhVQmkXFeksLQBdhixKCRcdT5bfN 6zUKsHDazZIlUFhw8Q9/m0/KNXPJtyT0BeFtio+B0tCSsJbN99zXrQbwpSPslPBMoMou FNJg== X-Gm-Message-State: AN3rC/4rQGsvr10kVryzSBO7ahNvWlVEs6r9uBMkQezB5UsRiPuFQ+/8 WvLPf118Jh9L09CU 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170418_113340_467733_A206B22E X-CRM114-Status: GOOD ( 11.18 ) 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, 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 --- 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; +}