Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp518804pxm; Fri, 25 Feb 2022 12:47:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyr/j5YWgX8L3ACYIRssXsIchOuhQQWtotDEtbgMwXZxT3+GGFl06o9OuFMBxYR/3RjvNNm X-Received: by 2002:a17:906:a40f:b0:6c9:e255:7926 with SMTP id l15-20020a170906a40f00b006c9e2557926mr7179159ejz.27.1645822025688; Fri, 25 Feb 2022 12:47:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645822025; cv=none; d=google.com; s=arc-20160816; b=v7GY+EvYpUO0X4vyhDM98FuWp7QuH1Xa7knW80IsGo3F2CpU5uI5VpQWZX+OsnCodV 1lwFhxHraCtwNrERZpctBZbfPuz20nOo2ZhiZsNj8xk/+ZAWnqvxBCaPI29zMwJ1WKm3 CM5Hbo3z8826fQHxBWnD//kFfd+M6+f4m5NIXBDrfN0V7oZLn+krbwtgH394dOnTBY6P xwSkUz2lrsXO+jDlG+FwJyLguwtBaYjmdz4J9/z+3K5gmjfH2nRniLJmx5iSVBqhFh8B 0JjQolPxjcYa1xsC5IK2Bp6XU7g8zorZ8wo4NaziCcj4LPaftiuZ+M1LRN+uiHm5MPRI WmLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PKwIaA6vJQ86hsYmx90S5GHPLZ3QnL0/6rDtNGfZPd8=; b=J0791VKebRigxXZ6e4Y66D2cT2+cjNkmNoL/uVki8hhxQtScD98gme3a441N4FFRVH 8J2hJyhxdS8H7J8s7U0r0UEg7ZManibKqcZQDaIilLfwQVqhJQGSpfFul+iz8coy/xAg IvSFD9OC4UeE7QfaSCcGcLYu3fGJAH6oJlp0nYHYzsesUh2az0PnPBp8Lhw2XXI6FdP1 NSGP+qBdT5O+CoPZjMdGRNLxAFTF5C3a/cAvHLkxOJLcRwMGYu2SxQOrXlBMvaI/H5Qn Bv8DfF5vBRQTpvu1GVz0hoZmizyrGZwXHkfmSij2tlEIQeEUWF5xzx0iLGpjbkRNTYNP QI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TbGpEsTo; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v29-20020a17090610dd00b006d08c9350ebsi2006860ejv.640.2022.02.25.12.46.41; Fri, 25 Feb 2022 12:47:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TbGpEsTo; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242252AbiBYPkC (ORCPT + 99 others); Fri, 25 Feb 2022 10:40:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242160AbiBYPj7 (ORCPT ); Fri, 25 Feb 2022 10:39:59 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 604A41CFA37 for ; Fri, 25 Feb 2022 07:39:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645803566; 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: in-reply-to:in-reply-to:references:references; bh=PKwIaA6vJQ86hsYmx90S5GHPLZ3QnL0/6rDtNGfZPd8=; b=TbGpEsToCmR6NIPZ8S6Rl5aG1GEm6rf6XAVHcQa6Zy4yIuHqmmn6a0Myi3v8ZlxxmdB2v0 NzrOaryyK43wQHBhL0mQ54rAIjOS53gKQ++Nv9MF+lJHNO583smCZ3F0TmdpWfTA12RVAk kmlHmtNTpmvzaKjd+wA5mmJeQlV6Atc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-e41bORCJP4O_0wUA4GSfZw-1; Fri, 25 Feb 2022 10:39:23 -0500 X-MC-Unique: e41bORCJP4O_0wUA4GSfZw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4391C1091DA0; Fri, 25 Feb 2022 15:39:19 +0000 (UTC) Received: from localhost (ovpn-12-89.pek2.redhat.com [10.72.12.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 507087F0DB; Fri, 25 Feb 2022 15:39:05 +0000 (UTC) Date: Fri, 25 Feb 2022 23:39:02 +0800 From: 'Baoquan He' To: David Laight Cc: Christoph Hellwig , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "cl@linux.com" , "42.hyeyoo@gmail.com" <42.hyeyoo@gmail.com>, "penberg@kernel.org" , "rientjes@google.com" , "iamjoonsoo.kim@lge.com" , "vbabka@suse.cz" , "david@redhat.com" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" , "linux-crypto@vger.kernel.org" , "steffen.klassert@secunet.com" , "netdev@vger.kernel.org" , "hca@linux.ibm.com" , "gor@linux.ibm.com" , "agordeev@linux.ibm.com" , "borntraeger@linux.ibm.com" , "svens@linux.ibm.com" , "linux-s390@vger.kernel.org" , "michael@walle.cc" , "linux-i2c@vger.kernel.org" , "wsa@kernel.org" Subject: Re: [PATCH 1/2] dma-mapping: check dma_mask for streaming mapping allocs Message-ID: <20220225153902.GA148875@MiWiFi-R3L-srv> References: <20220220084044.GC93179@MiWiFi-R3L-srv> <20220222084530.GA6210@lst.de> <20220222131120.GB10093@lst.de> <20220222155904.GA13323@lst.de> <20220223142555.GA5986@lst.de> <1fead34bceda468cbe34077a28c4a4b1@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1fead34bceda468cbe34077a28c4a4b1@AcuMS.aculab.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 02/24/22 at 02:27pm, David Laight wrote: > From: Baoquan He > > Sent: 24 February 2022 14:11 > ... > > With my understanding, there are two kinds of DMA mapping, coherent > > mapping (which is also persistent mapping), and streaming mapping. The > > coherent mapping will be handled during driver init, and released during > > driver de-init. While streaming mapping will be done when needed at any > > time, and released after usage. > > The lifetime has absolutely nothing to do with it. > > It is all about how the DMA cycles (from the device) interact with > (or more don't interact with) the cpu memory cache. > > For coherent mapping the cpu and device can write to (different) > words in the same cache line at the same time, and both will see > both updates. > On some systems this can only be achieved by making the memory > uncached - which significantly slows down cpu access. > > For non-coherent (streaming) mapping the cpu writes back and/or > invalidates the data cache so that the dma read cycles from memory > read the correct data and the cpu re-reads the cache line after > the dma has completed. > They are only really suitable for data buffers. Thanks for valuable input, I agree the lifetime is not stuff we can rely on to judge. But how do we explain dma_alloc_noncoherent() is not streaming mapping? Then which kind of dma mapping is it? I could miss something important to understand this which is obvious to other people, I will make time to check.