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: 177800 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp223311ill; Fri, 25 Oct 2019 16:48:41 -0700 (PDT) X-Received: by 2002:a63:1c03:: with SMTP id c3mr7254427pgc.198.1572047321357; Fri, 25 Oct 2019 16:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572047321; cv=none; d=google.com; s=arc-20160816; b=KGJv8gU+V8D55giOw2AYb3k6pBwVNHHBcrszRkRHqZNgZEc/ywX4SYz9J9flM2VEoN YSVkXZKrUmICqhBM2hFqkfd/QluYmuBamAmrfUvw4K9vyHLkk++U4pTEj4IfjDVH/Fvn 4PcMdCB+QWNUhVLCzGgXIfbuO+jcYzL3Zq/Fu6o0zY/RLEtEk6LVMMgEqumT+ZiODbdY CUO6FeGrLY/7rNncm0nECSQrA4q1F6Z1uBMaDqKxWyKnCgPN6SQ2CK6/YTmVPsEj+zYf N6ODzpThfeYNA5mxF+hNHEQnwpGqVX234IGLCZv2dY56vIDn5LehH7yAaXi0xZ4tqAbn 4ZmA== 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=akimG7mgtSazW0Xv9weq5WdYsXvPJgD82qEofxZDZEo=; b=HhYi1QaFXz++b7mRUTqPFt52SWgugmz3WGiewaBfvd/LFxAUFmCQQaiy7WPxIs+ux0 Yi9u88ERZuWL1AYBjo4uT2D4V+3qzr428lpKPhl/rLhQZwtPPLYS/hMDcjJ1MzQDekJk DD+HiPNMjmOfTsCHsJu243LpBDVZ+jMeorMhC2JWuxmKO6JKfv1C6HqY9kwtz2w/TNrm zJ6m2UHMSVsX9G63ZbdiyOCOPzEVA/C7dPfxwuHj9A0BCxXefASrxK8Pegf6aDmy7Rsn LuoZWgK1ewScjHy/V4baP6SJkxeAnKaEYJrKAi/BAQjnRqUTjUKR35yhoup5fax+HMsL yDbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kYbg0nUp; 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 4sor9100916pjj.1.2019.10.25.16.48.41 for (Google Transport Security); Fri, 25 Oct 2019 16:48:41 -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=kYbg0nUp; 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=akimG7mgtSazW0Xv9weq5WdYsXvPJgD82qEofxZDZEo=; b=kYbg0nUp/PxzkjVrb1KGOJVPc1ih+UCUGjDKAgLLtvpaZ9Pp+/Q3cv4t0dB71G44aS 1wF3g90STc7JgIzQVNFd2OT47TMuSNGhWq6p3nERUIVHd5+QBDoi779pCYC6SDgp24GO WPFPM2iiqEYEZem9oWs2cJTf8hNVxEWG4h3ruJZzab15rfukexYiWFkNqjiorjlihRVj VcKekKIMo2nCLNOYMa8cqJA9lIn7e/RWWLtB65doGIXpH4JFEeeqg+ua2yA7dmZatZzj xh4go74AhdfigrguMdEtk2DgBS+XrR+zbHEJPdNUFIuJft1as404b2m+OKIUe0iRozLD UMew== 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=SFJicCqe08xchmBnxbZXeT0TIUxF27GvyYv2gz3aUTX+txVly2j1eb6ZUTDo6RcFAc oRPEdwWct0VTi1VGqfc8TaAW3uiqSPkmlNnFvt0Xdj+atxDyDHSyPv/wrGIl/FDZpa+j JGLQw1GjHCzOArI3h4yjyVMB37yAORZJ9YLN8B+HUFKr/muhaVidrbeFVW5Xq00xof7E 5Bsq23rJgcRzr0WJk8QIDoPH8o3DnZB+Vsw1dfGugeghztTkQx1clZRMX2670I9Pb3YJ b8F6VZgyz5gdr3+m6hazxRXSxnOSArrdAIHhW5ZtQ2iPGIqszxoZV2N3RewSzSzb5p+R xKTw== X-Gm-Message-State: APjAAAVAwwNGyyPweIatvEpcN8BiPH0O0zOVtg6pTuCp8FSNZVr1r6pg VzStIcn0+TDadG29dqxEscdqVpnh 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) Return-Path: 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 Cc: John Stultz , Laura Abbott , Benjamin Gaignard , Sumit Semwal , Liam Mark , Pratik Patel , Brian Starkey , "Andrew F . Davis" , Andrew Morton , Yue Hu , Mike Rapoport , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , dri-devel@lists.freedesktop.org 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> 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(-) -- 2.17.1 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) {