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) {