Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1760328pxb; Mon, 12 Apr 2021 06:13:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOOfEdEEt9wOeIaSW8yvSPCc5KtrIKr5mEXZQuaEl8H7RlMGYJ6BuKhumo+636cNnT4y1+ X-Received: by 2002:a63:ee02:: with SMTP id e2mr10719751pgi.280.1618233216042; Mon, 12 Apr 2021 06:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618233216; cv=none; d=google.com; s=arc-20160816; b=Ho8lNMQq9zsIp3g/7VjdcTm7ShGsAR9kcAeGfGVQgrTUj4Hy434Lwl+37Sx3bTwVau GTavvqSLSjJA9/aN89/+mnZ/FP7V30Z/PxNeVLM62vra6lzQP6+veXuuF6w9Zf8K9pUl fP2ViudyVBg/rYe8kJzUVpiV4AjXBx5wVFir0BA7bTv/Mo0Za90bnuvNoCzU36QOidYg TjVMPCGS/Ae/iu028EoJ75bFF+x1macH1+HjFuoZf+vW5YSvD9nZwM2lmHJrDrGOKplz opOlcVTapDuLA3d77EhRxcaN/7cPKSBx27oxBUeI2JajzNxsxhQ8hqzhInXhr9+7ClKj pRqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=VIAl6baLLguCLNSBjntkitsRvA0QSwiQJ45sqw1Y85I=; b=SwCoSG55uURwS+wHatiksXDHTonMoFiDJwCC88i9i6kxNF78kyCPVtahK6dJ3Bz7q5 5ps2/z5Bnl1/Q0+R/YCIi+e+4FoX89vFvV9qB9pT5YO1SRNuro6A1DNxiQ5f339qw8yp teRScxeU2KKdU8C7a5qmqWOo8pPdy5sQmfNjn5cBpGmieBywQzoGeDqeN0nnONMCFX/R 0b4xL7L45g+M2PyE32ilg/WC/paVatOncz0vDHnZ0pECzDDZOVpVVNr0AwVJyI9ch5Kn 85nc0Wbqo3HUf6bb/TcCvigK2QxsLsQi0j9/xeeBGEQwI5xt+JMjiRsIIyyUjleTZijf c8UQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g11si13241078plp.148.2021.04.12.06.13.23; Mon, 12 Apr 2021 06:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S241706AbhDLNMz (ORCPT + 99 others); Mon, 12 Apr 2021 09:12:55 -0400 Received: from foss.arm.com ([217.140.110.172]:50288 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241498AbhDLNMu (ORCPT ); Mon, 12 Apr 2021 09:12:50 -0400 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 CFAFD1063; Mon, 12 Apr 2021 06:12:31 -0700 (PDT) Received: from [10.57.58.164] (unknown [10.57.58.164]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1FDDA3F73B; Mon, 12 Apr 2021 06:12:27 -0700 (PDT) Subject: Re: [PATCH v3] drivers: introduce and use WANT_DMA_CMA for soft dependencies on DMA_CMA To: David Hildenbrand , Arnd Bergmann Cc: Linux Fbdev development list , linux-aspeed , David Airlie , Linus Walleij , dri-devel , "open list:BROADCOM NVRAM DRIVER" , Paul Cercueil , Eric Anholt , Christoph Hellwig , Masahiro Yamada , Michal Simek , Jason Gunthorpe , Joel Stanley , Russell King , Thomas Zimmermann , Bartlomiej Zolnierkiewicz , Maarten Lankhorst , The etnaviv authors , Maxime Ripard , Christian Gmeiner , Peter Collingbourne , Linux ARM , "Alexander A. Klimov" , Linux-MM , Andrew Jeffery , Linux Kernel Mailing List , "open list:IOMMU DRIVERS" , Daniel Vetter , Andrew Morton , Mike Rapoport , Lucas Stach References: <20210409112035.27221-1-david@redhat.com> <53ec94ac-ffe3-d0bc-d081-3489fa03daa1@redhat.com> From: Robin Murphy Message-ID: <34350446-0e0e-6947-40bd-fabdccdc835f@arm.com> Date: Mon, 12 Apr 2021 14:12:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <53ec94ac-ffe3-d0bc-d081-3489fa03daa1@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-04-09 14:39, David Hildenbrand wrote: > On 09.04.21 15:35, Arnd Bergmann wrote: >> On Fri, Apr 9, 2021 at 1:21 PM David Hildenbrand >> wrote: >>> >>> Random drivers should not override a user configuration of core knobs >>> (e.g., CONFIG_DMA_CMA=n). Applicable drivers would like to use DMA_CMA, >>> which depends on CMA, if possible; however, these drivers also have to >>> tolerate if DMA_CMA is not available/functioning, for example, if no CMA >>> area for DMA_CMA use has been setup via "cma=X". In the worst case, the >>> driver cannot do it's job properly in some configurations. >>> >>> For example, commit 63f5677544b3 ("drm/etnaviv: select CMA and >>> DMA_CMA if >>> available") documents >>>          While this is no build dependency, etnaviv will only work >>> correctly >>>          on most systems if CMA and DMA_CMA are enabled. Select both >>> options >>>          if available to avoid users ending up with a non-working GPU >>> due to >>>          a lacking kernel config. >>> So etnaviv really wants to have DMA_CMA, however, can deal with some >>> cases >>> where it is not available. >>> >>> Let's introduce WANT_DMA_CMA and use it in most cases where drivers >>> select CMA/DMA_CMA, or depend on DMA_CMA (in a wrong way via CMA because >>> of recursive dependency issues). >>> >>> We'll assume that any driver that selects DRM_GEM_CMA_HELPER or >>> DRM_KMS_CMA_HELPER would like to use DMA_CMA if possible. >>> >>> With this change, distributions can disable CONFIG_CMA or >>> CONFIG_DMA_CMA, without it silently getting enabled again by random >>> drivers. Also, we'll now automatically try to enabled both, CONFIG_CMA >>> and CONFIG_DMA_CMA if they are unspecified and any driver is around that >>> selects WANT_DMA_CMA -- also implicitly via DRM_GEM_CMA_HELPER or >>> DRM_KMS_CMA_HELPER. >>> >>> For example, if any driver selects WANT_DMA_CMA and we do a >>> "make olddefconfig": >>> >>> 1. With "# CONFIG_CMA is not set" and no specification of >>>     "CONFIG_DMA_CMA" >>> >>> -> CONFIG_DMA_CMA won't be part of .config >>> >>> 2. With no specification of CONFIG_CMA or CONFIG_DMA_CMA >>> >>> Contiguous Memory Allocator (CMA) [Y/n/?] (NEW) >>> DMA Contiguous Memory Allocator (DMA_CMA) [Y/n/?] (NEW) >>> >>> 3. With "# CONFIG_CMA is not set" and "# CONFIG_DMA_CMA is not set" >>> >>> -> CONFIG_DMA_CMA will be removed from .config >>> >>> Note: drivers/remoteproc seems to be special; commit c51e882cd711 >>> ("remoteproc/davinci: Update Kconfig to depend on DMA_CMA") explains >>> that >>> there is a real dependency to DMA_CMA for it to work; leave that >>> dependency >>> in place and don't convert it to a soft dependency. >> >> I don't think this dependency is fundamentally different from the others, >> though davinci machines tend to have less memory than a lot of the >> other machines, so it's more likely to fail without CMA. >> > > I was also unsure - and Lucas had similar thoughts. If you want, I can > send a v4 also taking care of this. TBH I think it should all just be removed. DMA_CMA is effectively an internal feature of the DMA API, and drivers which simply use the DMA API shouldn't really be trying to assume *how* things might be allocated at runtime - CMA is hardly the only way. Platform-level assumptions about the presence or not of IOMMUs, memory carveouts, etc., and whether it even matters - e.g. a device with a tiny LCD may only need display buffers which still fit in a regular MAX_ORDER allocation - could go in platform-specific configs, but I really don't think they belong at the generic subsystem level. We already have various examples like I2S drivers that won't even probe without a dmaengine provider being present, or host controller drivers which are useless without their corresponding phy driver (and I'm guessing you can probably also do higher-level things like include the block layer but omit all filesystem drivers). I don't believe it's Kconfig's job to try to guess whether a given configuration is *useful*, only to enforce that's it's valid to build. Robin.