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: 186018 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp284791ilf; Fri, 1 May 2020 00:40:03 -0700 (PDT) X-Received: by 2002:a17:90a:1743:: with SMTP id 3mr3223688pjm.106.1588318803856; Fri, 01 May 2020 00:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318803; cv=none; d=google.com; s=arc-20160816; b=y7Utd1Kps2VcyNR0azVAWNCEMNkh6sRK3pxGZgvtJay1bgzTDGzgVqDbHAVM3Bz1aV UnCIx0FdNsmRL69G9hr0EGJnkzF7pGMQ+Z3dvWxJRQlMrePA0TjyNmwzhONJEHIjC7+Q FR+VIQlirDxC9y7YXpgHAEkiHlQHnrFC2vg5SteVgoGq9r+YedO7BseNC4jbe5ALGyVo VzNSTf8jEbSuy9EfC7hBCvQmsboAjxzXvWFUgteJ3HidCCO2pnPdIIVd1GI7gqsKpEnq adPtj+XtTdl93JL5a2vrKSzGWyrRJMwIY8ac9veJ2ewzYSnjwmXGgFEP7V70rzBMu1ic PRiw== 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=NSH9BerjJoV88xjF7QVK1SklBZqxZKa42SGy8GT/SY0=; b=GNUyWDYdi4BvUs5q4wcM/2xUwqCprJlI0CQiKnpyEDzzR9G3jQqDLmutoeL3tE0O75 jIZrnHEmWXBTYNZFF+IwX00wg63Xx28emAc0r1SmCNna0QJwmS4me5tEI9xutVoWw+gI yT/8bHdez9ztqSuW2bdmjShpKXxCiBWLUd8dmC6GbWsds6cGBjLtvjOGxFJSZhzYgs8o vNZ24BL2eyI0u1ZLXzJxO1RizAfA4hvHyUcNyXvgDF/BhfL41w1JypiFtYl/dvvkt23q d2F0o6jeWjXB/cDScK5SpDYmb3XZzTRJdqqeLF3ylll3suOtSO+oVJujZNeAUN4enuKy CiVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gMfRkU6y; 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 d3sor2635522pjl.15.2020.05.01.00.40.03 for (Google Transport Security); Fri, 01 May 2020 00:40:03 -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=gMfRkU6y; 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=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=L2xwFVFgIwVVqavcNqxK0RMpyZaYE3Q0dwtGrApUXUbuz5wojTTnUGng5gDDIlobXd FT6e53gyMIaXNWgnoBURoSPit0jGAbzynEJHZfCW27JtEJGUlPC6f5JHmkf+l7xUKz/x bbKVU00Knc7o99XxYblx/toXT46U5uXjPTD6yvW0X3aENkeBmyFvjfTfVezTfDaOAQfP EvZ6KIRpjtj3F/YBGZve9kalh0FVulL4Q9nUDe8TBEg/LhCruNu2neSIohSLg77f5uo6 5wnUQ99I2jG9pQZGAk/GzUNJuHQd49pf5fJhl+udr533/c0cbblQIWJZN87tewUeLf89 wtvg== X-Gm-Message-State: AGi0PuaIJWMTduHCMeDEHagT0d6c9AJDPRRXfp6/fmouNwpLsBB1ZFYb O/MwWXaW0y9BBqeQqzEI6D5MKzCb 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) Return-Path: 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 Cc: John Stultz , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Brian Starkey , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org 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> 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(+) -- 2.17.1 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: 186019 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp284833ilf; Fri, 1 May 2020 00:40:07 -0700 (PDT) X-Received: by 2002:aa7:8489:: with SMTP id u9mr3037619pfn.248.1588318806949; Fri, 01 May 2020 00:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318806; cv=none; d=google.com; s=arc-20160816; b=MJiJuB8ptVwxTQP3XFfX8U4S3OcCRQ4eUbRseBbUxfHY54TZedJXxg8wG6NklJX47f RXSd3lYfu3/M0XhnjHjjfpd1Ma2L0IW+z1AKoltyj01DTTQlCSxiwqnxIPMLN0WiiaNL lgHmGH16OJt2NKDbGZPq2lGNPkvTRiOlD0KUlAM6gC2PhjSeinHtIeHnnqKrAGNJ0Ww1 p92NwnXf89rLQq5c5aAWyWY923sSNjLR56ksVkhbY3UuTB9Hz2wu6y9dZtm3NBgLKugZ GPwLUjzZyObFl0Yp7LCKHtuiUhtg2PQ+bJFK9m6afLcFd0wKZuzoxyX0Ku4h1aSJmz5k vLvw== 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=pbJ0rXWHkCLJRyK9vXiUuFPqdQtHbtzqJkW11UYQ0Gg=; b=hylI41iBScIUzRT5utYXufTMSUASV7XeKVn4pveJVvYw64L9u7oOdvsA0NgHDO595q OpSCFtH5xNO9sAR6Om7/HXEsx+hcFN6yYuQswkxQkaqH5cVngAVt9W+tzlvH0MHKm1bp E+L0iU9v4JQJJ1wtG0O75ojPIF4K1dwy2Vi9LcZ5JoDtnA7YvuEZnfohWJjWOcU8VWfL 4aSCQVhInX8OnoJCcvpUGfmzXUM+fKaumOVTCecMp69c86LQ463NKAL5YYLwAz3f3Pp3 /WDFGgEtKdUr0uu2Yp7ZeCGMMfPW0RS4cx9s7l9kKAb+YAuPehR0s7gjKqoyH32LJiTQ IY8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vb0wY5RB; 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 j10sor2912125pll.0.2020.05.01.00.40.06 for (Google Transport Security); Fri, 01 May 2020 00:40:06 -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=vb0wY5RB; 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=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=WfvrdVxNfbvIPLi4pTBoN4VVJFPxpnIPvzAhhZCOlodx/2kt1BsIY6xpLmkE3rb2bp D5FFTbnI+rNGzkWjwel/bWYTby48SL71SvbW2HuSVIkSWFZZ7ZdTIQWAa7jVsZ9kwsNI +49YIWEUNTI96PKW+cF6M32zcYrPeV45b5XwNshHnKuQgwEMMsEaIWUaIoHF1xqbDqMb JKW3JQkoQzcxLC9D+4N+5C9Uv3/FDda6mA1peAJzi9QJTYPAbF0fKgvc7B/6LuILjy6a M3hbi0y8Wb9Ikmf3uTXJPDUPM56ctASmxOUu3Pdh1qzrPR+0mURI+mH2YNNpEFsxW/0d hPhA== X-Gm-Message-State: AGi0PuanxSU01jHjlsS3yjaDCk0tHyXrSzHi5EC+EGBgHtW+UDbfOhYo H3hN0/4POWRwL4nyo9HAVuOAPLJH 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) Return-Path: 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 Cc: John Stultz , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Brian Starkey , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org 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> 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(+) -- 2.17.1 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: 186020 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp284870ilf; Fri, 1 May 2020 00:40:10 -0700 (PDT) X-Received: by 2002:a17:90a:24a7:: with SMTP id i36mr3247285pje.32.1588318810278; Fri, 01 May 2020 00:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318810; cv=none; d=google.com; s=arc-20160816; b=zzZI40eiHGhOdS9J/5+ifSIORhz52wL/xkEJL96XltrIZueIG5J26M/17bK/RFIlF6 i8j7pWdjAVidzFwQL49x/AY5i3fHsAtKPRZ8dOoET+VUkXnOWAftupkUDq+lp4LP+jOu 1T1FZGIrpocZcBe6jwoG30Je9xH+QM5bZy87dAZVwIHXFbAXu13UB3JyIweBH7jvVqb+ 1058cBrh14GAgU6LXoz1qGClZY1np+NkHk8t2jRO0uyPuEJ8AcRmwMBYaWmpYdVmIJgS djQpFrqzbo19vF9hsKTrM8DBzuq6cR6n4tI1OLbPZtyLAOubPpcSuyglS1l13Bx1hAjR a08w== 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=68MF0mDAuQKXmyv4cM6UCkwuoNI6S07F0Y008UnFGIA=; b=z0MGAsaHMfSt4fsIlizBWM2ysnX+7EXFKjOvuFkpiTVedUAbPMJyGnYdKrdPCHwopI AHKkuWhAmcfMziBZmz9is81GhXyYcjVMFkTvNqFOl+QfPvcOoz+b2QvtwX+N7mw0VyLL sV38n6MioXFsvEdkNE4uuzLINyYOiKZLuND5GfXTxNeoQQAXMqZFL64v9FXHE5ECN6jV NssEVGTfb4tygHbvGZa8LY6JlPtf2KdX3k969YuYMb+tlx7dBxpkxAj/HRLv56BcIFVJ Zq0rBcYInpAtqEyyTZQHinQ3hVgFK0onu1hqzrw8CNEe91R8t1ON/lD/NgBXVIkOtpFj 6rlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d7DrWM7P; 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 cx11sor2715678pjb.24.2020.05.01.00.40.10 for (Google Transport Security); Fri, 01 May 2020 00:40:10 -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=d7DrWM7P; 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=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=o80qw7Cd8tI9i1AR8s+c1RgHUjJvIyjfcqp3RVughP9RazrSSKE3XaPKTRPMCMtRlR AD0BuW0tBVHO5Kjp0Wp+eLapLDoSTPUd4g6ZOALR8gpg0BW/X5J/5Fczsgx2AfW2Df6J 89KiXefFBRxB1OsaplHqweD0cGhHy2+mu2o2KejmcRA4wjtyR/sPyRb/63p2XPKqmNQd HWdjq9Rr2wxfevZ9aDwOO6uMmxaz3QF55IC2wWqdnxDQnGHLJuVYs+SO4yv5HkY9DMFD UHKMLfjZlA+e6hxljQg9mGDaV1xvvVqWCcubHHvEbH1ln9mH67Z2oZujgkfxJxFNiXT/ lwBQ== X-Gm-Message-State: AGi0PuYFuuESR83eJGqDZ7EDfBcNBg+m9SYCudB44vMzhDmOi3dZM7/V 9WLDPi8h5oc8YFnDOQdDqEXCsV6+ 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) Return-Path: 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 Cc: John Stultz , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Brian Starkey , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org 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> 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(-) -- 2.17.1 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: 186021 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp284909ilf; Fri, 1 May 2020 00:40:13 -0700 (PDT) X-Received: by 2002:a17:90a:343:: with SMTP id 3mr3203613pjf.178.1588318813570; Fri, 01 May 2020 00:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588318813; cv=none; d=google.com; s=arc-20160816; b=CJLTfFuvDyf01JE/UF9NGcz+P+GbzC0yjbmVJF95oK24Ja2sbcRPMVFgu/hYgQKSY6 T6PVS5Z8942of+9/GHJU4xxJi+Y02i2nQC9oEYxtpyDw8wOzc0/a0xY+ZrGpq9Ujrf0z auhccX6JR/V7dm7gYCjsxWC4wPnL5ctMsSLo+Haw39sBlccMDdty3t15XD93GulzCpjM W5cOlw1W/2JWxZjUb2B/2vruhqofiTwBvYsqgqy5zBZWCleD+cdTIVFhI8iLP1rjoaZ2 AnuahuP/B1v+3xXocIaTpsFeCfKw9P+9VmIY+eXPIZBVDIR1cOkqqK8SohptOeiC4vSA 5JLA== 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=QD+OM/IPa9x7hJvHclwxEGNJ9gIn9LRrmuc2cMqM+jk=; b=Jb2wfzdzke7eTUIvECjEdiiZjsFoug6wCjoGEUBJqPmKrp1EEHn4pD60AwPDmT/HPS Jym6xvCuD2cRlrx6f4Uu8hwNo3CL0OOoYtedbSlqsfQOV4AAYqTvzSW6xFSyqEfe16Jm J1+xFaFmSFCc7Q+zR+3/nWh/xgSAwdb2r/X5OiyW80Fo2CPQS5hTK3V6mu8sezFBunlH NQuOx4ydHMUiPM+aUJPOlwPBbzDMKUB9mI354q1EFkMMuXuedm8uz3SO1YzDbmr7Bweq i1kOaofU/3JHtF/p/XpJhqa2/vfGXkyof7T+gWgJ5H/HyFfbx5OXKAACwBk4iNoMfM1g qa+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uHgfP9cW; 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 w185sor3113061pfb.43.2020.05.01.00.40.13 for (Google Transport Security); Fri, 01 May 2020 00:40:13 -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=uHgfP9cW; 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=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=fqJ2E5A7m47pCvX4hyRkWDIy2bUDH1ZfmWham9/9W0oGkFvEBuDKFon0mJrgtFffck n1ZwsGdXeqv8jWjGnwvBMb16R5kLRtQPo7XNEKutrM8Fg534ZFfMAA20rrTUkD2RBw8U x/pGIEf3qjq3vuVMWbr0HOl33u6HQK9y5fSpJ71waRAuCPz4Xdz8685pQIim6XqVVcPk 3othdAWXOm1cqZOBIXANJGi1rMnBcOF/fi+WInqiG+plixMZvvZpeyV6XqAuko2pgeyl 7+uSR9sMPrTYM3REbDlaD8RItq95VbuOtCJiSU1tx8h+QLAGJ1cmIUU+SBUdcw9mnV4Q 91JA== X-Gm-Message-State: AGi0PuZmGyOrsS7QGHPEl0k3D97X6kMmVZrOL2ioNExsiI+M1tDKdw7d 4tiRVfCknXh2JqMDne5cKO4WJUjS 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) Return-Path: 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 Cc: John Stultz , Rob Herring , Sumit Semwal , "Andrew F. Davis" , Benjamin Gaignard , Liam Mark , Pratik Patel , Laura Abbott , Brian Starkey , Chenbo Feng , Alistair Strachan , Sandeep Patil , Hridya Valsaraju , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Andrew Morton , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org 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> 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(+) -- 2.17.1 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 {