From patchwork Thu Mar 2 21:44:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9601641 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 35C3660453 for ; Thu, 2 Mar 2017 21:46:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2605F285F8 for ; Thu, 2 Mar 2017 21:46:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AAF0285FC; Thu, 2 Mar 2017 21:46:36 +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=unavailable 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 AEFA9285F8 for ; Thu, 2 Mar 2017 21:46:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752044AbdCBVph (ORCPT ); Thu, 2 Mar 2017 16:45:37 -0500 Received: from mail-qk0-f173.google.com ([209.85.220.173]:32926 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975AbdCBVp1 (ORCPT ); Thu, 2 Mar 2017 16:45:27 -0500 Received: by mail-qk0-f173.google.com with SMTP id n127so147111941qkf.0 for ; Thu, 02 Mar 2017 13:45:21 -0800 (PST) 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=a+DAnUtfIrZni97hD7/D6q4I9BVBanj6ojOYeHDzLLQ=; b=theIkcppRcpcdV5MFKkMkjpSKgXhwe5JA45Cdc2nL4fVvrmynfwsuUqSXZG6SHgFje LMFhchk4LGSr3PBRppC20Y/d86hqDAljuOluxxYw6Wti9ADpd2PsDtrKevXlibzTzE37 cJiyiw40iKe/axQAbCK/2TgrV59sykh6xvaWQRHSJeGbrxKYWHd50DEy1Z4TLComshHu 42DTJxpOqUTvx/FPJ3qD448RVFwdW3kdoZcKwsZpXZGYKE5qGJsuA+OMr94grUgIWH8p 84lvuQY5H8x8h4/lpvnyZZVDo+eFuRvffjT4FMDKWhUGK4fdShdMjKWA2T1jebn7KUUC Wqcg== X-Gm-Message-State: AMke39lhLyEDpaxbD0FlcLPKyhL+QpFVl//qSkV0dX/drY4CSBTWfKM9lVM1NUWJbl6UnGaN X-Received: by 10.55.7.138 with SMTP id 132mr20836159qkh.114.1488491120914; Thu, 02 Mar 2017 13:45:20 -0800 (PST) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc::5ce7]) by smtp.gmail.com with ESMTPSA id r10sm6261671qte.1.2017.03.02.13.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 13:45:19 -0800 (PST) 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 Subject: [RFC PATCH 09/12] cma: Introduce cma_for_each_area Date: Thu, 2 Mar 2017 13:44:41 -0800 Message-Id: <1488491084-17252-10-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488491084-17252-1-git-send-email-labbott@redhat.com> References: <1488491084-17252-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 --- 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 49f98ea..b521e3c 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -33,4 +33,6 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, struct cma **res_cma); extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align); 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 4a93d2b..a430df0 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -464,3 +464,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; +}