Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6437738rwn; Tue, 13 Sep 2022 04:24:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6T3OpAf7JFbFO67iKsVHAenH6dJNjU42vl8l3fkUvlU4WW0jhDnoFDnE7B1NWEkSgZGTFd X-Received: by 2002:a17:902:e801:b0:178:11e9:2ba2 with SMTP id u1-20020a170902e80100b0017811e92ba2mr17723235plg.26.1663068279137; Tue, 13 Sep 2022 04:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663068279; cv=none; d=google.com; s=arc-20160816; b=uOXunzFH9Ph3yl4y5CevRlxfjv0m/gWRWgdDFFv9WxTgVjvC/MKBw/nRUDmABe1gTF 8J1ExwadMoVR/DNrlvsZ/tczFG2v3eyAE4ZDkvyQl8MxlsS7/cUO1tlwKiw4KtvfyWew 8pu+chJO3M+QhReSr3Yr/vwSOBQAPrEP9evQYAWuyP6N5GBb/JdsQ64rdPh71k1LKS46 vl1kTDAknn41uRM7da5uh7ZUochEJqoNG3kN8CwHF+MOITffb7IZV0lIjzwZ1OWFrqYI 2tW/emrJd7uaX+TMM3t9Nmgf133GkyHsMDv2fAhMwTg9Bgld0bzcYd0vfhs5qbhsLWiX /Nzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=NM9BgL/eWoe78tgSX8pRQfih5lthA99vZRoC1aU9300=; b=q/AZLTdCr88dINYM+y8hdXHjI4bP7H4jWjhP3uuYwq7TItVMIdk8L4pCFoteJG+wPI ivtmQHjuD7BKfLPW0P/B7+VJDsoMBgOQC+pNOZ3mGV2TjotuwYrbe8O18PIEs18eH4U1 reEKiVMkkIWCEH5uI4pwLPrKFtCRk5Q3NA5nPjltcLok6ijqbU88/2QkSBMV9gQCGywc QNb+PJLlU/bTrds0PUQUPtRWIhMqZ4X0u2qAyThjFVTGFs28JZN/oOsJi+kp57onmYvz Vnt8FjQaXwOK93GPkEA6sVolVsPo40okko56f4nFxpVFgIMtHM9GNbwOuq1jieYILlN3 t2Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a170902b58600b0017853084f91si100835pls.506.2022.09.13.04.24.27; Tue, 13 Sep 2022 04:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231698AbiIMKpj (ORCPT + 99 others); Tue, 13 Sep 2022 06:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231695AbiIMKpe (ORCPT ); Tue, 13 Sep 2022 06:45:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 51C7F13F24; Tue, 13 Sep 2022 03:45:25 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 665341063; Tue, 13 Sep 2022 03:45:31 -0700 (PDT) Received: from [10.57.15.170] (unknown [10.57.15.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CCBCC3F71A; Tue, 13 Sep 2022 03:45:22 -0700 (PDT) Message-ID: Date: Tue, 13 Sep 2022 11:45:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] dma-contiguous: add optional cma_name for cma= kernel parameter To: Nate Drude , iommu@lists.linux.dev Cc: Jonathan Corbet , Christoph Hellwig , Marek Szyprowski , Borislav Petkov , "Paul E. McKenney" , Andrew Morton , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, eran.m@variscite.com References: <20220912163805.4113238-1-nate.d@variscite.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: <20220912163805.4113238-1-nate.d@variscite.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-09-12 17:38, Nate Drude wrote: > When cma is defined in the device tree, the device tree node > name is used as the cma name. In the following example, the cma > will be named 'linux,cma': > > linux,cma { > compatible = "shared-dma-pool"; > reusable; > size = <0 0x3c000000>; > alloc-ranges = <0 0x40000000 0 0xC0000000>; > linux,cma-default; > }; > > And a device /dev/dma_heap/linux,cma is created. > > However, when cma is provided by command line, a default > name of 'reserved' is used, and the device path changes to > /dev/dma_heap/reserved. If userspace expects the CMA heap driver to expose a consistent name for CMA heaps, shouldn't it be the CMA heap driver's responsibility to expose a consistent name for CMA heaps? Tinkering with the core CMA code doesn't feel like the right approach. Furthermore, given that DT reserved-memory nodes carrying the "linux-cma-default" property equally can (and do) have different names as well, that or fixing userspace really are the only robust options. Thanks, Robin. > This is problematic because some user space applications, > like gstreamer plugins, are expecting /dev/dma_heap/linux,cma. > > This parameter allows overriding the default 'reserved' name. > > Signed-off-by: Nate Drude > --- > .../admin-guide/kernel-parameters.txt | 7 +++++++ > kernel/dma/contiguous.c | 21 ++++++++++++++++++- > 2 files changed, 27 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 51397a320f5e..975ec862d071 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -644,6 +644,13 @@ > altogether. For more information, see > kernel/dma/contiguous.c > > + cma_name= Override the cma heap name > + Format: > + When passing the cma kernel parameter, the default > + cma name is 'reserved'. This parameter allows it to > + be overriden to align with the device tree name, > + like 'linux,cma'. > + > cma_pernuma=nn[MG] > [ARM64,KNL,CMA] > Sets the size of kernel per-numa memory area for > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c > index 3d63d91cba5c..e89819ec183e 100644 > --- a/kernel/dma/contiguous.c > +++ b/kernel/dma/contiguous.c > @@ -74,6 +74,7 @@ static const phys_addr_t size_bytes __initconst = > static phys_addr_t size_cmdline __initdata = -1; > static phys_addr_t base_cmdline __initdata; > static phys_addr_t limit_cmdline __initdata; > +static char name_cmdline[CMA_MAX_NAME] = "reserved"; > > static int __init early_cma(char *p) > { > @@ -96,6 +97,24 @@ static int __init early_cma(char *p) > } > early_param("cma", early_cma); > > +static int __init early_cma_name(char *p) > +{ > + if (!p) { > + pr_err("Config string not provided\n"); > + return -EINVAL; > + } > + > + if (!strlen(p)) { > + pr_err("cma_name must have at least one character\n"); > + return -EINVAL; > + } > + > + snprintf(name_cmdline, CMA_MAX_NAME, p); > + > + return 0; > +} > +early_param("cma_name", early_cma_name); > + > #ifdef CONFIG_DMA_PERNUMA_CMA > > static struct cma *dma_contiguous_pernuma_area[MAX_NUMNODES]; > @@ -231,7 +250,7 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base, > int ret; > > ret = cma_declare_contiguous(base, size, limit, 0, 0, fixed, > - "reserved", res_cma); > + name_cmdline, res_cma); > if (ret) > return ret; >