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 E2020C433EF for ; Thu, 24 Feb 2022 14:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235556AbiBXO1i convert rfc822-to-8bit (ORCPT ); Thu, 24 Feb 2022 09:27:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234473AbiBXO1h (ORCPT ); Thu, 24 Feb 2022 09:27:37 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 21FED52E14 for ; Thu, 24 Feb 2022 06:27:06 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-196-WFPNFewdOROHOFf201Jvtg-1; Thu, 24 Feb 2022 14:27:04 +0000 X-MC-Unique: WFPNFewdOROHOFf201Jvtg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Thu, 24 Feb 2022 14:27:02 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Thu, 24 Feb 2022 14:27:02 +0000 From: David Laight To: 'Baoquan He' , Christoph Hellwig CC: "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 Thread-Topic: [PATCH 1/2] dma-mapping: check dma_mask for streaming mapping allocs Thread-Index: AQHYKYhjymqZSBR5G0e43mhWKNvBx6yiv4Mw Date: Thu, 24 Feb 2022 14:27:02 +0000 Message-ID: <1fead34bceda468cbe34077a28c4a4b1@AcuMS.aculab.com> References: <20220219005221.634-22-bhe@redhat.com> <20220219071730.GG26711@lst.de> <20220220084044.GC93179@MiWiFi-R3L-srv> <20220222084530.GA6210@lst.de> <20220222131120.GB10093@lst.de> <20220222155904.GA13323@lst.de> <20220223142555.GA5986@lst.de> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)