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: 9601681 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 CAF1960453 for ; Thu, 2 Mar 2017 21:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA6FE285EF for ; Thu, 2 Mar 2017 21:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF27B285FB; Thu, 2 Mar 2017 21:49:48 +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 540E8285EF for ; Thu, 2 Mar 2017 21:49:48 +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=W1heA5qTOhCmyWrVAEPviXkbWG1RINxZsMixvDsNt3I=; b=b9gsG06vLYtnOnnqEVVq45XdXC UdC6ohUh7kfayy5YMtgMHWa5Z9JjaOUu8I5klNKOIDEFJOP7Iosoxica/7v9N1FVulpjOiCVuEM99 59g8n4mfp1nHVlObHIQPw39afWIFLXfrsTOBkSG2l/P1q9kbzJKK2LV7/1leZ/dkCsaBLxDcXlDx1 JBJAjXyWH7WocLteUuHih4XyKJjmrF8/CLJlWXxEow60tBSCR3nPpOVFNMdIRlbvvEl2s6HBa2QOT OmGuYixm/qQrt468OXT+qbsKaS48OcxQ6t/gTjuQtstn/NkNY7HZ5rxcd1DRBMa9w7EYVpsQ27KX/ FkNZR80w==; 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 1cjYbb-0002fJ-KH; Thu, 02 Mar 2017 21:49:47 +0000 Received: from mail-qk0-f178.google.com ([209.85.220.178]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjYXd-0007sc-NI for linux-arm-kernel@lists.infradead.org; Thu, 02 Mar 2017 21:45:43 +0000 Received: by mail-qk0-f178.google.com with SMTP id s186so146630520qkb.1 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=eznq698Up03vGCA6Vel1EhoyZ4J4q+dc3N2OKtfLO5r0c40RTXDp+kzdWlNUB5IAUw Ef8UGy5Z5zVP8dPCFx7Q4SJ7aaOjEyyZP5tqq2KNlAP2/VkS/TCSTAe0xwpTqWRqt0zd KdO2fbrMrkiyGD+sZxWZXY2pygf2iCgLRkFYK95S5rGUp2IdN0ySSEAFvWGlKUZ/+48B 3GIj/oJeqgiUgSnPljyjiXkSoeyLapynf80okRtUuNTu6VdEB/9g5EBkv7g7gut1MTun Zr66P7hMZvZACADm7yGCWTl7SZjl7i2aEYvYec87+d/ADvuJkFTwzQ/RdhpQNIlE7Sdz q+jw== X-Gm-Message-State: AMke39madisInDhOxYcmY8RrAKmsnaOR7CzRJl4hWCxogvRNEOIzgCeAhtxPEpJFN+/ipLtg 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170302_134541_943596_047AF69E X-CRM114-Status: GOOD ( 10.12 ) 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 , 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 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; +}