Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp399738ybz; Fri, 1 May 2020 00:45:22 -0700 (PDT) X-Google-Smtp-Source: APiQypLTk2JKecMrfMbfiUKwS5WN6fE+61gKpwWb/SdEPE7oFQLiU0fYf2jN7Y3sDAiLW+rFzhBb X-Received: by 2002:a50:e8c1:: with SMTP id l1mr2476184edn.81.1588319122597; Fri, 01 May 2020 00:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588319122; cv=none; d=google.com; s=arc-20160816; b=FD3q+OYag8MYQPNqqvqGgB5jtq5QEg4XxrPqaCc2orFN7+OyMV5ZPgvN5V8DVJgpFt uyrG+dWKIZpGCAa1CCXixUa9pmsBXikzMoQUtoj21iQKI0d8Z07MGmHXqAoFSYdbTfiC E8ojyP7ypqP1KSnM3hxfF8hHY1MHAebroeKHtSxO+2zXP3yLzrXDAVjNCC5iQIeX+XRC TzB139ZLGPPYV/CivkSv1G4KWFYJ2ALBjVeqNCfOQstwZ0SfjQtbafUuagaCFr37OkKu 40NhkZayRDJRTyM8kISoEnKTSVgAUXltFiDJ/oavedEGNwsWGeoaB+T5G2anmaRr4RnA KUTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=LuIJ4evjChWTEecZDzXypdkobP2PBIuJZpqJbT6OYkJ3krupEeSVC2Lofmgdv55LXu N/2lrDI3cLom6/VRCa8t2kEETPX//fnrtDPmwVyjvjyhLj7wDhl5d6nbkeSq533DXtsc aRKppghZ44n08VVOz7sDcYXMJZQ6LOePb5WMdSVwm1Hf7uajBEolWUhKz9KZGSOWWTqZ 1L5V4OE/jPrun2nEb4/rmNXU0Zc1WwAZsrbhCKfHcmvh+IVnvpbwx4A5OkksFatFaNWu 8KuZ/Lnm6YOJs64h9Gdhm20W9Yw8rMchXu982wCte+oqmNwa+IR03b6A1UtQe/SZEP5i LqTQ== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba9si1251159edb.114.2020.05.01.00.44.59; Fri, 01 May 2020 00:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d7DrWM7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728376AbgEAHkN (ORCPT + 99 others); Fri, 1 May 2020 03:40:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728348AbgEAHkL (ORCPT ); Fri, 1 May 2020 03:40:11 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A574CC035495 for ; Fri, 1 May 2020 00:40:10 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id y6so2028595pjc.4 for ; Fri, 01 May 2020 00:40:10 -0700 (PDT) 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=mXjVBljaWoaHjEZsF9OW0ithNNs5qvOhiS+zZ6LZYHAxyvSunJdKuzyjzuNpa4uy+N 9sBWF8dRvXylG6BQ69m4Y8kEiqvNXyUWo2wyuhMtkGKD8JXJgISCOhT5Iwy6M8aeD3bj JXWnIj/fpoJjoDEbHjc/qCLvwamHPIBdWwqElu35mtJcxXq8mvnDATthlV4sbInhoLpq b6yTDjBWyQDet+zF+6OS4r+ePLRbLBFZCbwqdWKr9IxY5G4Oi8zKIN0VJ4TQg7GH6pVP N62xM1PL0Hi6F6sVvXP7hZE5roRYYLlTTrBT2AJjVC0SJH/qMiXbrcHTvAYl6To6/hZp 6Vhg== X-Gm-Message-State: AGi0PubcM+4oji1OyTG8VAf7hksn9uj8+a40Mwoof0AGBZ0R6u/Wql/u j7pmOOUz+oa3eJN3v73w6QTq6LLfawo= X-Received: by 2002:a17:90a:3ace:: with SMTP id b72mr3264947pjc.48.1588318809841; Fri, 01 May 2020 00:40:09 -0700 (PDT) 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) 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"); -- 2.17.1