Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp213097rdb; Fri, 6 Oct 2023 00:43:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExJ8Vhqli1UilLnsX6A04bJ8FwCx/BAZc4Ep4FY7qJAtBoS1YeRq0jcGo16AbNIeoHxLAt X-Received: by 2002:a17:90b:1643:b0:268:10a3:cea8 with SMTP id il3-20020a17090b164300b0026810a3cea8mr7165296pjb.9.1696578206450; Fri, 06 Oct 2023 00:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696578206; cv=none; d=google.com; s=arc-20160816; b=TIPcmnbBnq012UiBRlLty6QynG8JF4YqHdO7EAE+6jSVht4MimVSE+f80b7bKxsEwj yVFgWxuTP1tUP7EVzz/gmeyeG1RnUEcgdg/dOcev7/ufvsXNf3wn+G31wBuNnnfywxG1 ewVfrDfXFCwO7r3QzNhBOhgfkclYKAHVo/LRqFjwmWxZXcuLh8/gbaQ0+F6uUDYlwTT6 EzZ7SRgBtwUAkDWIxYrlbjRPcLmxnv6J5scuRV1Up5K3sfPQzZLh9/aDUjGGUewOcJTy hDvxHRwj/yfSBkmaezWy4V3uQtiP6DuHoUi7yWohIyYATnbdZ9ZQcvwgCfxBWWSlTxtF lFBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=VkrU2GrYLj4JhqQ2DECSj7SQp0w6q2lQdQCQFbpLHQY=; fh=JIjIpEq9RN3tD+AmZyj1nFa75VDqHJaZ2jtyLNBH84Y=; b=Px0aPQyJSBheUSBy0JXeGRcrFD3e1/ScBCC2XNGWsh7QCCZcjZPBGouLtYbErY5K8F xhBNWKE1XBtAoY8PjbxvDgiiSJY/otm9aTtDvkLM2kab5Xe0kfnLz0MBpxyZwOqNpN8H cKuSngqL/rJz0dD/UIsU/ufuoFh6JKYFtpap2/ECPCVsAIvQFNKEXKHp7CEbhQDF1+xu IbVAn0VIQHlzaTDv4olIcI7L6BR+z747y5wv6SOXXFEEnECYWdg6e9iH3ic9VIb1FWv/ 9n7Nwse69k8KdgD7hFuEMbwDUgh1RORf8j7tsZmUkN+Z3plaAHcr4fV53okx2uuvUIHB 1i/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ge10-20020a17090b0e0a00b002465d98f18csi5268480pjb.170.2023.10.06.00.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 702338066629; Fri, 6 Oct 2023 00:43:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231169AbjJFHnS (ORCPT + 99 others); Fri, 6 Oct 2023 03:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjJFHm7 (ORCPT ); Fri, 6 Oct 2023 03:42:59 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14DA9386B for ; Fri, 6 Oct 2023 00:40:55 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 0AFDA6732D; Fri, 6 Oct 2023 09:40:46 +0200 (CEST) Date: Fri, 6 Oct 2023 09:40:45 +0200 From: Christoph Hellwig To: Jim Quinlan Cc: Christoph Hellwig , Linus Walleij , 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 Subject: Re: [PATCH v1 1/1] ARM: Select DMA_DIRECT_REMAP to fix restricted DMA Message-ID: <20231006074045.GA15303@lst.de> References: <20230926175208.9298-1-james.quinlan@broadcom.com> <20230926175208.9298-2-james.quinlan@broadcom.com> <20231002061628.GC911@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 06 Oct 2023 00:43:24 -0700 (PDT) On Thu, Oct 05, 2023 at 01:53:33PM -0400, Jim Quinlan wrote: > > Yes, DMA_DIRECT_REMAP should only be used for platforms using the > > generic generic remap that plus straight into dma-direct and > > bypasses arch_dma_alloc. > > > > ARM first needs support to directly set the uncached/wc bits on > > the direct mapping for CMA, which should be fairly simple but require > > wide spread testing. > > > > I'd be happy to work with anyone who wants to look into this. > I'd like to look into this and help make it work for ARCH=arm but you > seem to be saying that you also need help from ARM the company? No, I don't care about companies. I just need someone (singular or plural) to test a wide range of arm systems. Here is my idea for the attack plan: As step 1 ignore the whole CMA direct map issue, and just to the trivial generic dma remap conversion. This should involved: - select DMA_DIRECT_REMAP - provide arch_dma_prep_coherent to flush out all dirty data by calling __dma_clear_buffer - remove the existing arch_dma_alloc/arch_dma_free and all their infrastructure With this things should work fine on any system not using CMA Then attack the CMA direct mapping: - modify the core DMA mapping code so that the ARCH_HAS_DMA_SET_UNCACHED code is only used conditionally I'm not quite sure what the right checks and right place is, but the intent is that it should allow arm to only use that path for CMA allocations. For all existing users of CONFIG_ARCH_HAS_DMA_SET_UNCACHED it should evaluate to a compile-time true to not change the behavior or code generation - then in arm select ARCH_HAS_DMA_SET_UNCACHED and implement arch_dma_set_uncached, arch_dma_clear_uncached and the new helper above