From patchwork Fri May 1 07:39:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 186020 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp284870ilf; Fri, 1 May 2020 00:40:10 -0700 (PDT) X-Received: by 2002:a17:90a:24a7:: with SMTP id i36mr3247285pje.32.1588318810278; Fri, 01 May 2020 00:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318810; cv=none; d=google.com; s=arc-20160816; b=zzZI40eiHGhOdS9J/5+ifSIORhz52wL/xkEJL96XltrIZueIG5J26M/17bK/RFIlF6 i8j7pWdjAVidzFwQL49x/AY5i3fHsAtKPRZ8dOoET+VUkXnOWAftupkUDq+lp4LP+jOu 1T1FZGIrpocZcBe6jwoG30Je9xH+QM5bZy87dAZVwIHXFbAXu13UB3JyIweBH7jvVqb+ 1058cBrh14GAgU6LXoz1qGClZY1np+NkHk8t2jRO0uyPuEJ8AcRmwMBYaWmpYdVmIJgS djQpFrqzbo19vF9hsKTrM8DBzuq6cR6n4tI1OLbPZtyLAOubPpcSuyglS1l13Bx1hAjR a08w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=z0MGAsaHMfSt4fsIlizBWM2ysnX+7EXFKjOvuFkpiTVedUAbPMJyGnYdKrdPCHwopI AHKkuWhAmcfMziBZmz9is81GhXyYcjVMFkTvNqFOl+QfPvcOoz+b2QvtwX+N7mw0VyLL sV38n6MioXFsvEdkNE4uuzLINyYOiKZLuND5GfXTxNeoQQAXMqZFL64v9FXHE5ECN6jV NssEVGTfb4tygHbvGZa8LY6JlPtf2KdX3k969YuYMb+tlx7dBxpkxAj/HRLv56BcIFVJ Zq0rBcYInpAtqEyyTZQHinQ3hVgFK0onu1hqzrw8CNEe91R8t1ON/lD/NgBXVIkOtpFj 6rlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d7DrWM7P; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id cx11sor2715678pjb.24.2020.05.01.00.40.10 for (Google Transport Security); Fri, 01 May 2020 00:40:10 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d7DrWM7P; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=d7DrWM7Pg1LzeLY9hTHX3Vu6bzl5opKrCH2QlCTt6Jrx2Kf5gZhk+v6vTLU6f+ULz2 PTiPKHZARFJ6lrB3W3f9Ywxqo6KsLZQ/vb3d1Tw5dk54Ht4in1nQE5s/8lPxhYRC9x1a D6edusf8njClbUpHSkZBebx7PTMR1SOSvH/r7MaZr6myG/iAla1rNjPRCW6OW+XNQIHt OmRiF3MrZcOxTbSbEdUqOK7VqTixWGAKbO/x12boCmXJ9u9lBV04xM/B/YgAAbeVKoUN UGDdZTWUZA10VOkmyzHXDnEI1gjDagbffVyU61Fe1nwJg3me3bJZ6FbrIMvJuUZ+dixf BcUw== 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=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=o80qw7Cd8tI9i1AR8s+c1RgHUjJvIyjfcqp3RVughP9RazrSSKE3XaPKTRPMCMtRlR AD0BuW0tBVHO5Kjp0Wp+eLapLDoSTPUd4g6ZOALR8gpg0BW/X5J/5Fczsgx2AfW2Df6J 89KiXefFBRxB1OsaplHqweD0cGhHy2+mu2o2KejmcRA4wjtyR/sPyRb/63p2XPKqmNQd HWdjq9Rr2wxfevZ9aDwOO6uMmxaz3QF55IC2wWqdnxDQnGHLJuVYs+SO4yv5HkY9DMFD UHKMLfjZlA+e6hxljQg9mGDaV1xvvVqWCcubHHvEbH1ln9mH67Z2oZujgkfxJxFNiXT/ lwBQ== X-Gm-Message-State: AGi0PuYFuuESR83eJGqDZ7EDfBcNBg+m9SYCudB44vMzhDmOi3dZM7/V 9WLDPi8h5oc8YFnDOQdDqEXCsV6+ X-Google-Smtp-Source: APiQypJiEJ4kQAfPAoSZcmNCfZQu1/ZpRWQas3IjFCF2RyIzmyY+jFIehrdb4AljNbKemje+OfRRHA== X-Received: by 2002:a17:90a:3ace:: with SMTP id b72mr3264947pjc.48.1588318809841; Fri, 01 May 2020 00:40:09 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id w12sm1557841pfq.133.2020.05.01.00.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:40:09 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Brian Starkey , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org Subject: [RFC][PATCH 3/4] dma-buf: cma_heap: Extend logic to export CMA regions tagged with "linux, cma-heap" Date: Fri, 1 May 2020 07:39:48 +0000 Message-Id: <20200501073949.120396-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501073949.120396-1-john.stultz@linaro.org> References: <20200501073949.120396-1-john.stultz@linaro.org> This patch reworks the cma_heap initialization so that we expose both the default CMA region and any CMA regions tagged with "linux,cma-heap" in the device-tree. Cc: Rob Herring Cc: Sumit Semwal Cc: "Andrew F. Davis" Cc: Benjamin Gaignard Cc: Liam Mark Cc: Pratik Patel Cc: Laura Abbott Cc: Brian Starkey Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Andrew Morton Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Signed-off-by: John Stultz --- drivers/dma-buf/heaps/cma_heap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 626cf7fd033a..dd154e2db101 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -141,6 +141,11 @@ static int __add_cma_heap(struct cma *cma, void *data) { struct cma_heap *cma_heap; struct dma_heap_export_info exp_info; + struct cma *default_cma = dev_get_cma_area(NULL); + + /* We only add the default heap and explicitly tagged heaps */ + if (cma != default_cma && !cma_dma_heap_enabled(cma)) + return 0; cma_heap = kzalloc(sizeof(*cma_heap), GFP_KERNEL); if (!cma_heap) @@ -162,16 +167,11 @@ static int __add_cma_heap(struct cma *cma, void *data) return 0; } -static int add_default_cma_heap(void) +static int cma_heaps_init(void) { - struct cma *default_cma = dev_get_cma_area(NULL); - int ret = 0; - - if (default_cma) - ret = __add_cma_heap(default_cma, NULL); - - return ret; + cma_for_each_area(__add_cma_heap, NULL); + return 0; } -module_init(add_default_cma_heap); +module_init(cma_heaps_init); MODULE_DESCRIPTION("DMA-BUF CMA Heap"); MODULE_LICENSE("GPL v2");