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: 177799 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp223279ill; Fri, 25 Oct 2019 16:48:40 -0700 (PDT) X-Received: by 2002:a17:90a:234c:: with SMTP id f70mr7220468pje.109.1572047319958; Fri, 25 Oct 2019 16:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572047319; cv=none; d=google.com; s=arc-20160816; b=HQMCq7xHH1LG1/gFuzUh5+JJ+ayGkOv0w+c7FWSRUFTDtHCShbDBeXwld+AchCfNAP +dW3dPE8PvR1jLbmGB50YCcXSamNyKC7gfGXiAxCw57hJgYVpXZVevieboc8t39tJ/Ch PXcCfrOmf7y3hPrqxkx18/SkjaPD03ZK1PsmdtzcWCcVrylulsG+tAQQikPL8BmxQJO4 eYeiFaWIvDMp88zSmyHOJe2In044hCVJY9jxc6HIQI3u1s+2KrI0HtGahMTX17eu/894 20KMU3qcuvLVvCI3n+V2Dwg5Fm3wdxhdRmPl1P7PCJGzkDfkFK/s848yAiJV3HVq0Zhl 6yQA== 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=kpP5L5ZL9jr9Wuirrq/wpxNCtz1x33e9wP9JwvG83tE=; b=AHTHYupfBKurAWR4fRCI5UwmDpbakdt4WE0lPFMf8CtLh8pVuXZGJoTdkrlZRaCxbK Nd26P2V3q1jRzH7wOlm14+FxUFxscQE7OjrApd4+NIA18h1OkdvRJn23G9NIeKU4zpEd 2L/UpbnaIumpqVTPmBxYKK8fGDOwcHF/7QmxKlTivRhiTy0p8hbyA2N7a3iiiPv3pY7R k6dpw54GMtG+22zTsMonIpTbTePDlK+UHbT+KNHqzbkvvvJtrSqgHrsmsIsXWpiNynZP gAko8I84p1nzqOjYGr6F51yEmkhlOXMve4q3+O6cobOs0cka2R5OUkLdmCZt3CSYE5rP wFQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aH+q1oJw; 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 f4sor4905251pln.60.2019.10.25.16.48.39 for (Google Transport Security); Fri, 25 Oct 2019 16:48:39 -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=aH+q1oJw; 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=kpP5L5ZL9jr9Wuirrq/wpxNCtz1x33e9wP9JwvG83tE=; b=aH+q1oJwle0nqOjUevAI2mb8wKUrtDhyNCymP6wx1Ejk2vXIr1dGQFtWul5+98jwl5 NO9Iy0gKcfG72k6QZO9qhdGo7LSYi0XtxBHzmFcp9Isx9v1/v6olIDuSiz8ZyEYNQEib ibY4cf3DmZZuXO/k7TCOxJOoVEUq1q9IGNs9O36Zv62yADhnhDv/ea+isimPR9ixiX0J S7AVKbruLRl+6+C5qP1BB4gA+aaGLy3wtcy1dJhqRG5Y7KeXR9sDkspCuLQZPbL0Am4L KYy8KYY6fS36vL5cyXVmwC9VUEPcZHQJ6gcR7JBqhiYKRIA0N07LPYw1nkLntijgcZZg s5/A== 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=k/kSUeDxFN0vJExINSPhUdvZtOtdVK7oV9nQEQh4CL2fYPZUYEKtZFTo3tyZrfs0M9 VPqNi+PIEm8dwJgGTPSi1U9l2CzTwCPH666ejJ70pMwGALDzwxOz+wfYWfylTXYiGWMf GnpGb9U+yUnp0CdH9HPpiEe9MvYoI1XVVubSokfepZnX5PW+LrO2+ljJYc/ct5/W+gvW JH0iLJm1aHSzJWUGfnLcUeMePDoQFUh9jQyHKTITokpZbCPev3bAJoN1wOGO0+ql3TlZ UzJPXFQHA9dOavzJTpBdtLAvuOfIeCFdaJfZKHgQ/Zkm9/Fkj9OEGSEONjyJ9LKc0jXU JTWA== X-Gm-Message-State: APjAAAUcpJrlxYAwuX/+QwaVH+KykYKp28Z7YoVvbG8lqUpxj3gtwURm WRi6KwNZQFHyysDMwDqTTKNW8HLe 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) 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.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 Cc: Sandeep Patil , 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 , Hridya Valsaraju , dri-devel@lists.freedesktop.org, John Stultz 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> 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(+) -- 2.17.1 Acked-by: Sandeep Patil 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: 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) {