From patchwork Fri Oct 25 22:50:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 177796 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp168715ill; Fri, 25 Oct 2019 15:50:19 -0700 (PDT) X-Received: by 2002:a63:cf46:: with SMTP id b6mr7267969pgj.90.1572043818832; Fri, 25 Oct 2019 15:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572043818; cv=none; d=google.com; s=arc-20160816; b=TAwbB1ODxXI8YxoYF3RUd+/Sj+9aCkSyrkNzwh1NggypNESTZYY86G1gSr3QOHtn5j ryLNARZ+p2+kvGVqZn5XdaBR1huMtW0F8t4kYXUBh2lsk1OOml/acZUhZXZUX6GCA77l Al3JxbnAyvQnEzjVvEV7Vj4VOo7Ab7zfsfxuZUw5TXWiFVJdmsgJGSMB3WT6jtWFeg9J FwS6HJ1M9ZCYJa4dlQSks5gEqsktPZRdElx9yahDE8PRGzBHauC/Utr9kU/9atnYym4W Gq93/CUkSHqt0YoTNqtCH5yPqNG2m3SlGQ9ePaQC4PjjD34HZHXOWy8i+qjmZ2CU0N3p xz6w== 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=KxqkayFb7m9sYPELw0DxQ5VjRvj+WqO4uI8I+KYabjE=; b=lAfl+pJbn4O3OpHPTHpUf9VPxv/gFZSInC8LnNG5T6Lu4/6eXn5OnuJENt5XhKmIyY yQIldCyIi9IIcQ+FumW6pYCfDOH/mm3nia1Mb9B9zX4frtF0qgoBiDRb5o/iDhcvrpSU B3NKw6LhjvCcduwWmIL0Ia1bQbmGgOe/tNnhRWzuln2IzmR7NY1op0SmyHhEhLQOfr8/ zHqFCLrzSIoi9VuUKcmXpKuH5G3WRT7+XX0h2p6USCZZYL+KzHG9tG2HMqG4YdBERf+I 73VLmFZ/SXHZ0E1a94qnBemjCg8JGaBk/U5ae7iuFpOObrMcNEPiH5u7RlXMYZ1HtC4N sNzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YPNNxVZO; 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 a14sor3521234pgh.66.2019.10.25.15.50.18 for (Google Transport Security); Fri, 25 Oct 2019 15:50:18 -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=YPNNxVZO; 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=KxqkayFb7m9sYPELw0DxQ5VjRvj+WqO4uI8I+KYabjE=; b=YPNNxVZOZJlLKs7oXdvUCzvzCrltQPL8eWMoKdZWWv6dR9YRavL7O8GUrDdJN+aF1c NONSin6KYmGXn/ghUVTQuPQPS7fDeC0To+Axtws+gmTPLAZH8XKDibrwFAtn9aXa44zn z3R6iQ02U7OFyhYvs8GNx7UWmkS60YLobBM9GP1y/oHOBiWjS0KRzPNBiXLalgKt0/lk luVuTeAece9hd7my2vsqWp2iOIEILuRyhxB675rOPv/o+UmDNg2pK5vP4bAZ5+L+q3Bu EBPnMKcpO1TROkAZXERNtRg70QdVQbrEdXao1+P4SsHD5z1hkzgeGU7RNdmqeG+6JL4B pVhQ== 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=KxqkayFb7m9sYPELw0DxQ5VjRvj+WqO4uI8I+KYabjE=; b=JjNMNvlAawgIltR7CgNoIWQ3CHJTlsRUIubkxfPLCDN4xBgz8lJdR96smFWg+gTgJc lvHmemaH96e+5v2qPEl+/sjW3S4IDRS07WWjmQ4P/KAwQ28kPu8lL8ym1FvmmJgsWWAj L24RMdRQKSU7Nb7Oj6eacck3udRDH/0IvkFJtCIg+0dfFLkHXFzuY03YZ8t90sV9IQDE tyRdw/FUxXKXnlrpuMd8/NjfFOoAYocfCeMNDV9Vkz/FRIAgs2t0FT1RvxZdBsvhldT/ eNohs8vl3OM/allcPvz2awh87YybE4FrqFUCXtAv+IODc4C2KZQyO/Dvc7GPxCuDu/VM BCxA== X-Gm-Message-State: APjAAAXp/WbBvB6IoDllqGozHf6BjhqyStDrFmXBDNc/uJxF+IaCO3U9 T37fDM4py2YbBW8iyTvbQ4YtpJCP X-Google-Smtp-Source: APXvYqwH7FDeikwYbqOx/o7f38x/ORIOox29XW0WwLYwBPb50atXz5l+ZpfB/8ub7NnMSoQQiqTbow== X-Received: by 2002:a65:638a:: with SMTP id h10mr7136687pgv.388.1572043818363; Fri, 25 Oct 2019 15:50:18 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id o15sm2758018pjs.14.2019.10.25.15.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 15:50:17 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Rob Herring , Mark Rutland , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , "Andrew F . Davis" , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [RFC][PATCH 2/3] dma-buf: heaps: Allow adding specified non-default CMA heaps Date: Fri, 25 Oct 2019 22:50:08 +0000 Message-Id: <20191025225009.50305-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191025225009.50305-1-john.stultz@linaro.org> References: <20191025225009.50305-1-john.stultz@linaro.org> In earlier versions of the dmabuf CMA heap, we added all CMA areas as CMA heaps. Andrew noted this might not be desired, and so we changed the code to only add the default CMA area. This patch extends the earlier effort so that devices can specifiy which CMA areas they want to add as dmabuf heaps via DT, and we'll only add those. This allows multiple CMA areas to be exported via the dmabuf heaps interface. Cc: Rob Herring Cc: Mark Rutland Cc: Laura Abbott Cc: Benjamin Gaignard Cc: Sumit Semwal Cc: Liam Mark Cc: Pratik Patel Cc: Brian Starkey Cc: Andrew F. Davis Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/dma-buf/heaps/cma_heap.c | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 2.17.1 diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 064926b5d735..0d5231a1e561 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -174,5 +177,40 @@ static int add_default_cma_heap(void) return ret; } module_init(add_default_cma_heap); + +static int cma_heaps_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct cma *cma_area; + int ret; + + ret = of_reserved_mem_device_init_by_idx(&pdev->dev, np, 0); + if (ret) { + pr_err("Error %s(): of_reserved_mem_device_init_by_idx failed!\n", __func__); + return ret; + } + + cma_area = dev_get_cma_area(&pdev->dev); + if (cma_area) + ret = __add_cma_heap(cma_area, NULL); + + return ret; +} + +static const struct of_device_id cma_heap_dt_ids[] = { + { .compatible = "dmabuf-heap-cma" }, + {}, +}; +MODULE_DEVICE_TABLE(of, cma_heap_dt_ids); + +static struct platform_driver cma_heaps_driver = { + .driver = { + .name = "CMA Heaps", + .of_match_table = cma_heap_dt_ids, + }, + .probe = cma_heaps_probe, +}; + +module_platform_driver(cma_heaps_driver); MODULE_DESCRIPTION("DMA-BUF CMA Heap"); MODULE_LICENSE("GPL v2");