From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37B87C43460 for ; Mon, 12 Apr 2021 13:19:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6C6A61288 for ; Mon, 12 Apr 2021 13:19:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6C6A61288 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 495206B0036; Mon, 12 Apr 2021 09:19:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41E536B006C; Mon, 12 Apr 2021 09:19:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24A326B006E; Mon, 12 Apr 2021 09:19:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 027AC6B0036 for ; Mon, 12 Apr 2021 09:19:06 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B3A318248D51 for ; Mon, 12 Apr 2021 13:19:06 +0000 (UTC) X-FDA: 78023770692.15.321AEA6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id B4840A000395 for ; Mon, 12 Apr 2021 13:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618233545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ZXD0Vjr7M6pXQoqoYaNJ9fIJMRtCGqZKUK6a7IbIAM=; b=IfujdcitXd9kYzsj+8DDlnMxAEjGbadVBza3cHUTz9FUaG8Yd9XzCtltvTBh5btJ4Md062 e0XtzAvn94j3qcrWUUs9/h5aYJj1WyfjDRc2XzXDp1kM6+av/4bR/79iKg9neQZiE19BVq x94D0YPCfff5/1n++f+Di2qy3WWhCgE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-yKqkmYf5PXm66gli80bbSQ-1; Mon, 12 Apr 2021 09:19:04 -0400 X-MC-Unique: yKqkmYf5PXm66gli80bbSQ-1 Received: by mail-wm1-f69.google.com with SMTP id v5-20020a05600c2145b029012bdd9ddcb7so254636wml.1 for ; Mon, 12 Apr 2021 06:19:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=7ZXD0Vjr7M6pXQoqoYaNJ9fIJMRtCGqZKUK6a7IbIAM=; b=JDEpoAx5Nxgg6Q/fNs8oCZxJvMldEdXIxgrFMfe3+8YCmitQJkT5XRE43YnSEziKaT KbTfmsYPt2E7mb6cP+GMfwxsBN4OtiWm3asA7sBW8ISCzD/pWuMB9/5tW5tKk5Kw93WL IMLPjZlD/a+SfIuYzelSlkMuovvJPBIuvtAzoEkCvue9mQhh/vitidUoWOHCn41EPuG3 xivxBn057UF21dcTpGFrLmMRhBex7gmJOtMKORUQoRWVlfLOoYY947U3akd/U9YpkXGK n7L2uLWHdzhCkcHq52vhJZ8ZbTEJDom4w+uERvVbEtxEowpB0fxfOWBNOWhzg6kzY8Y9 bwZg== X-Gm-Message-State: AOAM532hjcxrqmPh/wc/KZN0EAB4lfYr1XGdwnsrcZm1+umPtvuqP18X yRSt6uV2b73v2cIz8db4AJ0cLGx/zMzAOFkM9F8m+tzBiivzlrTdItbPy6L/dw8Zq2I90L8ri0j TP7OWsOeIW1U= X-Received: by 2002:a5d:40c1:: with SMTP id b1mr14516026wrq.33.1618233542734; Mon, 12 Apr 2021 06:19:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7xYSMl1mhv7IAg348AjhAJnlfD0ElxtQIBjiZbX8gXBrQUGHbbh/j9IzPlcTzIMjQzJv+hg== X-Received: by 2002:a5d:40c1:: with SMTP id b1mr14515964wrq.33.1618233542418; Mon, 12 Apr 2021 06:19:02 -0700 (PDT) Received: from [192.168.3.132] (p5b0c66cb.dip0.t-ipconnect.de. [91.12.102.203]) by smtp.gmail.com with ESMTPSA id c8sm14836856wmb.34.2021.04.12.06.19.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Apr 2021 06:19:02 -0700 (PDT) Subject: Re: [PATCH v3] drivers: introduce and use WANT_DMA_CMA for soft dependencies on DMA_CMA To: Robin Murphy , 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> <34350446-0e0e-6947-40bd-fabdccdc835f@arm.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Mon, 12 Apr 2021 15:19:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <34350446-0e0e-6947-40bd-fabdccdc835f@arm.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B4840A000395 X-Stat-Signature: j1o3je7d45qt5zd3kr6s5fohaam73a8d Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618233540-9304 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 12.04.21 15:12, Robin Murphy wrote: > 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 knob= s >>>> (e.g., CONFIG_DMA_CMA=3Dn). 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=3DX". 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 >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 While this is no b= uild dependency, etnaviv will only work >>>> correctly >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 on most systems if= CMA and DMA_CMA are enabled. Select both >>>> options >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if available to av= oid users ending up with a non-working GPU >>>> due to >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 a lacking kernel c= onfig. >>>> 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 bec= ause >>>> 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_C= MA >>>> 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 >>>> =C2=A0=C2=A0=C2=A0 "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 oth= ers, >>> 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. >=20 > 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 allocate= d > at runtime - CMA is hardly the only way. Platform-level assumptions > about the presence or not of IOMMUs, memory carveouts, etc., and whethe= r > 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. >=20 > 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. That would mean: if it's not a built-time dependency, don't mention it=20 in Kconfig. If that were true, why do we have have defaults modeled in Kconfig then? IMHO, some part of Kconfig is to give you sane defaults. --=20 Thanks, David / dhildenb