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: 9660455 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 5ED466032D for ; Mon, 3 Apr 2017 19:38:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F8A0284D6 for ; Mon, 3 Apr 2017 19:38:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44141284D9; Mon, 3 Apr 2017 19:38:00 +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 D6124284D6 for ; Mon, 3 Apr 2017 19:37:59 +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=fWE8sl9v+rl/Tu0A7p7EjFCXJL YDQM+0h6Axs+TTsjQfJpSfmeD0N7d4Qx3EtygJOndXVIR+NPgLNS3VCh/PTQ2+Wxtpy3Ss4loztxm NQP1fkbiSocDFNPVl3/mmTsJ0r6mAD6IGoa5Ewaq27xPcl1jcufqj1DiojeosfdYFdIbpCSWguMUn 6ST4GAH17aKYYJzKFe/Csv+GSCSqcgq3isVcHtHV1RoHFe3Nzg1SgJn31Jd5nHMetxKDq+u92ipUg XUGHp71mW6jNotTe4POR6vMmP9sUexD99QW/90Im9U6pgxkK7CwQ9LH8gaYXouYZruxPz2bRKBGIz fvQIDrAA==; 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 1cv7na-0003mn-3w; Mon, 03 Apr 2017 19:37:58 +0000 Received: from mail-qk0-f172.google.com ([209.85.220.172]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cv7IC-0003Pm-Nj for linux-arm-kernel@lists.infradead.org; Mon, 03 Apr 2017 19:05:45 +0000 Received: by mail-qk0-f172.google.com with SMTP id h67so24353905qke.0 for ; Mon, 03 Apr 2017 12:05:12 -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=XcNAgDv63NbpjXeXZkKo/u+xOmEuWKV7ORzgUDL5FRvwOY+0s+PZNEqlwXlYv/GKFA p1TDxihB646Eyft1bblFdv2MJUfc8VDd9Rkbzcpbj2qfmv8U+bldvPcz/NMgnxIkZZN5 KkiZApxtUblGk2Rf9LYrELIuGdWuVlc/uYZyXe26Drp7n8RsmFKn8zq7MGNUUoY7irTV pNgs2N/D/uznw2uixZNiJLF8gh+YF/si/KC877yS9RNLxqZ0wBRwGmfuSeakzRDybTT8 Sh0a8NqNqhWe8y9K/aA7CHhme+HHvdktXaKDMhg9FqH55OzdRp0sVwfNSQKUqglYQ0+9 gEqA== X-Gm-Message-State: AFeK/H0ckcqE7FC80msZYKyEWhG4uU32O319TDAQu2pvfW8yNDC3Jbf9A/lAVeUH8iWtRROx 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170403_120533_140368_09110E09 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, 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 , 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; +}