From patchwork Fri Jul 17 01:10:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 235663 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1273198ilg; Thu, 16 Jul 2020 18:10:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySx0iMcxR9EW8TxIDgAeisDzRg5F4vYL2g9hpKHrtvCmcotX4+g+CvspbYlwddEeWiYzK3 X-Received: by 2002:a05:6402:6c4:: with SMTP id n4mr7219720edy.353.1594948226060; Thu, 16 Jul 2020 18:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594948226; cv=none; d=google.com; s=arc-20160816; b=Hjvo3zLYhZ0Q6JjGVrXvlS1aAyl+Z3hYZ/R7vGRD7l8+RaL6EugQRVCn5hftsFs76P RsVBe1lmRFOd5TQww9XNLhASFRxOTZlEFXy+rgK0w9oXJcTDrd2x2l7l0oVKo+wwhIy7 qlvu4dJUxbyCO3+FTw+4Maj4qA8v9ItmLOGn9IcIqRx6laSORutTNu08JB3ijEWEnIBt Qi/rKLNxEQ7zdxsGd0DWRE5bVJXMxouhzVr7S3svXxMep6PUMZLKLFJb7etp7AMbOmeE fFFuZNO/ryainM5aCE21gyV33veIv7JVzvLCgybePI9IIkH0yyrrtG1zuwiLuFHGKmtv VGXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=r+NiO0vOLKHN54DPGnVsRvgbk0hISFEsYWq+vQj5wj8=; b=joU15swwSyDpH+BV9jX4F3MSIh27Q4ufHH/zoGcOHHesfNQHBziP8QRI4YNzomYd0G TYUA7I2PTb2MB+YXsn7E1QnmUeNKESg5dpoIBrJ5lTCaGmY6vB4JgAckWQUD98Ti71vZ MplZH+Le2xHdh0FXimExFJ2mRfqZXxeHmQofO5nMSgJDMzpD7L0zzrjhx70xNInBv8gO 3b4dNdDmSW80qcsdsgqKQtAlPcyIojWi+2Q5MohIQN8ZsChB5GfURys9v3kAcP+YWZo7 9DoYGdV2USkVWBK4yt8DUreg7QxgLlKMVUopZoYZUXpFqNjPPUPFlc8efYgaThzauzAd y1zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si4154315ejr.359.2020.07.16.18.10.25; Thu, 16 Jul 2020 18:10:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726636AbgGQBKW (ORCPT + 4 others); Thu, 16 Jul 2020 21:10:22 -0400 Received: from mx.socionext.com ([202.248.49.38]:6309 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726394AbgGQBKV (ORCPT ); Thu, 16 Jul 2020 21:10:21 -0400 Received: from unknown (HELO kinkan-ex.css.socionext.com) ([172.31.9.52]) by mx.socionext.com with ESMTP; 17 Jul 2020 10:10:19 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by kinkan-ex.css.socionext.com (Postfix) with ESMTP id 9C3A3180117; Fri, 17 Jul 2020 10:10:18 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Fri, 17 Jul 2020 10:10:18 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 3A0A61A0509; Fri, 17 Jul 2020 10:10:18 +0900 (JST) From: Kunihiko Hayashi To: Sumit Semwal , "Andrew F . Davis" , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , Christian Koenig Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, Kunihiko Hayashi Subject: [PATCH] dma-buf: heaps: Introduce dma_heap_add_cma() for non-default CMA heap Date: Fri, 17 Jul 2020 10:10:08 +0900 Message-Id: <1594948208-4739-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Current dma-buf heaps can handle only default CMA. This introduces dma_heap_add_cma() function to attach CMA heaps that belongs to a device. At first, the driver calls of_reserved_mem_device_init() to set memory-region property associated with reserved-memory defined as CMA to the device. And when the driver calls this dma_heap_add_cma(), the CMA will be added to dma-buf heaps. For example, prepare CMA node named "linux,cma@10000000" and specify the node for memory-region property. After the above calls in the driver, a device file "/dev/dma_heap/linux,cma@10000000" associated with the CMA become available as dma-buf heaps. Signed-off-by: Kunihiko Hayashi --- drivers/dma-buf/heaps/cma_heap.c | 12 ++++++++++++ include/linux/dma-heap.h | 9 +++++++++ 2 files changed, 21 insertions(+) -- 2.7.4 diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 626cf7f..5d2442e 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -162,6 +162,18 @@ static int __add_cma_heap(struct cma *cma, void *data) return 0; } +/* add device CMA heap to dmabuf heaps */ +int dma_heap_add_cma(struct device *dev) +{ + struct cma *cma = dev_get_cma_area(dev); + + if (!cma) + return -ENOMEM; + + return __add_cma_heap(cma, NULL); +} +EXPORT_SYMBOL_GPL(dma_heap_add_cma); + static int add_default_cma_heap(void) { struct cma *default_cma = dev_get_cma_area(NULL); diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h index 454e354..16bec7d 100644 --- a/include/linux/dma-heap.h +++ b/include/linux/dma-heap.h @@ -56,4 +56,13 @@ void *dma_heap_get_drvdata(struct dma_heap *heap); */ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info); +#ifdef CONFIG_DMABUF_HEAPS_CMA +/** + * dma_heap_add_cma - adds a device CMA heap to dmabuf heaps + * @dev: device with a CMA heap to register + */ +int dma_heap_add_cma(struct device *dev); + +#endif /* CONFIG_DMABUF_HEAPS_CMA */ + #endif /* _DMA_HEAPS_H */