From patchwork Fri Oct 25 23:48:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11213237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 840CB112C for ; Fri, 25 Oct 2019 23:48:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 693CC21D7F for ; Fri, 25 Oct 2019 23:48:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 693CC21D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 989ED6EBD0; Fri, 25 Oct 2019 23:48:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1175B6EBD6 for ; Fri, 25 Oct 2019 23:48:40 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id d22so2137527pll.7 for ; Fri, 25 Oct 2019 16:48:40 -0700 (PDT) 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=kpP5L5ZL9jr9Wuirrq/wpxNCtz1x33e9wP9JwvG83tE=; b=jqGImQDYM5FeOuvmIczApFFQNqmFJjmw+ES1cMaGr9NuphQdg1524lJ18ojwzazB31 kxitMC4rZ0d8fh+LS0YjVST5+E1iBDrAr770pQMDFrR4Ng/k0JC9NGb/D+gLwi6rv0qM rAyqlDJChZrjsXuPab/VvO/sSfP+OT0fecGWZ7bhQpm7An2ehE0dRtcZuB0HMN5/UoHA E8tGCeLQ6sNrM6ux5qSAQRjSQgo96CUmL2JFI/71nm+SJIVT5zssl5BE1cWoJBv+1+l+ EjbhfCCynSyq3q4NjAu3B4u5fECgTaX7dkciLZRBZLehzaV4LMACxlCuJBYkuvgk0cHj UCZA== X-Gm-Message-State: APjAAAVNRFQi27/ULx1Jo3v+M4CUh0uCnNoCqymEUsTK4AuhUrbU6d+c 2BVBkJk6z1fCeYXiCaUdBYObqA== X-Google-Smtp-Source: APXvYqychMWInYueDZ6EKJar8eyzhLNrYGYyX2Zp5f95/WM8Z4uN16jYK60waVFhNpHWeyYvjB4gmg== X-Received: by 2002:a17:902:aa07:: with SMTP id be7mr6818499plb.242.1572047319332; Fri, 25 Oct 2019 16:48:39 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id cx22sm2817179pjb.19.2019.10.25.16.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 16:48:38 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH 1/2] mm: cma: Export cma symbols for cma heap as a module Date: Fri, 25 Oct 2019 23:48:33 +0000 Message-Id: <20191025234834.28214-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191025234834.28214-1-john.stultz@linaro.org> References: <20191025234834.28214-1-john.stultz@linaro.org> X-Mailman-Original-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=kpP5L5ZL9jr9Wuirrq/wpxNCtz1x33e9wP9JwvG83tE=; b=aH+q1oJwle0nqOjUevAI2mb8wKUrtDhyNCymP6wx1Ejk2vXIr1dGQFtWul5+98jwl5 NO9Iy0gKcfG72k6QZO9qhdGo7LSYi0XtxBHzmFcp9Isx9v1/v6olIDuSiz8ZyEYNQEib ibY4cf3DmZZuXO/k7TCOxJOoVEUq1q9IGNs9O36Zv62yADhnhDv/ea+isimPR9ixiX0J S7AVKbruLRl+6+C5qP1BB4gA+aaGLy3wtcy1dJhqRG5Y7KeXR9sDkspCuLQZPbL0Am4L KYy8KYY6fS36vL5cyXVmwC9VUEPcZHQJ6gcR7JBqhiYKRIA0N07LPYw1nkLntijgcZZg s5/A== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandeep Patil , Mike Rapoport , Chenbo Feng , Alistair Strachan , Liam Mark , Yue Hu , dri-devel@lists.freedesktop.org, "Andrew F . Davis" , Hridya Valsaraju , Andrew Morton , Pratik Patel MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sandeep Patil Export cma_get_name, cma_alloc, cma_release, cma_for_each_area and dma_contiguous_default_area so that we can use these from the dmabuf cma heap when it is built as module. Cc: Laura Abbott Cc: Benjamin Gaignard Cc: Sumit Semwal Cc: Liam Mark Cc: Pratik Patel Cc: Brian Starkey Cc: Andrew F. Davis Cc: Andrew Morton Cc: Yue Hu Cc: Mike Rapoport Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: dri-devel@lists.freedesktop.org Signed-off-by: Sandeep Patil [jstultz: Rewrote commit message, added dma_contiguous_default_area to the set of exported symbols] Signed-off-by: John Stultz --- kernel/dma/contiguous.c | 1 + mm/cma.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 69cfb4345388..ff6cba63ea6f 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -31,6 +31,7 @@ #endif struct cma *dma_contiguous_default_area; +EXPORT_SYMBOL(dma_contiguous_default_area); /* * Default global CMA area size can be defined in kernel's .config. diff --git a/mm/cma.c b/mm/cma.c index 7fe0b8356775..db4642e58058 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ const char *cma_get_name(const struct cma *cma) { return cma->name ? cma->name : "(undefined)"; } +EXPORT_SYMBOL_GPL(cma_get_name); static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, unsigned int align_order) @@ -500,6 +502,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align, pr_debug("%s(): returned %p\n", __func__, page); return page; } +EXPORT_SYMBOL_GPL(cma_alloc); /** * cma_release() - release allocated pages @@ -533,6 +536,7 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count) return true; } +EXPORT_SYMBOL_GPL(cma_release); int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data) { @@ -547,3 +551,4 @@ int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data) return 0; } +EXPORT_SYMBOL_GPL(cma_for_each_area); From patchwork Fri Oct 25 23:48:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11213239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4894B13BD for ; Fri, 25 Oct 2019 23:48:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E30421D7F for ; Fri, 25 Oct 2019 23:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E30421D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C1086EBD4; Fri, 25 Oct 2019 23:48:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED1896EBD0 for ; Fri, 25 Oct 2019 23:48:41 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id 23so2595829pgk.3 for ; Fri, 25 Oct 2019 16:48:41 -0700 (PDT) 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=akimG7mgtSazW0Xv9weq5WdYsXvPJgD82qEofxZDZEo=; b=U20h8YxOk9LD3/jO+vM7PeM3WuGDqsKF9gSvgahp/paKWd31IvjwM0hjOI/6oGu9bP C9XW2S647S7YdOxsWAELVJvq5/twli3HsWiyK5y5mg+Bt5OY6wjQKCDftMZhB9cb44A4 xhthz4uId8liovW6OCh8GnLl5MJ7E3OflVMyntMsQikahQJDJFlV//r+ZbmaElaE2cdE 7y2+BjCKnaxFlQT0mwA6re9YuIsK4IUo56+V+cJGTU3M9yJ5ya805mdTj+ACkf3JH3js pIyXMIKECIn0Ve5mswwRAxqpmRWSmCE5iAgCF/N0XKtjtSqgjjqzn6Sc3IP7nvRLpwKn uKwg== X-Gm-Message-State: APjAAAX7oXKi3GmD6dTcyDoY2yeb353ukxyIfiEeytgxl9SMwZv8/Zj9 D+FvqdmWfk9SV/esX/cGIFfmAg== X-Google-Smtp-Source: APXvYqzFVpzIpCxoPgDb9KejO5rMTuJfOB/3/u6olhx9SqL/mVxNlO6qlClo1U0EarnNOG8lvUvjkg== X-Received: by 2002:a17:90a:d58f:: with SMTP id v15mr7476798pju.17.1572047320896; Fri, 25 Oct 2019 16:48:40 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id cx22sm2817179pjb.19.2019.10.25.16.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 16:48:40 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH 2/2] dma-buf: heaps: Allow system & cma heaps to be configured as a modules Date: Fri, 25 Oct 2019 23:48:34 +0000 Message-Id: <20191025234834.28214-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191025234834.28214-1-john.stultz@linaro.org> References: <20191025234834.28214-1-john.stultz@linaro.org> X-Mailman-Original-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=akimG7mgtSazW0Xv9weq5WdYsXvPJgD82qEofxZDZEo=; b=kYbg0nUp/PxzkjVrb1KGOJVPc1ih+UCUGjDKAgLLtvpaZ9Pp+/Q3cv4t0dB71G44aS 1wF3g90STc7JgIzQVNFd2OT47TMuSNGhWq6p3nERUIVHd5+QBDoi779pCYC6SDgp24GO WPFPM2iiqEYEZem9oWs2cJTf8hNVxEWG4h3ruJZzab15rfukexYiWFkNqjiorjlihRVj VcKekKIMo2nCLNOYMa8cqJA9lIn7e/RWWLtB65doGIXpH4JFEeeqg+ua2yA7dmZatZzj xh4go74AhdfigrguMdEtk2DgBS+XrR+zbHEJPdNUFIuJft1as404b2m+OKIUe0iRozLD UMew== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandeep Patil , Mike Rapoport , Chenbo Feng , Alistair Strachan , Liam Mark , Yue Hu , dri-devel@lists.freedesktop.org, "Andrew F . Davis" , Hridya Valsaraju , Andrew Morton , Pratik Patel MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Allow loading system and cma heap as a module instead of just as a statically built in heap. Since there isn't a good mechanism for dmabuf lifetime tracking it isn't safe to allow the heap drivers to be unloaded, so these drivers do not implement any module unloading functionality and will show up in lsmod as "[permanent]". This patch also exports key functions from dmabuf heaps core and the heap helper functions so they can be accessed by the module. Cc: Laura Abbott Cc: Benjamin Gaignard Cc: Sumit Semwal Cc: Liam Mark Cc: Pratik Patel Cc: Brian Starkey Cc: Andrew F. Davis Cc: Andrew Morton Cc: Yue Hu Cc: Mike Rapoport Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/dma-buf/dma-heap.c | 2 ++ drivers/dma-buf/heaps/Kconfig | 4 ++-- drivers/dma-buf/heaps/heap-helpers.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 9a41b73e54b4..2c4ac71a715b 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -161,6 +161,7 @@ void *dma_heap_get_drvdata(struct dma_heap *heap) { return heap->priv; } +EXPORT_SYMBOL_GPL(dma_heap_get_drvdata); struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) { @@ -243,6 +244,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) kfree(heap); return err_ret; } +EXPORT_SYMBOL_GPL(dma_heap_add); static char *dma_heap_devnode(struct device *dev, umode_t *mode) { diff --git a/drivers/dma-buf/heaps/Kconfig b/drivers/dma-buf/heaps/Kconfig index a5eef06c4226..e273fb18feca 100644 --- a/drivers/dma-buf/heaps/Kconfig +++ b/drivers/dma-buf/heaps/Kconfig @@ -1,12 +1,12 @@ config DMABUF_HEAPS_SYSTEM - bool "DMA-BUF System Heap" + tristate "DMA-BUF System Heap" depends on DMABUF_HEAPS help Choose this option to enable the system dmabuf heap. The system heap is backed by pages from the buddy allocator. If in doubt, say Y. config DMABUF_HEAPS_CMA - bool "DMA-BUF CMA Heap" + tristate "DMA-BUF CMA Heap" depends on DMABUF_HEAPS && DMA_CMA help Choose this option to enable dma-buf CMA heap. This heap is backed diff --git a/drivers/dma-buf/heaps/heap-helpers.c b/drivers/dma-buf/heaps/heap-helpers.c index 750bef4e902d..fb9835126893 100644 --- a/drivers/dma-buf/heaps/heap-helpers.c +++ b/drivers/dma-buf/heaps/heap-helpers.c @@ -24,6 +24,7 @@ void init_heap_helper_buffer(struct heap_helper_buffer *buffer, INIT_LIST_HEAD(&buffer->attachments); buffer->free = free; } +EXPORT_SYMBOL_GPL(init_heap_helper_buffer); struct dma_buf *heap_helper_export_dmabuf(struct heap_helper_buffer *buffer, int fd_flags) @@ -37,6 +38,7 @@ struct dma_buf *heap_helper_export_dmabuf(struct heap_helper_buffer *buffer, return dma_buf_export(&exp_info); } +EXPORT_SYMBOL_GPL(heap_helper_export_dmabuf); static void *dma_heap_map_kernel(struct heap_helper_buffer *buffer) {