From patchwork Fri May 1 07:39:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11522239 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 137341392 for ; Fri, 1 May 2020 07:40:07 +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 DBD7B2173E for ; Fri, 1 May 2020 07:40:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gMfRkU6y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBD7B2173E 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 5977F6EBA6; Fri, 1 May 2020 07:40:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by gabe.freedesktop.org (Postfix) with ESMTPS id E73E36EBA6 for ; Fri, 1 May 2020 07:40:03 +0000 (UTC) Received: by mail-pj1-x1041.google.com with SMTP id e6so2071098pjt.4 for ; Fri, 01 May 2020 00:40:03 -0700 (PDT) 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=NSH9BerjJoV88xjF7QVK1SklBZqxZKa42SGy8GT/SY0=; b=gMfRkU6y7H6ig9SB1voFB4Yprbz40Y65m2Mu8m2ApDv+jlMCQ2E6B9PMumov1+nGbF 45e9GP/a2A50GpZUNhd4HGTouy7LlSl5VzwQlUCMs1AXhJXwuMJcLarUGrUkRjxNS0+s CyzTAHjlmacCveMfha1bTwwkBCOPfUE7uuSPucD0Z+vxu1J/f4pWD34fBtGcMp6CN5j0 WMzgYCWeYRnk5hwW12qNNwjCMvrO4G4QzAW5V1SgWMWdDrFL1f6Szn68URsUfcJpdrLj vJQtM0xsiQq2qKPoVohGRHexTuBl0Itj2tNgGnXC3UD9PZdIeoJ518WZvDOK9dLvUKuk HzRg== 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=NSH9BerjJoV88xjF7QVK1SklBZqxZKa42SGy8GT/SY0=; b=WixncW8p6RUH7nP7X88/Wn1KLWVPuBkUmfbkKAudoKY9GLoYzSWQkMKD2WkG8gdPMf 4Tjrx47hn1RpEleaaw9ukPeIPmM05LxvV9M4pLqKuJWKWvKIPfKodVl7QGKkUV3oVob5 L+sDp3B0KSmBIU3nvKfVvNjC2nIG9UA3w2Oij4fe/arEgtSCW9r64TcWt2AdVE84hY7T IAbbmDmRID1VWJnsPxZOXJ36PqgoGOhhlmBZJYn+z3v06gQfPK3/X3hBXo0yGdy+s4e9 kwoySGFcdy/3SV2/Omm3uCrpmRuW94MJIjRTBa+AVRuL3OuM2PcjauVpeFxncrN4GNZ/ YKew== X-Gm-Message-State: AGi0Pua8Ry0NUzFbYXtZ1ePu5S6DfpZvRq6G36G/BxaWVhFS8BlkXJKo aWPiJJ6YO0rrY3DI8avM8sYW8Q== X-Google-Smtp-Source: APiQypJx7E4+GSzc/77OGnxoI4XuIbUstaIsftZ+TRzVjzHs+hgtNb6KovPmKD4Pj3wjrWGJONPmuw== X-Received: by 2002:a17:90a:734b:: with SMTP id j11mr3082377pjs.108.1588318803469; Fri, 01 May 2020 00:40:03 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id w12sm1557841pfq.133.2020.05.01.00.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:40:03 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH 1/4] devicetree: bindings: Add linux, cma-heap tag for reserved memory Date: Fri, 1 May 2020 07:39:46 +0000 Message-Id: <20200501073949.120396-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501073949.120396-1-john.stultz@linaro.org> References: <20200501073949.120396-1-john.stultz@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Sandeep Patil , Christoph Hellwig , Robin Murphy , Chenbo Feng , Alistair Strachan , Liam Mark , "Andrew F. Davis" , linux-mm@kvack.org, Rob Herring , dri-devel@lists.freedesktop.org, Hridya Valsaraju , Andrew Morton , Laura Abbott , Pratik Patel , Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch adds a linux,cma-heap property for CMA reserved memory regions, which will be used to allow the region to be exposed via the DMA-BUF Heaps interface Cc: Rob Herring Cc: Sumit Semwal Cc: "Andrew F. Davis" Cc: Benjamin Gaignard Cc: Liam Mark Cc: Pratik Patel Cc: Laura Abbott Cc: Brian Starkey Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Andrew Morton Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Signed-off-by: John Stultz --- .../devicetree/bindings/reserved-memory/reserved-memory.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt index bac4afa3b197..e97b6a4c3bc0 100644 --- a/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt +++ b/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt @@ -68,6 +68,9 @@ Linux implementation note: - If a "linux,cma-default" property is present, then Linux will use the region for the default pool of the contiguous memory allocator. +- If a "linux,cma-heap" property is present, then Linux will expose the + the CMA region via the DMA-BUF Heaps interface. + - If a "linux,dma-default" property is present, then Linux will use the region for the default pool of the consistent DMA allocator. From patchwork Fri May 1 07:39:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11522243 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 001A717EF for ; Fri, 1 May 2020 07:40:10 +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 D2C672173E for ; Fri, 1 May 2020 07:40:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vb0wY5RB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2C672173E 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 6A8546EC06; Fri, 1 May 2020 07:40:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by gabe.freedesktop.org (Postfix) with ESMTPS id 068576EC06 for ; Fri, 1 May 2020 07:40:07 +0000 (UTC) Received: by mail-pj1-x1043.google.com with SMTP id e6so2071143pjt.4 for ; Fri, 01 May 2020 00:40:07 -0700 (PDT) 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=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=vb0wY5RB7Avh9W40PInSuMIMfqVVX8c5gNx4ovRY8kJyxvZpFLdww15R4N6GP0BdJO kgrgqAzooQ68Q9h97J83Z4uygdncUlx9LUQNXlDR83RSSuYlXcMHM61ShwEckSNa/w7j zGeH7KfIJLwO4jcDE+hc8uyeYhlVyv3TJoSE5JPRSbPgtGRPc13KO8L6QoWmL398HqVa 3w+KMqQFA5upozNshMJzy7mU+yY6mts1x0PnRbUfUkevtqmFalyAtIiDrHPV6U79ju0B RGvaj1qzRpkf+1dHg8hx94nkYH28ELKWwg+2aR17hsgwFDSTrgW0H37OI6J/sl2XNoQk 7nXA== 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=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=E8tMXk5NZVuu6H+PpWUgeKlSnMN/uUfdcC6EwgNWR1x6pT4EaE30veEDcGG04nx0wN wGgCY7NJh7WNW4+lurQ0H0HDqgbVYE2h4+VMMv1AS5ouQ9fxk4aDtUiyJCHoJ/9pkh27 W7xD2iCXdSvNXBVu07yKRg0mBKon6GHIgBMjh1h1BtBVxuAvWjDBK/CqNWBS3oliCDnm EmvQnVdZ89dyEJkv3LwmvtvdtwqNOSN3bcrdvQYRiG/dbLehSyB/AwYF3Hz9qp2D/eGk QmESymVx8cRLl9f33XDb9Z22soCnWMkE27v1nB+v9vZHZ5KIpbqyKfve6K/eYvQhB9ea Vg4A== X-Gm-Message-State: AGi0PuYkbls1HTyeu9J/Jb3EonsvIhdYMV46kyc6FwBauxEs1xTyATzy z1bSs3xXSWPK4krHJuNRNR36ow== X-Google-Smtp-Source: APiQypJrHuK513hl/mWNZ3CMK5SALK94WvqJyZlw7ryX0HGGvoYccP4SvWf/0xIaXWcS+grMnsx+6Q== X-Received: by 2002:a17:902:6b01:: with SMTP id o1mr3395641plk.64.1588318806626; Fri, 01 May 2020 00:40:06 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id w12sm1557841pfq.133.2020.05.01.00.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:40:06 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH 2/4] mm: cma: Add dma_heap flag to cma structure Date: Fri, 1 May 2020 07:39:47 +0000 Message-Id: <20200501073949.120396-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501073949.120396-1-john.stultz@linaro.org> References: <20200501073949.120396-1-john.stultz@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Sandeep Patil , Christoph Hellwig , Robin Murphy , Chenbo Feng , Alistair Strachan , Liam Mark , "Andrew F. Davis" , linux-mm@kvack.org, Rob Herring , dri-devel@lists.freedesktop.org, Hridya Valsaraju , Andrew Morton , Laura Abbott , Pratik Patel , Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch adds a dma_heap flag on the cma structure, along with accessors to set and read the flag. This is then used to process and store the "linux,cma-heap" property documented in the previous patch. Cc: Rob Herring Cc: Sumit Semwal Cc: "Andrew F. Davis" Cc: Benjamin Gaignard Cc: Liam Mark Cc: Pratik Patel Cc: Laura Abbott Cc: Brian Starkey Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Andrew Morton Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Signed-off-by: John Stultz --- include/linux/cma.h | 3 +++ kernel/dma/contiguous.c | 3 +++ mm/cma.c | 11 +++++++++++ mm/cma.h | 1 + 4 files changed, 18 insertions(+) diff --git a/include/linux/cma.h b/include/linux/cma.h index 6ff79fefd01f..d8b8e6ce221c 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -25,6 +25,9 @@ extern phys_addr_t cma_get_base(const struct cma *cma); extern unsigned long cma_get_size(const struct cma *cma); extern const char *cma_get_name(const struct cma *cma); +extern void __init cma_enable_dma_heap(struct cma *cma, bool enabled); +extern bool cma_dma_heap_enabled(struct cma *cma); + extern int __init cma_declare_contiguous_nid(phys_addr_t base, phys_addr_t size, phys_addr_t limit, phys_addr_t alignment, unsigned int order_per_bit, diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 8bc6f2d670f9..f667fd51daa2 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -303,6 +303,7 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) phys_addr_t mask = align - 1; unsigned long node = rmem->fdt_node; bool default_cma = of_get_flat_dt_prop(node, "linux,cma-default", NULL); + bool heap_exported = of_get_flat_dt_prop(node, "linux,cma-heap", NULL); struct cma *cma; int err; @@ -332,6 +333,8 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem) if (default_cma) dma_contiguous_set_default(cma); + cma_enable_dma_heap(cma, heap_exported); + rmem->ops = &rmem_cma_ops; rmem->priv = cma; diff --git a/mm/cma.c b/mm/cma.c index 0463ad2ce06b..ec671bd8f66e 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -55,6 +55,16 @@ const char *cma_get_name(const struct cma *cma) return cma->name ? cma->name : "(undefined)"; } +void __init cma_enable_dma_heap(struct cma *cma, bool enabled) +{ + cma->dma_heap = enabled; +} + +bool cma_dma_heap_enabled(struct cma *cma) +{ + return !!cma->dma_heap; +} + static unsigned long cma_bitmap_aligned_mask(const struct cma *cma, unsigned int align_order) { @@ -157,6 +167,7 @@ static int __init cma_init_reserved_areas(void) } core_initcall(cma_init_reserved_areas); + /** * cma_init_reserved_mem() - create custom contiguous area from reserved memory * @base: Base address of the reserved area diff --git a/mm/cma.h b/mm/cma.h index 33c0b517733c..6fe2242c724f 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -13,6 +13,7 @@ struct cma { spinlock_t mem_head_lock; #endif const char *name; + bool dma_heap; }; extern struct cma cma_areas[MAX_CMA_AREAS]; From patchwork Fri May 1 07:39:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11522245 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 A27A51392 for ; Fri, 1 May 2020 07:40:12 +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 806742173E for ; Fri, 1 May 2020 07:40:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="d7DrWM7P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 806742173E 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 0D49E6EC0F; Fri, 1 May 2020 07:40:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52F456EC0F for ; Fri, 1 May 2020 07:40:10 +0000 (UTC) Received: by mail-pl1-x642.google.com with SMTP id c21so3410551plz.4 for ; Fri, 01 May 2020 00:40:10 -0700 (PDT) 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=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=d7DrWM7Pg1LzeLY9hTHX3Vu6bzl5opKrCH2QlCTt6Jrx2Kf5gZhk+v6vTLU6f+ULz2 PTiPKHZARFJ6lrB3W3f9Ywxqo6KsLZQ/vb3d1Tw5dk54Ht4in1nQE5s/8lPxhYRC9x1a D6edusf8njClbUpHSkZBebx7PTMR1SOSvH/r7MaZr6myG/iAla1rNjPRCW6OW+XNQIHt OmRiF3MrZcOxTbSbEdUqOK7VqTixWGAKbO/x12boCmXJ9u9lBV04xM/B/YgAAbeVKoUN UGDdZTWUZA10VOkmyzHXDnEI1gjDagbffVyU61Fe1nwJg3me3bJZ6FbrIMvJuUZ+dixf BcUw== 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=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=PVGyG6PY7XXxfeVbZE0JqYFeKdDD/V3oCxejfqw7bhlZEfSdp3mpFu9mPE7qQMe+SE R/kb8Zcg78nQVMPJim0BEzHNy/H/nY/sgDp35aci6gveALRobKo7ltJjo3Ul53Wg4QO9 +lCnCzS9XF2ByB7JWFriyWGITlo74H1tSjgvr+w12zqSnsHzU/cjHG1+htXoQXhh2o4z +Fx2O5N8EzTgOmk7LCPdLb33lf0rsi5r0l/pLDLFHR+yTOowQnnePkA3hCeURlashx6B KbTkTvFoC+NKEMRD9iAuLHVqbF8wUdsQZnXR1DbcqHTgZQ4d8MTymxLixDKohSiYU8ak Ce5w== X-Gm-Message-State: AGi0PubdjhcynC9CQKwiAwjJsOpONujtEDn8voaxUFbHAEioTBAnsSMO zV6EBxPdC8zvljBMEh8SHsFODA== X-Google-Smtp-Source: APiQypJiEJ4kQAfPAoSZcmNCfZQu1/ZpRWQas3IjFCF2RyIzmyY+jFIehrdb4AljNbKemje+OfRRHA== X-Received: by 2002:a17:90a:3ace:: with SMTP id b72mr3264947pjc.48.1588318809841; Fri, 01 May 2020 00:40:09 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id w12sm1557841pfq.133.2020.05.01.00.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:40:09 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH 3/4] dma-buf: cma_heap: Extend logic to export CMA regions tagged with "linux, cma-heap" Date: Fri, 1 May 2020 07:39:48 +0000 Message-Id: <20200501073949.120396-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501073949.120396-1-john.stultz@linaro.org> References: <20200501073949.120396-1-john.stultz@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Sandeep Patil , Christoph Hellwig , Robin Murphy , Chenbo Feng , Alistair Strachan , Liam Mark , "Andrew F. Davis" , linux-mm@kvack.org, Rob Herring , dri-devel@lists.freedesktop.org, Hridya Valsaraju , Andrew Morton , Laura Abbott , Pratik Patel , Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch reworks the cma_heap initialization so that we expose both the default CMA region and any CMA regions tagged with "linux,cma-heap" in the device-tree. Cc: Rob Herring Cc: Sumit Semwal Cc: "Andrew F. Davis" Cc: Benjamin Gaignard Cc: Liam Mark Cc: Pratik Patel Cc: Laura Abbott Cc: Brian Starkey Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Andrew Morton Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Signed-off-by: John Stultz --- drivers/dma-buf/heaps/cma_heap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c index 626cf7fd033a..dd154e2db101 100644 --- a/drivers/dma-buf/heaps/cma_heap.c +++ b/drivers/dma-buf/heaps/cma_heap.c @@ -141,6 +141,11 @@ static int __add_cma_heap(struct cma *cma, void *data) { struct cma_heap *cma_heap; struct dma_heap_export_info exp_info; + struct cma *default_cma = dev_get_cma_area(NULL); + + /* We only add the default heap and explicitly tagged heaps */ + if (cma != default_cma && !cma_dma_heap_enabled(cma)) + return 0; cma_heap = kzalloc(sizeof(*cma_heap), GFP_KERNEL); if (!cma_heap) @@ -162,16 +167,11 @@ static int __add_cma_heap(struct cma *cma, void *data) return 0; } -static int add_default_cma_heap(void) +static int cma_heaps_init(void) { - struct cma *default_cma = dev_get_cma_area(NULL); - int ret = 0; - - if (default_cma) - ret = __add_cma_heap(default_cma, NULL); - - return ret; + cma_for_each_area(__add_cma_heap, NULL); + return 0; } -module_init(add_default_cma_heap); +module_init(cma_heaps_init); MODULE_DESCRIPTION("DMA-BUF CMA Heap"); MODULE_LICENSE("GPL v2"); From patchwork Fri May 1 07:39:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11522249 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 2B2B91575 for ; Fri, 1 May 2020 07:40:16 +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 0A8AC21924 for ; Fri, 1 May 2020 07:40:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uHgfP9cW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A8AC21924 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 645496EC10; Fri, 1 May 2020 07:40:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2DDA6EC10 for ; Fri, 1 May 2020 07:40:13 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id o185so4250151pgo.3 for ; Fri, 01 May 2020 00:40:13 -0700 (PDT) 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=QD+OM/IPa9x7hJvHclwxEGNJ9gIn9LRrmuc2cMqM+jk=; b=uHgfP9cWbKjgsICCn22DXY5E8YVkK4lR5mSH38oijVyLq+WDsYAckO411+fCRx4fSG 92T98KiXWYh/Veuu9k4mILrjo6zo4M8S4hPIn1pjXH4afDJRgMkF3HIHomYHPtbJ2CIT oHO3AozrS69KPbj/CTUAtS0sIYMkdKaiEqIvnSOR5NCG1ZOjYGvWsRTbWlGF2X+swrpU pF1SZxSAvCiYlvGEZHBmQuMPgM/YMkwvPoLMwh2SWAo7qUkc5ifkQoPpgJfJmVVL5VBG jEdBB2/STxwoSAR6Dj/ZZDJ0PZXyVaXxiFVJoKoWWEDCYQLst2EN08W0fE9yARqfug+f NI7w== 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=QD+OM/IPa9x7hJvHclwxEGNJ9gIn9LRrmuc2cMqM+jk=; b=c75zsyh87E0EpGJpg+D/34GwVmvaw6sjtXYbySvObwDfNPjc/JpEFOjfXiHGgD+dcD qTuw34hteiwW0jq/UlXBRmrqokhRJneZOOns1E3lUTPRaDV5Ok4CTC4qgFCZ/XEA7PN+ Sw+IjvVSQVa2J9PTMuaeJU0XbL8vuVTCQ1u+eNgiZ+5aMb6J03fvWznU6/bSEQDB0vYy kBK5CyfgWHYJITJoadNfPV1jWlFIRiZfmdgyKZYsI3Jt/4k+/4CdvnoROQ/hntYwJSOm Nys21x89lBa/1FxkDN0TtGL9Wx383iMzTbQsQFBNy3WCF0k6jJ0UA6eqZOS/bp0ISQak 2cxQ== X-Gm-Message-State: AGi0PuaMQxxwCqNBjnfJ6+7nHAlk1rlnqA8TjNaQRpOibYHBklgRQIQZ QkF3ye4WRBROAHi3FPwTtFA7cw== X-Google-Smtp-Source: APiQypIe0OyaYrak6ULk6jy1juCWPHfm+627JYy+N9jmFW5Ppc7wa4zxgW6OTSiIq3XBtubeLxsMWQ== X-Received: by 2002:a62:e113:: with SMTP id q19mr2839382pfh.107.1588318813249; Fri, 01 May 2020 00:40:13 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id w12sm1557841pfq.133.2020.05.01.00.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 00:40:12 -0700 (PDT) From: John Stultz To: lkml Subject: [RFC][PATCH 4/4] example: dts: hi3660-hikey960: Add dts entries to test cma heap binding Date: Fri, 1 May 2020 07:39:49 +0000 Message-Id: <20200501073949.120396-5-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501073949.120396-1-john.stultz@linaro.org> References: <20200501073949.120396-1-john.stultz@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Sandeep Patil , Christoph Hellwig , Robin Murphy , Chenbo Feng , Alistair Strachan , Liam Mark , "Andrew F. Davis" , linux-mm@kvack.org, Rob Herring , dri-devel@lists.freedesktop.org, Hridya Valsaraju , Andrew Morton , Laura Abbott , Pratik Patel , Marek Szyprowski MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Adds example test entry to create and expose a dummy "camera" cma region via the dmabuf heaps interface This isn't a patch I'm submitting to merge, but just an example of how this functionality can be used, which I've used for testing. Cc: Rob Herring Cc: Sumit Semwal Cc: "Andrew F. Davis" Cc: Benjamin Gaignard Cc: Liam Mark Cc: Pratik Patel Cc: Laura Abbott Cc: Brian Starkey Cc: Chenbo Feng Cc: Alistair Strachan Cc: Sandeep Patil Cc: Hridya Valsaraju Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Andrew Morton Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-mm@kvack.org Signed-off-by: John Stultz --- arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts index c0a6aad9593f..5eef1a76d51a 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts +++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts @@ -81,6 +81,13 @@ reusable; linux,cma-default; }; + + cma_camera: cma-camera { + compatible = "shared-dma-pool"; + reg = <0x0 0x24C00000 0x0 0x4000000>; + reusable; + linux,cma-heap; + }; }; reboot-mode-syscon@32100000 {