Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2901746rdh; Mon, 27 Nov 2023 01:32:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUmCoxjAmI8ZW21OeB4l7MoMft3D7fsPfs7iA2flHcIzYcF3wYncTdD9DsPwnBdomU9+du X-Received: by 2002:a05:6a20:8401:b0:18b:9f43:7d75 with SMTP id c1-20020a056a20840100b0018b9f437d75mr11862470pzd.17.1701077545934; Mon, 27 Nov 2023 01:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701077545; cv=none; d=google.com; s=arc-20160816; b=0g68InIB+++gLeQySfL5Lxa4uG0sW62NGl7GVDG2DOrseyH61Dhq6MWWTfZPI8p1wW ItewovMIkLmX8dHaECvhZZx8PdkcoFJ3Tq4FkDzyI4+aeKgojFI3mRx4napM8UYLV8ZI tikar1i85jl4TbseXIN0Yzz/98XRSVOV4aeDTiGn4ydkncG0ZKu0ycIxffi/iXzSRxtu QjcsXMQJrzuI8D5i/8Yx9eB4Qkqide26m8dKO0gmctZPXE/vAD9pILcca03ovFBK6j5y 9siVteA1Gpc0kQthNPJxIUKx77YMnTs1DfdA2pKJyJ+9Sl+vEUb/E0KBY0/pi+kLp1yi ThFw== 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=sCO0bUfj/WCKXamXuR0O5mAbT5U35IyiJiY91M/iI7s=; fh=sIrXup+5VjqjFnNs06heIrZXJu72H9BMLQjYohBrsAI=; b=s2Pxf0G7gjGxKoYWBdiag3UHVsvNx6x7O23ExDIu3xO2KRTTkHu3dvyKl/zYBwwk8v PRRgPyk1WO+iUgA26WOd7s6yDYdre2nzo577FeOQTLKJLDNddVRAhBeBjZxhzvdqhdN9 8nTkzyHSjJgCRDpDb4wXKV5/f697UI38oGh6G+YyfMEHhrhcxUSK92mQhk/vy7zlcTjT mk0KCc9FR7LWyNZ0c0/wxMgiMWUzt55AiG5MnmIqgPODH/W+FKjmA5Rb59i5bWWegjIM VFvcaG2h/fj2z5rBesVP1yNZzrl67+sfMZEJhSQBsEYO3yDqOZh0RKRUvSg2oamE9bPN hDqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g8-20020aa79dc8000000b006c31c0e909dsi8780440pfq.32.2023.11.27.01.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 01:32:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id A51BC806A617; Mon, 27 Nov 2023 01:32:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232801AbjK0JcJ (ORCPT + 99 others); Mon, 27 Nov 2023 04:32:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232686AbjK0JcH (ORCPT ); Mon, 27 Nov 2023 04:32:07 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7825BE for ; Mon, 27 Nov 2023 01:32:13 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 4D49C67373; Mon, 27 Nov 2023 10:32:10 +0100 (CET) Date: Mon, 27 Nov 2023 10:32:10 +0100 From: Christoph Hellwig To: Zhaoyang Huang Cc: Christoph Hellwig , "zhaoyang.huang" , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, steve.kang@unisoc.com Subject: Re: [PATCH] kernel: dma: let dma use vmalloc area Message-ID: <20231127093210.GA3662@lst.de> References: <20231127030930.1074374-1-zhaoyang.huang@unisoc.com> <20231127071430.GA28214@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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 27 Nov 2023 01:32:23 -0800 (PST) On Mon, Nov 27, 2023 at 04:56:45PM +0800, Zhaoyang Huang wrote: > Sorry for the confusion, please find below codes for more information. > dma_init_coherent_memory > memremap > addr = ioremap_wt(offset, size); > What I mean is addr is a vmalloc address, which is implicitly mapped > by dma's framework and not be aware of to the driver. Yes. And it is only returned from dma_alloc_coherent, which should never be passed to dma_map_. > Please correct me if I am wrong. According to my understanding, cache > consistency could be solved inside dma_map_page via either > dma_direct_map_page(swio/arch_sync_dma_for_device) or ops->map_page. > The original thought of rejecting vmalloc is that this pa is not safe > as this mapping could go in any time. What I am suggesting is to let > this kind of va be enrolled. But that only works for the direct mapping. It does not work for the additional aliases created by vmap/ioremap/memremap. Now that only matters if the cache is virtually indexed, which is rather unusual these days.