Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3349204rdh; Thu, 28 Sep 2023 09:06:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqSqWbI44tmzIvA8t+vHP3G40t/FAPSLkIm3lslYCiUqE4wSHj09nJyVp9KOa79kQQu0I4 X-Received: by 2002:a54:478c:0:b0:3ad:f86a:877b with SMTP id o12-20020a54478c000000b003adf86a877bmr1561449oic.23.1695917188568; Thu, 28 Sep 2023 09:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695917188; cv=none; d=google.com; s=arc-20160816; b=qckhJ4r8Z6thklM2ZV3/VFNfU0wWhx1nBNZojzOrie+cvrBI8aaaqSMF48GGCDljvF OAfvFSMLYCtuIxMC7JfjxwwpfIcAci9Mn5FuuwUF/mCaI9jKl83UHYUPpVnYkuV90ofL p7o3MCw7Hhv9Egzz7KP1J27x/VX5ZrWdvtUVS303hGamInI/Hpdv4TGsdx8lyh+5wS12 TNrjv1o9p3RtaxVmP5SzU08nInZi2V5I17W3d4UYsz3dpcCy03+/t5I9DR8Cw4bAIruO dFAbpySyEJiU1+eNZPf4brDUHJ2h8z3Z/FN7qWiX04n7zo1PfxIqZ8MUnziw1Yn/Wu3O nvUg== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Bra8oGdN2GS4Vd38eoi8zAhSeLghPJr2Vj1m9xjp6xg=; fh=zvaelTYd811++9ei8wYHR4fXNWH4U7Cq5A2oc7pz4fA=; b=rFlDVmFYgWdTNQieaJKza0wQyAeUJc3LoL//Dk8sYXdzgsWSq39Xkunrs7kXglT2No rOpRxFvMwmJCxK7ai47RABF5+qekeiK4SpFK0/Wdv/c0GOiWz2nR4/+adnl+t8NizUZN 0gquQLg7f3/OJQs14i/WtoO9O7b/AHgsZaecAehOPvHip5SLN30+FS0lPau9s6gTxLSa NhlqrqcRSbbm+r15uwWhkwiphJWmwX1Ck+RUp1IE45SC1KcrOlQaVzk9wlQ4hySw9JPL N2F8ACebrXqMLHWm/X/oVDo8pe2ZIAI2RwJcYYhtfx4Py6r1x3OW3Eb1M8uoG0Ryr/+P nsdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d19-20020a637353000000b00578da0d5b6bsi19311791pgn.724.2023.09.28.09.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 09:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 010BA81E5565; Thu, 28 Sep 2023 08:47:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232039AbjI1PrO (ORCPT + 99 others); Thu, 28 Sep 2023 11:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231845AbjI1PrN (ORCPT ); Thu, 28 Sep 2023 11:47:13 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A6A771A1 for ; Thu, 28 Sep 2023 08:47:11 -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 A03C11FB; Thu, 28 Sep 2023 08:47:49 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E8C5D3F59C; Thu, 28 Sep 2023 08:47:08 -0700 (PDT) Message-ID: Date: Thu, 28 Sep 2023 16:47:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v1 1/1] ARM: Select DMA_DIRECT_REMAP to fix restricted DMA Content-Language: en-GB To: Jim Quinlan , Linus Walleij Cc: Christoph Hellwig , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, Russell King , Arnd Bergmann , Geert Uytterhoeven , "Russell King (Oracle)" , Andrew Morton , Jonathan Corbet , Thomas Gleixner , Sebastian Reichel , "Mike Rapoport (IBM)" , Eric DeVolder , Nathan Chancellor , "Kirill A. Shutemov" , Christophe Leroy , "moderated list:ARM PORT" , open list , Claire Chang References: <20230926175208.9298-1-james.quinlan@broadcom.com> <20230926175208.9298-2-james.quinlan@broadcom.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 28 Sep 2023 08:47:53 -0700 (PDT) On 28/09/2023 1:07 pm, Jim Quinlan wrote: > On Wed, Sep 27, 2023 at 7:10 PM Linus Walleij wrote: >> >> Hi Jim, >> >> thanks for your patch! >> >> On Tue, Sep 26, 2023 at 7:52 PM Jim Quinlan wrote: >> >>> Without this commit, the use of dma_alloc_coherent() while >>> using CONFIG_DMA_RESTRICTED_POOL=y breaks devices from working. >>> For example, the common Wifi 7260 chip (iwlwifi) works fine >>> on arm64 with restricted memory but not on arm, unless this >>> commit is applied. >>> >>> Signed-off-by: Jim Quinlan >> >> (...) >>> + select DMA_DIRECT_REMAP >> >> Christoph invented that symbol so he can certainly >> explain what is missing to use this on ARM. >> >> This looks weird to me, because: >>> git grep atomic_pool_init >> arch/arm/mm/dma-mapping.c:static int __init atomic_pool_init(void) >> kernel/dma/pool.c:static int __init dma_atomic_pool_init(void) >> >> Now you have two atomic DMA pools in the kernel, >> and a lot more than that is duplicated. I'm amazed that it >> compiles at all. >> >> Clearly if you want to do this, surely the ARM-specific >> arch/arm/mm/dma-mapping.c and arch/arm/mm/dma-mapping-nommu.c >> needs to be removed at the same time? >> >> However I don't think it's that simple, because Christoph would surely >> had done this a long time ago if it was that simple. > > Hello Linus, > > Yes, this is the reason I used "RFC" as the fix looked too easy to be viable :-) > I debugged it enough to see that the host driver's > writes to the dma_alloc_coherent() region were not appearing in > memory, and that > led me to DMA_DIRECT_REMAP. Oh, another thing - the restricted-dma-pool is really only for streaming DMA - IIRC there can be cases where the emergency fallback of trying to allocate out of the bounce buffer won't work properly. Are you also using an additional shared-dma-pool carveout to satisfy the coherent allocations, per the DT binding? Thanks, Robin.