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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D77CC4167B for ; Mon, 27 Nov 2023 09:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232812AbjK0JcK (ORCPT ); Mon, 27 Nov 2023 04:32:10 -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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.